@visulima/vis 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/LICENSE.md +33 -22
- package/dashboard/dist/index.html +12 -12
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +1 -1
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +2 -2
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +168 -170
- package/dist/packem_chunks/doctor-probe.js +2 -2
- package/dist/packem_chunks/fix.js +5 -5
- 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 +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler50.js +4 -4
- package/dist/packem_chunks/handler53.js +1 -1
- package/dist/packem_chunks/handler54.js +1 -1
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler58.js +1 -1
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +5 -5
- package/dist/packem_chunks/handler60.js +1 -1
- package/dist/packem_chunks/handler61.js +7 -7
- package/dist/packem_chunks/handler62.js +1 -1
- package/dist/packem_chunks/handler63.js +1 -1
- package/dist/packem_chunks/handler64.js +2 -2
- package/dist/packem_chunks/handler65.js +2 -2
- package/dist/packem_chunks/handler66.js +1 -1
- package/dist/packem_chunks/handler67.js +25 -24
- package/dist/packem_chunks/handler68.js +153 -25
- package/dist/packem_chunks/handler69.js +10 -153
- package/dist/packem_chunks/handler70.js +22 -10
- package/dist/packem_chunks/handler71.js +4 -4
- package/dist/packem_chunks/handler72.js +3 -3
- package/dist/packem_chunks/handler73.js +6 -6
- package/dist/packem_chunks/handler74.js +1 -1
- package/dist/packem_chunks/handler75.js +1 -1
- package/dist/packem_chunks/handler76.js +1 -1
- package/dist/packem_chunks/handler77.js +40 -40
- package/dist/packem_chunks/handler78.js +20 -20
- package/dist/packem_chunks/heal.js +4 -4
- package/dist/packem_chunks/help-command.js +5 -5
- package/dist/packem_chunks/index4.js +6 -8
- package/dist/packem_chunks/index6.js +5 -5
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/prompts.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/shell-runner.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/tar.js +3 -3
- package/dist/packem_shared/{advisories-CyDqzi5j.js → advisories-0ScpWAHV.js} +1 -1
- package/dist/packem_shared/{affected-selection-DPQR-Bd3.js → affected-selection-BMoQWuHl.js} +1 -1
- package/dist/packem_shared/{ai-fix-6nXZbecQ.js → ai-fix-CKN1JGRh.js} +1 -1
- package/dist/packem_shared/{bin-wafzkjaB.js → bin-CN4heKmb.js} +1 -1
- package/dist/packem_shared/{cyclonedx-C_ezHg8b.js → cyclonedx-B1vzerwP.js} +1 -1
- package/dist/packem_shared/{docker-Br_iFmI-.js → docker-Bex05Qcn.js} +16 -16
- package/dist/packem_shared/giget-D8Kwb0kD.js +2 -0
- package/dist/packem_shared/index.server-BAjDJSEu.js +2 -0
- package/dist/packem_shared/main-BP-w-K-6.js +1 -0
- package/dist/packem_shared/{osv-bloom-5wDAoZ1e.js → osv-bloom-JYIWcH3F.js} +1 -1
- package/dist/packem_shared/{package-version-BJkg7-6H.js → package-version-CJxZ_B7G.js} +3 -3
- package/dist/packem_shared/{project-name-filter-BeREbPMI.js → project-name-filter-DsrVo0MY.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-COmP7eqr.js → resolve-explicit-DYaHAVDg.js} +1 -1
- package/dist/packem_shared/{s1ngularity-RZOHbGrE.js → s1ngularity-C8sva2SO.js} +1 -1
- package/dist/packem_shared/{scan-progress-C9nMDLis.js → scan-progress-5uTRdC1G.js} +2 -2
- package/dist/packem_shared/{spinner-CbJfWYwB.js → spinner-BM_0Bj6x.js} +1 -1
- package/dist/packem_shared/{tabs-BilwonkM.js → tabs-UDYQ3tqt.js} +1 -1
- package/dist/packem_shared/target-merge-B4No-LHM.js +4 -0
- package/dist/packem_shared/{typosquats-D8ppc5kr.js → typosquats-Cdsnf6aN.js} +1 -1
- package/dist/packem_shared/{vis-update-app-ngwL2mRv.js → vis-update-app-zqSa2clT.js} +1 -1
- package/dist/packem_shared/{vis-user-error-jhNwmkZp.js → vis-user-error-Dkc97rGY.js} +1 -1
- package/index.js +26 -26
- package/package.json +14 -14
- package/dist/packem_shared/giget-CVyyR7x8.js +0 -2
- package/dist/packem_shared/index.server-CwSgbeN7.js +0 -2
- package/dist/packem_shared/main-BjJN8kWj.js +0 -1
- package/dist/packem_shared/target-merge-D1xbylFw.js +0 -4
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import{createRequire as lf}from"node:module";import{n as pf,d as ff,m as hf,w as mf,r as gf,i as yf}from"../packem_shared/vis-user-error-jhNwmkZp.js";import{k as tl,e as g,h as sr,m as nt,z as G,l as jt,a as ss,b as vf,U as ln,v as nl}from"../packem_shared/index-DHD8wb6Z.js";import{N as sl,p as le}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{u as k,y,X as V,m as R,S as bf,U as Uo,V as Se,W as wf,Y as kf,Z as He,_ as Sf,$ as xf,a0 as $f,a1 as Ef,a2 as Cf,a3 as Rf,a4 as jf,a5 as Tf,z as il,D as qe,d as Of,a6 as Af,j as Go,i as If,x as Bf,p as ir,F as zo,R as Pf,c as Nf,h as Df,a7 as rr,a8 as or,a9 as Mf,aa as Lf}from"./catalog.js";import{parseStacktrace as _f}from"@visulima/error/stacktrace";import{i as ct}from"../packem_shared/index-BjdW45xX.js";import{y as x}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as ge,h as ft}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{findVisConfigFile as Dt,loadVisConfig as qo}from"./CONFIG_FILES.js";import{S as Jf}from"../packem_shared/index-BisalDCf.js";import{T as Kf}from"../packem_shared/target-merge-D1xbylFw.js";import{s as qf}from"../packem_shared/bin-wafzkjaB.js";import{X as bi,q as Ne,r as Bn,D as Qe,F as tn,T as Yf,t as ni,J as Xf}from"../packem_shared/index.server-CwSgbeN7.js";import{s as ar}from"../packem_shared/index-B4AjSxHU.js";import{g as _s}from"../packem_shared/package-version-BJkg7-6H.js";import{l as ht,k as Yo,ad as th,ae as ll,g as nh,d as mt,af as cr,ag as sh,$ as un,c as Fn,ah as dl}from"../packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js";import{d as Xo}from"../packem_shared/pm-runner-de-jCq8q.js";import{m as ih}from"./ts-loader.js";import{getMainWorktreeRoot as rh,Cache as Fs,readLastRunSummary as ul,getLastRunSummaryPath as lr,parseCacheSize as oh,digestFile as pl}from"@visulima/task-runner";import{e as mh}from"../packem_shared/index-DjTWo3sH.js";let df;const uf=e=>(df??=lf(import.meta.url))(e),Sn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,xe=e=>{if(typeof Sn<"u"&&Sn.versions&&Sn.versions.node){const[t,n]=Sn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Sn.getBuiltinModule(e)}return uf(e)},{createRequire:Be}=xe("node:module"),{spawnSync:en,execSync:rl,execFileSync:Ff,execFile:Vf}=xe("node:child_process"),{writeFileSync:ae,existsSync:Jo,renameSync:ol,statSync:Tt,rmSync:dn,readdirSync:Te,copyFileSync:Hf,unlinkSync:pt,mkdirSync:Wf,cpSync:Uf,readFileSync:Gf,watch:zf}=xe("node:fs"),{dirname:al,delimiter:Ko,resolve:Ls}=xe("node:path"),{createInterface:cl}=xe("node:readline"),{homedir:Zf,platform:Qf,tmpdir:eh}=xe("node:os"),{readFile:fl,readdir:is,stat:gn,realpath:Zo,rm:Kr,mkdtemp:ah,mkdir:ch}=xe("node:fs/promises"),{isIP:lh}=xe("node:net"),{createServer:dh,STATUS_CODES:uh}=xe("node:http"),{Http2ServerRequest:nn,constants:ph}=xe("node:http2"),{Readable:Qo}=xe("node:stream"),{randomUUID:fh}=xe("node:crypto"),{fileURLToPath:hh}=xe("node:url"),gh=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"];let yh;const vh=e=>(yh??=Be(import.meta.url))(e),xn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,hl=e=>{if(typeof xn<"u"&&xn.versions&&xn.versions.node){const[t,n]=xn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return xn.getBuiltinModule(e)}return vh(e)},{execFileSync:bh}=hl("node:child_process"),{existsSync:ea,readFileSync:wh}=hl("node:fs"),kh=[...gh],ta=new Set(["bun","npm","pnpm","yarn"]),ml=e=>{const t=sl(wh(e,"utf8"));return typeof t?.packageManager=="string"?t.packageManager:void 0},Sh=e=>{let t;if(kh.forEach(s=>{!t&&ea(g(e,s))&&(t=g(e,s))}),t)return t;const n=g(e,"package.json");if(ea(n)&&ml(n)!==void 0)return n},xh=e=>{if(!e)throw new sr("Could not find a package manager");if(e.endsWith("package.json")){const t=ml(e);if(t){const n=["npm","yarn","pnpm","bun"].find(s=>t.startsWith(s));if(n)return{packageManager:n,path:nt(e)}}}if(e.endsWith("yarn.lock"))return{packageManager:"yarn",path:nt(e)};if(e.endsWith("package-lock.json")||e.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:nt(e)};if(e.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:nt(e)};if(e.endsWith("bun.lock")||e.endsWith("bun.lockb"))return{packageManager:"bun",path:nt(e)};throw new sr("Could not find a package manager")},$h=e=>{const t=tl(Sh,{...e&&{cwd:e}});return xh(t)},Rj=e=>{if(!ta.has(e))throw new Error(`Unsupported package manager "${e}". Expected one of: ${[...ta].join(", ")}.`);return bh(e,["--version"]).toString("utf8").trim()};let Eh;const Ch=e=>(Eh??=Be(import.meta.url))(e),$n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Rh=e=>{if(typeof $n<"u"&&$n.versions&&$n.versions.node){const[t,n]=$n.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return $n.getBuiltinModule(e)}return Ch(e)},{existsSync:na,readFileSync:jh}=Rh("node:fs"),Th=e=>{let t;try{t=sl(e)}catch{return!1}if(!t||typeof t!="object"||Array.isArray(t))return!1;const{workspaces:n}=t;return typeof n=="object"&&n!==null},gl=e=>{const t=tl(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(t?.endsWith("lerna.json")){const s=le(t);if(s&&typeof s=="object"&&!Array.isArray(s)){const i=s;if(i.useWorkspaces||i.packages)return{path:nt(t),strategy:"lerna"}}}const n=t?.endsWith("turbo.json");try{const{packageManager:s,path:i}=$h(e);if(["npm","yarn"].includes(s)){const r=g(i,"package.json");if(na(r)){const o=jh(g(i,"package.json"),"utf8");if(Th(o))return{path:i,strategy:n?"turbo":s}}}else if(s==="pnpm"){const r=g(i,"pnpm-workspace.yaml");if(na(r))return{path:i,strategy:n?"turbo":"pnpm"}}}catch(s){if(!(s instanceof sr))throw s}throw new Error(`No monorepo root could be found upwards from the directory ${String(e??process.cwd())} using lerna, yarn, pnpm, or npm as indicators.`)};function yl(e,t,n,s){let i,r,o;r=n,o=s;const a=Jf(t,r,o??i);ge(e,a,i)}const Z=(e,t)=>async()=>({default:(await e())[t]}),Oh=new Set(["--cwd"]),Ah=new Set(["--help","--version","-h","-V"]),Ih=e=>{const t=[];for(let n=0;n<e.length;n+=1){const s=e[n];if(s!==void 0){if(Ah.has(s))return!1;if(s.startsWith("-")){const i=s.indexOf("="),r=i===-1?s:s.slice(0,i);if(Oh.has(r)&&i===-1){const o=e[n+1];o!==void 0&&!o.startsWith("-")&&(n+=1)}continue}t.push(s)}}return t.length===1&&t[0]==="migrate"},Bh=e=>{if(e.length===0)return!1;for(const t of e){const n=t.codePointAt(0)??0;return!(n<=127||n<=255)}return!1};let Ph=class{buffer="";timer;onFlush;timeout;constructor({onFlush:t,timeout:n}){this.onFlush=t,this.timeout=n}add(t){this.buffer+=t,this.timer!==void 0&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},this.timeout)}flush(){if(this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer.length>0){const t=this.buffer;this.buffer="",this.onFlush(t)}}destroy(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer=""}};const Nh={disambiguateEscapeCodes:1,reportAllKeysAsEscapeCodes:8,reportAlternateKeys:4,reportAssociatedText:16,reportEventTypes:2};function sa(e){let t=0;for(const n of e)t|=Nh[n];return t}const Ye={alt:2,capsLock:64,ctrl:4,hyper:16,meta:32,numLock:128,shift:1,super:8},Dh="\x1B",de="\x1B[",Mh=";",ia=`${de}?1049h`,ra=`${de}?1049l`,vl=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,Lh=/^(?:msys|cygwin)$/,bl=process,dr=bl?.env??{};!vl&&dr.TERM_PROGRAM;const _h=!vl&&(bl?.platform==="win32"||dr.OSTYPE!==void 0&&Lh.test(dr.OSTYPE)),Fh=(e=1)=>`${de}${String(e)}B`,Ot=`${de}?25l`,Vh=`${de}G`,Hh=(e=1)=>`${de}${String(e)}G`,Wh=(e=1)=>`${de}${String(e)}E`,pn=`${de}?25h`,si=(e,t)=>t===void 0?Hh(e+1):`${de}${String(t+1)}${Mh}${String(e+1)}H`,Vs=(e=1)=>`${de}${String(e)}A`;var Uh=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(Uh||{});const Gh=e=>`${de}${String(e)} q`;var sn=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(sn||{});const Vn=e=>{const t=e>=0&&e<=3?e:0;return`${de}${t===0?"":String(t)}J`};var wl=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(wl||{});const qr=e=>{const t=e>=0&&e<=2?e:0;return`${de}${t===0?"":String(t)}K`},zh=qr(2),Jh=qr(0),$t=e=>{if(e<=0)return"";let t="";for(let n=0;n<e;n+=1)t+=zh,n<e-1&&(t+=Vs());return t+=Vh,t};si(0,0)+Vn(sn.ToEnd);`${qr(wl.EntireLine)}${de}`;const Kh=`${de}H${Vn(sn.EntireScreen)}`;_h?`${Vn(sn.EntireScreen)}${de}`:`${Vn(sn.EntireScreen)}${Vn(sn.EntireScreenAndScrollback)}${de}${Dh}`;let qh=class{code;isDecMode=!0;constructor(t){this.code=t}};const kl=(e,...t)=>{if(t.length===0)return"";const n=e?"l":"h";if(t.length===1){const o=t[0];let a=de;return o.isDecMode&&(a+="?"),a+String(o.code)+n}const s=t.filter(o=>!o.isDecMode).map(o=>o.code),i=t.filter(o=>o.isDecMode).map(o=>o.code);let r="";return s.length>0&&(r+=`${de}${s.join(";")}${n}`),i.length>0&&(r+=`${de}?${i.join(";")}${n}`),r};var Yh=(e=>(e[e.NotRecognized=0]="NotRecognized",e[e.Set=1]="Set",e[e.Reset=2]="Reset",e[e.PermanentlySet=3]="PermanentlySet",e[e.PermanentlyReset=4]="PermanentlyReset",e))(Yh||{});const Sl=e=>new qh(e),xl=(...e)=>kl(!1,...e),$l=(...e)=>kl(!0,...e),El=Sl(2004),Cl=k.createContext({renderThrottleMs:0,subscribe(){return{startTime:0,unsubscribe(){}}}});Cl.displayName="InternalAnimationContext";const Yr=k.createContext({exit(){},suspendTerminal:(()=>Promise.resolve(void 0)),async waitUntilRenderFlush(){}});Yr.displayName="InternalAppContext";const Rl=k.createContext({setCursorPosition(){}});Rl.displayName="InternalCursorContext";let Xh;const Zh=e=>(Xh??=Be(import.meta.url))(e),Gt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Qh=e=>{if(typeof Gt<"u"&&Gt.versions&&Gt.versions.node){const[t,n]=Gt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Gt.getBuiltinModule(e)}return Zh(e)},{existsSync:em,readFileSync:tm}=Qh("node:fs"),{cwd:nm}=Gt,sm=(e,t=2)=>e.replace(/^\t+/gm,n=>" ".repeat(n.length*t)),im=(e,t)=>{const n=[],s=e-t,i=e+t;for(let r=s;r<=i;r++)n.push(r);return n},rm=(e,t,n={})=>{var s;if(typeof e!="string")throw new TypeError("Source code is missing.");if(!t||t<1)throw new TypeError("Line number must start from `1`.");const i=sm(e).split(/\r?\n/);if(!(t>i.length))return im(t,(s=n.around)!==null&&s!==void 0?s:3).filter(r=>i[r-1]!==void 0).map(r=>({line:r,value:i[r-1]}))},wi=e=>{if(!e)return e;const t=nm();return e.replace(`file://${t}/`,"").replace(`${t}/`,"")};function om({error:e}){const t=_f(e),n=new Map,s=t.map(c=>{const l=!c.methodName&&!c.file?`raw:${c.raw}`:`${wi(c.file)??""}:${c.line}:${c.column}:${c.methodName??""}`,d=n.get(l)??0;return n.set(l,d+1),{key:`${l}#${d}`,trace:c}}),i=t[0],r=wi(i?.file);let o,a=0;if(r&&i?.line&&em(r)){const c=tm(r,"utf8");if(o=rm(c,i.line),o)for(const{line:l}of o)a=Math.max(a,String(l).length)}return y.jsxs(V,{flexDirection:"column",padding:1,children:[y.jsxs(V,{children:[y.jsxs(R,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),y.jsxs(R,{children:[" ",e.message]})]}),i&&r?y.jsx(V,{marginTop:1,children:y.jsxs(R,{dimColor:!0,children:[r,":",i.line,":",i.column]})}):null,i&&o?y.jsx(V,{flexDirection:"column",marginTop:1,children:o.map(({line:c,value:l})=>y.jsxs(V,{children:[y.jsx(V,{width:a+1,children:y.jsxs(R,{"aria-label":c===i.line?`Line ${c}, error`:`Line ${c}`,backgroundColor:c===i.line?"red":void 0,color:c===i.line?"white":void 0,dimColor:c!==i.line,children:[String(c).padStart(a," "),":"]})}),y.jsx(R,{backgroundColor:c===i.line?"red":void 0,color:c===i.line?"white":void 0,children:` ${l}`})]},`excerpt-${c}`))}):null,t.length>0?y.jsx(V,{flexDirection:"column",marginTop:1,children:s.map(({key:c,trace:l})=>{const d=wi(l.file)??"";return!l.methodName&&!l.file?y.jsxs(V,{children:[y.jsx(R,{dimColor:!0,children:"- "}),y.jsx(R,{bold:!0,dimColor:!0,children:l.raw})]},c):y.jsxs(V,{children:[y.jsx(R,{dimColor:!0,children:"- "}),y.jsx(R,{bold:!0,dimColor:!0,children:l.methodName??"<anonymous>"}),y.jsxs(R,{"aria-label":`at ${d} line ${l.line} column ${l.column}`,color:"gray",dimColor:!0,children:[" ","(",d,":",l.line,":",l.column,")"]})]},c)})}):null]})}let am=class extends k.PureComponent{static displayName="InternalErrorBoundary";static getDerivedStateFromError(t){return{error:t}}state={error:void 0};componentDidCatch(t){this.props.onError(t)}render(){return this.state.error?y.jsx(om,{error:this.state.error}):this.props.children}};const Xr=k.createContext({activate(){},activeId:void 0,add(){},deactivate(){},disableFocus(){},enableFocus(){},focus(){},focusNext(){},focusPrevious(){},remove(){}});Xr.displayName="InternalFocusContext";const cm=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:jl,jl=cm,Tl=k.createContext({stderr:jl.stderr,write(){}});Tl.displayName="InternalStderrContext";let lm;const dm=e=>(lm??=Be(import.meta.url))(e),zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Ol,um=e=>{if(typeof zt<"u"&&zt.versions&&zt.versions.node){const[t,n]=zt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return zt.getBuiltinModule(e)}return dm(e)},{EventEmitter:pm}=um("node:events"),Ol=zt,ii=k.createContext({internal_eventEmitter:new pm,internal_exitOnCtrlC:!0,isRawModeSupported:!1,setBracketedPasteMode(){},setRawMode(){},stdin:Ol.stdin});ii.displayName="InternalStdinContext";const fm=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Al,Al=fm,Zr=k.createContext({stdout:Al.stdout,write(){}});Zr.displayName="InternalStdoutContext";const hm={bar:6,"blinking-bar":5,"blinking-block":1,"blinking-underline":3,block:2,default:0,underline:4},oa=e=>Gh(hm[e]),Hs=(e,t)=>e?.x!==t?.x||e?.y!==t?.y,rn=(e,t)=>{if(!t)return"";const n=e-t.y;return(n>0?Vs(n):"")+si(t.x)+pn},Il=(e,t)=>{if(!t)return"";const n=e-1-t.y;return(n>0?Fh(n):"")+si(0)},Bl=e=>{const t=e.cursorWasShown?Ot:"",n=Il(e.previousLineCount,e.previousCursorPosition),s=rn(e.visibleLineCount,e.cursorPosition);return t+n+s},Ws=(e,t,n)=>e?Ot+Il(t,n):"";let mm;const gm=e=>(mm??=Be(import.meta.url))(e),En=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ri=e=>{if(typeof En<"u"&&En.versions&&En.versions.node){const[t,n]=En.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return En.getBuiltinModule(e)}return gm(e)},{existsSync:aa}=ri("node:fs"),{createRequire:ym}=ri("node:module"),{dirname:ca,join:ms}=ri("node:path"),{fileURLToPath:vm}=ri("node:url"),bm=12,wm=e=>{const t=ym(e),n=ca(vm(e));let s=n;for(let i=0;i<bm;i+=1){if(aa(ms(s,"package.json"))&&aa(ms(s,"index.js")))return t(ms(s,"index.js"));const r=ca(s);if(r===s)break;s=r}return t(ms(n,"..","index.js"))};let km=class{constructor(t,n){this.target=t,this.contentRect=n}target;contentRect};function Sm(e,t,n=!1){const s=e.resizeObservers&&e.resizeObservers.size>0;if((s||n)&&e.yogaNode){const i=Math.round(e.yogaNode.getComputedWidth()),r=Math.round(e.yogaNode.getComputedHeight());if(!Number.isNaN(i)&&!Number.isNaN(r)){const o=e.internal_lastMeasuredSize;if((o?.width!==i||o.height!==r)&&(e.internal_lastMeasuredSize={height:r,width:i},s)){const a=new km(e,{height:r,width:i});for(const c of e.resizeObservers)t.has(c)||t.set(c,[]),t.get(c).push(a)}}}}let xm;const $m=e=>(xm??=Be(import.meta.url))(e),Jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:it,Qr=e=>{if(typeof Jt<"u"&&Jt.versions&&Jt.versions.node){const[t,n]=Jt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Jt.getBuiltinModule(e)}return $m(e)},it=Jt,{execFileSync:Em}=Qr("node:child_process"),Pn=Qr("node:fs"),Cm=Qr("node:tty"),Pl=80,Nl=24,ur=(e,t,{shell:n,env:s}={})=>Em(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),Os=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),Dl=(e,t)=>{const{columns:n,rows:s}=Os(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===Pl&&s===Nl))return{columns:n,rows:s}},Rm=()=>{if(it.platform!=="linux")return!0;try{const e=Pn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),i=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(i)||i<=0?!1:s===i}catch{return!1}};function jm(){const{env:e,stdout:t,stderr:n}=it;if(t?.columns&&t?.rows)return Os(t.columns,t.rows);if(n?.columns&&n?.rows)return Os(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return Os(e.COLUMNS,e.LINES);const s={columns:Pl,rows:Nl};return it.platform==="win32"?ki()??s:it.platform==="darwin"?la()??ki()??s:la()??ki()??Tm()??s}const la=()=>{try{const e=it.platform==="darwin"?Pn.constants.O_EVTONLY|Pn.constants.O_NONBLOCK:Pn.constants.O_NONBLOCK,{columns:t,rows:n}=Cm.WriteStream(Pn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},ki=()=>{try{const e=ur("tput",["cols"],{env:{TERM:"dumb",...it.env}}),t=ur("tput",["lines"],{env:{TERM:"dumb",...it.env}});if(e&&t)return Dl(e,t)}catch{}},Tm=()=>{try{if(!Rm())return;const e=ur("resize",["-u"]).match(/\d+/g);if(e.length===2)return Dl(e[0],e[1])}catch{}},et=e=>{const{columns:t,rows:n}=e;if(t&&n)return{columns:t,rows:n};const s=jm();return{columns:t||s.columns||80,rows:n||s.rows||24}};let Om;const Am=e=>(Om??=Be(import.meta.url))(e),Kt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,oi=e=>{if(typeof Kt<"u"&&Kt.versions&&Kt.versions.node){const[t,n]=Kt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Kt.getBuiltinModule(e)}return Am(e)},Re=Kt,{env:Si}=Re,{PassThrough:da,Stream:Im}=oi("node:stream"),{Buffer:ua}=oi("node:buffer"),{Console:Bm}=oi("node:console"),{EventEmitter:Pm}=oi("node:events"),pa=e=>e in Si&&Si[e]!=="0"&&Si[e]!=="false",Ml=pa("CI")||pa("CONTINUOUS_INTEGRATION"),fa=["assert","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"];let xi={};const Nm=e=>{const t=new da,n=new da;t.write=i=>{e("stdout",i)},n.write=i=>{e("stderr",i)};const s=new console.Console(t,n);for(const i of fa)xi[i]=console[i],console[i]=s[i];return()=>{for(const i of fa)console[i]=xi[i];xi={}}},on=[];on.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&on.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&on.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const As=e=>!!e&&!0&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",$i=Symbol.for("signal-exit emitter"),Ei=globalThis,Dm=Object.defineProperty.bind(Object);class Mm{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Ei[$i])return Ei[$i];Dm(Ei,$i,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,n){this.listeners[t].push(n)}removeListener(t,n){const s=this.listeners[t],i=s.indexOf(n);i!==-1&&(i===0&&s.length===1?s.length=0:s.splice(i,1))}emit(t,n,s){if(this.emitted[t])return!1;this.emitted[t]=!0;let i=!1;for(const r of this.listeners[t])i=r(n,s)===!0||i;return t==="exit"&&(i=this.emit("afterExit",n,s)||i),i}}let Ll=class{};const Lm=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});class _m extends Ll{onExit(){return()=>{}}load(){}unload(){}}class Fm extends Ll{#e=pr.platform==="win32"?"SIGINT":"SIGHUP";#t=new Mm;#n;#r;#s;#i={};#o=!1;constructor(t){super(),this.#n=t,this.#i={};for(const n of on)this.#i[n]=()=>{const s=this.#n.listeners(n);let{count:i}=this.#t;const r=t;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(i+=r.__signal_exit_emitter__.count),s.length===i){this.unload();const o=this.#t.emit("exit",null,n),a=n==="SIGHUP"?this.#e:n;o||t.kill(t.pid,a)}};this.#s=t.reallyExit,this.#r=t.emit}onExit(t,n){if(!As(this.#n))return()=>{};this.#o===!1&&this.load();const s=n?.alwaysLast?"afterExit":"exit";return this.#t.on(s,t),()=>{this.#t.removeListener(s,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(const t of on)try{const n=this.#i[t];n&&this.#n.on(t,n)}catch{}this.#n.emit=(t,...n)=>this.#c(t,...n),this.#n.reallyExit=t=>this.#a(t)}}unload(){this.#o&&(this.#o=!1,on.forEach(t=>{const n=this.#i[t];if(!n)throw new Error("Listener not defined for signal: "+t);try{this.#n.removeListener(t,n)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#s,this.#t.count-=1)}#a(t){return As(this.#n)?(this.#n.exitCode=t||0,this.#t.emit("exit",this.#n.exitCode,null),this.#s.call(this.#n,this.#n.exitCode)):0}#c(t,...n){const s=this.#r;if(t==="exit"&&As(this.#n)){typeof n[0]=="number"&&(this.#n.exitCode=n[0]);const i=s.call(this.#n,t,...n);return this.#t.emit("exit",this.#n.exitCode,null),i}else return s.call(this.#n,t,...n)}}const pr=globalThis.process,{onExit:Vm}=Lm(As(pr)?new Fm(pr):new _m),Us="\x1B",_l="\x1B[200~",ha="\x1B[201~",Hm=e=>e>=48&&e<=63,Wm=e=>e>=32&&e<=47,Fl=e=>e>=64&&e<=126,Um=(e,t,n)=>{const s=t+n+1;let i=s;for(;i<e.length;i++){const r=e.codePointAt(i);if(r===void 0)return"pending";if(!(Hm(r)||Wm(r))&&!(r===91&&i===s))return Fl(r)?{nextIndex:i+1,sequence:e.slice(t,i+1)}:void 0}return"pending"},Gm=(e,t,n)=>{const s=t+n+2;if(s>e.length)return"pending";const i=e.codePointAt(s-1);if(!(i===void 0||!Fl(i)))return{nextIndex:s,sequence:e.slice(t,s)}},ma=(e,t,n)=>{const s=e[t+n];if(s===void 0)return"pending";if(s==="[")return Um(e,t,n);if(s==="O")return Gm(e,t,n)},zm=(e,t)=>{const n=e.codePointAt(t+1),s=n!==void 0&&n>65535?2:1,i=t+1+s;return{nextIndex:i,sequence:e.slice(t,i)}},Jm=(e,t)=>{if(t===e.length-1)return"pending";if(e[t+1]===Us){if(t+2>=e.length)return"pending";const s=ma(e,t,2);return s==="pending"?"pending":s||{nextIndex:t+2,sequence:e.slice(t,t+2)}}const n=ma(e,t,1);return n==="pending"?"pending":n||zm(e,t)},ga=(e,t)=>{let n=0;for(let s=0;s<e.length;s++){const i=e[s];(i===""||i==="\b")&&(s>n&&t.push(e.slice(n,s)),t.push(i),n=s+1)}n<e.length&&t.push(e.slice(n))},Km=e=>{const t=[];let n=0;const s=i=>({events:t,pending:e.slice(i)});for(;n<e.length;){const i=e.indexOf(Us,n);if(i===-1)return ga(e.slice(n),t),{events:t,pending:""};i>n&&ga(e.slice(n,i),t);const r=Jm(e,i);if(r==="pending")return s(i);if(r.sequence===_l){const o=r.nextIndex,a=e.indexOf(ha,o);if(a===-1)return s(i);t.push({paste:e.slice(o,a)}),n=a+ha.length;continue}t.push(r.sequence),n=r.nextIndex}return{events:t,pending:""}},qm=()=>{let e="";return{flushPendingEscape(){if(!e.startsWith(Us))return;const t=e;return e="",t},hasPendingEscape(){return e.startsWith(Us)&&!e.startsWith(_l)&&e!=="\x1B[200"},push(t){const n=Km(e+t);return e=n.pending,n.events},reset(){e=""}}},Ym=" ",Xm="\x1B[Z",Zm="\x1B",ya=xl(El),Ci=$l(El),Vl=({children:e,exitOnCtrlC:t,interactive:n,onExit:s,onRegisterInputControl:i,onSuspendTerminal:r,onWaitUntilRenderFlush:o,renderThrottleMs:a,setCursorPosition:c,stderr:l,stdin:d,stdout:u,writeToStderr:p,writeToStdout:f})=>{const[h,m]=k.useState(!0),[b,$]=k.useState(void 0),[,v]=k.useState([]),S=k.useRef(0),C=k.useRef([]),P=k.useRef(new Map),j=k.useRef(void 0),B=k.useRef(0),L=k.useRef(!1),D=k.useRef(0),[K]=k.useState(()=>{const M=new Pm;return M.setMaxListeners(1/0),M}),ie=k.useRef(void 0),ee=k.useRef(void 0);ee.current??=qm();const te=k.useRef(void 0),se=k.useRef(!1),_=20,w=k.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=void 0)},[]),A=k.useCallback(()=>{j.current&&(clearTimeout(j.current),j.current=void 0)},[]),W=k.useCallback(()=>{if(A(),P.current.size===0)return;let M=Number.POSITIVE_INFINITY;for(const Y of P.current.values())M=Math.min(M,Y.nextDueTime);const X=Math.max(0,M-performance.now());j.current=setTimeout(()=>{j.current=void 0;const Y=performance.now(),ue=[...P.current.values()];for(const ke of ue){if(Y<ke.nextDueTime)continue;ke.callback(Y);const af=Y-ke.startTime,cf=Math.floor(af/ke.interval)+1;ke.nextDueTime=ke.startTime+cf*ke.interval}W()},X)},[A]),O=k.useCallback((M,X)=>{const Y=performance.now();return P.current.set(M,{callback:M,interval:X,nextDueTime:Y+X,startTime:Y}),W(),{startTime:Y,unsubscribe(){if(P.current.delete(M),P.current.size===0){A();return}W()}}},[A,W]);k.useEffect(()=>()=>{A()},[A]);const I=d.isTTY,T=k.useCallback(()=>{ie.current&&(d.removeListener("readable",ie.current),ie.current=void 0)},[d]),F=k.useCallback(()=>{ee.current?.reset(),w(),T()},[w,T]),H=k.useCallback(()=>{L.current=!1,d.setRawMode(!1),d.unref(),B.current=0,F()},[d,F]),U=k.useCallback(M=>{I&&(B.current>0||L.current)&&H(),s(M)},[I,H,s]),q=k.useCallback(M=>{if(M.includes("")&&t){U();return}M===Zm&&h&&$(X=>{if(!X)return X})},[t,U,h]),N=k.useCallback(M=>{q(M),K.emit("input",M)},[q,K]),J=k.useCallback(()=>{w(),te.current=setTimeout(()=>{te.current=void 0;const M=ee.current.flushPendingEscape();M&&N(M)},_)},[w,N]),oe=k.useCallback(()=>{w();let M;for(;(M=d.read())!==null;){const X=ee.current.push(M);for(const Y of X)if(typeof Y=="string")N(Y);else{if(K.listenerCount("paste")===0){se.current||(se.current=!0,p(`Warning: useInput() received bracketed paste because no usePaste() handler is active. This fallback is deprecated and will be removed in the next major version. Migrate paste handling to usePaste().
|
|
2
|
-
`)),
|
|
1
|
+
import{createRequire as gf}from"node:module";import{n as bf,d as wf,m as kf,w as Sf,r as xf,i as $f}from"../packem_shared/vis-user-error-Dkc97rGY.js";import{k as al,e as g,h as ii,m as nt,z as G,l as Tt,a as rs,b as Ef,U as dn,v as cl}from"../packem_shared/index-DHD8wb6Z.js";import{N as ll,p as le}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{u as k,y,X as V,m as R,S as Cf,U as zo,V as Se,W as Rf,Y as jf,Z as We,_ as Tf,$ as Of,a0 as Af,a1 as If,a2 as Bf,a3 as Pf,a4 as Nf,a5 as Df,z as dl,F as Ke,d as Mf,a6 as Lf,j as Jo,i as _f,x as Ff,p as oi,D as qo,R as Vf,c as Wf,h as Hf,a7 as ai,a8 as ci,a9 as Uf,aa as Gf}from"./catalog.js";import{parseStacktrace as zf}from"@visulima/error/stacktrace";import{i as ct}from"../packem_shared/index-BjdW45xX.js";import{y as x}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as me,h as ft}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{findVisConfigFile as Dt,loadVisConfig as Xo}from"./CONFIG_FILES.js";import{S as eh}from"../packem_shared/index-BisalDCf.js";import{T as th}from"../packem_shared/target-merge-B4No-LHM.js";import{s as nh}from"../packem_shared/bin-CN4heKmb.js";import{X as kr,j as Ne,b as Bn,q as Qe,F as sn,T as sh,t as nr,J as rh}from"../packem_shared/index.server-BAjDJSEu.js";import{s as li}from"../packem_shared/index-B4AjSxHU.js";import{g as Fs}from"../packem_shared/package-version-CJxZ_B7G.js";import{l as ht,k as Zo,ad as ch,ae as ml,g as lh,d as mt,af as di,ag as dh,$ as pn,c as Fn,ah as gl}from"../packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js";import{d as Qo}from"../packem_shared/pm-runner-de-jCq8q.js";import{m as uh}from"./ts-loader.js";import{getMainWorktreeRoot as ph,Cache as Vs,readLastRunSummary as yl,getLastRunSummaryPath as ui,parseCacheSize as fh,digestFile as vl}from"@visulima/task-runner";import{e as Sh}from"../packem_shared/index-DjTWo3sH.js";let yf;const vf=e=>(yf??=gf(import.meta.url))(e),Sn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,xe=e=>{if(typeof Sn<"u"&&Sn.versions&&Sn.versions.node){const[t,n]=Sn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Sn.getBuiltinModule(e)}return vf(e)},{createRequire:Be}=xe("node:module"),{spawnSync:nn,execSync:ul,execFileSync:Jf,execFile:qf}=xe("node:child_process"),{writeFileSync:ae,existsSync:Ko,renameSync:pl,statSync:Ot,rmSync:un,readdirSync:Te,copyFileSync:Kf,unlinkSync:pt,mkdirSync:Yf,cpSync:Xf,readFileSync:Zf,watch:Qf}=xe("node:fs"),{dirname:fl,delimiter:Yo,resolve:_s}=xe("node:path"),{createInterface:hl}=xe("node:readline"),{homedir:ih,platform:oh,tmpdir:ah}=xe("node:os"),{readFile:bl,readdir:is,stat:gn,realpath:ea,rm:Xi,mkdtemp:hh,mkdir:mh}=xe("node:fs/promises"),{isIP:gh}=xe("node:net"),{createServer:yh,STATUS_CODES:vh}=xe("node:http"),{Http2ServerRequest:rn,constants:bh}=xe("node:http2"),{Readable:ta}=xe("node:stream"),{randomUUID:wh}=xe("node:crypto"),{fileURLToPath:kh}=xe("node:url"),xh=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"];let $h;const Eh=e=>($h??=Be(import.meta.url))(e),xn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,wl=e=>{if(typeof xn<"u"&&xn.versions&&xn.versions.node){const[t,n]=xn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return xn.getBuiltinModule(e)}return Eh(e)},{execFileSync:Ch}=wl("node:child_process"),{existsSync:na,readFileSync:Rh}=wl("node:fs"),jh=[...xh],sa=new Set(["bun","npm","pnpm","yarn"]),kl=e=>{const t=ll(Rh(e,"utf8"));return typeof t?.packageManager=="string"?t.packageManager:void 0},Th=e=>{let t;if(jh.forEach(s=>{!t&&na(g(e,s))&&(t=g(e,s))}),t)return t;const n=g(e,"package.json");if(na(n)&&kl(n)!==void 0)return n},Oh=e=>{if(!e)throw new ii("Could not find a package manager");if(e.endsWith("package.json")){const t=kl(e);if(t){const n=["npm","yarn","pnpm","bun"].find(s=>t.startsWith(s));if(n)return{packageManager:n,path:nt(e)}}}if(e.endsWith("yarn.lock"))return{packageManager:"yarn",path:nt(e)};if(e.endsWith("package-lock.json")||e.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:nt(e)};if(e.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:nt(e)};if(e.endsWith("bun.lock")||e.endsWith("bun.lockb"))return{packageManager:"bun",path:nt(e)};throw new ii("Could not find a package manager")},Ah=e=>{const t=al(Th,{...e&&{cwd:e}});return Oh(t)},q3=e=>{if(!sa.has(e))throw new Error(`Unsupported package manager "${e}". Expected one of: ${[...sa].join(", ")}.`);return Ch(e,["--version"]).toString("utf8").trim()};let Ih;const Bh=e=>(Ih??=Be(import.meta.url))(e),$n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ph=e=>{if(typeof $n<"u"&&$n.versions&&$n.versions.node){const[t,n]=$n.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return $n.getBuiltinModule(e)}return Bh(e)},{existsSync:ra,readFileSync:Nh}=Ph("node:fs"),Dh=e=>{let t;try{t=ll(e)}catch{return!1}if(!t||typeof t!="object"||Array.isArray(t))return!1;const{workspaces:n}=t;return typeof n=="object"&&n!==null},Sl=e=>{const t=al(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(t?.endsWith("lerna.json")){const s=le(t);if(s&&typeof s=="object"&&!Array.isArray(s)){const r=s;if(r.useWorkspaces||r.packages)return{path:nt(t),strategy:"lerna"}}}const n=t?.endsWith("turbo.json");try{const{packageManager:s,path:r}=Ah(e);if(["npm","yarn"].includes(s)){const i=g(r,"package.json");if(ra(i)){const o=Nh(g(r,"package.json"),"utf8");if(Dh(o))return{path:r,strategy:n?"turbo":s}}}else if(s==="pnpm"){const i=g(r,"pnpm-workspace.yaml");if(ra(i))return{path:r,strategy:n?"turbo":"pnpm"}}}catch(s){if(!(s instanceof ii))throw s}throw new Error(`No monorepo root could be found upwards from the directory ${String(e??process.cwd())} using lerna, yarn, pnpm, or npm as indicators.`)};function xl(e,t,n,s){let r,i,o;i=n,o=s;const a=eh(t,i,o??r);me(e,a,r)}const Z=(e,t)=>async()=>({default:(await e())[t]}),Mh=new Set(["--cwd"]),Lh=new Set(["--help","--version","-h","-V"]),_h=e=>{const t=[];for(let n=0;n<e.length;n+=1){const s=e[n];if(s!==void 0){if(Lh.has(s))return!1;if(s.startsWith("-")){const r=s.indexOf("="),i=r===-1?s:s.slice(0,r);if(Mh.has(i)&&r===-1){const o=e[n+1];o!==void 0&&!o.startsWith("-")&&(n+=1)}continue}t.push(s)}}return t.length===1&&t[0]==="migrate"},Fh=e=>{if(e.length===0)return!1;for(const t of e){const n=t.codePointAt(0)??0;return!(n<=127||n<=255)}return!1};let Vh=class{buffer="";timer;onFlush;timeout;constructor({onFlush:t,timeout:n}){this.onFlush=t,this.timeout=n}add(t){this.buffer+=t,this.timer!==void 0&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},this.timeout)}flush(){if(this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer.length>0){const t=this.buffer;this.buffer="",this.onFlush(t)}}destroy(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer=""}};const Wh={disambiguateEscapeCodes:1,reportAllKeysAsEscapeCodes:8,reportAlternateKeys:4,reportAssociatedText:16,reportEventTypes:2};function ia(e){let t=0;for(const n of e)t|=Wh[n];return t}const Ye={alt:2,capsLock:64,ctrl:4,hyper:16,meta:32,numLock:128,shift:1,super:8},Hh="\x1B",de="\x1B[",Uh=";",oa=`${de}?1049h`,aa=`${de}?1049l`,$l=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,Gh=/^(?:msys|cygwin)$/,El=process,pi=El?.env??{};!$l&&pi.TERM_PROGRAM;const zh=!$l&&(El?.platform==="win32"||pi.OSTYPE!==void 0&&Gh.test(pi.OSTYPE)),Jh=(e=1)=>`${de}${String(e)}B`,Jn=`${de}?25l`,qh=`${de}G`,Kh=(e=1)=>`${de}${String(e)}G`,Yh=(e=1)=>`${de}${String(e)}E`,qn=`${de}?25h`,sr=(e,t)=>t===void 0?Kh(e+1):`${de}${String(t+1)}${Uh}${String(e+1)}H`,Ws=(e=1)=>`${de}${String(e)}A`;var Xh=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(Xh||{});const Zh=e=>`${de}${String(e)} q`;var on=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(on||{});const Vn=e=>{const t=e>=0&&e<=3?e:0;return`${de}${t===0?"":String(t)}J`};var Cl=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(Cl||{});const Zi=e=>{const t=e>=0&&e<=2?e:0;return`${de}${t===0?"":String(t)}K`},Qh=Zi(2),em=Zi(0),Kn=e=>{if(e<=0)return"";let t="";for(let n=0;n<e;n+=1)t+=Qh,n<e-1&&(t+=Ws());return t+=qh,t};sr(0,0)+Vn(on.ToEnd);`${Zi(Cl.EntireLine)}${de}`;const tm=`${de}H${Vn(on.EntireScreen)}`;zh?`${Vn(on.EntireScreen)}${de}`:`${Vn(on.EntireScreen)}${Vn(on.EntireScreenAndScrollback)}${de}${Hh}`;let nm=class{code;isDecMode=!0;constructor(t){this.code=t}};const Rl=(e,...t)=>{if(t.length===0)return"";const n=e?"l":"h";if(t.length===1){const o=t[0];let a=de;return o.isDecMode&&(a+="?"),a+String(o.code)+n}const s=t.filter(o=>!o.isDecMode).map(o=>o.code),r=t.filter(o=>o.isDecMode).map(o=>o.code);let i="";return s.length>0&&(i+=`${de}${s.join(";")}${n}`),r.length>0&&(i+=`${de}?${r.join(";")}${n}`),i};var sm=(e=>(e[e.NotRecognized=0]="NotRecognized",e[e.Set=1]="Set",e[e.Reset=2]="Reset",e[e.PermanentlySet=3]="PermanentlySet",e[e.PermanentlyReset=4]="PermanentlyReset",e))(sm||{});const jl=e=>new nm(e),Tl=(...e)=>Rl(!1,...e),Ol=(...e)=>Rl(!0,...e),Al=jl(2004),rm={aliceblue:"f0f8ff",antiquewhite:"faebd7",antiquewhite1:"ffefdb",antiquewhite2:"eedfcc",antiquewhite3:"cdc0b0",antiquewhite4:"8b8378",aqua:"00ffff",aquamarine:"7fffd4",aquamarine1:"7fffd4",aquamarine2:"76eec6",aquamarine3:"66cdaa",aquamarine4:"458b74",azure:"f0ffff",azure1:"f0ffff",azure2:"e0eeee",azure3:"c1cdcd",azure4:"838b8b",beige:"f5f5dc",bisque:"ffe4c4",bisque1:"ffe4c4",bisque2:"eed5b7",bisque3:"cdb79e",bisque4:"8b7d6b",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blue1:"0000ff",blue2:"0000ee",blue3:"0000cd",blue4:"00008b",blueviolet:"8a2be2",brown:"a52a2a",brown1:"ff4040",brown2:"ee3b3b",brown3:"cd3333",brown4:"8b2323",burlywood:"deb887",burlywood1:"ffd39b",burlywood2:"eec591",burlywood3:"cdaa7d",burlywood4:"8b7355",cadetblue:"5f9ea0",cadetblue1:"98f5ff",cadetblue2:"8ee5ee",cadetblue3:"7ac5cd",cadetblue4:"53868b",chartreuse:"7fff00",chartreuse1:"7fff00",chartreuse2:"76ee00",chartreuse3:"66cd00",chartreuse4:"458b00",chocolate:"d2691e",chocolate1:"ff7f24",chocolate2:"ee7621",chocolate3:"cd661d",chocolate4:"8b4513",coral:"ff7f50",coral1:"ff7256",coral2:"ee6a50",coral3:"cd5b45",coral4:"8b3e2f",cornflowerblue:"6495ed",cornsilk:"fff8dc",cornsilk1:"fff8dc",cornsilk2:"eee8cd",cornsilk3:"cdc8b1",cornsilk4:"8b8878",crimson:"dc143c",cyan:"00ffff",cyan1:"00ffff",cyan2:"00eeee",cyan3:"00cdcd",cyan4:"008b8b",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgoldenrod1:"ffb90f",darkgoldenrod2:"eead0e",darkgoldenrod3:"cd950c",darkgoldenrod4:"8b6508",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkolivegreen1:"caff70",darkolivegreen2:"bcee68",darkolivegreen3:"a2cd5a",darkolivegreen4:"6e8b3d",darkorange:"ff8c00",darkorange1:"ff7f00",darkorange2:"ee7600",darkorange3:"cd6600",darkorange4:"8b4500",darkorchid:"9932cc",darkorchid1:"bf3eff",darkorchid2:"b23aee",darkorchid3:"9a32cd",darkorchid4:"68228b",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkseagreen1:"c1ffc1",darkseagreen2:"b4eeb4",darkseagreen3:"9bcd9b",darkseagreen4:"698b69",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategray1:"97ffff",darkslategray2:"8deeee",darkslategray3:"79cdcd",darkslategray4:"528b8b",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deeppink1:"ff1493",deeppink2:"ee1289",deeppink3:"cd1076",deeppink4:"8b0a50",deepskyblue:"00bfff",deepskyblue1:"00bfff",deepskyblue2:"00b2ee",deepskyblue3:"009acd",deepskyblue4:"00688b",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",dodgerblue1:"1e90ff",dodgerblue2:"1c86ee",dodgerblue3:"1874cd",dodgerblue4:"104e8b",firebrick:"b22222",firebrick1:"ff3030",firebrick2:"ee2c2c",firebrick3:"cd2626",firebrick4:"8b1a1a",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",gold1:"ffd700",gold2:"eec900",gold3:"cdad00",gold4:"8b7500",goldenrod:"daa520",goldenrod1:"ffc125",goldenrod2:"eeb422",goldenrod3:"cd9b1d",goldenrod4:"8b6914",gray:"bebebe",gray0:"000000",gray1:"030303",gray2:"050505",gray3:"080808",gray4:"0a0a0a",gray5:"0d0d0d",gray6:"0f0f0f",gray7:"121212",gray8:"141414",gray9:"171717",gray10:"1a1a1a",gray11:"1c1c1c",gray12:"1f1f1f",gray13:"212121",gray14:"242424",gray15:"262626",gray16:"292929",gray17:"2b2b2b",gray18:"2e2e2e",gray19:"303030",gray20:"333333",gray21:"363636",gray22:"383838",gray23:"3b3b3b",gray24:"3d3d3d",gray25:"404040",gray26:"424242",gray27:"454545",gray28:"474747",gray29:"4a4a4a",gray30:"4d4d4d",gray31:"4f4f4f",gray32:"525252",gray33:"545454",gray34:"575757",gray35:"595959",gray36:"5c5c5c",gray37:"5e5e5e",gray38:"616161",gray39:"636363",gray40:"666666",gray41:"696969",gray42:"6b6b6b",gray43:"6e6e6e",gray44:"707070",gray45:"737373",gray46:"757575",gray47:"787878",gray48:"7a7a7a",gray49:"7d7d7d",gray50:"7f7f7f",gray51:"828282",gray52:"858585",gray53:"878787",gray54:"8a8a8a",gray55:"8c8c8c",gray56:"8f8f8f",gray57:"919191",gray58:"949494",gray59:"969696",gray60:"999999",gray61:"9c9c9c",gray62:"9e9e9e",gray63:"a1a1a1",gray64:"a3a3a3",gray65:"a6a6a6",gray66:"a8a8a8",gray67:"ababab",gray68:"adadad",gray69:"b0b0b0",gray70:"b3b3b3",gray71:"b5b5b5",gray72:"b8b8b8",gray73:"bababa",gray74:"bdbdbd",gray75:"bfbfbf",gray76:"c2c2c2",gray77:"c4c4c4",gray78:"c7c7c7",gray79:"c9c9c9",gray80:"cccccc",gray81:"cfcfcf",gray82:"d1d1d1",gray83:"d4d4d4",gray84:"d6d6d6",gray85:"d9d9d9",gray86:"dbdbdb",gray87:"dedede",gray88:"e0e0e0",gray89:"e3e3e3",gray90:"e5e5e5",gray91:"e8e8e8",gray92:"ebebeb",gray93:"ededed",gray94:"f0f0f0",gray95:"f2f2f2",gray96:"f5f5f5",gray97:"f7f7f7",gray98:"fafafa",gray99:"fcfcfc",gray100:"ffffff",green:"00ff00",green1:"00ff00",green2:"00ee00",green3:"00cd00",green4:"008b00",greenyellow:"adff2f",grey:"bebebe",grey0:"000000",grey1:"030303",grey2:"050505",grey3:"080808",grey4:"0a0a0a",grey5:"0d0d0d",grey6:"0f0f0f",grey7:"121212",grey8:"141414",grey9:"171717",grey10:"1a1a1a",grey11:"1c1c1c",grey12:"1f1f1f",grey13:"212121",grey14:"242424",grey15:"262626",grey16:"292929",grey17:"2b2b2b",grey18:"2e2e2e",grey19:"303030",grey20:"333333",grey21:"363636",grey22:"383838",grey23:"3b3b3b",grey24:"3d3d3d",grey25:"404040",grey26:"424242",grey27:"454545",grey28:"474747",grey29:"4a4a4a",grey30:"4d4d4d",grey31:"4f4f4f",grey32:"525252",grey33:"545454",grey34:"575757",grey35:"595959",grey36:"5c5c5c",grey37:"5e5e5e",grey38:"616161",grey39:"636363",grey40:"666666",grey41:"696969",grey42:"6b6b6b",grey43:"6e6e6e",grey44:"707070",grey45:"737373",grey46:"757575",grey47:"787878",grey48:"7a7a7a",grey49:"7d7d7d",grey50:"7f7f7f",grey51:"828282",grey52:"858585",grey53:"878787",grey54:"8a8a8a",grey55:"8c8c8c",grey56:"8f8f8f",grey57:"919191",grey58:"949494",grey59:"969696",grey60:"999999",grey61:"9c9c9c",grey62:"9e9e9e",grey63:"a1a1a1",grey64:"a3a3a3",grey65:"a6a6a6",grey66:"a8a8a8",grey67:"ababab",grey68:"adadad",grey69:"b0b0b0",grey70:"b3b3b3",grey71:"b5b5b5",grey72:"b8b8b8",grey73:"bababa",grey74:"bdbdbd",grey75:"bfbfbf",grey76:"c2c2c2",grey77:"c4c4c4",grey78:"c7c7c7",grey79:"c9c9c9",grey80:"cccccc",grey81:"cfcfcf",grey82:"d1d1d1",grey83:"d4d4d4",grey84:"d6d6d6",grey85:"d9d9d9",grey86:"dbdbdb",grey87:"dedede",grey88:"e0e0e0",grey89:"e3e3e3",grey90:"e5e5e5",grey91:"e8e8e8",grey92:"ebebeb",grey93:"ededed",grey94:"f0f0f0",grey95:"f2f2f2",grey96:"f5f5f5",grey97:"f7f7f7",grey98:"fafafa",grey99:"fcfcfc",grey100:"ffffff",honeydew:"f0fff0",honeydew1:"f0fff0",honeydew2:"e0eee0",honeydew3:"c1cdc1",honeydew4:"838b83",hotpink:"ff69b4",hotpink1:"ff6eb4",hotpink2:"ee6aa7",hotpink3:"cd6090",hotpink4:"8b3a62",indianred:"cd5c5c",indianred1:"ff6a6a",indianred2:"ee6363",indianred3:"cd5555",indianred4:"8b3a3a",indigo:"4b0082",ivory:"fffff0",ivory1:"fffff0",ivory2:"eeeee0",ivory3:"cdcdc1",ivory4:"8b8b83",khaki:"f0e68c",khaki1:"fff68f",khaki2:"eee685",khaki3:"cdc673",khaki4:"8b864e",lavender:"e6e6fa",lavenderblush:"fff0f5",lavenderblush1:"fff0f5",lavenderblush2:"eee0e5",lavenderblush3:"cdc1c5",lavenderblush4:"8b8386",lawngreen:"7cfc00",lemonchiffon:"fffacd",lemonchiffon1:"fffacd",lemonchiffon2:"eee9bf",lemonchiffon3:"cdc9a5",lemonchiffon4:"8b8970",lightblue:"add8e6",lightblue1:"bfefff",lightblue2:"b2dfee",lightblue3:"9ac0cd",lightblue4:"68838b",lightcoral:"f08080",lightcyan:"e0ffff",lightcyan1:"e0ffff",lightcyan2:"d1eeee",lightcyan3:"b4cdcd",lightcyan4:"7a8b8b",lightgoldenrod:"eedd82",lightgoldenrod1:"ffec8b",lightgoldenrod2:"eedc82",lightgoldenrod3:"cdbe70",lightgoldenrod4:"8b814c",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightpink1:"ffaeb9",lightpink2:"eea2ad",lightpink3:"cd8c95",lightpink4:"8b5f65",lightsalmon:"ffa07a",lightsalmon1:"ffa07a",lightsalmon2:"ee9572",lightsalmon3:"cd8162",lightsalmon4:"8b5742",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightskyblue1:"b0e2ff",lightskyblue2:"a4d3ee",lightskyblue3:"8db6cd",lightskyblue4:"607b8b",lightslateblue:"8470ff",lightslategray:"778899",lightslategrey:"778899",lightsteelblue:"b0c4de",lightsteelblue1:"cae1ff",lightsteelblue2:"bcd2ee",lightsteelblue3:"a2b5cd",lightsteelblue4:"6e7b8b",lightyellow:"ffffe0",lightyellow1:"ffffe0",lightyellow2:"eeeed1",lightyellow3:"cdcdb4",lightyellow4:"8b8b7a",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",magenta1:"ff00ff",magenta2:"ee00ee",magenta3:"cd00cd",magenta4:"8b008b",maroon:"b03060",maroon1:"ff34b3",maroon2:"ee30a7",maroon3:"cd2990",maroon4:"8b1c62",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumorchid1:"e066ff",mediumorchid2:"d15fee",mediumorchid3:"b452cd",mediumorchid4:"7a378b",mediumpurple:"9370db",mediumpurple1:"ab82ff",mediumpurple2:"9f79ee",mediumpurple3:"8968cd",mediumpurple4:"5d478b",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",mistyrose1:"ffe4e1",mistyrose2:"eed5d2",mistyrose3:"cdb7b5",mistyrose4:"8b7d7b",moccasin:"ffe4b5",navajowhite:"ffdead",navajowhite1:"ffdead",navajowhite2:"eecfa1",navajowhite3:"cdb38b",navajowhite4:"8b795e",navy:"000080",navyblue:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",olivedrab1:"c0ff3e",olivedrab2:"b3ee3a",olivedrab3:"9acd32",olivedrab4:"698b22",orange:"ffa500",orange1:"ffa500",orange2:"ee9a00",orange3:"cd8500",orange4:"8b5a00",orangered:"ff4500",orangered1:"ff4500",orangered2:"ee4000",orangered3:"cd3700",orangered4:"8b2500",orchid:"da70d6",orchid1:"ff83fa",orchid2:"ee7ae9",orchid3:"cd69c9",orchid4:"8b4789",palegoldenrod:"eee8aa",palegreen:"98fb98",palegreen1:"9aff9a",palegreen2:"90ee90",palegreen3:"7ccd7c",palegreen4:"548b54",paleturquoise:"afeeee",paleturquoise1:"bbffff",paleturquoise2:"aeeeee",paleturquoise3:"96cdcd",paleturquoise4:"668b8b",palevioletred:"db7093",palevioletred1:"ff82ab",palevioletred2:"ee799f",palevioletred3:"cd6889",palevioletred4:"8b475d",papayawhip:"ffefd5",peachpuff:"ffdab9",peachpuff1:"ffdab9",peachpuff2:"eecbad",peachpuff3:"cdaf95",peachpuff4:"8b7765",peru:"cd853f",pink:"ffc0cb",pink1:"ffb5c5",pink2:"eea9b8",pink3:"cd919e",pink4:"8b636c",plum:"dda0dd",plum1:"ffbbff",plum2:"eeaeee",plum3:"cd96cd",plum4:"8b668b",powderblue:"b0e0e6",purple:"a020f0",purple1:"9b30ff",purple2:"912cee",purple3:"7d26cd",purple4:"551a8b",rebeccapurple:"663399",red:"ff0000",red1:"ff0000",red2:"ee0000",red3:"cd0000",red4:"8b0000",rosybrown:"bc8f8f",rosybrown1:"ffc1c1",rosybrown2:"eeb4b4",rosybrown3:"cd9b9b",rosybrown4:"8b6969",royalblue:"4169e1",royalblue1:"4876ff",royalblue2:"436eee",royalblue3:"3a5fcd",royalblue4:"27408b",saddlebrown:"8b4513",salmon:"fa8072",salmon1:"ff8c69",salmon2:"ee8262",salmon3:"cd7054",salmon4:"8b4c39",sandybrown:"f4a460",seagreen:"2e8b57",seagreen1:"54ff9f",seagreen2:"4eee94",seagreen3:"43cd80",seagreen4:"2e8b57",seashell:"fff5ee",seashell1:"fff5ee",seashell2:"eee5de",seashell3:"cdc5bf",seashell4:"8b8682",sienna:"a0522d",sienna1:"ff8247",sienna2:"ee7942",sienna3:"cd6839",sienna4:"8b4726",silver:"c0c0c0",skyblue:"87ceeb",skyblue1:"87ceff",skyblue2:"7ec0ee",skyblue3:"6ca6cd",skyblue4:"4a708b",slateblue:"6a5acd",slateblue1:"836fff",slateblue2:"7a67ee",slateblue3:"6959cd",slateblue4:"473c8b",slategray:"708090",slategray1:"c6e2ff",slategray2:"b9d3ee",slategray3:"9fb6cd",slategray4:"6c7b8b",slategrey:"708090",snow:"fffafa",snow1:"fffafa",snow2:"eee9e9",snow3:"cdc9c9",snow4:"8b8989",springgreen:"00ff7f",springgreen1:"00ff7f",springgreen2:"00ee76",springgreen3:"00cd66",springgreen4:"008b45",steelblue:"4682b4",steelblue1:"63b8ff",steelblue2:"5cacee",steelblue3:"4f94cd",steelblue4:"36648b",tan:"d2b48c",tan1:"ffa54f",tan2:"ee9a49",tan3:"cd853f",tan4:"8b5a2b",teal:"008080",thistle:"d8bfd8",thistle1:"ffe1ff",thistle2:"eed2ee",thistle3:"cdb5cd",thistle4:"8b7b8b",tomato:"ff6347",tomato1:"ff6347",tomato2:"ee5c42",tomato3:"cd4f39",tomato4:"8b3626",turquoise:"40e0d0",turquoise1:"00f5ff",turquoise2:"00e5ee",turquoise3:"00c5cd",turquoise4:"00868b",violet:"ee82ee",violetred:"d02090",violetred1:"ff3e96",violetred2:"ee3a8c",violetred3:"cd3278",violetred4:"8b2252",webgray:"808080",webgreen:"008000",webgrey:"808080",webmaroon:"800000",webpurple:"800080",wheat:"f5deb3",wheat1:"ffe7ba",wheat2:"eed8ae",wheat3:"cdba96",wheat4:"8b7e66",white:"ffffff",whitesmoke:"f5f5f5",x11gray:"bebebe",x11green:"00ff00",x11grey:"bebebe",x11maroon:"b03060",x11purple:"a020f0",yellow:"ffff00",yellow1:"ffff00",yellow2:"eeee00",yellow3:"cdcd00",yellow4:"8b8b00",yellowgreen:"9acd32"},im=e=>{const t=rm[e.toLowerCase().replaceAll(" ","")];return t===void 0?void 0:`#${t}`},om=/^rgba?:([\da-f]{1,4})\/([\da-f]{1,4})\/([\da-f]{1,4})(?:\/[\da-f]{1,4})?$/i,am=/^#((?:[\da-f]{3}){1,4})$/i,Vt=e=>{const t=16**e.length-1;return Math.round(Number.parseInt(e,16)/t*255)},cm=e=>{const t=e.trim(),n=om.exec(t);if(n)return{b:Vt(n[3]),g:Vt(n[2]),r:Vt(n[1])};const s=t.startsWith("#")?t:im(t);if(s===void 0)return;const r=am.exec(s);if(!r)return;const i=r[1],o=i.length/3;return{b:Vt(i.slice(o*2)),g:Vt(i.slice(o,o*2)),r:Vt(i.slice(0,o))}},Il=k.createContext({renderThrottleMs:0,subscribe(){return{startTime:0,unsubscribe(){}}}});Il.displayName="InternalAnimationContext";const Qi=k.createContext({exit(){},suspendTerminal:(()=>Promise.resolve(void 0)),async waitUntilRenderFlush(){}});Qi.displayName="InternalAppContext";const Bl=k.createContext({setCursorPosition(){}});Bl.displayName="InternalCursorContext";let lm;const dm=e=>(lm??=Be(import.meta.url))(e),Gt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,um=e=>{if(typeof Gt<"u"&&Gt.versions&&Gt.versions.node){const[t,n]=Gt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Gt.getBuiltinModule(e)}return dm(e)},{existsSync:pm,readFileSync:fm}=um("node:fs"),{cwd:hm}=Gt,mm=(e,t=2)=>e.replace(/^\t+/gm,n=>" ".repeat(n.length*t)),gm=(e,t)=>{const n=[],s=e-t,r=e+t;for(let i=s;i<=r;i++)n.push(i);return n},ym=(e,t,n={})=>{var s;if(typeof e!="string")throw new TypeError("Source code is missing.");if(!t||t<1)throw new TypeError("Line number must start from `1`.");const r=mm(e).split(/\r?\n/);if(!(t>r.length))return gm(t,(s=n.around)!==null&&s!==void 0?s:3).filter(i=>r[i-1]!==void 0).map(i=>({line:i,value:r[i-1]}))},Sr=e=>{if(!e)return e;const t=hm();return e.replace(`file://${t}/`,"").replace(`${t}/`,"")};function vm({error:e}){const t=zf(e),n=new Map,s=t.map(c=>{const l=!c.methodName&&!c.file?`raw:${c.raw}`:`${Sr(c.file)??""}:${c.line}:${c.column}:${c.methodName??""}`,d=n.get(l)??0;return n.set(l,d+1),{key:`${l}#${d}`,trace:c}}),r=t[0],i=Sr(r?.file);let o,a=0;if(i&&r?.line&&pm(i)){const c=fm(i,"utf8");if(o=ym(c,r.line),o)for(const{line:l}of o)a=Math.max(a,String(l).length)}return y.jsxs(V,{flexDirection:"column",padding:1,children:[y.jsxs(V,{children:[y.jsxs(R,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),y.jsxs(R,{children:[" ",e.message]})]}),r&&i?y.jsx(V,{marginTop:1,children:y.jsxs(R,{dimColor:!0,children:[i,":",r.line,":",r.column]})}):null,r&&o?y.jsx(V,{flexDirection:"column",marginTop:1,children:o.map(({line:c,value:l})=>y.jsxs(V,{children:[y.jsx(V,{width:a+1,children:y.jsxs(R,{"aria-label":c===r.line?`Line ${c}, error`:`Line ${c}`,backgroundColor:c===r.line?"red":void 0,color:c===r.line?"white":void 0,dimColor:c!==r.line,children:[String(c).padStart(a," "),":"]})}),y.jsx(R,{backgroundColor:c===r.line?"red":void 0,color:c===r.line?"white":void 0,children:` ${l}`})]},`excerpt-${c}`))}):null,t.length>0?y.jsx(V,{flexDirection:"column",marginTop:1,children:s.map(({key:c,trace:l})=>{const d=Sr(l.file)??"";return!l.methodName&&!l.file?y.jsxs(V,{children:[y.jsx(R,{dimColor:!0,children:"- "}),y.jsx(R,{bold:!0,dimColor:!0,children:l.raw})]},c):y.jsxs(V,{children:[y.jsx(R,{dimColor:!0,children:"- "}),y.jsx(R,{bold:!0,dimColor:!0,children:l.methodName??"<anonymous>"}),y.jsxs(R,{"aria-label":`at ${d} line ${l.line} column ${l.column}`,color:"gray",dimColor:!0,children:[" ","(",d,":",l.line,":",l.column,")"]})]},c)})}):null]})}let bm=class extends k.PureComponent{static displayName="InternalErrorBoundary";static getDerivedStateFromError(t){return{error:t}}state={error:void 0};componentDidCatch(t){this.props.onError(t)}render(){return this.state.error?y.jsx(vm,{error:this.state.error}):this.props.children}};const eo=k.createContext({activate(){},activeId:void 0,add(){},deactivate(){},disableFocus(){},enableFocus(){},focus(){},focusNext(){},focusPrevious(){},remove(){}});eo.displayName="InternalFocusContext";const wm=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Pl,Pl=wm,Nl=k.createContext({stderr:Pl.stderr,write(){}});Nl.displayName="InternalStderrContext";let km;const Sm=e=>(km??=Be(import.meta.url))(e),zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Dl,xm=e=>{if(typeof zt<"u"&&zt.versions&&zt.versions.node){const[t,n]=zt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return zt.getBuiltinModule(e)}return Sm(e)},{EventEmitter:$m}=xm("node:events"),Dl=zt,rr=k.createContext({internal_eventEmitter:new $m,internal_exitOnCtrlC:!0,isRawModeSupported:!1,setBracketedPasteMode(){},setRawMode(){},stdin:Dl.stdin});rr.displayName="InternalStdinContext";const Em=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Ml,Ml=Em,to=k.createContext({stdout:Ml.stdout,write(){}});to.displayName="InternalStdoutContext";const Cm={bar:6,"blinking-bar":5,"blinking-block":1,"blinking-underline":3,block:2,default:0,underline:4},ca=e=>Zh(Cm[e]),la=(e,t)=>e?.x!==t?.x||e?.y!==t?.y,ir=(e,t)=>{if(!t)return"";const n=e-t.y;return(n>0?Ws(n):"")+sr(t.x)+qn},Ll=(e,t)=>{if(!t)return"";const n=e-1-t.y;return(n>0?Jh(n):"")+sr(0)},Rm=e=>{const t=e.cursorWasShown?Jn:"",n=Ll(e.previousLineCount,e.previousCursorPosition),s=ir(e.visibleLineCount,e.cursorPosition);return t+n+s},da=(e,t,n)=>e?Jn+Ll(t,n):"";let jm;const Tm=e=>(jm??=Be(import.meta.url))(e),En=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,or=e=>{if(typeof En<"u"&&En.versions&&En.versions.node){const[t,n]=En.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return En.getBuiltinModule(e)}return Tm(e)},{existsSync:ua}=or("node:fs"),{createRequire:Om}=or("node:module"),{dirname:pa,join:gs}=or("node:path"),{fileURLToPath:Am}=or("node:url"),Im=12,Bm=e=>{const t=Om(e),n=pa(Am(e));let s=n;for(let r=0;r<Im;r+=1){if(ua(gs(s,"package.json"))&&ua(gs(s,"index.js")))return t(gs(s,"index.js"));const i=pa(s);if(i===s)break;s=i}return t(gs(n,"..","index.js"))},ys=new WeakMap,Pm=async(e,t)=>(await e,t()),_l=(e,t)=>{const n=ys.get(e),s=n===void 0?t():Pm(n,t);let r;return r=(async()=>{try{await s}catch{}ys.get(e)===r&&ys.delete(e)})(),ys.set(e,r),s};let Nm=class{constructor(t,n){this.target=t,this.contentRect=n}target;contentRect};function Dm(e,t,n=!1){const s=e.resizeObservers&&e.resizeObservers.size>0;if((s||n)&&e.yogaNode){const r=Math.round(e.yogaNode.getComputedWidth()),i=Math.round(e.yogaNode.getComputedHeight());if(!Number.isNaN(r)&&!Number.isNaN(i)){const o=e.internal_lastMeasuredSize;if((o?.width!==r||o.height!==i)&&(e.internal_lastMeasuredSize={height:i,width:r},s)){const a=new Nm(e,{height:i,width:r});for(const c of e.resizeObservers)t.has(c)||t.set(c,[]),t.get(c).push(a)}}}}let Mm;const Lm=e=>(Mm??=Be(import.meta.url))(e),Jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:rt,no=e=>{if(typeof Jt<"u"&&Jt.versions&&Jt.versions.node){const[t,n]=Jt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Jt.getBuiltinModule(e)}return Lm(e)},rt=Jt,{execFileSync:_m}=no("node:child_process"),Pn=no("node:fs"),Fm=no("node:tty"),Fl=80,Vl=24,fi=(e,t,{shell:n,env:s}={})=>_m(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),As=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),Wl=(e,t)=>{const{columns:n,rows:s}=As(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===Fl&&s===Vl))return{columns:n,rows:s}},Vm=()=>{if(rt.platform!=="linux")return!0;try{const e=Pn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),r=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(r)||r<=0?!1:s===r}catch{return!1}};function Wm(){const{env:e,stdout:t,stderr:n}=rt;if(t?.columns&&t?.rows)return As(t.columns,t.rows);if(n?.columns&&n?.rows)return As(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return As(e.COLUMNS,e.LINES);const s={columns:Fl,rows:Vl};return rt.platform==="win32"?xr()??s:rt.platform==="darwin"?fa()??xr()??s:fa()??xr()??Hm()??s}const fa=()=>{try{const e=rt.platform==="darwin"?Pn.constants.O_EVTONLY|Pn.constants.O_NONBLOCK:Pn.constants.O_NONBLOCK,{columns:t,rows:n}=Fm.WriteStream(Pn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},xr=()=>{try{const e=fi("tput",["cols"],{env:{TERM:"dumb",...rt.env}}),t=fi("tput",["lines"],{env:{TERM:"dumb",...rt.env}});if(e&&t)return Wl(e,t)}catch{}},Hm=()=>{try{if(!Vm())return;const e=fi("resize",["-u"]).match(/\d+/g);if(e.length===2)return Wl(e[0],e[1])}catch{}},et=e=>{const{columns:t,rows:n}=e;if(t&&n)return{columns:t,rows:n};const s=Wm();return{columns:t||s.columns||80,rows:n||s.rows||24}};let Um;const Gm=e=>(Um??=Be(import.meta.url))(e),qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ar=e=>{if(typeof qt<"u"&&qt.versions&&qt.versions.node){const[t,n]=qt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return qt.getBuiltinModule(e)}return Gm(e)},Re=qt,{env:$r}=Re,{PassThrough:ha,Stream:zm}=ar("node:stream"),{Buffer:ma}=ar("node:buffer"),{Console:Jm}=ar("node:console"),{EventEmitter:qm}=ar("node:events"),ga=e=>e in $r&&$r[e]!=="0"&&$r[e]!=="false",Hl=ga("CI")||ga("CONTINUOUS_INTEGRATION"),ya=["assert","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"];let Er={};const Km=e=>{const t=new ha,n=new ha;t.write=r=>{e("stdout",r)},n.write=r=>{e("stderr",r)};const s=new console.Console(t,n);for(const r of ya)Er[r]=console[r],console[r]=s[r];return()=>{for(const r of ya)console[r]=Er[r];Er={}}},an=[];an.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&an.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&an.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const Is=e=>!!e&&!0&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",Cr=Symbol.for("signal-exit emitter"),Rr=globalThis,Ym=Object.defineProperty.bind(Object);class Xm{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Rr[Cr])return Rr[Cr];Ym(Rr,Cr,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,n){this.listeners[t].push(n)}removeListener(t,n){const s=this.listeners[t],r=s.indexOf(n);r!==-1&&(r===0&&s.length===1?s.length=0:s.splice(r,1))}emit(t,n,s){if(this.emitted[t])return!1;this.emitted[t]=!0;let r=!1;for(const i of this.listeners[t])r=i(n,s)===!0||r;return t==="exit"&&(r=this.emit("afterExit",n,s)||r),r}}let Ul=class{};const Zm=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});class Qm extends Ul{onExit(){return()=>{}}load(){}unload(){}}class eg extends Ul{#e=hi.platform==="win32"?"SIGINT":"SIGHUP";#t=new Xm;#n;#i;#s;#r={};#o=!1;constructor(t){super(),this.#n=t,this.#r={};for(const n of an)this.#r[n]=()=>{const s=this.#n.listeners(n);let{count:r}=this.#t;const i=t;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(r+=i.__signal_exit_emitter__.count),s.length===r){this.unload();const o=this.#t.emit("exit",null,n),a=n==="SIGHUP"?this.#e:n;o||t.kill(t.pid,a)}};this.#s=t.reallyExit,this.#i=t.emit}onExit(t,n){if(!Is(this.#n))return()=>{};this.#o===!1&&this.load();const s=n?.alwaysLast?"afterExit":"exit";return this.#t.on(s,t),()=>{this.#t.removeListener(s,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(const t of an)try{const n=this.#r[t];n&&this.#n.on(t,n)}catch{}this.#n.emit=(t,...n)=>this.#c(t,...n),this.#n.reallyExit=t=>this.#a(t)}}unload(){this.#o&&(this.#o=!1,an.forEach(t=>{const n=this.#r[t];if(!n)throw new Error("Listener not defined for signal: "+t);try{this.#n.removeListener(t,n)}catch{}}),this.#n.emit=this.#i,this.#n.reallyExit=this.#s,this.#t.count-=1)}#a(t){return Is(this.#n)?(this.#n.exitCode=t||0,this.#t.emit("exit",this.#n.exitCode,null),this.#s.call(this.#n,this.#n.exitCode)):0}#c(t,...n){const s=this.#i;if(t==="exit"&&Is(this.#n)){typeof n[0]=="number"&&(this.#n.exitCode=n[0]);const r=s.call(this.#n,t,...n);return this.#t.emit("exit",this.#n.exitCode,null),r}else return s.call(this.#n,t,...n)}}const hi=globalThis.process,{onExit:tg}=Zm(Is(hi)?new eg(hi):new Qm),Hs="\x1B",Gl="\x1B[200~",va="\x1B[201~",ng=e=>e>=48&&e<=63,sg=e=>e>=32&&e<=47,zl=e=>e>=64&&e<=126,rg=(e,t,n)=>{const s=t+n+1;let r=s;for(;r<e.length;r++){const i=e.codePointAt(r);if(i===void 0)return"pending";if(!(ng(i)||sg(i))&&!(i===91&&r===s))return zl(i)?{nextIndex:r+1,sequence:e.slice(t,r+1)}:void 0}return"pending"},ig=(e,t,n)=>{const s=t+n+2;if(s>e.length)return"pending";const r=e.codePointAt(s-1);if(!(r===void 0||!zl(r)))return{nextIndex:s,sequence:e.slice(t,s)}},ba=(e,t,n)=>{const s=e[t+n];if(s===void 0)return"pending";if(s==="[")return rg(e,t,n);if(s==="O")return ig(e,t,n)},og=(e,t)=>{const n=e.codePointAt(t+1),s=n!==void 0&&n>65535?2:1,r=t+1+s;return{nextIndex:r,sequence:e.slice(t,r)}},ag=(e,t)=>{if(t===e.length-1)return"pending";if(e[t+1]===Hs){if(t+2>=e.length)return"pending";const s=ba(e,t,2);return s==="pending"?"pending":s||{nextIndex:t+2,sequence:e.slice(t,t+2)}}const n=ba(e,t,1);return n==="pending"?"pending":n||og(e,t)},wa=(e,t)=>{let n=0;for(let s=0;s<e.length;s++){const r=e[s];(r===""||r==="\b")&&(s>n&&t.push(e.slice(n,s)),t.push(r),n=s+1)}n<e.length&&t.push(e.slice(n))},cg=e=>{const t=[];let n=0;const s=r=>({events:t,pending:e.slice(r)});for(;n<e.length;){const r=e.indexOf(Hs,n);if(r===-1)return wa(e.slice(n),t),{events:t,pending:""};r>n&&wa(e.slice(n,r),t);const i=ag(e,r);if(i==="pending")return s(r);if(i.sequence===Gl){const o=i.nextIndex,a=e.indexOf(va,o);if(a===-1)return s(r);t.push({paste:e.slice(o,a)}),n=a+va.length;continue}t.push(i.sequence),n=i.nextIndex}return{events:t,pending:""}},lg=()=>{let e="";return{flushPendingEscape(){if(!e.startsWith(Hs))return;const t=e;return e="",t},hasPendingEscape(){return e.startsWith(Hs)&&!e.startsWith(Gl)&&e!=="\x1B[200"},push(t){const n=cg(e+t);return e=n.pending,n.events},reset(){e=""}}},dg=" ",ug="\x1B[Z",pg="\x1B",ka=Tl(Al),jr=Ol(Al),Jl=({children:e,exitOnCtrlC:t,interactive:n,onExit:s,onRegisterInputControl:r,onSuspendTerminal:i,onWaitUntilRenderFlush:o,renderThrottleMs:a,setCursorPosition:c,stderr:l,stdin:d,stdout:u,writeToStderr:p,writeToStdout:f})=>{const[h,m]=k.useState(!0),[v,$]=k.useState(void 0),[,b]=k.useState([]),S=k.useRef(0),C=k.useRef([]),P=k.useRef(new Map),T=k.useRef(void 0),N=k.useRef(0),_=k.useRef(!1),F=k.useRef(0),[Y]=k.useState(()=>{const D=new qm;return D.setMaxListeners(1/0),D}),re=k.useRef(void 0),ee=k.useRef(void 0);ee.current??=lg();const te=k.useRef(void 0),se=k.useRef(!1),M=20,w=k.useCallback(()=>{te.current&&(clearTimeout(te.current),te.current=void 0)},[]),A=k.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=void 0)},[]),H=k.useCallback(()=>{if(A(),P.current.size===0)return;let D=Number.POSITIVE_INFINITY;for(const K of P.current.values())D=Math.min(D,K.nextDueTime);const X=Math.max(0,D-performance.now());T.current=setTimeout(()=>{T.current=void 0;const K=performance.now(),ue=[...P.current.values()];for(const ke of ue){if(K<ke.nextDueTime)continue;ke.callback(K);const hf=K-ke.startTime,mf=Math.floor(hf/ke.interval)+1;ke.nextDueTime=ke.startTime+mf*ke.interval}H()},X)},[A]),O=k.useCallback((D,X)=>{const K=performance.now();return P.current.set(D,{callback:D,interval:X,nextDueTime:K+X,startTime:K}),H(),{startTime:K,unsubscribe(){if(P.current.delete(D),P.current.size===0){A();return}H()}}},[A,H]);k.useEffect(()=>()=>{A()},[A]);const I=d.isTTY,j=k.useCallback(()=>{re.current&&(d.removeListener("readable",re.current),re.current=void 0)},[d]),L=k.useCallback(()=>{ee.current?.reset(),w(),j()},[w,j]),W=k.useCallback(()=>{_.current=!1,d.setRawMode(!1),d.unref(),N.current=0,L()},[d,L]),U=k.useCallback(D=>{I&&(N.current>0||_.current)&&W(),s(D)},[I,W,s]),q=k.useCallback(D=>{if(D.includes("")&&t){U();return}D===pg&&h&&$(X=>{if(!X)return X})},[t,U,h]),B=k.useCallback(D=>{q(D),Y.emit("input",D)},[q,Y]),J=k.useCallback(()=>{w(),te.current=setTimeout(()=>{te.current=void 0;const D=ee.current.flushPendingEscape();D&&B(D)},M)},[w,B]),oe=k.useCallback(()=>{w();let D;for(;(D=d.read())!==null;){const X=ee.current.push(D);for(const K of X)if(typeof K=="string")B(K);else{if(Y.listenerCount("paste")===0){se.current||(se.current=!0,p(`Warning: useInput() received bracketed paste because no usePaste() handler is active. This fallback is deprecated and will be removed in the next major version. Migrate paste handling to usePaste().
|
|
2
|
+
`)),B(K.paste);continue}Y.emit("paste",K.paste)}}ee.current.hasPendingEscape()&&J()},[d,B,w,J,p,Y]),ce=k.useCallback(()=>{re.current||(re.current=oe,d.addListener("readable",oe))},[d,oe]),fe=k.useCallback(D=>{if(!I)throw d===Re.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
|
|
3
3
|
Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`):new Error(`Raw mode is not supported on the stdin provided to Ink.
|
|
4
|
-
Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(d.setEncoding("utf8"),
|
|
5
|
-
`)?e.length-1:e.length,
|
|
6
|
-
|
|
7
|
-
`)
|
|
8
|
-
`),
|
|
9
|
-
|
|
10
|
-
`),
|
|
11
|
-
`)?1
|
|
12
|
-
`))}const
|
|
13
|
-
`)
|
|
14
|
-
`))};calculateLayout=()=>{const t=s=>{const i=new Map;this.calculateScrollAndTriggerObservers(s,i);for(const[r,o]of i)r.internalTrigger(o)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const n=et(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(n),this.rootNode.yogaNode.calculateLayout(void 0,void 0,He.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,n){if(t.nodeName==="ink-box"){const{style:s}=t,i=s.overflow??"visible",r=s.overflowX??i,o=s.overflowY??i;r==="scroll"||o==="scroll"?(Sf(t),s.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(Sm(t,n),!t.internal_static)for(const s of t.childNodes)s.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(s,n)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,n){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),xf(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let s=0;for(const i of t.childNodes){const r=i;i.nodeName!=="#text"&&r.yogaNode&&(t.yogaNode.insertChild(r.yogaNode,s),s++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const s of t.childNodes)s.nodeName!=="#text"&&this.prepareYogaTree(s,n);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const s=et(this.options.stdout).columns,{width:i}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof i=="number"?i:s),t.yogaNode.calculateLayout(void 0,void 0,He.DIRECTION_LTR)),n(t),$f(t,{skipStaticElements:!1,trackSelection:this.options.trackSelection}),t.internal_onRendered?.()}}markAllTextNodesDirty(t){if(!t.cachedRender){t.nodeName==="ink-text"&&t.yogaNode&&t.yogaNode.markDirty();for(const n of t.childNodes)n.nodeName!=="#text"&&this.markAllTextNodesDirty(n)}}handleStaticChange=()=>{this.fullStaticOutput=""};computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const n=Math.round(t.internal_scrollState.scrollTop),s=t.yogaNode?.getComputedPadding(He.EDGE_TOP)??0,i=Math.max(0,n-Math.round(s)),r=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:o}=t.style,a=o===void 0?r:Math.max(r,i-Math.max(0,o)),c=i-a;if(c<=0)return"";const l=Qm(t,a,c);return l===""?"":(t.internal_maxPushedScrollTop=i,`${l}\x1B[0m
|
|
15
|
-
`)}onRender=()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=Ef(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:n,cursorRequested:s,cursorShape:i,output:r,outputBuffer:o,outputHeight:a,outputWidth:c,staticOutput:l}=t;this.renderedCursorRequested=s,this.renderedCursorPosition=n,this.log.setCursorShape(s?i:void 0);const d=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&o&&c){l&&l!==`
|
|
4
|
+
Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(d.setEncoding("utf8"),D){if(N.current===0){const X=_.current;_.current=!1,X||(d.ref(),d.setRawMode(!0)),ce()}N.current++;return}N.current!==0&&--N.current===0&&(L(),_.current=!0,queueMicrotask(()=>{_.current&&W()}))},[I,d,ce,L,W]),be=k.useCallback(D=>{if(u.isTTY){if(D){F.current===0&&u.write(ka),F.current++;return}F.current!==0&&--F.current===0&&u.write(jr)}},[u]),we=k.useRef({bracketedPaste:!1,rawMode:!1}),vt=k.useCallback(()=>{const D=I&&(N.current>0||_.current),X=F.current>0;we.current={bracketedPaste:X,rawMode:D},X&&u.isTTY&&u.write(jr),D&&(_.current=!1,L(),d.setRawMode(!1),d.unref())},[I,u,d,L]),Do=k.useCallback(()=>{const{bracketedPaste:D,rawMode:X}=we.current;X&&(d.ref(),d.setRawMode(!0),d.setEncoding("utf8"),ce()),D&&u.isTTY&&u.write(ka)},[d,u,ce]);k.useEffect(()=>{r(vt,Do)},[r,vt,Do]);const Mo=k.useCallback((D,X)=>{const K=D.findIndex(ue=>ue.id===X);for(let ue=K+1;ue<D.length;ue++){const ke=D[ue];if(ke?.isActive)return ke.id}},[]),Lo=k.useCallback((D,X)=>{const K=D.findIndex(ue=>ue.id===X);for(let ue=K-1;ue>=0;ue--){const ke=D[ue];if(ke?.isActive)return ke.id}},[]),hs=k.useCallback(()=>{const D=C.current;$(X=>{const K=D.find(ue=>ue.isActive)?.id;return Mo(D,X)??K})},[Mo]),ms=k.useCallback(()=>{const D=C.current;$(X=>{const K=D.findLast(ue=>ue.isActive)?.id;return Lo(D,X)??K})},[Lo]);k.useEffect(()=>{const D=K=>{!h||S.current===0||(K===dg&&hs(),K===ug&&ms())};Y.on("input",D);const X=Y;return()=>{X.off("input",D)}},[h,hs,ms,Y]);const _o=k.useCallback(()=>{m(!0)},[]),Fo=k.useCallback(()=>{m(!1)},[]),Vo=k.useCallback(D=>{C.current.some(X=>X?.id===D)&&$(D)},[]),Wo=k.useCallback((D,{autoFocus:X})=>{const K=[...C.current,{id:D,isActive:!0}];S.current=K.length,C.current=K,b(K),X&&$(ue=>ue||D)},[]),Ho=k.useCallback(D=>{$(K=>{if(K!==D)return K});const X=C.current.filter(K=>K.id!==D);S.current=X.length,C.current=X,b(X)},[]),Uo=k.useCallback(D=>{const X=C.current.map(K=>K.id!==D?K:{id:D,isActive:!0});C.current=X,b(X)},[]),Go=k.useCallback(D=>{$(K=>{if(K!==D)return K});const X=C.current.map(K=>K.id!==D?K:{id:D,isActive:!1});C.current=X,b(X)},[]);k.useEffect(()=>()=>{const D=!u.destroyed&&!u.writableEnded;n&&D&&u.write(qn),I&&(N.current>0||_.current)&&W(),F.current>0&&(u.isTTY&&D&&u.write(jr),F.current=0)},[u,I,W,n]);const af=k.useMemo(()=>({exit:U,suspendTerminal:i,waitUntilRenderFlush:o}),[U,i,o]),cf=k.useMemo(()=>({internal_eventEmitter:Y,internal_exitOnCtrlC:t,isRawModeSupported:I,setBracketedPasteMode:be,setRawMode:fe,stdin:d}),[d,fe,be,I,t,Y]),lf=k.useMemo(()=>({stdout:u,write:f}),[u,f]),df=k.useMemo(()=>({stderr:l,write:p}),[l,p]),uf=k.useMemo(()=>({setCursorPosition:c}),[c]),pf=k.useMemo(()=>({activate:Uo,activeId:v,add:Wo,deactivate:Go,disableFocus:Fo,enableFocus:_o,focus:Vo,focusNext:hs,focusPrevious:ms,remove:Ho}),[v,Wo,Ho,Uo,Go,_o,Fo,hs,ms,Vo]),ff=k.useMemo(()=>({renderThrottleMs:a,subscribe:O}),[O,a]);return y.jsx(Qi.Provider,{value:af,children:y.jsx(rr.Provider,{value:cf,children:y.jsx(to.Provider,{value:lf,children:y.jsx(Nl.Provider,{value:df,children:y.jsx(eo.Provider,{value:pf,children:y.jsx(Il.Provider,{value:ff,children:y.jsx(Bl.Provider,{value:uf,children:y.jsx(bm,{onError:U,children:e})})})})})})})})};Jl.displayName="InternalApp";const fg=(e,t,n)=>{if(n<=0||!e.yogaNode)return"";const{yogaNode:s}=e,r=s.getComputedBorder(We.EDGE_LEFT),i=s.getComputedBorder(We.EDGE_RIGHT),o=s.getComputedBorder(We.EDGE_TOP),a=s.getComputedPadding(We.EDGE_LEFT),c=s.getComputedPadding(We.EDGE_RIGHT),l=s.getComputedPadding(We.EDGE_TOP),d=Math.round(s.getComputedWidth()-r-i-a-c);if(d<=0)return"";const u=new Nf({height:n,width:d}),p=-(e.internal_scrollState?.scrollLeft??0)-r-a,f=-t-o-l;for(const h of e.childNodes)Df(h,u,{absoluteOffsetX:p,absoluteOffsetY:f,offsetX:p,offsetY:f,skipStaticElements:!1});return u.get().output},mi=new WeakMap,Wt=e=>e??"default",hg=()=>{let e,t;return{consumeDelta:()=>{if(Wt(t)===Wt(e))return"";const n=Wt(t);return e=t,ca(n)},consumeRestoreOnDone:()=>{const n=Wt(e)!=="default";return e=void 0,t=void 0,n?ca("default"):""},isDirty:()=>Wt(t)!==Wt(e),setPending:n=>{t=n}}},Yn=(e,t)=>t.endsWith(`
|
|
5
|
+
`)?e.length-1:e.length,ql=e=>e.rows||1/0,Kl=(e,t)=>Math.min(e,ql(t)),Yl=(e,t)=>{const{activeCursor:n,content:s,contentLines:r,previousLines:i,returnPrefix:o,shapeDelta:a}=e,c=ir(Yn(r,s),n);t.write(a+o+Kn(Kl(i.length,t))+s+c)},mg=(e,t)=>{const{activeCursor:n,content:s,contentLines:r,previous:i,previousLines:o,returnPrefix:a,shapeDelta:c}=e,l=Yn(r,s);if(s===`
|
|
6
|
+
`||i.length===0){Yl(e,t);return}const d=Yn(o,i),u=s.endsWith(`
|
|
7
|
+
`),p=[c,a],f=ql(t);if(l<d){const h=i.endsWith(`
|
|
8
|
+
`)?1:0;p.push(Kn(Math.min(d-l+h,f)),Ws(Math.min(l,f-1)))}else p.push(Ws(Math.min(d-1,f-1)));for(let h=0;h<l;h+=1){const m=h===l-1;if(r[h]===o[h]){(!m||u)&&p.push(Yh());continue}p.push(sr(0)+r[h]+em+(m&&!u?"":`
|
|
9
|
+
`))}p.push(ir(l,n)),t.write(p.join(""))},gg=(e,{showCursor:t=!1},n)=>{let s=[],r="",i=!1,o,a=!1,c,l=!1;const d=hg(),u=()=>a?o:void 0,p=(v,$)=>{const b=la($,c);return v!==r||b||d.isDirty()},f=v=>{c=v?{...v}:void 0,l=v!==void 0},h=()=>{r="",s=[],c=void 0,l=!1},m=v=>{!t&&!i&&(e.write(Jn),i=!0);const $=u();a=!1;const b=la($,c);if(!p(v,$))return!1;const S=d.consumeDelta(),C=v.split(`
|
|
10
|
+
`),P=Yn(C,v);return v===r&&b?(e.write(S+Rm({cursorPosition:$,cursorWasShown:l,previousCursorPosition:c,previousLineCount:s.length,visibleLineCount:P})),f($),!0):v===r&&S!==""?(e.write(S),f($),!0):(n({activeCursor:$,content:v,contentLines:C,previous:r,previousLines:s,returnPrefix:da(l,s.length,c),shapeDelta:S},e),r=v,s=C,f($),!0)};return m.clear=()=>{const v=da(l,s.length,c);e.write(v+Kn(Kl(s.length,e))),h()},m.done=()=>{h();const v=d.consumeRestoreOnDone();v!==""&&e.write(v),t||(e.write(qn),i=!1)},m.reset=h,m.sync=v=>{const $=u();a=!1;const b=v.split(`
|
|
11
|
+
`);r=v,s=b;const S=d.consumeDelta();S!==""&&e.write(S),!$&&l&&e.write(Jn),$&&e.write(ir(Yn(b,v),$)),f($)},m.setCursorPosition=v=>{o=v,a=!0},m.setCursorShape=d.setPending,m.isCursorDirty=()=>a||d.isDirty(),m.willRender=v=>p(v,u()),m},yg=(e,{incremental:t=!1,showCursor:n=!1}={})=>gg(e,{showCursor:n},t?mg:Yl),vg={create:yg},Xl=jl(2026),wt=Tl(Xl),Ze=Ol(Xl);function bg(e,t){return"isTTY"in e&&e.isTTY&&(t??!Hl)}let Ht;const wg=()=>{if(Ht!==!1){if(Ht!==void 0)return Ht;try{return Ht=Bm(import.meta.url).Renderer,Ht}catch{Ht=!1;return}}},kg=e=>{const t=wg();if(!t)return;let n,s=0,r=0;const i=(o,a)=>{(!n||s!==o||r!==a)&&(n?n.resize(o,a):n=new t(o,a),s=o,r=a)};return{clear(){if(n){const o=new Uint32Array(s*r*2),a=65535;for(let c=0;c<o.length;c+=2)o[c]=32,o[c+1]=a;n.render(o)}},destroy(){n=void 0},render(o,a,c){if(i(a,c),!!n){e.isTTY&&n.writeRaw(wt);try{n.render(o)}finally{e.isTTY&&n.writeRaw(Ze)}}},resize(o,a){i(o,a)}}};function Sa(e,t=0,n={}){const s=n.leading??!0,r=n.trailing??!0;let i,o,a,c;const l=()=>{if(o===void 0)return;const h=o;o=void 0,c=e(...h)},d=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},u=()=>{i=void 0,r&&l(),o=void 0,a=void 0},p=()=>{d(),i=setTimeout(u,t)},f=function(...h){const m=Date.now();if(a??=m,m-a>=t)return o=h,l(),a=m,p(),c;o=h;const v=i===void 0;return p(),s&&v&&l(),c};return f.cancel=()=>{d(),o=void 0,a=void 0},f.flush=()=>(d(),l(),a=void 0,c),f}console.Console||(console.Console=Jm);const Cn=()=>{},xa=async()=>new Promise(e=>{setImmediate(e)}),Sg=27,xg=91,$g=63,Eg=117,Cg=48,Rg=57,jg=e=>e>=Cg&&e<=Rg,Zl=(e,t)=>{if(e[t]!==Sg||e[t+1]!==xg||e[t+2]!==$g)return;let n=t+3;const s=n;for(;n<e.length&&jg(e[n]);)n++;if(n!==s){if(n===e.length)return{state:"partial"};if(e[n]===Eg)return{endIndex:n,state:"complete"}}},Tg=e=>{for(let t=0;t<e.length;t++)if(Zl(e,t)?.state==="complete")return!0;return!1},Og=e=>{const t=[];let n=0;for(;n<e.length;){const s=Zl(e,n);if(s?.state==="complete"){n=s.endIndex+1;continue}if(s?.state==="partial")break;t.push(e[n]),n++}return t},Ag=({isTty:e,isUnmounting:t,isWindows:n,nextOutputHeight:s,previousOutputHeight:r,viewportRows:i})=>{if(!e)return!1;const o=r>0,a=r>=i,c=s>=i,l=r>i,d=s>i,u=a&&s<i;return l||d&&o||u||t&&a||n&&(c||a)},Tr=e=>e instanceof Error||Object.prototype.toString.call(e)==="[object Error]",$a=e=>{const t=!e.destroyed&&!e.writableEnded&&(e.writable??!0),n=e._writableState!==void 0||e.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:n}},vs=(e,t)=>{if(!e||typeof e.flush!="function")return;const n=e;t?n.flush():typeof n.cancel=="function"&&n.cancel()};class Ig{isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;backbufferNode;backbufferMultiWarned=!1;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;kittyFlags;isSuspended=!1;pauseInput;resumeInput;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=Cf("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??Re.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const n=t.debug||this.isScreenReaderEnabled,s=t.maxFps??30,r=s>0?Math.max(1,Math.ceil(1e3/s)):0;this.renderThrottleMs=n?0:r;const i=n?this.onRender:(()=>{const a=Sa(this.onRender,r,{leading:!0,trailing:!0});return this.throttledOnRender=a,()=>{this.hasPendingThrottledRender=!0,a()}})();if(n&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let a=!1;const c=()=>{a||(a=!0,queueMicrotask(()=>{a=!1,this.onRender()}))};this.rootNode.onRender=c,this.rootNode.onImmediateRender=c}else this.rootNode.onRender=i,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=vg.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=kg(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=n?this.log:Sa(a=>{const c=this.log.willRender(a),l=this.shouldSync();l&&c&&this.options.stdout.write(wt),this.log(a),l&&c&&this.options.stdout.write(Ze)},void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.isUnmounting=!1,this.isConcurrent=t.concurrent??!1,this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.lastTerminalWidth=et(this.options.stdout).columns,this.fullStaticOutput="";const o=t.concurrent?zo.ConcurrentRoot:zo.LegacyRoot;this.container=Se.createContainer(this.rootNode,o,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=tg(this.unmount,{alwaysLast:!1}),this.setAlternateScreen(!!t.alternateScreen),t.patchConsole&&this.patchConsole(),this.interactive&&(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)}),this.initImmediateKittyKeyboard(),Re.env.DEV==="true"&&Se.injectIntoDevTools(),this.exitPromise=new Promise((a,c)=>{this.resolveExitPromise=a,this.rejectExitPromise=c}),this.exitPromise.catch(Cn)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=()=>{const t=et(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),Rf(),this.calculateLayout(),jf(this.rootNode),this.onRender(),this.lastTerminalWidth=t};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};handleAppExit=t=>{if(!(this.isUnmounted||this.isUnmounting)){if(Tr(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}};getActiveCursorPosition=()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition;setCursorPosition=t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())};restoreLastOutput=()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
|
|
12
|
+
`))};calculateLayout=()=>{const t=s=>{const r=new Map;this.calculateScrollAndTriggerObservers(s,r);for(const[i,o]of r)i.internalTrigger(o)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const n=et(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(n),this.rootNode.yogaNode.calculateLayout(void 0,void 0,We.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,n){if(t.nodeName==="ink-box"){const{style:s}=t,r=s.overflow??"visible",i=s.overflowX??r,o=s.overflowY??r;i==="scroll"||o==="scroll"?(Tf(t),s.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(Dm(t,n),!t.internal_static)for(const s of t.childNodes)s.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(s,n)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,n){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),Of(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let s=0;for(const r of t.childNodes){const i=r;r.nodeName!=="#text"&&i.yogaNode&&(t.yogaNode.insertChild(i.yogaNode,s),s++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const s of t.childNodes)s.nodeName!=="#text"&&this.prepareYogaTree(s,n);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const s=et(this.options.stdout).columns,{width:r}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof r=="number"?r:s),t.yogaNode.calculateLayout(void 0,void 0,We.DIRECTION_LTR)),n(t),Af(t,{skipStaticElements:!1,trackSelection:this.options.trackSelection}),t.internal_onRendered?.()}}markAllTextNodesDirty(t){if(!t.cachedRender){t.nodeName==="ink-text"&&t.yogaNode&&t.yogaNode.markDirty();for(const n of t.childNodes)n.nodeName!=="#text"&&this.markAllTextNodesDirty(n)}}handleStaticChange=()=>{this.fullStaticOutput=""};computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const n=Math.round(t.internal_scrollState.scrollTop),s=t.yogaNode?.getComputedPadding(We.EDGE_TOP)??0,r=Math.max(0,n-Math.round(s)),i=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:o}=t.style,a=o===void 0?i:Math.max(i,r-Math.max(0,o)),c=r-a;if(c<=0)return"";const l=fg(t,a,c);return l===""?"":(t.internal_maxPushedScrollTop=r,`${l}\x1B[0m
|
|
13
|
+
`)}onRender=()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=If(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:n,cursorRequested:s,cursorShape:r,output:i,outputBuffer:o,outputHeight:a,outputWidth:c,staticOutput:l}=t;this.renderedCursorRequested=s,this.renderedCursorPosition=n,this.log.setCursorShape(s?r:void 0);const d=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&o&&c){l&&l!==`
|
|
16
14
|
`&&this.options.stdout.write(l),d&&this.options.stdout.write(d),this.nativeLog.render(o,c,a),this.lastOutputHeight=a;return}s&&this.log.setCursorPosition(this.getActiveCursorPosition());const u=l&&l!==`
|
|
17
|
-
`;if(this.options.debug){u&&(this.fullStaticOutput+=l),this.lastOutput=
|
|
18
|
-
`,this.lastOutputHeight=a;return}if(this.isScreenReaderEnabled){const p=this.shouldSync();if(p&&this.options.stdout.write(wt),u){const m=this.lastOutputHeight>0
|
|
19
|
-
`).length,p&&this.options.stdout.write(Ze);return}u&&(this.fullStaticOutput+=l),this.renderInteractiveFrame(
|
|
15
|
+
`;if(this.options.debug){u&&(this.fullStaticOutput+=l),this.lastOutput=i,this.lastOutputToRender=i,this.lastOutputHeight=a,this.options.stdout.write(this.fullStaticOutput+i);return}if(!this.interactive){u&&this.options.stdout.write(l),this.lastOutput=i,this.lastOutputToRender=`${i}
|
|
16
|
+
`,this.lastOutputHeight=a;return}if(this.isScreenReaderEnabled){const p=this.shouldSync();if(p&&this.options.stdout.write(wt),u){const m=this.lastOutputHeight>0?Kn(this.lastOutputHeight):"";this.options.stdout.write(m+l),this.lastOutputHeight=0}if(i===this.lastOutput&&!u){p&&this.options.stdout.write(Ze);return}const f=et(this.options.stdout).columns,h=Bf(i,{trim:!1,width:f,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(u)this.options.stdout.write(h);else{const m=this.lastOutputHeight>0?Kn(this.lastOutputHeight):"";this.options.stdout.write(m+h)}this.lastOutput=i,this.lastOutputToRender=h,this.lastOutputHeight=h===""?0:h.split(`
|
|
17
|
+
`).length,p&&this.options.stdout.write(Ze);return}u&&(this.fullStaticOutput+=l),this.renderInteractiveFrame(i,a,u?l:"",d)};accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const n=y.jsx(Pf.Provider,{value:this.accessibilityContextValue,children:y.jsx(Jl,{exitOnCtrlC:this.options.exitOnCtrlC,interactive:this.interactive,onExit:this.handleAppExit,onRegisterInputControl:this.registerInputControl,onSuspendTerminal:this.suspendTerminal,onWaitUntilRenderFlush:this.waitUntilRenderFlush,renderThrottleMs:this.renderThrottleMs,setCursorPosition:this.setCursorPosition,stderr:this.options.stderr,stdin:this.options.stdin,stdout:this.options.stdout,writeToStderr:this.writeToStderr,writeToStdout:this.writeToStdout,children:t})});this.options.concurrent?Se.updateContainer(n,this.container,null,Cn):(Se.updateContainerSync(n,this.container,null,Cn),Se.flushSyncWork())}writeToStdout=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stdout.write(t);return}const n=this.shouldSync();n&&this.options.stdout.write(wt),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),n&&this.options.stdout.write(Ze)};writeToStderr=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stderr.write(t);return}const n=this.shouldSync();n&&this.options.stdout.write(wt),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),n&&this.options.stdout.write(Ze)};unmount=t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(Re.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const n=this.options.stdout,{canWriteToStdout:s,hasWritableState:r}=$a(n);vs(this.throttledOnRender,s),s&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),vs(this.throttledLog,s),typeof this.restoreConsole=="function"&&this.restoreConsole();const i=()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),s&&(this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen?(this.log.clear(),this.log.done(),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.fullStaticOutput="",this.writeBestEffort(this.options.stdout,aa),this.writeBestEffort(this.options.stdout,qn),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
|
|
20
18
|
`:`${this.lastOutput}
|
|
21
|
-
`)),this.kittyProtocolEnabled=!1,
|
|
22
|
-
`))}patchConsole(){this.options.debug||(this.restoreConsole=
|
|
23
|
-
`,u=Re.platform==="win32",p=a&&u&&(l||this.lastOutputHeight>=c);if(
|
|
24
|
-
`),n},
|
|
25
|
-
`:{i.name="enter";break}case" ":{i.name="tab";break}case" ":case"\x1B ":{i.name="space",i.meta=e.length===2;break}case"\b":case"\x1B\b":{i.name="backspace",i.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{i.name="escape",i.meta=e.length===2;break}case"\x1B":case"":{i.name="backspace",i.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")i.name=String.fromCharCode(e.charCodeAt(0)+97-1),i.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")i.name="number";else if(e.length===1&&e>="a"&&e<="z")i.name=e;else if(e.length===1&&e>="A"&&e<="Z")i.name=e.toLowerCase(),i.shift=!0;else if(t=Tg.exec(e))i.meta=!0,i.shift=/^[A-Z]$/.test(t[1]);else if(t=Og.exec(e)){const r=[...e];r[0]==="\x1B"&&r[1]==="\x1B"&&(i.option=!0);const o=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;i.ctrl=!!(a&4),i.meta=!!(a&10),i.shift=!!(a&1),i.code=o,i.name=Yl[o]??"",i.shift=Ig(o)||i.shift,i.ctrl=Bg(o)||i.ctrl}}return i},eo=(e,t={})=>{const{internal_eventEmitter:n,internal_exitOnCtrlC:s,setRawMode:i,stdin:r}=Kl(),o=t.imeEnabled??!0,a=t.imeTimeout??50,c=k.useRef(void 0),l=k.useEffectEvent(e);k.useEffect(()=>{if(o)return c.current=new Ph({onFlush:d=>{const u={backspace:!1,capsLock:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,hyper:!1,leftArrow:!1,meta:!1,numLock:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,super:!1,tab:!1,upArrow:!1};Se.discreteUpdates(()=>{l(d,u)})},timeout:a}),()=>{c.current?.destroy(),c.current=void 0}},[o,a]),k.useEffect(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),k.useLayoutEffect(()=>{if(t.isActive===!1)return;const d=u=>{if(o&&Bh(u)){c.current?.add(u);return}c.current?.flush();const p=_g(u),f={backspace:p.name==="backspace",capsLock:p.capsLock??!1,ctrl:p.ctrl,delete:p.name==="delete",downArrow:p.name==="down",end:p.name==="end",escape:p.name==="escape",eventType:p.eventType,home:p.name==="home",hyper:p.hyper??!1,leftArrow:p.name==="left",meta:p.meta||p.option,numLock:p.numLock??!1,pageDown:p.name==="pagedown",pageUp:p.name==="pageup",return:p.name==="return",rightArrow:p.name==="right",shift:p.shift,super:p.super??!1,tab:p.name==="tab",upArrow:p.name==="up"};let h;p.isKittyProtocol?p.isPrintable?h=p.text??p.name:p.ctrl&&p.name.length===1?h=p.name:h="":p.ctrl?h=p.name:h=p.sequence,!p.isKittyProtocol&&Ag.includes(p.name)&&(h=""),h.startsWith("\x1B")&&(h=h.slice(1)),h.length===1&&typeof h[0]=="string"&&/[A-Z]/.test(h[0])&&(f.shift=!0),!(h==="c"&&f.ctrl&&s)&&(!p.name&&h===""||Se.discreteUpdates(()=>{l(h,f)}))};return n.on("input",d),()=>{n.removeListener("input",d)}},[t.isActive,r,s,o])},Fg=()=>{const{stdin:e}=Kl(),{stdout:t}=zl(),[n,s]=k.useState(null),[i,r]=k.useState(!0),o=k.useMemo(()=>kg(),[]);return k.useEffect(()=>{if(!o||!e||!t){r(!1);return}let a=!1;return(async()=>{try{const c=await Sg(e,t,200);a||s(c)}catch{}finally{a||r(!1)}})(),()=>{a=!0}},[o,e,t]),{isLoading:i,isSupported:o,palette:n}},Vg=({autoFocus:e=!1,id:t,isActive:n=!0}={})=>{const{isRawModeSupported:s,setRawMode:i}=xg(),{activate:r,activeId:o,add:a,deactivate:c,focus:l,remove:d}=k.useContext(Xr),u=k.useMemo(()=>t??Math.random().toString().slice(2,7),[t]);return k.useEffect(()=>(a(u,{autoFocus:e}),()=>{d(u)}),[u,e]),k.useEffect(()=>{n?r(u):c(u)},[n,u]),k.useEffect(()=>{if(!(!s||!n))return i(!0),()=>{i(!1)}},[n]),{focus:l,isFocused:!!u&&o===u}},Hg=e=>{const{getViewportHeight:t,isActive:n=!0,scrollBy:s,scrollToBottom:i,scrollToTop:r,vimBindings:o=!1}=e,{isFocused:a}=Vg({isActive:n});return eo((c,l)=>{if(l.upArrow){s(-1);return}if(l.downArrow){s(1);return}if(l.pageUp){s(-t());return}if(l.pageDown){s(t());return}if(l.home){r();return}if(l.end){i();return}if(l.ctrl&&c==="u"){s(-Math.floor(t()/2));return}if(l.ctrl&&c==="d"){s(Math.floor(t()/2));return}if(o){if(c==="k"){s(-1);return}if(c==="j"){s(1);return}if(c==="G"&&l.shift){i();return}if(c==="g"&&!l.shift){r();return}if(c==="u"&&!l.ctrl){s(-Math.floor(t()/2));return}c==="d"&&!l.ctrl&&s(Math.floor(t()/2))}},{isActive:n}),{isFocused:a}},hr=e=>{const[t,n]=k.useState(e),s=k.useRef(e),i=k.useCallback(o=>{const a=typeof o=="function"?o(s.current):o;s.current=a,n(a)},[]),r=k.useCallback(()=>s.current,[]);return[t,i,r]},Wg=({children:e,index:t,measureKey:n,onMeasure:s,width:i})=>{const r=k.useRef(null);return k.useLayoutEffect(()=>{if(r.current){const{height:o}=il(r.current);s(t,o)}},[t,s,i,n,e]),y.jsx(V,{flexDirection:"column",flexShrink:0,ref:r,width:"100%",children:e})},zs=e=>{if(e==null)return[];if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n+=1){const s=e[n];k.isValidElement(s)&&s.type===k.Fragment?t.push(...zs(s.props.children)):t.push(s)}return t}return k.isValidElement(e)&&e.type===k.Fragment?zs(e.props.children):[e]},Sa=({children:e,debug:t=!1,onContentHeightChange:n,onItemHeightChange:s,onViewportSizeChange:i,overscan:r=3,ref:o,scrollOffset:a,virtualize:c=!1,...l})=>{const d=k.useRef(!1),[u,p,f]=hr({height:0,width:0}),[h,m,b]=hr(0),[$,v]=k.useState({}),S=k.useRef(null),C=k.useRef(0);k.useLayoutEffect(()=>{h!==C.current&&(n?.(h,C.current),C.current=h)},[h,n]);const P=k.useRef({}),j=k.useRef([]),B=k.useRef([]),L=k.useRef(0),D=k.useCallback((O,I)=>{const T=j.current[O]??O;if(P.current[T]!==I){const F=P.current[T]??0;P.current={...P.current,[T]:I};let H=0;for(let q=0;q<j.current.length;q+=1){const N=j.current[q];N!=null&&(H+=P.current[N]??0)}const U=b();H!==U&&m(H),s?.(O,I,F),L.current=Math.min(L.current,O+1)}},[s,b,m]),K=k.useCallback(()=>{if(S.current){const{height:O,width:I}=il(S.current),T=f();(I!==T.width||O!==T.height)&&(i?.({height:O,width:I},T),p({height:O,width:I}))}},[S,i,f,p]);k.useLayoutEffect(()=>{K()});const ie=k.useRef(null);if(ie.current!==e){ie.current=e;const O=[],I={};zs(e).forEach((H,U)=>{if(!H)return;const q=(k.isValidElement(H)?H.key:null)??U;O[U]=q;const N=P.current[q]??0;I[q]=N}),P.current=I,j.current=O,B.current=Array.from({length:O.length}).fill(0),L.current=0;let T=0;O.forEach(H=>{T+=I[H]??0});const F=b();T!==F&&m(T)}k.useImperativeHandle(o,()=>({getBottomOffset:()=>Math.max(0,b()-f().height),getContentHeight:b,getItemHeight:O=>{const I=j.current[O]??O;return P.current[I]??0},getItemPosition:O=>{if(O<0||O>=j.current.length)return null;if(O>=L.current){let F=0,H=0;if(L.current>0){H=L.current;const U=H-1,q=j.current[U]??U,N=P.current[q]??0;F=(B.current[U]??0)+N}for(let U=H;U<=O;U+=1){B.current[U]=F;const q=j.current[U]??U,N=P.current[q]??0;F+=N}L.current=O+1}const I=B.current[O]??0,T=j.current[O]??O;return{height:P.current[T]??0,top:I}},getViewportHeight:()=>f().height,remeasure:K,remeasureItem:O=>{v(I=>({...I,[O]:(I[O]??0)+1}))}}),[K,b,f,v]);const ee=zs(e);!d.current&&h>0&&(d.current=!0);let te=0,se=ee.length-1,_=0,w=0;const A=ee.length>0&&ee.every((O,I)=>{const T=j.current[I]??I;return(P.current[T]??0)>0}),W=c&&d.current&&A;if(W){const O=j.current.length;if(L.current<O){let T=0,F=0;if(L.current>0){F=L.current;const H=F-1,U=j.current[H]??H,q=P.current[U]??0;T=(B.current[H]??0)+q}for(let H=F;H<O;H+=1){B.current[H]=T;const U=j.current[H]??H;T+=P.current[U]??0}L.current=O}const I=a+u.height;te=ee.length,se=-1;for(let T=0;T<O;T+=1){const F=B.current[T]??0,H=j.current[T]??T,U=P.current[H]??0;F+U>a&&F<I&&(T<te&&(te=T),se=T)}if(te>se&&(te=0,se=-1),te=Math.max(0,te-r),se=Math.min(ee.length-1,Math.max(-1,se)+r),_=B.current[te]??0,se<ee.length-1){const T=j.current[se]??se,F=(B.current[se]??0)+(P.current[T]??0);w=h-F}}return y.jsx(V,{...l,children:y.jsx(V,{ref:S,width:"100%",children:y.jsx(V,{overflow:t?void 0:"hidden",width:"100%",children:y.jsxs(V,{flexDirection:"column",marginTop:-a,width:"100%",children:[W&&_>0&&y.jsx(V,{height:_}),ee.map((O,I)=>!O||W&&(I<te||I>se)?null:y.jsx(Wg,{index:I,measureKey:$[I],onMeasure:D,width:u.width,children:O},k.isValidElement(O)?O.key??I:I)),W&&w>0&&y.jsx(V,{height:w})]})})})})},xa={arrow:{lowerThumb:"╽",thumb:"┃",track:"|",upperThumb:"╿"},block:{thumb:"█",track:"░"},bold:{lowerThumb:"╿",thumb:"│",track:"┃",upperThumb:"╽"},classic:{thumb:"┃",track:"|"},dots:{thumb:"●",track:"·"},double:{thumb:"┃",track:"║"},doubleSingle:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},line:{thumb:"│",track:" "},round:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},single:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},singleDouble:{thumb:"┃",track:"║"},thick:{thumb:"┃",track:"╏"}},$a={arrow:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},bold:{bottomLeft:"┗",bottomRight:"┛",topLeft:"┏",topRight:"┓"},classic:{bottomLeft:"+",bottomRight:"+",topLeft:"+",topRight:"+"},double:{bottomLeft:"╚",bottomRight:"╝",topLeft:"╔",topRight:"╗"},doubleSingle:{bottomLeft:"╘",bottomRight:"╛",topLeft:"╒",topRight:"╕"},round:{bottomLeft:"╰",bottomRight:"╯",topLeft:"╭",topRight:"╮"},single:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},singleDouble:{bottomLeft:"╙",bottomRight:"╜",topLeft:"╓",topRight:"╖"}},Ug=e=>xa[typeof e=="string"?e:"single"]??xa.single??{thumb:"┃",track:"│"},Gg=e=>$a[typeof e=="string"?e:"single"]??$a.single??{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},td=({autoHide:e=!1,color:t,contentHeight:n,dimColor:s,placement:i="right",scrollOffset:r,style:o,thumbChar:a,trackChar:c,viewportHeight:l})=>{const d=k.useMemo(()=>{const h=Math.max(n,l);if(e&&h<=l)return null;const m=Ug(o),b=a??m.thumb,$=c??m.track,v=l*2,S=Math.min(l/h,1),C=Math.max(2,Math.round(v*S)),P=h-l,j=P>0?Math.min(Math.max(r/P,0),1):0,B=v-C,L=Math.round(j*B),D=L+C,K=[];for(let ie=0;ie<l;ie+=1){const ee=ie*2,te=ie*2+1,se=ee>=L&&ee<D,_=te>=L&&te<D;se&&_?K.push(b):se&&!_?K.push(m.lowerThumb??b):!se&&_?K.push(m.upperThumb??b):K.push($)}return K},[n,l,r,o,a,c,e]);if(d===null)return null;if(i==="inset")return y.jsx(V,{flexDirection:"column",flexShrink:0,width:1,children:d.map((h,m)=>y.jsx(R,{color:t,dimColor:s,children:h},m))});const u=Gg(o),p=i==="left"?u.topLeft:u.topRight,f=i==="left"?u.bottomLeft:u.bottomRight;return y.jsxs(V,{flexDirection:"column",flexShrink:0,width:1,children:[y.jsx(R,{color:t,dimColor:s,children:p}),d.map((h,m)=>y.jsx(R,{color:t,dimColor:s,children:h},m)),y.jsx(R,{color:t,dimColor:s,children:f})]})},nd=({children:e,debug:t=!1,followOutput:n=!1,followThreshold:s=3,keyboard:i=!1,onContentHeightChange:r,onItemHeightChange:o,onReachEnd:a,onReachStart:c,onScroll:l,onViewportSizeChange:d,overscan:u,reachThreshold:p=5,ref:f,scrollbar:h=!1,scrollbarColor:m,scrollbarStyle:b="line",vimBindings:$=!1,virtualize:v,...S})=>{const[C,P,j]=hr(0),B=k.useRef(null),L=k.useRef(0),D=k.useRef(0),[K,ie]=k.useState(0),[ee,te]=k.useState(0),se=k.useRef(!1),_=k.useRef(!1),w=k.useCallback(()=>Math.max(0,L.current-D.current),[]),A=k.useCallback(N=>{const J=w();a&&N>=J-p&&!se.current?(se.current=!0,a()):N<J-p&&(se.current=!1),c&&N<=p&&!_.current?(_.current=!0,c()):N>p&&(_.current=!1)},[a,c,p,w]),W=k.useCallback(N=>{N!==j()&&(P(N),l?.(N),A(N))},[j,P,l,A]),O=k.useCallback((N,J)=>{const oe=j()>=w()-s;if(L.current=N,ie(N),r?.(N,J),n&&oe&&N>J){const ce=Math.max(0,N-D.current);W(ce)}else{const ce=Math.max(0,N-D.current);j()>ce&&W(ce)}},[r,n,s,j,w,W]),I=k.useCallback((N,J)=>{D.current=N.height,te(N.height),d?.(N,J)},[d]),T=k.useCallback(N=>{if(typeof N!="number"||Number.isNaN(N))return;const J=Math.max(0,L.current-D.current),oe=Math.max(0,Math.min(j()+N,J));W(oe)},[j,W]),F=k.useCallback(N=>{if(typeof N!="number"||Number.isNaN(N))return;const J=Math.max(0,L.current-D.current),oe=Math.max(0,Math.min(N,J));W(oe)},[W]),H=k.useCallback(()=>{const N=w();W(N)},[w,W]),U=k.useCallback(()=>{W(0)},[W]),q=k.useCallback(()=>D.current,[]);return Hg({getViewportHeight:q,isActive:i,scrollBy:T,scrollToBottom:H,scrollToTop:U,vimBindings:$}),k.useImperativeHandle(f,()=>({getBottomOffset:w,getContentHeight:()=>L.current,getItemHeight:N=>B.current?.getItemHeight(N)??0,getItemPosition:N=>B.current?.getItemPosition(N)??null,getScrollOffset:j,getViewportHeight:()=>D.current,remeasure:()=>B.current?.remeasure(),remeasureItem:N=>B.current?.remeasureItem(N),scrollBy:T,scrollTo:F,scrollToBottom:H,scrollToTop:U}),[w,j,T,F,H,U]),h&&K>ee&&ee>0?y.jsxs(V,{flexDirection:"row",flexGrow:S.flexGrow,flexShrink:S.flexShrink,overflow:"hidden",children:[y.jsx(Sa,{children:e,debug:t,onContentHeightChange:O,onItemHeightChange:o,onViewportSizeChange:I,overscan:u,ref:B,scrollOffset:C,virtualize:v,...S,flexGrow:1}),y.jsx(td,{color:m,contentHeight:K,placement:"inset",scrollOffset:C,style:b,viewportHeight:ee})]}):y.jsx(Sa,{children:e,debug:t,onContentHeightChange:O,onItemHeightChange:o,onViewportSizeChange:I,overscan:u,ref:B,scrollOffset:C,virtualize:v,...S})},mr=({backgroundColor:e,borderColor:t="cyan",borderStyle:n="round",children:s,columns:i,footer:r,maxHeight:o=.8,paddingX:a=2,paddingY:c=1,rows:l,scrollbarStyle:d="block",scrollRef:u,title:p,visible:f=!0,width:h=60})=>{const m=Jl(),{isLoading:b,palette:$}=Fg(),v=k.useRef(null),S=u??v;if(!f)return null;const C=i??(m.columns||80),P=l??(m.rows||24),j=e??(b?"black":$?.background??"black"),B=o<=1?Math.floor(P*o):Math.min(o,P-2),L=typeof p=="string"?y.jsx(V,{marginBottom:1,children:y.jsx(R,{bold:!0,color:t,children:p})}):p??null;return y.jsx(V,{alignItems:"center",height:P,justifyContent:"center",position:"absolute",width:C,children:y.jsxs(V,{backgroundColor:j,borderBackgroundColor:j,borderColor:t,borderStyle:n,flexDirection:"column",maxHeight:B,opaque:!0,paddingY:c,width:Math.min(h,C-4),children:[L!=null&&y.jsx(V,{flexShrink:0,paddingX:a,children:L}),y.jsx(nd,{flexGrow:1,flexShrink:1,paddingX:a,ref:S,scrollbar:!0,scrollbarColor:t,scrollbarStyle:d,children:s}),r!=null&&y.jsx(V,{alignItems:"center",flexDirection:"column",flexShrink:0,marginTop:1,paddingX:a,children:r})]})})},Ea=({autoExitSeconds:e,onCancel:t,visible:n})=>{const{exit:s}=ql(),[i,r]=k.useState(e||3),o=k.useRef(null),a=k.useRef(0);k.useEffect(()=>{if(!n)return;const l=e||3;r(l),a.current=Date.now();let d=l;return o.current=setInterval(()=>{d-=1,d<=0?(o.current&&(clearInterval(o.current),o.current=null),r(0),s()):r(d)},1e3),()=>{o.current&&(clearInterval(o.current),o.current=null)}},[n,e,s]);const c=k.useCallback(()=>{o.current&&(clearInterval(o.current),o.current=null),t()},[t]);return eo((l,d)=>{Date.now()-a.current<200||(l==="q"?s():c())},{isActive:n}),y.jsx(mr,{backgroundColor:"#1e1e1e",footer:y.jsxs(R,{dimColor:!0,children:["Press"," ",y.jsx(R,{bold:!0,color:"white",children:"q"})," ","to exit,"," ",y.jsx(R,{bold:!0,color:"white",children:"any key"})," ","to stay"]}),title:`Exiting in ${i}…`,visible:n,width:50,children:y.jsx(R,{dimColor:!0,children:"Stay to explore the results interactively."})})},zg=e=>{if(e.startsWith("⚠"))return"yellow";e.startsWith("── ")||e.startsWith("[dry-run]")},Jg=({focused:e,item:t,scrollRef:n})=>{const s=e?"white":"gray";return t?y.jsxs(V,{borderColor:s,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[y.jsx(V,{flexShrink:0,paddingTop:1,paddingX:2,children:y.jsx(R,{bold:!0,color:"white",children:t.entry.title})}),y.jsx(V,{flexShrink:0,paddingBottom:1,paddingX:2,children:y.jsx(R,{dimColor:!0,children:t.entry.description})}),y.jsx(nd,{flexGrow:1,flexShrink:1,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:y.jsxs(V,{flexDirection:"column",children:[y.jsx(R,{dimColor:!0,children:"── What will change ──"}),y.jsx(R,{}),t.preview.length===0&&y.jsx(R,{dimColor:!0,children:"(no preview available)"}),t.preview.map((i,r)=>{const o=zg(i);return i===""?y.jsx(R,{},`blank-${String(r)}`):y.jsx(R,{color:o,children:i},`${String(r)}-${i.slice(0,20)}`)})]})})]}):y.jsx(V,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:y.jsx(R,{dimColor:!0,children:"No migration selected"})})},Kg=({checked:e,isSelected:t,item:n})=>{const s=e?"☑":"☐",i=n.preview.length;return y.jsxs(V,{flexShrink:0,height:1,children:[y.jsx(R,{children:t?">":" "}),y.jsxs(R,{color:e?"white":"gray",children:[" ",s," "]}),y.jsx(V,{flexGrow:1,children:y.jsx(R,{bold:t,inverse:t,wrap:"truncate",children:n.entry.title})}),y.jsxs(R,{dimColor:!0,children:[" ",i," ","change",i===1?"":"s"," "]})]})},qg=({checkedItems:e,focused:t,isDryRun:n,items:s,scrollOffset:i,selectedIndex:r,viewportHeight:o})=>{const a=t?"white":"gray",c=s.filter(p=>e.has(p.entry.id)).length,l=s.map((p,f)=>y.jsx(Kg,{checked:e.has(p.entry.id),isSelected:f===r,item:p},p.entry.id)),d=s.length,u=d>o&&o>0;return y.jsxs(V,{borderColor:a,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[y.jsxs(V,{flexShrink:0,gap:1,paddingX:1,children:[y.jsx(R,{bold:!0,inverse:!0,children:" MIGRATE "}),y.jsxs(R,{wrap:"truncate",children:[s.length," ","applicable"]}),c>0&&y.jsxs(R,{dimColor:!0,children:[" — ",c," selected"]}),n&&y.jsx(R,{color:"yellow",children:" (dry-run)"})]}),y.jsxs(V,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[y.jsx(V,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:y.jsx(V,{flexDirection:"column",marginTop:-i,children:l})}),u&&y.jsx(V,{flexShrink:0,marginLeft:1,marginRight:1,children:y.jsx(td,{contentHeight:d,placement:"inset",scrollOffset:i,style:"block",viewportHeight:o})})]})]})},Yg=100,Xg=40,Zg=10,Qg=({autoExitSeconds:e=0,isDryRun:t,store:n})=>{const{exit:s}=ql(),{columns:i,rows:r}=Jl(),o=k.useSyncExternalStore(n.subscribe,n.getSnapshot),[a,c]=k.useState(!1),[l,d]=k.useState(!1),[u,p]=k.useState(!1),[f,h]=k.useState(0),m=k.useRef(null),b=k.useRef(null),$=k.useRef(null),v=o.items[o.selectedIndex]??null,S=Math.max(1,r-6),C=k.useCallback(_=>{h(w=>_>=w+S?Math.max(0,_-S+1):_<w?Math.max(0,_):w)},[S]);if(k.useEffect(()=>{b.current?.scrollToTop()},[v?.entry.id]),eo((_,w)=>{if(_==="c"&&w.ctrl){s();return}if(!u){if(l){_==="u"||w.return?(d(!1),n.startApply(),s(n.getCheckedItems())):w.escape||_==="q"?d(!1):w.downArrow||_==="j"?$.current?.scrollBy(1):(w.upArrow||_==="k")&&$.current?.scrollBy(-1);return}if(a){w.escape||_==="?"?c(!1):_==="q"?(c(!1),p(!0)):w.downArrow||_==="j"?m.current?.scrollBy(1):(w.upArrow||_==="k")&&m.current?.scrollBy(-1);return}if(_==="?"){c(!0);return}if(_==="q"){p(!0);return}if(w.tab){n.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(o.focusedPanel==="list"){if(w.downArrow||_==="j"){const A=Math.min(o.selectedIndex+1,o.items.length-1);n.setSelectedIndex(A),C(A);return}if(w.upArrow||_==="k"){const A=Math.max(o.selectedIndex-1,0);n.setSelectedIndex(A),C(A);return}if(w.pageDown){const A=Math.min(o.selectedIndex+10,o.items.length-1);n.setSelectedIndex(A),C(A);return}if(w.pageUp){const A=Math.max(o.selectedIndex-10,0);n.setSelectedIndex(A),C(A);return}if(w.home){n.setSelectedIndex(0),h(0);return}if(w.end){const A=o.items.length-1;n.setSelectedIndex(A),C(A);return}if(_===" "||w.return){v&&n.toggleCheck(v.entry.id);return}if(_==="a"){n.toggleAll();return}if(_==="u"&&!t&&o.checkedItems.size>0){d(!0);return}w.rightArrow&&n.setFocusedPanel("detail");return}if(o.focusedPanel==="detail"){if(w.escape||w.leftArrow){n.setFocusedPanel("list");return}if(w.downArrow||_==="j"){b.current?.scrollBy(1);return}if(w.upArrow||_==="k"){b.current?.scrollBy(-1);return}if(w.pageDown){b.current?.scrollBy(10);return}if(w.pageUp){b.current?.scrollBy(-10);return}if(w.home){b.current?.scrollToTop();return}w.end&&b.current?.scrollToBottom()}}},{isActive:!0}),i<Xg||r<Zg)return y.jsx(V,{alignItems:"center",height:r,justifyContent:"center",width:i,children:y.jsxs(R,{color:"yellow",children:["Terminal too small (",i,"x",r,")"]})});const P=i>=Yg,j=[y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"q"}),y.jsx(R,{dimColor:!0,children:"QUIT"})]},"q"),y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"?"}),y.jsx(R,{dimColor:!0,children:"HELP"})]},"?"),y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"↑↓"}),y.jsx(R,{dimColor:!0,children:"NAV"})]},"nav"),y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"Space"}),y.jsx(R,{dimColor:!0,children:"CHECK"})]},"sp"),y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"a"}),y.jsx(R,{dimColor:!0,children:"ALL"})]},"a")];!t&&o.checkedItems.size>0&&j.push(y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"green",children:"u"}),y.jsx(R,{dimColor:!0,children:"APPLY"})]},"u")),j.push(y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"Tab"}),y.jsx(R,{dimColor:!0,children:"PANEL"})]},"tab"));const B=y.jsx(V,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:y.jsx(V,{flexWrap:"wrap",gap:2,paddingX:1,children:j})}),L=y.jsxs(mr,{footer:y.jsxs(R,{dimColor:!0,children:[y.jsx(R,{bold:!0,color:"white",children:"↑↓"})," scroll ",y.jsx(R,{bold:!0,color:"white",children:"?"}),"/",y.jsx(R,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:m,title:"KEYBOARD SHORTCUTS",visible:a,width:52,children:[y.jsxs(V,{flexDirection:"column",marginBottom:1,children:[y.jsx(R,{bold:!0,color:"white",children:"NAVIGATION"}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" ↑/k"}),y.jsx(R,{dimColor:!0,children:" Move up"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" ↓/j"}),y.jsx(R,{dimColor:!0,children:" Move down"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" Tab"}),y.jsx(R,{dimColor:!0,children:" Switch panel"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" →/←"}),y.jsx(R,{dimColor:!0,children:" Focus detail/list"})]})]}),y.jsxs(V,{flexDirection:"column",marginBottom:1,children:[y.jsx(R,{bold:!0,color:"white",children:"SELECTION"}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" Space"}),y.jsx(R,{dimColor:!0,children:" Toggle migration"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" a"}),y.jsx(R,{dimColor:!0,children:" Toggle all"})]})]}),y.jsxs(V,{flexDirection:"column",children:[y.jsx(R,{bold:!0,color:"white",children:"ACTIONS"}),!t&&y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" u"}),y.jsx(R,{dimColor:!0,children:" Apply selected migrations"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" q"}),y.jsx(R,{dimColor:!0,children:" Quit"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" ?"}),y.jsx(R,{dimColor:!0,children:" Toggle help"})]})]})]}),D=n.getCheckedItems(),K=y.jsx(V,{alignItems:"center",flexDirection:"column",children:y.jsxs(R,{dimColor:!0,children:["Press ",y.jsx(R,{bold:!0,color:"white",children:"u"})," or ",y.jsx(R,{bold:!0,color:"white",children:"Enter"})," to confirm, ",y.jsx(R,{bold:!0,color:"white",children:"Esc"})," to cancel"]})}),ie=y.jsx(mr,{footer:K,scrollRef:$,title:`Apply ${String(D.length)} migration${D.length===1?"":"s"}?`,visible:l,width:70,children:D.map(_=>y.jsxs(V,{gap:1,children:[y.jsxs(R,{children:[" ",_.entry.title]}),y.jsxs(R,{dimColor:!0,children:["(",_.preview.length," ","change",_.preview.length===1?"":"s",")"]})]},_.entry.id))}),ee=y.jsx(qg,{checkedItems:o.checkedItems,focused:o.focusedPanel==="list",isDryRun:t,items:o.items,scrollOffset:f,selectedIndex:o.selectedIndex,viewportHeight:S}),te=y.jsx(Jg,{focused:o.focusedPanel==="detail",item:v,scrollRef:b});if(P){const _=Math.floor(i*.55);return y.jsxs(V,{flexDirection:"column",height:r,width:i,children:[y.jsxs(V,{flexDirection:"row",flexGrow:1,children:[y.jsx(V,{flexGrow:1,children:ee}),y.jsx(V,{width:_,children:te})]}),B,ie,y.jsx(Ea,{autoExitSeconds:e||3,onCancel:()=>{p(!1)},visible:u}),L]})}const se=Math.floor(r*.45);return y.jsxs(V,{flexDirection:"column",height:r,width:i,children:[y.jsx(V,{height:se,children:ee}),y.jsx(V,{flexGrow:1,children:te}),B,ie,y.jsx(Ea,{autoExitSeconds:e||3,onCancel:()=>{p(!1)},visible:u}),L]})},sd=[".lintstagedrc.json",".lintstagedrc"],id=[".lintstagedrc.yaml",".lintstagedrc.yml",".lintstagedrc.mjs","lint-staged.config.mjs",".lintstagedrc.cjs","lint-staged.config.cjs",".lintstagedrc.js","lint-staged.config.js",".lintstagedrc.ts","lint-staged.config.ts",".lintstagedrc.mts","lint-staged.config.mts",".lintstagedrc.cts","lint-staged.config.cts"],rd=[...sd,...id],ey=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+lint-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)lint-staged\b/],od=[".nano-staged.json",".nanostagedrc"],ad=[".nano-staged.mjs",".nano-staged.cjs",".nano-staged.js","nano-staged.config.mjs","nano-staged.config.cjs","nano-staged.config.js","nano-staged.config.mts","nano-staged.config.cts","nano-staged.config.ts"],cd=[...od,...ad],ty=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+nano-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)nano-staged\b/],ld=["husky","lint-staged","nano-staged"],ny=/\(is-ci \|\| husky \|\| exit 0\)\s*&&\s*/g,sy=/\bhusky(?:\s+install)?\s*&&\s*/g,iy=/\s*&&\s*husky(?:\s+install)?/g,ry=/\s*\|\|\s*husky(?:\s+install)?/g,oy=[ny,sy,iy,ry],dd=e=>{if(e==="husky"||e==="husky install")return;let t=e;for(const n of oy)t=t.replace(n,"");return t=t.trim(),t===e?e:t||void 0},ud=["pre-commit","pre-merge-commit","prepare-commit-msg","commit-msg","post-commit","applypatch-msg","pre-applypatch","post-applypatch","pre-rebase","post-rewrite","post-checkout","post-merge","pre-push","pre-auto-gc"],to=".vis/hooks",Zt=".vis-hooks",Bj=[".pre-commit-config.yaml",".pre-commit-config.yml","prek.toml"],Pj={commit:"pre-commit","merge-commit":"pre-merge-commit",push:"pre-push"},Nj=new Set(["commit-msg","post-checkout","post-commit","post-merge","post-rewrite","pre-commit","pre-merge-commit","pre-push","pre-rebase","prepare-commit-msg"]),Dj=new Set(["commit-msg","post-checkout","post-merge","post-rewrite","pre-rebase","prepare-commit-msg"]),Mj=new Set(["fail","script","system"]),ay="config.json",Ti=1,cy=new Set(["alwaysRun","args","builtin","entry","exclude","excludeTypes","fail","files","id","name","passFilenames","types","typesOr","verbose"]),ly=new Set(["failFast","skipInCI","stages","version"]),dy=["args","exclude","excludeTypes","files","passFilenames","types","typesOr"],pd=(e,t)=>g(e,t,ay),gr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),bs=e=>{if(!Array.isArray(e))return;const t=[];for(const n of e){if(typeof n!="string")return;t.push(n)}return t},Wn=e=>typeof e=="boolean"?e:void 0,Wt=e=>typeof e=="string"&&e.length>0?e:void 0,uy=(e,t,n)=>{if(!gr(e))throw new TypeError("hook entry must be an object");if(typeof e.id!="string"||e.id.length===0)throw new TypeError("hook entry is missing `id`");const s={id:e.id},i=Wn(e.alwaysRun);i!==void 0&&(s.alwaysRun=i);const r=bs(e.args);r&&(s.args=r);const o=Wt(e.builtin);o&&(s.builtin=o);const a=Wt(e.entry);a&&(s.entry=a);const c=Wt(e.exclude);c&&(s.exclude=c);const l=bs(e.excludeTypes);l&&(s.excludeTypes=l);const d=Wt(e.fail);d&&(s.fail=d);const u=Wt(e.files);u&&(s.files=u);const p=Wt(e.name);p&&(s.name=p);const f=Wn(e.passFilenames);f!==void 0&&(s.passFilenames=f);const h=bs(e.types);h&&(s.types=h);const m=bs(e.typesOr);m&&(s.typesOr=m);const b=Wn(e.verbose);if(b!==void 0&&(s.verbose=b),[s.builtin,s.entry,s.fail].filter(v=>v!==void 0).length!==1)throw new TypeError(`hook "${s.id}" must set exactly one of \`builtin\`, \`entry\`, \`fail\``);if(s.fail!==void 0){const v=dy.filter(S=>s[S]!==void 0);if(v.length>0)throw new TypeError(`hook "${s.id}" is a \`fail\` entry — remove ${v.join(", ")} (filters do not apply)`)}for(const v of Object.keys(e))cy.has(v)||t.push({hookId:s.id,message:`unknown field "${v}" ignored`,stage:n});return s},py=(e,t)=>{if(!gr(e))throw new TypeError("hook config must be an object");if(e.version!==Ti)throw new TypeError(`unsupported hook config version: expected ${Ti}, got ${String(e.version)}`);if(!gr(e.stages))throw new TypeError("hook config is missing `stages` map");const n={};for(const[o,a]of Object.entries(e.stages)){if(!Array.isArray(a))throw new TypeError(`hook config: stage "${o}" must be an array`);n[o]=a.map(c=>uy(c,t,o))}const s={stages:n,version:Ti},i=Wn(e.failFast);i!==void 0&&(s.failFast=i);const r=Wn(e.skipInCI);r!==void 0&&(s.skipInCI=r);for(const o of Object.keys(e))ly.has(o)||t.push({message:`unknown top-level field "${o}" ignored`});return s},fy=(e,t=to,n)=>{const s=pd(e,t);if(!x(s))return;const i=G(s);let r;try{r=JSON.parse(i)}catch(o){const a=o instanceof Error?o.message:String(o);throw new TypeError(`failed to parse ${s}: ${a}`,{cause:o})}return py(r,[])},Lj=(e,t,n)=>{const s=pd(e,t);ae(s,`${JSON.stringify(n,void 0,4)}
|
|
26
|
-
`,"utf8")},
|
|
19
|
+
`)),this.kittyProtocolEnabled=!1,mi.delete(this.options.stdout);const{exitResult:a}=this,c=()=>{Tr(t)?this.rejectExitPromise(t):this.resolveExitPromise(a)};t!==void 0&&!Tr(t)?c():s&&r?this.options.stdout.write("",c):setImmediate(c)},o=Se;this.options.concurrent?(Se.updateContainerSync(null,this.container,null,Cn),Se.flushSyncWork(),o.flushPassiveEffects?.(),i()):(Se.updateContainerSync(null,this.container,null,Cn),Se.flushSyncWork(),i())};async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},Re.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await xa(),this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(this.isConcurrent&&this.hasPendingConcurrentWork()&&(await Promise.race([this.awaitNextRender(),this.awaitExit()]),this.isUnmounted||this.isUnmounting)){this.nextRenderCommit=void 0,await this.awaitExit();return}Se.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:n,hasWritableState:s}=$a(t);if(vs(this.throttledOnRender,n),vs(this.throttledLog,n),n&&s){await new Promise(r=>{this.options.stdout.write("",()=>{r()})});return}await xa()}clear(){!this.interactive||this.options.debug||(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
|
|
20
|
+
`))}patchConsole(){this.options.debug||(this.restoreConsole=Km((t,n)=>{t==="stdout"&&this.writeToStdout(n),t==="stderr"&&(n.startsWith("The above error occurred")||this.writeToStderr(n))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,oa),this.writeBestEffort(this.options.stdout,Jn))}resolveInteractiveOption(t){return t??(!Hl&&this.options.stdout.isTTY)}resolveAlternateScreenOption(t,n){return!!t&&n&&this.options.stdout.isTTY}shouldSync(){return bg(this.options.stdout,this.interactive)}writeBestEffort(t,n){try{t.write(n)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){const t=this.container;return(t.pendingLanes??0)!==0&&t.callbackNode!==void 0&&t.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let t;const n=new Promise(s=>{t=s});this.nextRenderCommit={promise:n,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,n,s,r=""){const i=s+r,o=i!=="",a=this.options.stdout.isTTY,c=a?et(this.options.stdout).rows:24,l=a&&n>=c,d=l?t:`${t}
|
|
21
|
+
`,u=Re.platform==="win32",p=a&&u&&(l||this.lastOutputHeight>=c);if(Ag({isTty:a,isUnmounting:this.isUnmounting,isWindows:u,nextOutputHeight:n,previousOutputHeight:this.lastOutputHeight,viewportRows:c})){if(this.options.incrementalRendering&&!p){o&&(this.log.clear(),this.options.stdout.write(i)),(t!==this.lastOutput||this.log.isCursorDirty()||o)&&this.throttledLog(d),this.lastOutput=t,this.lastOutputToRender=d,this.lastOutputHeight=n;return}const f=this.shouldSync();f&&this.options.stdout.write(wt),this.options.stdout.write(tm+this.fullStaticOutput+r+d),this.lastOutput=t,this.lastOutputToRender=d,this.lastOutputHeight=n,this.log.sync(d),f&&this.options.stdout.write(Ze);return}if(o){const f=this.shouldSync();f&&this.options.stdout.write(wt),this.log.clear(),this.options.stdout.write(i),this.log(d),f&&this.options.stdout.write(Ze)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(d);this.lastOutput=t,this.lastOutputToRender=d,this.lastOutputHeight=n}initImmediateKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="enabled")return;const n=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(n)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const n=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(n)}confirmKittySupport(t){_l(this.options.stdin,async()=>this.runKittySupportQuery(t))}async runKittySupportQuery(t){const{stdin:n,stdout:s}=this.options;let r=[],i,o;const a=()=>{this.cancelKittyDetection=void 0,i&&clearTimeout(i),n.removeListener("data",c);const l=Og(r);r=[],l.length>0&&n.unshift(ma.from(l))},c=l=>{const d=typeof l=="string"?ma.from(l):l;for(const u of d)r.push(u);Tg(r)&&(a(),this.isUnmounted||this.enableKittyProtocol(t),o?.())};return n.on("data",c),s.write("\x1B[?u"),new Promise(l=>{o=l,i=setTimeout(()=>{a(),l()},200),this.cancelKittyDetection=()=>{a(),l()}})}registerInputControl=(t,n)=>{this.pauseInput=t,this.resumeInput=n};suspendTerminal=(async t=>{if(this.beginSuspend(),t){try{await t()}finally{await this.endSuspend()}return}const n=async()=>{await this.endSuspend()};return{resume:n,[Symbol.asyncDispose]:n}});beginSuspend(){if(this.isSuspended)throw new Error("The terminal is already suspended. Resume the current suspension before suspending again.");if(this.isSuspended=!0,!(!this.interactive||this.isUnmounted||this.isUnmounting))try{this.log.clear(),this.log.done(),this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,aa),this.writeBestEffort(this.options.stdout,qn)),this.pauseInput?.()}catch(t){this.isSuspended=!1;try{this.resumeInput?.()}catch{}throw t}}async endSuspend(){if(this.isSuspended&&(this.isSuspended=!1,this.resumeInput?.(),!(!this.interactive||this.isUnmounted||this.isUnmounting))){this.alternateScreen&&this.writeBestEffort(this.options.stdout,oa),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\x1B[>${ia(this.kittyFlags)}u`),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.log.reset();try{this.calculateLayout(),this.onRender(),await this.waitUntilRenderFlush()}catch{}}}enableKittyProtocol(t){this.kittyFlags=t,this.options.stdout.write(`\x1B[>${ia(t)}u`),this.kittyProtocolEnabled=!0}}const Bg=(e,t)=>{const n={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:Re.stderr,stdin:Re.stdin,stdout:Re.stdout,...Pg(t)},s=Ng(n.stdout,()=>new Ig(n));return s.render(e),{cleanup(){s.unmount()},clear(){s.clear()},rerender(r){s.render(r)},rootNode:s.rootNode,unmount(){s.unmount()},waitUntilExit(){return s.waitUntilExit()},waitUntilRenderFlush(){return s.waitUntilRenderFlush()}}},Pg=(e={})=>e instanceof zm?{stdin:Re.stdin,stdout:e}:e,Ng=(e,t)=>{const n=mi.get(e);if(n===void 0){const s=t();return mi.set(e,s),s}return Re.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
|
|
22
|
+
`),n},Xt="\x07",so="\x1B",Zt=`${so}]`,Ea=`${so}\\`,cr=16,Dg=3+cr,Mg=8192,Lg=e=>{const t=e.lastIndexOf(";"),n=cm(t===-1?e:e.slice(t+1));if(n===void 0)return null;const s=r=>r.toString(16).padStart(2,"0");return`#${s(n.r)}${s(n.g)}${s(n.b)}`},_g=()=>{const e=process.env.TERM_PROGRAM??"";return new Set(["Alacritty","contour","foot","Ghostty","iTerm2","iTerm.app","kitty","rio","WezTerm"]).has(e)?!0:(process.env.TERM??"").startsWith("xterm")||!!process.env.WT_SESSION},Fg=(e,t)=>{const n=Lg(e);if(n===null)return!1;if(e.startsWith("10;"))return t.foreground=n,!0;if(e.startsWith("11;"))return t.background=n,!0;if(e.startsWith("12;"))return t.cursor=n,!0;if(e.startsWith("4;")){const s=e.indexOf(";",2),r=Number(e.slice(2,s===-1?e.length:s));if(Number.isSafeInteger(r)&&r>=0&&r<cr)return t.colors[r]=n,!0}return!1},Vg=()=>{const e=[`${Zt}10;?${Xt}`,`${Zt}11;?${Xt}`,`${Zt}12;?${Xt}`];for(let t=0;t<cr;t+=1)e.push(`${Zt}4;${String(t)};?${Xt}`);return e.join("")},Us=new WeakMap,Wg=e=>{const t=[];let n="",s=e;for(;;){const r=s.indexOf(Zt);if(r===-1){const d=s.endsWith(so)?1:0;return n+=s.slice(0,s.length-d),{answers:t,foreign:n,rest:s.slice(s.length-d)}}n+=s.slice(0,r),s=s.slice(r);const i=s.indexOf(Xt),o=s.indexOf(Ea),a=i!==-1,c=o!==-1;if(!a&&!c)return{answers:t,foreign:n,rest:s};const l=a&&(!c||i<o)?i:o;t.push(s.slice(Zt.length,l)),s=s.slice(l+(l===i?Xt.length:Ea.length))}},Hg=async(e,t,n)=>new Promise(s=>{const r={colors:Array.from({length:cr})};let i="",o="",a=0,c=!1;const l=e.listenerCount("data")===0;let d;const u=f=>{const h=Wg(o+f.toString());i+=h.foreign,o=h.rest;for(const m of h.answers)Fg(m,r)&&(a+=1);(a>=Dg||o.length+i.length>Mg)&&p()};function p(){if(c)return;c=!0,d&&clearTimeout(d);const f=e.listenerCount("data")===1;e.removeListener("data",u);const h=i+o;if(l&&f&&h.length>0)try{e.pause(),e.unshift(h)}catch{}const m={};r.foreground&&(m.foreground=r.foreground),r.background&&(m.background=r.background),r.cursor&&(m.cursor=r.cursor),r.colors.some(Boolean)&&(m.colors=r.colors.map(v=>v??"")),s(m)}e.on("data",u),d=setTimeout(p,n),t.write(Vg())}),Ug=async(e,t)=>{const n=Promise.withResolvers(),s=()=>{n.resolve({})};t.addEventListener("abort",s,{once:!0});try{return await Promise.race([e,n.promise])}finally{t.removeEventListener("abort",s)}},Gg=async(e,t,n)=>{let s;try{s=await _l(e,async()=>Hg(e,t,n))}catch(r){throw Us.delete(t),r}return Object.keys(s).length===0&&Us.delete(t),s},zg=async(e,t,n=500,s)=>{if(s?.aborted)return{};let r=Us.get(t);return r||(r=Gg(e,t,n),Us.set(t,r)),s?Ug(r,s):r},Ql=()=>k.useContext(to),ed=()=>{const{stdout:e}=Ql(),[t,n]=k.useState(()=>et(e));return k.useEffect(()=>{const s=()=>{n(et(e))};return e.on("resize",s),()=>{e.off("resize",s)}},[e]),t},Jg=()=>k.useContext(rr),td=()=>k.useContext(rr);class qg{#e;#t=new Set;constructor(t){this.#e={applyProgress:null,checkedItems:new Set(t.map(n=>n.entry.id)),error:null,focusedPanel:"list",items:t,phase:"browsing",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#t.add(t),()=>{this.#t.delete(t)});getCheckedItems(){return this.#e.items.filter(t=>this.#e.checkedItems.has(t.entry.id))}getSelectedItem(){return this.#e.items[this.#e.selectedIndex]??null}setSelectedIndex(t){const n=Math.max(0,Math.min(t,this.#e.items.length-1));n!==this.#e.selectedIndex&&this.#n({...this.#e,selectedIndex:n})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#n({...this.#e,focusedPanel:t})}toggleCheck(t){const n=new Set(this.#e.checkedItems);n.has(t)?n.delete(t):n.add(t),this.#n({...this.#e,checkedItems:n})}checkAll(){this.#n({...this.#e,checkedItems:new Set(this.#e.items.map(t=>t.entry.id))})}uncheckAll(){this.#n({...this.#e,checkedItems:new Set})}toggleAll(){this.#e.checkedItems.size===this.#e.items.length?this.uncheckAll():this.checkAll()}startApply(){const t=this.getCheckedItems().length;this.#n({...this.#e,applyProgress:{current:0,total:t},phase:"applying"})}updateApplyProgress(t){this.#e.applyProgress&&this.#n({...this.#e,applyProgress:{...this.#e.applyProgress,current:t}})}markDone(){this.#n({...this.#e,phase:"done"})}setError(t){this.#n({...this.#e,error:t,phase:"error"})}#n(t){this.#e=t;for(const n of this.#t)try{n()}catch{}}}const nd=()=>k.useContext(Qi);let Kg;const Yg=e=>(Kg??=Be(import.meta.url))(e),Rn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xg=e=>{if(typeof Rn<"u"&&Rn.versions&&Rn.versions.node){const[t,n]=Rn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Rn.getBuiltinModule(e)}return Yg(e)},{Buffer:Zg}=Xg("node:buffer"),Qg=/^\u001B([a-z0-9])$/i,ey=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,sd={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},ty=[...Object.values(sd),"backspace"],ny=e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),sy=e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),rd=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,ry=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,iy={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},oy={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},Ca={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},id=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),Or=e=>id(e)?String.fromCodePoint(e):"?";function od(e){return e===3?"release":e===2?"repeat":"press"}function ad(e){return{capsLock:!!(e&Ye.capsLock),ctrl:!!(e&Ye.ctrl),hyper:!!(e&Ye.hyper),meta:!!(e&Ye.meta),numLock:!!(e&Ye.numLock),option:!!(e&Ye.alt),shift:!!(e&Ye.shift),super:!!(e&Ye.super)}}const ay=e=>{const t=rd.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),s=t[2]?Math.max(0,Number.parseInt(t[2],10)-1):0,r=t[3]?Number.parseInt(t[3],10):1,i=t[4];if(!id(n))return null;let o;i&&(o=i.split(":").map(l=>Or(Number.parseInt(l,10))).join(""));let a,c;return n===32?(a="space",c=!0):n===13?(a="return",c=!0):Ca[n]?(a=Ca[n],c=!1):n>=1&&n<=26?(a=String.fromCodePoint(n+96),c=!1):(a=Or(n).toLowerCase(),c=!0),c&&!o&&(o=Or(n)),{name:a,...ad(s),eventType:od(r),isKittyProtocol:!0,isPrintable:c,raw:e,sequence:e,text:o}},cy=e=>{const t=ry.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),s=Math.max(0,Number.parseInt(t[2],10)-1),r=Number.parseInt(t[3],10),i=t[4],o=i==="~"?oy[n]:iy[i];return o?{name:o,...ad(s),eventType:od(r),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},ly=(e="")=>{let t;Zg.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const n=ay(e);if(n)return n;const s=cy(e);if(s)return s;if(rd.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const r={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(r.sequence=r.sequence||e||r.name,e){case"\r":case"\x1B\r":{r.raw=void 0,r.name="return",r.option=e.length===2;break}case`
|
|
23
|
+
`:{r.name="enter";break}case" ":{r.name="tab";break}case" ":case"\x1B ":{r.name="space",r.meta=e.length===2;break}case"\b":case"\x1B\b":{r.name="backspace",r.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{r.name="escape",r.meta=e.length===2;break}case"\x1B":case"":{r.name="backspace",r.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(t=Qg.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(t[1]);else if(t=ey.exec(e)){const i=[...e];i[0]==="\x1B"&&i[1]==="\x1B"&&(r.option=!0);const o=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;r.ctrl=!!(a&4),r.meta=!!(a&10),r.shift=!!(a&1),r.code=o,r.name=sd[o]??"",r.shift=ny(o)||r.shift,r.ctrl=sy(o)||r.ctrl}}return r},ro=(e,t={})=>{const{internal_eventEmitter:n,internal_exitOnCtrlC:s,setRawMode:r,stdin:i}=td(),o=t.imeEnabled??!0,a=t.imeTimeout??50,c=k.useRef(void 0),l=k.useEffectEvent(e);k.useEffect(()=>{if(o)return c.current=new Vh({onFlush:d=>{const u={backspace:!1,capsLock:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,hyper:!1,leftArrow:!1,meta:!1,numLock:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,super:!1,tab:!1,upArrow:!1};Se.discreteUpdates(()=>{l(d,u)})},timeout:a}),()=>{c.current?.destroy(),c.current=void 0}},[o,a]),k.useEffect(()=>{if(t.isActive!==!1)return r(!0),()=>{r(!1)}},[t.isActive,r]),k.useLayoutEffect(()=>{if(t.isActive===!1)return;const d=u=>{if(o&&Fh(u)){c.current?.add(u);return}c.current?.flush();const p=ly(u),f={backspace:p.name==="backspace",capsLock:p.capsLock??!1,ctrl:p.ctrl,delete:p.name==="delete",downArrow:p.name==="down",end:p.name==="end",escape:p.name==="escape",eventType:p.eventType,home:p.name==="home",hyper:p.hyper??!1,leftArrow:p.name==="left",meta:p.meta||p.option,numLock:p.numLock??!1,pageDown:p.name==="pagedown",pageUp:p.name==="pageup",return:p.name==="return",rightArrow:p.name==="right",shift:p.shift,super:p.super??!1,tab:p.name==="tab",upArrow:p.name==="up"};let h;p.isKittyProtocol?p.isPrintable?h=p.text??p.name:p.ctrl&&p.name.length===1?h=p.name:h="":p.ctrl?h=p.name:h=p.sequence,!p.isKittyProtocol&&ty.includes(p.name)&&(h=""),h.startsWith("\x1B")&&(h=h.slice(1)),h.length===1&&typeof h[0]=="string"&&/[A-Z]/.test(h[0])&&(f.shift=!0),!(h==="c"&&f.ctrl&&s)&&(!p.name&&h===""||Se.discreteUpdates(()=>{l(h,f)}))};return n.on("input",d),()=>{n.removeListener("input",d)}},[t.isActive,i,s,o])},dy=()=>{const{stdin:e}=td(),{stdout:t}=Ql(),[n,s]=k.useState(null),[r,i]=k.useState(!0),o=k.useMemo(()=>_g(),[]);return k.useEffect(()=>{if(!o||!e||!t){i(!1);return}const a=new AbortController;return(async()=>{try{const c=await zg(e,t,200,a.signal);a.signal.aborted||s(c)}catch{}finally{a.signal.aborted||i(!1)}})(),()=>{a.abort()}},[o,e,t]),{isLoading:r,isSupported:o,palette:n}},uy=({autoFocus:e=!1,id:t,isActive:n=!0}={})=>{const{isRawModeSupported:s,setRawMode:r}=Jg(),{activate:i,activeId:o,add:a,deactivate:c,focus:l,remove:d}=k.useContext(eo),u=k.useMemo(()=>t??Math.random().toString().slice(2,7),[t]);return k.useEffect(()=>(a(u,{autoFocus:e}),()=>{d(u)}),[u,e]),k.useEffect(()=>{n?i(u):c(u)},[n,u]),k.useEffect(()=>{if(!(!s||!n))return r(!0),()=>{r(!1)}},[n]),{focus:l,isFocused:!!u&&o===u}},py=e=>{const{getViewportHeight:t,isActive:n=!0,scrollBy:s,scrollToBottom:r,scrollToTop:i,vimBindings:o=!1}=e,{isFocused:a}=uy({isActive:n});return ro((c,l)=>{if(l.upArrow){s(-1);return}if(l.downArrow){s(1);return}if(l.pageUp){s(-t());return}if(l.pageDown){s(t());return}if(l.home){i();return}if(l.end){r();return}if(l.ctrl&&c==="u"){s(-Math.floor(t()/2));return}if(l.ctrl&&c==="d"){s(Math.floor(t()/2));return}if(o){if(c==="k"){s(-1);return}if(c==="j"){s(1);return}if(c==="G"&&l.shift){r();return}if(c==="g"&&!l.shift){i();return}if(c==="u"&&!l.ctrl){s(-Math.floor(t()/2));return}c==="d"&&!l.ctrl&&s(Math.floor(t()/2))}},{isActive:n}),{isFocused:a}},gi=e=>{const[t,n]=k.useState(e),s=k.useRef(e),r=k.useCallback(o=>{const a=typeof o=="function"?o(s.current):o;s.current=a,n(a)},[]),i=k.useCallback(()=>s.current,[]);return[t,r,i]},fy=({children:e,index:t,measureKey:n,onMeasure:s,width:r})=>{const i=k.useRef(null);return k.useLayoutEffect(()=>{if(i.current){const{height:o}=dl(i.current);s(t,o)}},[t,s,r,n,e]),y.jsx(V,{flexDirection:"column",flexShrink:0,ref:i,width:"100%",children:e})},Gs=e=>{if(e==null)return[];if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n+=1){const s=e[n];k.isValidElement(s)&&s.type===k.Fragment?t.push(...Gs(s.props.children)):t.push(s)}return t}return k.isValidElement(e)&&e.type===k.Fragment?Gs(e.props.children):[e]},Ra=({children:e,debug:t=!1,onContentHeightChange:n,onItemHeightChange:s,onViewportSizeChange:r,overscan:i=3,ref:o,scrollOffset:a,virtualize:c=!1,...l})=>{const d=k.useRef(!1),[u,p,f]=gi({height:0,width:0}),[h,m,v]=gi(0),[$,b]=k.useState({}),S=k.useRef(null),C=k.useRef(0);k.useLayoutEffect(()=>{h!==C.current&&(n?.(h,C.current),C.current=h)},[h,n]);const P=k.useRef({}),T=k.useRef([]),N=k.useRef([]),_=k.useRef(0),F=k.useCallback((O,I)=>{const j=T.current[O]??O;if(P.current[j]!==I){const L=P.current[j]??0;P.current={...P.current,[j]:I};let W=0;for(let q=0;q<T.current.length;q+=1){const B=T.current[q];B!=null&&(W+=P.current[B]??0)}const U=v();W!==U&&m(W),s?.(O,I,L),_.current=Math.min(_.current,O+1)}},[s,v,m]),Y=k.useCallback(()=>{if(S.current){const{height:O,width:I}=dl(S.current),j=f();(I!==j.width||O!==j.height)&&(r?.({height:O,width:I},j),p({height:O,width:I}))}},[S,r,f,p]);k.useLayoutEffect(()=>{Y()});const re=k.useRef(null);if(re.current!==e){re.current=e;const O=[],I={};Gs(e).forEach((W,U)=>{if(!W)return;const q=(k.isValidElement(W)?W.key:null)??U;O[U]=q;const B=P.current[q]??0;I[q]=B}),P.current=I,T.current=O,N.current=Array.from({length:O.length}).fill(0),_.current=0;let j=0;O.forEach(W=>{j+=I[W]??0});const L=v();j!==L&&m(j)}k.useImperativeHandle(o,()=>({getBottomOffset:()=>Math.max(0,v()-f().height),getContentHeight:v,getItemHeight:O=>{const I=T.current[O]??O;return P.current[I]??0},getItemPosition:O=>{if(O<0||O>=T.current.length)return null;if(O>=_.current){let L=0,W=0;if(_.current>0){W=_.current;const U=W-1,q=T.current[U]??U,B=P.current[q]??0;L=(N.current[U]??0)+B}for(let U=W;U<=O;U+=1){N.current[U]=L;const q=T.current[U]??U,B=P.current[q]??0;L+=B}_.current=O+1}const I=N.current[O]??0,j=T.current[O]??O;return{height:P.current[j]??0,top:I}},getViewportHeight:()=>f().height,remeasure:Y,remeasureItem:O=>{b(I=>({...I,[O]:(I[O]??0)+1}))}}),[Y,v,f,b]);const ee=Gs(e);!d.current&&h>0&&(d.current=!0);let te=0,se=ee.length-1,M=0,w=0;const A=ee.length>0&&ee.every((O,I)=>{const j=T.current[I]??I;return(P.current[j]??0)>0}),H=c&&d.current&&A;if(H){const O=T.current.length;if(_.current<O){let j=0,L=0;if(_.current>0){L=_.current;const W=L-1,U=T.current[W]??W,q=P.current[U]??0;j=(N.current[W]??0)+q}for(let W=L;W<O;W+=1){N.current[W]=j;const U=T.current[W]??W;j+=P.current[U]??0}_.current=O}const I=a+u.height;te=ee.length,se=-1;for(let j=0;j<O;j+=1){const L=N.current[j]??0,W=T.current[j]??j,U=P.current[W]??0;L+U>a&&L<I&&(j<te&&(te=j),se=j)}if(te>se&&(te=0,se=-1),te=Math.max(0,te-i),se=Math.min(ee.length-1,Math.max(-1,se)+i),M=N.current[te]??0,se<ee.length-1){const j=T.current[se]??se,L=(N.current[se]??0)+(P.current[j]??0);w=h-L}}return y.jsx(V,{...l,children:y.jsx(V,{ref:S,width:"100%",children:y.jsx(V,{overflow:t?void 0:"hidden",width:"100%",children:y.jsxs(V,{flexDirection:"column",marginTop:-a,width:"100%",children:[H&&M>0&&y.jsx(V,{height:M}),ee.map((O,I)=>!O||H&&(I<te||I>se)?null:y.jsx(fy,{index:I,measureKey:$[I],onMeasure:F,width:u.width,children:O},k.isValidElement(O)?O.key??I:I)),H&&w>0&&y.jsx(V,{height:w})]})})})})},ja={arrow:{lowerThumb:"╽",thumb:"┃",track:"|",upperThumb:"╿"},block:{thumb:"█",track:"░"},bold:{lowerThumb:"╿",thumb:"│",track:"┃",upperThumb:"╽"},classic:{thumb:"┃",track:"|"},dots:{thumb:"●",track:"·"},double:{thumb:"┃",track:"║"},doubleSingle:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},line:{thumb:"│",track:" "},round:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},single:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},singleDouble:{thumb:"┃",track:"║"},thick:{thumb:"┃",track:"╏"}},Ta={arrow:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},bold:{bottomLeft:"┗",bottomRight:"┛",topLeft:"┏",topRight:"┓"},classic:{bottomLeft:"+",bottomRight:"+",topLeft:"+",topRight:"+"},double:{bottomLeft:"╚",bottomRight:"╝",topLeft:"╔",topRight:"╗"},doubleSingle:{bottomLeft:"╘",bottomRight:"╛",topLeft:"╒",topRight:"╕"},round:{bottomLeft:"╰",bottomRight:"╯",topLeft:"╭",topRight:"╮"},single:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},singleDouble:{bottomLeft:"╙",bottomRight:"╜",topLeft:"╓",topRight:"╖"}},hy=e=>ja[typeof e=="string"?e:"single"]??ja.single??{thumb:"┃",track:"│"},my=e=>Ta[typeof e=="string"?e:"single"]??Ta.single??{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},cd=({autoHide:e=!1,color:t,contentHeight:n,dimColor:s,placement:r="right",scrollOffset:i,style:o,thumbChar:a,trackChar:c,viewportHeight:l})=>{const d=k.useMemo(()=>{const h=Math.max(n,l);if(e&&h<=l)return null;const m=hy(o),v=a??m.thumb,$=c??m.track,b=l*2,S=Math.min(l/h,1),C=Math.max(2,Math.round(b*S)),P=h-l,T=P>0?Math.min(Math.max(i/P,0),1):0,N=b-C,_=Math.round(T*N),F=_+C,Y=[];for(let re=0;re<l;re+=1){const ee=re*2,te=re*2+1,se=ee>=_&&ee<F,M=te>=_&&te<F;se&&M?Y.push(v):se&&!M?Y.push(m.lowerThumb??v):!se&&M?Y.push(m.upperThumb??v):Y.push($)}return Y},[n,l,i,o,a,c,e]);if(d===null)return null;if(r==="inset")return y.jsx(V,{flexDirection:"column",flexShrink:0,width:1,children:d.map((h,m)=>y.jsx(R,{color:t,dimColor:s,children:h},m))});const u=my(o),p=r==="left"?u.topLeft:u.topRight,f=r==="left"?u.bottomLeft:u.bottomRight;return y.jsxs(V,{flexDirection:"column",flexShrink:0,width:1,children:[y.jsx(R,{color:t,dimColor:s,children:p}),d.map((h,m)=>y.jsx(R,{color:t,dimColor:s,children:h},m)),y.jsx(R,{color:t,dimColor:s,children:f})]})},ld=({children:e,debug:t=!1,followOutput:n=!1,followThreshold:s=3,keyboard:r=!1,onContentHeightChange:i,onItemHeightChange:o,onReachEnd:a,onReachStart:c,onScroll:l,onViewportSizeChange:d,overscan:u,reachThreshold:p=5,ref:f,scrollbar:h=!1,scrollbarColor:m,scrollbarStyle:v="line",vimBindings:$=!1,virtualize:b,...S})=>{const[C,P,T]=gi(0),N=k.useRef(null),_=k.useRef(0),F=k.useRef(0),[Y,re]=k.useState(0),[ee,te]=k.useState(0),se=k.useRef(!1),M=k.useRef(!1),w=k.useCallback(()=>Math.max(0,_.current-F.current),[]),A=k.useCallback(B=>{const J=w();a&&B>=J-p&&!se.current?(se.current=!0,a()):B<J-p&&(se.current=!1),c&&B<=p&&!M.current?(M.current=!0,c()):B>p&&(M.current=!1)},[a,c,p,w]),H=k.useCallback(B=>{B!==T()&&(P(B),l?.(B),A(B))},[T,P,l,A]),O=k.useCallback((B,J)=>{const oe=T()>=w()-s;if(_.current=B,re(B),i?.(B,J),n&&oe&&B>J){const ce=Math.max(0,B-F.current);H(ce)}else{const ce=Math.max(0,B-F.current);T()>ce&&H(ce)}},[i,n,s,T,w,H]),I=k.useCallback((B,J)=>{F.current=B.height,te(B.height),d?.(B,J)},[d]),j=k.useCallback(B=>{if(typeof B!="number"||Number.isNaN(B))return;const J=Math.max(0,_.current-F.current),oe=Math.max(0,Math.min(T()+B,J));H(oe)},[T,H]),L=k.useCallback(B=>{if(typeof B!="number"||Number.isNaN(B))return;const J=Math.max(0,_.current-F.current),oe=Math.max(0,Math.min(B,J));H(oe)},[H]),W=k.useCallback(()=>{const B=w();H(B)},[w,H]),U=k.useCallback(()=>{H(0)},[H]),q=k.useCallback(()=>F.current,[]);return py({getViewportHeight:q,isActive:r,scrollBy:j,scrollToBottom:W,scrollToTop:U,vimBindings:$}),k.useImperativeHandle(f,()=>({getBottomOffset:w,getContentHeight:()=>_.current,getItemHeight:B=>N.current?.getItemHeight(B)??0,getItemPosition:B=>N.current?.getItemPosition(B)??null,getScrollOffset:T,getViewportHeight:()=>F.current,remeasure:()=>N.current?.remeasure(),remeasureItem:B=>N.current?.remeasureItem(B),scrollBy:j,scrollTo:L,scrollToBottom:W,scrollToTop:U}),[w,T,j,L,W,U]),h&&Y>ee&&ee>0?y.jsxs(V,{flexDirection:"row",flexGrow:S.flexGrow,flexShrink:S.flexShrink,overflow:"hidden",children:[y.jsx(Ra,{children:e,debug:t,onContentHeightChange:O,onItemHeightChange:o,onViewportSizeChange:I,overscan:u,ref:N,scrollOffset:C,virtualize:b,...S,flexGrow:1}),y.jsx(cd,{color:m,contentHeight:Y,placement:"inset",scrollOffset:C,style:v,viewportHeight:ee})]}):y.jsx(Ra,{children:e,debug:t,onContentHeightChange:O,onItemHeightChange:o,onViewportSizeChange:I,overscan:u,ref:N,scrollOffset:C,virtualize:b,...S})},yi=({backgroundColor:e,borderColor:t="cyan",borderStyle:n="round",children:s,columns:r,footer:i,maxHeight:o=.8,paddingX:a=2,paddingY:c=1,rows:l,scrollbarStyle:d="block",scrollRef:u,title:p,visible:f=!0,width:h=60})=>{const m=ed(),{isLoading:v,palette:$}=dy(),b=k.useRef(null),S=u??b;if(!f)return null;const C=r??(m.columns||80),P=l??(m.rows||24),T=e??(v?"black":$?.background??"black"),N=o<=1?Math.floor(P*o):Math.min(o,P-2),_=typeof p=="string"?y.jsx(V,{marginBottom:1,children:y.jsx(R,{bold:!0,color:t,children:p})}):p??null;return y.jsx(V,{alignItems:"center",height:P,justifyContent:"center",position:"absolute",width:C,children:y.jsxs(V,{backgroundColor:T,borderBackgroundColor:T,borderColor:t,borderStyle:n,flexDirection:"column",maxHeight:N,opaque:!0,paddingY:c,width:Math.min(h,C-4),children:[_!=null&&y.jsx(V,{flexShrink:0,paddingX:a,children:_}),y.jsx(ld,{flexGrow:1,flexShrink:1,paddingX:a,ref:S,scrollbar:!0,scrollbarColor:t,scrollbarStyle:d,children:s}),i!=null&&y.jsx(V,{alignItems:"center",flexDirection:"column",flexShrink:0,marginTop:1,paddingX:a,children:i})]})})},Oa=({autoExitSeconds:e,onCancel:t,visible:n})=>{const{exit:s}=nd(),[r,i]=k.useState(e||3),o=k.useRef(null),a=k.useRef(0);k.useEffect(()=>{if(!n)return;const l=e||3;i(l),a.current=Date.now();let d=l;return o.current=setInterval(()=>{d-=1,d<=0?(o.current&&(clearInterval(o.current),o.current=null),i(0),s()):i(d)},1e3),()=>{o.current&&(clearInterval(o.current),o.current=null)}},[n,e,s]);const c=k.useCallback(()=>{o.current&&(clearInterval(o.current),o.current=null),t()},[t]);return ro((l,d)=>{Date.now()-a.current<200||(l==="q"?s():c())},{isActive:n}),y.jsx(yi,{backgroundColor:"#1e1e1e",footer:y.jsxs(R,{dimColor:!0,children:["Press"," ",y.jsx(R,{bold:!0,color:"white",children:"q"})," ","to exit,"," ",y.jsx(R,{bold:!0,color:"white",children:"any key"})," ","to stay"]}),title:`Exiting in ${r}…`,visible:n,width:50,children:y.jsx(R,{dimColor:!0,children:"Stay to explore the results interactively."})})},gy=e=>{if(e.startsWith("⚠"))return"yellow";e.startsWith("── ")||e.startsWith("[dry-run]")},yy=({focused:e,item:t,scrollRef:n})=>{const s=e?"white":"gray";return t?y.jsxs(V,{borderColor:s,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[y.jsx(V,{flexShrink:0,paddingTop:1,paddingX:2,children:y.jsx(R,{bold:!0,color:"white",children:t.entry.title})}),y.jsx(V,{flexShrink:0,paddingBottom:1,paddingX:2,children:y.jsx(R,{dimColor:!0,children:t.entry.description})}),y.jsx(ld,{flexGrow:1,flexShrink:1,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:y.jsxs(V,{flexDirection:"column",children:[y.jsx(R,{dimColor:!0,children:"── What will change ──"}),y.jsx(R,{}),t.preview.length===0&&y.jsx(R,{dimColor:!0,children:"(no preview available)"}),t.preview.map((r,i)=>{const o=gy(r);return r===""?y.jsx(R,{},`blank-${String(i)}`):y.jsx(R,{color:o,children:r},`${String(i)}-${r.slice(0,20)}`)})]})})]}):y.jsx(V,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:y.jsx(R,{dimColor:!0,children:"No migration selected"})})},vy=({checked:e,isSelected:t,item:n})=>{const s=e?"☑":"☐",r=n.preview.length;return y.jsxs(V,{flexShrink:0,height:1,children:[y.jsx(R,{children:t?">":" "}),y.jsxs(R,{color:e?"white":"gray",children:[" ",s," "]}),y.jsx(V,{flexGrow:1,children:y.jsx(R,{bold:t,inverse:t,wrap:"truncate",children:n.entry.title})}),y.jsxs(R,{dimColor:!0,children:[" ",r," ","change",r===1?"":"s"," "]})]})},by=({checkedItems:e,focused:t,isDryRun:n,items:s,scrollOffset:r,selectedIndex:i,viewportHeight:o})=>{const a=t?"white":"gray",c=s.filter(p=>e.has(p.entry.id)).length,l=s.map((p,f)=>y.jsx(vy,{checked:e.has(p.entry.id),isSelected:f===i,item:p},p.entry.id)),d=s.length,u=d>o&&o>0;return y.jsxs(V,{borderColor:a,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[y.jsxs(V,{flexShrink:0,gap:1,paddingX:1,children:[y.jsx(R,{bold:!0,inverse:!0,children:" MIGRATE "}),y.jsxs(R,{wrap:"truncate",children:[s.length," ","applicable"]}),c>0&&y.jsxs(R,{dimColor:!0,children:[" — ",c," selected"]}),n&&y.jsx(R,{color:"yellow",children:" (dry-run)"})]}),y.jsxs(V,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[y.jsx(V,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:y.jsx(V,{flexDirection:"column",marginTop:-r,children:l})}),u&&y.jsx(V,{flexShrink:0,marginLeft:1,marginRight:1,children:y.jsx(cd,{contentHeight:d,placement:"inset",scrollOffset:r,style:"block",viewportHeight:o})})]})]})},wy=100,ky=40,Sy=10,xy=({autoExitSeconds:e=0,isDryRun:t,store:n})=>{const{exit:s}=nd(),{columns:r,rows:i}=ed(),o=k.useSyncExternalStore(n.subscribe,n.getSnapshot),[a,c]=k.useState(!1),[l,d]=k.useState(!1),[u,p]=k.useState(!1),[f,h]=k.useState(0),m=k.useRef(null),v=k.useRef(null),$=k.useRef(null),b=o.items[o.selectedIndex]??null,S=Math.max(1,i-6),C=k.useCallback(M=>{h(w=>M>=w+S?Math.max(0,M-S+1):M<w?Math.max(0,M):w)},[S]);if(k.useEffect(()=>{v.current?.scrollToTop()},[b?.entry.id]),ro((M,w)=>{if(M==="c"&&w.ctrl){s();return}if(!u){if(l){M==="u"||w.return?(d(!1),n.startApply(),s(n.getCheckedItems())):w.escape||M==="q"?d(!1):w.downArrow||M==="j"?$.current?.scrollBy(1):(w.upArrow||M==="k")&&$.current?.scrollBy(-1);return}if(a){w.escape||M==="?"?c(!1):M==="q"?(c(!1),p(!0)):w.downArrow||M==="j"?m.current?.scrollBy(1):(w.upArrow||M==="k")&&m.current?.scrollBy(-1);return}if(M==="?"){c(!0);return}if(M==="q"){p(!0);return}if(w.tab){n.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(o.focusedPanel==="list"){if(w.downArrow||M==="j"){const A=Math.min(o.selectedIndex+1,o.items.length-1);n.setSelectedIndex(A),C(A);return}if(w.upArrow||M==="k"){const A=Math.max(o.selectedIndex-1,0);n.setSelectedIndex(A),C(A);return}if(w.pageDown){const A=Math.min(o.selectedIndex+10,o.items.length-1);n.setSelectedIndex(A),C(A);return}if(w.pageUp){const A=Math.max(o.selectedIndex-10,0);n.setSelectedIndex(A),C(A);return}if(w.home){n.setSelectedIndex(0),h(0);return}if(w.end){const A=o.items.length-1;n.setSelectedIndex(A),C(A);return}if(M===" "||w.return){b&&n.toggleCheck(b.entry.id);return}if(M==="a"){n.toggleAll();return}if(M==="u"&&!t&&o.checkedItems.size>0){d(!0);return}w.rightArrow&&n.setFocusedPanel("detail");return}if(o.focusedPanel==="detail"){if(w.escape||w.leftArrow){n.setFocusedPanel("list");return}if(w.downArrow||M==="j"){v.current?.scrollBy(1);return}if(w.upArrow||M==="k"){v.current?.scrollBy(-1);return}if(w.pageDown){v.current?.scrollBy(10);return}if(w.pageUp){v.current?.scrollBy(-10);return}if(w.home){v.current?.scrollToTop();return}w.end&&v.current?.scrollToBottom()}}},{isActive:!0}),r<ky||i<Sy)return y.jsx(V,{alignItems:"center",height:i,justifyContent:"center",width:r,children:y.jsxs(R,{color:"yellow",children:["Terminal too small (",r,"x",i,")"]})});const P=r>=wy,T=[y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"q"}),y.jsx(R,{dimColor:!0,children:"QUIT"})]},"q"),y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"?"}),y.jsx(R,{dimColor:!0,children:"HELP"})]},"?"),y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"↑↓"}),y.jsx(R,{dimColor:!0,children:"NAV"})]},"nav"),y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"Space"}),y.jsx(R,{dimColor:!0,children:"CHECK"})]},"sp"),y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"a"}),y.jsx(R,{dimColor:!0,children:"ALL"})]},"a")];!t&&o.checkedItems.size>0&&T.push(y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"green",children:"u"}),y.jsx(R,{dimColor:!0,children:"APPLY"})]},"u")),T.push(y.jsxs(V,{gap:1,children:[y.jsx(R,{bold:!0,color:"white",children:"Tab"}),y.jsx(R,{dimColor:!0,children:"PANEL"})]},"tab"));const N=y.jsx(V,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:y.jsx(V,{flexWrap:"wrap",gap:2,paddingX:1,children:T})}),_=y.jsxs(yi,{footer:y.jsxs(R,{dimColor:!0,children:[y.jsx(R,{bold:!0,color:"white",children:"↑↓"})," scroll ",y.jsx(R,{bold:!0,color:"white",children:"?"}),"/",y.jsx(R,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:m,title:"KEYBOARD SHORTCUTS",visible:a,width:52,children:[y.jsxs(V,{flexDirection:"column",marginBottom:1,children:[y.jsx(R,{bold:!0,color:"white",children:"NAVIGATION"}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" ↑/k"}),y.jsx(R,{dimColor:!0,children:" Move up"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" ↓/j"}),y.jsx(R,{dimColor:!0,children:" Move down"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" Tab"}),y.jsx(R,{dimColor:!0,children:" Switch panel"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" →/←"}),y.jsx(R,{dimColor:!0,children:" Focus detail/list"})]})]}),y.jsxs(V,{flexDirection:"column",marginBottom:1,children:[y.jsx(R,{bold:!0,color:"white",children:"SELECTION"}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" Space"}),y.jsx(R,{dimColor:!0,children:" Toggle migration"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" a"}),y.jsx(R,{dimColor:!0,children:" Toggle all"})]})]}),y.jsxs(V,{flexDirection:"column",children:[y.jsx(R,{bold:!0,color:"white",children:"ACTIONS"}),!t&&y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" u"}),y.jsx(R,{dimColor:!0,children:" Apply selected migrations"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" q"}),y.jsx(R,{dimColor:!0,children:" Quit"})]}),y.jsxs(R,{children:[y.jsx(R,{bold:!0,color:"white",children:" ?"}),y.jsx(R,{dimColor:!0,children:" Toggle help"})]})]})]}),F=n.getCheckedItems(),Y=y.jsx(V,{alignItems:"center",flexDirection:"column",children:y.jsxs(R,{dimColor:!0,children:["Press ",y.jsx(R,{bold:!0,color:"white",children:"u"})," or ",y.jsx(R,{bold:!0,color:"white",children:"Enter"})," to confirm, ",y.jsx(R,{bold:!0,color:"white",children:"Esc"})," to cancel"]})}),re=y.jsx(yi,{footer:Y,scrollRef:$,title:`Apply ${String(F.length)} migration${F.length===1?"":"s"}?`,visible:l,width:70,children:F.map(M=>y.jsxs(V,{gap:1,children:[y.jsxs(R,{children:[" ",M.entry.title]}),y.jsxs(R,{dimColor:!0,children:["(",M.preview.length," ","change",M.preview.length===1?"":"s",")"]})]},M.entry.id))}),ee=y.jsx(by,{checkedItems:o.checkedItems,focused:o.focusedPanel==="list",isDryRun:t,items:o.items,scrollOffset:f,selectedIndex:o.selectedIndex,viewportHeight:S}),te=y.jsx(yy,{focused:o.focusedPanel==="detail",item:b,scrollRef:v});if(P){const M=Math.floor(r*.55);return y.jsxs(V,{flexDirection:"column",height:i,width:r,children:[y.jsxs(V,{flexDirection:"row",flexGrow:1,children:[y.jsx(V,{flexGrow:1,children:ee}),y.jsx(V,{width:M,children:te})]}),N,re,y.jsx(Oa,{autoExitSeconds:e||3,onCancel:()=>{p(!1)},visible:u}),_]})}const se=Math.floor(i*.45);return y.jsxs(V,{flexDirection:"column",height:i,width:r,children:[y.jsx(V,{height:se,children:ee}),y.jsx(V,{flexGrow:1,children:te}),N,re,y.jsx(Oa,{autoExitSeconds:e||3,onCancel:()=>{p(!1)},visible:u}),_]})},dd=[".lintstagedrc.json",".lintstagedrc"],ud=[".lintstagedrc.yaml",".lintstagedrc.yml",".lintstagedrc.mjs","lint-staged.config.mjs",".lintstagedrc.cjs","lint-staged.config.cjs",".lintstagedrc.js","lint-staged.config.js",".lintstagedrc.ts","lint-staged.config.ts",".lintstagedrc.mts","lint-staged.config.mts",".lintstagedrc.cts","lint-staged.config.cts"],pd=[...dd,...ud],$y=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+lint-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)lint-staged\b/],fd=[".nano-staged.json",".nanostagedrc"],hd=[".nano-staged.mjs",".nano-staged.cjs",".nano-staged.js","nano-staged.config.mjs","nano-staged.config.cjs","nano-staged.config.js","nano-staged.config.mts","nano-staged.config.cts","nano-staged.config.ts"],md=[...fd,...hd],Ey=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+nano-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)nano-staged\b/],gd=["husky","lint-staged","nano-staged"],Cy=/\(is-ci \|\| husky \|\| exit 0\)\s*&&\s*/g,Ry=/\bhusky(?:\s+install)?\s*&&\s*/g,jy=/\s*&&\s*husky(?:\s+install)?/g,Ty=/\s*\|\|\s*husky(?:\s+install)?/g,Oy=[Cy,Ry,jy,Ty],yd=e=>{if(e==="husky"||e==="husky install")return;let t=e;for(const n of Oy)t=t.replace(n,"");return t=t.trim(),t===e?e:t||void 0},vd=["pre-commit","pre-merge-commit","prepare-commit-msg","commit-msg","post-commit","applypatch-msg","pre-applypatch","post-applypatch","pre-rebase","post-rewrite","post-checkout","post-merge","pre-push","pre-auto-gc"],io=".vis/hooks",Qt=".vis-hooks",eR=[".pre-commit-config.yaml",".pre-commit-config.yml","prek.toml"],tR={commit:"pre-commit","merge-commit":"pre-merge-commit",push:"pre-push"},nR=new Set(["commit-msg","post-checkout","post-commit","post-merge","post-rewrite","pre-commit","pre-merge-commit","pre-push","pre-rebase","prepare-commit-msg"]),sR=new Set(["commit-msg","post-checkout","post-merge","post-rewrite","pre-rebase","prepare-commit-msg"]),rR=new Set(["fail","script","system"]),Ay="config.json",Ar=1,Iy=new Set(["alwaysRun","args","builtin","entry","exclude","excludeTypes","fail","files","id","name","passFilenames","types","typesOr","verbose"]),By=new Set(["failFast","skipInCI","stages","version"]),Py=["args","exclude","excludeTypes","files","passFilenames","types","typesOr"],bd=(e,t)=>g(e,t,Ay),vi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),bs=e=>{if(!Array.isArray(e))return;const t=[];for(const n of e){if(typeof n!="string")return;t.push(n)}return t},Wn=e=>typeof e=="boolean"?e:void 0,Ut=e=>typeof e=="string"&&e.length>0?e:void 0,Ny=(e,t,n)=>{if(!vi(e))throw new TypeError("hook entry must be an object");if(typeof e.id!="string"||e.id.length===0)throw new TypeError("hook entry is missing `id`");const s={id:e.id},r=Wn(e.alwaysRun);r!==void 0&&(s.alwaysRun=r);const i=bs(e.args);i&&(s.args=i);const o=Ut(e.builtin);o&&(s.builtin=o);const a=Ut(e.entry);a&&(s.entry=a);const c=Ut(e.exclude);c&&(s.exclude=c);const l=bs(e.excludeTypes);l&&(s.excludeTypes=l);const d=Ut(e.fail);d&&(s.fail=d);const u=Ut(e.files);u&&(s.files=u);const p=Ut(e.name);p&&(s.name=p);const f=Wn(e.passFilenames);f!==void 0&&(s.passFilenames=f);const h=bs(e.types);h&&(s.types=h);const m=bs(e.typesOr);m&&(s.typesOr=m);const v=Wn(e.verbose);if(v!==void 0&&(s.verbose=v),[s.builtin,s.entry,s.fail].filter(b=>b!==void 0).length!==1)throw new TypeError(`hook "${s.id}" must set exactly one of \`builtin\`, \`entry\`, \`fail\``);if(s.fail!==void 0){const b=Py.filter(S=>s[S]!==void 0);if(b.length>0)throw new TypeError(`hook "${s.id}" is a \`fail\` entry — remove ${b.join(", ")} (filters do not apply)`)}for(const b of Object.keys(e))Iy.has(b)||t.push({hookId:s.id,message:`unknown field "${b}" ignored`,stage:n});return s},Dy=(e,t)=>{if(!vi(e))throw new TypeError("hook config must be an object");if(e.version!==Ar)throw new TypeError(`unsupported hook config version: expected ${Ar}, got ${String(e.version)}`);if(!vi(e.stages))throw new TypeError("hook config is missing `stages` map");const n={};for(const[o,a]of Object.entries(e.stages)){if(!Array.isArray(a))throw new TypeError(`hook config: stage "${o}" must be an array`);n[o]=a.map(c=>Ny(c,t,o))}const s={stages:n,version:Ar},r=Wn(e.failFast);r!==void 0&&(s.failFast=r);const i=Wn(e.skipInCI);i!==void 0&&(s.skipInCI=i);for(const o of Object.keys(e))By.has(o)||t.push({message:`unknown top-level field "${o}" ignored`});return s},My=(e,t=io,n)=>{const s=bd(e,t);if(!x(s))return;const r=G(s);let i;try{i=JSON.parse(r)}catch(o){const a=o instanceof Error?o.message:String(o);throw new TypeError(`failed to parse ${s}: ${a}`,{cause:o})}return Dy(i,[])},iR=(e,t,n)=>{const s=bd(e,t);ae(s,`${JSON.stringify(n,void 0,4)}
|
|
24
|
+
`,"utf8")},Ly=/\/$/,_y=e=>{if(e===Qt||!Ko(Qt)||Ko(e))return;const t=fl(e);return t&&t!=="."&&ft(t),pl(Qt,e),`migrated ${Qt} → ${e}`},Fy=e=>{let t='"$0"';for(let n=0;n<e;n+=1)t=`"$(dirname ${t})"`;return t},Vy=(e,t={})=>{const s=e.split("/").filter(o=>o!==""&&o!==".").length+2,r=Fy(s);return`#!/usr/bin/env sh
|
|
27
25
|
{ [ "$VIS_GIT_HOOKS" = "2" ]; } && set -x
|
|
28
26
|
n=$(basename "$0")
|
|
29
27
|
s=$(dirname "$(dirname "$0")")/$n
|
|
@@ -32,196 +30,196 @@ s=$(dirname "$(dirname "$0")")/$n
|
|
|
32
30
|
|
|
33
31
|
{ [ "\${VIS_GIT_HOOKS-}" = "0" ]; } && exit 0
|
|
34
32
|
${t.skipInCI?'{ [ -n "${CI-}" ] && [ "${VIS_GIT_HOOKS-}" != "1" ]; } && exit 0\n':""}
|
|
35
|
-
d=${
|
|
33
|
+
d=${r}
|
|
36
34
|
export PATH="$d/node_modules/.bin:$PATH"
|
|
37
35
|
sh -e "$s" "$@"
|
|
38
36
|
c=$?
|
|
39
37
|
|
|
40
38
|
[ $c != 0 ] && echo "vis - $n script failed (code $c)"
|
|
41
39
|
[ $c = 127 ] && echo "vis - command not found in PATH=$PATH"
|
|
42
|
-
exit $c`},
|
|
43
|
-
. "$(dirname "$0")/h"`,{mode:493});return{isError:!1,message:n??""}},
|
|
44
|
-
`,"utf8")}return{modified:
|
|
45
|
-
`,"utf8"),!0},
|
|
46
|
-
`),{entries:
|
|
47
|
-
`),"utf8")},
|
|
48
|
-
`),n.info(`Converted ${
|
|
49
|
-
`)},
|
|
50
|
-
`),pt(
|
|
51
|
-
`),n.info(`Converted ${
|
|
52
|
-
`)},
|
|
53
|
-
${Object.entries(e).map(([n,s])=>{const
|
|
40
|
+
exit $c`},Wy=(e=io)=>{if(process.env.VIS_GIT_HOOKS==="0")return{isError:!1,message:"skip install (git hooks disabled via VIS_GIT_HOOKS=0)"};if(e.includes(".."))return{isError:!0,message:'".." is not allowed in hooks directory path'};const t=nn("git",["rev-parse","--show-prefix"]);if(t.status===null)return{isError:!0,message:"git command not found"};if(t.status!==0)return{isError:!1,message:".git directory not found (not a git repository)"};const n=_y(e),s=(p="")=>g(e,"_",p),r=t.stdout.toString().trim().replace(Ly,""),i=r?`${r}/${e}/_`:`${e}/_`,o=r?`${r}/${Qt}/_`:`${Qt}/_`,a=nn("git",["config","--local","core.hooksPath"]),c=a.status===0?a.stdout?.toString().trim():"";if(c&&c!==i&&c!==o)return{isError:!1,message:`core.hooksPath is already set to "${c}", skipping`};const{status:l,stderr:d}=nn("git",["config","core.hooksPath",i]);if(l===null)return{isError:!0,message:"git command not found"};if(l)return{isError:!0,message:String(d)};const u=(()=>{try{return My(process.cwd(),e)?.skipInCI??!1}catch{return!1}})();ft(s()),ae(s(".gitignore"),"*"),ae(s("h"),Vy(e,{skipInCI:u}),{mode:493});for(const p of vd)ae(s(p),`#!/usr/bin/env sh
|
|
41
|
+
. "$(dirname "$0")/h"`,{mode:493});return{isError:!1,message:n??""}},Hy=[".husky",".config/husky"],Uy=/^\. "\$\(dirname "\$0"\)\/common\.sh"\s*/m,Gy=e=>{for(const t of Hy)if(x(g(e,t))&&Ot(g(e,t)).isDirectory())return t},zy=(e,t)=>{const n=new Map,s=g(e,t),r=new Set(vd);for(const i of Te(s)){if(i==="_"||i===".gitignore"||i.startsWith("."))continue;const o=g(s,i);Ot(o).isFile()&&(!r.has(i)&&i!=="common.sh"||n.set(i,G(o)))}return n},Jy=e=>e.replace(Uy,""),wd=e=>x(g(e,"pnpm-lock.yaml"))||x(g(e,"pnpm-workspace.yaml"))?"pnpm":x(g(e,"yarn.lock"))?"yarn":x(g(e,"bun.lockb"))||x(g(e,"bun.lock"))?"bun":"npm",qy=(e,t)=>{const n=wd(e),s={bun:["bun","remove","husky"],npm:["npm","uninstall","husky"],pnpm:["pnpm","remove","husky"],yarn:["yarn","remove","husky"]},[r,...i]=s[n];t.info(`Removing husky package via ${n}...`);const o=nn(r,i,{cwd:e,encoding:"utf8",stdio:"pipe"});return o.status!==0?(t.info(`Warning: failed to remove husky via ${n} (${o.stderr?.trim()??"unknown error"})`),!1):!0},Ky=(e,t,n)=>{const s=yd(n);if(s!==n)return s?(e[t]=s,`updated "${t}" script`):(delete e[t],`removed "${t}" script (was: "${n}")`)},Yy=(e,t)=>{const n=g(e,"package.json");if(!x(n))return{modified:!1,removedScriptReferences:[]};const s=G(n),r=JSON.parse(s),i=[],o=r.scripts;if(o)for(const[a,c]of Object.entries(o)){if(typeof c!="string")continue;const l=Ky(o,a,c);l&&i.push(l)}if(i.length>0){const a=Ke(n,s,{defaultIndent:" ",useEditorconfig:t});ae(n,`${JSON.stringify(r,void 0,a)}
|
|
42
|
+
`,"utf8")}return{modified:i.length>0,removedScriptReferences:i}},oR=(e,t,n,s={})=>{const r=Gy(e),i=s.dryRun===!0;if(!r)return{isError:!0,message:"No husky installation found (.husky/ or .config/husky/)"};n.info(`Found husky at ${r}/`);const o=zy(e,r);if(o.size===0&&n.info("No user-defined hooks found in husky directory."),!i){const d=nn("git",["config","--local","core.hooksPath"]),u=d.status===0?d.stdout?.toString().trim():"";u&&(u===".husky/_"||u.startsWith(".husky"))&&nn("git",["config","--local","--unset","core.hooksPath"]);const p=Wy(t);if(p.isError)return p;p.message&&n.info(p.message)}const a=g(e,t);i||ft(a);let c=0;for(const[d,u]of o){if(d==="common.sh"){i?n.info(" (would copy) common.sh"):(ae(g(a,d),u,{mode:493}),n.info(" Copied common.sh"));continue}if(i)n.info(` (would migrate) ${d}`);else{const p=Jy(u);ae(g(a,d),p,{mode:493}),n.info(` Migrated ${d}`)}c+=1}if(i)n.info(" (would remove) husky npm package and clean package.json scripts"),n.info(` (would remove) ${r}/ directory`);else{qy(e,n);const d=Yy(e,s.useEditorconfig);if(d.modified){n.info("Updated package.json scripts:");for(const p of d.removedScriptReferences)n.info(` ${p}`)}const u=g(e,r);un(u,{force:!0,recursive:!0}),n.info(`Removed ${r}/`)}return{isError:!1,message:`${i?"would migrate":"Migration complete:"} ${c} hook${c===1?"":"s"} ${i?"from":"migrated from"} ${r}/ to ${t}/`}},ie=(e,t)=>{if(!x(e))return;const n=`${e}.bak`;x(n)||(t?.backupsCreated.includes(n)??!1)||(Kf(e,n),t&&t.backupsCreated.push(n))},pe=e=>{try{const t=G(e);return JSON.parse(t)}catch{return}},yn=e=>{if(!x(e))return!1;try{return JSON.parse(G(e)),!0}catch{return!1}},os=(e,t,n={})=>Ke(e,t,{defaultIndent:" ",useEditorconfig:n.useEditorconfig}),At=(e,t,n,s={})=>{if(!x(e))return!1;const r=G(e);let i;try{i=JSON.parse(r)}catch{return!1}const o=t(i);if(o===void 0)return!1;const a=os(e,r,s);return n&&ie(e,n),ae(e,`${JSON.stringify(o,void 0,a)}
|
|
43
|
+
`,"utf8"),!0},Xy=/\blint-staged\b/g,Zy=(e,t)=>{let n=!1;const s={...e};for(const[r,i]of Object.entries(s)){if(typeof i!="string")continue;let o=yd(i);o&&(o=o.replaceAll(Xy,"vis staged").trim()||void 0),o!==i&&(o?s[r]=o:delete s[r],n=!0,t.rewrittenScriptCount+=1)}return{modified:n,scripts:s}},kd=(e,t,n,s)=>{const r=g(e,"package.json");x(r)&&At(r,i=>{let o=!1;for(const c of gd){const l=i.dependencies,d=i.devDependencies;l?.[c]&&(delete l[c],o=!0,s.removedPackageCount+=1),d?.[c]&&(delete d[c],o=!0,s.removedPackageCount+=1)}if(Object.keys(n).length>0)switch(t){case"bun":{const c=i.workspaces,l=c&&!Array.isArray(c)?c:void 0,d={...l?.catalog??i.catalog};for(const[p,f]of Object.entries(n))d[p]=f;l?.catalog===void 0?i.catalog=d:l.catalog=d;const u=i.overrides??{};for(const p of Object.keys(n))u[p]="catalog:";i.overrides=u,o=!0;break}case"npm":{const c=i.overrides??{};i.overrides={...c,...n},o=!0;break}case"pnpm":{const c=i.pnpm??{},l=c.overrides??{};c.overrides={...l,...n},i.pnpm=c,o=!0;break}case"yarn":{const c=i.resolutions??{};i.resolutions={...c,...n},o=!0;break}}const a=i.scripts;if(a){const c=Zy(a,s);c.modified&&(i.scripts=c.scripts,o=!0)}return o?i:void 0})},Qy=(e,t,n,s)=>{try{const{workspace:r}=Mf(e);for(const i of Object.values(r.projects)){const o=g(e,i.root);kd(o,t,n,s)}}catch{}},ev=e=>e.startsWith("- ")||e!==""&&!e.includes(":")&&!e.startsWith("#"),tv=e=>{let t=!1,n="";const s=new Set;for(const r of e){const i=r.trim();if(i==="catalog:"){t=!0;continue}if(!t)continue;if(ev(i))break;const o=i.includes(":")?i.split(":")[0]?.trim():void 0;o&&(s.add(o),n=n||r.slice(0,r.indexOf(i)))}return{entries:s,indent:n||" "}},nv=(e,t,n)=>{const s=[];let r=!1,i=!1;for(let o=0;o<e.length;o+=1){const a=e[o],c=a.trim();if(s.push(a),c==="catalog:"){i=!0;continue}if(i&&!r){const d=e[o+1]?.trim()??"";(!d.includes(":")||d.startsWith("- ")||!d||d==="catalog:")&&(s.push(...t),r=!0,i=!1)}}return r||(n.includes("catalog:")||s.push("catalog:"),s.push(...t)),s},sv=(e,t)=>{const n=g(e,"pnpm-workspace.yaml");if(!x(n)||Object.keys(t).length===0)return;const s=G(n),r=s.split(`
|
|
44
|
+
`),{entries:i,indent:o}=tv(r),a=[];for(const[l,d]of Object.entries(t))i.has(l)||a.push(`${o}${l}: "${d}"`);if(a.length===0)return;const c=nv(r,a,s);ie(n),ae(n,c.join(`
|
|
45
|
+
`),"utf8")},Aa=(e,t,n,s,r,i)=>{const o=n.overrides??{};if(s.dryRun){r.info("[dry-run] Would rewrite package.json files (remove husky/lint-staged, rewrite scripts)"),Object.keys(o).length>0&&r.info(`[dry-run] Would add overrides: ${JSON.stringify(o)}`);return}kd(e,t,o,i),r.info("Rewritten root package.json"),Qy(e,t,o,i),t==="pnpm"&&sv(e,o)},Ee=()=>({backupsCreated:[],gitHooksConfigured:!1,inlinedLintStagedConfigCount:0,manualSteps:[],mergedStagedConfigCount:0,perMigration:{},removedConfigCount:0,removedPackageCount:0,rewrittenScriptCount:0,warnings:[]}),Q=(e,t)=>{!e||e.warnings.includes(t)||e.warnings.push(t)},ne=(e,t)=>{!e||e.manualSteps.includes(t)||e.manualSteps.push(t)},he=(e,t,n,s=1)=>{const r=e.perMigration[t]??{removedConfigCount:0,removedPackageCount:0,rewrittenScriptCount:0};r[n]+=s,e.perMigration[t]=r,e[n]+=s},rv=["gitleaks.toml",".gitleaks.toml"],iv=["gitleaks-report.json",".gitleaks-report.json","baseline.json"],lr=e=>rv.find(t=>x(g(e,t))),oo=e=>{const t=g(e,".gitleaksignore");return x(t)?t:void 0},ao=e=>{for(const t of iv){const n=g(e,t);if(x(n))try{const s=JSON.parse(G(n));if(Array.isArray(s)&&s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"RuleID"in s[0])return n}catch{}}},ov=e=>e.map(t=>({description:t.Description??"",endColumn:t.EndColumn??0,endLine:t.EndLine??t.StartLine??0,entropy:t.Entropy??0,file:t.File??"",match:t.Match??"",ruleId:t.RuleID??"",secret:t.Secret??"",startColumn:t.StartColumn??0,startLine:t.StartLine??0,tags:t.Tags??[]})),av=(e,t,n,s,r)=>{const i=ao(e);if(!i)return;const o=g(e,".secrets-baseline.json");if(x(o)&&i!==o){Q(s,`.secrets-baseline.json already exists — leaving ${i} in place`);return}const a=pe(i);if(!Array.isArray(a)){Q(s,`Could not parse ${i} as a gitleaks baseline`);return}const c=ov(a);if(t){n.info(`[dry-run] Would convert ${i} -> ${o} (${String(c.length)} findings)`);return}ie(i,s),me(o,`${JSON.stringify(c,null,Ke(o,void 0,{defaultIndent:" ",useEditorconfig:r}))}
|
|
46
|
+
`),n.info(`Converted ${i} -> ${o} (${String(c.length)} findings)`),he(s,"gitleaks","rewrittenScriptCount")},cv=(e,t,n,s,r)=>{const i=g(e,"package.json");if(!x(i))return;const o=pe(i);if(!o)return;const a=lr(e),c=a?`vis secrets --config ${a}`:"vis secrets";let l=!1;if(o.scripts){for(const[u,p]of Object.entries(o.scripts))if(typeof p=="string"&&/\bgitleaks\b/.test(p)){const f=p.replaceAll(/\bgitleaks(?:\s+(?:detect|protect))?\b[^\n&|;]*/g,c).trim();f!==p&&(o.scripts[u]=f,l=!0,n.info(` scripts.${u}: "${p}" -> "${f}"`),he(s,"gitleaks","rewrittenScriptCount"))}}if(o.devDependencies){const u=o.devDependencies;for(const p of["gitleaks","@gitleaks/cli"])p in u&&(delete u[p],l=!0,he(s,"gitleaks","removedPackageCount"),n.info(` removed devDependency: ${p}`))}if(!l)return;if(t){n.info(`[dry-run] Would update ${i}`);return}const d=Ke(i,G(i),{defaultIndent:" ",useEditorconfig:r});ie(i,s),me(i,`${JSON.stringify(o,null,d)}
|
|
47
|
+
`)},lv=(e,t,n,s)=>{const r=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],i=lr(e),o=i?`vis secrets --staged --config ${i}`:"vis secrets --staged";for(const a of r){const c=g(e,a);if(!x(c))continue;const l=G(c);if(!/\bgitleaks\b/.test(l))continue;const d=l.replaceAll(/\bgitleaks(?:\s+(?:detect|protect))?\b[^\n&|;]*/g,o);if(t){n.info(`[dry-run] Would rewrite ${c}`);continue}ie(c,s),me(c,d),s.gitHooksConfigured=!0,n.info(`Rewrote gitleaks invocation in ${a}`)}},dv=/^([^:#][^:]*):([^:]+):(\d+)$/,uv=e=>{const t=dv.exec(e.trim());if(!t)return;const[,n,s,r]=t,i=Number.parseInt(r??"0",10);return{description:"",endColumn:0,endLine:i,entropy:0,file:n??"",match:"",ruleId:s??"",secret:"",startColumn:0,startLine:i,tags:[]}},pv=(e,t,n,s,r)=>{const i=oo(e);if(!i)return;const c=G(i).split(/\r?\n/).map(m=>m.trim()).filter(m=>m.length>0&&!m.startsWith("#")).map(m=>uv(m)).filter(m=>m!==void 0);c.length===0&&Q(s,`${i} contained no recognisable fingerprint lines — deleting it.`);const l=g(e,".secrets-baseline.json"),d=x(l)?pe(l)??[]:[],u=new Set(d.map(m=>`${m.file}:${m.ruleId}:${String(m.startLine)}`)),p=[...d];for(const m of c){const v=`${m.file}:${m.ruleId}:${String(m.startLine)}`;u.has(v)||(u.add(v),p.push(m))}if(t){n.info(`[dry-run] Would merge ${String(c.length)} .gitleaksignore fingerprint(s) into ${l}, then delete ${i}.`);return}ie(i,s);const f=x(l)?G(l):void 0;f!==void 0&&ie(l,s);const h=Ke(l,f,{defaultIndent:" ",useEditorconfig:r});me(l,`${JSON.stringify(p,null,h)}
|
|
48
|
+
`),pt(i),n.info(`Merged ${String(c.length)} fingerprint(s) from ${i} into ${l}; removed .gitleaksignore.`),he(s,"gitleaks","rewrittenScriptCount",c.length)},Ia=(e,t,n,s)=>{const r=lr(e),i=oo(e);return!(r??i??ao(e))?(t.silent||n.info("No gitleaks artifacts found — nothing to migrate."),!1):(r&&(n.info(`Keeping ${r} as-is (compatible with vis secrets --config).`),ne(s,`Run \`vis secrets --config ${r}\` or rename to .gitleaksignore-compatible defaults.`)),i&&pv(e,t.dryRun,n,s,t.useEditorconfig),av(e,t.dryRun,n,s,t.useEditorconfig),cv(e,t.dryRun,n,s,t.useEditorconfig),lv(e,t.dryRun,n,s),ne(s,"Review CI workflows (.github/workflows/*.yml) for gitleaks-action calls — replace with `vis secrets`."),!0)},fv=["kingfisher-baseline.yaml",".kingfisher-baseline.yaml","kingfisher-baseline.yml",".kingfisher-baseline.yml"],hv=["kingfisher-rules.yml","kingfisher-rules.yaml",".kingfisher-rules.yml",".kingfisher-rules.yaml"],co=e=>fv.find(t=>x(g(e,t))),dr=e=>hv.find(t=>x(g(e,t))),mv=e=>{const t=[];let n={};for(const s of e.split(/\r?\n/)){const r=s.replace(/#.*$/,"");(/^\s*-\s*filepath\s*:/.test(r)||/^\s*-\s*$/.test(r))&&(n.filepath&&typeof n.linenum=="number"&&n.fingerprint&&t.push(n),n={});const i=/filepath\s*:\s*(.+?)\s*$/.exec(r);if(i?.[1]){n.filepath=i[1].replaceAll(/^["']|["']$/g,"");continue}const o=/fingerprint\s*:\s*(.+?)\s*$/.exec(r);if(o?.[1]){n.fingerprint=o[1].replaceAll(/^["']|["']$/g,"");continue}const a=/linenum\s*:\s*(\d+)/.exec(r);a?.[1]&&(n.linenum=Number.parseInt(a[1],10))}return n.filepath&&typeof n.linenum=="number"&&n.fingerprint&&t.push(n),t},gv=e=>({_kingfisherMigration:{legacyFingerprint:e.fingerprint,note:"Kingfisher xxhash — regenerate by running `vis secrets --update-baseline`."},description:"",endColumn:0,endLine:e.linenum,entropy:0,file:e.filepath,match:"",ruleId:"",secret:"",startColumn:0,startLine:e.linenum,tags:[]}),yv=(e,t,n,s,r)=>{const i=co(e);if(!i)return;const o=g(e,i);let a;try{a=mv(G(o))}catch(d){const u=d instanceof Error?d.message:String(d);Q(s,`Could not parse ${i} as a Kingfisher baseline: ${u}`);return}if(a.length===0){Q(s,`${i} contained no recognisable records — leaving it in place for manual review.`);return}const c=g(e,".secrets-baseline.json");if(x(c)){Q(s,`.secrets-baseline.json already exists — leaving Kingfisher baseline at ${i} for manual merge.`);return}const l=a.map(d=>gv(d));if(t){n.info(`[dry-run] Would convert ${i} -> .secrets-baseline.json (${String(l.length)} placeholder finding(s))`),ne(s,"Run `vis secrets --update-baseline` after migration — Kingfisher xxhash fingerprints aren't interchangeable with our content-hash.");return}ie(o,s),me(c,`${JSON.stringify(l,null,Ke(c,void 0,{defaultIndent:" ",useEditorconfig:r}))}
|
|
49
|
+
`),n.info(`Converted ${i} -> .secrets-baseline.json (${String(l.length)} placeholder finding(s))`),ne(s,"Run `vis secrets --update-baseline` — the converted entries are placeholders until the scanner computes real fingerprints."),he(s,"kingfisher","rewrittenScriptCount")},Sd=/\bkingfisher(?:\s+(?:scan|validate|rules|update|manage-baseline|report|github|gitlab|bitbucket))?\b[^\n&|;]*/g,vv=(e,t,n,s,r)=>{const i=g(e,"package.json");if(!x(i))return;const o=pe(i);if(!o)return;const a=dr(e),c=a?`vis secrets --config ${a}`:"vis secrets";let l=!1;if(o.scripts)for(const[u,p]of Object.entries(o.scripts)){if(typeof p!="string"||!/\bkingfisher\b/.test(p))continue;const f=p.replaceAll(Sd,h=>h.includes("validate")?`${c} --validate`:c).trim();f!==p&&(o.scripts[u]=f,l=!0,n.info(` scripts.${u}: "${p}" -> "${f}"`),he(s,"kingfisher","rewrittenScriptCount"))}if(o.devDependencies){const u=o.devDependencies;for(const p of["kingfisher","@mongodb/kingfisher","kingfisher-scanner"])p in u&&(delete u[p],l=!0,he(s,"kingfisher","removedPackageCount"),n.info(` removed devDependency: ${p}`))}if(!l)return;if(t){n.info(`[dry-run] Would update ${i}`);return}const d=Ke(i,G(i),{defaultIndent:" ",useEditorconfig:r});ie(i,s),me(i,`${JSON.stringify(o,null,d)}
|
|
50
|
+
`)},bv=(e,t,n,s)=>{const r=dr(e),i=r?`vis secrets --staged --config ${r}`:"vis secrets --staged";for(const o of xd){const a=g(e,o);if(!x(a))continue;const c=G(a);if(!/\bkingfisher\b/.test(c))continue;const l=c.replaceAll(Sd,i);if(t){n.info(`[dry-run] Would rewrite ${a}`);continue}ie(a,s),me(a,l),s.gitHooksConfigured=!0,n.info(`Rewrote kingfisher invocation in ${o}`)}},xd=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],Ba=e=>{if(!x(e))return!1;try{return/\bkingfisher\b/.test(G(e))}catch{return!1}},Pa=(e,t,n,s)=>{const r=co(e),i=dr(e),o=Ba(g(e,"package.json")),a=xd.some(l=>Ba(g(e,l)));return!!(r??i)||o||a?(i&&(n.info(`Found custom Kingfisher ruleset at ${i} — keeping it for now.`),ne(s,`Convert ${i} to gitleaks-shaped JSON using \`packages/tooling/secret-scanner/scripts/kingfisher-converter.mjs\`, then point \`vis secrets --config\` at the result.`)),r&&yv(e,t.dryRun,n,s,t.useEditorconfig),vv(e,t.dryRun,n,s,t.useEditorconfig),bv(e,t.dryRun,n,s),ne(s,"Replace `# kingfisher:ignore` markers with `# secret-scanner:allow` (or keep `# gitleaks:allow` — the scanner accepts both)."),ne(s,"Review CI workflows (.github/workflows/*.yml) for Kingfisher action/docker invocations — replace with `vis secrets`."),!0):(t.silent||n.info("No Kingfisher artifacts found — nothing to migrate."),!1)},wv=/\bstaged\s*:/,Na=/(defineConfig\(\{)/,Da=/(export\s+default\s+\{)/,kv=e=>{for(const n of ud)if(x(g(e,n)))return!0;const t=g(e,".lintstagedrc");return x(t)&&!yn(t)},Sv=e=>{const t=Dt(e);if(!t)return!1;const n=G(t);return wv.test(n)},$d=e=>{const t=g(e,"package.json");if(x(t)&&pe(t)?.["lint-staged"])return"package.json";for(const n of pd)if(x(g(e,n)))return n},xv=e=>pe(g(e,"package.json"))?.["lint-staged"],$v=e=>pe(e),bi=e=>` staged: {
|
|
51
|
+
${Object.entries(e).map(([n,s])=>{const r=Array.isArray(s)?`[${s.map(i=>JSON.stringify(i)).join(", ")}]`:JSON.stringify(s);return` ${JSON.stringify(n)}: ${r}`}).join(`,
|
|
54
52
|
`)},
|
|
55
|
-
}`,
|
|
56
|
-
${c},`):
|
|
57
|
-
${c},`)),l?(
|
|
53
|
+
}`,Ev=(e,t,n)=>{const s=Dt(e);if(s){const a=G(s),c=bi(t);let l;return Na.test(a)?l=a.replace(Na,`$1
|
|
54
|
+
${c},`):Da.test(a)&&(l=a.replace(Da,`$1
|
|
55
|
+
${c},`)),l?(ie(s),ae(s,l,"utf8"),n.info(`Merged staged config into ${s}`),!0):(n.warn(`Could not auto-insert staged config into ${s} — please add manually`),!1)}const r=g(e,"vis.config.ts"),o=`import { defineConfig } from "@visulima/vis/config";
|
|
58
56
|
|
|
59
57
|
export default defineConfig({
|
|
60
|
-
${
|
|
58
|
+
${bi(t)},
|
|
61
59
|
});
|
|
62
|
-
`;return ae(
|
|
63
|
-
`,"utf8")}return s},
|
|
64
|
-
`);let
|
|
65
|
-
`)),!0):!1},
|
|
66
|
-
`)},
|
|
67
|
-
${Object.entries(e).map(([n,s])=>{const
|
|
60
|
+
`;return ae(r,o,"utf8"),n.info(`Created ${r} with staged config`),!0},Cv=(e,t)=>{const n=g(e,"package.json"),s={configRemoved:!1,dependencyRemoved:!1};if(!x(n))return s;const r=G(n),i=JSON.parse(r);let o=!1;i["lint-staged"]&&(delete i["lint-staged"],o=!0,s.configRemoved=!0);const a=i.devDependencies,c=i.dependencies;if(a?.["lint-staged"]&&(delete a["lint-staged"],o=!0,s.dependencyRemoved=!0),c?.["lint-staged"]&&(delete c["lint-staged"],o=!0,s.dependencyRemoved=!0),o){const l=os(n,r,{useEditorconfig:t});ie(n),ae(n,`${JSON.stringify(i,void 0,l)}
|
|
61
|
+
`,"utf8")}return s},Rv=(e,t)=>{for(const n of pd){const s=g(e,n);x(s)&&(ie(s,t),pt(s),t.removedConfigCount+=1)}},jv=(e,t)=>{const n=g(e,t,"pre-commit");if(!x(n))return!1;const s=G(n);if(s.includes("vis staged"))return!1;const r=s.split(`
|
|
62
|
+
`);let i=!1;const o=[];for(const a of r){const c=a.trim();if(!i){let l=!1;for(const d of $y){const u=d.exec(c);if(u){const p=a.slice(0,a.length-a.trimStart().length),f=u[1]?.trim()??"",h=c.slice(u[0].length).trim(),m=[f,"vis staged",h].filter(Boolean);o.push(`${p}${m.join(" ")}`),i=!0,l=!0;break}}if(l)continue}o.push(a)}return i?(ie(n),ae(n,o.join(`
|
|
63
|
+
`)),!0):!1},Tv=(e,t,n)=>{if(t==="package.json")return xv(e);const s=g(e,t);if(!dd.includes(t)){Q(n,`${t} cannot be auto-migrated — please add "staged" config to vis.config.ts manually`),ne(n,`Manually convert ${t} to staged config in vis.config.ts`);return}if(t===".lintstagedrc"&&!yn(s)){Q(n,".lintstagedrc is not JSON format — please migrate manually");return}return $v(s)},Ed=(e,t,n)=>{const{configRemoved:s,dependencyRemoved:r}=Cv(e,n);s&&(t.inlinedLintStagedConfigCount+=1),r&&(t.removedPackageCount+=1),Rv(e,t)},Ov=(e,t,n,s)=>{const r=[".vis/hooks",".husky"];for(const i of r)x(g(e,i))&&jv(e,i)&&(s.gitHooksConfigured=!0,t.silent||n.info(`Rewrote pre-commit hook in ${i}/ to use "vis staged"`))},Av=(e,t,n,s,r)=>{Ev(e,t,s)&&(r.mergedStagedConfigCount+=1),Ed(e,r,n.useEditorconfig),Ov(e,n,s,r)},Ma=(e,t,n,s)=>{const r=$d(e);if(!r)return t.silent||n.info("No lint-staged configuration found — nothing to migrate."),!1;if(kv(e)&&(Q(s,'Non-JSON lint-staged config found — please migrate to "staged" in vis.config.ts manually'),ne(s,"Convert your lint-staged config file to JSON format or add staged config to vis.config.ts manually")),Sv(e))return Q(s,'vis.config.ts already has a "staged" config — skipping lint-staged merge'),t.silent||n.warn('vis.config.ts already has a "staged" config — skipping'),t.dryRun||Ed(e,s,t.useEditorconfig),!0;const i=Tv(e,r,s);return!i||Object.keys(i).length===0?(t.silent||n.warn("lint-staged config is empty — skipping"),!1):t.dryRun?(t.silent||(n.info("[dry-run] Would insert staged config into vis.config.ts:"),n.info(bi(i))),!0):(Av(e,i,t,n,s),!0)},lo=(e,t,n)=>{const s=t?Ke(t,void 0,{defaultIndent:" ",useEditorconfig:n}):" ";return JSON.stringify(e,null,s).replaceAll(/"(\w+)":/g,"$1:")},uo=(e,t,n,s,r)=>{const i=g(e,"vis.config.ts"),o=x(i);return o&&!n.dryRun&&!n.force?(s.warn("vis.config.ts already exists — refusing to overwrite. Re-run with --force to replace it (a .bak is taken first), or run with --dry-run to preview."),r.warnings.push("vis.config.ts already exists; migration skipped writing the file. Re-run with --force to overwrite."),!1):(n.dryRun?(s.info("── vis.config.ts (preview) ──"),s.info(t),s.info("── end preview ──")):(o&&n.force&&(ie(i,r),s.info(`Replacing ${i} (backup at ${i}.bak)`)),me(i,t),s.info(`Wrote ${i}`)),!0)},Cd=(e,t)=>{const n=g(e,t);if(x(n))try{return JSON.parse(G(n))}catch(s){throw new Error(`Failed to parse ${n}: ${s.message}`,{cause:s})}},Iv=e=>{const t={};return e.command&&(t.command=Array.isArray(e.args)?`${e.command} ${e.args.join(" ")}`:e.args?`${e.command} ${e.args}`:e.command),e.deps&&e.deps.length>0&&(t.dependsOn=e.deps),e.inputs&&e.inputs.length>0&&(t.inputs=e.inputs),e.outputs&&e.outputs.length>0&&(t.outputs=e.outputs),e.type&&(t.type=e.type),e.preset&&(t.preset=e.preset),e.options&&(t.options=e.options),t},Bv=(e,t,n)=>{const s={};e.fileGroups&&(s.fileGroups=e.fileGroups);const r={};for(const[o,a]of Object.entries(e.tasks??{}))r[o]=Iv(a);return Object.keys(r).length>0&&(s.tasks=r),e.implicitInputs&&e.implicitInputs.length>0&&(s.namedInputs={default:e.implicitInputs}),["// Migrated from moon's .moon/tasks.yml by `vis migrate moon`.","// Per-project moon.yml files can be converted to project.json —","// review the generated file and move project-specific tasks there.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${lo(s,g(t,"vis.config.ts"),n)});`,""].join(`
|
|
64
|
+
`)},Pv=e=>{const t=g(e,".moon");if(!x(t))return;for(const s of["tasks.yml","tasks.yaml"]){const r=g(t,s);if(x(r))return r}const n=g(t,"tasks");if(x(n)){const s=Te(n).filter(r=>r.endsWith(".yml")||r.endsWith(".yaml")).sort();if(s.length>0)return g(n,s[0])}},Nv=e=>{const t=g(e,".moon","templates");if(!x(t))return[];const n=[];try{for(const s of Te(t,{withFileTypes:!0}))s.isDirectory()&&x(g(t,s.name,"template.yml"))&&n.push(s.name)}catch{}return n.sort()},Dv=(e,t,n,s,r)=>{const i=g(e,".moon","templates"),o=g(e,".vis","templates");n||Yf(o,{recursive:!0});for(const a of t){const c=g(i,a),l=g(o,a);if(x(l)){r.warnings.push(`Template "${a}" already exists at .vis/templates/${a} — left untouched. Remove or rename either copy to resolve.`);continue}if(n){s.info(`Would copy .moon/templates/${a} → .vis/templates/${a}`);continue}try{Xf(c,l,{recursive:!0}),s.info(`Copied .moon/templates/${a} → .vis/templates/${a}`)}catch(d){const u=d instanceof Error?d.message:String(d);r.warnings.push(`Failed to copy template "${a}": ${u}`)}}!n&&t.length>0&&r.manualSteps.push(`Copied ${String(t.length)} template${t.length===1?"":"s"} from .moon/templates/ to .vis/templates/. Remove the .moon/templates/ directory when ready.`)},La=(e,t,n,s)=>{const r=Pv(e);if(!r){n.warn("No .moon/tasks.yml (or .moon/tasks/<scope>.yml) found — nothing to migrate."),s.warnings.push("No moon tasks file at workspace root.");return}let i;try{i=Tt(r)}catch(l){throw new Error(`Failed to parse ${r}: ${l.message}`,{cause:l})}for(const[l,d]of Object.entries(i.tasks??{}))d.env&&Object.keys(d.env).length>0&&s.warnings.push(`Task "${l}" has an \`env\` block which vis does not support — set environment variables in the command or a wrapper script.`),d.platform&&s.warnings.push(`Task "${l}" has a \`platform\` field ("${d.platform}") which vis does not support — review and remove.`),d.toolchain&&s.warnings.push(`Task "${l}" has a \`toolchain\` field ("${d.toolchain}") which vis does not support — review and remove.`),Array.isArray(d.args)&&d.args.some(p=>p.includes(" "))&&s.warnings.push(`Task "${l}" has \`args\` entries containing spaces — vis flattens args into the command string so quoting may need manual adjustment.`);i.extends&&i.extends.length>0&&s.warnings.push("`extends` was found in the moon config but has no direct vis equivalent — inline the referenced files or use vis's `scopedTasks` blocks."),i.implicitDeps&&i.implicitDeps.length>0&&s.warnings.push("`implicitDeps` was found in the moon config but has no direct vis equivalent — add explicit `dependsOn` entries in project.json instead."),i.taskOptions&&Object.keys(i.taskOptions).length>0&&s.warnings.push("`taskOptions` was found in the moon config but has no direct vis equivalent — review and apply settings per-target in vis.config.ts.");const o=Bv(i,e,t.useEditorconfig);if(!uo(e,o,t,n,s))return;s.manualSteps.push("moon's per-project `moon.yml` files should be converted to `project.json`. vis reads targets, tags, layer, stack, language, and owners from project.json — the field names match."),s.manualSteps.push("Scoped `.moon/tasks/<scope>.yml` files map to vis's `scopedTasks` with a `match` block. Only the first scope file was parsed — review the generated file."),s.manualSteps.push("vis tasks support `when: { os, env, branch, ci, not.* }` for conditional execution and `always: true` for cleanup tasks that fire even when upstream fails. Review tasks that used moon's `local: true`, `options.runInCI`, or shell-based platform gating — the new surface is more expressive and may simplify them. See docs/guides/conditional-and-finally-tasks.mdx.");const a=Nv(e);if(a.length===0)return;const c=a.map(l=>`"${l}"`).join(", ");t.copyTemplates?Dv(e,a,!!t.dryRun,n,s):s.manualSteps.push(`Detected ${String(a.length)} template${a.length===1?"":"s"} under .moon/templates/ (${c}). They are already usable via \`vis generate <name>\` — vis auto-discovers moon-format template directories at runtime. To decouple from moon entirely, re-run \`vis migrate moon --copy-templates\` to physically move them to .vis/templates/.`)},Mv=/\bstaged\s*:/,_a=/(defineConfig\(\{)/,Fa=/(export\s+default\s+\{)/,Lv=e=>{for(const n of hd)if(x(g(e,n)))return!0;const t=g(e,".nanostagedrc");return x(t)&&!yn(t)},_v=e=>{const t=Dt(e);return t?Mv.test(G(t)):!1},Rd=e=>{const t=g(e,"package.json");if(x(t)&&pe(t)?.["nano-staged"])return"package.json";for(const n of md)if(x(g(e,n)))return n},Fv=e=>pe(g(e,"package.json"))?.["nano-staged"],Vv=e=>pe(e),wi=e=>` staged: {
|
|
65
|
+
${Object.entries(e).map(([n,s])=>{const r=Array.isArray(s)?`[${s.map(i=>JSON.stringify(i)).join(", ")}]`:JSON.stringify(s);return` ${JSON.stringify(n)}: ${r}`}).join(`,
|
|
68
66
|
`)},
|
|
69
|
-
}`,
|
|
70
|
-
${c},`):
|
|
71
|
-
${c},`)),l?(
|
|
67
|
+
}`,Wv=(e,t,n)=>{const s=Dt(e);if(s){const a=G(s),c=wi(t);let l;return _a.test(a)?l=a.replace(_a,`$1
|
|
68
|
+
${c},`):Fa.test(a)&&(l=a.replace(Fa,`$1
|
|
69
|
+
${c},`)),l?(ie(s),ae(s,l,"utf8"),n.info(`Merged staged config into ${s}`),!0):(n.warn(`Could not auto-insert staged config into ${s} — please add manually`),!1)}const r=g(e,"vis.config.ts"),o=`import { defineConfig } from "@visulima/vis/config";
|
|
72
70
|
|
|
73
71
|
export default defineConfig({
|
|
74
|
-
${
|
|
72
|
+
${wi(t)},
|
|
75
73
|
});
|
|
76
|
-
`;return ae(
|
|
77
|
-
`,"utf8")}return s},
|
|
78
|
-
`);let
|
|
79
|
-
`)),!0):!1},
|
|
74
|
+
`;return ae(r,o,"utf8"),n.info(`Created ${r} with staged config`),!0},Hv=(e,t)=>{const n=g(e,"package.json"),s={configRemoved:!1,dependencyRemoved:!1};if(!x(n))return s;const r=G(n),i=JSON.parse(r);let o=!1;i["nano-staged"]&&(delete i["nano-staged"],o=!0,s.configRemoved=!0);const a=i.devDependencies,c=i.dependencies;if(a?.["nano-staged"]&&(delete a["nano-staged"],o=!0,s.dependencyRemoved=!0),c?.["nano-staged"]&&(delete c["nano-staged"],o=!0,s.dependencyRemoved=!0),o){const l=os(n,r,{useEditorconfig:t});ie(n),ae(n,`${JSON.stringify(i,void 0,l)}
|
|
75
|
+
`,"utf8")}return s},Uv=(e,t)=>{for(const n of md){const s=g(e,n);x(s)&&(ie(s,t),pt(s),t.removedConfigCount+=1)}},Gv=(e,t)=>{const n=g(e,t,"pre-commit");if(!x(n))return!1;const s=G(n);if(s.includes("vis staged"))return!1;const r=s.split(`
|
|
76
|
+
`);let i=!1;const o=[];for(const a of r){const c=a.trim();if(!i){let l=!1;for(const d of Ey){const u=d.exec(c);if(u){const p=a.slice(0,a.length-a.trimStart().length),f=u[1]?.trim()??"",h=c.slice(u[0].length).trim(),m=[f,"vis staged",h].filter(Boolean);o.push(`${p}${m.join(" ")}`),i=!0,l=!0;break}}if(l)continue}o.push(a)}return i?(ie(n),ae(n,o.join(`
|
|
77
|
+
`)),!0):!1},zv=(e,t,n)=>{if(t==="package.json")return Fv(e);const s=g(e,t);if(!fd.includes(t)){Q(n,`${t} cannot be auto-migrated — please add "staged" config to vis.config.ts manually`),ne(n,`Manually convert ${t} to staged config in vis.config.ts`);return}if(t===".nanostagedrc"&&!yn(s)){Q(n,".nanostagedrc is not JSON format — please migrate manually");return}return Vv(s)},jd=(e,t,n)=>{const{configRemoved:s,dependencyRemoved:r}=Hv(e,n);s&&(t.inlinedLintStagedConfigCount+=1),r&&(t.removedPackageCount+=1),Uv(e,t)},Jv=(e,t,n,s)=>{const r=[".vis/hooks",".husky"];for(const i of r)x(g(e,i))&&Gv(e,i)&&(s.gitHooksConfigured=!0,t.silent||n.info(`Rewrote pre-commit hook in ${i}/ to use "vis staged"`))},qv=(e,t,n,s,r)=>{Wv(e,t,s)&&(r.mergedStagedConfigCount+=1),jd(e,r,n.useEditorconfig),Jv(e,n,s,r)},Va=(e,t,n,s)=>{const r=Rd(e);if(!r)return t.silent||n.info("No nano-staged configuration found — nothing to migrate."),!1;if(Lv(e)&&(Q(s,'Non-JSON nano-staged config found — please migrate to "staged" in vis.config.ts manually'),ne(s,"Convert your nano-staged config file to JSON format or add staged config to vis.config.ts manually")),_v(e))return Q(s,'vis.config.ts already has a "staged" config — skipping nano-staged merge'),t.silent||n.warn('vis.config.ts already has a "staged" config — skipping'),t.dryRun||jd(e,s,t.useEditorconfig),!0;const i=zv(e,r,s);return!i||Object.keys(i).length===0?(t.silent||n.warn("nano-staged config is empty — skipping"),!1):t.dryRun?(t.silent||(n.info("[dry-run] Would insert staged config into vis.config.ts:"),n.info(wi(i))),!0):(qv(e,i,t,n,s),!0)},Td=[".vis/last-summary.json",".vis/last-failures/"],Od=(e,t)=>{const n=t.replace(/\/$/,"");return e.some(s=>{const r=s.trim();return r===""||r.startsWith("#")?!1:r===t||r===n?!0:/^\*{0,2}\/?\.vis(?:\/\*{0,2})?$/.test(r)})},Kv=(e,t={})=>{const{create:n=!0}=t,s=g(e,".gitignore"),r=x(s);if(!r&&!n)return{added:[],changed:!1};const i=r?G(s):"",o=i.includes(`\r
|
|
80
78
|
`)?`\r
|
|
81
79
|
`:`
|
|
82
|
-
`,a=
|
|
83
|
-
`)},Oi=/node_modules\/nx\/schemas\/project-schema\.json$/u,Bv=(e,t,n,s)=>{let i=0;for(const r of e){if(t.dryRun){const a=ao(r);a?.$schema&&Oi.test(a.$schema)&&(n.info(`Would rewrite $schema in ${r}`),i+=1);continue}At(r,a=>{if(!(!a.$schema||!Oi.test(a.$schema)))return a.$schema=a.$schema.replace(Oi,"node_modules/@visulima/vis/schemas/project.schema.json"),a},s,{useEditorconfig:t.useEditorconfig})&&(i+=1)}return i>0&&n.info(`Rewrote $schema in ${String(i)} project.json file(s).`),i},ao=e=>{if(x(e))try{return JSON.parse(G(e))}catch{return}},Pv=e=>{const t=new Map,n=new Set;for(const s of e){const i=ao(s);if(!i?.name)continue;n.add(i.name);const r=g(nt(s),"package.json");if(x(r))try{const o=JSON.parse(G(r));o.name&&o.name!==i.name&&t.set(o.name,i.name)}catch{}}return{knownProjects:n,pkgToProject:t}},Nv=/&&|\|\||[;|><`]|\$\(/u,Dv=/[*[\]^.]/u,Ai=(e,t)=>{if(t===""){e.complex=!0;return}if(t.startsWith("!")){e.hasExclusion=!0;return}if(Dv.test(t)||t.includes("...")){e.hasGlob=!0;return}e.filters.push(t)},Mv=e=>{if(typeof e!="string"||e.trim()===""||Nv.test(e)||/['"]/u.test(e))return null;const t=e.trim().split(/\s+/u);if(t[0]!=="pnpm"&&t[0]!=="pnpm.cmd")return null;const n={complex:!1,filters:[],hasExclusion:!1,hasGlob:!1,parallel:!1,recursive:!1,target:""};let s=1;for(;s<t.length;){const i=t[s];if(i==="--filter"||i==="-F"){const r=t[s+1];if(r===void 0)return n.complex=!0,n;Ai(n,r),s+=2;continue}if(i.startsWith("--filter=")){Ai(n,i.slice(9)),s+=1;continue}if(i.startsWith("-F=")){Ai(n,i.slice(3)),s+=1;continue}if(i==="--parallel"){n.parallel=!0,s+=1;continue}if(i==="-r"||i==="--recursive"){n.recursive=!0,s+=1;continue}if(i==="--workspace-root"||i==="-w")return n.complex=!0,n;if(i==="run"||i==="exec"){if(i==="exec")return n.complex=!0,n;s+=1;continue}return i.startsWith("-")?(n.complex=!0,n):(n.target=i,s+=1,s<t.length&&(n.complex=!0),n)}return n.complex=!0,n},Lv=(e,t)=>{const n=[],s=[];for(const i of e){const r=t.pkgToProject.get(i);if(r!==void 0){n.push(r);continue}if(t.knownProjects.has(i)){n.push(i);continue}s.push(i)}return{mapped:n,unmapped:s}},_v=(e,t)=>{const n=["vis","run",e.target];if(t.length>0){const s=[...t].sort((i,r)=>i.localeCompare(r)).join(",");n.push(`--projects=${s}`)}return n.join(" ")},Fv=new Set(["dev","dev:server","dev:watch","serve","start:dev","storybook","watch"]),Vv=(e,t,n,s,i)=>{const r={rewrittenTargets:new Set,unmappedHits:[]},o=g(e,"package.json");if(!x(o))return r;let a;try{a=JSON.parse(G(o))}catch{return r}if(!a.scripts)return r;const c=new Map;for(const[l,d]of Object.entries(a.scripts)){const u=Mv(d);if(!u||u.target===""||u.complex)continue;if(u.hasExclusion||u.hasGlob){i.warnings.push(`pnpm filter in scripts.${l} uses ${u.hasExclusion?"an exclusion (!)":"a glob/dependency selector"} — left untouched. Translate by hand to \`vis run ${u.target} --projects=...\` once you decide which projects should be selected.`);continue}if(u.filters.length===0&&!u.recursive)continue;const p=Lv(u.filters,t);if(p.unmapped.length>0){r.unmappedHits.push({filters:p.unmapped,script:l});continue}const f=_v(u,p.mapped);f!==d&&(c.set(l,f),r.rewrittenTargets.add(u.target))}if(c.size===0)return r;if(n.dryRun){for(const[l,d]of c){const u=a.scripts[l];s.info(`Would rewrite scripts.${l}: \`${u??""}\` → \`${d}\``)}return r}return At(o,l=>{if(!l.scripts)return;const d={...l.scripts};let u=!1;for(const[p,f]of c)d[p]!==void 0&&d[p]!==f&&(d[p]=f,u=!0);if(u)return l.scripts=d,l},i,{useEditorconfig:n.useEditorconfig}),s.info(`Rewrote ${String(c.size)} pnpm-filter script(s) in package.json to use \`vis run\`.`),r},Hv=(e,t,n)=>{let s=e.targetDefaults??{},i=!1;for(const r of t){if(!Fv.has(r))continue;const a={...s[r]??{}};let c=!1;a.persistent!==!0&&(a.persistent=!0,c=!0),a.cache!==!1&&(a.cache=!1,c=!0),c&&(s={...s,[r]:a},i=!0,n.manualSteps.push(`tasks.${r} set to { persistent: true, cache: false } — long-running task auto-detected from rewritten pnpm filter scripts. Adjust if your ${r} is actually short-lived.`))}i&&(e.targetDefaults=s)},Wv=e=>{if(e.executor!=="nx:run-script")return!1;const t=Object.keys(e.options??{});return t.length===0||t.length===1&&t[0]==="script"},Uv=(e,t,n,s)=>{let i=0,r=0,o=0;const a=[];for(const c of e){const l=ao(c);if(!l?.targets||Object.keys(l.targets).length===0)continue;const d=l.name??"<unnamed>",u=[],p=[],f=[];for(const[b,$]of Object.entries(l.targets))$.syncGenerators&&$.syncGenerators.length>0&&f.push({sync:[...$.syncGenerators],target:b}),Wv($)?p.push(b):u.push(b);const h=u.length===0&&p.length>0,m=p.length>0;h?(t.dryRun?(n.info(`Would remove targets block from ${c} (all entries are nx:run-script shims).`),i+=1):(At(c,b=>{if(b.targets)return delete b.targets,b},s,{useEditorconfig:t.useEditorconfig}),i+=1),f.length>0&&a.push({file:c,name:d,nonShimTargets:[],syncGenerators:f})):m?(t.dryRun?n.info(`Would strip ${String(p.length)} nx:run-script shim entr(y/ies) from ${c} (non-shim entries kept: ${u.join(", ")}).`):At(c,b=>{if(b.targets){for(const $ of p)Reflect.deleteProperty(b.targets,$);return b}},s,{useEditorconfig:t.useEditorconfig}),r+=1,o+=p.length,a.push({file:c,name:d,nonShimTargets:u,syncGenerators:f})):a.push({file:c,name:d,nonShimTargets:u,syncGenerators:f})}return i>0&&n.info(`Removed targets block from ${String(i)} project.json file(s) (entries were nx:run-script shims).`),o>0&&!t.dryRun&&n.info(`Stripped ${String(o)} nx:run-script shim entr(y/ies) across ${String(r)} project.json file(s) (non-shim entries remain for manual review).`),{droppedTargetBlocks:i,partialTargetBlocks:r,punchList:a,strippedShimEntries:o}},Gv=(e,t,n,s)=>{const i=g(e,"pnpm-workspace.yaml");if(!x(i))return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1};let r;try{r=jt(i)}catch{return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1}}if(!r||typeof r!="object")return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1};let o=0;const a=f=>f==="nx"||f.startsWith("@nx/"),c=(f,h,m)=>{if(!f||typeof f!="object")return;const b=Object.keys(f).length,$=Object.fromEntries(Object.entries(f).filter(([S])=>!a(S))),v=b-Object.keys($).length;v>0&&(o+=v,h[m]=$)};c(r.catalog,r,"catalog");const l=r.catalogs;if(l&&typeof l=="object")for(const[f,h]of Object.entries(l))c(h,l,f);let d=!1;const u=r.onlyBuiltDependencies;if(Array.isArray(u)){const f=u.filter(h=>h!=="nx");f.length!==u.length&&(r.onlyBuiltDependencies=f,d=!0)}return(o>0||d)&&(t.dryRun?(o>0&&n.info(`Would remove ${String(o)} nx-related catalog entr(y/ies) from pnpm-workspace.yaml.`),d&&n.info("Would remove `nx` from pnpm-workspace.yaml#onlyBuiltDependencies.")):(re(i,s),yl(i,r),o>0&&n.info(`Removed ${String(o)} nx-related catalog entr(y/ies) from pnpm-workspace.yaml.`),d&&n.info("Removed `nx` from pnpm-workspace.yaml#onlyBuiltDependencies."))),{catalogEntriesRemoved:o,onlyBuiltRemoved:d}},zv=(e,t,n,s,i,r,o)=>{const a=g(nt(e),"package.json");if(!x(a))return{reason:"no sibling package.json"};const c=`pre${n}`,l=`echo "TODO(vis): replace with logic equivalent to nx syncGenerators: ${s.join(", ")}" && exit 1`;if(i.dryRun){let p;try{p=JSON.parse(G(a)).scripts}catch{return{reason:"package.json unreadable"}}return p?.[c]?{reason:`\`${c}\` script already exists in ${ve(t,a)}`}:(r.info(`Would add \`${c}\` script to ${ve(t,a)} (TODO for nx syncGenerators: ${s.join(", ")}).`),{pkgPath:ve(t,a),preScript:c})}let d;return At(a,p=>{if(p.scripts?.[c]){d=`\`${c}\` script already exists in ${ve(t,a)}`;return}return p.scripts={...p.scripts,[c]:l},p},o,{useEditorconfig:i.useEditorconfig})?(r.info(`Added \`${c}\` script (TODO) to ${ve(t,a)} — wire up replacement for: ${s.join(", ")}.`),{pkgPath:ve(t,a),preScript:c}):{reason:d??"package.json unwritable"}},Jv=/^nx\s+(?:run-many|run|affected|reset|repair)\b|^nx\s+exec\b/u,Kv=new Set(["affected","exec","repair","reset","run","run-many"]),qv=(e,t)=>{const n=e.trim();if(/[;&|"']/u.test(n))return;const s=/^nx\s+run-many\s+(?:-t|--target=?)\s*([\w:-]+)\s*$/u.exec(n);if(s)return`vis run ${s[1]}`;const i=/^nx\s+affected\s+(?:-t|--target=?)\s*([\w:-]+)\s*$/u.exec(n);if(i)return`vis run ${i[1]} --affected`;const r=/^nx\s+run\s+([\w@/-]+):([\w:-]+)\s*$/u.exec(n);if(r?.[1]&&r[2]&&t.has(r[1]))return`vis run ${r[2]} --projects=${r[1]}`;const o=/^nx\s+([\w:-]+)\s*$/u.exec(n);if(o?.[1]&&!Kv.has(o[1]))return`vis run ${o[1]}`},Yv=(e,t,n,s,i)=>{const r={deletedFiles:[],rewrittenScripts:[],skippedScripts:[],strippedDevDeps:[]},o=g(e,".github","ignore-files-for-nx-affected.yml");if(x(o))if(n.dryRun)s.info(`Would delete ${ve(e,o)}.`),r.deletedFiles.push(ve(e,o));else{re(o,i);try{pt(o),s.info(`Removed ${ve(e,o)} (backup at \`${ve(e,o)}.bak\`).`),r.deletedFiles.push(ve(e,o))}catch{}}const a=g(e,"package.json");if(!x(a))return r;if(At(a,c=>{let l=!1;if(c.devDependencies)for(const d of Object.keys(c.devDependencies))(d==="nx"||d.startsWith("@nx/")||d.startsWith("@nrwl/"))&&(n.dryRun||Reflect.deleteProperty(c.devDependencies,d),r.strippedDevDeps.push(d),l=!0);if(c.scripts)for(const[d,u]of Object.entries(c.scripts)){if(typeof u!="string"||!(Jv.test(u)||u.startsWith("nx ")))continue;const f=qv(u,t);if(f===void 0){r.skippedScripts.push(d);continue}n.dryRun||(c.scripts[d]=f),r.rewrittenScripts.push({from:u,name:d,to:f}),l=!0}return l?c:void 0},n.dryRun?void 0:i,{useEditorconfig:n.useEditorconfig}),r.strippedDevDeps.length>0){const c=n.dryRun?"Would strip":"Stripped";s.info(`${c} ${String(r.strippedDevDeps.length)} nx-related devDependenc(y/ies) from package.json: ${r.strippedDevDeps.join(", ")}.`)}for(const c of r.rewrittenScripts){const l=n.dryRun?"Would rewrite":"Rewrote";s.info(`${l} \`scripts.${c.name}\`: \`${c.from}\` -> \`${c.to}\``)}return r.skippedScripts.length>0&&i.manualSteps.push(`--aggressive could not rewrite these package.json scripts (they have shell complexity or unknown flags): ${r.skippedScripts.join(", ")}. Rewrite them manually to use \`vis run\`.`),r},Xv=e=>{const t={eslintHits:[],ignoreFile:!1,nxJson:!1,pkgDevDeps:[],pkgScripts:[],workflowHits:[]};x(g(e,"nx.json"))&&(t.nxJson=!0),x(g(e,".github/ignore-files-for-nx-affected.yml"))&&(t.ignoreFile=!0);const n=g(e,"package.json");if(x(n))try{const i=JSON.parse(G(n));if(i.devDependencies)for(const r of Object.keys(i.devDependencies))(r==="nx"||r.startsWith("@nx/")||r.startsWith("@nrwl/"))&&t.pkgDevDeps.push(r);if(i.scripts)for(const[r,o]of Object.entries(i.scripts))typeof o=="string"&&(/\bnx\s+(?:run-many|run|affected|exec|reset|repair)\b/u.test(o)||o.startsWith("nx "))&&t.pkgScripts.push(r)}catch{}const s=g(e,".github/workflows");if(x(s))try{for(const i of Te(s)){if(!i.endsWith(".yml")&&!i.endsWith(".yaml"))continue;const r=g(s,i),o=G(r);/nrwl\/nx-set-shas/u.test(o)&&t.workflowHits.push({file:`.github/workflows/${i}`,reason:"uses nrwl/nx-set-shas action"}),/\bNX_BRANCH\b|\bNX_RUN_GROUP\b/u.test(o)&&t.workflowHits.push({file:`.github/workflows/${i}`,reason:"sets NX_BRANCH / NX_RUN_GROUP env"}),(/--files=\$\{\{[^}]*tj-actions/u.test(o)||/tj-actions\/changed-files/u.test(o))&&t.workflowHits.push({file:`.github/workflows/${i}`,reason:"uses tj-actions/changed-files (no longer needed; vis does its own affected diff)"})}}catch{}for(const i of["eslint.config.mjs","eslint.config.js","eslint.config.cjs","eslint.config.ts",".eslintrc.json",".eslintrc.js"]){const r=g(e,i);if(!x(r))continue;const o=G(r);/@nx\/eslint-plugin|@nx\/enforce-module-boundaries|@nx\/dependency-checks|@nx\/nx-plugin-checks/u.test(o)&&t.eslintHits.push(i)}return t},Zv=(e,t,n)=>{const s=[];if(e.nxJson&&!n.backedUpNxJson&&s.push(`Remove ${g(t,"nx.json")} once you're satisfied with vis.config.ts.`),e.ignoreFile&&s.push("Delete .github/ignore-files-for-nx-affected.yml — vis uses git-based affected diff and has no equivalent."),e.pkgDevDeps.length>0&&s.push(`Remove these nx devDependencies from package.json: ${e.pkgDevDeps.join(", ")}.`),e.pkgScripts.length>0&&s.push(`Rewrite these package.json scripts to use \`vis run\`: ${e.pkgScripts.join(", ")}.`),e.workflowHits.length>0){const i=new Map;for(const r of e.workflowHits){const o=i.get(r.file)??new Set;o.add(r.reason),i.set(r.file,o)}for(const[r,o]of i)s.push(`Update ${r}: ${[...o].join("; ")}.`)}return e.eslintHits.length>0&&s.push(`Remove @nx/eslint-plugin imports + rules (enforce-module-boundaries, dependency-checks, nx-plugin-checks) from: ${e.eslintHits.join(", ")}. There is no vis equivalent yet.`),s.map((i,r)=>`${String(r+1)}. ${i}`)},Qv=(e,t)=>{if(e.length!==0){t.info(""),t.info("── Post-migrate cleanup ──");for(const n of e)t.info(n)}},Ma=(e,t,n,s)=>{t.aggressive&&(t={...t,force:!0,rewriteSyncGenerators:!0});const i=bd(e,"nx.json");if(!i){n.warn("No nx.json found in workspace root — nothing to migrate."),s.warnings.push("No nx.json at workspace root.");return}i.targetDefaults&&(i.targetDefaults=Av(i.targetDefaults,s,n));const r=jv(e),o=Pv(r),a=Vv(e,o,t,n,s);Hv(i,a.rewrittenTargets,s);for(const f of a.unmappedHits)s.warnings.push(`scripts.${f.script}: pnpm filter(s) ${f.filters.map(h=>`\`${h}\``).join(", ")} don't match any known project.json#name or sibling package.json#name. Left untouched — fix the filter or add the missing project.json before re-running.`);const c=Iv(i,e,t.useEditorconfig);if(!oo(e,c,t,n,s))return;Bv(r,t,n,s);const{punchList:l}=Uv(r,t,n,s);for(const f of l){f.nonShimTargets.length>0&&s.manualSteps.push(`Review targets in ${ve(e,f.file)} (project: ${f.name}) — non-shim targets need manual review: ${f.nonShimTargets.join(", ")}.`);for(const h of f.syncGenerators){if(t.rewriteSyncGenerators){const m=zv(f.file,e,h.target,h.sync,t,n,s);if("preScript"in m){s.manualSteps.push(`${m.pkgPath} now has a \`${m.preScript}\` script that fails with a TODO. Replace it with the real equivalent of nx syncGenerators: ${h.sync.join(", ")}.`);continue}s.warnings.push(`syncGenerators on \`${f.name}#${h.target}\` (${ve(e,f.file)}) not auto-rewritten — ${m.reason}. Move ${h.sync.join(", ")} into a \`pre${h.target}\` script in package.json manually.`);continue}s.warnings.push(`syncGenerators on \`${f.name}#${h.target}\` (${ve(e,f.file)}) has no vis equivalent. Move ${h.sync.join(", ")} into a \`pre${h.target}\` script in package.json (or re-run with --rewrite-sync-generators to insert a TODO automatically).`)}}Gv(e,t,n,s),t.aggressive&&Yv(e,o.knownProjects,t,n,s),s.manualSteps.push("vis adds two task primitives nx doesn't expose declaratively: `when: { os, env, branch, ci, not.* }` for conditional execution (replaces ad-hoc `configurations`) and `always: true` for finally/teardown tasks that run even when upstream fails. See docs/guides/conditional-and-finally-tasks.mdx.");const d=i.affected?.defaultBase??i.defaultBase;typeof d=="string"&&d.length>0&&d!=="main"&&n.info(`Translated nx's default base branch (${d}) into vis.config.ts#defaultBase.`),Cv(e,{dryRun:t.dryRun},n);const u=Xv(e),p=Zv(u,e,{});if(Qv(p,n),t.force&&!t.dryRun&&u.nxJson){const f=g(e,"nx.json");re(f,s);try{pt(f),n.info(`Removed ${f} (backup at ${f}.bak).`)}catch{}}},$d=[".secretlintrc",".secretlintrc.json",".secretlintrc.js",".secretlintrc.mjs",".secretlintrc.cjs",".secretlintrc.yml",".secretlintrc.yaml"],Ed=[".secretlintignore"],Cd=e=>$d.find(t=>x(g(e,t))),Rd=e=>Ed.find(t=>x(g(e,t))),eb=(e,t,n)=>{if(t.endsWith(".js")||t.endsWith(".mjs")||t.endsWith(".cjs"))return Q(n,`${t} is a JS config — cannot auto-extract rule IDs. Review manually to confirm coverage.`),[];if(t.endsWith(".yml")||t.endsWith(".yaml"))return Q(n,`${t} is YAML — cannot auto-extract rule IDs without a YAML parser. Review manually.`),[];const s=fe(g(e,t));if(!s)return[];const i=new Set,r=o=>{if(o)for(const a of o)a.id&&i.add(a.id),a.rules&&r(a.rules)};return r(s.rules),[...i]},tb=(e,t,n,s)=>{for(const i of[...$d,...Ed]){const r=g(e,i);if(x(r)){if(t){n.info(`[dry-run] Would remove ${r}`);continue}re(r,s),pt(r),me(s,"secretlint","removedConfigCount"),n.info(`Removed ${r}`)}}},nb=(e,t,n,s)=>{const i=g(e,".secretlintignore");if(!x(i))return;const o=G(i).split(/\r?\n/).map(a=>a.trim()).filter(a=>a&&!a.startsWith("#"));o.length!==0&&(ne(s,`.secretlintignore contained ${String(o.length)} path pattern(s). vis secrets uses .gitignore + --exclude / --exclude-from; add these globs to your .gitignore or pass --exclude: ${o.slice(0,5).join(", ")}${o.length>5?", ...":""}`),t&&n.info(`[dry-run] Would consume ${i} (${String(o.length)} patterns) and surface as manual step.`))},sb=(e,t,n,s,i)=>{const r=g(e,"package.json");if(!x(r))return;const o=fe(r);if(!o)return;let a=!1;if(o.scripts){for(const[l,d]of Object.entries(o.scripts))if(typeof d=="string"&&/\bsecretlint\b/.test(d)){const u=d.replaceAll(/\bsecretlint\b[^\n&|;]*/g,"vis secrets").trim();u!==d&&(o.scripts[l]=u,a=!0,me(s,"secretlint","rewrittenScriptCount"),n.info(` scripts.${l}: "${d}" -> "${u}"`))}}if(o.devDependencies){const l=o.devDependencies,d=[];for(const u of Object.keys(l))(u==="secretlint"||u.startsWith("@secretlint/"))&&(delete l[u],d.push(u),a=!0,me(s,"secretlint","removedPackageCount"));d.length>0&&n.info(` removed ${String(d.length)} secretlint devDependencies: ${d.join(", ")}`)}if(!a)return;if(t){n.info(`[dry-run] Would update ${r}`);return}const c=qe(r,G(r),{defaultIndent:" ",useEditorconfig:i});re(r,s),ge(r,`${JSON.stringify(o,null,c)}
|
|
84
|
-
`)},
|
|
85
|
-
`,"utf8")}return s},cb=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],lb=[".github/workflows",".gitlab-ci.yml",".circleci/config.yml",".woodpecker.yml",".drone.yml"],Id=(e,t)=>{const n=[];for(const s of cb){const i=g(e,s);x(i)&&li.test(G(i))&&(n.push(s),ne(t,`Update ${s} — replace \`sherif\` invocation with \`vis lint\`.`))}return n},Bd=(e,t)=>{const n=[],s=i=>{const r=g(e,i);x(r)&&li.test(G(r))&&(n.push(i),ne(t,`Update ${i} — replace \`sherif\` invocation with \`vis lint\`.`))};for(const i of lb){const r=g(e,i);if(x(r)){if(i===".github/workflows"){try{for(const o of Te(r))(o.endsWith(".yml")||o.endsWith(".yaml"))&&s(`.github/workflows/${o}`)}catch{}continue}s(i)}}return n},db=(e,t,n,s,i)=>{const r=Od(t,i);if(r.visDisabled.length>0){const p=Ad(r.visDisabled);ne(i,`sherif's \`ignore-rules\` was set to [${r.visDisabled.map(f=>JSON.stringify(f)).join(", ")}] (vis names). vis has no global rule-disable; replace any \`sherif\` script with the explicit positive list: \`${p}\`.`)}r.unmapped.length>0&&Q(i,`sherif rule(s) [${r.unmapped.map(p=>JSON.stringify(p)).join(", ")}] could not be mapped — please re-evaluate manually.`),Array.isArray(t["ignore-dependencies"])&&t["ignore-dependencies"].length>0&&ne(i,`sherif's \`ignore-dependencies\` was set to [${t["ignore-dependencies"].map(p=>JSON.stringify(p)).join(", ")}]. Mirror this in vis.config.ts under \`policy.workspaceVersions.ignore\`, \`policy.customTypes.ignore\`, \`policy.typesInDeps.ignore\` (and \`policy.redefineRoot.ignore\`) for the lints where it applies.`),Array.isArray(t["ignore-packages"])&&t["ignore-packages"].length>0&&(Q(i,`sherif's \`ignore-packages\` was set to [${t["ignore-packages"].map(p=>JSON.stringify(p)).join(", ")}] — vis has no global package-skip yet (only per-rule scoping via policy.bannedDeps.{packages,paths}). Tracked alongside the dep filter work.`),ne(i,"Re-evaluate sherif `ignore-packages` — vis has no equivalent global filter yet.")),Array.isArray(t["ignore-paths"])&&t["ignore-paths"].length>0&&(Q(i,`sherif's \`ignore-paths\` was set to [${t["ignore-paths"].map(p=>JSON.stringify(p)).join(", ")}] — vis has no global path-skip yet.`),ne(i,"Re-evaluate sherif `ignore-paths` — vis has no equivalent global filter yet."));const o=Id(e,i);o.length>0&&!n.silent&&s.warn(`Found sherif reference in ${String(o.length)} hook file(s) — see manualSteps for details.`);const a=Bd(e,i);a.length>0&&!n.silent&&s.warn(`Found sherif reference in ${String(a.length)} CI file(s) — see manualSteps for details.`);const{configRemoved:c,dependencyRemoved:l,removedScripts:d,scriptCount:u}=ab(e,n.useEditorconfig);if(c&&!n.silent&&s.info("Removed `sherif` block from package.json"),c&&me(i,Ii,"removedConfigCount"),l&&me(i,Ii,"removedPackageCount"),u>0){me(i,Ii,"rewrittenScriptCount",u);for(const{name:p,value:f}of d)ne(i,`Recreate script \`${p}\` (removed; was \`${f}\`). Replace \`sherif\` with \`vis lint\` (sherif's lint surface ≈ \`vis lint\`).`);n.silent||s.info(`Removed ${String(u)} script(s) referencing \`sherif\`. Replace with \`vis lint\`.`)}},_a=(e,t,n,s)=>{const i=jd(e),r=Td(e);if(!i&&!r)return t.silent||n.info("No sherif configuration or installation found — nothing to migrate."),!1;const o=ob(e)??{};if(t.dryRun){const a=Od(o,s);if(Id(e,s),Bd(e,s),!t.silent&&(i&&n.info("[dry-run] Would remove `sherif` block from package.json"),r&&n.info("[dry-run] Would strip `sherif` from devDependencies/scripts"),a.visDisabled.length>0)){const c=Ad(a.visDisabled);n.info(`[dry-run] Suggested replacement script: ${c}`)}return!0}return db(e,o,t,n,s),!0},ub=["dependencies","devDependencies","peerDependencies","optionalDependencies","overrides","resolutions","pnpm.overrides"],pb=(e,t)=>{const n=t.split(".");let s=e;for(const i of n){if(typeof s!="object"||s===null)return;s=s[i]}return typeof s=="object"&&s!==null?s:void 0},co=e=>{const t=g(e,"package.json");if(!x(t))return["."];const s=le(t).workspaces;let i=[];if(s){const r=Array.isArray(s)?s:s.packages;r&&(i=Go(e,r))}if(i.length===0){const r=If(e);r&&(i=Go(e,r))}return[".",...i]},di=e=>{if(x(e))try{return le(e)}catch{return}},fb=e=>{const t=new Set,n=co(e);for(const s of n){const i=di(g(e,s,"package.json"));i&&typeof i.name=="string"&&t.add(i.name)}return t},Fj=(e,t={})=>{const n=t.includeInternal??!0,s=t.depTypes??ub,i=co(e),r=fb(e),o=[],c=s.includes("pnpm.overrides")?Af(e):void 0,l=c?g(e,"pnpm-workspace.yaml"):void 0;for(const d of i){const u=g(e,d,"package.json"),p=di(u);if(!p)continue;const f=typeof p.name=="string"?p.name:void 0,h=d==="."?".":ss(e,g(e,d));for(const m of s){const b=m.includes(".")?pb(p,m):p[m];if(!(!b||typeof b!="object"))for(const[$,v]of Object.entries(b)){if(typeof v!="string")continue;const S=r.has($);!n&&S||o.push({depName:$,depType:m,isInternal:S,packageDir:h,packageJsonPath:u,packageName:f,specifier:v})}}}if(c&&l)for(const[d,u]of Object.entries(c)){const p=r.has(d);!n&&p||o.push({depName:d,depType:"pnpm.overrides",isInternal:p,packageDir:".",packageJsonPath:l,packageName:void 0,specifier:u})}return o},lo=new Set(["devEngines.packageManager","devEngines.runtime","engines","packageManager","volta"]),hb=["engines","volta"],mb=new Set(["extends"]),gb=/^([@\w./-]+?)@([^+]+)(\+.+)?$/,yb=/^([@\w./-]+)~(.+)$/,ui=e=>{const t=gb.exec(e.trim());if(!(!t?.[1]||!t[2]))return{hash:t[3]??"",name:t[1],version:t[2]}},Pd=e=>{const t=yb.exec(e.trim());if(!(!t?.[1]||!t[2]))return{name:t[1],version:t[2]}},Yn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Nd=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.name=="string",vb=new Set(["name@version","name~version","string","versionsByName"]),Vj=e=>{const t=[];if(!e)return t;const n=new Set;for(const s of e){const i=typeof s?.name=="string"&&s.name.length>0?s.name:"<unnamed>";if(typeof s?.name!="string"||s.name.length===0){t.push("extraTypes entry missing 'name'");continue}lo.has(s.name)&&t.push(`extraTypes[${i}]: name collides with a built-in customType`),n.has(s.name)&&t.push(`extraTypes[${i}]: duplicate name`),n.add(s.name),(typeof s.path!="string"||s.path.length===0)&&t.push(`extraTypes[${i}]: missing 'path'`),vb.has(s.strategy)||t.push(`extraTypes[${i}]: invalid strategy "${String(s.strategy)}" (expected name@version | name~version | string | versionsByName)`),s.strategy==="string"&&(typeof s.depName!="string"||s.depName.length===0)&&t.push(`extraTypes[${i}]: strategy 'string' requires 'depName'`)}return t},bb=(e,t)=>{if(t.length===0)return;let n=e;for(const s of t.split(".")){if(typeof n!="object"||n===null||Array.isArray(n))return;n=n[s]}return n},wb=(e,t,n,s,i)=>{const r=bb(t,e.path);if(r===void 0)return[];const o=Object.freeze({depName:e.depName,path:e.path,strategy:e.strategy});if(e.strategy==="versionsByName"){if(!Yn(r))return[];const a=[];for(const[c,l]of Object.entries(r))typeof l=="string"&&a.push({customType:e.name,depName:c,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:l,specifier:l});return a}if(e.strategy==="name@version"){if(typeof r!="string")return[];const a=ui(r);return a?[{customType:e.name,depName:a.name,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:r,specifier:a.version}]:[]}if(e.strategy==="name~version"){if(typeof r!="string")return[];const a=Pd(r);return a?[{customType:e.name,depName:a.name,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:r,specifier:a.version}]:[]}return typeof r!="string"||typeof e.depName!="string"||e.depName.length===0?[]:[{customType:e.name,depName:e.depName,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:r,specifier:r}]},Hj=(e,t)=>{const n=co(e),s=[];for(const i of n){const r=g(e,i,"package.json"),o=di(r);if(!o)continue;const a=typeof o.name=="string"?o.name:void 0,c=i==="."?".":ss(e,g(e,i));for(const d of hb){const u=o[d];if(Yn(u))for(const[p,f]of Object.entries(u))typeof f=="string"&&(d==="volta"&&mb.has(p)||s.push({customType:d,depName:p,packageDir:c,packageJsonPath:r,packageName:a,rawValue:f,specifier:f}))}if(typeof o.packageManager=="string"){const d=ui(o.packageManager);d&&s.push({customType:"packageManager",depName:d.name,packageDir:c,packageJsonPath:r,packageName:a,rawValue:o.packageManager,specifier:d.version})}const{devEngines:l}=o;if(typeof l=="object"&&l!==null&&!Array.isArray(l))for(const d of["runtime","packageManager"]){const u=l[d];if(u===void 0)continue;const p=Array.isArray(u)?u:[u];for(const f of p)!Nd(f)||typeof f.version!="string"||s.push({customType:d==="runtime"?"devEngines.runtime":"devEngines.packageManager",depName:f.name,packageDir:c,packageJsonPath:r,packageName:a,rawValue:f.version,specifier:f.version})}if(t){for(const d of t)if(!(typeof d?.name!="string"||d.name.length===0)&&!lo.has(d.name))for(const u of wb(d,o,c,r,a))s.push(u)}}return s},kb=(e,t)=>`${e} ${t}`,Sb=(e,t)=>{const n=[...e].sort((i,r)=>(i.packageName??i.packageDir).localeCompare(r.packageName??r.packageDir));let s;for(const i of n){const r=ir(i.specifier);if(!r)continue;if(!s){s=i;continue}const o=ir(s.specifier);if(!o){s=i;continue}const a=zo(o,r),c=zo(r,o);(t==="highest"&&a||t==="lowest"&&c)&&(s=i)}return s},Wj=(e,t={})=>{const n=new Set(t.ignoreDeps),s=t.resolve??"highest",i=[],r=e.filter(a=>t.dep!==void 0&&a.depName!==t.dep?!1:!n.has(a.depName)),o=new Map;for(const a of r){const c=kb(a.customType,a.depName),l=o.get(c);l?l.push(a):o.set(c,[a])}for(const[,a]of o){if(a.length<2||new Set(a.map(d=>d.specifier)).size<=1)continue;const l=Sb(a,s);if(l)for(const d of a)d.specifier!==l.specifier&&ir(d.specifier)!==void 0&&i.push({canonicalSource:l.packageName??l.packageDir,customType:d.customType,depName:d.depName,...d.extra?{extra:d.extra}:{},fix:l.specifier,packageDir:d.packageDir,packageJsonPath:d.packageJsonPath,packageName:d.packageName,specifier:d.specifier})}return i},xb=(e,t)=>{const n=t.extra;if(!n)return!1;const s=n.path.split(".");if(s.length===0||s.some(o=>o.length===0))return!1;let i=e;for(let o=0;o<s.length-1;o+=1){const a=i[s[o]];if(typeof a!="object"||a===null||Array.isArray(a))return!1;i=a}const r=s.at(-1);if(n.strategy==="versionsByName"){const o=i[r];return Yn(o)?(o[t.depName]=t.fix,!0):!1}if(n.strategy==="name@version"){const o=i[r];if(typeof o!="string")return!1;const a=ui(o);return a?(i[r]=`${a.name}@${t.fix}`,!0):!1}if(n.strategy==="name~version"){const o=i[r];if(typeof o!="string")return!1;const a=Pd(o);return a?(i[r]=`${a.name}~${t.fix}`,!0):!1}return typeof i[r]!="string"?!1:(i[r]=t.fix,!0)},Uj=(e,t={})=>{const{useEditorconfig:n}=t,s=new Map;for(const r of e){const o=s.get(r.packageJsonPath);o?o.push(r):s.set(r.packageJsonPath,[r])}const i=[];for(const[r,o]of s){const a=di(r);if(!a)continue;let c=!1;for(const l of o){if(l.extra){xb(a,l)&&(c=!0);continue}if(l.customType==="engines"||l.customType==="volta"){const h=a[l.customType];Yn(h)&&(h[l.depName]=l.fix,c=!0);continue}if(l.customType==="packageManager"){const h=a.packageManager;if(typeof h=="string"){const m=ui(h);m&&(a.packageManager=`${m.name}@${l.fix}`,c=!0)}continue}const d=l.customType==="devEngines.runtime"?"runtime":"packageManager",{devEngines:u}=a;if(!Yn(u))continue;const p=u[d];if(p===void 0)continue;const f=Array.isArray(p)?p:[p];for(const h of f)Nd(h)&&h.name===l.depName&&(h.version=l.fix,c=!0)}c&&(Kf(r,a,{indent:Bf(r,{useEditorconfig:n}),overwrite:!0}),i.push(r))}return i},wr="syncpack",Dd=[".syncpackrc",".syncpackrc.json"],uo=[".syncpackrc.yaml",".syncpackrc.yml"],po=[".syncpackrc.cjs",".syncpackrc.js",".syncpackrc.mjs",".syncpackrc.ts","syncpack.config.cjs","syncpack.config.js","syncpack.config.mjs","syncpack.config.ts"],$b=[...Dd,...uo,...po],Eb=/\bextraTypes\s*:/,Cb=/\bpolicy\s*:/,Fa=/(defineConfig\(\{)/,Va=/(export\s+default\s+\{)/,fo=/\bsyncpack\b/,Md=e=>{const t=g(e,"package.json");if(x(t)&&fe(t)?.syncpack)return"package.json";for(const n of $b)if(x(g(e,n)))return n},Rb=e=>{for(const n of po)if(x(g(e,n)))return n;const t=g(e,".syncpackrc");if(x(t)&&!yn(t))try{jt(t);return}catch{return".syncpackrc"}},jb=e=>{const t=Dt(e);return t?Eb.test(G(t)):!1},Tb=e=>fe(g(e,"package.json"))?.syncpack,Ob=e=>fe(e),Ha=e=>{try{return jt(e)}catch{return}},Ab=(e,t,n)=>{if(t==="package.json")return Tb(e);if(po.includes(t)){Q(n,`${t} is a TS/JS config and cannot be auto-migrated — vis migrate does not load executable config. Convert to .syncpackrc.json and re-run, or translate directly into vis.config.ts. Tracked in https://github.com/visulima/visulima/issues/622.`),ne(n,`Translate ${t} into vis.config.ts (policy.* and security.*) — see https://github.com/visulima/visulima/issues/622`);return}const s=g(e,t);if(uo.includes(t))return Ha(s);if(t===".syncpackrc"&&!yn(s)){const i=Ha(s);if(i)return i;Q(n,".syncpackrc is neither valid JSON nor YAML — please migrate manually.");return}return Ob(s)},Ld=(e,t)=>{const n=[];if(!e.customTypes)return n;for(const[s,i]of Object.entries(e.customTypes)){if(!i||typeof i!="object")continue;const{strategy:r}=i,{path:o}=i;if(typeof o!="string"||o.length===0){Q(t,`customType "${s}" has no \`path\` — skipped.`);continue}if(r!=="name@version"&&r!=="string"&&r!=="versionsByName"){Q(t,`customType "${s}" has unsupported strategy ${JSON.stringify(r)} — skipped.`);continue}if(lo.has(s)){Q(t,`customType "${s}" collides with a vis built-in and was dropped — vis already lints this surface.`);continue}const a={name:s,path:o,strategy:r};if(r==="string"){const{depName:c}=i;typeof c=="string"&&c.length>0?a.depName=c:(Q(t,`customType "${s}" uses strategy "string" but has no \`depName\` — vis requires it. Add it manually after migration.`),ne(t,`Set policy.customTypes.extraTypes[name="${s}"].depName before running vis lint`))}n.push(a)}return n},_d=e=>e.isBanned===!0,Fd=(e,t)=>{if(Array.isArray(e.versionGroups)&&e.versionGroups.length>0){const n=e.versionGroups.filter(s=>s&&typeof s=="object"&&!_d(s));n.length>0&&(Q(t,`${String(n.length)} versionGroups rule(s) cannot be migrated — \`pinVersion\`, \`snapTo\`, and \`policy: "sameRange"\` (and other versionGroups DSL surfaces) are tracked in https://github.com/visulima/visulima/issues/622.`),ne(t,'Re-implement versionGroups rules using `pinVersion` / `snapTo` / `policy: "sameRange"` once the vis DSL ships (issue #622).'))}Array.isArray(e.semverGroups)&&e.semverGroups.length>0&&(Q(t,`${String(e.semverGroups.length)} semverGroups rule(s) cannot be migrated — semverGroups DSL is tracked in https://github.com/visulima/visulima/issues/622.`),ne(t,"Re-implement semverGroups rules manually once the vis DSL ships (issue #622)")),Array.isArray(e.dependencyTypes)&&e.dependencyTypes.length>0&&ne(t,"Review syncpack `dependencyTypes` — vis applies policies to dependencies/devDependencies/peerDependencies/optionalDependencies/overrides by default. Narrow via policy.* filters if needed."),Array.isArray(e.specifierTypes)&&e.specifierTypes.length>0&&ne(t,"Review syncpack `specifierTypes` — vis has no direct equivalent today; specifier filtering belongs in versionGroups (issue #622)."),typeof e.filter=="string"&&e.filter.length>0&&ne(t,`Re-implement syncpack \`filter\` regex (${e.filter}) once vis exposes a top-level dep filter.`),(Array.isArray(e.sortAz)&&e.sortAz.length>0||Array.isArray(e.sortFirst)&&e.sortFirst.length>0||Array.isArray(e.sortExports)&&e.sortExports.length>0)&&Q(t,"syncpack sort options (sortAz / sortFirst / sortExports) are superseded by `vis sort-package-json` — no migration needed."),(e.sortPackages!==void 0||e.formatBugs!==void 0||e.formatRepository!==void 0)&&Q(t,"syncpack package.json shape options (sortPackages / formatBugs / formatRepository) are superseded by `vis sort-package-json` — no migration needed."),(e.lintFormatting!==void 0||e.lintSemverRanges!==void 0||e.lintVersions!==void 0)&&Q(t,"syncpack lint toggles (lintFormatting / lintSemverRanges / lintVersions) are covered by `vis lint` by default — no migration needed."),Array.isArray(e.source)&&e.source.length>0&&ne(t,`syncpack \`source\` was set to [${e.source.map(n=>JSON.stringify(n)).join(", ")}]. vis derives workspace globs from pnpm-workspace.yaml / package.json#workspaces — verify they match before relying on \`vis lint\`.`),typeof e.indent=="string"&&e.indent.length>0&&Q(t,"syncpack `indent` is implicit in vis — JSON writers honor `.editorconfig` (and the source file's existing indentation). No migration needed.")},Vd=(e,t)=>{const n={};if(!Array.isArray(e.versionGroups))return n;for(const s of e.versionGroups){if(!s||typeof s!="object")continue;const i=s;if(!_d(i))continue;const r=Array.isArray(i.dependencies)?i.dependencies.filter(l=>typeof l=="string"&&l.length>0):[];if(r.length===0){Q(t,"versionGroup with `isBanned: true` has no `dependencies` entries — skipped.");continue}const o=Array.isArray(i.packages)?i.packages.filter(l=>typeof l=="string"&&l.length>0):[],a=i.label,c=typeof a=="string"&&a.length>0?a:"banned via syncpack versionGroups";for(const l of r){if(n[l]!==void 0){Q(t,`Multiple banned versionGroups target "${l}" — kept the first match; merge manually if needed.`);continue}n[l]=o.length>0?{packages:o,reason:c}:c}}return n},Ib=e=>{const t=[`name: ${JSON.stringify(e.name)}`,`path: ${JSON.stringify(e.path)}`,`strategy: ${JSON.stringify(e.strategy)}`];return e.depName!==void 0&&t.push(`depName: ${JSON.stringify(e.depName)}`),` { ${t.join(", ")} }`},Bb=(e,t)=>{if(typeof t=="string")return` ${JSON.stringify(e)}: ${JSON.stringify(t)}`;const n=[`reason: ${JSON.stringify(t.reason)}`];return t.packages&&t.packages.length>0&&n.push(`packages: [${t.packages.map(s=>JSON.stringify(s)).join(", ")}]`),t.paths&&t.paths.length>0&&n.push(`paths: [${t.paths.map(s=>JSON.stringify(s)).join(", ")}]`),t.replacement!==void 0&&n.push(`replacement: ${JSON.stringify(t.replacement)}`),` ${JSON.stringify(e)}: { ${n.join(", ")} }`},kr=(e,t={})=>{const n=[],s=Object.entries(t);if(s.length>0){const i=s.map(([r,o])=>Bb(r,o)).join(`,
|
|
80
|
+
`,a=i.split(/\r?\n/),c=Td.filter(d=>!Od(a,d));if(c.length===0)return{added:[],changed:!1};const l=[...a];for(;l.length>0&&l[l.length-1].trim()==="";)l.pop();return l.length>0&&l.push(""),l.push("# vis run state (.vis/templates and .vis/hooks are tracked — do not ignore .vis/ wholesale)",...c),me(s,`${l.join(o)}${o}`),{added:[...c],changed:!0}},Yv=(e,t,n)=>{if(t.dryRun){const r=g(e,".gitignore"),i=x(r)?G(r).split(/\r?\n/):[],o=Td.filter(a=>!Od(i,a));o.length>0&&n.info(`Would add to .gitignore: ${o.join(", ")}.`);return}const s=Kv(e,{create:!1});s.added.length>0&&n.info(`Added to .gitignore: ${s.added.join(", ")}.`)},ve=(e,t)=>{const n=rs(e,t);return n.startsWith("..")?t:n.split(Ef).join("/")},Xv=new Set([".cache",".git",".next",".nx",".output",".svelte-kit",".turbo",".vercel",".vis","build","coverage","dist","node_modules"]),Zv=(e,t=8)=>{const n=[],s=(r,i)=>{if(i>t)return;let o;try{o=Te(r)}catch{return}for(const a of o){if(Xv.has(a)||a.startsWith("."))continue;const c=g(r,a);let l;try{l=Ot(c)}catch{continue}l.isDirectory()?s(c,i+1):a==="project.json"&&n.push(c)}};return s(e,0),n},Qv={"@nx/eslint:lint":"lint:eslint","@nx/jest:jest":"test","@nx/js:tsc":"build","@nx/next:build":"build","@nx/playwright:playwright":"test:e2e","@nx/storybook:build":"build-storybook","@nx/vite:build":"build","@nx/vite:test":"test","@nx/webpack:webpack":"build"},eb=["cache","dependsOn","inputs","outputs","persistent"],tb=(e,t,n)=>{const s={};for(const[r,i]of Object.entries(e))r.includes(":")||(s[r]=i);for(const[r,i]of Object.entries(e)){if(!r.includes(":"))continue;const o=Qv[r];if(!o){t.warnings.push(`Dropped \`${r}\` from tasks — vis only supports script-name targets, not nx-namespaced executors.`);continue}if(s[o]){t.warnings.push(`Dropped \`${r}\` from tasks — \`${o}\` already has an explicit entry; the explicit one was kept.`);continue}const a={},c=[];for(const d of eb)i[d]!==void 0&&(a[d]=i[d],c.push(d));s[o]=a;const l=c.length>0?`carried ${c.join(", ")}`:"no settings to carry";n?.info(`Translated \`${r}\` → \`${o}\` in tasks (${l}).`)}return s},nb=(e,t,n)=>{const s={},r=e.affected?.defaultBase??e.defaultBase;return typeof r=="string"&&r.length>0&&r!=="main"&&(s.defaultBase=r),e.namedInputs&&Object.keys(e.namedInputs).length>0&&(s.namedInputs=e.namedInputs),e.targetDefaults&&Object.keys(e.targetDefaults).length>0&&(s.tasks=e.targetDefaults),["// Migrated from nx.json by `vis migrate nx`.","// Per-project project.json files are compatible with vis and do not need to be rewritten —","// vis already reads targets, tags, implicitDependencies, and sourceRoot.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${lo(s,g(t,"vis.config.ts"),n)});`,""].join(`
|
|
81
|
+
`)},Ir=/node_modules\/nx\/schemas\/project-schema\.json$/u,sb=(e,t,n,s)=>{let r=0;for(const i of e){if(t.dryRun){const a=po(i);a?.$schema&&Ir.test(a.$schema)&&(n.info(`Would rewrite $schema in ${i}`),r+=1);continue}At(i,a=>{if(!(!a.$schema||!Ir.test(a.$schema)))return a.$schema=a.$schema.replace(Ir,"node_modules/@visulima/vis/schemas/project.schema.json"),a},s,{useEditorconfig:t.useEditorconfig})&&(r+=1)}return r>0&&n.info(`Rewrote $schema in ${String(r)} project.json file(s).`),r},po=e=>{if(x(e))try{return JSON.parse(G(e))}catch{return}},rb=e=>{const t=new Map,n=new Set;for(const s of e){const r=po(s);if(!r?.name)continue;n.add(r.name);const i=g(nt(s),"package.json");if(x(i))try{const o=JSON.parse(G(i));o.name&&o.name!==r.name&&t.set(o.name,r.name)}catch{}}return{knownProjects:n,pkgToProject:t}},ib=/&&|\|\||[;|><`]|\$\(/u,ob=/[*[\]^.]/u,Br=(e,t)=>{if(t===""){e.complex=!0;return}if(t.startsWith("!")){e.hasExclusion=!0;return}if(ob.test(t)||t.includes("...")){e.hasGlob=!0;return}e.filters.push(t)},ab=e=>{if(typeof e!="string"||e.trim()===""||ib.test(e)||/['"]/u.test(e))return null;const t=e.trim().split(/\s+/u);if(t[0]!=="pnpm"&&t[0]!=="pnpm.cmd")return null;const n={complex:!1,filters:[],hasExclusion:!1,hasGlob:!1,parallel:!1,recursive:!1,target:""};let s=1;for(;s<t.length;){const r=t[s];if(r==="--filter"||r==="-F"){const i=t[s+1];if(i===void 0)return n.complex=!0,n;Br(n,i),s+=2;continue}if(r.startsWith("--filter=")){Br(n,r.slice(9)),s+=1;continue}if(r.startsWith("-F=")){Br(n,r.slice(3)),s+=1;continue}if(r==="--parallel"){n.parallel=!0,s+=1;continue}if(r==="-r"||r==="--recursive"){n.recursive=!0,s+=1;continue}if(r==="--workspace-root"||r==="-w")return n.complex=!0,n;if(r==="run"||r==="exec"){if(r==="exec")return n.complex=!0,n;s+=1;continue}return r.startsWith("-")?(n.complex=!0,n):(n.target=r,s+=1,s<t.length&&(n.complex=!0),n)}return n.complex=!0,n},cb=(e,t)=>{const n=[],s=[];for(const r of e){const i=t.pkgToProject.get(r);if(i!==void 0){n.push(i);continue}if(t.knownProjects.has(r)){n.push(r);continue}s.push(r)}return{mapped:n,unmapped:s}},lb=(e,t)=>{const n=["vis","run",e.target];if(t.length>0){const s=[...t].sort((r,i)=>r.localeCompare(i)).join(",");n.push(`--projects=${s}`)}return n.join(" ")},db=new Set(["dev","dev:server","dev:watch","serve","start:dev","storybook","watch"]),ub=(e,t,n,s,r)=>{const i={rewrittenTargets:new Set,unmappedHits:[]},o=g(e,"package.json");if(!x(o))return i;let a;try{a=JSON.parse(G(o))}catch{return i}if(!a.scripts)return i;const c=new Map;for(const[l,d]of Object.entries(a.scripts)){const u=ab(d);if(!u||u.target===""||u.complex)continue;if(u.hasExclusion||u.hasGlob){r.warnings.push(`pnpm filter in scripts.${l} uses ${u.hasExclusion?"an exclusion (!)":"a glob/dependency selector"} — left untouched. Translate by hand to \`vis run ${u.target} --projects=...\` once you decide which projects should be selected.`);continue}if(u.filters.length===0&&!u.recursive)continue;const p=cb(u.filters,t);if(p.unmapped.length>0){i.unmappedHits.push({filters:p.unmapped,script:l});continue}const f=lb(u,p.mapped);f!==d&&(c.set(l,f),i.rewrittenTargets.add(u.target))}if(c.size===0)return i;if(n.dryRun){for(const[l,d]of c){const u=a.scripts[l];s.info(`Would rewrite scripts.${l}: \`${u??""}\` → \`${d}\``)}return i}return At(o,l=>{if(!l.scripts)return;const d={...l.scripts};let u=!1;for(const[p,f]of c)d[p]!==void 0&&d[p]!==f&&(d[p]=f,u=!0);if(u)return l.scripts=d,l},r,{useEditorconfig:n.useEditorconfig}),s.info(`Rewrote ${String(c.size)} pnpm-filter script(s) in package.json to use \`vis run\`.`),i},pb=(e,t,n)=>{let s=e.targetDefaults??{},r=!1;for(const i of t){if(!db.has(i))continue;const a={...s[i]??{}};let c=!1;a.persistent!==!0&&(a.persistent=!0,c=!0),a.cache!==!1&&(a.cache=!1,c=!0),c&&(s={...s,[i]:a},r=!0,n.manualSteps.push(`tasks.${i} set to { persistent: true, cache: false } — long-running task auto-detected from rewritten pnpm filter scripts. Adjust if your ${i} is actually short-lived.`))}r&&(e.targetDefaults=s)},fb=e=>{if(e.executor!=="nx:run-script")return!1;const t=Object.keys(e.options??{});return t.length===0||t.length===1&&t[0]==="script"},hb=(e,t,n,s)=>{let r=0,i=0,o=0;const a=[];for(const c of e){const l=po(c);if(!l?.targets||Object.keys(l.targets).length===0)continue;const d=l.name??"<unnamed>",u=[],p=[],f=[];for(const[v,$]of Object.entries(l.targets))$.syncGenerators&&$.syncGenerators.length>0&&f.push({sync:[...$.syncGenerators],target:v}),fb($)?p.push(v):u.push(v);const h=u.length===0&&p.length>0,m=p.length>0;h?(t.dryRun?(n.info(`Would remove targets block from ${c} (all entries are nx:run-script shims).`),r+=1):(At(c,v=>{if(v.targets)return delete v.targets,v},s,{useEditorconfig:t.useEditorconfig}),r+=1),f.length>0&&a.push({file:c,name:d,nonShimTargets:[],syncGenerators:f})):m?(t.dryRun?n.info(`Would strip ${String(p.length)} nx:run-script shim entr(y/ies) from ${c} (non-shim entries kept: ${u.join(", ")}).`):At(c,v=>{if(v.targets){for(const $ of p)Reflect.deleteProperty(v.targets,$);return v}},s,{useEditorconfig:t.useEditorconfig}),i+=1,o+=p.length,a.push({file:c,name:d,nonShimTargets:u,syncGenerators:f})):a.push({file:c,name:d,nonShimTargets:u,syncGenerators:f})}return r>0&&n.info(`Removed targets block from ${String(r)} project.json file(s) (entries were nx:run-script shims).`),o>0&&!t.dryRun&&n.info(`Stripped ${String(o)} nx:run-script shim entr(y/ies) across ${String(i)} project.json file(s) (non-shim entries remain for manual review).`),{droppedTargetBlocks:r,partialTargetBlocks:i,punchList:a,strippedShimEntries:o}},mb=(e,t,n,s)=>{const r=g(e,"pnpm-workspace.yaml");if(!x(r))return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1};let i;try{i=Tt(r)}catch{return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1}}if(!i||typeof i!="object")return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1};let o=0;const a=f=>f==="nx"||f.startsWith("@nx/"),c=(f,h,m)=>{if(!f||typeof f!="object")return;const v=Object.keys(f).length,$=Object.fromEntries(Object.entries(f).filter(([S])=>!a(S))),b=v-Object.keys($).length;b>0&&(o+=b,h[m]=$)};c(i.catalog,i,"catalog");const l=i.catalogs;if(l&&typeof l=="object")for(const[f,h]of Object.entries(l))c(h,l,f);let d=!1;const u=i.onlyBuiltDependencies;if(Array.isArray(u)){const f=u.filter(h=>h!=="nx");f.length!==u.length&&(i.onlyBuiltDependencies=f,d=!0)}return(o>0||d)&&(t.dryRun?(o>0&&n.info(`Would remove ${String(o)} nx-related catalog entr(y/ies) from pnpm-workspace.yaml.`),d&&n.info("Would remove `nx` from pnpm-workspace.yaml#onlyBuiltDependencies.")):(ie(r,s),xl(r,i),o>0&&n.info(`Removed ${String(o)} nx-related catalog entr(y/ies) from pnpm-workspace.yaml.`),d&&n.info("Removed `nx` from pnpm-workspace.yaml#onlyBuiltDependencies."))),{catalogEntriesRemoved:o,onlyBuiltRemoved:d}},gb=(e,t,n,s,r,i,o)=>{const a=g(nt(e),"package.json");if(!x(a))return{reason:"no sibling package.json"};const c=`pre${n}`,l=`echo "TODO(vis): replace with logic equivalent to nx syncGenerators: ${s.join(", ")}" && exit 1`;if(r.dryRun){let p;try{p=JSON.parse(G(a)).scripts}catch{return{reason:"package.json unreadable"}}return p?.[c]?{reason:`\`${c}\` script already exists in ${ve(t,a)}`}:(i.info(`Would add \`${c}\` script to ${ve(t,a)} (TODO for nx syncGenerators: ${s.join(", ")}).`),{pkgPath:ve(t,a),preScript:c})}let d;return At(a,p=>{if(p.scripts?.[c]){d=`\`${c}\` script already exists in ${ve(t,a)}`;return}return p.scripts={...p.scripts,[c]:l},p},o,{useEditorconfig:r.useEditorconfig})?(i.info(`Added \`${c}\` script (TODO) to ${ve(t,a)} — wire up replacement for: ${s.join(", ")}.`),{pkgPath:ve(t,a),preScript:c}):{reason:d??"package.json unwritable"}},yb=/^nx\s+(?:run-many|run|affected|reset|repair)\b|^nx\s+exec\b/u,vb=new Set(["affected","exec","repair","reset","run","run-many"]),bb=(e,t)=>{const n=e.trim();if(/[;&|"']/u.test(n))return;const s=/^nx\s+run-many\s+(?:-t|--target=?)\s*([\w:-]+)\s*$/u.exec(n);if(s)return`vis run ${s[1]}`;const r=/^nx\s+affected\s+(?:-t|--target=?)\s*([\w:-]+)\s*$/u.exec(n);if(r)return`vis run ${r[1]} --affected`;const i=/^nx\s+run\s+([\w@/-]+):([\w:-]+)\s*$/u.exec(n);if(i?.[1]&&i[2]&&t.has(i[1]))return`vis run ${i[2]} --projects=${i[1]}`;const o=/^nx\s+([\w:-]+)\s*$/u.exec(n);if(o?.[1]&&!vb.has(o[1]))return`vis run ${o[1]}`},wb=(e,t,n,s,r)=>{const i={deletedFiles:[],rewrittenScripts:[],skippedScripts:[],strippedDevDeps:[]},o=g(e,".github","ignore-files-for-nx-affected.yml");if(x(o))if(n.dryRun)s.info(`Would delete ${ve(e,o)}.`),i.deletedFiles.push(ve(e,o));else{ie(o,r);try{pt(o),s.info(`Removed ${ve(e,o)} (backup at \`${ve(e,o)}.bak\`).`),i.deletedFiles.push(ve(e,o))}catch{}}const a=g(e,"package.json");if(!x(a))return i;if(At(a,c=>{let l=!1;if(c.devDependencies)for(const d of Object.keys(c.devDependencies))(d==="nx"||d.startsWith("@nx/")||d.startsWith("@nrwl/"))&&(n.dryRun||Reflect.deleteProperty(c.devDependencies,d),i.strippedDevDeps.push(d),l=!0);if(c.scripts)for(const[d,u]of Object.entries(c.scripts)){if(typeof u!="string"||!(yb.test(u)||u.startsWith("nx ")))continue;const f=bb(u,t);if(f===void 0){i.skippedScripts.push(d);continue}n.dryRun||(c.scripts[d]=f),i.rewrittenScripts.push({from:u,name:d,to:f}),l=!0}return l?c:void 0},n.dryRun?void 0:r,{useEditorconfig:n.useEditorconfig}),i.strippedDevDeps.length>0){const c=n.dryRun?"Would strip":"Stripped";s.info(`${c} ${String(i.strippedDevDeps.length)} nx-related devDependenc(y/ies) from package.json: ${i.strippedDevDeps.join(", ")}.`)}for(const c of i.rewrittenScripts){const l=n.dryRun?"Would rewrite":"Rewrote";s.info(`${l} \`scripts.${c.name}\`: \`${c.from}\` -> \`${c.to}\``)}return i.skippedScripts.length>0&&r.manualSteps.push(`--aggressive could not rewrite these package.json scripts (they have shell complexity or unknown flags): ${i.skippedScripts.join(", ")}. Rewrite them manually to use \`vis run\`.`),i},kb=e=>{const t={eslintHits:[],ignoreFile:!1,nxJson:!1,pkgDevDeps:[],pkgScripts:[],workflowHits:[]};x(g(e,"nx.json"))&&(t.nxJson=!0),x(g(e,".github/ignore-files-for-nx-affected.yml"))&&(t.ignoreFile=!0);const n=g(e,"package.json");if(x(n))try{const r=JSON.parse(G(n));if(r.devDependencies)for(const i of Object.keys(r.devDependencies))(i==="nx"||i.startsWith("@nx/")||i.startsWith("@nrwl/"))&&t.pkgDevDeps.push(i);if(r.scripts)for(const[i,o]of Object.entries(r.scripts))typeof o=="string"&&(/\bnx\s+(?:run-many|run|affected|exec|reset|repair)\b/u.test(o)||o.startsWith("nx "))&&t.pkgScripts.push(i)}catch{}const s=g(e,".github/workflows");if(x(s))try{for(const r of Te(s)){if(!r.endsWith(".yml")&&!r.endsWith(".yaml"))continue;const i=g(s,r),o=G(i);/nrwl\/nx-set-shas/u.test(o)&&t.workflowHits.push({file:`.github/workflows/${r}`,reason:"uses nrwl/nx-set-shas action"}),/\bNX_BRANCH\b|\bNX_RUN_GROUP\b/u.test(o)&&t.workflowHits.push({file:`.github/workflows/${r}`,reason:"sets NX_BRANCH / NX_RUN_GROUP env"}),(/--files=\$\{\{[^}]*tj-actions/u.test(o)||/tj-actions\/changed-files/u.test(o))&&t.workflowHits.push({file:`.github/workflows/${r}`,reason:"uses tj-actions/changed-files (no longer needed; vis does its own affected diff)"})}}catch{}for(const r of["eslint.config.mjs","eslint.config.js","eslint.config.cjs","eslint.config.ts",".eslintrc.json",".eslintrc.js"]){const i=g(e,r);if(!x(i))continue;const o=G(i);/@nx\/eslint-plugin|@nx\/enforce-module-boundaries|@nx\/dependency-checks|@nx\/nx-plugin-checks/u.test(o)&&t.eslintHits.push(r)}return t},Sb=(e,t,n)=>{const s=[];if(e.nxJson&&!n.backedUpNxJson&&s.push(`Remove ${g(t,"nx.json")} once you're satisfied with vis.config.ts.`),e.ignoreFile&&s.push("Delete .github/ignore-files-for-nx-affected.yml — vis uses git-based affected diff and has no equivalent."),e.pkgDevDeps.length>0&&s.push(`Remove these nx devDependencies from package.json: ${e.pkgDevDeps.join(", ")}.`),e.pkgScripts.length>0&&s.push(`Rewrite these package.json scripts to use \`vis run\`: ${e.pkgScripts.join(", ")}.`),e.workflowHits.length>0){const r=new Map;for(const i of e.workflowHits){const o=r.get(i.file)??new Set;o.add(i.reason),r.set(i.file,o)}for(const[i,o]of r)s.push(`Update ${i}: ${[...o].join("; ")}.`)}return e.eslintHits.length>0&&s.push(`Remove @nx/eslint-plugin imports + rules (enforce-module-boundaries, dependency-checks, nx-plugin-checks) from: ${e.eslintHits.join(", ")}. There is no vis equivalent yet.`),s.map((r,i)=>`${String(i+1)}. ${r}`)},xb=(e,t)=>{if(e.length!==0){t.info(""),t.info("── Post-migrate cleanup ──");for(const n of e)t.info(n)}},Wa=(e,t,n,s)=>{t.aggressive&&(t={...t,force:!0,rewriteSyncGenerators:!0});const r=Cd(e,"nx.json");if(!r){n.warn("No nx.json found in workspace root — nothing to migrate."),s.warnings.push("No nx.json at workspace root.");return}r.targetDefaults&&(r.targetDefaults=tb(r.targetDefaults,s,n));const i=Zv(e),o=rb(i),a=ub(e,o,t,n,s);pb(r,a.rewrittenTargets,s);for(const f of a.unmappedHits)s.warnings.push(`scripts.${f.script}: pnpm filter(s) ${f.filters.map(h=>`\`${h}\``).join(", ")} don't match any known project.json#name or sibling package.json#name. Left untouched — fix the filter or add the missing project.json before re-running.`);const c=nb(r,e,t.useEditorconfig);if(!uo(e,c,t,n,s))return;sb(i,t,n,s);const{punchList:l}=hb(i,t,n,s);for(const f of l){f.nonShimTargets.length>0&&s.manualSteps.push(`Review targets in ${ve(e,f.file)} (project: ${f.name}) — non-shim targets need manual review: ${f.nonShimTargets.join(", ")}.`);for(const h of f.syncGenerators){if(t.rewriteSyncGenerators){const m=gb(f.file,e,h.target,h.sync,t,n,s);if("preScript"in m){s.manualSteps.push(`${m.pkgPath} now has a \`${m.preScript}\` script that fails with a TODO. Replace it with the real equivalent of nx syncGenerators: ${h.sync.join(", ")}.`);continue}s.warnings.push(`syncGenerators on \`${f.name}#${h.target}\` (${ve(e,f.file)}) not auto-rewritten — ${m.reason}. Move ${h.sync.join(", ")} into a \`pre${h.target}\` script in package.json manually.`);continue}s.warnings.push(`syncGenerators on \`${f.name}#${h.target}\` (${ve(e,f.file)}) has no vis equivalent. Move ${h.sync.join(", ")} into a \`pre${h.target}\` script in package.json (or re-run with --rewrite-sync-generators to insert a TODO automatically).`)}}mb(e,t,n,s),t.aggressive&&wb(e,o.knownProjects,t,n,s),s.manualSteps.push("vis adds two task primitives nx doesn't expose declaratively: `when: { os, env, branch, ci, not.* }` for conditional execution (replaces ad-hoc `configurations`) and `always: true` for finally/teardown tasks that run even when upstream fails. See docs/guides/conditional-and-finally-tasks.mdx.");const d=r.affected?.defaultBase??r.defaultBase;typeof d=="string"&&d.length>0&&d!=="main"&&n.info(`Translated nx's default base branch (${d}) into vis.config.ts#defaultBase.`),Yv(e,{dryRun:t.dryRun},n);const u=kb(e),p=Sb(u,e,{});if(xb(p,n),t.force&&!t.dryRun&&u.nxJson){const f=g(e,"nx.json");ie(f,s);try{pt(f),n.info(`Removed ${f} (backup at ${f}.bak).`)}catch{}}},Ad=[".secretlintrc",".secretlintrc.json",".secretlintrc.js",".secretlintrc.mjs",".secretlintrc.cjs",".secretlintrc.yml",".secretlintrc.yaml"],Id=[".secretlintignore"],Bd=e=>Ad.find(t=>x(g(e,t))),Pd=e=>Id.find(t=>x(g(e,t))),$b=(e,t,n)=>{if(t.endsWith(".js")||t.endsWith(".mjs")||t.endsWith(".cjs"))return Q(n,`${t} is a JS config — cannot auto-extract rule IDs. Review manually to confirm coverage.`),[];if(t.endsWith(".yml")||t.endsWith(".yaml"))return Q(n,`${t} is YAML — cannot auto-extract rule IDs without a YAML parser. Review manually.`),[];const s=pe(g(e,t));if(!s)return[];const r=new Set,i=o=>{if(o)for(const a of o)a.id&&r.add(a.id),a.rules&&i(a.rules)};return i(s.rules),[...r]},Eb=(e,t,n,s)=>{for(const r of[...Ad,...Id]){const i=g(e,r);if(x(i)){if(t){n.info(`[dry-run] Would remove ${i}`);continue}ie(i,s),pt(i),he(s,"secretlint","removedConfigCount"),n.info(`Removed ${i}`)}}},Cb=(e,t,n,s)=>{const r=g(e,".secretlintignore");if(!x(r))return;const o=G(r).split(/\r?\n/).map(a=>a.trim()).filter(a=>a&&!a.startsWith("#"));o.length!==0&&(ne(s,`.secretlintignore contained ${String(o.length)} path pattern(s). vis secrets uses .gitignore + --exclude / --exclude-from; add these globs to your .gitignore or pass --exclude: ${o.slice(0,5).join(", ")}${o.length>5?", ...":""}`),t&&n.info(`[dry-run] Would consume ${r} (${String(o.length)} patterns) and surface as manual step.`))},Rb=(e,t,n,s,r)=>{const i=g(e,"package.json");if(!x(i))return;const o=pe(i);if(!o)return;let a=!1;if(o.scripts){for(const[l,d]of Object.entries(o.scripts))if(typeof d=="string"&&/\bsecretlint\b/.test(d)){const u=d.replaceAll(/\bsecretlint\b[^\n&|;]*/g,"vis secrets").trim();u!==d&&(o.scripts[l]=u,a=!0,he(s,"secretlint","rewrittenScriptCount"),n.info(` scripts.${l}: "${d}" -> "${u}"`))}}if(o.devDependencies){const l=o.devDependencies,d=[];for(const u of Object.keys(l))(u==="secretlint"||u.startsWith("@secretlint/"))&&(delete l[u],d.push(u),a=!0,he(s,"secretlint","removedPackageCount"));d.length>0&&n.info(` removed ${String(d.length)} secretlint devDependencies: ${d.join(", ")}`)}if(!a)return;if(t){n.info(`[dry-run] Would update ${i}`);return}const c=Ke(i,G(i),{defaultIndent:" ",useEditorconfig:r});ie(i,s),me(i,`${JSON.stringify(o,null,c)}
|
|
82
|
+
`)},jb=(e,t,n,s)=>{const r=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"];for(const i of r){const o=g(e,i);if(!x(o))continue;const a=G(o);if(!/\bsecretlint\b/.test(a))continue;const c=a.replaceAll(/\bsecretlint\b[^\n&|;]*/g,"vis secrets --staged");if(t){n.info(`[dry-run] Would rewrite ${o}`);continue}ie(o,s),me(o,c),s.gitHooksConfigured=!0,n.info(`Rewrote secretlint invocation in ${i}`)}},Ha=(e,t,n,s)=>{const r=Bd(e),i=Pd(e);if(!!!(r??i))return t.silent||n.info("No secretlint artifacts found — nothing to migrate."),!1;if(r){const a=$b(e,r,s);n.info(`Found ${r}`),a.length>0?(n.info(` active rules/presets: ${a.join(", ")}`),ne(s,`secretlint used these rules: ${a.join(", ")}. vis secrets ships the gitleaks ruleset (177 rules covering AWS/GCP/Azure/GitHub/Slack/Stripe and more). Verify parity before removing secretlint.`)):ne(s,`Rule IDs could not be auto-extracted from ${r}. Verify that the bundled gitleaks ruleset covers your secretlint rule set.`)}return Cb(e,t.dryRun,n,s),Rb(e,t.dryRun,n,s,t.useEditorconfig),jb(e,t.dryRun,n,s),Eb(e,t.dryRun,n,s),!0},Pr="sherif",ur=/\bsherif\b/,ki={"empty-dependencies":"empty-deps","multiple-dependency-versions":"workspace-versions","non-existant-packages":"dead-workspace-patterns","packages-without-package-json":"missing-package-json","root-package-dependencies":"root-deps","root-package-manager-field":"root-package-manager","root-package-private-field":"root-private","types-in-dependencies":"types-in-deps","unordered-dependencies":void 0,"unsync-similar-dependencies":"similar-deps"},Tb=Object.values(ki).filter(e=>e!==void 0),Nd=e=>{const t=g(e,"package.json");return x(t)&&pe(t)?.sherif?"package.json":void 0},Dd=e=>{const t=g(e,"package.json");if(!x(t))return!1;const n=pe(t);if(!n)return!1;if(n.devDependencies?.sherif||n.dependencies?.sherif)return!0;if(n.scripts){for(const s of Object.values(n.scripts))if(typeof s=="string"&&ur.test(s))return!0}return!1},Ob=e=>pe(g(e,"package.json"))?.sherif,Md=(e,t)=>{const n={unmapped:[],visDisabled:[]};if(!Array.isArray(e["ignore-rules"]))return n;for(const s of e["ignore-rules"]){if(typeof s!="string"||s.length===0)continue;const r=ki[s];if(r===void 0){s==="unordered-dependencies"?Q(t,"sherif rule `unordered-dependencies` has no `vis lint` equivalent — vis covers ordering via `vis sort-package-json` (separate command). No migration needed; skip running it if you don't want it."):Object.hasOwn(ki,s)?n.unmapped.push(s):Q(t,`sherif rule \`${s}\` is unknown to vis migrate — skipped.`);continue}n.visDisabled.push(r)}return n},Ld=e=>{const t=Tb.filter(n=>!e.includes(n));return t.length===0?"vis lint":`vis lint ${t.map(n=>`--${n}`).join(" ")}`},Ab=(e,t)=>{const n=g(e,"package.json"),s={configRemoved:!1,dependencyRemoved:!1,removedScripts:[],scriptCount:0};if(!x(n))return s;const r=G(n),i=JSON.parse(r);let o=!1;i.sherif&&(delete i.sherif,o=!0,s.configRemoved=!0);for(const c of["dependencies","devDependencies"]){const l=i[c];l?.sherif&&(delete l.sherif,o=!0,s.dependencyRemoved=!0)}const a=i.scripts;if(a){const c={};for(const[l,d]of Object.entries(a))typeof d=="string"&&ur.test(d)?(s.scriptCount+=1,s.removedScripts.push({name:l,value:d}),o=!0):c[l]=d;s.scriptCount>0&&(Object.keys(c).length===0?delete i.scripts:i.scripts=c)}if(o){const c=os(n,r,{useEditorconfig:t});ie(n),ae(n,`${JSON.stringify(i,void 0,c)}
|
|
83
|
+
`,"utf8")}return s},Ib=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],Bb=[".github/workflows",".gitlab-ci.yml",".circleci/config.yml",".woodpecker.yml",".drone.yml"],_d=(e,t)=>{const n=[];for(const s of Ib){const r=g(e,s);x(r)&&ur.test(G(r))&&(n.push(s),ne(t,`Update ${s} — replace \`sherif\` invocation with \`vis lint\`.`))}return n},Fd=(e,t)=>{const n=[],s=r=>{const i=g(e,r);x(i)&&ur.test(G(i))&&(n.push(r),ne(t,`Update ${r} — replace \`sherif\` invocation with \`vis lint\`.`))};for(const r of Bb){const i=g(e,r);if(x(i)){if(r===".github/workflows"){try{for(const o of Te(i))(o.endsWith(".yml")||o.endsWith(".yaml"))&&s(`.github/workflows/${o}`)}catch{}continue}s(r)}}return n},Pb=(e,t,n,s,r)=>{const i=Md(t,r);if(i.visDisabled.length>0){const p=Ld(i.visDisabled);ne(r,`sherif's \`ignore-rules\` was set to [${i.visDisabled.map(f=>JSON.stringify(f)).join(", ")}] (vis names). vis has no global rule-disable; replace any \`sherif\` script with the explicit positive list: \`${p}\`.`)}i.unmapped.length>0&&Q(r,`sherif rule(s) [${i.unmapped.map(p=>JSON.stringify(p)).join(", ")}] could not be mapped — please re-evaluate manually.`),Array.isArray(t["ignore-dependencies"])&&t["ignore-dependencies"].length>0&&ne(r,`sherif's \`ignore-dependencies\` was set to [${t["ignore-dependencies"].map(p=>JSON.stringify(p)).join(", ")}]. Mirror this in vis.config.ts under \`policy.workspaceVersions.ignore\`, \`policy.customTypes.ignore\`, \`policy.typesInDeps.ignore\` (and \`policy.redefineRoot.ignore\`) for the lints where it applies.`),Array.isArray(t["ignore-packages"])&&t["ignore-packages"].length>0&&(Q(r,`sherif's \`ignore-packages\` was set to [${t["ignore-packages"].map(p=>JSON.stringify(p)).join(", ")}] — vis has no global package-skip yet (only per-rule scoping via policy.bannedDeps.{packages,paths}). Tracked alongside the dep filter work.`),ne(r,"Re-evaluate sherif `ignore-packages` — vis has no equivalent global filter yet.")),Array.isArray(t["ignore-paths"])&&t["ignore-paths"].length>0&&(Q(r,`sherif's \`ignore-paths\` was set to [${t["ignore-paths"].map(p=>JSON.stringify(p)).join(", ")}] — vis has no global path-skip yet.`),ne(r,"Re-evaluate sherif `ignore-paths` — vis has no equivalent global filter yet."));const o=_d(e,r);o.length>0&&!n.silent&&s.warn(`Found sherif reference in ${String(o.length)} hook file(s) — see manualSteps for details.`);const a=Fd(e,r);a.length>0&&!n.silent&&s.warn(`Found sherif reference in ${String(a.length)} CI file(s) — see manualSteps for details.`);const{configRemoved:c,dependencyRemoved:l,removedScripts:d,scriptCount:u}=Ab(e,n.useEditorconfig);if(c&&!n.silent&&s.info("Removed `sherif` block from package.json"),c&&he(r,Pr,"removedConfigCount"),l&&he(r,Pr,"removedPackageCount"),u>0){he(r,Pr,"rewrittenScriptCount",u);for(const{name:p,value:f}of d)ne(r,`Recreate script \`${p}\` (removed; was \`${f}\`). Replace \`sherif\` with \`vis lint\` (sherif's lint surface ≈ \`vis lint\`).`);n.silent||s.info(`Removed ${String(u)} script(s) referencing \`sherif\`. Replace with \`vis lint\`.`)}},Ua=(e,t,n,s)=>{const r=Nd(e),i=Dd(e);if(!r&&!i)return t.silent||n.info("No sherif configuration or installation found — nothing to migrate."),!1;const o=Ob(e)??{};if(t.dryRun){const a=Md(o,s);if(_d(e,s),Fd(e,s),!t.silent&&(r&&n.info("[dry-run] Would remove `sherif` block from package.json"),i&&n.info("[dry-run] Would strip `sherif` from devDependencies/scripts"),a.visDisabled.length>0)){const c=Ld(a.visDisabled);n.info(`[dry-run] Suggested replacement script: ${c}`)}return!0}return Pb(e,o,t,n,s),!0},Nb=["dependencies","devDependencies","peerDependencies","optionalDependencies","overrides","resolutions","pnpm.overrides"],Db=(e,t)=>{const n=t.split(".");let s=e;for(const r of n){if(typeof s!="object"||s===null)return;s=s[r]}return typeof s=="object"&&s!==null?s:void 0},fo=e=>{const t=g(e,"package.json");if(!x(t))return["."];const s=le(t).workspaces;let r=[];if(s){const i=Array.isArray(s)?s:s.packages;i&&(r=Jo(e,i))}if(r.length===0){const i=_f(e);i&&(r=Jo(e,i))}return[".",...r]},pr=e=>{if(x(e))try{return le(e)}catch{return}},Mb=e=>{const t=new Set,n=fo(e);for(const s of n){const r=pr(g(e,s,"package.json"));r&&typeof r.name=="string"&&t.add(r.name)}return t},aR=(e,t={})=>{const n=t.includeInternal??!0,s=t.depTypes??Nb,r=fo(e),i=Mb(e),o=[],c=s.includes("pnpm.overrides")?Lf(e):void 0,l=c?g(e,"pnpm-workspace.yaml"):void 0;for(const d of r){const u=g(e,d,"package.json"),p=pr(u);if(!p)continue;const f=typeof p.name=="string"?p.name:void 0,h=d==="."?".":rs(e,g(e,d));for(const m of s){const v=m.includes(".")?Db(p,m):p[m];if(!(!v||typeof v!="object"))for(const[$,b]of Object.entries(v)){if(typeof b!="string")continue;const S=i.has($);!n&&S||o.push({depName:$,depType:m,isInternal:S,packageDir:h,packageJsonPath:u,packageName:f,specifier:b})}}}if(c&&l)for(const[d,u]of Object.entries(c)){const p=i.has(d);!n&&p||o.push({depName:d,depType:"pnpm.overrides",isInternal:p,packageDir:".",packageJsonPath:l,packageName:void 0,specifier:u})}return o},ho=new Set(["devEngines.packageManager","devEngines.runtime","engines","packageManager","volta"]),Lb=["engines","volta"],_b=new Set(["extends"]),Fb=/^([@\w./-]+?)@([^+]+)(\+.+)?$/,Vb=/^([@\w./-]+)~(.+)$/,fr=e=>{const t=Fb.exec(e.trim());if(!(!t?.[1]||!t[2]))return{hash:t[3]??"",name:t[1],version:t[2]}},Vd=e=>{const t=Vb.exec(e.trim());if(!(!t?.[1]||!t[2]))return{name:t[1],version:t[2]}},Xn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Wd=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.name=="string",Wb=new Set(["name@version","name~version","string","versionsByName"]),cR=e=>{const t=[];if(!e)return t;const n=new Set;for(const s of e){const r=typeof s?.name=="string"&&s.name.length>0?s.name:"<unnamed>";if(typeof s?.name!="string"||s.name.length===0){t.push("extraTypes entry missing 'name'");continue}ho.has(s.name)&&t.push(`extraTypes[${r}]: name collides with a built-in customType`),n.has(s.name)&&t.push(`extraTypes[${r}]: duplicate name`),n.add(s.name),(typeof s.path!="string"||s.path.length===0)&&t.push(`extraTypes[${r}]: missing 'path'`),Wb.has(s.strategy)||t.push(`extraTypes[${r}]: invalid strategy "${String(s.strategy)}" (expected name@version | name~version | string | versionsByName)`),s.strategy==="string"&&(typeof s.depName!="string"||s.depName.length===0)&&t.push(`extraTypes[${r}]: strategy 'string' requires 'depName'`)}return t},Hb=(e,t)=>{if(t.length===0)return;let n=e;for(const s of t.split(".")){if(typeof n!="object"||n===null||Array.isArray(n))return;n=n[s]}return n},Ub=(e,t,n,s,r)=>{const i=Hb(t,e.path);if(i===void 0)return[];const o=Object.freeze({depName:e.depName,path:e.path,strategy:e.strategy});if(e.strategy==="versionsByName"){if(!Xn(i))return[];const a=[];for(const[c,l]of Object.entries(i))typeof l=="string"&&a.push({customType:e.name,depName:c,extra:o,packageDir:n,packageJsonPath:s,packageName:r,rawValue:l,specifier:l});return a}if(e.strategy==="name@version"){if(typeof i!="string")return[];const a=fr(i);return a?[{customType:e.name,depName:a.name,extra:o,packageDir:n,packageJsonPath:s,packageName:r,rawValue:i,specifier:a.version}]:[]}if(e.strategy==="name~version"){if(typeof i!="string")return[];const a=Vd(i);return a?[{customType:e.name,depName:a.name,extra:o,packageDir:n,packageJsonPath:s,packageName:r,rawValue:i,specifier:a.version}]:[]}return typeof i!="string"||typeof e.depName!="string"||e.depName.length===0?[]:[{customType:e.name,depName:e.depName,extra:o,packageDir:n,packageJsonPath:s,packageName:r,rawValue:i,specifier:i}]},lR=(e,t)=>{const n=fo(e),s=[];for(const r of n){const i=g(e,r,"package.json"),o=pr(i);if(!o)continue;const a=typeof o.name=="string"?o.name:void 0,c=r==="."?".":rs(e,g(e,r));for(const d of Lb){const u=o[d];if(Xn(u))for(const[p,f]of Object.entries(u))typeof f=="string"&&(d==="volta"&&_b.has(p)||s.push({customType:d,depName:p,packageDir:c,packageJsonPath:i,packageName:a,rawValue:f,specifier:f}))}if(typeof o.packageManager=="string"){const d=fr(o.packageManager);d&&s.push({customType:"packageManager",depName:d.name,packageDir:c,packageJsonPath:i,packageName:a,rawValue:o.packageManager,specifier:d.version})}const{devEngines:l}=o;if(typeof l=="object"&&l!==null&&!Array.isArray(l))for(const d of["runtime","packageManager"]){const u=l[d];if(u===void 0)continue;const p=Array.isArray(u)?u:[u];for(const f of p)!Wd(f)||typeof f.version!="string"||s.push({customType:d==="runtime"?"devEngines.runtime":"devEngines.packageManager",depName:f.name,packageDir:c,packageJsonPath:i,packageName:a,rawValue:f.version,specifier:f.version})}if(t){for(const d of t)if(!(typeof d?.name!="string"||d.name.length===0)&&!ho.has(d.name))for(const u of Ub(d,o,c,i,a))s.push(u)}}return s},Gb=(e,t)=>`${e} ${t}`,zb=(e,t)=>{const n=[...e].sort((r,i)=>(r.packageName??r.packageDir).localeCompare(i.packageName??i.packageDir));let s;for(const r of n){const i=oi(r.specifier);if(!i)continue;if(!s){s=r;continue}const o=oi(s.specifier);if(!o){s=r;continue}const a=qo(o,i),c=qo(i,o);(t==="highest"&&a||t==="lowest"&&c)&&(s=r)}return s},dR=(e,t={})=>{const n=new Set(t.ignoreDeps),s=t.resolve??"highest",r=[],i=e.filter(a=>t.dep!==void 0&&a.depName!==t.dep?!1:!n.has(a.depName)),o=new Map;for(const a of i){const c=Gb(a.customType,a.depName),l=o.get(c);l?l.push(a):o.set(c,[a])}for(const[,a]of o){if(a.length<2||new Set(a.map(d=>d.specifier)).size<=1)continue;const l=zb(a,s);if(l)for(const d of a)d.specifier!==l.specifier&&oi(d.specifier)!==void 0&&r.push({canonicalSource:l.packageName??l.packageDir,customType:d.customType,depName:d.depName,...d.extra?{extra:d.extra}:{},fix:l.specifier,packageDir:d.packageDir,packageJsonPath:d.packageJsonPath,packageName:d.packageName,specifier:d.specifier})}return r},Jb=(e,t)=>{const n=t.extra;if(!n)return!1;const s=n.path.split(".");if(s.length===0||s.some(o=>o.length===0))return!1;let r=e;for(let o=0;o<s.length-1;o+=1){const a=r[s[o]];if(typeof a!="object"||a===null||Array.isArray(a))return!1;r=a}const i=s.at(-1);if(n.strategy==="versionsByName"){const o=r[i];return Xn(o)?(o[t.depName]=t.fix,!0):!1}if(n.strategy==="name@version"){const o=r[i];if(typeof o!="string")return!1;const a=fr(o);return a?(r[i]=`${a.name}@${t.fix}`,!0):!1}if(n.strategy==="name~version"){const o=r[i];if(typeof o!="string")return!1;const a=Vd(o);return a?(r[i]=`${a.name}~${t.fix}`,!0):!1}return typeof r[i]!="string"?!1:(r[i]=t.fix,!0)},uR=(e,t={})=>{const{useEditorconfig:n}=t,s=new Map;for(const i of e){const o=s.get(i.packageJsonPath);o?o.push(i):s.set(i.packageJsonPath,[i])}const r=[];for(const[i,o]of s){const a=pr(i);if(!a)continue;let c=!1;for(const l of o){if(l.extra){Jb(a,l)&&(c=!0);continue}if(l.customType==="engines"||l.customType==="volta"){const h=a[l.customType];Xn(h)&&(h[l.depName]=l.fix,c=!0);continue}if(l.customType==="packageManager"){const h=a.packageManager;if(typeof h=="string"){const m=fr(h);m&&(a.packageManager=`${m.name}@${l.fix}`,c=!0)}continue}const d=l.customType==="devEngines.runtime"?"runtime":"packageManager",{devEngines:u}=a;if(!Xn(u))continue;const p=u[d];if(p===void 0)continue;const f=Array.isArray(p)?p:[p];for(const h of f)Wd(h)&&h.name===l.depName&&(h.version=l.fix,c=!0)}c&&(th(i,a,{indent:Ff(i,{useEditorconfig:n}),overwrite:!0}),r.push(i))}return r},Si="syncpack",Hd=[".syncpackrc",".syncpackrc.json"],mo=[".syncpackrc.yaml",".syncpackrc.yml"],go=[".syncpackrc.cjs",".syncpackrc.js",".syncpackrc.mjs",".syncpackrc.ts","syncpack.config.cjs","syncpack.config.js","syncpack.config.mjs","syncpack.config.ts"],qb=[...Hd,...mo,...go],Kb=/\bextraTypes\s*:/,Yb=/\bpolicy\s*:/,Ga=/(defineConfig\(\{)/,za=/(export\s+default\s+\{)/,yo=/\bsyncpack\b/,Ud=e=>{const t=g(e,"package.json");if(x(t)&&pe(t)?.syncpack)return"package.json";for(const n of qb)if(x(g(e,n)))return n},Xb=e=>{for(const n of go)if(x(g(e,n)))return n;const t=g(e,".syncpackrc");if(x(t)&&!yn(t))try{Tt(t);return}catch{return".syncpackrc"}},Zb=e=>{const t=Dt(e);return t?Kb.test(G(t)):!1},Qb=e=>pe(g(e,"package.json"))?.syncpack,e0=e=>pe(e),Ja=e=>{try{return Tt(e)}catch{return}},t0=(e,t,n)=>{if(t==="package.json")return Qb(e);if(go.includes(t)){Q(n,`${t} is a TS/JS config and cannot be auto-migrated — vis migrate does not load executable config. Convert to .syncpackrc.json and re-run, or translate directly into vis.config.ts. Tracked in https://github.com/visulima/visulima/issues/622.`),ne(n,`Translate ${t} into vis.config.ts (policy.* and security.*) — see https://github.com/visulima/visulima/issues/622`);return}const s=g(e,t);if(mo.includes(t))return Ja(s);if(t===".syncpackrc"&&!yn(s)){const r=Ja(s);if(r)return r;Q(n,".syncpackrc is neither valid JSON nor YAML — please migrate manually.");return}return e0(s)},Gd=(e,t)=>{const n=[];if(!e.customTypes)return n;for(const[s,r]of Object.entries(e.customTypes)){if(!r||typeof r!="object")continue;const{strategy:i}=r,{path:o}=r;if(typeof o!="string"||o.length===0){Q(t,`customType "${s}" has no \`path\` — skipped.`);continue}if(i!=="name@version"&&i!=="string"&&i!=="versionsByName"){Q(t,`customType "${s}" has unsupported strategy ${JSON.stringify(i)} — skipped.`);continue}if(ho.has(s)){Q(t,`customType "${s}" collides with a vis built-in and was dropped — vis already lints this surface.`);continue}const a={name:s,path:o,strategy:i};if(i==="string"){const{depName:c}=r;typeof c=="string"&&c.length>0?a.depName=c:(Q(t,`customType "${s}" uses strategy "string" but has no \`depName\` — vis requires it. Add it manually after migration.`),ne(t,`Set policy.customTypes.extraTypes[name="${s}"].depName before running vis lint`))}n.push(a)}return n},zd=e=>e.isBanned===!0,Jd=(e,t)=>{if(Array.isArray(e.versionGroups)&&e.versionGroups.length>0){const n=e.versionGroups.filter(s=>s&&typeof s=="object"&&!zd(s));n.length>0&&(Q(t,`${String(n.length)} versionGroups rule(s) cannot be migrated — \`pinVersion\`, \`snapTo\`, and \`policy: "sameRange"\` (and other versionGroups DSL surfaces) are tracked in https://github.com/visulima/visulima/issues/622.`),ne(t,'Re-implement versionGroups rules using `pinVersion` / `snapTo` / `policy: "sameRange"` once the vis DSL ships (issue #622).'))}Array.isArray(e.semverGroups)&&e.semverGroups.length>0&&(Q(t,`${String(e.semverGroups.length)} semverGroups rule(s) cannot be migrated — semverGroups DSL is tracked in https://github.com/visulima/visulima/issues/622.`),ne(t,"Re-implement semverGroups rules manually once the vis DSL ships (issue #622)")),Array.isArray(e.dependencyTypes)&&e.dependencyTypes.length>0&&ne(t,"Review syncpack `dependencyTypes` — vis applies policies to dependencies/devDependencies/peerDependencies/optionalDependencies/overrides by default. Narrow via policy.* filters if needed."),Array.isArray(e.specifierTypes)&&e.specifierTypes.length>0&&ne(t,"Review syncpack `specifierTypes` — vis has no direct equivalent today; specifier filtering belongs in versionGroups (issue #622)."),typeof e.filter=="string"&&e.filter.length>0&&ne(t,`Re-implement syncpack \`filter\` regex (${e.filter}) once vis exposes a top-level dep filter.`),(Array.isArray(e.sortAz)&&e.sortAz.length>0||Array.isArray(e.sortFirst)&&e.sortFirst.length>0||Array.isArray(e.sortExports)&&e.sortExports.length>0)&&Q(t,"syncpack sort options (sortAz / sortFirst / sortExports) are superseded by `vis sort-package-json` — no migration needed."),(e.sortPackages!==void 0||e.formatBugs!==void 0||e.formatRepository!==void 0)&&Q(t,"syncpack package.json shape options (sortPackages / formatBugs / formatRepository) are superseded by `vis sort-package-json` — no migration needed."),(e.lintFormatting!==void 0||e.lintSemverRanges!==void 0||e.lintVersions!==void 0)&&Q(t,"syncpack lint toggles (lintFormatting / lintSemverRanges / lintVersions) are covered by `vis lint` by default — no migration needed."),Array.isArray(e.source)&&e.source.length>0&&ne(t,`syncpack \`source\` was set to [${e.source.map(n=>JSON.stringify(n)).join(", ")}]. vis derives workspace globs from pnpm-workspace.yaml / package.json#workspaces — verify they match before relying on \`vis lint\`.`),typeof e.indent=="string"&&e.indent.length>0&&Q(t,"syncpack `indent` is implicit in vis — JSON writers honor `.editorconfig` (and the source file's existing indentation). No migration needed.")},qd=(e,t)=>{const n={};if(!Array.isArray(e.versionGroups))return n;for(const s of e.versionGroups){if(!s||typeof s!="object")continue;const r=s;if(!zd(r))continue;const i=Array.isArray(r.dependencies)?r.dependencies.filter(l=>typeof l=="string"&&l.length>0):[];if(i.length===0){Q(t,"versionGroup with `isBanned: true` has no `dependencies` entries — skipped.");continue}const o=Array.isArray(r.packages)?r.packages.filter(l=>typeof l=="string"&&l.length>0):[],a=r.label,c=typeof a=="string"&&a.length>0?a:"banned via syncpack versionGroups";for(const l of i){if(n[l]!==void 0){Q(t,`Multiple banned versionGroups target "${l}" — kept the first match; merge manually if needed.`);continue}n[l]=o.length>0?{packages:o,reason:c}:c}}return n},n0=e=>{const t=[`name: ${JSON.stringify(e.name)}`,`path: ${JSON.stringify(e.path)}`,`strategy: ${JSON.stringify(e.strategy)}`];return e.depName!==void 0&&t.push(`depName: ${JSON.stringify(e.depName)}`),` { ${t.join(", ")} }`},s0=(e,t)=>{if(typeof t=="string")return` ${JSON.stringify(e)}: ${JSON.stringify(t)}`;const n=[`reason: ${JSON.stringify(t.reason)}`];return t.packages&&t.packages.length>0&&n.push(`packages: [${t.packages.map(s=>JSON.stringify(s)).join(", ")}]`),t.paths&&t.paths.length>0&&n.push(`paths: [${t.paths.map(s=>JSON.stringify(s)).join(", ")}]`),t.replacement!==void 0&&n.push(`replacement: ${JSON.stringify(t.replacement)}`),` ${JSON.stringify(e)}: { ${n.join(", ")} }`},xi=(e,t={})=>{const n=[],s=Object.entries(t);if(s.length>0){const r=s.map(([i,o])=>s0(i,o)).join(`,
|
|
86
84
|
`);n.push(` bannedDeps: {
|
|
87
|
-
${
|
|
88
|
-
}`)}if(e.length>0){const
|
|
85
|
+
${r},
|
|
86
|
+
}`)}if(e.length>0){const r=e.map(i=>n0(i)).join(`,
|
|
89
87
|
`);n.push(` customTypes: {
|
|
90
88
|
extraTypes: [
|
|
91
|
-
${
|
|
89
|
+
${r},
|
|
92
90
|
],
|
|
93
91
|
}`)}return` policy: {
|
|
94
92
|
${n.join(`,
|
|
95
93
|
`)},
|
|
96
|
-
}`},
|
|
97
|
-
${d},`):
|
|
98
|
-
${d},`)),u?(
|
|
94
|
+
}`},Kd=(e,t)=>{const n=[],s=Object.keys(t).length;return e.length>0&&n.push(`${String(e.length)} customType(s)`),s>0&&n.push(`${String(s)} bannedDep(s)`),n.join(" + ")},r0=(e,t,n,s={})=>{const r=Kd(t,s);if(r==="")return!1;const i=Dt(e);if(i){const l=G(i);if(Yb.test(l))return n.warn(`vis.config.ts already has a "policy" block — please merge ${r} manually.`),!1;const d=xi(t,s);let u;return Ga.test(l)?u=l.replace(Ga,`$1
|
|
95
|
+
${d},`):za.test(l)&&(u=l.replace(za,`$1
|
|
96
|
+
${d},`)),u?(ie(i),ae(i,u,"utf8"),n.info(`Merged ${r} into ${i}`),!0):(n.warn(`Could not auto-insert policy block into ${i} — please add manually`),!1)}const o=g(e,"vis.config.ts"),c=`import { defineConfig } from "@visulima/vis/config";
|
|
99
97
|
|
|
100
98
|
export default defineConfig({
|
|
101
|
-
${
|
|
99
|
+
${xi(t,s)},
|
|
102
100
|
});
|
|
103
|
-
`;return ae(o,c,"utf8"),n.info(`Created ${o} with ${
|
|
104
|
-
`,"utf8")}return s},
|
|
105
|
-
`)},
|
|
106
|
-
`);for(const n of e){t.info(` • ${n.entry.title} — ${n.entry.description}`);for(const s of n.preview)t.info(` ${s}`);t.info("")}t.info("Run a specific migration with `vis migrate <name>` (e.g. `vis migrate deps`).")}
|
|
107
|
-
`)}e.visConfig={}}const o=process.argv[2]??"";if(!new Set(["--help","--version","-h","-V","create","help","implode","init"]).has(o)&&!
|
|
101
|
+
`;return ae(o,c,"utf8"),n.info(`Created ${o} with ${r}`),!0},i0=(e,t)=>{const n=g(e,"package.json"),s={catalogStripped:!1,configRemoved:!1,dependencyRemoved:!1,removedScripts:[],scriptCount:0};if(!x(n))return s;const r=G(n),i=JSON.parse(r);let o=!1;i.syncpack&&(delete i.syncpack,o=!0,s.configRemoved=!0);for(const d of["dependencies","devDependencies"]){const u=i[d];u?.syncpack&&(delete u.syncpack,o=!0,s.dependencyRemoved=!0)}const a=i.workspaces;if(a&&typeof a=="object"&&!Array.isArray(a)){const d=a.catalog;d&&typeof d.syncpack=="string"&&(delete d.syncpack,o=!0,s.catalogStripped=!0);const u=a.catalogs;if(u&&typeof u=="object")for(const p of Object.values(u))p&&typeof p.syncpack=="string"&&(delete p.syncpack,o=!0,s.catalogStripped=!0)}const c=i.catalog;c&&typeof c.syncpack=="string"&&(delete c.syncpack,o=!0,s.catalogStripped=!0);const l=i.scripts;if(l){const d={};for(const[u,p]of Object.entries(l))typeof p=="string"&&yo.test(p)?(s.scriptCount+=1,s.removedScripts.push({name:u,value:p}),o=!0):d[u]=p;s.scriptCount>0&&(Object.keys(d).length===0?delete i.scripts:i.scripts=d)}if(o){const d=os(n,r,{useEditorconfig:t});ie(n),ae(n,`${JSON.stringify(i,void 0,d)}
|
|
102
|
+
`,"utf8")}return s},o0=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],a0=[".github/workflows",".gitlab-ci.yml",".circleci/config.yml",".woodpecker.yml",".drone.yml"],Yd=(e,t)=>{const n=[],s=r=>{const i=g(e,r);x(i)&&yo.test(G(i))&&(n.push(r),ne(t,`Update ${r} — replace \`syncpack\` invocation(s) with \`vis lint\` / \`vis sort-package-json\` as appropriate.`))};for(const r of a0){const i=g(e,r);if(x(i)){if(r===".github/workflows"){try{for(const o of Te(i))(o.endsWith(".yml")||o.endsWith(".yaml"))&&s(`.github/workflows/${o}`)}catch{}continue}s(r)}}return n},Xd=(e,t)=>{const n=[];for(const s of o0){const r=g(e,s);x(r)&&yo.test(G(r))&&(n.push(s),ne(t,`Update ${s} — replace \`syncpack\` invocation with \`vis lint\` / \`vis sort-package-json\` as appropriate.`))}return n},c0=e=>{const t=g(e,"pnpm-workspace.yaml");if(!x(t))return!1;let n;try{n=Tt(t)}catch{return!1}if(!n||typeof n!="object")return!1;let s=!1;const r=n.catalog;r&&typeof r.syncpack=="string"&&(delete r.syncpack,s=!0);const i=n.catalogs;if(i&&typeof i=="object")for(const o of Object.values(i))o&&typeof o.syncpack=="string"&&(delete o.syncpack,s=!0);return s&&(ie(t),xl(t,n)),s},l0=(e,t)=>{for(const n of[...Hd,...mo]){const s=g(e,n);x(s)&&(ie(s,t),pt(s),he(t,Si,"removedConfigCount"))}},d0=(e,t,n,s,r)=>{const i=Gd(t,r);Jd(t,r);const o=Xd(e,r);o.length>0&&!n.silent&&s.warn(`Found syncpack reference in ${String(o.length)} hook file(s) — see manualSteps for details.`);const a=Yd(e,r);a.length>0&&!n.silent&&s.warn(`Found syncpack reference in ${String(a.length)} CI file(s) — see manualSteps for details.`);const c=qd(t,r);(i.length>0||Object.keys(c).length>0)&&r0(e,i,s,c);const{catalogStripped:l,configRemoved:d,dependencyRemoved:u,removedScripts:p,scriptCount:f}=i0(e,n.useEditorconfig);d&&!n.silent&&s.info("Removed `syncpack` block from package.json"),u&&he(r,Si,"removedPackageCount");const h=c0(e);if((l||h)&&!n.silent&&s.info("Stripped `syncpack` from catalog protocol entries."),f>0){he(r,Si,"rewrittenScriptCount",f);for(const{name:m,value:v}of p)ne(r,`Recreate script \`${m}\` (removed; was \`${v}\`). Replace \`syncpack\` with \`vis lint\` / \`vis sort-package-json\` as appropriate.`);n.silent||s.info(`Removed ${String(f)} script(s) referencing \`syncpack\`. Replace with \`vis lint\` / \`vis sort-package-json\` as appropriate.`)}l0(e,r)},qa=(e,t,n,s)=>{const r=Ud(e);if(!r)return t.silent||n.info("No syncpack configuration found — nothing to migrate."),!1;const i=Xb(e);i&&(Q(s,`Syncpack config ${i} is a TS/JS format vis migrate cannot load — executable config support is tracked in https://github.com/visulima/visulima/issues/622. Convert to .syncpackrc.json and re-run.`),ne(s,`Convert ${i} to .syncpackrc.json (or translate it directly into policy.customTypes.extraTypes in vis.config.ts) — see https://github.com/visulima/visulima/issues/622`),t.silent||n.warn(`Cannot read ${i} — manual migration required (https://github.com/visulima/visulima/issues/622).`)),Zb(e)&&(Q(s,"vis.config.ts already declares `policy.customTypes.extraTypes` — skipping syncpack customTypes merge to avoid duplicates."),t.silent||n.warn("vis.config.ts already has policy.customTypes.extraTypes — skipping merge"));const o=t0(e,r,s);if(!o)return!1;if(t.dryRun){const a=Gd(o,s),c=qd(o,s);Jd(o,s),Xd(e,s),Yd(e,s);const l=Kd(a,c);return t.silent||(l===""?n.info("[dry-run] No policy entries to merge — manualSteps will surface the rest."):(n.info(`[dry-run] Would merge ${l} into vis.config.ts:`),n.info(xi(a,c)))),!0}return d0(e,o,t,n,s),!0},u0=e=>e.map(t=>{if(t.startsWith("^"))return{dependencies:!0,target:t.slice(1)};if(t.includes("#")){const[n,s]=t.split("#");return{projects:n,target:s}}return t}),p0=(e,t,n)=>{const s=e.tasks??e.pipeline??{},r={};for(const[c,l]of Object.entries(s)){if(c.includes("#"))continue;const d={};l.persistent&&(d.persistent=!0),l.interactive&&(d.interactive=!0);const u={};l.cache===!1&&(u.cache=!1),l.dependsOn&&l.dependsOn.length>0&&(u.dependsOn=u0(l.dependsOn)),l.inputs&&l.inputs.length>0&&(u.inputs=l.inputs),l.outputs&&l.outputs.length>0&&(u.outputs=l.outputs),l.env&&l.env.length>0&&(u.env=l.env),l.passThroughEnv&&l.passThroughEnv.length>0&&(u.passThroughEnv=l.passThroughEnv),Object.keys(d).length>0&&(u.options=d),r[c]=u}const i={};Object.keys(r).length>0&&(i.tasks=r);const o={};return e.globalDependencies&&e.globalDependencies.length>0&&(o.globalInputs=e.globalDependencies),e.globalEnv&&e.globalEnv.length>0&&(o.globalEnv=e.globalEnv),e.globalPassThroughEnv&&e.globalPassThroughEnv.length>0&&(o.globalPassThroughEnv=e.globalPassThroughEnv),Object.keys(o).length>0&&(i.taskRunner=o),["// Migrated from turbo.json by `vis migrate turborepo`.","// Review the generated `tasks` block and move project-specific tasks","// into each project's project.json.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${lo(i,g(t,"vis.config.ts"),n)});`,""].join(`
|
|
103
|
+
`)},Ka=(e,t,n,s)=>{const r=Cd(e,"turbo.json");if(!r){n.warn("No turbo.json found in workspace root — nothing to migrate."),s.warnings.push("No turbo.json at workspace root.");return}const i=p0(r,e,t.useEditorconfig);if(!uo(e,i,t,n,s))return;s.manualSteps.push("Review the `tasks` block in vis.config.ts — project-specific tasks (turbo's project#task syntax) were skipped and should be moved into each project's project.json."),s.manualSteps.push("vis adds two task primitives turbo doesn't have: `when: { os, env, branch, ci, not.* }` for conditional execution and `always: true` for finally/teardown tasks that run even when upstream fails. See docs/guides/conditional-and-finally-tasks.mdx.");const o=r.tasks??r.pipeline??{};Object.values(o).some(c=>c.outputLogs!==void 0)&&s.warnings.push("`outputLogs` was found on one or more tasks but vis has no equivalent setting — review and remove."),r.remoteCache?.enabled&&s.manualSteps.push("turbo remote cache detected. vis speaks the same HTTP protocol — set taskRunner.remoteCache { url, token, teamId } in vis.config.ts, or keep your TURBO_API / TURBO_TOKEN / TURBO_TEAM env vars (vis honours them as fallbacks).")},f0=/\b(?:husky|lint-staged|nano-staged)\b/,h0=e=>{const t=g(e,"package.json");if(x(t))try{return JSON.parse(G(t))}catch{return}},m0=(e,t)=>{const n=h0(e);if(!n)return!1;const s={...n.dependencies,...n.devDependencies};for(const i of gd)if(s[i])return!0;if(n.scripts){for(const i of Object.values(n.scripts))if(typeof i=="string"&&f0.test(i))return!0}const{overrides:r}=t;return r?Object.keys(r).length>0:!1},g0=e=>x(g(e,"turbo.json")),y0=e=>x(g(e,"nx.json")),v0=e=>x(g(e,".moon")),Oe=()=>{const e=[];return{lines:e,logger:{info:t=>{e.push(t)},warn:t=>{e.push(`⚠ ${t}`)}}}},b0=[{apply:({packageManager:e,root:t,visConfig:n},s,r)=>{Aa(t,e,n,{dryRun:!1},r,s)},description:"Remove husky/lint-staged/nano-staged from package.json and rewrite scripts to `vis staged`.",detect:({root:e,visConfig:t})=>m0(e,t),id:"deps",probe:({packageManager:e,root:t,visConfig:n})=>{const{lines:s,logger:r}=Oe(),i=Ee();return Aa(t,e,n,{dryRun:!0},r,i),s},title:"Dependencies & scripts"},{apply:({root:e},t,n)=>{Ma(e,{dryRun:!1},n,t)},description:"Inline lint-staged configuration into vis.config.ts.",detect:({root:e})=>!!$d(e),id:"lint-staged",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return Ma(e,{dryRun:!0},n,s),t},title:"lint-staged"},{apply:({root:e},t,n)=>{Va(e,{dryRun:!1},n,t)},description:"Inline nano-staged configuration into vis.config.ts.",detect:({root:e})=>!!Rd(e),id:"nano-staged",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return Va(e,{dryRun:!0},n,s),t},title:"nano-staged"},{apply:({root:e},t,n)=>{Ka(e,{dryRun:!1},n,t)},description:"Translate turbo.json tasks into vis.config.ts.",detect:({root:e})=>g0(e),id:"turborepo",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return Ka(e,{dryRun:!0},n,s),t},title:"Turborepo"},{apply:({root:e},t,n)=>{Wa(e,{dryRun:!1},n,t)},description:"Translate nx.json targets into vis.config.ts.",detect:({root:e})=>y0(e),id:"nx",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return Wa(e,{dryRun:!0},n,s),t},title:"Nx"},{apply:({root:e},t,n)=>{La(e,{copyTemplates:!1,dryRun:!1},n,t)},description:"Translate .moon/tasks.yml into vis.config.ts.",detect:({root:e})=>v0(e),id:"moon",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return La(e,{copyTemplates:!1,dryRun:!0},n,s),t},title:"Moon"},{apply:({root:e},t,n)=>{Ia(e,{dryRun:!1},n,t)},description:"Convert gitleaks config/baseline/hooks to `vis secrets`.",detect:({root:e})=>!!(lr(e)??oo(e)??ao(e)),id:"gitleaks",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return Ia(e,{dryRun:!0},n,s),t},title:"Gitleaks"},{apply:({root:e},t,n)=>{Pa(e,{dryRun:!1},n,t)},description:"Convert Kingfisher baseline/rules/hooks to `vis secrets`.",detect:({root:e})=>!!(co(e)??dr(e)),id:"kingfisher",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return Pa(e,{dryRun:!0},n,s),t},title:"Kingfisher"},{apply:({root:e},t,n)=>{Ha(e,{dryRun:!1},n,t)},description:"Replace secretlint config/hooks with `vis secrets`.",detect:({root:e})=>!!(Bd(e)??Pd(e)),id:"secretlint",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return Ha(e,{dryRun:!0},n,s),t},title:"Secretlint"},{apply:({root:e},t,n)=>{qa(e,{dryRun:!1},n,t)},description:"Translate syncpack customTypes into policy.customTypes.extraTypes and strip the syncpack dep/scripts.",detect:({root:e})=>!!Ud(e),id:"syncpack",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return qa(e,{dryRun:!0},n,s),t},title:"Syncpack"},{apply:({root:e},t,n)=>{Ua(e,{dryRun:!1},n,t)},description:"Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command.",detect:({root:e})=>!!Nd(e)||Dd(e),id:"sherif",probe:({root:e})=>{const{lines:t,logger:n}=Oe(),s=Ee();return Ua(e,{dryRun:!0},n,s),t},title:"Sherif"}],w0=e=>b0.filter(t=>t.detect(e)),k0=(e,t)=>({packageManager:wd(e),root:e,visConfig:t}),S0=(e,t)=>{t.info("── Migration Summary ──");const n=[["Staged configs merged into vis.config.ts",e.mergedStagedConfigCount],["Lint-staged configs inlined",e.inlinedLintStagedConfigCount],["Config files removed",e.removedConfigCount],["Packages removed",e.removedPackageCount],["Scripts rewritten",e.rewrittenScriptCount]];for(const[r,i]of n)i>0&&t.info(` ${r}: ${String(i)}`);e.gitHooksConfigured&&t.info(" Pre-commit hook updated to use vis staged");const s=Object.entries(e.perMigration);if(s.length>0){t.info(""),t.info("By migration:");for(const[r,i]of s){const o=[];i.removedConfigCount>0&&o.push(`${String(i.removedConfigCount)} config(s) removed`),i.removedPackageCount>0&&o.push(`${String(i.removedPackageCount)} package(s) removed`),i.rewrittenScriptCount>0&&o.push(`${String(i.rewrittenScriptCount)} script(s) rewritten`),t.info(` ${r}: ${o.join(", ")||"no changes"}`)}}if(e.backupsCreated.length>0&&(t.info(""),t.info(`Created ${String(e.backupsCreated.length)} .bak file(s) for rollback. Remove them once you're happy.`)),e.warnings.length>0){t.info(""),t.warn("Warnings:");for(const r of e.warnings)t.warn(` - ${r}`)}if(e.manualSteps.length>0){t.info(""),t.info("Manual steps required:");for(const r of e.manualSteps)t.info(` - ${r}`)}},x0=(e,t)=>{if(e.length===0){t.info("No applicable migrations detected in this workspace.");return}t.info(`Detected migrations (non-interactive preview):
|
|
104
|
+
`);for(const n of e){t.info(` • ${n.entry.title} — ${n.entry.description}`);for(const s of n.preview)t.info(` ${s}`);t.info("")}t.info("Run a specific migration with `vis migrate <name>` (e.g. `vis migrate deps`).")},$0=async e=>{const t=e.workspaceRoot??process.cwd(),n=e.visConfig??{},s=k0(t,n),i=w0(s).map(h=>({entry:h,preview:h.probe(s)}));if(!(!!process.stdout.isTTY&&!ct)){x0(i,e.logger);return}if(i.length===0){e.logger.info("No applicable migrations detected in this workspace.");return}const a=new qg(i),c=n.tui?.autoExit??!1,l=c===!0?3:typeof c=="number"?c:0,u=await Bg(Vf.createElement(xy,{autoExitSeconds:l,isDryRun:!1,store:a}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();if(!u||u.length===0){e.logger.info("No migrations selected — exiting.");return}const p=Ee(),f=[];for(const h of u)try{e.logger.info(`── Applying ${h.entry.title} ──`),h.entry.apply(s,p,e.logger),e.logger.info("")}catch(m){f.push({entry:h.entry,error:m}),e.logger.warn(`Failed to apply ${h.entry.title}: ${m.message}`)}S0(p,e.logger),f.length>0&&(e.logger.warn(""),e.logger.warn(`${String(f.length)} migration(s) failed — see messages above.`),process.exitCode=1)},E0={beforeCommand:async e=>{try{const t=e.options?.cwd,n=e.options?.config;let s;if(t)s=dn(process.cwd(),t);else{const c=process.env.VIS_MONOREPO_ROOT;s=c&&c.length>0?c:Sl(process.cwd()).path}e.workspaceRoot=s;const r=n?dn(process.cwd(),n):void 0;let i=r??Dt(s);try{e.visConfig=await Xo(s,r?{explicitConfigPath:r}:void 0);const c=e.visConfig?.versionConstraint;if(c&&!li.validRange(c)){e.logger.error(""),e.logger.error(kr(Ne("✖ Invalid versionConstraint"))),e.logger.error(` vis.config.ts has versionConstraint ${Ne(JSON.stringify(c))}, which is not a valid semver range.`),e.logger.error(""),process.exitCode=1;return}if(c&&!li.satisfies(Fs(),c)){e.logger.error(""),e.logger.error(kr(Ne("✖ vis version too old"))),e.logger.error(` vis.config.ts requires vis ${Ne(c)}, but the current version is ${Ne(Fs())}.`),e.logger.error(` ${Bn("→")} Upgrade: ${Qe("pnpm add -D @visulima/vis@latest")}`),e.logger.error(""),process.exitCode=1;return}}catch(c){const l=i,d=c instanceof Error?c.message:String(c);e.visConfigError={file:l??void 0,message:d};const u=!!process.stdout.isTTY&&!ct;if(l&&!u){if(e.logger.error(""),e.logger.error(kr(Ne(`✖ Failed to load ${l}`))),e.logger.error(` ${d}`),e.logger.error(""),d.includes("Cannot find module")){const f=/Cannot find module '([^']+)'/.exec(d)?.[1]??"unknown";e.logger.error(`${Bn("→ Hint:")} The module ${Ne(f)} could not be resolved.`),f.includes("@visulima/vis")?(e.logger.error(" This usually means the package isn't installed or the export path changed."),e.logger.error(` Try: ${Qe("pnpm add @visulima/vis")}`),e.logger.error(` Or regenerate: ${Qe("vis init --force")}`)):e.logger.error(` Try: ${Qe(`pnpm add ${f}`)}`)}else d.includes("SyntaxError")||d.includes("Unexpected token")?(e.logger.error(`${Bn("→ Hint:")} The config file has a syntax error.`),e.logger.error(" Check your config for typos or invalid syntax."),e.logger.error(` Or regenerate: ${Qe("vis init --force")}`)):(e.logger.error(`${Bn("→ Hint:")} Delete the broken config and recreate it:`),e.logger.error(` ${Qe(`rm ${l} && vis init`)}`));e.logger.error(""),e.logger.error(` Continuing with default settings.
|
|
105
|
+
`)}e.visConfig={}}const o=process.argv[2]??"";if(!new Set(["--help","--version","-h","-V","create","help","implode","init"]).has(o)&&!i&&!ct)if(process.stdin.isTTY){const c=hl({input:process.stdin,output:process.stderr}),l=await new Promise(u=>{c.question("\x1B[36;1m?\x1B[0m \x1B[1mNo vis.config.ts found. Create one with best-practice security defaults?\x1B[0m \x1B[90m(\x1B[92mY\x1B[90m/n)\x1B[0m ",u),c.on("SIGINT",()=>{c.close(),u("n")})});if(c.close(),!l.trim()||l.trim().toLowerCase()==="y"||l.trim().toLowerCase()==="yes"){const u=g(s,"vis.config.ts"),p=['import { defineConfig } from "@visulima/vis/config";',"","// Secure defaults are applied automatically by defineConfig().","// You only need to add allowBuilds for packages with build scripts.","// Run 'vis check --security-config' to see all active settings.","export default defineConfig({"," security: {"," allowBuilds: {",' // "esbuild": true,'," },"," },","});",""].join(`
|
|
108
106
|
`);ae(u,p),e.logger.info(`✓ Created ${u}
|
|
109
|
-
`),e.visConfig=await
|
|
110
|
-
${Qe("✨")} ${Ne(`vis ships an MCP server for ${
|
|
111
|
-
${
|
|
112
|
-
${
|
|
113
|
-
`),
|
|
114
|
-
${
|
|
115
|
-
${
|
|
116
|
-
`),
|
|
117
|
-
\x1B[2mtip: ${
|
|
118
|
-
`),n.lastGlobal=t,n.perTip[i.id]=t,S0(n))},E0=e=>({afterCommand:async t=>{const n=process.argv.slice(2),s=n[0]??"",i=process.exitCode===void 0||process.exitCode===0;e&&e();const r=t.workspaceRoot??process.cwd();$0({args:n,command:s,hasDockerfile:x(g(r,"Dockerfile")),hasDockerignore:x(g(r,".dockerignore")),hasVercelConfig:x(g(r,"vercel.json"))||x(g(r,".vercel")),hasVisConfig:t.visConfig!==void 0&&Object.keys(t.visConfig).length>0,success:i}),w0({success:i,visConfig:t.visConfig}),m0({command:s,success:i,visConfig:t.visConfig})},name:"post-command"});let C0;const R0=e=>(C0??=Be(import.meta.url))(e),qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ho=e=>{if(typeof qt<"u"&&qt.versions&&qt.versions.node){const[t,n]=qt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return qt.getBuiltinModule(e)}return R0(e)},Et=qt,{execFileSync:j0}=ho("node:child_process"),Nn=ho("node:fs"),T0=ho("node:tty"),O0=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],A0=12288,I0=65510,B0=[12288,12288,65281,65376,65504,65510],P0=8361,N0=65518,D0=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],M0=32,L0=10630,_0=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],F0=4352,V0=262141,Gd=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],os=(e,t)=>{let n=0,s=Math.floor(e.length/2)-1;for(;n<=s;){const i=Math.floor((n+s)/2),r=i*2;if(t<e[r])s=i-1;else if(t>e[r+1])n=i+1;else return!0}return!1},za=19968,[H0,W0]=U0(Gd);function U0(e){let t=e[0],n=e[1];for(let s=0;s<e.length;s+=2){const i=e[s],r=e[s+1];if(za>=i&&za<=r)return[i,r];r-i>n-t&&(t=i,n=r)}return[t,n]}const G0=e=>e<161||e>1114109?!1:os(O0,e),z0=e=>e<A0||e>I0?!1:os(B0,e),J0=e=>e<P0||e>N0?!1:os(D0,e),K0=e=>e<M0||e>L0?!1:os(_0,e),q0=e=>e>=H0&&e<=W0?!0:e<F0||e>V0?!1:os(Gd,e);function Y0(e){return G0(e)?"ambiguous":z0(e)?"fullwidth":J0(e)?"halfwidth":K0(e)?"narrow":q0(e)?"wide":"neutral"}function X0(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function zd(e){return X0(e),Y0(e)}const Jd=String.raw,Ja=Jd`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Z0=()=>new RegExp(Jd`\p{RI}{2}|(?)${Ja}(?:\u200D${Ja})*`,"gu"),wn=new Set(["\x1B",""]),pi="\x07",Kd="[",mo="m",Xn="]8;;",Q0=39,ew=/[\u200B\uFEFF\u2060-\u2064]/g,tw=new RegExp(`(?:\\${Kd}(?<code>\\d+)m|\\${Xn}(?<uri>.*)${pi})`),nw=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),qd=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,ws=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,sw=Z0(),Ka=new Map,iw=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),rw=e=>{const t=iw(e.width);let n=Ka.get(t);return n||(n=new Map,Ka.set(t,n)),n},ks=new RegExp(qd.source,"y"),Bi=new RegExp(sw.source,"uy"),Ss=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Yd=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",ow=(e,t)=>{const n=rw(t),s=Math.floor(e/65536),i=e%65536;let r=n.get(s);if(r||(r=new Map,n.set(s,r)),r.has(i))return r.get(i);let o;switch(Yd(e)){case"control":{o=t.width.control;break}case"latin":{o=t.width.regular;break}case"wide":{o=t.width.wide;break}case"zero":{o=0;break}default:switch(zd(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}}return r.set(i,o),o},aw=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,Er=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Er(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},s=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:i}=e,r=i>1e4;let o=0,a=0,c=i,l=!1;const d=e.includes("\x1B")||e.includes("");for(;o<i;){if(d&&(e[o]==="\x1B"||e[o]==="")){if(e.startsWith("\x1B]8;;",o)){const b="\x1B]8;;\x07",$=b.length,v=e.indexOf("\x07",o+5);if(v!==-1){const S=e.indexOf(b,v+1);if(S!==-1){const C=S+$,P=e.slice(v+1,S).replace(qd,""),j=Er(P,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,s-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),B=j.width;if(j.truncated)l=!0,c=Math.min(c,o);else if(a+B>s&&(c=Math.min(c,o),l=!0,a+B>n.truncation.limit))break;if(a+=B,o=C,l&&a>=n.truncation.limit)break;continue}}}if(ks.lastIndex=o,ks.test(e)){const b=ks.lastIndex-o,$=n.truncation.countAnsiEscapeCodes?b:n.width.ansi;if(a+$>s&&(c=Math.min(c,o),a+$>n.truncation.limit)){l=!0;break}a+=$,o=ks.lastIndex;continue}}const f=e.codePointAt(o);if(f===8203||f===65279||f>=8288&&f<=8292){o+=1;continue}if(f===9){if(a+n.width.tab>s&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(Ss.lastIndex=o,Ss.test(e)){const b=(Ss.lastIndex-o)*n.width.regular;if(a+b>s){const $=n.width.regular>0?Math.floor((s-a)/n.width.regular):0;if(c=Math.min(c,o+$),a+b>n.truncation.limit){l=!0;break}}a+=b,o=Ss.lastIndex;continue}if((f<=31||f>=127&&f<=159)&&(ws.lastIndex=o,ws.test(e))){const b=(ws.lastIndex-o)*n.width.control;if(a+b>s){const $=n.width.control>0?Math.floor((s-a)/n.width.control):0;if(c=Math.min(c,o+$),a+b>n.truncation.limit){l=!0;break}}a+=b,o=ws.lastIndex;continue}if(Bi.lastIndex=o,Bi.test(e)){if(a+n.width.emoji>s&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=Bi.lastIndex;continue}const h=e.codePointAt(o)??0;if(aw(h)){o+=h>65535?2:1;continue}let m;if(r)m=ow(h,n);else switch(Yd(h)){case"control":{m=n.width.control;break}case"latin":{m=n.width.regular;break}case"wide":{m=n.width.wide;break}case"zero":{m=0;break}default:switch(zd(h)){case"ambiguous":{m=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{m=n.width.fullWidth;break}case"wide":{m=n.width.wide;break}default:m=n.width.regular}}if(a+m>s&&(c=Math.min(c,o),a+m>n.truncation.limit)){l=!0;break}a+=m,o+=h>65535?2:1}let u=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(u=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:i,truncated:l,width:u}},lt=(e,t={})=>Er(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,cw=/\x1B\[(\d+)m/;let Xd=class{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const n=cw.exec(t);if(!n)return;const s=Number.parseInt(n[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=t;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(s)){const i={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];i&&(this.activeFormatting=this.activeFormatting.filter(r=>!r.includes(i)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const n={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const i=n[s];i&&t.push(i)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};const lw=(e,t)=>{if(!wn.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const n=!0,s=e.slice(t+1,t+1+Xn.length).join("")===Xn;return{isInsideEscape:n,isInsideLinkEscape:s}},dw=(e,t={})=>{const n=new Xd;let s="",i=!1,r="",o="",a=!1;const c=[...e];for(let l=0;l<c.length;l++){const d=c[l];if(d&&wn.has(d)){if(s){const m=t.getWidth?.(s)??0,b={isEscapeSequence:!1,isGrapheme:!0,text:s,width:m};if(a&&(b.isHyperlink=!0,b.hyperlinkUrl=o),t.onSegment?.(b,n)===!1)return;s=""}i=!0,r=d;const f=lw(c,l),{isInsideLinkEscape:h}=f;if(h){let m=l+1;for(o="";m<c.length;){const $=c[m];if($===pi)break;o+=$,m+=1}o=o.slice(4);const b={hyperlinkUrl:o,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(b,n)===!1)return;l=m,a=!0,i=!1,r="";continue}if(l+1<c.length&&c[l+1]==="\\"&&a){const m={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(m,n)===!1)return;a=!1,o="",l+=1,i=!1,r="";continue}}if(i){if(r!==d&&(r+=d),d===mo){i=!1,n.processEscape(r);const f={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};if(t.onSegment?.(f,n)===!1)return;r=""}continue}s+=d;const u=t.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};if(a&&(p.isHyperlink=!0,p.hyperlinkUrl=o),t.onSegment?.(p,n)===!1)return;s=""}if(s){const l=t.getWidth?.(s)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:s,width:l};a&&(d.isHyperlink=!0,d.hyperlinkUrl=o),t.onSegment?.(d,n)}if(r){const l={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};t.onSegment?.(l,n)}},qa=e=>`${wn.values().next().value}${Kd}${String(e)}${mo}`,Ya=e=>`${wn.values().next().value}${Xn}${e}${pi}`,uw=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",n,s;const i=e.join(`
|
|
119
|
-
`),
|
|
120
|
-
`?(s&&(t+=
|
|
121
|
-
`&&(n&&l&&(t+=
|
|
107
|
+
`),e.visConfig=await Xo(s),i=u}}else e.logger.warn("No vis.config.ts found. Run 'vis init' to create one with best-practice security defaults.")}catch(t){t instanceof Error&&!t.message.includes("monorepo root")&&e.logger.warn(`Failed to detect workspace: ${t.message}`),e.visConfig={}}},name:"config-loader"},C0=336*60*60*1e3,$i=g(ht(),"mcp-promote.json"),gt="@visulima/vis-mcp",R0=new Set(["--help","--version","-h","-V","ai","help","implode","mcp"]),j0=()=>{try{if(x($i))return le($i)}catch{}return{lastShown:0}},T0=e=>{try{ft(ht()),me($i,JSON.stringify(e))}catch{}},vn=e=>{try{return x(e)?le(e):void 0}catch{return}},bn=e=>{if(typeof e!="object"||e===null)return!1;for(const t of Object.values(e)){if(typeof t!="object"||t===null)continue;const n=t,s=Array.isArray(n.args)?n.args.join(" "):"",r=`${typeof n.command=="string"?n.command:""} ${s}`;if(r.includes(gt)||r.includes("vis-mcp"))return!0}return!1},O0=e=>{if(!Array.isArray(e))return!1;for(const t of e){if(typeof t!="object"||t===null)continue;const n=t,s=Array.isArray(n.args)?n.args.join(" "):"",r=`${typeof n.command=="string"?n.command:""} ${s} ${typeof n.name=="string"?n.name:""}`;if(r.includes(gt)||r.includes("vis-mcp"))return!0}return!1},A0=e=>{const t=g(e,".claude"),n=g(e,".claude.json"),s=x(t)||x(n);let r=!1;if(s){const i=vn(n);r=bn(i?.mcpServers)}return{displayName:"Claude Code",id:"claude-code",installCommand:`claude mcp add vis -- npx -y ${gt}@latest`,isConfigured:r,isInstalled:s}},I0=e=>{const t=g(e,".cursor","mcp.json"),n=x(g(e,".cursor"));let s=!1;if(n){const r=vn(t);s=bn(r?.mcpServers)}return{displayName:"Cursor",id:"cursor",installCommand:`Add to ~/.cursor/mcp.json: "vis": { "command": "npx", "args": ["-y", "${gt}@latest"] }`,isConfigured:s,isInstalled:n}},B0=e=>{const t=g(e,".codeium","windsurf"),n=g(t,"mcp_config.json"),s=x(t);let r=!1;if(s){const i=vn(n);r=bn(i?.mcpServers)}return{displayName:"Windsurf",id:"windsurf",installCommand:`Add to ~/.codeium/windsurf/mcp_config.json: "vis": { "command": "npx", "args": ["-y", "${gt}@latest"] }`,isConfigured:r,isInstalled:s}},P0=e=>{const t=g(e,".continue"),n=g(t,"config.json"),s=x(t);let r=!1;if(s){const i=vn(n);r=bn(i?.mcpServers)||O0(i?.mcpServers)}return{displayName:"Continue",id:"continue",installCommand:`Add to ~/.continue/config.json mcpServers: { "name": "vis", "command": "npx", "args": ["-y", "${gt}@latest"] }`,isConfigured:r,isInstalled:s}},N0=e=>{const t=g(e,"Library","Application Support","Zed","settings.json"),n=g(e,".config","zed","settings.json"),s=oh()==="darwin"?t:n,r=x(s);let i=!1;if(r){const o=vn(s);i=bn(o?.context_servers)}return{displayName:"Zed",id:"zed",installCommand:`Add to Zed settings.json under context_servers: "vis": { "command": "npx", "args": ["-y", "${gt}@latest"] }`,isConfigured:i,isInstalled:r}},D0=e=>{const t=[g(e,".config","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"),g(e,"Library","Application Support","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json")];let n;for(const i of t)if(x(i)){n=i;break}const s=n!==void 0;let r=!1;if(n!==void 0){const i=vn(n);r=bn(i?.mcpServers)}return{displayName:"Cline",id:"cline",installCommand:`In VS Code: open Cline > MCP Servers, add "vis" with command "npx" and args ["-y", "${gt}@latest"]`,isConfigured:r,isInstalled:s}},M0=()=>{const e=ih();return[A0(e),I0(e),B0(e),P0(e),N0(e),D0(e)]},L0=e=>{if(!e.success||process.env.VIS_CLI_TEST||ct||process.env.VIS_NO_MCP_PROMOTE==="1"||e.visConfig?.mcpPromote?.enabled===!1||!process.stderr.isTTY||e.command!==void 0&&R0.has(e.command))return!1;const t=new Set(process.argv.slice(2));return!(t.has("--silent")||t.has("-s")||t.has("--json"))},_0=e=>{if(!L0(e))return;const t=Date.now(),n=j0();if(t-n.lastShown<C0)return;const r=M0().find(i=>i.isInstalled&&!i.isConfigured);r!==void 0&&(process.stderr.write(`
|
|
108
|
+
${Qe("✨")} ${Ne(`vis ships an MCP server for ${r.displayName}.`)}
|
|
109
|
+
${r.installCommand}
|
|
110
|
+
${sn("Hide this with VIS_NO_MCP_PROMOTE=1 or mcpPromote: { enabled: false } in vis.config.ts")}
|
|
111
|
+
`),T0({lastShown:t}))},F0=336*60*60*1e3,V0="https://github.com/sponsors/prisis",Ei=g(ht(),"sponsor.json"),W0=()=>{try{if(x(Ei))return le(Ei)}catch{}return{lastShown:0}},H0=e=>{try{ft(ht()),me(Ei,JSON.stringify(e))}catch{}},U0=e=>{if(!e.success||process.env.VIS_CLI_TEST||ct||process.env.VIS_NO_SPONSOR==="1"||e.visConfig?.sponsor?.enabled===!1||!process.stderr.isTTY)return;const t=Date.now(),n=W0();t-n.lastShown<F0||(process.stderr.write(`
|
|
112
|
+
${sh("♥")} ${Ne("Enjoying visulima?")} ${sn(`Consider sponsoring at ${V0}`)}
|
|
113
|
+
${sn(" Hide this with VIS_NO_SPONSOR=1 or sponsor.enabled = false in vis.config.ts")}
|
|
114
|
+
`),H0({lastShown:t}))},Ya=300*1e3,Ci=g(ht(),"tips.json"),G0=()=>{try{if(x(Ci))return le(Ci)}catch{}return{lastGlobal:0,perTip:{}}},z0=e=>{try{ft(ht()),me(Ci,JSON.stringify(e))}catch{}},J0=[{cooldownMs:1800*1e3,id:"short-aliases",matches:e=>["install","link","remove","uninstall","update"].includes(e.command),message:e=>{const n={install:"i",link:"ln",remove:"rm",uninstall:"rm",update:"up"}[e.command];return n?`You can use 'vis ${n}' as a shorthand for 'vis ${e.command}'`:""},probability:.5},{id:"use-exec",matches:e=>e.command==="dlx"&&e.success,message:()=>"Use 'vis exec' to run locally installed binaries without downloading."},{id:"security-check",matches:e=>(e.command==="check"||e.command==="update")&&e.success&&!e.args.includes("--security"),message:()=>"Add --security to check for known vulnerabilities via OSV.dev",probability:.3},{cooldownMs:3600*1e3,id:"ai-analysis",matches:e=>(e.command==="check"||e.command==="update")&&e.success&&!e.args.includes("--ai"),message:()=>"Add --ai to run AI analysis on outdated packages before updating.",probability:.2},{cooldownMs:1440*60*1e3,id:"socket-security",matches:e=>(e.command==="install"||e.command==="update"||e.command==="check")&&e.success,message:()=>"Enable Socket.dev in vis.config.ts for security scores and supply chain alerts: security.socket.enabled = true",probability:.15},{id:"dedupe-after-install",matches:e=>e.command==="install"&&e.success,message:()=>"Run 'vis dedupe' periodically to remove duplicate dependencies.",probability:.15},{cooldownMs:720*60*1e3,id:"doctor-checkup",matches:e=>(e.command==="install"||e.command==="add"||e.command==="update")&&e.success,message:()=>"Run 'vis doctor' for a full project health check — outdated, security, duplicates, and optimizations in one view.",probability:.25},{cooldownMs:10080*60*1e3,id:"init-config",matches:e=>(e.command==="install"||e.command==="run")&&e.success&&!e.hasVisConfig,message:()=>"Run 'vis init' to create a vis.config.ts with secure defaults — supply chain protection enabled automatically.",probability:.4},{id:"why-command",matches:e=>e.command==="outdated"&&e.success,message:()=>"Use 'vis why <package>' to understand why a dependency is installed.",probability:.3},{id:"graph-command",matches:e=>e.command==="run"&&e.success,message:()=>"Use 'vis graph' to visualize your project dependency graph.",probability:.1},{id:"affected-command",matches:e=>e.command==="run"&&e.success&&!e.args.includes("--projects"),message:()=>"Use 'vis affected <target>' to run tasks only on changed projects.",probability:.2},{id:"pm-cache",matches:e=>e.command==="install"&&e.success,message:()=>"Use 'vis pm cache dir' to find your package manager's cache location.",probability:.1},{id:"create-editor",matches:e=>e.command==="create"&&e.success,message:()=>"Add --editor vscode to generate VS Code configuration during project creation.",probability:.5},{id:"env-pin",matches:e=>e.command==="env"&&e.args.includes("install")&&e.success,message:()=>"Use 'vis env pin <version>' to pin the Node.js version for your project.",probability:.5},{cooldownMs:720*60*1e3,id:"docker-lint",matches:e=>!!e.hasDockerfile&&e.success&&e.command!=="docker",message:()=>"Found a Dockerfile — run 'vis docker lint' to check it against hadolint best practices.",probability:.3},{cooldownMs:1440*60*1e3,id:"docker-ignore",matches:e=>!!e.hasDockerfile&&!e.hasDockerignore&&e.success&&e.command!=="ignore",message:()=>"No .dockerignore next to your Dockerfile — run 'vis ignore --write' to shrink the build context.",probability:.4},{cooldownMs:1440*60*1e3,id:"vercel-ignore",matches:e=>!!e.hasVercelConfig&&e.success&&e.command!=="ignore",message:()=>"Deploying to Vercel? Run 'vis ignore --target=vercel --write' to generate a deduped .vercelignore.",probability:.25},{id:"upgrade-check",matches:e=>e.command!=="self-update"&&e.success,message:()=>"Run 'vis self-update --check' to see if a newer version of vis is available.",probability:.05}],q0=e=>{if(process.env.VIS_CLI_TEST||ct)return;const t=Date.now(),n=G0();if(t-n.lastGlobal<Ya)return;const s=J0.filter(o=>{if(!o.matches(e))return!1;const a=n.perTip[o.id]??0,c=o.cooldownMs??Ya;return t-a>=c});if(s.length===0)return;const r=s.find(o=>{const a=o.probability??1;return Math.random()<a});if(!r)return;const i=r.message(e);i&&(process.stderr.write(`
|
|
115
|
+
\x1B[2mtip: ${i}\x1B[0m
|
|
116
|
+
`),n.lastGlobal=t,n.perTip[r.id]=t,z0(n))},K0=e=>({afterCommand:async t=>{const n=process.argv.slice(2),s=n[0]??"",r=process.exitCode===void 0||process.exitCode===0;e&&e();const i=t.workspaceRoot??process.cwd();q0({args:n,command:s,hasDockerfile:x(g(i,"Dockerfile")),hasDockerignore:x(g(i,".dockerignore")),hasVercelConfig:x(g(i,"vercel.json"))||x(g(i,".vercel")),hasVisConfig:t.visConfig!==void 0&&Object.keys(t.visConfig).length>0,success:r}),U0({success:r,visConfig:t.visConfig}),_0({command:s,success:r,visConfig:t.visConfig})},name:"post-command"});let Y0;const X0=e=>(Y0??=Be(import.meta.url))(e),Kt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vo=e=>{if(typeof Kt<"u"&&Kt.versions&&Kt.versions.node){const[t,n]=Kt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Kt.getBuiltinModule(e)}return X0(e)},Ct=Kt,{execFileSync:Z0}=vo("node:child_process"),Nn=vo("node:fs"),Q0=vo("node:tty"),ew=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],tw=12288,nw=65510,sw=[12288,12288,65281,65376,65504,65510],rw=8361,iw=65518,ow=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],aw=32,cw=10630,lw=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],dw=4352,uw=262141,Zd=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],as=(e,t)=>{let n=0,s=Math.floor(e.length/2)-1;for(;n<=s;){const r=Math.floor((n+s)/2),i=r*2;if(t<e[i])s=r-1;else if(t>e[i+1])n=r+1;else return!0}return!1},Xa=19968,[pw,fw]=hw(Zd);function hw(e){let t=e[0],n=e[1];for(let s=0;s<e.length;s+=2){const r=e[s],i=e[s+1];if(Xa>=r&&Xa<=i)return[r,i];i-r>n-t&&(t=r,n=i)}return[t,n]}const mw=e=>e<161||e>1114109?!1:as(ew,e),gw=e=>e<tw||e>nw?!1:as(sw,e),yw=e=>e<rw||e>iw?!1:as(ow,e),vw=e=>e<aw||e>cw?!1:as(lw,e),bw=e=>e>=pw&&e<=fw?!0:e<dw||e>uw?!1:as(Zd,e);function ww(e){return mw(e)?"ambiguous":gw(e)?"fullwidth":yw(e)?"halfwidth":vw(e)?"narrow":bw(e)?"wide":"neutral"}function kw(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Qd(e){return kw(e),ww(e)}const eu=String.raw,Za=eu`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Sw=()=>new RegExp(eu`\p{RI}{2}|(?)${Za}(?:\u200D${Za})*`,"gu"),wn=new Set(["\x1B",""]),hr="\x07",tu="[",bo="m",Zn="]8;;",xw=39,$w=/[\u200B\uFEFF\u2060-\u2064]/g,Ew=new RegExp(`(?:\\${tu}(?<code>\\d+)m|\\${Zn}(?<uri>.*)${hr})`),Cw=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),nu=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,ws=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,Rw=Sw(),Qa=new Map,jw=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),Tw=e=>{const t=jw(e.width);let n=Qa.get(t);return n||(n=new Map,Qa.set(t,n)),n},ks=new RegExp(nu.source,"y"),Nr=new RegExp(Rw.source,"uy"),Ss=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,su=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",Ow=(e,t)=>{const n=Tw(t),s=Math.floor(e/65536),r=e%65536;let i=n.get(s);if(i||(i=new Map,n.set(s,i)),i.has(r))return i.get(r);let o;switch(su(e)){case"control":{o=t.width.control;break}case"latin":{o=t.width.regular;break}case"wide":{o=t.width.wide;break}case"zero":{o=0;break}default:switch(Qd(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}}return i.set(r,o),o},Aw=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,Ri=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Ri(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},s=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:r}=e,i=r>1e4;let o=0,a=0,c=r,l=!1;const d=e.includes("\x1B")||e.includes("");for(;o<r;){if(d&&(e[o]==="\x1B"||e[o]==="")){if(e.startsWith("\x1B]8;;",o)){const v="\x1B]8;;\x07",$=v.length,b=e.indexOf("\x07",o+5);if(b!==-1){const S=e.indexOf(v,b+1);if(S!==-1){const C=S+$,P=e.slice(b+1,S).replace(nu,""),T=Ri(P,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,s-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),N=T.width;if(T.truncated)l=!0,c=Math.min(c,o);else if(a+N>s&&(c=Math.min(c,o),l=!0,a+N>n.truncation.limit))break;if(a+=N,o=C,l&&a>=n.truncation.limit)break;continue}}}if(ks.lastIndex=o,ks.test(e)){const v=ks.lastIndex-o,$=n.truncation.countAnsiEscapeCodes?v:n.width.ansi;if(a+$>s&&(c=Math.min(c,o),a+$>n.truncation.limit)){l=!0;break}a+=$,o=ks.lastIndex;continue}}const f=e.codePointAt(o);if(f===8203||f===65279||f>=8288&&f<=8292){o+=1;continue}if(f===9){if(a+n.width.tab>s&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(Ss.lastIndex=o,Ss.test(e)){const v=(Ss.lastIndex-o)*n.width.regular;if(a+v>s){const $=n.width.regular>0?Math.floor((s-a)/n.width.regular):0;if(c=Math.min(c,o+$),a+v>n.truncation.limit){l=!0;break}}a+=v,o=Ss.lastIndex;continue}if((f<=31||f>=127&&f<=159)&&(ws.lastIndex=o,ws.test(e))){const v=(ws.lastIndex-o)*n.width.control;if(a+v>s){const $=n.width.control>0?Math.floor((s-a)/n.width.control):0;if(c=Math.min(c,o+$),a+v>n.truncation.limit){l=!0;break}}a+=v,o=ws.lastIndex;continue}if(Nr.lastIndex=o,Nr.test(e)){if(a+n.width.emoji>s&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=Nr.lastIndex;continue}const h=e.codePointAt(o)??0;if(Aw(h)){o+=h>65535?2:1;continue}let m;if(i)m=Ow(h,n);else switch(su(h)){case"control":{m=n.width.control;break}case"latin":{m=n.width.regular;break}case"wide":{m=n.width.wide;break}case"zero":{m=0;break}default:switch(Qd(h)){case"ambiguous":{m=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{m=n.width.fullWidth;break}case"wide":{m=n.width.wide;break}default:m=n.width.regular}}if(a+m>s&&(c=Math.min(c,o),a+m>n.truncation.limit)){l=!0;break}a+=m,o+=h>65535?2:1}let u=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(u=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:r,truncated:l,width:u}},lt=(e,t={})=>Ri(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,Iw=/\x1B\[(\d+)m/;let ru=class{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const n=Iw.exec(t);if(!n)return;const s=Number.parseInt(n[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=t;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(s)){const r={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];r&&(this.activeFormatting=this.activeFormatting.filter(i=>!i.includes(r)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const n={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const r=n[s];r&&t.push(r)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};const Bw=(e,t)=>{if(!wn.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const n=!0,s=e.slice(t+1,t+1+Zn.length).join("")===Zn;return{isInsideEscape:n,isInsideLinkEscape:s}},Pw=(e,t={})=>{const n=new ru;let s="",r=!1,i="",o="",a=!1;const c=[...e];for(let l=0;l<c.length;l++){const d=c[l];if(d&&wn.has(d)){if(s){const m=t.getWidth?.(s)??0,v={isEscapeSequence:!1,isGrapheme:!0,text:s,width:m};if(a&&(v.isHyperlink=!0,v.hyperlinkUrl=o),t.onSegment?.(v,n)===!1)return;s=""}r=!0,i=d;const f=Bw(c,l),{isInsideLinkEscape:h}=f;if(h){let m=l+1;for(o="";m<c.length;){const $=c[m];if($===hr)break;o+=$,m+=1}o=o.slice(4);const v={hyperlinkUrl:o,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(v,n)===!1)return;l=m,a=!0,r=!1,i="";continue}if(l+1<c.length&&c[l+1]==="\\"&&a){const m={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(m,n)===!1)return;a=!1,o="",l+=1,r=!1,i="";continue}}if(r){if(i!==d&&(i+=d),d===bo){r=!1,n.processEscape(i);const f={isEscapeSequence:!0,isGrapheme:!1,text:i,width:0};if(t.onSegment?.(f,n)===!1)return;i=""}continue}s+=d;const u=t.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};if(a&&(p.isHyperlink=!0,p.hyperlinkUrl=o),t.onSegment?.(p,n)===!1)return;s=""}if(s){const l=t.getWidth?.(s)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:s,width:l};a&&(d.isHyperlink=!0,d.hyperlinkUrl=o),t.onSegment?.(d,n)}if(i){const l={isEscapeSequence:!0,isGrapheme:!1,text:i,width:0};t.onSegment?.(l,n)}},ec=e=>`${wn.values().next().value}${tu}${String(e)}${bo}`,tc=e=>`${wn.values().next().value}${Zn}${e}${hr}`,Nw=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",n,s;const r=e.join(`
|
|
117
|
+
`),i=[...r];let o=0;for(const[a,c]of i.entries()){if(t+=c,wn.has(c)){const d=Ew.exec(r.slice(o))?.groups??{};if(d.code!==void 0){const u=Number.parseFloat(d.code);n=u===xw?void 0:u}else d.uri!==void 0&&(s=d.uri.length===0?void 0:d.uri)}const l=Cw.get(Number(n));i[a+1]===`
|
|
118
|
+
`?(s&&(t+=tc("")),n&&l&&(t+=ec(l))):c===`
|
|
119
|
+
`&&(n&&l&&(t+=ec(n)),s&&(t+=tc(s))),o+=c.length}return t},iu=/(?=\s)|(?<=\s)/,ou=/^\s+$/,nc=new Map,Dw=e=>{const t=nc.get(e);if(t!==void 0)return t;const n=lt(e);return nc.set(e,n),n},Dr=e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},Rt=e=>{const t=e.split(" ");let n=t.length;for(;n>0&<(t[n-1])===0;)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},au=(e,t,n)=>{if(e.length===0)return[""];if(t<=0)return[e];const s=[],r=new ru;let i="",o=0,a=!1,c=!1,l="",d=0;for(;d<e.length;){const u=e.codePointAt(d),p=String.fromCodePoint(u),f=p.length;if(wn.has(p)){a=!0,l=p,i+=p,c=e.startsWith(Zn,d+1),d+=1;continue}if(a){l+=p,i+=p,c?p===hr&&(a=c=!1):p===bo&&(a=!1,r.processEscape(l)),d+=1;continue}const h=Dw(p),m=p===" ";if(h===0){i+=p,d+=f;continue}if(o+h>t&&(i&&s.push(i+r.getEndEscapesForAllActiveAttributes()),i=r.getStartEscapesForAllActiveAttributes(),o=lt(i),m&&n)){for(;d<e.length&&e[d]===" ";)d+=1;continue}if(i+=p,o+=h,o===t&&d+f<e.length&&(s.push(i+r.getEndEscapesForAllActiveAttributes()),i=r.getStartEscapesForAllActiveAttributes(),o=lt(i),d+f<e.length&&e[d+f]===" "&&n)){for(d+=f;d<e.length&&e[d]===" ";)d+=1;continue}d+=f}return i&&s.push(i+r.getEndEscapesForAllActiveAttributes()),n?s.map(u=>Rt(u)):s},Mw=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const r=[];let i="",o=0;return Pw(s,{getWidth:lt,onSegment:(a,c)=>{const l=a.text??"";if(a.isEscapeSequence)i+=l;else{const d=l===" ";if(a.width===0)return i+=l,!0;if(o+a.width>t&&(i&&r.push(i),i=c.getStartEscapesForAllActiveAttributes(),o=0,d))return n||r.push(c.getStartEscapesForAllActiveAttributes()+l),!0;i+=l,o+=a.width}return!0}}),i&&r.push(i),n?r.map(a=>Rt(a)):r},Lw=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const r=s.split(iu),i=[];let o="",a=0,c=0;for(;c<r.length;){const l=r[c],d=ou.test(l),u=lt(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(a+u>t&&a>0){n?i.push(Rt(o)):i.push(o),o="",a=0;continue}o+=l,a+=u,c+=1}return o&&(n?i.push(Rt(o)):i.push(o)),i},_w=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const r=s.split(iu),i=[];let o="",a=0,c=0;for(;c<r.length;){const l=r[c],d=ou.test(l),u=lt(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(u>t){o&&i.push(Dr(n?Rt(o):o));const p=au(l,t,n);if(p.length>0){for(let f=0;f<p.length-1;f+=1)i.push(p[f]);o=p.at(-1),a=lt(o)}else o="",a=0;c+=1;continue}if(a+u>t&&a>0&&(i.push(Dr(n?Rt(o):o)),o="",a=0,n&&d)){c+=1;continue}o+=l,a+=u,c+=1}return o&&i.push(Dr(n?Rt(o):o)),i},Dn={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},Fw=(e,t={})=>{const{removeZeroWidthCharacters:n=!0,trim:s=!0,width:r=80,wrapMode:i=Dn.PRESERVE_WORDS}=t;if(s&&e.trim()==="")return"";let o=e.normalize("NFC").replaceAll(`\r
|
|
122
120
|
`,`
|
|
123
|
-
`);return n&&(o=o.replaceAll(
|
|
124
|
-
`).map(a=>{if(s&&a.trim()==="")return"";let c;switch(
|
|
125
|
-
`)},
|
|
126
|
-
`));o<=c?(
|
|
121
|
+
`);return n&&(o=o.replaceAll($w,"")),o.split(`
|
|
122
|
+
`).map(a=>{if(s&&a.trim()==="")return"";let c;switch(i){case Dn.BREAK_AT_CHARACTERS:{c=Mw(a,r,s);break}case Dn.BREAK_WORDS:{c=_w(a,r,s);break}case Dn.STRICT_WIDTH:{c=au(a,r,s);break}default:c=Lw(a,r,s)}return Nw(c)}).join(`
|
|
123
|
+
`)},cu=80,lu=24,ji=(e,t,{shell:n,env:s}={})=>Z0(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),Bs=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),du=(e,t)=>{const{columns:n,rows:s}=Bs(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===cu&&s===lu))return{columns:n,rows:s}},Vw=()=>{if(Ct.platform!=="linux")return!0;try{const e=Nn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),r=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(r)||r<=0?!1:s===r}catch{return!1}};function Mr(){const{env:e,stdout:t,stderr:n}=Ct;if(t?.columns&&t?.rows)return Bs(t.columns,t.rows);if(n?.columns&&n?.rows)return Bs(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return Bs(e.COLUMNS,e.LINES);const s={columns:cu,rows:lu};return Ct.platform==="win32"?Lr()??s:Ct.platform==="darwin"?sc()??Lr()??s:sc()??Lr()??Ww()??s}const sc=()=>{try{const e=Ct.platform==="darwin"?Nn.constants.O_EVTONLY|Nn.constants.O_NONBLOCK:Nn.constants.O_NONBLOCK,{columns:t,rows:n}=Q0.WriteStream(Nn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},Lr=()=>{try{const e=ji("tput",["cols"],{env:{TERM:"dumb",...Ct.env}}),t=ji("tput",["lines"],{env:{TERM:"dumb",...Ct.env}});if(e&&t)return du(e,t)}catch{}},Ww=()=>{try{if(!Vw())return;const e=ji("resize",["-u"]).match(/\d+/g);if(e.length===2)return du(e[0],e[1])}catch{}};let Hw=class{#e;#t=!1;#n=!1;#i=0;#s=0;#r;#o;constructor(t,n){this.#e={stderr:n,stdout:t},this.#r=Mr(),this.#o=()=>{this.#r=Mr()};for(const s of Object.keys(this.#e))this.#e[s].onEarlyFlush(()=>{this.erase(s),this.#i=0,this.#s=0})}get lastLength(){return this.#i}get outside(){return this.#s}get isHooked(){return this.#t}get isSuspended(){return this.#n}clear(t){this.erase(t),this.#i=0,this.#s=0}done(t){this.#i=0,this.#s=0}erase(t,n=this.#i){this.#e[t].erase(n)}hook(){if(this.#t)return!1;const t=Object.values(this.#e);for(const n of t)n.active();return this.#r=Mr(),process.stdout.isTTY&&typeof process.stdout.on=="function"&&process.stdout.on("resize",this.#o),this.#a(!0),!0}resume(t,n){if(this.#n&&this.#t){this.#n=!1,n&&this.erase(t,n),this.#i=0,this.#s=0;const s=Object.values(this.#e);for(const r of s)r.active()}}suspend(t,n=!0){if(!this.#n){this.#n=!0,n&&this.erase(t);const s=Object.values(this.#e);for(const r of s)r.renew()}}unhook(t=!0){if(!this.#t)return!1;const n=Object.values(this.#e);for(const s of n)s.inactive(t);return typeof process.stdout.off=="function"&&process.stdout.off("resize",this.#o),this.#a(),!0}update(t,n,s=0){if(this.#n)return;if(n.length===0){this.clear(t);return}const r=this.#e[t],{columns:i,rows:o}=this.#r,a=Math.max(0,Math.min(o-1,s)),c=this.lastLength-a,l=Math.max(c-o,this.outside);let d=n.flatMap(u=>Fw(u,{trim:!1,width:i,wrapMode:Dn.STRICT_WIDTH}).split(`
|
|
124
|
+
`));o<=c?(r.erase(o),a<l&&(d=d.slice(l-a+1))):c&&r.erase(c),r.write(`${d.join(`
|
|
127
125
|
`)}
|
|
128
|
-
`),this.#
|
|
129
|
-
`),this.#a(this.#t.length));const n=this.#e.end();n&&this.write(n),this.renew()}renew(){this.#n===void 0||this.#o.write===this.#n?this.#o.write=this.#
|
|
130
|
-
`)},
|
|
131
|
-
${Array.from({length:t+1}).join(n)}`}},fi=(e,t)=>{if(e.length===0)return"";const n=t.prev+t.base;return n+e.split("\0\0").join(`,${n}`)+t.prev},Gw=/^[a-z_]\w*$/i,zw=/^"|"$/g,Jw=(e,t)=>{if(Gw.test(e))return e;const n=JSON.stringify(e);return t.quoteStyle==="double"?n.replaceAll('"',String.raw`\"`):n.replaceAll("'",String.raw`\'`).replaceAll(String.raw`\"`,'"').replaceAll(zw,"'")},Zn=([e,t],n,s,i)=>{s.truncate-=2;let r;typeof e=="string"?r=Jw(e,s):typeof e=="number"?r=String(e):r=`[${i(e,n,s)}]`,s.truncate-=r.length;const o=i(t,n,s);return`${r}: ${o}`},Kw=Symbol.for("chai/inspect"),Mi=e=>({[Kw]:()=>e}),Qn=(e,t)=>{let n;try{n=Object.getOwnPropertyDescriptor(e,t)}catch{n=void 0}if(n===void 0||"value"in n)try{return e[t]}catch{return Mi(Ke)}if(n.get===void 0)return Mi("[Setter]");try{return e[t]}catch{return Mi(Ke)}},qw=e=>{for(const t of e)if(Array.isArray(t)||typeof t=="object"&&t!==null)return!0;return!1},Yw=e=>{const t=[];for(const n of Object.keys(e)){const s=Number(n);Number.isInteger(s)&&s>=0&&String(s)===n&&s<4294967295||t.push(n)}return t},Xw=(e,t,n,s)=>{const i=Yw(e);if(e.length===0&&i.length===0)return"[]";t.truncate-=4;const r=!!s&&qw(e);let o=Ie(e,e,t,n,void 0,r?"\0\0":", ",t.maxArrayLength);t.truncate-=o.length;let a="";return i.length>0&&(a=Ie(i.map(c=>[c,Qn(e,c)]),e,t,n,Zn)),r&&s&&(o=fi(o,s)),`[${r?"":" "}${o}${a?`, ${a}`:""}${r?"":" "}]`},Zw=50,Qa=(e,t)=>{const n=new Uint8Array(e),s=Math.min(n.length,Zw);let i="",r=!1;for(let l=0;l<s;l+=1){const d=n[l];d!==0&&(r=!0),i+=(l===0?"":" ")+d.toString(16).padStart(2,"0")}n.length>s&&(i+=` ... ${String(n.length-s)} more byte${n.length-s===1?"":"s"}`);const o=e instanceof ArrayBuffer?"ArrayBuffer":"SharedArrayBuffer",a=r||n.length>s,c=i!==""&&a?`[Uint8Contents]: <${i}>, `:"";return`${t.stylize(o,"special")} { ${c}byteLength: ${t.stylize(String(e.byteLength),"number")} }`},ec=/\d(?=(?:\d{3})+(?!\d))/g,Qw=/\d{3}/g,ek=/_$/,lu=(e,t)=>{if(t.length<4||t.length===4&&t.codePointAt(0)===45||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY||t.includes("e"))return t;if(typeof e=="number"){const n=e<0?-Math.floor(-e):Math.floor(e);if(n!==e){const s=String(n),i=t.slice(s.length+1);return`${s.replace(ec,"$&_")}.${i.replace(Qw,"$&_").replace(ek,"")}`}}return t.replace(ec,"$&_")},tk=e=>e>="\uD800"&&e<="\uDBFF",yt=(e,t,n="…")=>{e=String(e);const s=n.length,i=e.length;if(s>t&&i>s)return n;if(i>t&&i>s){let r=t-s;return r>0&&tk(e[r-1])&&(r-=1),`${e.slice(0,r)}${n}`}return e},tc=(e,t)=>{let n=yt(e.toString(),t.truncate-1);return n!=="…"&&(n+="n"),t.stylize(t.numericSeparator?lu(e,n):n,"bigint")},du=e=>{try{return Array.isArray(e)}catch{return!1}},xt=(e,t)=>{try{return e[t]}catch{return}},nk=(e,t)=>{try{return e instanceof t}catch{return!1}},nc=(e,t)=>{try{return Object.getOwnPropertyDescriptor(e,t)?.enumerable??!1}catch{return!0}},sk=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:void 0),Bs=(e,t,n,s)=>{if("window"in globalThis&&e===globalThis)return"{ [object Window] }";if(e===globalThis)return"{ [object globalThis] }";let i,r;try{i=Object.getOwnPropertyNames(e),r=Object.getOwnPropertySymbols(e)}catch{return Ke}let o,a;try{o=t.showHidden?i:i.filter(f=>Object.getOwnPropertyDescriptor(e,f)?.enumerable)}catch{o=i.filter(f=>nc(e,f))}try{a=r.filter(f=>t.showHidden||Object.getOwnPropertyDescriptor(e,f)?.enumerable)}catch{a=r.filter(f=>nc(e,f))}let c;try{const f=sk(e)===Object.prototype||e.constructor===Object,h=e instanceof Object?"":"null prototype";let m;!f&&Symbol.toStringTag in e?m=e[Symbol.toStringTag]:m=h?"Object":"",c=m||h?`[${[m,h].filter(Boolean).join(": ")}] `:""}catch{c=""}if(o.length===0&&a.length===0)return`${c}{}`;t.truncate-=4;const l=s?"\0\0":", ",d=Ie(o.map(f=>[f,Qn(e,f)]),e,t,n,Zn,l),u=Ie(a.map(f=>[f,Qn(e,f)]),e,t,n,Zn,l);let p="";return d&&u&&(p=l),s?`${c}{${fi(d+p+u,s)}}`:`${c}{ ${d}${p}${u} }`},ik=(e,t,n,s)=>{let i;try{i=typeof e.constructor=="function"?e.constructor.name:""}catch{i=""}return(!i||i==="_class")&&(i="<Anonymous Class>"),t.truncate-=i.length,`${i} ${Bs(e,t,n,s)}`},rk=(e,t)=>{const n=t.stylize(String(e.byteLength),"number"),s=t.stylize(String(e.byteOffset),"number"),i=t.stylize(String(e.buffer.byteLength),"number");return`${t.stylize("DataView","special")} { byteLength: ${n}, byteOffset: ${s}, buffer: ArrayBuffer { byteLength: ${i} } }`},ok=(e,t)=>{const n=e.toJSON();if(n===null)return"Invalid Date";const s=n.split("T"),i=s[0];return t.stylize(`${i}T${yt(s[1],t.truncate-i.length-1)}`,"date")},ak=new Set(["column","columnNumber","description","fileName","line","lineNumber","message","name","number","stack"]),ck=(e,t,n)=>{const s=Object.getOwnPropertyNames(e).filter(a=>!ak.has(a)),{name:i}=e;t.truncate-=i.length;let r="";typeof e.message=="string"?r=yt(e.message,t.truncate):s.unshift("message"),r=r?`: ${r}`:"",t.truncate-=r.length+5;const o=Ie(s.map(a=>[a,Qn(e,a)]),e,t,n,Zn);return`${i}${r}${o?` { ${o} }`:""}`},sc=(e,t)=>{let n,s,i;try{n=e[Symbol.toStringTag]||"Function",s=e.toString(),{name:i}=e}catch{return t.stylize(Ke,"special")}return s.length<t.truncate-12?t.stylize(`[${n}: ${s}]`,"special"):i?t.stylize(`[${n} ${yt(i,t.truncate-11)}]`,"special"):t.stylize(`[${n}]`,"special")},ic=(e,t)=>{const n=xt(e,Symbol.toStringTag),s=typeof n=="string"?n:"Generator";return`${t.stylize(`Object [${s}]`,"special")} {}`},lk=([e,t],n,s,i)=>(s.truncate-=4,e=i(e,n,s),s.truncate-=e.length,`${e} => ${i(t,n,s)}`),dk=(e,t,n,s)=>{if(e.size<=0)return"Map (0) {}";t.truncate-=7;let i=Ie([...e.entries()],e,t,n,lk,s?"\0\0":", ",t.maxArrayLength);return s&&(i=fi(i,s)),`Map (${String(e.size)}) {${s?"":" "}${i}${s?"":" "}}`};function rc(e,t){return Number.isNaN(e)?t.stylize("NaN","number"):e===Number.POSITIVE_INFINITY?t.stylize("Infinity","number"):e===Number.NEGATIVE_INFINITY?t.stylize("-Infinity","number"):e===0?t.stylize(1/e===Number.POSITIVE_INFINITY?"+0":"-0","number"):t.stylize(yt(t.numericSeparator?lu(e,e.toString()):e.toString(),t.truncate),"number")}const uk=()=>"Promise{…}",pk=(e,t)=>{const n=t.truncate-(2+e.flags.length);return t.stylize(`/${yt(e.source,n)}/${e.flags}`,"regexp")},fk=(e,t,n,s)=>{if(e.size===0)return"Set (0) {}";t.truncate-=7;let i=Ie([...e],e,t,n,void 0,s?"\0\0":", ",t.maxArrayLength);return s&&(i=fi(i,s)),`Set (${String(e.size)}) {${s?"":" "}${i}${s?"":" "}}`},hk=(e,t)=>{const n=t.quoteStyle==="double"?'"':"'";return n+e+n},oc=new RegExp(String.raw`['\0-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5`+String.raw`\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]`,"g"),mk={" ":String.raw`\t`,"\n":String.raw`\n`,"\f":String.raw`\f`,"\r":String.raw`\r`,"\b":String.raw`\b`,"'":String.raw`\'`,"\\":"\\\\"},gk=16,yk=e=>mk[e]||String.raw`\u${`0000${e.codePointAt(0).toString(gk)}`.slice(-4)}`,ac=(e,t)=>(oc.test(e)&&(e=e.replaceAll(oc,yk)),t.stylize(hk(yt(e,t.truncate-2),t),"string")),cc=e=>"description"in Symbol.prototype?e.description?`Symbol(${e.description})`:"Symbol()":e.toString(),vk=e=>typeof Buffer=="function"&&e instanceof Buffer?"Buffer":e[Symbol.toStringTag],Fe=(e,t,n)=>{const s=vk(e);t.truncate-=s.length+4;const i=Object.keys(e).slice(e.length);if(e.length===0&&i.length===0)return`${s}[]`;let r="";const o=Number.isFinite(t.maxArrayLength)?Math.min(e.length,Math.max(0,Math.floor(t.maxArrayLength))):e.length;for(let c=0;c<o;c++){const l=`${t.stylize(yt(e[c],t.truncate),"number")}${c===o-1?"":", "}`;if(t.truncate-=l.length,c!==o-1&&t.truncate<=3){r+=`…(${String(e.length-c)})`;break}r+=l}o<e.length&&(r+=`${r?", ":""}… ${String(e.length-o)} more`);let a="";return i.length>0&&(a=Ie(i.map(c=>[c,Qn(e,c)]),e,t,n,Zn)),`${s}[ ${r}${a?`, ${a}`:""} ]`},lc=e=>typeof xt(e,Symbol.toStringTag)!="string",bk=e=>typeof e=="function",uu=(e,t,n)=>{if(e==null)return;const s=Object.getOwnPropertyDescriptor(e,t);if(s===void 0)return;const i=n==="get"?s.get:s.value;return typeof i=="function"?i:void 0},pu=(e,t)=>{if(e!==void 0)return n=>{try{return e.call(n,t),!0}catch{return!1}}},kt=(e,t)=>pu(uu(e,t,"get")),Xe=(e,t,n)=>pu(uu(e,t,"value"),n),dc=Object.freeze({}),Ve=kt(Reflect.getPrototypeOf(Int8Array.prototype),"length"),wk=typeof SharedArrayBuffer=="function"?SharedArrayBuffer.prototype:void 0,kk=Object.assign(Object.create(null),{Arguments:lc,Array:du,ArrayBuffer:kt(ArrayBuffer.prototype,"byteLength"),BigInt:Xe(BigInt.prototype,"valueOf"),Boolean:Xe(Boolean.prototype,"valueOf"),DataView:kt(DataView.prototype,"byteLength"),Date:Xe(Date.prototype,"valueOf"),Error:lc,Float32Array:Ve,Float64Array:Ve,Function:bk,Int8Array:Ve,Int16Array:Ve,Int32Array:Ve,Map:kt(Map.prototype,"size"),Number:Xe(Number.prototype,"valueOf"),RegExp:kt(RegExp.prototype,"source"),Set:kt(Set.prototype,"size"),SharedArrayBuffer:kt(wk,"byteLength"),String:Xe(String.prototype,"valueOf"),Symbol:Xe(Symbol.prototype,"valueOf"),Uint8Array:Ve,Uint8ClampedArray:Ve,Uint16Array:Ve,Uint32Array:Ve,WeakMap:Xe(WeakMap.prototype,"has",dc),WeakSet:Xe(WeakSet.prototype,"has",dc)}),Sk=(e,t)=>{const n=kk[t];return n===void 0||n(e)},uc=new WeakMap,pc=Object.create(null),xk=Object.assign(Object.create(null),{Arguments:Ww,Array:Xw,ArrayBuffer:Qa,AsyncGenerator:ic,BigInt:tc,bigint:tc,Boolean:(e,t)=>t.stylize(String(e),"boolean"),boolean:(e,t)=>t.stylize(String(e),"boolean"),DataView:rk,Date:ok,Error:ck,Float32Array:Fe,Float64Array:Fe,Function:sc,function:sc,Generator:ic,HTMLCollection:Tr,Int8Array:Fe,Int16Array:Fe,Int32Array:Fe,Map:dk,NodeList:Tr,null:(e,t)=>t.stylize("null","null"),Number:rc,number:rc,Promise:uk,RegExp:pk,Set:fk,SharedArrayBuffer:Qa,String:ac,string:ac,Symbol:cc,symbol:cc,Uint8Array:Fe,Uint8ClampedArray:Fe,Uint16Array:Fe,Uint32Array:Fe,undefined:(e,t)=>t.stylize("undefined","undefined"),WeakMap:(e,t)=>t.stylize("WeakMap{…}","special"),WeakSet:(e,t)=>t.stylize("WeakSet{…}","special")}),$k=Symbol.for("nodejs.util.inspect.custom"),Ek=Symbol.for("chai/inspect"),Ck=(e,t,n,s)=>{const i=xt(e,Ek);if(typeof i=="function")return i.call(e,t);if(!("window"in globalThis)){const c=xt(e,$k);if(typeof c=="function")return c.call(e,s,t)}const r=xt(e,"inspect");if(typeof r=="function")return r.call(e,s,t);const o=xt(e,"constructor");if(typeof o=="function"&&uc.has(o))return uc.get(o)?.(e,t)??"unknown";const a=Object.hasOwn(pc,n)?pc[n]:void 0;return a?a(e,t):""},Li=(e,t,n)=>{const{depth:s,inspect:i,seen:r}=n;if(r.includes(e))return"[Circular]";if(s>=t.depth&&t.depth>0&&typeof e=="object"&&e!==null)return du(e)?"[Array]":"[Object]";const o=t.indent?Uw(t.indent,s):void 0;let a=e===null?"null":typeof e;if(a==="object")try{a=Object.prototype.toString.call(e).slice(8,-1)}catch{a="Object"}let c=xk[a];if(c!==void 0&&typeof e=="object"&&e!==null&&!Sk(e,a)&&(c=void 0),c!==void 0)return c(e,t,i,o);if(t.customInspect&&e){const u=Ck(e,t,a,t.depth-s);if(u)return typeof u=="string"?u:i(u,e,t)}let l=!1;if(e)try{l=Object.getPrototypeOf(e)}catch{l=Object.prototype}if(l===Object.prototype||l===null)return Bs(e,t,i,o);if(e&&typeof HTMLElement=="function"&&nk(e,HTMLElement))return cu(e,e,t,i);const d=xt(e,"constructor");return d!==void 0?d!==Object?ik(e,t,i,o):Bs(e,t,i,o):e===Object(e)?Bs(e,t,i,o):t.stylize(String(e),a)},Ks=(e,t={})=>{const n={customInspect:!0,depth:5,indent:void 0,maxArrayLength:Number.POSITIVE_INFINITY,numericSeparator:!0,quoteStyle:"single",showHidden:!1,stylize:i=>i,truncate:Number.POSITIVE_INFINITY,...t};if(n.indent!==void 0&&n.indent!==" "&&!(Number.parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `undefined`');const s={depth:0,inspect:void 0,seen:[]};return s.inspect=(i,r,o)=>{if(r==null){s.depth+=1;const c=Li(i,o,s);return s.depth-=1,c}s.seen.push(r),s.depth+=1;const a=Li(i,o,s);return s.depth-=1,s.seen.pop(),a},Li(e,n,s)},Rk=new Set(["alert","critical","emergency","error","trace","warning"]),fu=e=>Rk.has(e),hu=(e,t)=>t?(t.__write??t.write.bind(t)).call(t,e):!1,jk=globalThis.process??Object.create(null),fc={versions:{}},es=new Proxy(jk,{get(e,t){if(t in e)return e[t];if(t in fc)return fc[t]}}),hi=e=>{let t;return()=>{if(t===void 0){if(typeof es.getBuiltinModule!="function")throw new TypeError(`[@visulima/error] Cannot load ${e}: this runtime implements no process.getBuiltinModule(). Requires Node ^22.14.0 || >=24.10.0, or another runtime providing process.getBuiltinModule().`);t=es.getBuiltinModule(e)}return t}},Tk=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
132
|
-
`),
|
|
133
|
-
`);typeof s.tabWidth=="number"&&e.includes(" ")&&(
|
|
134
|
-
`,s.prefix+d(C.replaceAll(/\d/g," "))," ",
|
|
135
|
-
`);return s.message&&!
|
|
136
|
-
${f}`),f},
|
|
137
|
-
`).map(
|
|
138
|
-
`,
|
|
139
|
-
`;else o+=
|
|
126
|
+
`),this.#i=l?l+d.length+1:a+d.length,this.#s=Math.max(this.lastLength-o,this.outside)}#a(t=!1){this.#t=t,this.#i=0,this.#s=0}},Uw;const Gw=e=>(Uw??=Be(import.meta.url))(e),jn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,zw=e=>{if(typeof jn<"u"&&jn.versions&&jn.versions.node){const[t,n]=jn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return jn.getBuiltinModule(e)}return Gw(e)},{StringDecoder:Jw}=zw("node:string_decoder"),cs="\x1B[",uu=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,qw=/^(?:msys|cygwin)$/,pu=process,Ti=pu?.env??{};!uu&&Ti.TERM_PROGRAM;!uu&&(pu?.platform==="win32"||Ti.OSTYPE!==void 0&&qw.test(Ti.OSTYPE));const Kw=`${cs}?25l`,Yw=`${cs}G`,Xw=`${cs}?25h`,Zw=(e=1)=>`${cs}${String(e)}A`;var Qw=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(Qw||{}),ek=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(ek||{}),tk=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(tk||{});const nk=e=>`${cs}${String(e)}K`,sk=nk(2),rk=e=>{if(e<=0)return"";let t="";for(let n=0;n<e;n+=1)t+=sk,n<e-1&&(t+=Zw());return t+=Yw,t},ik=1e4;class zs{static DRAIN=!0;#e=new Jw;#t=[];#n;#i;#s;#r;#o;isTTY;constructor(t,n={}){this.#r=t.write.bind(t),this.#o=t,this.#s=n.maxHistory??ik,this.isTTY=t.isTTY}active(){this.isTTY&&this.write(Kw);const t=(n,...s)=>{const r=s.at(-1);return this.#t.push(typeof n=="string"?n:this.#e.write(Buffer.from(n))),this.#t.length>this.#s&&(this.isTTY&&this.#i!==void 0&&this.#i(),this.#a(this.#t.length-Math.floor(this.#s/2))),typeof r=="function"&&r(),zs.DRAIN};this.#n=t,this.#o.write=this.#n}erase(t){t>0&&this.isTTY&&this.write(rk(t+1))}inactive(t=!1){this.#t.length>0&&(t&&this.write(`
|
|
127
|
+
`),this.#a(this.#t.length));const n=this.#e.end();n&&this.write(n),this.renew()}renew(){this.#n===void 0||this.#o.write===this.#n?this.#o.write=this.#r:console.warn("[@visulima/interactive-manager] stream.write was replaced by a third party while the hook was active; leaving it untouched to avoid stomping the other patch."),this.#n=void 0,this.isTTY&&this.write(Xw)}onEarlyFlush(t){this.#i=t}write(t){this.#r.apply(this.#o,[t])}#a(t){if(t<=0)return;const n=this.#t.splice(0,t);for(const s of n)this.write(s)}}let ok;const ak=e=>(ok??=Be(import.meta.url))(e),Yt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:it,wo=e=>{if(typeof Yt<"u"&&Yt.versions&&Yt.versions.node){const[t,n]=Yt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Yt.getBuiltinModule(e)}return ak(e)},it=Yt,{execFileSync:ck}=wo("node:child_process"),Mn=wo("node:fs"),lk=wo("node:tty"),dk={alert:7,critical:6,debug:1,emergency:8,error:5,informational:2,notice:3,trace:2,warning:4},fu={alert:{color:"red",label:"alert",logLevel:"alert"},await:{color:"blue",label:"awaiting",logLevel:"informational"},complete:{color:"cyan",label:"complete",logLevel:"informational"},critical:{color:"redBright",label:"critical",logLevel:"critical"},debug:{color:"gray",label:"debug",logLevel:"debug"},emergency:{color:"redBright",label:"emergency",logLevel:"emergency"},error:{color:"red",label:"error",logLevel:"error"},info:{color:"blueBright",label:"info",logLevel:"informational"},log:{label:"",logLevel:"informational"},notice:{color:"magentaBright",label:"notice",logLevel:"notice"},pending:{color:"magenta",label:"pending",logLevel:"informational"},start:{color:"greenBright",label:"start",logLevel:"informational"},stop:{color:"red",label:"stop",logLevel:"informational"},success:{color:"green",label:"success",logLevel:"informational"},trace:{color:"cyanBright",label:"trace",logLevel:"trace"},wait:{color:"blue",label:"waiting",logLevel:"informational"},warn:{color:"yellow",label:"warning",logLevel:"warning"},warning:{color:"yellow",label:"warning",logLevel:"warning"},watch:{color:"yellowBright",label:"watching",logLevel:"informational"}},ko=Symbol("EMPTY"),Oi=e=>{const t=Object.keys(e).map(n=>e[n].label??"");return t.length===0?"":t.reduce((n,s)=>n.length>s.length?n:s,"")},qe="[Inspection threw]",Ie=(e,t,n,s,r,i=", ",o=Number.POSITIVE_INFINITY)=>{const a=e.length;if(a===0)return"";const c=Number.isFinite(o)&&a>o,l=c?Math.max(0,Math.floor(o)):a;if(l===0)return`…(${String(a)})`;let d=s;r!==void 0&&(d=r);const u=n.truncate,p=Number.isFinite(u);let f="",h="",m="";for(let v=0;v<l;v+=1){const $=v+1===l,b=v+2===l;p&&(m=`…(${String(l-v)})`);let S=e[v];n.truncate=u-f.length-($?0:i.length);const C=h||d(S,t,n,s)+($?"":i),P=f.length+C.length,T=P+m.length;if($&&P>u&&f.length+m.length<=u||!$&&!b&&T>u)break;S=e[v+1];const N=b?"":i;if($?h="":h=d(S,t,n,s)+N,!$&&b&&T>u&&P+h.length>u)break;if(f+=C,!$&&!b&&P+h.length>=u){m=`…(${String(l-v-1)})`;break}m=""}return c&&m===""&&(m=`${i}… ${String(a-l)} more`),`${f}${m}`},uk=([e,t],n,s)=>(s.truncate-=3,t?`${s.stylize(String(e),"yellow")}=${s.stylize(`"${t}"`,"string")}`:s.stylize(String(e),"yellow")),hu=e=>{try{return Object.create(e,{length:{value:e.length}})}catch{return}},pk=(e,t,n,s)=>{let r;try{r=e.nodeType}catch{return qe}if(r===1)return mu(e,e,n,s);if(r===3){let i;try{i=e.data}catch{return qe}return s(i,void 0,n)}return s(e,void 0,n)},Ai=(e,t,n,s)=>{const r=hu(e);return r===void 0?qe:Ie(r,e,t,n,pk,`
|
|
128
|
+
`)},mu=(e,t,n,s)=>{let r,i;try{r=e.getAttributeNames().map(f=>[f,e.getAttribute(f)]),i=e.tagName.toLowerCase()}catch{return qe}const o=n.stylize(`<${i}`,"special"),a=n.stylize(">","special"),c=n.stylize(`</${i}>`,"special");n.truncate-=i.length*2+5;let l="";r.length>0&&(l+=" ",l+=Ie(r,t,n,s,uk," ")),n.truncate-=l.length;const{truncate:d}=n;let u;try{u=hu(e.children)}catch{u=void 0}let p;return u===void 0?p=qe:(p=Ai(u,n,s),p&&p.length>d&&(p=`…(${String(u.length)})`)),`${o}${l}${a}${p}${c}`},fk=(e,t,n)=>e.length===0?"Arguments []":(t.truncate-=13,`Arguments [ ${Ie(e,e,t,n,void 0,", ",t.maxArrayLength)} ]`),hk=(e,t)=>{let n;if(e===" ")n=" ";else if(typeof e=="number"&&e>0)n=Array.from({length:e+1}).join(" ");else return;return{base:n,prev:`
|
|
129
|
+
${Array.from({length:t+1}).join(n)}`}},mr=(e,t)=>{if(e.length===0)return"";const n=t.prev+t.base;return n+e.split("\0\0").join(`,${n}`)+t.prev},mk=/^[a-z_]\w*$/i,gk=/^"|"$/g,yk=(e,t)=>{if(mk.test(e))return e;const n=JSON.stringify(e);return t.quoteStyle==="double"?n.replaceAll('"',String.raw`\"`):n.replaceAll("'",String.raw`\'`).replaceAll(String.raw`\"`,'"').replaceAll(gk,"'")},Qn=([e,t],n,s,r)=>{s.truncate-=2;let i;typeof e=="string"?i=yk(e,s):typeof e=="number"?i=String(e):i=`[${r(e,n,s)}]`,s.truncate-=i.length;const o=r(t,n,s);return`${i}: ${o}`},vk=Symbol.for("chai/inspect"),_r=e=>({[vk]:()=>e}),es=(e,t)=>{let n;try{n=Object.getOwnPropertyDescriptor(e,t)}catch{n=void 0}if(n===void 0||"value"in n)try{return e[t]}catch{return _r(qe)}if(n.get===void 0)return _r("[Setter]");try{return e[t]}catch{return _r(qe)}},bk=e=>{for(const t of e)if(Array.isArray(t)||typeof t=="object"&&t!==null)return!0;return!1},wk=e=>{const t=[];for(const n of Object.keys(e)){const s=Number(n);Number.isInteger(s)&&s>=0&&String(s)===n&&s<4294967295||t.push(n)}return t},kk=(e,t,n,s)=>{const r=wk(e);if(e.length===0&&r.length===0)return"[]";t.truncate-=4;const i=!!s&&bk(e);let o=Ie(e,e,t,n,void 0,i?"\0\0":", ",t.maxArrayLength);t.truncate-=o.length;let a="";return r.length>0&&(a=Ie(r.map(c=>[c,es(e,c)]),e,t,n,Qn)),i&&s&&(o=mr(o,s)),`[${i?"":" "}${o}${a?`, ${a}`:""}${i?"":" "}]`},Sk=50,rc=(e,t)=>{const n=new Uint8Array(e),s=Math.min(n.length,Sk);let r="",i=!1;for(let l=0;l<s;l+=1){const d=n[l];d!==0&&(i=!0),r+=(l===0?"":" ")+d.toString(16).padStart(2,"0")}n.length>s&&(r+=` ... ${String(n.length-s)} more byte${n.length-s===1?"":"s"}`);const o=e instanceof ArrayBuffer?"ArrayBuffer":"SharedArrayBuffer",a=i||n.length>s,c=r!==""&&a?`[Uint8Contents]: <${r}>, `:"";return`${t.stylize(o,"special")} { ${c}byteLength: ${t.stylize(String(e.byteLength),"number")} }`},ic=/\d(?=(?:\d{3})+(?!\d))/g,xk=/\d{3}/g,$k=/_$/,gu=(e,t)=>{if(t.length<4||t.length===4&&t.codePointAt(0)===45||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY||t.includes("e"))return t;if(typeof e=="number"){const n=e<0?-Math.floor(-e):Math.floor(e);if(n!==e){const s=String(n),r=t.slice(s.length+1);return`${s.replace(ic,"$&_")}.${r.replace(xk,"$&_").replace($k,"")}`}}return t.replace(ic,"$&_")},Ek=e=>e>="\uD800"&&e<="\uDBFF",yt=(e,t,n="…")=>{e=String(e);const s=n.length,r=e.length;if(s>t&&r>s)return n;if(r>t&&r>s){let i=t-s;return i>0&&Ek(e[i-1])&&(i-=1),`${e.slice(0,i)}${n}`}return e},oc=(e,t)=>{let n=yt(e.toString(),t.truncate-1);return n!=="…"&&(n+="n"),t.stylize(t.numericSeparator?gu(e,n):n,"bigint")},yu=e=>{try{return Array.isArray(e)}catch{return!1}},$t=(e,t)=>{try{return e[t]}catch{return}},Ck=(e,t)=>{try{return e instanceof t}catch{return!1}},ac=(e,t)=>{try{return Object.getOwnPropertyDescriptor(e,t)?.enumerable??!1}catch{return!0}},Rk=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:void 0),Ps=(e,t,n,s)=>{if("window"in globalThis&&e===globalThis)return"{ [object Window] }";if(e===globalThis)return"{ [object globalThis] }";let r,i;try{r=Object.getOwnPropertyNames(e),i=Object.getOwnPropertySymbols(e)}catch{return qe}let o,a;try{o=t.showHidden?r:r.filter(f=>Object.getOwnPropertyDescriptor(e,f)?.enumerable)}catch{o=r.filter(f=>ac(e,f))}try{a=i.filter(f=>t.showHidden||Object.getOwnPropertyDescriptor(e,f)?.enumerable)}catch{a=i.filter(f=>ac(e,f))}let c;try{const f=Rk(e)===Object.prototype||e.constructor===Object,h=e instanceof Object?"":"null prototype";let m;!f&&Symbol.toStringTag in e?m=e[Symbol.toStringTag]:m=h?"Object":"",c=m||h?`[${[m,h].filter(Boolean).join(": ")}] `:""}catch{c=""}if(o.length===0&&a.length===0)return`${c}{}`;t.truncate-=4;const l=s?"\0\0":", ",d=Ie(o.map(f=>[f,es(e,f)]),e,t,n,Qn,l),u=Ie(a.map(f=>[f,es(e,f)]),e,t,n,Qn,l);let p="";return d&&u&&(p=l),s?`${c}{${mr(d+p+u,s)}}`:`${c}{ ${d}${p}${u} }`},jk=(e,t,n,s)=>{let r;try{r=typeof e.constructor=="function"?e.constructor.name:""}catch{r=""}return(!r||r==="_class")&&(r="<Anonymous Class>"),t.truncate-=r.length,`${r} ${Ps(e,t,n,s)}`},Tk=(e,t)=>{const n=t.stylize(String(e.byteLength),"number"),s=t.stylize(String(e.byteOffset),"number"),r=t.stylize(String(e.buffer.byteLength),"number");return`${t.stylize("DataView","special")} { byteLength: ${n}, byteOffset: ${s}, buffer: ArrayBuffer { byteLength: ${r} } }`},Ok=(e,t)=>{const n=e.toJSON();if(n===null)return"Invalid Date";const s=n.split("T"),r=s[0];return t.stylize(`${r}T${yt(s[1],t.truncate-r.length-1)}`,"date")},Ak=new Set(["column","columnNumber","description","fileName","line","lineNumber","message","name","number","stack"]),Ik=(e,t,n)=>{const s=Object.getOwnPropertyNames(e).filter(a=>!Ak.has(a)),{name:r}=e;t.truncate-=r.length;let i="";typeof e.message=="string"?i=yt(e.message,t.truncate):s.unshift("message"),i=i?`: ${i}`:"",t.truncate-=i.length+5;const o=Ie(s.map(a=>[a,es(e,a)]),e,t,n,Qn);return`${r}${i}${o?` { ${o} }`:""}`},cc=(e,t)=>{let n,s,r;try{n=e[Symbol.toStringTag]||"Function",s=e.toString(),{name:r}=e}catch{return t.stylize(qe,"special")}return s.length<t.truncate-12?t.stylize(`[${n}: ${s}]`,"special"):r?t.stylize(`[${n} ${yt(r,t.truncate-11)}]`,"special"):t.stylize(`[${n}]`,"special")},lc=(e,t)=>{const n=$t(e,Symbol.toStringTag),s=typeof n=="string"?n:"Generator";return`${t.stylize(`Object [${s}]`,"special")} {}`},Bk=([e,t],n,s,r)=>(s.truncate-=4,e=r(e,n,s),s.truncate-=e.length,`${e} => ${r(t,n,s)}`),Pk=(e,t,n,s)=>{if(e.size<=0)return"Map (0) {}";t.truncate-=7;let r=Ie([...e.entries()],e,t,n,Bk,s?"\0\0":", ",t.maxArrayLength);return s&&(r=mr(r,s)),`Map (${String(e.size)}) {${s?"":" "}${r}${s?"":" "}}`};function dc(e,t){return Number.isNaN(e)?t.stylize("NaN","number"):e===Number.POSITIVE_INFINITY?t.stylize("Infinity","number"):e===Number.NEGATIVE_INFINITY?t.stylize("-Infinity","number"):e===0?t.stylize(1/e===Number.POSITIVE_INFINITY?"+0":"-0","number"):t.stylize(yt(t.numericSeparator?gu(e,e.toString()):e.toString(),t.truncate),"number")}const Nk=()=>"Promise{…}",Dk=(e,t)=>{const n=t.truncate-(2+e.flags.length);return t.stylize(`/${yt(e.source,n)}/${e.flags}`,"regexp")},Mk=(e,t,n,s)=>{if(e.size===0)return"Set (0) {}";t.truncate-=7;let r=Ie([...e],e,t,n,void 0,s?"\0\0":", ",t.maxArrayLength);return s&&(r=mr(r,s)),`Set (${String(e.size)}) {${s?"":" "}${r}${s?"":" "}}`},Lk=(e,t)=>{const n=t.quoteStyle==="double"?'"':"'";return n+e+n},uc=new RegExp(String.raw`['\0-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5`+String.raw`\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]`,"g"),_k={" ":String.raw`\t`,"\n":String.raw`\n`,"\f":String.raw`\f`,"\r":String.raw`\r`,"\b":String.raw`\b`,"'":String.raw`\'`,"\\":"\\\\"},Fk=16,Vk=e=>_k[e]||String.raw`\u${`0000${e.codePointAt(0).toString(Fk)}`.slice(-4)}`,pc=(e,t)=>(uc.test(e)&&(e=e.replaceAll(uc,Vk)),t.stylize(Lk(yt(e,t.truncate-2),t),"string")),fc=e=>"description"in Symbol.prototype?e.description?`Symbol(${e.description})`:"Symbol()":e.toString(),Wk=e=>typeof Buffer=="function"&&e instanceof Buffer?"Buffer":e[Symbol.toStringTag],Fe=(e,t,n)=>{const s=Wk(e);t.truncate-=s.length+4;const r=Object.keys(e).slice(e.length);if(e.length===0&&r.length===0)return`${s}[]`;let i="";const o=Number.isFinite(t.maxArrayLength)?Math.min(e.length,Math.max(0,Math.floor(t.maxArrayLength))):e.length;for(let c=0;c<o;c++){const l=`${t.stylize(yt(e[c],t.truncate),"number")}${c===o-1?"":", "}`;if(t.truncate-=l.length,c!==o-1&&t.truncate<=3){i+=`…(${String(e.length-c)})`;break}i+=l}o<e.length&&(i+=`${i?", ":""}… ${String(e.length-o)} more`);let a="";return r.length>0&&(a=Ie(r.map(c=>[c,es(e,c)]),e,t,n,Qn)),`${s}[ ${i}${a?`, ${a}`:""} ]`},hc=e=>typeof $t(e,Symbol.toStringTag)!="string",Hk=e=>typeof e=="function",vu=(e,t,n)=>{if(e==null)return;const s=Object.getOwnPropertyDescriptor(e,t);if(s===void 0)return;const r=n==="get"?s.get:s.value;return typeof r=="function"?r:void 0},bu=(e,t)=>{if(e!==void 0)return n=>{try{return e.call(n,t),!0}catch{return!1}}},kt=(e,t)=>bu(vu(e,t,"get")),Xe=(e,t,n)=>bu(vu(e,t,"value"),n),mc=Object.freeze({}),Ve=kt(Reflect.getPrototypeOf(Int8Array.prototype),"length"),Uk=typeof SharedArrayBuffer=="function"?SharedArrayBuffer.prototype:void 0,Gk=Object.assign(Object.create(null),{Arguments:hc,Array:yu,ArrayBuffer:kt(ArrayBuffer.prototype,"byteLength"),BigInt:Xe(BigInt.prototype,"valueOf"),Boolean:Xe(Boolean.prototype,"valueOf"),DataView:kt(DataView.prototype,"byteLength"),Date:Xe(Date.prototype,"valueOf"),Error:hc,Float32Array:Ve,Float64Array:Ve,Function:Hk,Int8Array:Ve,Int16Array:Ve,Int32Array:Ve,Map:kt(Map.prototype,"size"),Number:Xe(Number.prototype,"valueOf"),RegExp:kt(RegExp.prototype,"source"),Set:kt(Set.prototype,"size"),SharedArrayBuffer:kt(Uk,"byteLength"),String:Xe(String.prototype,"valueOf"),Symbol:Xe(Symbol.prototype,"valueOf"),Uint8Array:Ve,Uint8ClampedArray:Ve,Uint16Array:Ve,Uint32Array:Ve,WeakMap:Xe(WeakMap.prototype,"has",mc),WeakSet:Xe(WeakSet.prototype,"has",mc)}),zk=(e,t)=>{const n=Gk[t];return n===void 0||n(e)},gc=new WeakMap,yc=Object.create(null),Jk=Object.assign(Object.create(null),{Arguments:fk,Array:kk,ArrayBuffer:rc,AsyncGenerator:lc,BigInt:oc,bigint:oc,Boolean:(e,t)=>t.stylize(String(e),"boolean"),boolean:(e,t)=>t.stylize(String(e),"boolean"),DataView:Tk,Date:Ok,Error:Ik,Float32Array:Fe,Float64Array:Fe,Function:cc,function:cc,Generator:lc,HTMLCollection:Ai,Int8Array:Fe,Int16Array:Fe,Int32Array:Fe,Map:Pk,NodeList:Ai,null:(e,t)=>t.stylize("null","null"),Number:dc,number:dc,Promise:Nk,RegExp:Dk,Set:Mk,SharedArrayBuffer:rc,String:pc,string:pc,Symbol:fc,symbol:fc,Uint8Array:Fe,Uint8ClampedArray:Fe,Uint16Array:Fe,Uint32Array:Fe,undefined:(e,t)=>t.stylize("undefined","undefined"),WeakMap:(e,t)=>t.stylize("WeakMap{…}","special"),WeakSet:(e,t)=>t.stylize("WeakSet{…}","special")}),qk=Symbol.for("nodejs.util.inspect.custom"),Kk=Symbol.for("chai/inspect"),Yk=(e,t,n,s)=>{const r=$t(e,Kk);if(typeof r=="function")return r.call(e,t);if(!("window"in globalThis)){const c=$t(e,qk);if(typeof c=="function")return c.call(e,s,t)}const i=$t(e,"inspect");if(typeof i=="function")return i.call(e,s,t);const o=$t(e,"constructor");if(typeof o=="function"&&gc.has(o))return gc.get(o)?.(e,t)??"unknown";const a=Object.hasOwn(yc,n)?yc[n]:void 0;return a?a(e,t):""},Fr=(e,t,n)=>{const{depth:s,inspect:r,seen:i}=n;if(i.includes(e))return"[Circular]";if(s>=t.depth&&t.depth>0&&typeof e=="object"&&e!==null)return yu(e)?"[Array]":"[Object]";const o=t.indent?hk(t.indent,s):void 0;let a=e===null?"null":typeof e;if(a==="object")try{a=Object.prototype.toString.call(e).slice(8,-1)}catch{a="Object"}let c=Jk[a];if(c!==void 0&&typeof e=="object"&&e!==null&&!zk(e,a)&&(c=void 0),c!==void 0)return c(e,t,r,o);if(t.customInspect&&e){const u=Yk(e,t,a,t.depth-s);if(u)return typeof u=="string"?u:r(u,e,t)}let l=!1;if(e)try{l=Object.getPrototypeOf(e)}catch{l=Object.prototype}if(l===Object.prototype||l===null)return Ps(e,t,r,o);if(e&&typeof HTMLElement=="function"&&Ck(e,HTMLElement))return mu(e,e,t,r);const d=$t(e,"constructor");return d!==void 0?d!==Object?jk(e,t,r,o):Ps(e,t,r,o):e===Object(e)?Ps(e,t,r,o):t.stylize(String(e),a)},Js=(e,t={})=>{const n={customInspect:!0,depth:5,indent:void 0,maxArrayLength:Number.POSITIVE_INFINITY,numericSeparator:!0,quoteStyle:"single",showHidden:!1,stylize:r=>r,truncate:Number.POSITIVE_INFINITY,...t};if(n.indent!==void 0&&n.indent!==" "&&!(Number.parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `undefined`');const s={depth:0,inspect:void 0,seen:[]};return s.inspect=(r,i,o)=>{if(i==null){s.depth+=1;const c=Fr(r,o,s);return s.depth-=1,c}s.seen.push(i),s.depth+=1;const a=Fr(r,o,s);return s.depth-=1,s.seen.pop(),a},Fr(e,n,s)},Xk=new Set(["alert","critical","emergency","error","trace","warning"]),wu=e=>Xk.has(e),ku=(e,t)=>t?(t.__write??t.write.bind(t)).call(t,e):!1,Zk=globalThis.process??Object.create(null),vc={versions:{}},ts=new Proxy(Zk,{get(e,t){if(t in e)return e[t];if(t in vc)return vc[t]}}),gr=e=>{let t;return()=>{if(t===void 0){if(typeof ts.getBuiltinModule!="function")throw new TypeError(`[@visulima/error] Cannot load ${e}: this runtime implements no process.getBuiltinModule(). Requires Node ^22.14.0 || >=24.10.0, or another runtime providing process.getBuiltinModule().`);t=ts.getBuiltinModule(e)}return t}},Qk=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
130
|
+
`),e1=(e,t,n,s)=>{const r={column:0,line:-1,...e.start},i={...r,...e.end},o=r.line,a=r.column,c=i.line,l=i.column;let d=Math.max(o-(n+1),0),u=Math.min(t.length,c+s);o===-1&&(d=0),c===-1&&(u=t.length);const p=c-o,f={};if(p)for(let h=0;h<=p;h++){const m=h+o;if(!a)f[m]=!0;else if(h===0){const v=t[m-1]?.length;f[m]=[a,(v??0)-a+1]}else if(h===p)f[m]=[0,l];else{const v=t[m-h]?.length;f[m]=[0,v]}}else a===l?f[o]=a?[a,0]:!0:f[o]=[a,(l??0)-(a??0)];return{end:u,markerLines:f,start:d}},t1=ts.platform==="win32"&&!ts.env?.WT_SESSION?">":"❯",n1=(e,t,n)=>{const s={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...n,color:{gutter:h=>h,marker:h=>h,message:h=>h,...n?.color}},r=typeof t.start.column=="number";let i=(e.includes("\r")?Qk(e):e).split(`
|
|
131
|
+
`);typeof s.tabWidth=="number"&&e.includes(" ")&&(i=i.map(h=>h.replaceAll(" "," ".repeat(s.tabWidth))));const{end:o,markerLines:a,start:c}=e1(t,i,s.linesAbove,s.linesBelow),l=String(o).length,{gutter:d,marker:u,message:p}=s.color;let f=i.slice(c,o).map((h,m)=>{const v=c+1+m,$=a[v],b=String(v).padStart(l),S=!a[v+1],C=` ${b}${s.showGutter?" |":""}`;if($){let P="";if(Array.isArray($)){const T=h.replaceAll(/[^\t]/g," ").slice(0,Math.max($[0]-1,0)),N=$[1]||1;P=[`
|
|
132
|
+
`,s.prefix+d(C.replaceAll(/\d/g," "))," ",T,u("^").repeat(N)].join(""),S&&s.message&&(P+=` ${p(s.message)}`)}return[s.prefix+u(t1),d(C),h.length>0?` ${h}`:"",P].join("")}return`${s.prefix} ${d(C)}${h.length>0?` ${h}`:""}`}).join(`
|
|
133
|
+
`);return s.message&&!r&&(f=`${s.prefix+" ".repeat(l+1)+s.message}
|
|
134
|
+
${f}`),f},s1=()=>ts.env?.DEBUG==="true",It=(e,...t)=>{if(s1()){const n=t.map(s=>typeof s=="function"?s():s);console.debug(`error:parse-stacktrace: ${e}`,...n)}},Bt="<unknown>",r1=/^(?:node:internal\/|node:|internal\/)/,i1=e=>e!==void 0&&r1.test(e),o1=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,a1=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,c1=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,l1=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,d1=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,u1=/in\s(.*)\s\(at\s(.+)\)\sat/,p1=/^(?:.*@)?(.*):(\d+):(\d+)$/,f1=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,h1=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,m1=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,bc=/\(error: ([^)]*)\)/,g1=/at\s/,y1=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,v1=/Error: |AggregateError:/,Su=/^Anonymous function$/,b1=/^\s*in\s.*/,w1=/^.*?\s*at\s.*/,k1=/^.*?\s*@.*|\[native code\]/,xu=(e,t)=>{const n=e.includes("safari-extension"),s=e.includes("safari-web-extension");return n||s?[e.includes("@")?e.split("@")[0]:Bt,n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},$u=(e,t)=>{const n=c1.exec(t);n&&(e.file=n[1],e.line=+n[2],e.column=+n[3])},S1=e=>{const t=u1.exec(e);if(t){It(`parse nested node error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const s=t[2].split(":");return{column:s[2]?+s[2]:void 0,file:s[0],line:s[1]?+s[1]:void 0,methodName:t[1]??Bt,raw:e,type:void 0}}const n=d1.exec(e);if(n){It(`parse node error stack line: "${e}"`,()=>`found: ${JSON.stringify(n)}`);const s={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(g1,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]??Bt,raw:e,type:e.startsWith("internal")?"internal":void 0};return $u(s,`${n[2]}:${n[3]}:${n[4]}`),s}},x1=e=>{const t=o1.exec(e);if(t){It(`parse chrome error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const n=t[2]?.startsWith("native"),s=t[2]?.startsWith("eval")||t[1]?.startsWith("eval");let r,i;if(s){const l=a1.exec(e);if(l){const d=y1.exec(l[1]);d?(t[2]=d[4]??d[1],t[3]=d[5]??d[2],t[4]=d[3]):l[2]&&(t[2]=l[1]),l[2]&&(r={column:l[4]?+l[4]:void 0,file:l[2],line:l[3]?+l[3]:void 0,methodName:"eval",raw:e,type:"eval"})}else{const d=l1.exec(e);d&&(i={column:d[4]?+d[4]:void 0,file:d[2],line:d[3]?+d[3]:void 0},r={column:d[6]?+d[6]:void 0,file:d[1],line:d[5]?+d[5]:void 0,methodName:"eval",raw:d[0],type:"eval"})}}const[o,a]=xu(t[1]?t[1].replace(Su,"<anonymous>"):Bt,t[2]),c={column:t[4]?+t[4]:void 0,evalOrigin:r,file:a,line:t[3]?+t[3]:void 0,methodName:o,raw:e,type:s?"eval":n?"native":i1(a)?"internal":void 0};return i?(c.column=i.column,c.file=i.file,c.line=i.line):$u(c,`${a}:${t[3]}:${t[4]}`),c}},$1=(e,t)=>{const n=f1.exec(e);if(n){It(`parse gecko error stack line: "${e}"`,()=>`found: ${JSON.stringify(n)}`);const s=n[3]?.includes(" > eval"),r=s&&n[3]&&h1.exec(n[3]);let i;s&&r&&(n[3]=r[1],i={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:e,type:"eval"},n[4]=r[2]);const[o,a]=xu(n[1]?n[1].replace(Su,"<anonymous>"):Bt,n[3]);let c;(t?.type==="safari"||!s&&t?.type==="firefox")&&t.column?c=t.column:!s&&n[5]&&(c=+n[5]);let l;return(t?.type==="safari"||!s&&t?.type==="firefox")&&t.line?l=t.line:n[4]&&(l=+n[4]),{column:c,evalOrigin:i,file:a,line:l,methodName:o,raw:e,type:s?"eval":a.includes("[native code]")?"native":void 0}}},E1=(e,t)=>{const n=m1.exec(e);if(!(n&&n[2].includes(" > eval"))&&n)return It(`parse firefox error stack line: "${e}"`,()=>`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:t?.column??void 0,file:n[2],line:n[3]?+n[3]:t?.line??void 0,methodName:n[1]||Bt,raw:e,type:void 0}},C1=e=>{const t=p1.exec(e);if(t)return It(`parse react android native error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`),{column:t[3]?+t[3]:void 0,file:t[1],line:t[2]?+t[2]:void 0,methodName:Bt,raw:e,type:void 0}},Eu=(e,{filter:t,frameLimit:n=50}={})=>{const s=e;let r=(typeof s.stacktrace=="string"?s.stacktrace:e.stack??"").split(`
|
|
135
|
+
`).map(i=>(bc.test(i)?i.replace(bc,"$1"):i).trim()).filter(i=>!v1.test(i)&&i!=="eval code");return t&&(r=r.filter(i=>t(i))),r=r.slice(0,n),r.reduce((i,o,a)=>{if(!o||o.length>1024)return i;let c;if(b1.test(o))c=S1(o);else if(w1.test(o))c=x1(o);else if(k1.test(o)){let l;if(a===0){const d=e,u=d.columnNumber,p=d.lineNumber,f=d.line,h=d.column;u||p?l={column:u,line:p,type:"firefox"}:(f||h)&&(l={column:h,line:f,type:"safari"})}c=E1(o,l)??$1(o,l)}else c=C1(o);return c?i.push(c):It(`parse error stack line: "${o}"`,"not parser found"),i},[])},wc=gr("node:fs"),Ns=gr("node:path"),R1=gr("node:process"),j1=gr("node:url"),ot=(e,t,n)=>n===0?e:t===" "?e+" ".repeat(n):e+" ".repeat(t*n),Cu=e=>e.replaceAll("\\","/"),T1=e=>{if(!e.startsWith("file:"))return e;try{return j1().fileURLToPath(e)}catch{return e}},O1=(e,t)=>{const n=e.replace("async file:","file:");return Cu(Ns().relative(t,T1(n)))},A1=(e,t,n)=>{if(t)return n.title(e.message);const s=e.message?`: ${e.message}`:"";return n.title(e.name+s)},Ru=(e,{color:t,hideErrorTitle:n,indentation:s,prefix:r},i)=>`${ot(r,s,i)}${A1(e,n,t)}
|
|
136
|
+
`,ju=(e,{color:t,indentation:n,prefix:s},r)=>{if(e.hint===void 0)return;const i=ot(s,n,r);let o="";if(Array.isArray(e.hint))for(const a of e.hint)o+=`${i+a}
|
|
137
|
+
`;else o+=i+e.hint;return t.hint(o)},So=(e,t)=>{if(!t||e.file===void 0||e.line===void 0)return{trace:e};try{const n=t({column:e.column,file:e.file,line:e.line});return n?{source:n.source,trace:{...e,column:n.column??e.column,file:n.file??e.file,line:n.line??e.line}}:{trace:e}}catch{return{trace:e}}},xo=(e,t,n=0)=>{const{color:s,cwd:r,displayShortPath:i,indentation:o,prefix:a}=t,{trace:c}=e;let l;c.file===void 0?l="<unknown>":l=i?O1(c.file,r):Cu(c.file);const{fileLine:d,method:u}=s;return`${ot(a,o,n)}at ${c.methodName?`${u(c.methodName)} `:""}${d(l)}:${d(c.line?.toString()??"")}`},I1=(e,t)=>{if(t.allowAllFilePaths)return!0;const n=Ns().resolve(t.cwd),s=Ns().resolve(n,e);return s===n||s.startsWith(n+Ns().sep)},B1=e=>{try{return wc().existsSync(e)?wc().readFileSync(e,"utf8"):void 0}catch{return}},Tu=(e,t,n)=>{const{color:s,indentation:r,linesAbove:i,linesBelow:o,prefix:a,showGutter:c,showLineNumbers:l,tabWidth:d}=t,{source:u,trace:p}=e;if(p.file===void 0)return;let f;if(u===void 0){const h=p.file.replace("file://","");if(!I1(h,t))return;const m=B1(h);if(m===void 0)return;f=m}else f=u;return n1(f,{start:{column:p.column,line:p.line}},{color:s,linesAbove:i,linesBelow:o,prefix:ot(a,r,n),showGutter:c,showLineNumbers:l,tabWidth:d})},Ou=(e,t,n)=>{if(e.errors.length===0)return;let s=`${ot(t.prefix,t.indentation,n)}Errors:
|
|
140
138
|
|
|
141
|
-
`,
|
|
139
|
+
`,r=!0;for(const i of e.errors)r?r=!1:s+=`
|
|
142
140
|
|
|
143
|
-
`,s+=
|
|
144
|
-
${s}`},
|
|
141
|
+
`,s+=Iu(i,{...t,framesMaxLimit:1,hideErrorCodeView:t.hideErrorErrorsCodeView},n+1);return`
|
|
142
|
+
${s}`},P1=e=>{if(typeof e=="object"&&e!==null)try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}return String(e)},Au=(e,t,n,s=new Set)=>{s.add(e);let r=`${ot(t.prefix,t.indentation,n)}Caused by:
|
|
145
143
|
|
|
146
|
-
`;const{cause:
|
|
144
|
+
`;const{cause:i}=e;if(!(i instanceof Error)){const c=P1(i);return r+=`${ot(t.prefix,t.indentation,n)}${t.color.title(c)}
|
|
147
145
|
`,`
|
|
148
|
-
${
|
|
149
|
-
`),o){const c=
|
|
150
|
-
${l}`)}}if(
|
|
151
|
-
${c}`)}return
|
|
146
|
+
${r}`}r+=Ru(i,t,n);const o=Eu(i).shift(),a=ju(i,t,n);if(a&&(r+=`${a}
|
|
147
|
+
`),o){const c=So(o,t.sourceMap);if(r+=xo(c,t,n),!t.hideErrorCauseCodeView){const l=Tu(c,t,n);l!==void 0&&(r+=`
|
|
148
|
+
${l}`)}}if(i instanceof AggregateError){const c=Ou(i,t,n);c!==void 0&&(r+=`
|
|
149
|
+
${c}`)}return i.cause&&(r+=s.has(i)?`
|
|
152
150
|
${ot(t.prefix,t.indentation,n+1)}Caused by: [Circular]`:`
|
|
153
|
-
${
|
|
154
|
-
${
|
|
155
|
-
`:"")+e.map(n=>
|
|
156
|
-
`),
|
|
157
|
-
`)},_i=(e,t={})=>{if(t.framesMaxLimit!==void 0&&t.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return Eu(e,t,0)},pS=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],fS=12288,hS=65510,mS=[12288,12288,65281,65376,65504,65510],gS=8361,yS=65518,vS=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],bS=32,wS=10630,kS=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],SS=4352,xS=262141,Cu=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],cs=(e,t)=>{let n=0,s=Math.floor(e.length/2)-1;for(;n<=s;){const i=Math.floor((n+s)/2),r=i*2;if(t<e[r])s=i-1;else if(t>e[r+1])n=i+1;else return!0}return!1},gc=19968,[$S,ES]=CS(Cu);function CS(e){let t=e[0],n=e[1];for(let s=0;s<e.length;s+=2){const i=e[s],r=e[s+1];if(gc>=i&&gc<=r)return[i,r];r-i>n-t&&(t=i,n=r)}return[t,n]}const RS=e=>e<161||e>1114109?!1:cs(pS,e),jS=e=>e<fS||e>hS?!1:cs(mS,e),TS=e=>e<gS||e>yS?!1:cs(vS,e),OS=e=>e<bS||e>wS?!1:cs(kS,e),AS=e=>e>=$S&&e<=ES?!0:e<SS||e>xS?!1:cs(Cu,e);function IS(e){return RS(e)?"ambiguous":jS(e)?"fullwidth":TS(e)?"halfwidth":OS(e)?"narrow":AS(e)?"wide":"neutral"}function BS(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ru(e){return BS(e),IS(e)}const ju=String.raw,yc=ju`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,PS=()=>new RegExp(ju`\p{RI}{2}|(?)${yc}(?:\u200D${yc})*`,"gu"),kn=new Set(["\x1B",""]),mi="\x07",Tu="[",wo="m",ts="]8;;",NS=39,DS=/[\u200B\uFEFF\u2060-\u2064]/g,MS=new RegExp(`(?:\\${Tu}(?<code>\\d+)m|\\${ts}(?<uri>.*)${mi})`),LS=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),Ou=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,xs=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,_S=PS(),vc=new Map,FS=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),VS=e=>{const t=FS(e.width);let n=vc.get(t);return n||(n=new Map,vc.set(t,n)),n},$s=new RegExp(Ou.source,"y"),Fi=new RegExp(_S.source,"uy"),Es=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Au=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",HS=(e,t)=>{const n=VS(t),s=Math.floor(e/65536),i=e%65536;let r=n.get(s);if(r||(r=new Map,n.set(s,r)),r.has(i))return r.get(i);let o;switch(Au(e)){case"control":{o=t.width.control;break}case"latin":{o=t.width.regular;break}case"wide":{o=t.width.wide;break}case"zero":{o=0;break}default:switch(Ru(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}}return r.set(i,o),o},WS=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,Or=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Or(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},s=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:i}=e,r=i>1e4;let o=0,a=0,c=i,l=!1;const d=e.includes("\x1B")||e.includes("");for(;o<i;){if(d&&(e[o]==="\x1B"||e[o]==="")){if(e.startsWith("\x1B]8;;",o)){const b="\x1B]8;;\x07",$=b.length,v=e.indexOf("\x07",o+5);if(v!==-1){const S=e.indexOf(b,v+1);if(S!==-1){const C=S+$,P=e.slice(v+1,S).replace(Ou,""),j=Or(P,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,s-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),B=j.width;if(j.truncated)l=!0,c=Math.min(c,o);else if(a+B>s&&(c=Math.min(c,o),l=!0,a+B>n.truncation.limit))break;if(a+=B,o=C,l&&a>=n.truncation.limit)break;continue}}}if($s.lastIndex=o,$s.test(e)){const b=$s.lastIndex-o,$=n.truncation.countAnsiEscapeCodes?b:n.width.ansi;if(a+$>s&&(c=Math.min(c,o),a+$>n.truncation.limit)){l=!0;break}a+=$,o=$s.lastIndex;continue}}const f=e.codePointAt(o);if(f===8203||f===65279||f>=8288&&f<=8292){o+=1;continue}if(f===9){if(a+n.width.tab>s&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(Es.lastIndex=o,Es.test(e)){const b=(Es.lastIndex-o)*n.width.regular;if(a+b>s){const $=n.width.regular>0?Math.floor((s-a)/n.width.regular):0;if(c=Math.min(c,o+$),a+b>n.truncation.limit){l=!0;break}}a+=b,o=Es.lastIndex;continue}if((f<=31||f>=127&&f<=159)&&(xs.lastIndex=o,xs.test(e))){const b=(xs.lastIndex-o)*n.width.control;if(a+b>s){const $=n.width.control>0?Math.floor((s-a)/n.width.control):0;if(c=Math.min(c,o+$),a+b>n.truncation.limit){l=!0;break}}a+=b,o=xs.lastIndex;continue}if(Fi.lastIndex=o,Fi.test(e)){if(a+n.width.emoji>s&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=Fi.lastIndex;continue}const h=e.codePointAt(o)??0;if(WS(h)){o+=h>65535?2:1;continue}let m;if(r)m=HS(h,n);else switch(Au(h)){case"control":{m=n.width.control;break}case"latin":{m=n.width.regular;break}case"wide":{m=n.width.wide;break}case"zero":{m=0;break}default:switch(Ru(h)){case"ambiguous":{m=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{m=n.width.fullWidth;break}case"wide":{m=n.width.wide;break}default:m=n.width.regular}}if(a+m>s&&(c=Math.min(c,o),a+m>n.truncation.limit)){l=!0;break}a+=m,o+=h>65535?2:1}let u=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(u=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:i,truncated:l,width:u}},je=(e,t={})=>Or(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,US=/\x1B\[(\d+)m/;let Iu=class{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const n=US.exec(t);if(!n)return;const s=Number.parseInt(n[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=t;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(s)){const i={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];i&&(this.activeFormatting=this.activeFormatting.filter(r=>!r.includes(i)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const n={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const i=n[s];i&&t.push(i)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};const GS=(e,t)=>{if(!kn.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const n=!0,s=e.slice(t+1,t+1+ts.length).join("")===ts;return{isInsideEscape:n,isInsideLinkEscape:s}},zS=(e,t={})=>{const n=new Iu;let s="",i=!1,r="",o="",a=!1;const c=[...e];for(let l=0;l<c.length;l++){const d=c[l];if(d&&kn.has(d)){if(s){const m=t.getWidth?.(s)??0,b={isEscapeSequence:!1,isGrapheme:!0,text:s,width:m};if(a&&(b.isHyperlink=!0,b.hyperlinkUrl=o),t.onSegment?.(b,n)===!1)return;s=""}i=!0,r=d;const f=GS(c,l),{isInsideLinkEscape:h}=f;if(h){let m=l+1;for(o="";m<c.length;){const $=c[m];if($===mi)break;o+=$,m+=1}o=o.slice(4);const b={hyperlinkUrl:o,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(b,n)===!1)return;l=m,a=!0,i=!1,r="";continue}if(l+1<c.length&&c[l+1]==="\\"&&a){const m={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(m,n)===!1)return;a=!1,o="",l+=1,i=!1,r="";continue}}if(i){if(r!==d&&(r+=d),d===wo){i=!1,n.processEscape(r);const f={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};if(t.onSegment?.(f,n)===!1)return;r=""}continue}s+=d;const u=t.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};if(a&&(p.isHyperlink=!0,p.hyperlinkUrl=o),t.onSegment?.(p,n)===!1)return;s=""}if(s){const l=t.getWidth?.(s)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:s,width:l};a&&(d.isHyperlink=!0,d.hyperlinkUrl=o),t.onSegment?.(d,n)}if(r){const l={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};t.onSegment?.(l,n)}},bc=e=>`${kn.values().next().value}${Tu}${String(e)}${wo}`,wc=e=>`${kn.values().next().value}${ts}${e}${mi}`,JS=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",n,s;const i=e.join(`
|
|
158
|
-
`),
|
|
159
|
-
`?(s&&(t+=
|
|
160
|
-
`&&(n&&l&&(t
|
|
151
|
+
${Au(i,t,n+1,s)}`),`
|
|
152
|
+
${r}`},N1=(e,t)=>(e.length>0?`
|
|
153
|
+
`:"")+e.map(n=>xo(So(n,t.sourceMap),t)).join(`
|
|
154
|
+
`),Iu=(e,t,n)=>{const s={allowAllFilePaths:!1,cwd:R1().cwd(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:a=>a,gutter:a=>a,hint:a=>a,marker:a=>a,message:a=>a,method:a=>a,title:a=>a,...t.color}},r=Eu(e,{filter:t.filterStacktrace,frameLimit:s.framesMaxLimit}),i=r.shift(),o=i?So(i,s.sourceMap):void 0;return[t.hideMessage?void 0:Ru(e,s,n),ju(e,s,n),o?xo(o,s,n):void 0,o&&!s.hideErrorCodeView?Tu(o,s,n):void 0,e instanceof AggregateError?Ou(e,s,n):void 0,e.cause===void 0||e.cause===null?void 0:Au(e,s,n),r.length>0?N1(r,s):void 0].filter(Boolean).join(`
|
|
155
|
+
`)},Vr=(e,t={})=>{if(t.framesMaxLimit!==void 0&&t.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return Iu(e,t,0)},D1=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],M1=12288,L1=65510,_1=[12288,12288,65281,65376,65504,65510],F1=8361,V1=65518,W1=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],H1=32,U1=10630,G1=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],z1=4352,J1=262141,Bu=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],ls=(e,t)=>{let n=0,s=Math.floor(e.length/2)-1;for(;n<=s;){const r=Math.floor((n+s)/2),i=r*2;if(t<e[i])s=r-1;else if(t>e[i+1])n=r+1;else return!0}return!1},kc=19968,[q1,K1]=Y1(Bu);function Y1(e){let t=e[0],n=e[1];for(let s=0;s<e.length;s+=2){const r=e[s],i=e[s+1];if(kc>=r&&kc<=i)return[r,i];i-r>n-t&&(t=r,n=i)}return[t,n]}const X1=e=>e<161||e>1114109?!1:ls(D1,e),Z1=e=>e<M1||e>L1?!1:ls(_1,e),Q1=e=>e<F1||e>V1?!1:ls(W1,e),eS=e=>e<H1||e>U1?!1:ls(G1,e),tS=e=>e>=q1&&e<=K1?!0:e<z1||e>J1?!1:ls(Bu,e);function nS(e){return X1(e)?"ambiguous":Z1(e)?"fullwidth":Q1(e)?"halfwidth":eS(e)?"narrow":tS(e)?"wide":"neutral"}function sS(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Pu(e){return sS(e),nS(e)}const Nu=String.raw,Sc=Nu`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,rS=()=>new RegExp(Nu`\p{RI}{2}|(?)${Sc}(?:\u200D${Sc})*`,"gu"),kn=new Set(["\x1B",""]),yr="\x07",Du="[",$o="m",ns="]8;;",iS=39,oS=/[\u200B\uFEFF\u2060-\u2064]/g,aS=new RegExp(`(?:\\${Du}(?<code>\\d+)m|\\${ns}(?<uri>.*)${yr})`),cS=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),Mu=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,xs=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,lS=rS(),xc=new Map,dS=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),uS=e=>{const t=dS(e.width);let n=xc.get(t);return n||(n=new Map,xc.set(t,n)),n},$s=new RegExp(Mu.source,"y"),Wr=new RegExp(lS.source,"uy"),Es=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Lu=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",pS=(e,t)=>{const n=uS(t),s=Math.floor(e/65536),r=e%65536;let i=n.get(s);if(i||(i=new Map,n.set(s,i)),i.has(r))return i.get(r);let o;switch(Lu(e)){case"control":{o=t.width.control;break}case"latin":{o=t.width.regular;break}case"wide":{o=t.width.wide;break}case"zero":{o=0;break}default:switch(Pu(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}}return i.set(r,o),o},fS=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,Ii=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Ii(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},s=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:r}=e,i=r>1e4;let o=0,a=0,c=r,l=!1;const d=e.includes("\x1B")||e.includes("");for(;o<r;){if(d&&(e[o]==="\x1B"||e[o]==="")){if(e.startsWith("\x1B]8;;",o)){const v="\x1B]8;;\x07",$=v.length,b=e.indexOf("\x07",o+5);if(b!==-1){const S=e.indexOf(v,b+1);if(S!==-1){const C=S+$,P=e.slice(b+1,S).replace(Mu,""),T=Ii(P,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,s-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),N=T.width;if(T.truncated)l=!0,c=Math.min(c,o);else if(a+N>s&&(c=Math.min(c,o),l=!0,a+N>n.truncation.limit))break;if(a+=N,o=C,l&&a>=n.truncation.limit)break;continue}}}if($s.lastIndex=o,$s.test(e)){const v=$s.lastIndex-o,$=n.truncation.countAnsiEscapeCodes?v:n.width.ansi;if(a+$>s&&(c=Math.min(c,o),a+$>n.truncation.limit)){l=!0;break}a+=$,o=$s.lastIndex;continue}}const f=e.codePointAt(o);if(f===8203||f===65279||f>=8288&&f<=8292){o+=1;continue}if(f===9){if(a+n.width.tab>s&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(Es.lastIndex=o,Es.test(e)){const v=(Es.lastIndex-o)*n.width.regular;if(a+v>s){const $=n.width.regular>0?Math.floor((s-a)/n.width.regular):0;if(c=Math.min(c,o+$),a+v>n.truncation.limit){l=!0;break}}a+=v,o=Es.lastIndex;continue}if((f<=31||f>=127&&f<=159)&&(xs.lastIndex=o,xs.test(e))){const v=(xs.lastIndex-o)*n.width.control;if(a+v>s){const $=n.width.control>0?Math.floor((s-a)/n.width.control):0;if(c=Math.min(c,o+$),a+v>n.truncation.limit){l=!0;break}}a+=v,o=xs.lastIndex;continue}if(Wr.lastIndex=o,Wr.test(e)){if(a+n.width.emoji>s&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=Wr.lastIndex;continue}const h=e.codePointAt(o)??0;if(fS(h)){o+=h>65535?2:1;continue}let m;if(i)m=pS(h,n);else switch(Lu(h)){case"control":{m=n.width.control;break}case"latin":{m=n.width.regular;break}case"wide":{m=n.width.wide;break}case"zero":{m=0;break}default:switch(Pu(h)){case"ambiguous":{m=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{m=n.width.fullWidth;break}case"wide":{m=n.width.wide;break}default:m=n.width.regular}}if(a+m>s&&(c=Math.min(c,o),a+m>n.truncation.limit)){l=!0;break}a+=m,o+=h>65535?2:1}let u=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(u=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:r,truncated:l,width:u}},je=(e,t={})=>Ii(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,hS=/\x1B\[(\d+)m/;let _u=class{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const n=hS.exec(t);if(!n)return;const s=Number.parseInt(n[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=t;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(s)){const r={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];r&&(this.activeFormatting=this.activeFormatting.filter(i=>!i.includes(r)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const n={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const r=n[s];r&&t.push(r)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};const mS=(e,t)=>{if(!kn.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const n=!0,s=e.slice(t+1,t+1+ns.length).join("")===ns;return{isInsideEscape:n,isInsideLinkEscape:s}},gS=(e,t={})=>{const n=new _u;let s="",r=!1,i="",o="",a=!1;const c=[...e];for(let l=0;l<c.length;l++){const d=c[l];if(d&&kn.has(d)){if(s){const m=t.getWidth?.(s)??0,v={isEscapeSequence:!1,isGrapheme:!0,text:s,width:m};if(a&&(v.isHyperlink=!0,v.hyperlinkUrl=o),t.onSegment?.(v,n)===!1)return;s=""}r=!0,i=d;const f=mS(c,l),{isInsideLinkEscape:h}=f;if(h){let m=l+1;for(o="";m<c.length;){const $=c[m];if($===yr)break;o+=$,m+=1}o=o.slice(4);const v={hyperlinkUrl:o,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(v,n)===!1)return;l=m,a=!0,r=!1,i="";continue}if(l+1<c.length&&c[l+1]==="\\"&&a){const m={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(m,n)===!1)return;a=!1,o="",l+=1,r=!1,i="";continue}}if(r){if(i!==d&&(i+=d),d===$o){r=!1,n.processEscape(i);const f={isEscapeSequence:!0,isGrapheme:!1,text:i,width:0};if(t.onSegment?.(f,n)===!1)return;i=""}continue}s+=d;const u=t.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};if(a&&(p.isHyperlink=!0,p.hyperlinkUrl=o),t.onSegment?.(p,n)===!1)return;s=""}if(s){const l=t.getWidth?.(s)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:s,width:l};a&&(d.isHyperlink=!0,d.hyperlinkUrl=o),t.onSegment?.(d,n)}if(i){const l={isEscapeSequence:!0,isGrapheme:!1,text:i,width:0};t.onSegment?.(l,n)}},$c=e=>`${kn.values().next().value}${Du}${String(e)}${$o}`,Ec=e=>`${kn.values().next().value}${ns}${e}${yr}`,yS=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",n,s;const r=e.join(`
|
|
156
|
+
`),i=[...r];let o=0;for(const[a,c]of i.entries()){if(t+=c,kn.has(c)){const d=aS.exec(r.slice(o))?.groups??{};if(d.code!==void 0){const u=Number.parseFloat(d.code);n=u===iS?void 0:u}else d.uri!==void 0&&(s=d.uri.length===0?void 0:d.uri)}const l=cS.get(Number(n));i[a+1]===`
|
|
157
|
+
`?(s&&(t+=Ec("")),n&&l&&(t+=$c(l))):c===`
|
|
158
|
+
`&&(n&&l&&(t+=$c(n)),s&&(t+=Ec(s))),o+=c.length}return t},Fu=/(?=\s)|(?<=\s)/,Vu=/^\s+$/,Cc=new Map,vS=e=>{const t=Cc.get(e);if(t!==void 0)return t;const n=je(e);return Cc.set(e,n),n},Hr=e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},jt=e=>{const t=e.split(" ");let n=t.length;for(;n>0&&je(t[n-1])===0;)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Wu=(e,t,n)=>{if(e.length===0)return[""];if(t<=0)return[e];const s=[],r=new _u;let i="",o=0,a=!1,c=!1,l="",d=0;for(;d<e.length;){const u=e.codePointAt(d),p=String.fromCodePoint(u),f=p.length;if(kn.has(p)){a=!0,l=p,i+=p,c=e.startsWith(ns,d+1),d+=1;continue}if(a){l+=p,i+=p,c?p===yr&&(a=c=!1):p===$o&&(a=!1,r.processEscape(l)),d+=1;continue}const h=vS(p),m=p===" ";if(h===0){i+=p,d+=f;continue}if(o+h>t&&(i&&s.push(i+r.getEndEscapesForAllActiveAttributes()),i=r.getStartEscapesForAllActiveAttributes(),o=je(i),m&&n)){for(;d<e.length&&e[d]===" ";)d+=1;continue}if(i+=p,o+=h,o===t&&d+f<e.length&&(s.push(i+r.getEndEscapesForAllActiveAttributes()),i=r.getStartEscapesForAllActiveAttributes(),o=je(i),d+f<e.length&&e[d+f]===" "&&n)){for(d+=f;d<e.length&&e[d]===" ";)d+=1;continue}d+=f}return i&&s.push(i+r.getEndEscapesForAllActiveAttributes()),n?s.map(u=>jt(u)):s},bS=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const r=[];let i="",o=0;return gS(s,{getWidth:je,onSegment:(a,c)=>{const l=a.text??"";if(a.isEscapeSequence)i+=l;else{const d=l===" ";if(a.width===0)return i+=l,!0;if(o+a.width>t&&(i&&r.push(i),i=c.getStartEscapesForAllActiveAttributes(),o=0,d))return n||r.push(c.getStartEscapesForAllActiveAttributes()+l),!0;i+=l,o+=a.width}return!0}}),i&&r.push(i),n?r.map(a=>jt(a)):r},wS=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const r=s.split(Fu),i=[];let o="",a=0,c=0;for(;c<r.length;){const l=r[c],d=Vu.test(l),u=je(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(a+u>t&&a>0){n?i.push(jt(o)):i.push(o),o="",a=0;continue}o+=l,a+=u,c+=1}return o&&(n?i.push(jt(o)):i.push(o)),i},kS=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const r=s.split(Fu),i=[];let o="",a=0,c=0;for(;c<r.length;){const l=r[c],d=Vu.test(l),u=je(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(u>t){o&&i.push(Hr(n?jt(o):o));const p=Wu(l,t,n);if(p.length>0){for(let f=0;f<p.length-1;f+=1)i.push(p[f]);o=p.at(-1),a=je(o)}else o="",a=0;c+=1;continue}if(a+u>t&&a>0&&(i.push(Hr(n?jt(o):o)),o="",a=0,n&&d)){c+=1;continue}o+=l,a+=u,c+=1}return o&&i.push(Hr(n?jt(o):o)),i},Ln={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},SS=(e,t={})=>{const{removeZeroWidthCharacters:n=!0,trim:s=!0,width:r=80,wrapMode:i=Ln.PRESERVE_WORDS}=t;if(s&&e.trim()==="")return"";let o=e.normalize("NFC").replaceAll(`\r
|
|
161
159
|
`,`
|
|
162
|
-
`);return n&&(o=o.replaceAll(
|
|
163
|
-
`).map(a=>{if(s&&a.trim()==="")return"";let c;switch(
|
|
164
|
-
`)},
|
|
165
|
-
${I}`,
|
|
166
|
-
${I}`);const
|
|
167
|
-
${U}`),A.pop(),`[${
|
|
168
|
-
${I}`,J=" ");const ce=Math.min(
|
|
169
|
-
${I}${
|
|
170
|
-
${U}`),A.pop(),`{${
|
|
171
|
-
${I}`,
|
|
172
|
-
${I}`);const
|
|
173
|
-
${
|
|
174
|
-
${I}`,U=" ");let q="";for(const
|
|
175
|
-
${I}${
|
|
176
|
-
${
|
|
160
|
+
`);return n&&(o=o.replaceAll(oS,"")),o.split(`
|
|
161
|
+
`).map(a=>{if(s&&a.trim()==="")return"";let c;switch(i){case Ln.BREAK_AT_CHARACTERS:{c=bS(a,r,s);break}case Ln.BREAK_WORDS:{c=kS(a,r,s);break}case Ln.STRICT_WIDTH:{c=Wu(a,r,s);break}default:c=wS(a,r,s)}return yS(c)}).join(`
|
|
162
|
+
`)},Hu=80,Uu=24,Bi=(e,t,{shell:n,env:s}={})=>ck(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),Ds=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),Gu=(e,t)=>{const{columns:n,rows:s}=Ds(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===Hu&&s===Uu))return{columns:n,rows:s}},xS=()=>{if(it.platform!=="linux")return!0;try{const e=Mn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),r=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(r)||r<=0?!1:s===r}catch{return!1}};function $S(){const{env:e,stdout:t,stderr:n}=it;if(t?.columns&&t?.rows)return Ds(t.columns,t.rows);if(n?.columns&&n?.rows)return Ds(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return Ds(e.COLUMNS,e.LINES);const s={columns:Hu,rows:Uu};return it.platform==="win32"?Ur()??s:it.platform==="darwin"?Rc()??Ur()??s:Rc()??Ur()??ES()??s}const Rc=()=>{try{const e=it.platform==="darwin"?Mn.constants.O_EVTONLY|Mn.constants.O_NONBLOCK:Mn.constants.O_NONBLOCK,{columns:t,rows:n}=lk.WriteStream(Mn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},Ur=()=>{try{const e=Bi("tput",["cols"],{env:{TERM:"dumb",...it.env}}),t=Bi("tput",["lines"],{env:{TERM:"dumb",...it.env}});if(e&&t)return Gu(e,t)}catch{}},ES=()=>{try{if(!xS())return;const e=Bi("resize",["-u"]).match(/\d+/g);if(e.length===2)return Gu(e[0],e[1])}catch{}},CS=e=>{const t=Object.keys(e).map(n=>e[n].badge??"");return t.length===0?"":t.reduce((n,s)=>n.length>s.length?n:s,"")},{bold:RS,cyan:jS,green:jc,grey:TS,magenta:OS,red:AS,yellow:Gr}=nr,IS={indent:2,quoteStyle:"single",stylize:(e,t)=>{const n={bigint:Gr,boolean:Gr,date:OS,null:RS,number:Gr,regexp:AS,special:jS,string:jc,symbol:jc,undefined:TS};return Object.hasOwn(n,t)?n[t](e):e}},{bold:BS,underline:PS}=nr,NS=(e,t)=>{let n=t.uppercase.label?e.toUpperCase():e;return n=t.underline.label?PS(n):n,t.bold.label&&(n=BS(n)),n},DS=e=>[e.getHours(),e.getMinutes(),e.getSeconds()].map(t=>String(t).padStart(2,"0")).join(":");class MS{styles;loggerTypes;constructor(t){this.styles={bold:{label:!1},dateFormatter:DS,underline:{label:!1,message:!1,prefix:!1,suffix:!1},uppercase:{label:!1},...t},this.loggerTypes=fu}setLoggerTypes(t){this.loggerTypes=t}}const LS=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:Eo,stderr:Co,env:Hn}=LS,_S="\x1B",Pt="\x1B[",FS=";",zu=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,VS=/^(?:msys|cygwin)$/,Ju=process,Pi=Ju?.env??{};!zu&&Pi.TERM_PROGRAM;const WS=!zu&&(Ju?.platform==="win32"||Pi.OSTYPE!==void 0&&VS.test(Pi.OSTYPE)),HS=(e,t)=>`${Pt}${String(t+1)}${FS}${String(e+1)}H`;var US=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(US||{}),cn=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(cn||{});const Un=e=>{const t=e>=0&&e<=3?e:0;return`${Pt}${t===0?"":String(t)}J`};var qu=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(qu||{});const GS=e=>{const t=e>=0&&e<=2?e:0;return`${Pt}${t===0?"":String(t)}K`};HS(0,0)+Un(cn.ToEnd);`${GS(qu.EntireLine)}${Pt}`;`${Pt}${Un(cn.EntireScreen)}`;const Tc=WS?`${Un(cn.EntireScreen)}${Pt}0f`:`${Un(cn.EntireScreen)}${Un(cn.EntireScreenAndScrollback)}${Pt}H${_S}c`;var zr={exports:{}},Oc;function zS(){return Oc||(Oc=1,(function(e,t){const{hasOwnProperty:n}=Object.prototype,s=$();s.configure=$,s.stringify=s,s.default=s,t.stringify=s,t.configure=$,e.exports=s;const r=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function i(b){return b.length<5e3&&!r.test(b)?`"${b}"`:JSON.stringify(b)}function o(b,S){if(b.length>200||S)return b.sort(S);for(let C=1;C<b.length;C++){const P=b[C];let T=C;for(;T!==0&&b[T-1]>P;)b[T]=b[T-1],T--;b[T]=P}return b}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(b){return a.call(b)!==void 0&&b.length!==0}function l(b,S,C){b.length<C&&(C=b.length);const P=S===","?"":" ";let T=`"0":${P}${b[0]}`;for(let N=1;N<C;N++)T+=`${S}"${N}":${P}${b[N]}`;return T}function d(b){if(n.call(b,"circularValue")){const S=b.circularValue;if(typeof S=="string")return`"${S}"`;if(S==null)return S;if(S===Error||S===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function u(b){let S;if(n.call(b,"deterministic")&&(S=b.deterministic,typeof S!="boolean"&&typeof S!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return S===void 0?!0:S}function p(b,S){let C;if(n.call(b,S)&&(C=b[S],typeof C!="boolean"))throw new TypeError(`The "${S}" argument must be of type boolean`);return C===void 0?!0:C}function f(b,S){let C;if(n.call(b,S)){if(C=b[S],typeof C!="number")throw new TypeError(`The "${S}" argument must be of type number`);if(!Number.isInteger(C))throw new TypeError(`The "${S}" argument must be an integer`);if(C<1)throw new RangeError(`The "${S}" argument must be >= 1`)}return C===void 0?1/0:C}function h(b){return b===1?"1 item":`${b} items`}function m(b){const S=new Set;for(const C of b)(typeof C=="string"||typeof C=="number")&&S.add(String(C));return S}function v(b){if(n.call(b,"strict")){const S=b.strict;if(typeof S!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(S)return C=>{let P=`Object can not safely be stringified. Received type ${typeof C}`;throw typeof C!="function"&&(P+=` (${C.toString()})`),new Error(P)}}}function $(b){b={...b};const S=v(b);S&&(b.bigint===void 0&&(b.bigint=!1),"circularValue"in b||(b.circularValue=Error));const C=d(b),P=p(b,"bigint"),T=u(b),N=typeof T=="function"?T:void 0,_=f(b,"maximumDepth"),F=f(b,"maximumBreadth");function Y(M,w,A,H,O,I){let j=w[M];switch(typeof j=="object"&&j!==null&&typeof j.toJSON=="function"&&(j=j.toJSON(M)),j=H.call(w,M,j),typeof j){case"string":return i(j);case"object":{if(j===null)return"null";if(A.indexOf(j)!==-1)return C;let L="",W=",";const U=I;if(Array.isArray(j)){if(j.length===0)return"[]";if(_<A.length+1)return'"[Array]"';A.push(j),O!==""&&(I+=O,L+=`
|
|
163
|
+
${I}`,W=`,
|
|
164
|
+
${I}`);const fe=Math.min(j.length,F);let be=0;for(;be<fe-1;be++){const vt=Y(String(be),j,A,H,O,I);L+=vt!==void 0?vt:"null",L+=W}const we=Y(String(be),j,A,H,O,I);if(L+=we!==void 0?we:"null",j.length-1>F){const vt=j.length-F-1;L+=`${W}"... ${h(vt)} not stringified"`}return O!==""&&(L+=`
|
|
165
|
+
${U}`),A.pop(),`[${L}]`}let q=Object.keys(j);const B=q.length;if(B===0)return"{}";if(_<A.length+1)return'"[Object]"';let J="",oe="";O!==""&&(I+=O,W=`,
|
|
166
|
+
${I}`,J=" ");const ce=Math.min(B,F);T&&!c(j)&&(q=o(q,N)),A.push(j);for(let fe=0;fe<ce;fe++){const be=q[fe],we=Y(be,j,A,H,O,I);we!==void 0&&(L+=`${oe}${i(be)}:${J}${we}`,oe=W)}if(B>F){const fe=B-F;L+=`${oe}"...":${J}"${h(fe)} not stringified"`,oe=W}return O!==""&&oe.length>1&&(L=`
|
|
167
|
+
${I}${L}
|
|
168
|
+
${U}`),A.pop(),`{${L}}`}case"number":return isFinite(j)?String(j):S?S(j):"null";case"boolean":return j===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(j);default:return S?S(j):void 0}}function re(M,w,A,H,O,I){switch(typeof w=="object"&&w!==null&&typeof w.toJSON=="function"&&(w=w.toJSON(M)),typeof w){case"string":return i(w);case"object":{if(w===null)return"null";if(A.indexOf(w)!==-1)return C;const j=I;let L="",W=",";if(Array.isArray(w)){if(w.length===0)return"[]";if(_<A.length+1)return'"[Array]"';A.push(w),O!==""&&(I+=O,L+=`
|
|
169
|
+
${I}`,W=`,
|
|
170
|
+
${I}`);const B=Math.min(w.length,F);let J=0;for(;J<B-1;J++){const ce=re(String(J),w[J],A,H,O,I);L+=ce!==void 0?ce:"null",L+=W}const oe=re(String(J),w[J],A,H,O,I);if(L+=oe!==void 0?oe:"null",w.length-1>F){const ce=w.length-F-1;L+=`${W}"... ${h(ce)} not stringified"`}return O!==""&&(L+=`
|
|
171
|
+
${j}`),A.pop(),`[${L}]`}A.push(w);let U="";O!==""&&(I+=O,W=`,
|
|
172
|
+
${I}`,U=" ");let q="";for(const B of H){const J=re(B,w[B],A,H,O,I);J!==void 0&&(L+=`${q}${i(B)}:${U}${J}`,q=W)}return O!==""&&q.length>1&&(L=`
|
|
173
|
+
${I}${L}
|
|
174
|
+
${j}`),A.pop(),`{${L}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(w);default:return S?S(w):void 0}}function ee(M,w,A,H,O){switch(typeof w){case"string":return i(w);case"object":{if(w===null)return"null";if(typeof w.toJSON=="function"){if(w=w.toJSON(M),typeof w!="object")return ee(M,w,A,H,O);if(w===null)return"null"}if(A.indexOf(w)!==-1)return C;const I=O;if(Array.isArray(w)){if(w.length===0)return"[]";if(_<A.length+1)return'"[Array]"';A.push(w),O+=H;let J=`
|
|
177
175
|
${O}`;const oe=`,
|
|
178
|
-
${O}`,ce=Math.min(w.length,
|
|
179
|
-
${I}`,A.pop(),`[${J}]`}let
|
|
180
|
-
${O}`;let U="",q="",
|
|
176
|
+
${O}`,ce=Math.min(w.length,F);let fe=0;for(;fe<ce-1;fe++){const we=ee(String(fe),w[fe],A,H,O);J+=we!==void 0?we:"null",J+=oe}const be=ee(String(fe),w[fe],A,H,O);if(J+=be!==void 0?be:"null",w.length-1>F){const we=w.length-F-1;J+=`${oe}"... ${h(we)} not stringified"`}return J+=`
|
|
177
|
+
${I}`,A.pop(),`[${J}]`}let j=Object.keys(w);const L=j.length;if(L===0)return"{}";if(_<A.length+1)return'"[Object]"';O+=H;const W=`,
|
|
178
|
+
${O}`;let U="",q="",B=Math.min(L,F);c(w)&&(U+=l(w,W,F),j=j.slice(w.length),B-=w.length,q=W),T&&(j=o(j,N)),A.push(w);for(let J=0;J<B;J++){const oe=j[J],ce=ee(oe,w[oe],A,H,O);ce!==void 0&&(U+=`${q}${i(oe)}: ${ce}`,q=W)}if(L>F){const J=L-F;U+=`${q}"...": "${h(J)} not stringified"`,q=W}return q!==""&&(U=`
|
|
181
179
|
${O}${U}
|
|
182
|
-
${I}`),A.pop(),`{${U}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(w);default:return S?S(w):void 0}}function te(_,w,A){switch(typeof w){case"string":return r(w);case"object":{if(w===null)return"null";if(typeof w.toJSON=="function"){if(w=w.toJSON(_),typeof w!="object")return te(_,w,A);if(w===null)return"null"}if(A.indexOf(w)!==-1)return C;let W="";const O=w.length!==void 0;if(O&&Array.isArray(w)){if(w.length===0)return"[]";if(L<A.length+1)return'"[Array]"';A.push(w);const U=Math.min(w.length,D);let q=0;for(;q<U-1;q++){const J=te(String(q),w[q],A);W+=J!==void 0?J:"null",W+=","}const N=te(String(q),w[q],A);if(W+=N!==void 0?N:"null",w.length-1>D){const J=w.length-D-1;W+=`,"... ${h(J)} not stringified"`}return A.pop(),`[${W}]`}let I=Object.keys(w);const T=I.length;if(T===0)return"{}";if(L<A.length+1)return'"[Object]"';let F="",H=Math.min(T,D);O&&c(w)&&(W+=l(w,",",D),I=I.slice(w.length),H-=w.length,F=","),j&&(I=o(I,B)),A.push(w);for(let U=0;U<H;U++){const q=I[U],N=te(q,w[q],A);N!==void 0&&(W+=`${F}${r(q)}:${N}`,F=",")}if(T>D){const U=T-D;W+=`${F}"...":"${h(U)} not stringified"`}return A.pop(),`{${W}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(w);default:return S?S(w):void 0}}function se(_,w,A){if(arguments.length>1){let W="";if(typeof A=="number"?W=" ".repeat(Math.min(A,10)):typeof A=="string"&&(W=A.slice(0,10)),w!=null){if(typeof w=="function")return K("",{"":_},[],w,W,"");if(Array.isArray(w))return ie("",_,[],m(w),W,"")}if(W.length!==0)return ee("",_,[],W,"")}return te("",_,[])}return se}})(Ui,Ui.exports)),Ui.exports}var x1=S1();class $1{#e=new Map;#t;constructor(t){this.#t=t}count(t="default"){const n=this.#e.get(t)??0;this.#e.set(t,n+1),this.#t("log",!1,!1,{message:`${t}: ${String(n+1)}`,prefix:t})}countReset(t="default"){this.#e.has(t)?this.#e.delete(t):this.#t("warn",!1,!1,{message:`Count for ${t} does not exist`,prefix:t})}}const E1=new Set(["alert","critical","emergency","error"]),C1=e=>{const t=console;return E1.has(e)?t.__error??console.error:e==="warning"?t.__warn??console.warn:e==="trace"?t.__trace??console.trace:t.__log??console.log};let R1=class{log(e){const{context:t=[],message:n,type:s}=e;C1(s.level)(n,...t)}};class j1{#e=new Map;#t=new Set;#n;#r;#s;constructor(t,n,s){this.#s=t,this.#n=n,this.#r=s}time(t="default"){this.#t.has(t)?this.#s("warn",!1,!1,{message:`Timer '${t}' already exists`,prefix:t}):(this.#t.add(t),this.#e.set(t,Date.now()),this.#s("start",!1,!1,{message:this.#n,prefix:t}))}timeLog(t,...n){if(!t&&this.#t.size>0&&(t=[...this.#t].pop()),t&&this.#e.has(t)){const s=Date.now()-this.#e.get(t);this.#s("info",!1,!1,{context:n,message:s<1e3?`${String(s)} ms`:`${(s/1e3).toFixed(2)} s`,prefix:t})}else this.#s("warn",!1,!1,{context:n,message:"Timer not found",prefix:t})}timeEnd(t){if(!t&&this.#t.size>0&&(t=[...this.#t].pop()),t&&this.#e.has(t)){const n=Date.now()-this.#e.get(t);this.#e.delete(t),this.#t.delete(t),this.#s("stop",!1,!1,{message:`${this.#r} ${n<1e3?`${String(n)} ms`:`${(n/1e3).toFixed(2)} s`}`,prefix:t})}else this.#s("warn",!1,!1,{message:"Timer not found",prefix:t})}}const Cc=e=>e===void 0?[]:Array.isArray(e)?e:[e],Rc=(e,t)=>{const n={...e};return Object.keys(t).forEach(s=>{n[s]={...n[s],...t[s]}}),n},T1=e=>{let t=!1;return function(...n){if(!t){t=!0;try{const s=e.apply(this,n);return t=!1,s}catch(s){throw t=!1,s}}}};class xo{timerManager;counterManager;lastLog;logLevels;disabled;paused;messageQueue;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;force={};#e=new Set;#t;#n;constructor(t){this.throttle=t.throttle??1e3,this.throttleMin=t.throttleMin??5;const n=t.parentLongestLabel,s=t.parentTypes,i=t.parentStringify,r=t.parentLogLevels;this.stringify=i??x1.configure({strict:!0}),this.startTimerMessage=t.messages?.timerStart??"Initialized timer...",this.endTimerMessage=t.messages?.timerEnd??"Timer run for:",s&&n?(this.types=s,this.longestLabel=n):(this.types=Rc(ou,t.types??{}),this.longestLabel=jr(this.types)),this.logLevels=r&&!t.logLevels?r:{...Fw,...t.logLevels},this.generalLogLevel=this.#i(t.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=t.disabled??!1,this.paused=!1,this.messageQueue=[],this.scopeName=Cc(t.scope).filter(Boolean),this.timerManager=new j1((o,a,c,...l)=>{this.logger(o,a,c,...l)},this.startTimerMessage,this.endTimerMessage),this.counterManager=new $1((o,a,c,...l)=>{this.logger(o,a,c,...l)}),this.groups=[],this.lastLog={},this.logger=T1(this.logger.bind(this)),this.#r(),Array.isArray(t.reporters)&&this.registerReporters(t.reporters),this.rawReporter=this.extendReporter(t.rawReporter??new R1),Array.isArray(t.processors)&&this.registerProcessors(t.processors)}#r(){for(const t in this.types)this[t]=this.logger.bind(this,t,!1,!1);for(const t in this.types)this.force[t]=this.logger.bind(this,t,!1,!0);this.raw=this.raw.bind(this)}wrapConsole(){for(const t in this.types)Object.hasOwn(console,`__${t}`)||(console[`__${t}`]=console[t]),console[t]=this[t]}restoreConsole(){for(const t in this.types)if(Object.hasOwn(console,`__${t}`)){const n=console[`__${t}`];n===void 0?delete console[t]:console[t]=n,delete console[`__${t}`]}}wrapException(){this.#t||this.#n||(this.#t=t=>{this.error(t)},this.#n=t=>{this.error(t)},process.on("uncaughtException",this.#t),process.on("unhandledRejection",this.#n))}restoreException(){this.#t&&(process.off("uncaughtException",this.#t),this.#t=void 0),this.#n&&(process.off("unhandledRejection",this.#n),this.#n=void 0)}disable(){this.disabled=!0}enable(){this.disabled=!1}isEnabled(){return!this.disabled}pause(){this.paused=!0}resume(){this.paused=!1;const t=this.messageQueue.splice(0);for(let n=0;n<t.length;n+=1){const{messageObject:s,raw:i,type:r}=t[n];this.logger(r,i,!1,...s)}}scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.child({scope:t})}unscope(){this.scopeName=[]}child(t){return new xo(this.buildChildOptions(t))}time(t="default"){this.timerManager.time(t)}timeLog(t,...n){this.timerManager.timeLog(t,...n)}timeEnd(t){this.timerManager.timeEnd(t)}group(t="console.group"){globalThis.window===void 0?this.groups.push(t):console.group(t)}groupEnd(){globalThis.window===void 0?this.groups.pop():console.groupEnd()}count(t="default"){this.counterManager.count(t)}countReset(t="default"){this.counterManager.countReset(t)}clear(){console.clear()}raw(t,...n){this.disabled||this.logger("log",!0,!1,{context:n,message:t})}buildChildOptions(t){const n=t?.types!==void 0,s=n?Rc(this.types,t.types):this.types,i=t?.reporters??[],r=i.length>0?[...this.reporters,...i]:[...this.reporters],o=t?.processors??[],a=o.length>0?[...this.processors,...o]:[...this.processors],c=t?.logLevels?{...this.logLevels,...t.logLevels}:this.logLevels;let l;if(t?.scope){const p=Cc(t.scope).filter(Boolean);l=this.scopeName.length>0?[...this.scopeName,...p]:p}else l=this.scopeName.length>0?this.scopeName:[];const d=t?.messages?{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage,...t.messages}:{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage},u={disabled:t?.disabled??this.disabled,logLevel:t?.logLevel??this.generalLogLevel,logLevels:c,messages:d,processors:a,rawReporter:t?.rawReporter??this.rawReporter,reporters:r,scope:l,throttle:t?.throttle??this.throttle,throttleMin:t?.throttleMin??this.throttleMin};return n?(u.parentTypes=s,u.parentLongestLabel=jr(s)):(u.parentTypes=this.types,u.parentLongestLabel=this.longestLabel),t?.logLevels||(u.parentLogLevels=this.logLevels),t?.messages||(u.parentMessages={timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage}),u.parentStringify=this.stringify,u}extendReporter(t){return typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),t}registerReporters(t){for(let n=0;n<t.length;n+=1)this.reporters.add(this.extendReporter(t[n]))}registerProcessors(t){for(let n=0;n<t.length;n+=1){const s=t[n];typeof s.setStringify=="function"&&s.setStringify(this.stringify),this.processors.add(s)}}#s(t,n){if(n)this.rawReporter.log(Object.freeze(t));else for(const s of this.reporters)s.log(Object.freeze(t))}#i(t){let n="debug";return t!==void 0&&Object.hasOwn(this.logLevels,t)?n=t:t!==void 0&&!this.#e.has(t)&&(this.#e.add(t),console.warn(`[pail] Unknown log level "${String(t)}". Valid levels: ${Object.keys(this.logLevels).join(", ")}. Falling back to "debug".`)),n}#o(t,n,...s){const i={badge:void 0,context:void 0,error:void 0,label:void 0,message:yo,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0};if(i.type={level:n.logLevel,name:t},i.groups=this.groups,i.scope=this.scopeName,i.date=new Date,s.length>0&&s[0]instanceof Error)i.error=s[0],s.length>1&&(i.context=s.slice(1));else if(s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"message"in s[0]){const{context:r,message:o,prefix:a,suffix:c}=s[0];if(r&&(i.context=r),a&&(i.prefix=a),c&&(i.suffix=c),i.message=o,s.length>1){const l=s.slice(1);i.context?i.context=Array.isArray(i.context)?[...i.context,...l]:[i.context,...l]:i.context=l}}else s.length>1?(i.message=s[0],i.context=s.slice(1)):s.length===1?i.message=s[0]:i.message=void 0;return n.logLevel==="trace"&&(i.traceError=new Error("Trace")),n.badge&&(i.badge=n.badge),n.label&&(i.label=n.label),i}logger(t,n,s,...i){if(this.disabled)return;if(this.paused){this.messageQueue.push({messageObject:i,raw:n,type:t});return}const r=this.types[t],o=this.#i(r.logLevel);if(s||this.logLevels[o]>=this.logLevels[this.generalLogLevel]){let a=this.#o(t,r,...i),c;try{c=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{c=void 0}const l=this.processors.size>0,d=(f=!1)=>{const h=(this.lastLog.count??0)-this.throttleMin;if(this.lastLog.object&&h>0){const m={...this.lastLog.object};h>1&&(m.repeated=h),this.#s(m,n),this.lastLog.count=1}if(f){for(const m of this.processors)a=m.process(a);if(a.dropped===!0)return;if(this.lastLog.object=a,l)try{this.lastLog.signature=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{this.lastLog.signature=void 0}else this.lastLog.signature=c;this.#s(a,n)}};clearTimeout(this.lastLog.timeout);const u=a.date instanceof Date?a.date:new Date(a.date),p=this.lastLog.time?u.getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=u,p<this.throttle)try{const f=c;if(this.lastLog.object&&f!==void 0&&f===this.lastLog.signature&&(this.lastLog.count=(this.lastLog.count??0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(d,this.throttle);return}}catch{}d(!0)}}}class O1{#e;#t;#n;#r=!1;#s;constructor(t={}){this.#e=ko,this.#t=So,this.#s=t}setStdout(t){this.#e=t}setStderr(t){this.#t=t}setInteractiveManager(t){this.#n=t}setIsInteractive(t){this.#r=t}log(t){const{context:n,groups:s,message:i,type:r}=t,o=[];if(i!==yo){const d=typeof i=="string"?i:Ks(i,this.#s);o.push(d)}n&&o.push(...n.map(d=>typeof d=="object"?` ${Ks(d,this.#s)}`:` ${String(d)}`));const a=fu(r.level)?"stderr":"stdout",c=a==="stderr"?this.#t:this.#e,l=s.map(()=>" ").join("");this.#r&&this.#n!==void 0&&c.isTTY?this.#n.update(a,(l+o.join("")).split(`
|
|
183
|
-
`),0):hu(l+o.join(""),c)}}class $o extends xo{constructor(t){const n=t.parentStderr,s=t.parentStdout,{interactive:i,processors:r,rawReporter:o,reporters:a,stderr:c,stdout:l}=t,d=n??c,u=s??l,p=t.parentLongestLabel,f=t.parentTypes,{parentLogLevels:h,parentMessages:m,parentStringify:b}=t,$={disabled:t.disabled,logLevel:t.logLevel,logLevels:t.logLevels,messages:t.messages,processors:[],rawReporter:t.rawReporter,reporters:[],scope:t.scope,throttle:t.throttle,throttleMin:t.throttleMin},v="types"in t;f&&p&&!v?($.parentTypes=f,$.parentLongestLabel=p):v&&t.types!==void 0&&($.types=t.types),b&&($.parentStringify=b),h&&!t.logLevels&&($.parentLogLevels=h),m&&!t.messages&&($.parentMessages=m),super($),this.options=t,this.interactive=i??!1,this.stdout=u,this.stderr=d,this.interactive&&this.stdout&&this.stderr&&(this.interactiveManager=new bw(new Js(this.stdout),new Js(this.stderr))),Array.isArray(a)&&this.registerReporters(a),this.rawReporter=this.extendReporter(o??new O1),Array.isArray(r)&&this.registerProcessors(r)}options;stdout;stderr;interactiveManager;interactive;scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.child({scope:t})}child(t){const n=this.buildChildOptions(t);return n.interactive=t?.interactive??this.interactive,n.stderr=t?.stderr??this.stderr,n.stdout=t?.stdout??this.stdout,t?.stdout||(n.parentStdout=this.stdout),t?.stderr||(n.parentStderr=this.stderr),new $o(n)}getInteractiveManager(){return this.interactiveManager}wrapStd(){this.#e(this.stdout,"log"),this.#e(this.stderr,"error")}restoreStd(){this.#t(this.stdout),this.#t(this.stderr)}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}clear(){this.stdout?.write($c),this.stderr?.write($c)}extendReporter(t){return typeof t.setStdout=="function"&&t.setStdout(this.stdout),typeof t.setStderr=="function"&&t.setStderr(this.stderr),typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),typeof t.setIsInteractive=="function"&&t.setIsInteractive(this.interactive),this.interactive&&typeof t.setInteractiveManager=="function"&&t.setInteractiveManager(this.interactiveManager),t}#e(t,n){t&&(t.__write||(t.__write=t.write),t.write=s=>{this[n](String(s).trim())})}#t(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}}const A1=$o;let Gi;const I1=()=>(Gi!==void 0||(Gi=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),Gi),B1=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,P1=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,N1=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,D1=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,Br=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),jc=/\s+/,qs=e=>{const t=I1();t.has(e)&&(e=t.get(e));const n=B1.exec(e);if(n)return[Number.parseInt(n[1],16),Number.parseInt(n[2],16),Number.parseInt(n[3],16)];const s=P1.exec(e);if(s)return[Number.parseInt(`${s[1]}${s[1]}`,16),Number.parseInt(`${s[2]}${s[2]}`,16),Number.parseInt(`${s[3]}${s[3]}`,16)];const i=N1.exec(e);if(i)return[Math.round(Math.max(0,Math.min(255,Number(i[1])))),Math.round(Math.max(0,Math.min(255,Number(i[2])))),Math.round(Math.max(0,Math.min(255,Number(i[3]))))];const r=D1.exec(e);if(r){let o=Number(r[1])%360;o<0&&(o+=360);const a=Math.max(0,Math.min(100,Number(r[2])))/100,c=Math.max(0,Math.min(100,Number(r[3])))/100,l=(1-Math.abs(2*c-1))*a,d=l*(1-Math.abs(o/60%2-1)),u=c-l/2;let p,f,h;return o<60?{0:p,1:f,2:h}=[l,d,0]:o<120?{0:p,1:f,2:h}=[d,l,0]:o<180?{0:p,1:f,2:h}=[0,l,d]:o<240?{0:p,1:f,2:h}=[0,d,l]:o<300?{0:p,1:f,2:h}=[d,0,l]:{0:p,1:f,2:h}=[l,0,d],[Math.round((p+u)*255),Math.round((f+u)*255),Math.round((h+u)*255)]}return null},zi=(e,t)=>typeof e=="string"||typeof t=="string"?e===t:e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],M1=e=>{if(typeof e!="string")return Br();const t=Br(),n=[];let s=!1,i=null,r=0,o="";for(const a of e){if(a==="(")r+=1;else if(r>0)a===")"&&(r-=1);else if(s){if(a===";"){const c=o.trim();c!==""&&n.push([i,c]),i=null,o="",s=!1;continue}}else if(a===":"){i=o.trim(),o="",s=!0;continue}o+=a}if(s&&r===0){const a=o.trim();a!==""&&n.push([i,a]),i=null,o=""}for(const{0:a,1:c}of n)switch(a){case"background-color":{c!=null&&(t.backgroundColor=c);break}case"color":{c!=null&&(t.color=c);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(c)&&(t.fontStyle="italic");break}case"font-weight":{c==="bold"&&(t.fontWeight=c);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const l=c.split(jc);for(const d of l){const u=qs(d);u!=null?t.textDecorationColor=u:["line-through","overline","underline"].includes(d)&&t.textDecorationLine.push(d)}break}case"text-decoration-color":{const l=qs(c);l!=null&&(t.textDecorationColor=l);break}case"text-decoration-line":{t.textDecorationLine=[];const l=c.split(jc);for(const d of l)["line-through","overline","underline"].includes(d)&&t.textDecorationLine.push(d);break}}return t},L1=(e,t)=>{t=t??Br();let n="";if(!zi(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)n+="\x1B[49m";else switch(e.backgroundColor){case"black":{n+="\x1B[40m";break}case"blue":{n+="\x1B[44m";break}case"cyan":{n+="\x1B[46m";break}case"green":{n+="\x1B[42m";break}case"magenta":{n+="\x1B[45m";break}case"red":{n+="\x1B[41m";break}case"white":{n+="\x1B[47m";break}case"yellow":{n+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:s,1:i,2:r}=e.backgroundColor;n+=`\x1B[48;2;${String(s)};${String(i)};${String(r)}m`}else{const s=qs(e.backgroundColor);if(s===null)n+="\x1B[49m";else{const{0:i,1:r,2:o}=s;n+=`\x1B[48;2;${String(i)};${String(r)};${String(o)}m`}}}if(!zi(e.color,t.color))if(e.color==null)n+="\x1B[39m";else switch(e.color){case"black":{n+="\x1B[30m";break}case"blue":{n+="\x1B[34m";break}case"cyan":{n+="\x1B[36m";break}case"green":{n+="\x1B[32m";break}case"magenta":{n+="\x1B[35m";break}case"red":{n+="\x1B[31m";break}case"white":{n+="\x1B[37m";break}case"yellow":{n+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:s,1:i,2:r}=e.color;n+=`\x1B[38;2;${String(s)};${String(i)};${String(r)}m`}else{const s=qs(e.color);if(s===null)n+="\x1B[39m";else{const{0:i,1:r,2:o}=s;n+=`\x1B[38;2;${String(i)};${String(r)};${String(o)}m`}}}if(e.fontWeight!==t.fontWeight&&(n+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(n+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!zi(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)n+="\x1B[59m";else{const{0:s,1:i,2:r}=e.textDecorationColor;n+=`\x1B[58;2;${String(s)};${String(i)};${String(r)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(n+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(n+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(n+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),n},_1=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},Tc="%".codePointAt(0),F1="s".codePointAt(0),V1="d".codePointAt(0),H1="f".codePointAt(0),W1="i".codePointAt(0),U1="O".codePointAt(0),G1="o".codePointAt(0),z1="j".codePointAt(0),J1="c".codePointAt(0),Oc=(e,t=[],n={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);const s=n.stringify??_1,i=1;if(typeof e=="object"){const u=t.length+i;if(u===1)return"{}";const p=Array.from({length:u});p[0]=s(e);for(let f=1;f<u;f+=1)p[f]=s(t[f-i]);return p.join(" ")}if(t.length===0)return e;let r="",o=1-i,a=-1,c=!1,l;const d=n.colors??globalThis.window===void 0;for(let u=0;u<e.length;){if(e.codePointAt(u)===Tc&&u+1<e.length){a=a>-1?a:0;const p=e.codePointAt(u+1);switch(p){case J1:{if(a<u&&(r+=e.slice(a,u)),d){const f=M1(t[o]),h=L1(f,l);r+=h,h!==""&&(c=!0,l=f)}a=u+2,u+=1;break}case V1:case H1:{const f=t[o];if(o>=t.length||f==null)break;a<u&&(r+=e.slice(a,u)),r+=(typeof f=="symbol"?Number.NaN:Number(f)).toString(),a=u+2,u+=1;break}case W1:{const f=t[o];if(o>=t.length||f==null)break;a<u&&(r+=e.slice(a,u)),r+=Math.floor(typeof f=="symbol"?Number.NaN:Number(f)).toString(),a=u+2,u+=1;break}case z1:case U1:case G1:{if(o>=t.length||t[o]===void 0)break;a<u&&(r+=e.slice(a,u));const f=t[o],h=typeof f;if(h==="string"){r+=`'${f}'`,a=u+2,u+=1;break}if(h==="function"){r+=f.name?`[Function: ${f.name}]`:"[Function: <anonymous>]",a=u+2,u+=1;break}r+=s(f),a=u+2,u+=1;break}case Tc:{a<u&&(r+=e.slice(a,u)),r+="%",a=u+2,u+=1,o-=1;break}case F1:{if(o>=t.length)break;a<u&&(r+=e.slice(a,u));const f=t[o];r+=typeof f=="object"&&f!==null?s(f):String(f),a=u+2,u+=1;break}default:typeof n.formatters?.[p]=="function"?(a<u&&(r+=e.slice(a,u)),r+=n.formatters[p](t[o]),a=u+2,u+=1):o-=1}o+=1}u+=1}if(a===-1&&!(n.appendExtraArguments&&o<t.length))return e;if(a===-1?r=e:a<e.length&&(r+=e.slice(a)),a!==-1&&c&&(r+="\x1B[0m"),n.appendExtraArguments&&o<t.length)for(let u=Math.max(o,0);u<t.length;u+=1){const p=t[u];r+=` ${typeof p=="object"&&p!==null?s(p):String(p)}`}return r},K1=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([i,r])=>{if(i.length===0)throw new Error(`Formatter %${i} has no characters`);if(i.length>1)throw new Error(`Formatter %${i} has more than one character`);if(typeof r!="function")throw new TypeError(`Formatter for %${i} is not a function`);const o=i.codePointAt(0);if(o===void 0)throw new Error(`${i}.codePointAt(0) failed to return a value, please report this issue`);t[o]=r});const n={...e};delete n.formatters;const s=Object.freeze({...n,formatters:t});return(i,r=[],o)=>o===void 0?Oc(i,r,s):Oc(i,r,{...n,...o,formatters:t})},q1='"[Circular]"';class Y1{#e;#t;#n;constructor(t={}){this.#t=t.formatters}setStringify(t){this.#e=t}process(t){this.#n===void 0&&(this.#n=K1({formatters:this.#t,stringify:s=>this.#r(s)}));const n=this.#n;return t.message!==void 0&&(t.message=this.#s(n,t.message,t.context??[])),t}#r(t){if(this.#e===void 0)try{return JSON.stringify(t)}catch{return q1}try{return this.#e(t)}catch(n){return JSON.stringify(`[unserializable: ${n instanceof Error?n.message:String(n)}]`)}}#s(t,n,s=[]){if(typeof n=="string")return t(n,s);if(typeof n=="object"&&n!==null){const i=n,r=Object.keys(i);for(let o=0;o<r.length;o+=1){const a=r[o],c=i[a];(typeof c=="string"||Array.isArray(c)||typeof c=="object")&&(i[a]=this.#s(t,c,s))}}return n}}const{bgGrey:X1,cyan:Z1,green:Q1,greenBright:ex,grey:Ae,red:Ji,underline:Ac,white:tx}=ni,nx=/[\\/]pail[\\/]dist/,Ki=e=>!nx.test(e);class sx extends f1{#e;#t;#n;#r=!1;#s;#i;#o;#a=!1;#c="";#l="";constructor(t={}){const{error:n,inspect:s,...i}=t;super({uppercase:{label:!0,...i.uppercase},...i}),this.#s={...c1,...s},this.#i={...n,color:{fileLine:Q1,hint:Z1,marker:Ji,message:Ji,method:ex,title:Ji}},this.#e=ko,this.#t=So,this.#d()}setLoggerTypes(t){super.setLoggerTypes(t),this.#d()}setStdout(t){this.#e=t,this.#o=void 0,this.#a=!1}setStderr(t){this.#t=t}setInteractiveManager(t){this.#n=t}setIsInteractive(t){this.#r=t}log(t){this._log(this._formatMessage(t),t.type.level)}#d(){this.#c=n1(this.loggerTypes),this.#l=jr(this.loggerTypes)}#p(){return!this.#a&&typeof this.#e.on=="function"&&(this.#a=!0,this.#e.on("resize",()=>{this.#o=void 0})),this.#o===void 0&&(this.#o=e1().columns),this.#o}_formatMessage(t){let n=this.#p();typeof this.styles.messageLength=="number"&&(n=this.styles.messageLength);const{badge:s,context:i,date:r,error:o,file:a,groups:c,label:l,message:d,prefix:u,repeated:p,scope:f,suffix:h,traceError:m,type:b}=t,{color:$}=this.loggerTypes[b.name],v=$?ni[$]:tx,S=c.map(()=>" ").join(""),C=[];if(c.length>0&&C.push(`${S+Ae(`[${c.at(-1)??""}]`)} `),r&&C.push(`${Ae(this.styles.dateFormatter(typeof r=="string"?new Date(r):r))} `),s)C.push(v(s));else{const B=this.#c;B.length>0&&C.push(`${Ae(".".repeat(B.length))} `)}const P=this.#l;if(l){const B=je(P),L=je(l);C.push(`${v(u1(l,this.styles))} `,Ae(".".repeat(Math.max(0,B-L))))}else C.push(Ae(".".repeat(P.length+2)));p&&C.push(`${X1.white(`[${String(p)}x]`)} `),Array.isArray(f)&&f.length>0&&C.push(` ${Ae(`[${f.join(" > ")}]`)} `),u&&C.push(`${Ae(`${Array.isArray(f)&&f.length>0?". ":" "}[${this.styles.underline.prefix?Ac(u):u}]`)} `);const j=je(C.join(" "));if(a){const B=(a.name??"")+(a.line?`:${String(a.line)}`:""),L=je(B);if(L+j+2>n)C.push(Ae(` ${B}`));else{const D=Math.max(0,n-j-L-2);C.push(Ae(`${".".repeat(D)} ${B}`))}}else C.push(Ae(".".repeat(Math.max(0,n-j-1))));if(C.length>0&&C.push(`
|
|
180
|
+
${I}`),A.pop(),`{${U}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(w);default:return S?S(w):void 0}}function te(M,w,A){switch(typeof w){case"string":return i(w);case"object":{if(w===null)return"null";if(typeof w.toJSON=="function"){if(w=w.toJSON(M),typeof w!="object")return te(M,w,A);if(w===null)return"null"}if(A.indexOf(w)!==-1)return C;let H="";const O=w.length!==void 0;if(O&&Array.isArray(w)){if(w.length===0)return"[]";if(_<A.length+1)return'"[Array]"';A.push(w);const U=Math.min(w.length,F);let q=0;for(;q<U-1;q++){const J=te(String(q),w[q],A);H+=J!==void 0?J:"null",H+=","}const B=te(String(q),w[q],A);if(H+=B!==void 0?B:"null",w.length-1>F){const J=w.length-F-1;H+=`,"... ${h(J)} not stringified"`}return A.pop(),`[${H}]`}let I=Object.keys(w);const j=I.length;if(j===0)return"{}";if(_<A.length+1)return'"[Object]"';let L="",W=Math.min(j,F);O&&c(w)&&(H+=l(w,",",F),I=I.slice(w.length),W-=w.length,L=","),T&&(I=o(I,N)),A.push(w);for(let U=0;U<W;U++){const q=I[U],B=te(q,w[q],A);B!==void 0&&(H+=`${L}${i(q)}:${B}`,L=",")}if(j>F){const U=j-F;H+=`${L}"...":"${h(U)} not stringified"`}return A.pop(),`{${H}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(w);default:return S?S(w):void 0}}function se(M,w,A){if(arguments.length>1){let H="";if(typeof A=="number"?H=" ".repeat(Math.min(A,10)):typeof A=="string"&&(H=A.slice(0,10)),w!=null){if(typeof w=="function")return Y("",{"":M},[],w,H,"");if(Array.isArray(w))return re("",M,[],m(w),H,"")}if(H.length!==0)return ee("",M,[],H,"")}return te("",M,[])}return se}})(zr,zr.exports)),zr.exports}var JS=zS();class qS{#e=new Map;#t;constructor(t){this.#t=t}count(t="default"){const n=this.#e.get(t)??0;this.#e.set(t,n+1),this.#t("log",!1,!1,{message:`${t}: ${String(n+1)}`,prefix:t})}countReset(t="default"){this.#e.has(t)?this.#e.delete(t):this.#t("warn",!1,!1,{message:`Count for ${t} does not exist`,prefix:t})}}const KS=new Set(["alert","critical","emergency","error"]),YS=e=>{const t=console;return KS.has(e)?t.__error??console.error:e==="warning"?t.__warn??console.warn:e==="trace"?t.__trace??console.trace:t.__log??console.log};let XS=class{log(e){const{context:t=[],message:n,type:s}=e;YS(s.level)(n,...t)}};class ZS{#e=new Map;#t=new Set;#n;#i;#s;constructor(t,n,s){this.#s=t,this.#n=n,this.#i=s}time(t="default"){this.#t.has(t)?this.#s("warn",!1,!1,{message:`Timer '${t}' already exists`,prefix:t}):(this.#t.add(t),this.#e.set(t,Date.now()),this.#s("start",!1,!1,{message:this.#n,prefix:t}))}timeLog(t,...n){if(!t&&this.#t.size>0&&(t=[...this.#t].pop()),t&&this.#e.has(t)){const s=Date.now()-this.#e.get(t);this.#s("info",!1,!1,{context:n,message:s<1e3?`${String(s)} ms`:`${(s/1e3).toFixed(2)} s`,prefix:t})}else this.#s("warn",!1,!1,{context:n,message:"Timer not found",prefix:t})}timeEnd(t){if(!t&&this.#t.size>0&&(t=[...this.#t].pop()),t&&this.#e.has(t)){const n=Date.now()-this.#e.get(t);this.#e.delete(t),this.#t.delete(t),this.#s("stop",!1,!1,{message:`${this.#i} ${n<1e3?`${String(n)} ms`:`${(n/1e3).toFixed(2)} s`}`,prefix:t})}else this.#s("warn",!1,!1,{message:"Timer not found",prefix:t})}}const Ac=e=>e===void 0?[]:Array.isArray(e)?e:[e],Ic=(e,t)=>{const n={...e};return Object.keys(t).forEach(s=>{n[s]={...n[s],...t[s]}}),n},QS=e=>{let t=!1;return function(...n){if(!t){t=!0;try{const s=e.apply(this,n);return t=!1,s}catch(s){throw t=!1,s}}}};class Ro{timerManager;counterManager;lastLog;logLevels;disabled;paused;messageQueue;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;force={};#e=new Set;#t;#n;constructor(t){this.throttle=t.throttle??1e3,this.throttleMin=t.throttleMin??5;const n=t.parentLongestLabel,s=t.parentTypes,r=t.parentStringify,i=t.parentLogLevels;this.stringify=r??JS.configure({strict:!0}),this.startTimerMessage=t.messages?.timerStart??"Initialized timer...",this.endTimerMessage=t.messages?.timerEnd??"Timer run for:",s&&n?(this.types=s,this.longestLabel=n):(this.types=Ic(fu,t.types??{}),this.longestLabel=Oi(this.types)),this.logLevels=i&&!t.logLevels?i:{...dk,...t.logLevels},this.generalLogLevel=this.#r(t.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=t.disabled??!1,this.paused=!1,this.messageQueue=[],this.scopeName=Ac(t.scope).filter(Boolean),this.timerManager=new ZS((o,a,c,...l)=>{this.logger(o,a,c,...l)},this.startTimerMessage,this.endTimerMessage),this.counterManager=new qS((o,a,c,...l)=>{this.logger(o,a,c,...l)}),this.groups=[],this.lastLog={},this.logger=QS(this.logger.bind(this)),this.#i(),Array.isArray(t.reporters)&&this.registerReporters(t.reporters),this.rawReporter=this.extendReporter(t.rawReporter??new XS),Array.isArray(t.processors)&&this.registerProcessors(t.processors)}#i(){for(const t in this.types)this[t]=this.logger.bind(this,t,!1,!1);for(const t in this.types)this.force[t]=this.logger.bind(this,t,!1,!0);this.raw=this.raw.bind(this)}wrapConsole(){for(const t in this.types)Object.hasOwn(console,`__${t}`)||(console[`__${t}`]=console[t]),console[t]=this[t]}restoreConsole(){for(const t in this.types)if(Object.hasOwn(console,`__${t}`)){const n=console[`__${t}`];n===void 0?delete console[t]:console[t]=n,delete console[`__${t}`]}}wrapException(){this.#t||this.#n||(this.#t=t=>{this.error(t)},this.#n=t=>{this.error(t)},process.on("uncaughtException",this.#t),process.on("unhandledRejection",this.#n))}restoreException(){this.#t&&(process.off("uncaughtException",this.#t),this.#t=void 0),this.#n&&(process.off("unhandledRejection",this.#n),this.#n=void 0)}disable(){this.disabled=!0}enable(){this.disabled=!1}isEnabled(){return!this.disabled}pause(){this.paused=!0}resume(){this.paused=!1;const t=this.messageQueue.splice(0);for(let n=0;n<t.length;n+=1){const{messageObject:s,raw:r,type:i}=t[n];this.logger(i,r,!1,...s)}}scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.child({scope:t})}unscope(){this.scopeName=[]}child(t){return new Ro(this.buildChildOptions(t))}time(t="default"){this.timerManager.time(t)}timeLog(t,...n){this.timerManager.timeLog(t,...n)}timeEnd(t){this.timerManager.timeEnd(t)}group(t="console.group"){globalThis.window===void 0?this.groups.push(t):console.group(t)}groupEnd(){globalThis.window===void 0?this.groups.pop():console.groupEnd()}count(t="default"){this.counterManager.count(t)}countReset(t="default"){this.counterManager.countReset(t)}clear(){console.clear()}raw(t,...n){this.disabled||this.logger("log",!0,!1,{context:n,message:t})}buildChildOptions(t){const n=t?.types!==void 0,s=n?Ic(this.types,t.types):this.types,r=t?.reporters??[],i=r.length>0?[...this.reporters,...r]:[...this.reporters],o=t?.processors??[],a=o.length>0?[...this.processors,...o]:[...this.processors],c=t?.logLevels?{...this.logLevels,...t.logLevels}:this.logLevels;let l;if(t?.scope){const p=Ac(t.scope).filter(Boolean);l=this.scopeName.length>0?[...this.scopeName,...p]:p}else l=this.scopeName.length>0?this.scopeName:[];const d=t?.messages?{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage,...t.messages}:{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage},u={disabled:t?.disabled??this.disabled,logLevel:t?.logLevel??this.generalLogLevel,logLevels:c,messages:d,processors:a,rawReporter:t?.rawReporter??this.rawReporter,reporters:i,scope:l,throttle:t?.throttle??this.throttle,throttleMin:t?.throttleMin??this.throttleMin};return n?(u.parentTypes=s,u.parentLongestLabel=Oi(s)):(u.parentTypes=this.types,u.parentLongestLabel=this.longestLabel),t?.logLevels||(u.parentLogLevels=this.logLevels),t?.messages||(u.parentMessages={timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage}),u.parentStringify=this.stringify,u}extendReporter(t){return typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),t}registerReporters(t){for(let n=0;n<t.length;n+=1)this.reporters.add(this.extendReporter(t[n]))}registerProcessors(t){for(let n=0;n<t.length;n+=1){const s=t[n];typeof s.setStringify=="function"&&s.setStringify(this.stringify),this.processors.add(s)}}#s(t,n){if(n)this.rawReporter.log(Object.freeze(t));else for(const s of this.reporters)s.log(Object.freeze(t))}#r(t){let n="debug";return t!==void 0&&Object.hasOwn(this.logLevels,t)?n=t:t!==void 0&&!this.#e.has(t)&&(this.#e.add(t),console.warn(`[pail] Unknown log level "${String(t)}". Valid levels: ${Object.keys(this.logLevels).join(", ")}. Falling back to "debug".`)),n}#o(t,n,...s){const r={badge:void 0,context:void 0,error:void 0,label:void 0,message:ko,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0};if(r.type={level:n.logLevel,name:t},r.groups=this.groups,r.scope=this.scopeName,r.date=new Date,s.length>0&&s[0]instanceof Error)r.error=s[0],s.length>1&&(r.context=s.slice(1));else if(s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"message"in s[0]){const{context:i,message:o,prefix:a,suffix:c}=s[0];if(i&&(r.context=i),a&&(r.prefix=a),c&&(r.suffix=c),r.message=o,s.length>1){const l=s.slice(1);r.context?r.context=Array.isArray(r.context)?[...r.context,...l]:[r.context,...l]:r.context=l}}else s.length>1?(r.message=s[0],r.context=s.slice(1)):s.length===1?r.message=s[0]:r.message=void 0;return n.logLevel==="trace"&&(r.traceError=new Error("Trace")),n.badge&&(r.badge=n.badge),n.label&&(r.label=n.label),r}logger(t,n,s,...r){if(this.disabled)return;if(this.paused){this.messageQueue.push({messageObject:r,raw:n,type:t});return}const i=this.types[t],o=this.#r(i.logLevel);if(s||this.logLevels[o]>=this.logLevels[this.generalLogLevel]){let a=this.#o(t,i,...r),c;try{c=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{c=void 0}const l=this.processors.size>0,d=(f=!1)=>{const h=(this.lastLog.count??0)-this.throttleMin;if(this.lastLog.object&&h>0){const m={...this.lastLog.object};h>1&&(m.repeated=h),this.#s(m,n),this.lastLog.count=1}if(f){for(const m of this.processors)a=m.process(a);if(a.dropped===!0)return;if(this.lastLog.object=a,l)try{this.lastLog.signature=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{this.lastLog.signature=void 0}else this.lastLog.signature=c;this.#s(a,n)}};clearTimeout(this.lastLog.timeout);const u=a.date instanceof Date?a.date:new Date(a.date),p=this.lastLog.time?u.getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=u,p<this.throttle)try{const f=c;if(this.lastLog.object&&f!==void 0&&f===this.lastLog.signature&&(this.lastLog.count=(this.lastLog.count??0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(d,this.throttle);return}}catch{}d(!0)}}}class e2{#e;#t;#n;#i=!1;#s;constructor(t={}){this.#e=Eo,this.#t=Co,this.#s=t}setStdout(t){this.#e=t}setStderr(t){this.#t=t}setInteractiveManager(t){this.#n=t}setIsInteractive(t){this.#i=t}log(t){const{context:n,groups:s,message:r,type:i}=t,o=[];if(r!==ko){const d=typeof r=="string"?r:Js(r,this.#s);o.push(d)}n&&o.push(...n.map(d=>typeof d=="object"?` ${Js(d,this.#s)}`:` ${String(d)}`));const a=wu(i.level)?"stderr":"stdout",c=a==="stderr"?this.#t:this.#e,l=s.map(()=>" ").join("");this.#i&&this.#n!==void 0&&c.isTTY?this.#n.update(a,(l+o.join("")).split(`
|
|
181
|
+
`),0):ku(l+o.join(""),c)}}class jo extends Ro{constructor(t){const n=t.parentStderr,s=t.parentStdout,{interactive:r,processors:i,rawReporter:o,reporters:a,stderr:c,stdout:l}=t,d=n??c,u=s??l,p=t.parentLongestLabel,f=t.parentTypes,{parentLogLevels:h,parentMessages:m,parentStringify:v}=t,$={disabled:t.disabled,logLevel:t.logLevel,logLevels:t.logLevels,messages:t.messages,processors:[],rawReporter:t.rawReporter,reporters:[],scope:t.scope,throttle:t.throttle,throttleMin:t.throttleMin},b="types"in t;f&&p&&!b?($.parentTypes=f,$.parentLongestLabel=p):b&&t.types!==void 0&&($.types=t.types),v&&($.parentStringify=v),h&&!t.logLevels&&($.parentLogLevels=h),m&&!t.messages&&($.parentMessages=m),super($),this.options=t,this.interactive=r??!1,this.stdout=u,this.stderr=d,this.interactive&&this.stdout&&this.stderr&&(this.interactiveManager=new Hw(new zs(this.stdout),new zs(this.stderr))),Array.isArray(a)&&this.registerReporters(a),this.rawReporter=this.extendReporter(o??new e2),Array.isArray(i)&&this.registerProcessors(i)}options;stdout;stderr;interactiveManager;interactive;scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.child({scope:t})}child(t){const n=this.buildChildOptions(t);return n.interactive=t?.interactive??this.interactive,n.stderr=t?.stderr??this.stderr,n.stdout=t?.stdout??this.stdout,t?.stdout||(n.parentStdout=this.stdout),t?.stderr||(n.parentStderr=this.stderr),new jo(n)}getInteractiveManager(){return this.interactiveManager}wrapStd(){this.#e(this.stdout,"log"),this.#e(this.stderr,"error")}restoreStd(){this.#t(this.stdout),this.#t(this.stderr)}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}clear(){this.stdout?.write(Tc),this.stderr?.write(Tc)}extendReporter(t){return typeof t.setStdout=="function"&&t.setStdout(this.stdout),typeof t.setStderr=="function"&&t.setStderr(this.stderr),typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),typeof t.setIsInteractive=="function"&&t.setIsInteractive(this.interactive),this.interactive&&typeof t.setInteractiveManager=="function"&&t.setInteractiveManager(this.interactiveManager),t}#e(t,n){t&&(t.__write||(t.__write=t.write),t.write=s=>{this[n](String(s).trim())})}#t(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}}const t2=jo;let Jr;const n2=()=>(Jr!==void 0||(Jr=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),Jr),s2=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,r2=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,i2=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,o2=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,Ni=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),Bc=/\s+/,qs=e=>{const t=n2();t.has(e)&&(e=t.get(e));const n=s2.exec(e);if(n)return[Number.parseInt(n[1],16),Number.parseInt(n[2],16),Number.parseInt(n[3],16)];const s=r2.exec(e);if(s)return[Number.parseInt(`${s[1]}${s[1]}`,16),Number.parseInt(`${s[2]}${s[2]}`,16),Number.parseInt(`${s[3]}${s[3]}`,16)];const r=i2.exec(e);if(r)return[Math.round(Math.max(0,Math.min(255,Number(r[1])))),Math.round(Math.max(0,Math.min(255,Number(r[2])))),Math.round(Math.max(0,Math.min(255,Number(r[3]))))];const i=o2.exec(e);if(i){let o=Number(i[1])%360;o<0&&(o+=360);const a=Math.max(0,Math.min(100,Number(i[2])))/100,c=Math.max(0,Math.min(100,Number(i[3])))/100,l=(1-Math.abs(2*c-1))*a,d=l*(1-Math.abs(o/60%2-1)),u=c-l/2;let p,f,h;return o<60?{0:p,1:f,2:h}=[l,d,0]:o<120?{0:p,1:f,2:h}=[d,l,0]:o<180?{0:p,1:f,2:h}=[0,l,d]:o<240?{0:p,1:f,2:h}=[0,d,l]:o<300?{0:p,1:f,2:h}=[d,0,l]:{0:p,1:f,2:h}=[l,0,d],[Math.round((p+u)*255),Math.round((f+u)*255),Math.round((h+u)*255)]}return null},qr=(e,t)=>typeof e=="string"||typeof t=="string"?e===t:e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],a2=e=>{if(typeof e!="string")return Ni();const t=Ni(),n=[];let s=!1,r=null,i=0,o="";for(const a of e){if(a==="(")i+=1;else if(i>0)a===")"&&(i-=1);else if(s){if(a===";"){const c=o.trim();c!==""&&n.push([r,c]),r=null,o="",s=!1;continue}}else if(a===":"){r=o.trim(),o="",s=!0;continue}o+=a}if(s&&i===0){const a=o.trim();a!==""&&n.push([r,a]),r=null,o=""}for(const{0:a,1:c}of n)switch(a){case"background-color":{c!=null&&(t.backgroundColor=c);break}case"color":{c!=null&&(t.color=c);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(c)&&(t.fontStyle="italic");break}case"font-weight":{c==="bold"&&(t.fontWeight=c);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const l=c.split(Bc);for(const d of l){const u=qs(d);u!=null?t.textDecorationColor=u:["line-through","overline","underline"].includes(d)&&t.textDecorationLine.push(d)}break}case"text-decoration-color":{const l=qs(c);l!=null&&(t.textDecorationColor=l);break}case"text-decoration-line":{t.textDecorationLine=[];const l=c.split(Bc);for(const d of l)["line-through","overline","underline"].includes(d)&&t.textDecorationLine.push(d);break}}return t},c2=(e,t)=>{t=t??Ni();let n="";if(!qr(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)n+="\x1B[49m";else switch(e.backgroundColor){case"black":{n+="\x1B[40m";break}case"blue":{n+="\x1B[44m";break}case"cyan":{n+="\x1B[46m";break}case"green":{n+="\x1B[42m";break}case"magenta":{n+="\x1B[45m";break}case"red":{n+="\x1B[41m";break}case"white":{n+="\x1B[47m";break}case"yellow":{n+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:s,1:r,2:i}=e.backgroundColor;n+=`\x1B[48;2;${String(s)};${String(r)};${String(i)}m`}else{const s=qs(e.backgroundColor);if(s===null)n+="\x1B[49m";else{const{0:r,1:i,2:o}=s;n+=`\x1B[48;2;${String(r)};${String(i)};${String(o)}m`}}}if(!qr(e.color,t.color))if(e.color==null)n+="\x1B[39m";else switch(e.color){case"black":{n+="\x1B[30m";break}case"blue":{n+="\x1B[34m";break}case"cyan":{n+="\x1B[36m";break}case"green":{n+="\x1B[32m";break}case"magenta":{n+="\x1B[35m";break}case"red":{n+="\x1B[31m";break}case"white":{n+="\x1B[37m";break}case"yellow":{n+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:s,1:r,2:i}=e.color;n+=`\x1B[38;2;${String(s)};${String(r)};${String(i)}m`}else{const s=qs(e.color);if(s===null)n+="\x1B[39m";else{const{0:r,1:i,2:o}=s;n+=`\x1B[38;2;${String(r)};${String(i)};${String(o)}m`}}}if(e.fontWeight!==t.fontWeight&&(n+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(n+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!qr(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)n+="\x1B[59m";else{const{0:s,1:r,2:i}=e.textDecorationColor;n+=`\x1B[58;2;${String(s)};${String(r)};${String(i)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(n+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(n+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(n+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),n},l2=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},Pc="%".codePointAt(0),d2="s".codePointAt(0),u2="d".codePointAt(0),p2="f".codePointAt(0),f2="i".codePointAt(0),h2="O".codePointAt(0),m2="o".codePointAt(0),g2="j".codePointAt(0),y2="c".codePointAt(0),Nc=(e,t=[],n={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);const s=n.stringify??l2,r=1;if(typeof e=="object"){const u=t.length+r;if(u===1)return"{}";const p=Array.from({length:u});p[0]=s(e);for(let f=1;f<u;f+=1)p[f]=s(t[f-r]);return p.join(" ")}if(t.length===0)return e;let i="",o=1-r,a=-1,c=!1,l;const d=n.colors??globalThis.window===void 0;for(let u=0;u<e.length;){if(e.codePointAt(u)===Pc&&u+1<e.length){a=a>-1?a:0;const p=e.codePointAt(u+1);switch(p){case y2:{if(a<u&&(i+=e.slice(a,u)),d){const f=a2(t[o]),h=c2(f,l);i+=h,h!==""&&(c=!0,l=f)}a=u+2,u+=1;break}case u2:case p2:{const f=t[o];if(o>=t.length||f==null)break;a<u&&(i+=e.slice(a,u)),i+=(typeof f=="symbol"?Number.NaN:Number(f)).toString(),a=u+2,u+=1;break}case f2:{const f=t[o];if(o>=t.length||f==null)break;a<u&&(i+=e.slice(a,u)),i+=Math.floor(typeof f=="symbol"?Number.NaN:Number(f)).toString(),a=u+2,u+=1;break}case g2:case h2:case m2:{if(o>=t.length||t[o]===void 0)break;a<u&&(i+=e.slice(a,u));const f=t[o],h=typeof f;if(h==="string"){i+=`'${f}'`,a=u+2,u+=1;break}if(h==="function"){i+=f.name?`[Function: ${f.name}]`:"[Function: <anonymous>]",a=u+2,u+=1;break}i+=s(f),a=u+2,u+=1;break}case Pc:{a<u&&(i+=e.slice(a,u)),i+="%",a=u+2,u+=1,o-=1;break}case d2:{if(o>=t.length)break;a<u&&(i+=e.slice(a,u));const f=t[o];i+=typeof f=="object"&&f!==null?s(f):String(f),a=u+2,u+=1;break}default:typeof n.formatters?.[p]=="function"?(a<u&&(i+=e.slice(a,u)),i+=n.formatters[p](t[o]),a=u+2,u+=1):o-=1}o+=1}u+=1}if(a===-1&&!(n.appendExtraArguments&&o<t.length))return e;if(a===-1?i=e:a<e.length&&(i+=e.slice(a)),a!==-1&&c&&(i+="\x1B[0m"),n.appendExtraArguments&&o<t.length)for(let u=Math.max(o,0);u<t.length;u+=1){const p=t[u];i+=` ${typeof p=="object"&&p!==null?s(p):String(p)}`}return i},v2=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([r,i])=>{if(r.length===0)throw new Error(`Formatter %${r} has no characters`);if(r.length>1)throw new Error(`Formatter %${r} has more than one character`);if(typeof i!="function")throw new TypeError(`Formatter for %${r} is not a function`);const o=r.codePointAt(0);if(o===void 0)throw new Error(`${r}.codePointAt(0) failed to return a value, please report this issue`);t[o]=i});const n={...e};delete n.formatters;const s=Object.freeze({...n,formatters:t});return(r,i=[],o)=>o===void 0?Nc(r,i,s):Nc(r,i,{...n,...o,formatters:t})},b2='"[Circular]"';class w2{#e;#t;#n;constructor(t={}){this.#t=t.formatters}setStringify(t){this.#e=t}process(t){this.#n===void 0&&(this.#n=v2({formatters:this.#t,stringify:s=>this.#i(s)}));const n=this.#n;return t.message!==void 0&&(t.message=this.#s(n,t.message,t.context??[])),t}#i(t){if(this.#e===void 0)try{return JSON.stringify(t)}catch{return b2}try{return this.#e(t)}catch(n){return JSON.stringify(`[unserializable: ${n instanceof Error?n.message:String(n)}]`)}}#s(t,n,s=[]){if(typeof n=="string")return t(n,s);if(typeof n=="object"&&n!==null){const r=n,i=Object.keys(r);for(let o=0;o<i.length;o+=1){const a=i[o],c=r[a];(typeof c=="string"||Array.isArray(c)||typeof c=="object")&&(r[a]=this.#s(t,c,s))}}return n}}const{bgGrey:k2,cyan:S2,green:x2,greenBright:$2,grey:Ae,red:Kr,underline:Dc,white:E2}=nr,C2=/[\\/]pail[\\/]dist/,Yr=e=>!C2.test(e);class R2 extends MS{#e;#t;#n;#i=!1;#s;#r;#o;#a=!1;#c="";#l="";constructor(t={}){const{error:n,inspect:s,...r}=t;super({uppercase:{label:!0,...r.uppercase},...r}),this.#s={...IS,...s},this.#r={...n,color:{fileLine:x2,hint:S2,marker:Kr,message:Kr,method:$2,title:Kr}},this.#e=Eo,this.#t=Co,this.#d()}setLoggerTypes(t){super.setLoggerTypes(t),this.#d()}setStdout(t){this.#e=t,this.#o=void 0,this.#a=!1}setStderr(t){this.#t=t}setInteractiveManager(t){this.#n=t}setIsInteractive(t){this.#i=t}log(t){this._log(this._formatMessage(t),t.type.level)}#d(){this.#c=CS(this.loggerTypes),this.#l=Oi(this.loggerTypes)}#p(){return!this.#a&&typeof this.#e.on=="function"&&(this.#a=!0,this.#e.on("resize",()=>{this.#o=void 0})),this.#o===void 0&&(this.#o=$S().columns),this.#o}_formatMessage(t){let n=this.#p();typeof this.styles.messageLength=="number"&&(n=this.styles.messageLength);const{badge:s,context:r,date:i,error:o,file:a,groups:c,label:l,message:d,prefix:u,repeated:p,scope:f,suffix:h,traceError:m,type:v}=t,{color:$}=this.loggerTypes[v.name],b=$?nr[$]:E2,S=c.map(()=>" ").join(""),C=[];if(c.length>0&&C.push(`${S+Ae(`[${c.at(-1)??""}]`)} `),i&&C.push(`${Ae(this.styles.dateFormatter(typeof i=="string"?new Date(i):i))} `),s)C.push(b(s));else{const N=this.#c;N.length>0&&C.push(`${Ae(".".repeat(N.length))} `)}const P=this.#l;if(l){const N=je(P),_=je(l);C.push(`${b(NS(l,this.styles))} `,Ae(".".repeat(Math.max(0,N-_))))}else C.push(Ae(".".repeat(P.length+2)));p&&C.push(`${k2.white(`[${String(p)}x]`)} `),Array.isArray(f)&&f.length>0&&C.push(` ${Ae(`[${f.join(" > ")}]`)} `),u&&C.push(`${Ae(`${Array.isArray(f)&&f.length>0?". ":" "}[${this.styles.underline.prefix?Dc(u):u}]`)} `);const T=je(C.join(" "));if(a){const N=(a.name??"")+(a.line?`:${String(a.line)}`:""),_=je(N);if(_+T+2>n)C.push(Ae(` ${N}`));else{const F=Math.max(0,n-T-_-2);C.push(Ae(`${".".repeat(F)} ${N}`))}}else C.push(Ae(".".repeat(Math.max(0,n-T-1))));if(C.length>0&&C.push(`
|
|
184
182
|
|
|
185
|
-
`),d!==
|
|
183
|
+
`),d!==ko){const N=typeof d=="string"?d:Js(d,this.#s);C.push(S+SS(N,{trim:!1,width:n-3,wrapMode:Ln.STRICT_WIDTH}))}if(r){let N=!1;C.push(...r.map(_=>{if(_ instanceof Error)return N=!0,`
|
|
186
184
|
|
|
187
|
-
${
|
|
185
|
+
${Vr(_,{...this.#r,filterStacktrace:Yr,prefix:S})}`;if(typeof _=="object")return` ${Js(_,this.#s)}`;const F=(N?`
|
|
188
186
|
|
|
189
|
-
`:" ")+String(
|
|
187
|
+
`:" ")+String(_);return N=!1,F}))}return o&&C.push(Vr(o,{...this.#r,filterStacktrace:Yr,prefix:S})),m&&C.push(`
|
|
190
188
|
|
|
191
|
-
${
|
|
192
|
-
`,S+Ae(this.styles.underline.suffix?
|
|
193
|
-
`),0):
|
|
194
|
-
`,i)}}const ix=()=>Un.NODE_ENV==="debug"||Un.DEBUG!==void 0?"debug":Un.NODE_ENV==="test"?"warning":"informational",Hu=e=>{let t=ix();return Un.PAIL_LOG_LEVEL!==void 0&&(t=Un.PAIL_LOG_LEVEL),new A1({logLevel:t,processors:[new Y1],reporters:[new sx],stderr:So,stdout:ko,...e})};Hu();const E=Hu(),rx=e=>`MARSHALL_DISABLE_${e.replaceAll(/([A-Z])/g,"_$1").toUpperCase()}`,qi=(e,t=process.env)=>Yo(t.MARSHALL_DISABLE_ALL)?!0:Yo(t[rx(e)]),Wu=(e,t)=>{const n={errors:[],warnings:[]},{security:s}=e;if(!s)return n.warnings.push("No security settings configured. Use defineConfig() from '@visulima/vis/config' to get secure defaults automatically."),n;const i=s.policies??{},{installScripts:r}=i,o=r?.allow,a=o&&Object.keys(o).length>0;if(a||n.warnings.push(t==="pnpm"?"security.policies.installScripts.allow is not configured. pnpm blocks build scripts by default since v10. Run 'vis approve-builds' to review.":"security.policies.installScripts.allow is not configured. Consider listing which packages are allowed to run install/postinstall scripts."),i.firstSeen?.minutes===0&&n.warnings.push("security.policies.firstSeen.minutes is explicitly set to 0. New packages can be installed immediately after publishing."),i.publisherChange?.mode==="off"&&n.warnings.push("security.policies.publisherChange.mode is explicitly 'off'. Packages whose trust level has decreased will not be blocked."),s.blockExoticSubdeps===!1&&n.warnings.push("security.blockExoticSubdeps is explicitly disabled. Transitive dependencies can pull code from git repos or tarball URLs."),r?.strict===!1&&n.warnings.push("security.policies.installScripts.strict is explicitly disabled. Unapproved build scripts will only produce warnings, not errors."),r?.strict&&!a&&n.errors.push("security.policies.installScripts.strict is enabled but `.allow` is empty. All dependencies with build scripts will be blocked. Run 'vis approve-builds' to review and add packages."),s.acceptedRisks){const l=Date.now();for(const[d,u]of Object.entries(s.acceptedRisks)){const p=new Date(u.acceptedAt).getTime();l-p>7776e6&&n.warnings.push(`Accepted risk for "${d}" is over 90 days old (accepted ${u.acceptedAt}). Consider re-evaluating with 'vis audit'.`)}}return n},ox=(e,t,n=!1)=>{if(ct&&!process.env.VIS_SECURITY_WARNINGS)return;const s=Wu(e,t);for(const r of s.errors)E.error(r);const i=n?s.warnings.filter(r=>!r.startsWith("security.policies.installScripts.allow is not configured")):s.warnings;i.length>0&&E.warn(`${i.length} security recommendation${i.length===1?"":"s"} found. Run 'vis check --security-config' for details.`)},Kj=(e,t)=>{const n=Wu(e,t),{security:s}=e;if(s){const i=s.policies??{},{firstSeen:r}=i,{publisherChange:o}=i,{installScripts:a}=i,{score:c}=i;if(E.info("Active security settings:"),E.info(` policies.firstSeen.minutes: ${r?.minutes??"not set"} minutes`),E.info(` policies.publisherChange.mode: ${o?.mode??"not set"}`),E.info(` policies.publisherChange.ignoreAfter: ${o?.ignoreAfter??"not set"} minutes`),E.info(` blockExoticSubdeps: ${s.blockExoticSubdeps??!1}`),E.info(` policies.installScripts.strict: ${a?.strict??!1}`),E.info(` policies.installScripts.allow: ${a?.allow?`${Object.keys(a.allow).length} entries`:"not configured"}`),E.info(""),E.info("Socket.dev integration:"),E.info(` socket.enabled: ${s.socket?.enabled??!1}`),E.info(` socket.apiToken: ${s.socket?.apiToken||process.env.VIS_SOCKET_TOKEN?"configured":"using public token"}`),E.info(` policies.score.minimum: ${c?.minimum??"default (0.4)"}`),E.info(` socket.cacheTtlMs: ${s.socket?.cacheTtlMs??"default (1 hour)"}`),E.info(` socket.timeoutMs: ${s.socket?.timeoutMs??"default (15s)"}`),s.acceptedRisks){const l=Object.entries(s.acceptedRisks);E.info(` acceptedRisks: ${String(l.length)} entr${l.length===1?"y":"ies"}`);for(const[d,u]of l)E.info(` ${d}: ${u.reason} (accepted ${u.acceptedAt.slice(0,10)})`)}else E.info(" acceptedRisks: none");E.info("")}if(n.errors.length===0&&n.warnings.length===0){E.info("All recommended security settings are configured.");return}for(const i of n.errors)E.error(i);for(const i of n.warnings)E.warn(i);E.notice(""),E.notice("Secure defaults are applied by defineConfig(). You only need to add install-script allowances:"),E.notice(""),E.notice(" import { defineConfig } from '@visulima/vis/config';"),E.notice(""),E.notice(" export default defineConfig({"),E.notice(" security: {"),E.notice(" policies: {"),E.notice(" installScripts: {"),E.notice(" allow: {"),E.notice(" esbuild: true,"),E.notice(" '@prisma/client': true,"),E.notice(" },"),E.notice(" },"),E.notice(" },"),E.notice(" },"),E.notice(" });")},qj=e=>{const{security:t}=e;if(!t)return[];const n=t.policies??{},{firstSeen:s}=n,{publisherChange:i}=n,{installScripts:r}=n,o=[];return s?.minutes!==void 0&&o.push(`minimumReleaseAge: ${s.minutes}`),i?.mode&&i.mode!=="off"&&o.push(`trustPolicy: ${i.mode}`),t.blockExoticSubdeps&&o.push("blockExoticSubdeps: true"),r?.allow&&o.push(`allowBuilds: ${Object.keys(r.allow).length} entries`),r?.strict&&o.push("strictDepBuilds: true"),i?.ignoreAfter!==void 0&&o.push(`trustPolicyIgnoreAfter: ${i.ignoreAfter}`),o},Uu=e=>{const t=e.trim();if(t==="")return;const n=/^(\d+(?:\.\d+)?)\s*([mhdw]?)$/i.exec(t);if(!n)return;const s=Number.parseFloat(n[1]);if(!(!Number.isFinite(s)||s<0))switch(n[2]?.toLowerCase()){case"":case"m":case void 0:return Math.round(s);case"d":return Math.round(s*1440);case"h":return Math.round(s*60);case"w":return Math.round(s*10080);default:return}},ax=e=>e.startsWith("@")||e.includes("/")||/[:#\s]/.test(e),Yj=e=>ax(e)?`'${e.replaceAll("'","''")}'`:e,cx=e=>{const t=e.trim();return/^\d+$/.test(t)?Number.parseInt(t,10)*1440:Uu(t)},lx=(e,t)=>{const n={};try{switch(e){case"bun":{const s=g(t,"package.json");if(x(s)){const r=le(s);Array.isArray(r.trustedDependencies)&&(n.allowBuilds=new Set(r.trustedDependencies))}const i=g(t,"bunfig.toml");if(x(i)){const r=ih(i),o=r?.install?.minimumReleaseAge;typeof o=="number"&&(n.minReleaseAgeMinutes=Math.round(o/60)),Array.isArray(r?.install?.minimumReleaseAgeExcludes)&&(n.minReleaseAgeExcludes=new Set(r.install.minimumReleaseAgeExcludes))}break}case"npm":{const s=g(t,".npmrc");if(x(s)){const i=G(s),r=/^\s*min-release-age\s*=\s*([^\s#;]+)/m.exec(i);r&&(n.minReleaseAgeMinutes=cx(r[1]))}break}case"pnpm":{const s=g(t,"pnpm-workspace.yaml");if(x(s)){const i=jt(s);i?.allowBuilds&&typeof i.allowBuilds=="object"?n.allowBuilds=new Set(Object.entries(i.allowBuilds).filter(([,r])=>r).map(([r])=>r)):Array.isArray(i?.onlyBuiltDependencies)&&(n.allowBuilds=new Set(i.onlyBuiltDependencies)),typeof i?.minimumReleaseAge=="number"&&(n.minReleaseAgeMinutes=i.minimumReleaseAge),Array.isArray(i?.minimumReleaseAgeExclude)&&(n.minReleaseAgeExcludes=new Set(i.minimumReleaseAgeExclude))}break}case"yarn":{const s=g(t,".yarnrc.yml");if(x(s)){const i=jt(s),r=i?.npmMinimalAgeGate;typeof r=="string"?n.minReleaseAgeMinutes=Uu(r):typeof r=="number"&&(n.minReleaseAgeMinutes=r),Array.isArray(i?.npmPreapprovedPackages)&&(n.minReleaseAgeExcludes=new Set(i.npmPreapprovedPackages))}break}default:break}}catch{}return n},dx=(e,t,n)=>{const s=lx(t,n),i={hasDrift:!1,packageManager:t},o=(e.security??{}).policies??{},{installScripts:a}=o,{firstSeen:c}=o;if(a?.allow&&(t==="pnpm"||t==="bun")){const l=new Set(Object.entries(a.allow).filter(([,f])=>f).map(([f])=>f)),d=s.allowBuilds??new Set,u=[...l].filter(f=>!d.has(f)),p=[...d].filter(f=>!l.has(f));(u.length>0||p.length>0)&&(i.allowBuilds={onlyInPm:p,onlyInVis:u},i.hasDrift=!0)}if(c?.minutes!==void 0&&!(t==="yarn"&&s.minReleaseAgeMinutes===void 0&&!x(g(n,".yarnrc.yml")))&&s.minReleaseAgeMinutes!==c.minutes&&(i.minReleaseAge={pm:s.minReleaseAgeMinutes,vis:c.minutes},i.hasDrift=!0),c?.exclude&&(t==="pnpm"||t==="bun"||t==="yarn")){const l=new Set(c.exclude),d=s.minReleaseAgeExcludes??new Set,u=[...l].filter(f=>!d.has(f)),p=[...d].filter(f=>!l.has(f));(u.length>0||p.length>0)&&(i.minReleaseAgeExcludes={onlyInPm:p,onlyInVis:u},i.hasDrift=!0)}return i},ux=e=>{if(!e.hasDrift)return[];const t=[`vis.config and ${e.packageManager}-native config disagree on security settings:`];if(e.allowBuilds&&(e.allowBuilds.onlyInVis.length>0&&t.push(` security.policies.installScripts.allow — only in vis.config: ${e.allowBuilds.onlyInVis.join(", ")}`),e.allowBuilds.onlyInPm.length>0&&t.push(` security.policies.installScripts.allow — only in ${e.packageManager} config: ${e.allowBuilds.onlyInPm.join(", ")}`)),e.minReleaseAge){const n=e.minReleaseAge.vis===void 0?"unset":`${String(e.minReleaseAge.vis)} min`,s=e.minReleaseAge.pm===void 0?"unset":`${String(e.minReleaseAge.pm)} min`;t.push(` security.policies.firstSeen.minutes — vis.config: ${n}, ${e.packageManager}: ${s}`)}return e.minReleaseAgeExcludes&&(e.minReleaseAgeExcludes.onlyInVis.length>0&&t.push(` security.policies.firstSeen.exclude — only in vis.config: ${e.minReleaseAgeExcludes.onlyInVis.join(", ")}`),e.minReleaseAgeExcludes.onlyInPm.length>0&&t.push(` security.policies.firstSeen.exclude — only in ${e.packageManager} config: ${e.minReleaseAgeExcludes.onlyInPm.join(", ")}`)),t.push(" Run 'vis security sync' to push vis.config values to the native config."),t},px=e=>x(g(e,".yarnrc.yml")),fx=(e,t,n)=>{const s={extraArgs:[],postInstallPackages:[],scriptsBlockedByDefault:!1,warnings:[]},i=n.security?.policies?.installScripts?.allow??{},r=Object.keys(i).length>0;switch(e){case"bun":{if(s.scriptsBlockedByDefault=!0,r){const o=g(t,"package.json");try{(x(o)?le(o):{}).trustedDependencies?.length||s.warnings.push("vis security.policies.installScripts.allow is configured but trustedDependencies is empty. Run 'vis approve-builds --sync-native'.")}catch{}}break}case"npm":{s.scriptsBlockedByDefault=!1;const o=g(t,".npmrc"),a=x(o)&&/^\s*ignore-scripts\s*=\s*true\s*$/m.test(G(o));if(!a&&r?(s.warnings.push("npm does not block lifecycle scripts. vis will add --ignore-scripts automatically."),s.extraArgs.push("--ignore-scripts")):!a&&!r&&s.warnings.push("npm does not block lifecycle scripts. Add 'ignore-scripts=true' to .npmrc and configure security.policies.installScripts.allow."),r)for(const[c,l]of Object.entries(i))l&&s.postInstallPackages.push(c);break}case"pnpm":{s.scriptsBlockedByDefault=!0,r||s.warnings.push("pnpm blocks build scripts by default. Run 'vis approve-builds' to review packages that need scripts.");break}case"yarn":{if(s.scriptsBlockedByDefault=!1,px(t)){const o=G(g(t,".yarnrc.yml"));/^\s*enableScripts\s*:\s*false\s*$/m.test(o)?s.scriptsBlockedByDefault=!0:s.warnings.push("yarn berry supports enableScripts. Add 'enableScripts: false' to .yarnrc.yml.")}else if(s.warnings.push("yarn classic does not support blocking lifecycle scripts. Consider upgrading to yarn berry."),r){s.extraArgs.push("--ignore-scripts");for(const[o,a]of Object.entries(i))a&&s.postInstallPackages.push(o)}break}}return s},Gu=(...e)=>{const t={...process.env},n=t.PATH??t.Path??"",s=e.filter(i=>i.length>0).join(Ko);return t.PATH=s.length>0?n?`${s}${Ko}${n}`:s:n,t},hx=e=>{if(e.endsWith("*"))return e.endsWith("@*")?e.slice(0,-2):e;const t=e.startsWith("@"),n=e.indexOf("@",t?1:0);return n===-1?e:e.slice(0,n)},mx=(e,t)=>{const n=g(e,"node_modules"),s=[];for(const i of t){if(!i.endsWith("*")){s.push(hx(i));continue}const r=i.slice(0,-1);try{if(r.startsWith("@")&&r.endsWith("/")){const o=g(n,r.slice(0,-1));for(const a of Te(o))!a.startsWith(".")&&Tt(g(o,a)).isDirectory()&&s.push(`${r.slice(0,-1)}/${a}`)}else for(const o of Te(n))o.startsWith(r)&&Tt(g(n,o)).isDirectory()&&s.push(o)}catch{}}return s},gx=(e,t)=>{if(t.length===0)return;const n=mx(e,t);if(n.length===0)return;const s=g(e,"node_modules"),i=g(s,".bin");let r=!1;for(const o of n){if(o.includes("..")||o.startsWith("/")||o.startsWith("\\")){E.warn(`Skipping invalid package name: ${o}`);continue}const a=(o.match(/\//g)??[]).length;if(a>1||a===1&&!o.startsWith("@")){E.warn(`Skipping invalid package name: ${o}`);continue}const c=g(s,o),l=g(c,"package.json");if(x(l))try{const d=le(l).scripts??{},u=g(c,"node_modules",".bin"),p=Gu(u,i);for(const f of["preinstall","install","postinstall"])if(d[f]){E.info(`Running ${f} for ${o}...`);try{const h=d[f];rl(h,{cwd:c,env:p,stdio:"inherit"})}catch{E.error(`${f} script failed for ${o}`),r=!0}}}catch{}}r&&(process.exitCode=1)},Xj=(e,t=["prepublish","prepare"])=>{const n=g(e,"package.json");if(!x(n))return;let s;try{s=le(n).scripts??{}}catch{return}let i=!1;const r=Gu(g(e,"node_modules",".bin"));for(const o of t){const a=s[o];if(a){E.info(`Running root ${o}...`);try{rl(a,{cwd:e,env:r,stdio:"inherit"})}catch{E.error(`Root ${o} script failed.`),i=!0}}}i&&(process.exitCode=1)},Yi=new Set(["add","install","update"]),yx=new Set(["add","dedupe","install","remove","update"]),vx=/(\d+\.\d+\.\d+)/,bx=e=>{const t=g(e,"package.json");if(!x(t))return[];const n=[];try{const s=le(t),i={...s.dependencies,...s.devDependencies};for(const[r,o]of Object.entries(i)){const a=g(e,"node_modules",r,"package.json");if(x(a))try{const l=le(a);if(l.version){n.push({name:r,version:l.version});continue}}catch{}const c=vx.exec(o);c?.[1]&&n.push({name:r,version:c[1]})}}catch{}return n},wx={afterCommand:async e=>{if(process.exitCode&&process.exitCode!==0)return;const t=e.scriptEnforcement;t?.postInstallPackages.length&&e.workspaceRoot&&gx(e.workspaceRoot,t.postInstallPackages);const n=process.argv[2]??"",s=Yi.has(n)&&e.workspaceRoot?Xo(e.workspaceRoot):void 0;if(s&&e.visConfig&&e.workspaceRoot&&new Set(["bun","npm","pnpm","yarn"]).has(s.name)){const r=dx(e.visConfig,s.name,e.workspaceRoot);if(r.hasDrift){E.info("");for(const o of ux(r))E.warn(o)}}if(Yi.has(n)&&e.workspaceRoot){const i=new Set;qi("socket")&&i.add("socket"),qi("depsDev")&&i.add("deps-dev");const r=e.visConfig?.security?.policies?.score?.minimum,o=Nf(e.visConfig?.security,{disabled:i,minimumScore:r});if(o.length>0)try{const a=bx(e.workspaceRoot);if(a.length>0){const c=await Df(o,a);if(c.size>0){const l=th(c,r);if(l){E.info(""),E.info(l);let d=0;for(const u of c.values())for(const p of u.alerts)(p.severity==="critical"||p.severity==="high")&&d++;d>0&&E.warn(`${String(d)} critical/high severity alert${d===1?"":"s"} detected. Run 'vis check --security' for details.`)}}}}catch{}}},beforeCommand:async e=>{const t=process.argv[2]??"";if(yx.has(t)&&e.visConfig&&e.workspaceRoot){const n=Xo(e.workspaceRoot),s=Yi.has(t);if(ox(e.visConfig,n.name,s),s&&!qi("installScripts")){const i=fx(n.name,e.workspaceRoot,e.visConfig);for(const r of i.warnings)e.logger.warn(`security: ${r}`);e.scriptEnforcement=i}}},name:"security-enforcement"};class Eo extends pf{troubleshooting;constructor(t,n,s=[]){super(t,n,{troubleshooting:s}),this.name="CompletionError",this.troubleshooting=s,s.length>0&&(this.hint=s.join(`
|
|
195
|
-
`))}}const
|
|
196
|
-
`);e.info(n)},
|
|
197
|
-
`)),o}else{const a=["Failed to generate completion script",`Error: ${o instanceof Error?o.message:String(o)}`,"","Troubleshooting:"," • Ensure @bomb.sh/tab is installed: pnpm add @bomb.sh/tab",` • Verify shell is supported: ${
|
|
198
|
-
`))}}},name:"completion",options:[{defaultOption:!0,defaultValue:Bc(),description:"Shell type (bash, zsh, fish, powershell). Defaults to current shell if detected.",name:"shell",type:String,typeLabel:"{underline shell}"},{defaultValue:Ic(),description:"JavaScript runtime (node, bun, deno). Defaults to current runtime if detected.",name:"runtime",type:String,typeLabel:"{underline runtime}"}]},Ox={alias:["v","V"],description:"Output the version number",execute:({logger:e,runtime:t})=>{const n=t.getPackageVersion();n===void 0?(e.warn("Unknown version"),e.debug("The version number was not provided by the cli constructor.")):e.info(n)},name:"version",options:[],usage:[]},Ax={argument:{description:"Target selector (same syntax as `vis run`): `build`, `:build`, `~:test`, `#tag:lint`, …",name:"selector",type:String},description:"Show the execution plan for a target without running it",examples:[["vis action-graph build","Print the task plan for `build` on every project"],["vis action-graph :test","Moon-style selector"],["vis action-graph build --json","Emit a JSON description of the plan"],['vis action-graph lint --query "tag=frontend"',"Filter projects by query"],["vis action-graph build --projects=@org/web","Plan only the named projects (same flag as `vis run`)"]],group:"Workspace",loader:()=>import("./handler2.js"),name:"action-graph",options:[{defaultValue:!1,description:"Emit JSON instead of ASCII",name:"json",type:Boolean},{alias:"p",description:"Comma-separated list of projects to plan (same semantics as `vis run --projects`)",name:"projects",type:String},{description:"Filter matched projects by a query",name:"query",type:String},{description:'Only plan projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…".',multiple:!0,name:"tag",type:String}]},Ix={argument:{description:"Packages to add (e.g., react react-dom)",name:"packages",type:String},description:"Add packages using the detected package manager",examples:[["vis add react react-dom","Add packages"],["vis add -D typescript @types/react","Add as dev dependencies"],["vis add react --filter app","Add to specific workspace package"],["vis add react --to web","Add to one package, auto-conforming the version to existing catalogs / sibling deps"],["vis add -g typescript","Add globally (uses npm)"],["vis add lodash -w","Add to workspace root"],["vis add lodash --no-socket-check","Add without Socket.dev check"],["vis add lodash --no-typosquat-check","Skip typosquat name check"],["vis add lodash --no-marshall-check","Skip the offline marshall pipeline (author, downloads, etc.)"],["vis add lodash --run-scripts","Run lifecycle scripts (opts out of vis's default block-by-default policy)"]],group:"Dependencies",loader:()=>import("./handler15.js"),name:"add",options:[{alias:"D",defaultValue:!1,description:"Add as dev dependency",name:"save-dev",type:Boolean},{alias:"E",defaultValue:!1,description:"Save exact version",name:"exact",type:Boolean},{alias:"P",defaultValue:!1,description:"Add as peer dependency",name:"save-peer",type:Boolean},{alias:"O",defaultValue:!1,description:"Add as optional dependency",name:"save-optional",type:Boolean},{alias:"g",defaultValue:!1,description:"Install globally (uses npm)",name:"global",type:Boolean},{alias:"w",defaultValue:!1,description:"Add to workspace root",name:"workspace-root",type:Boolean},{defaultValue:!1,description:"Use workspace protocol (pnpm)",name:"workspace",type:Boolean},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String},{description:"Target a single workspace package and auto-conform the version to existing catalogs / sibling deps (syncpack#285)",name:"to",type:String},{defaultValue:!1,description:"Skip typosquat name check before adding",name:"no-typosquat-check",type:Boolean},{defaultValue:!1,description:"Skip Socket.dev security check before adding",name:"no-socket-check",type:Boolean},{defaultValue:!1,description:"Skip the offline marshall pipeline (author, provenance, metadata, downloads, expired-domains, new-bin, signatures, archived-repo)",name:"no-marshall-check",type:Boolean},{defaultValue:!1,description:"Run lifecycle scripts during add (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)",name:"run-scripts",type:Boolean},{defaultValue:!1,description:"After adding, recursively install non-optional peer dependencies that aren't already in the workspace (matches nypm's installPeerDependencies)",name:"auto-install-peers",type:Boolean}]},Co={description:"Override the cache DB path (defaults to <cache>/vis/advisories/db.sqlite via @visulima/find-cache-dir).",name:"db",type:String},ls={description:"Output format: table (default) or json.",name:"format",type:String},Bx={commandPath:["advisories"],description:"Download and ingest one or more OSV ecosystem dumps into the local cache",examples:[["vis advisories sync","Sync the npm ecosystem (default)"],["vis advisories sync --ecosystem npm","Sync a single explicit ecosystem"],["vis advisories sync --ecosystem npm,PyPI","Sync several ecosystems in one pass"],["vis advisories sync --force","Re-download even when the ETag matches"],["vis advisories sync --source https://mirror.example.com","Use a corporate OSV mirror (must be in allowedHosts)"]],group:"Security & Health",loader:Z(()=>import("./sync.js"),"advisoriesSyncExecute"),name:"sync",options:[{description:"Comma-separated list of ecosystems to sync (default: npm).",name:"ecosystem",type:String},{defaultValue:!1,description:"Re-download and re-ingest even if the upstream ETag is unchanged.",name:"force",type:Boolean},{description:"Override the advisory source URL. Must be https and resolve to an allowed host.",name:"source",type:String},Co,ls]},Px={commandPath:["advisories"],description:"Print the local advisory DB summary: path, schema version, ecosystems, row counts, last sync, ETag",examples:[["vis advisories status","Human-readable summary"],["vis advisories status --format json","Machine-readable for CI freshness checks"]],group:"Security & Health",loader:Z(()=>import("./status.js"),"advisoriesStatusExecute"),name:"status",options:[Co,ls]},Nx={commandPath:["advisories"],description:"Delete the local advisory DB. The next `vis audit --offline` will fail until you re-sync",examples:[["vis advisories prune","Confirm and delete the local DB"],["vis advisories prune --force","Delete without confirmation"]],group:"Security & Health",loader:Z(()=>import("./prune.js"),"advisoriesPruneExecute"),name:"prune",options:[Co,{defaultValue:!1,description:"Skip the confirmation prompt.",name:"force",type:Boolean},ls]},zu={description:"Override the bloom cache directory (defaults to <cache>/vis/osv-bloom/).",name:"cache-dir",type:String},Dx={commandPath:["advisories","bloom"],description:"Fetch and verify the endevco/osv-bloom MAL-* prefilter into the local cache",examples:[["vis advisories bloom sync","Fetch the bloom filter from the default upstream"],["vis advisories bloom sync --force","Re-download even when the set digest matches"],["vis advisories bloom sync --source https://bloom.example.com","Use an internal mirror (must be in allowedHosts)"]],group:"Security & Health",loader:Z(()=>import("./bloom-sync.js"),"advisoriesBloomSyncExecute"),name:"sync",options:[{defaultValue:!1,description:"Re-download and re-verify even when the upstream set digest is unchanged.",name:"force",type:Boolean},{description:"Override the bloom source URL. Must be https and resolve to an allowed host.",name:"source",type:String},zu,ls]},Mx={commandPath:["advisories","bloom"],description:"Print the local osv-bloom cache freshness: built-at, filter size, m/k parameters, set digest",examples:[["vis advisories bloom status","Human-readable summary"],["vis advisories bloom status --format json","Machine-readable for CI freshness checks"]],group:"Security & Health",loader:Z(()=>import("./bloom-status.js"),"advisoriesBloomStatusExecute"),name:"status",options:[zu,ls]},Lx=[Bx,Px,Nx,Dx,Mx],Ge=e=>[e,{description:`Disable --${e.name}.`,hidden:!0,name:`no-${e.name}`,type:Boolean}],_x={argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target only on projects affected by recent changes",examples:[["vis affected build","Run build on affected projects"],["vis affected test --base=main","Run tests on projects changed since main"],["vis affected destroy --reverse","Tear down affected projects leaves-first"],["vis affected build --sparse-checkout","Print a git sparse-checkout cone set for the affected projects and exit"]],group:"Run & Execute",loader:()=>import("./handler3.js"),name:"affected",options:[{description:"Git base ref for comparison. When omitted, vis auto-resolves it from the active CI provider (GitHub/GitLab/Buildkite/CircleCI) or falls back to `git merge-base HEAD origin/<defaultBase>` locally. Default base branch comes from `vis.config.ts#defaultBase` (or `main`).",name:"base",type:String},{description:"Git head ref for comparison. When omitted, auto-resolves from CI env (e.g. `$GITHUB_SHA`) or defaults to `HEAD`.",name:"head",type:String},...Ge({description:"Include uncommitted working-tree changes (tracked edits and untracked files) in the changed-file set. Defaults to on for local runs and off in CI; use --no-uncommitted to force off.",name:"uncommitted",type:Boolean}),{defaultValue:"deep",description:'Downstream scope: "none", "direct", or "deep" — controls how far to include dependents of changed projects',name:"downstream",type:String},{defaultValue:"none",description:'Upstream scope: "none", "direct", or "deep" — controls how far to include dependencies of changed projects',name:"upstream",type:String},{defaultValue:3,description:"Maximum number of parallel tasks",name:"parallel",type:Number},...Ge({defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean}),{defaultValue:!1,description:"Show what would run without executing",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Instead of running, print the affected project roots as a git sparse-checkout cone set (one path per line) and exit. Pipe into `git sparse-checkout set --stdin` to shrink huge-monorepo CI checkouts.",name:"sparse-checkout",type:Boolean},{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',name:"partition",type:String},{description:"Filter affected projects by a query (e.g. 'language=typescript && tag=lib')",name:"query",type:String},{description:'Only run affected projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…"; combines with --query as AND.',multiple:!0,name:"tag",type:String},{defaultValue:!1,description:"Run the dependency graph in reverse (leaves first, then their dependents). Useful for teardown targets like `destroy`/`undeploy` where dependents must run before the things they depend on.",name:"reverse",type:Boolean},{description:"Comma-separated tags this runner advertises (e.g. 'gpu,slow'). Forwarded verbatim to the downstream `vis run` so capability-gated tasks resolve identically. Falls back to VIS_RUNNER_TAGS env var.",name:"runner-tags",type:String}]},Ju={description:"Output format: table or json (default: table)",name:"format",type:String},Fx={commandPath:["ai"],description:"List detected AI providers and show which one is selected",examples:[["vis ai providers","List all AI providers and their status"],["vis ai providers --format json","Output as JSON"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiProvidersExecute"),name:"providers",options:[Ju]},Vx={commandPath:["ai"],description:"Test the best available AI provider with a quick prompt",examples:[["vis ai test","Test the selected provider"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiTestExecute"),name:"test",options:[]},Hx={argument:{description:"Task ID to propose a fix for (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["ai"],description:"Read a failed task's logs and propose a structured patch (Phase 1: local-only, no git)",examples:[["vis ai fix @myorg/app:build","Print proposed patch for the failed task"],["vis ai fix @myorg/app:build --apply","Apply the patch to disk after confirming"],["vis ai fix @myorg/app:build --format json","Machine-readable patch output"],["vis ai fix @myorg/app:build --run 2026-04-28T...","Inspect a specific historical run"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiFixExecute"),name:"fix",options:[Ju,{description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},{defaultValue:!1,description:"Apply the proposed patch to disk after printing it",name:"apply",type:Boolean},{defaultValue:!1,description:"Bypass the AI response cache",name:"no-cache",type:Boolean},{defaultValue:!1,description:"Skip the confirmation prompt before applying",name:"yes",type:Boolean}]},Wx={description:"AI-assisted commands: provider detection and failure-fix proposals (cache management lives under `vis cache`)",examples:[["vis ai","List all AI subcommands"],["vis ai discover-help","Machine-readable subcommand catalogue (for AI agents)"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiRootExecute"),name:"ai",options:[]},Ux={commandPath:["ai"],description:"Print the machine-readable AI subcommand catalogue (JSON to stdout, designed for AI agents)",examples:[["vis ai discover-help","Emit the discovery payload as JSON"],["vis ai discover-help | jq '.subcommands[].path'","List all available paths"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiDiscoverHelpExecute"),name:"discover-help",options:[]},Gx={commandPath:["ai"],description:"Diagnose the most recent failed task and post a structured patch as a PR/MR comment (or Buildkite annotation)",examples:[["vis ai heal","Heal the most recent failure"],["vis ai heal --dry-run","Propose a patch but skip apply / validate / post"],["vis ai heal --run 2026-04-28T...","Heal a specific historical run"]],group:"System",loader:Z(()=>import("./heal.js").then(e=>e.h),"aiHeal"),name:"heal",options:[{defaultValue:!1,description:"Show the proposal and exit without applying or posting it",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Bypass the AI response cache",name:"no-cache",type:Boolean},{description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},{description:"Per-task validation timeout in seconds (default: 1800)",name:"validation-timeout",type:Number}]},zx={commandPath:["ai","heal"],description:"Re-run the proposed fix and commit it to the PR/MR branch when validation passes",examples:[["vis ai heal accept","Triggered automatically by a `/vis heal accept` PR comment (GitHub/GitLab) or a Buildkite block-step unblock"]],group:"System",loader:Z(()=>import("./heal-accept.js"),"aiHealAccept"),name:"accept",options:[{description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},{description:"Per-task validation timeout in seconds (default: 1800)",name:"validation-timeout",type:Number}]},Ku=[Wx,Ux,Fx,Vx,Hx,Gx,zx],Zj=Object.defineProperty({__proto__:null,default:Ku},Symbol.toStringTag,{value:"Module"}),Jx={argument:{description:"Package name to analyze (e.g., react)",name:"package",required:!0,type:String},description:"Analyze a single package update with AI",examples:[["vis analyze react","Analyze updating react to latest"],["vis analyze react 19.0.0","Analyze updating react to specific version"],["vis analyze react --ai-type security","Run security-focused analysis"],["vis analyze react --format json","Output as JSON"]],group:"System",loader:()=>import("./handler4.js"),name:"analyze",options:[{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",name:"ai-type",type:String},{defaultValue:!1,description:"Check for known security vulnerabilities",name:"security",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]},Kx={description:"Review and approve dependencies with build scripts",examples:[["vis approve-builds","Scan and list unapproved build scripts"],["vis approve-builds --all","Approve all pending builds (pnpm)"],["vis approve-builds --write","Write unapproved entries into vis.config.ts security.policies.installScripts.allow"],["vis approve-builds --sync-native","Sync allowBuilds to native PM config"]],group:"Security & Health",loader:()=>import("./handler51.js"),name:"approve-builds",options:[{defaultValue:!1,description:"Approve all pending builds without prompting (pnpm only)",name:"all",type:Boolean},{defaultValue:!1,description:"Force vis scanning even for pnpm (instead of delegating)",name:"scan",type:Boolean},{defaultValue:!1,description:"Sync allowBuilds to native PM config (bun: trustedDependencies, npm: .npmrc, yarn: .yarnrc.yml)",name:"sync-native",type:Boolean},{defaultValue:!1,description:"Write unapproved entries directly into vis.config.ts security.policies.installScripts.allow (LavaMoat 'auto' parity)",name:"write",type:Boolean}]},qu={description:"Output format: table, json, or ndjson (default: table). json/ndjson go to stdout, logs to stderr.",name:"format",type:String},qx={commandPath:["attest"],description:"Verify inbound provenance + registry signatures across the locked dependency graph and gate on regressions",examples:[["vis attest verify","Check every locked dep for provenance regressions and signature problems"],["vis attest verify --prod-only","Skip devDependencies"],["vis attest verify --format json","Machine-readable findings for CI (Axis A)"],["vis attest verify --fail-on error","Exit non-zero only on error-severity findings (default: any finding)"]],group:"Security & Health",loader:Z(()=>import("./handler5.js"),"attestVerifyExecute"),name:"verify",options:[qu,{defaultValue:!1,description:"Skip devDependencies — verify the production graph only.",name:"prod-only",type:Boolean},{description:"Severity that triggers a non-zero exit: 'warning' (any finding, default) or 'error'.",name:"fail-on",type:String},{description:"Comma-separated package names to exclude from both marshalls.",name:"allowlist",type:String}]},Yx={argument:{description:"Path to the built artifact to attest (e.g. dist/app.tgz). Its sha256 becomes the in-toto subject digest.",name:"subject",type:String},description:"Build an in-toto SLSA v1 provenance statement for an artifact and keyless-sign it via Sigstore",examples:[["vis attest dist/app.tgz","Emit dist/app.tgz.sigstore (keyless-signed in CI)"],["vis attest dist/app.tgz --output attest.sigstore","Write the bundle to a specific path"],["vis attest dist/app.tgz --predicate slsaProvenance","Predicate type (default: slsaProvenance)"],["vis attest dist/app.tgz --require-signing","Fail instead of skip-with-warn when no ambient OIDC (outside CI)"],["vis attest dist/app.tgz --format json","Print the signed bundle summary as JSON (Axis A)"]],group:"Security & Health",loader:Z(()=>import("./handler5.js"),"attestEmitExecute"),name:"attest",options:[qu,{description:"Write the serialized Sigstore bundle here (default: <subject>.sigstore).",name:"output",type:String},{description:"Predicate type: 'slsaProvenance' (default, https://slsa.dev/provenance/v1).",name:"predicate",type:String},{defaultValue:!1,description:"Error instead of skip-with-warn when no ambient OIDC token is available (i.e. outside CI).",name:"require-signing",type:Boolean}]},Xx=[Yx,qx],Zx={description:"Audit installed packages for vulnerabilities and supply chain risks",examples:[["vis audit","Full audit of all installed packages"],["vis audit --severity high","Show only high/critical issues"],["vis audit --format json","Output as JSON for CI integration"],["vis audit --format sarif","Output SARIF 2.1.0 for code-scanning uploads"],["vis audit --format csaf","Output CSAF 2.0 csaf_vex for enterprise vuln pipelines"],["vis audit --format cyclonedx-vex","Output a CycloneDX 1.7 BOM with vulnerabilities[] (SBOM + VEX)"],["vis audit --format gitlab","Output a GitLab dependency-scanning report (gl-dependency-scanning.json)"],["vis audit --format junit","Output a Surefire-compatible JUnit XML report"],["vis audit --report report.html","Write a self-contained HTML report to ./report.html"],["vis audit --usage","Only report vulnerabilities in statically-imported packages"],["vis audit --offline","Query the local OSV cache only (no network)"],["vis audit --offline --db ./vendor.sqlite","Use a specific advisory DB"],["vis audit --ecosystem npm,pypi","Scan multiple OSV ecosystems (npm, pypi, crates.io, maven, go, rubygems)"],["vis audit --prod-only","Skip devDependencies"],["vis audit --fail-on high","Exit non-zero on any high or critical finding"],["vis audit --show-fixes","Print fix-suggestion lines (no apply, no rescan)"],["vis audit --fix","Apply direct-dep upgrades for vulnerable packages, then rescan (dry-run preview by default)"],["vis audit --fix --yes","Skip the confirmation prompt and run the upgrades immediately"],["vis audit --fix --allow-major","Permit major-version bumps when the lowest fix is outside the existing range"],["vis audit --fix-transitive","Write PM-specific overrides for vulnerable transitives (dry-run preview by default)"],["vis audit --exit-code","Exit with code 1 if issues found (for CI)"],["vis audit --show-accepted","Include acknowledged risks in output"],["vis audit --sync","Sync accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)"],["vis audit --policies license,vulnerability","Run only the named policies (default: every configured policy)"],["vis audit --policies none","Skip the policy engine entirely"],["vis audit --explain","Add a plain-English AI explanation under every finding (auto-detects an installed AI CLI)"],["vis audit --explain CVE-2021-23337","Explain only the finding with this CVE/GHSA id"],["vis audit --explain 2","Explain only the 2nd finding"]],group:"Security & Health",loader:()=>import("./handler72.js"),name:"audit",options:[{description:"Minimum severity to report: low, medium, high, critical (default: low)",name:"severity",type:String},{description:"Output format: table, json, sarif, csaf, cyclonedx-vex, gitlab, or junit (default: table)",name:"format",type:String},{description:"Write a self-contained HTML report to this path. Auto-opens in a TTY when not in CI.",name:"report",type:String},{defaultValue:!1,description:"Only report vulnerabilities in statically-imported packages (reachability filter).",name:"usage",type:Boolean},{defaultValue:!1,description:"Disable the reachability filter even if enabled in config.",name:"no-usage",type:Boolean},{defaultValue:!1,description:"Query the local OSV advisory cache only — no network calls. Errors if the cache is missing.",name:"offline",type:Boolean},{description:"Override the offline advisory DB path (default: <cache>/vis/advisories/db.sqlite).",name:"db",type:String},{description:"Comma-separated list of OSV ecosystems to scan (default: npm). Supported: npm, pypi, crates.io (or 'cargo'), maven, go, rubygems. Non-npm ecosystems require --offline (online OSV path is npm-only).",name:"ecosystem",type:String},{defaultValue:!1,description:"Skip devDependencies — scan production graph only.",name:"prod-only",type:Boolean},{description:"Exit non-zero when any finding is at this severity or higher. One of: low, medium, high, critical.",name:"fail-on",type:String},{defaultValue:!1,description:"Print fix-suggestion lines for each finding (no apply, no rescan)",name:"show-fixes",type:Boolean},{defaultValue:!1,description:"Apply direct-dep fixes for vulnerable packages by running the active PM update command, then rescan",name:"fix",type:Boolean},{defaultValue:!1,description:"Apply transitive fixes by writing PM-specific overrides (pnpm-workspace.yaml / package.json overrides / resolutions)",name:"fix-transitive",type:Boolean},{defaultValue:!1,description:"Skip confirmation prompt for --fix / --fix-transitive (required in CI)",name:"yes",type:Boolean},{defaultValue:!1,description:"Allow --fix to bump a direct dep across a major version when the lowest fix is outside the existing range",name:"allow-major",type:Boolean},{defaultValue:!1,description:"Exit with code 1 if any issues found (for CI)",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Include acknowledged (accepted risk) issues in output",name:"show-accepted",type:Boolean},{defaultValue:!1,description:"Sync vis accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)",name:"sync",type:Boolean},{description:"Comma-separated list of supply-chain policies to evaluate (default: every configured policy). Use 'none' to skip the engine entirely, 'all' to force the full set. Known: malware, firstSeen, unexpectedDeps, publisherChange, installScripts, score, vulnerability, license.",name:"policies",type:String},{description:"Audit backend: 'auto' (default, delegates to 'aube audit' when aube is the installer), 'aube' (force delegate), or 'vis' (always use vis's OSV/Socket scanner).",name:"backend",type:String},{description:"Add a plain-English AI explanation to findings. Bare flag explains all findings at/above --severity; pass a finding index (e.g. 2) or a CVE/GHSA id to explain just one. Auto-detects an installed AI CLI; mutually exclusive with --offline.",name:"explain",type:String}]},ds={description:"Cache directory (overrides config and default). Relative paths are resolved against the workspace root.",name:"cache-dir",type:String},gi={description:"Cache scope: 'shared' (default — main worktree's cache), 'worktree' (this checkout's local cache), or 'all' (both)",name:"scope",type:String},Yu={description:"Cache type: 'task' (workspace task cache), 'ai' (AI response cache), 'socket' (Socket.dev reports), 'deps-dev' (Google deps.dev reports), or 'all' (default)",name:"type",type:String},Qx={commandPath:["cache"],description:"List all cache entries",examples:[["vis cache list","List all cache entries"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheListExecute"),name:"list",options:[ds,gi,{description:"Output format: table or json (default: table)",name:"format",type:String}]},e$={commandPath:["cache"],description:"Remove cache entries (defaults to all stores: workspace task cache, AI responses, Socket.dev reports)",examples:[["vis cache clean","Remove all cache entries from every store"],["vis cache clean --type=ai","Clear only the AI response cache"],["vis cache clean --type=task","Clear only the workspace task cache"],["vis cache clean --dry-run","Preview what clean would remove"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheCleanExecute"),name:"clean",options:[ds,Yu,{defaultValue:!1,description:"Preview without deleting",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Skip the confirmation prompt for out-of-workspace cache directories",name:"force",type:Boolean}]},t$={commandPath:["cache"],description:"Remove old and oversized cache entries",examples:[["vis cache prune","Remove old and oversized entries"],["vis cache prune --max-age-days=3 --max-size=500MB","Prune with custom limits"],["vis cache prune --keep-last=30","Keep only the 30 most recent entries"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cachePruneExecute"),name:"prune",options:[ds,gi,{description:"Remove entries older than N days",name:"max-age-days",type:Number},{description:"Evict oldest entries until cache is under this size (e.g. 500MB)",name:"max-size",type:String},{description:"Keep only the N most recent entries (sorted newest-first by mtime)",name:"keep-last",type:Number}]},n$={commandPath:["cache"],description:"Print on-disk footprint and stats for one or more cache stores (task / ai / socket)",examples:[["vis cache size","Show stats for every cache store"],["vis cache size --type=ai","Show only the AI response cache (entries, size, oldest, newest)"],["vis cache size --type=task --format=json","Machine-readable task cache size"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheSizeExecute"),name:"size",options:[ds,gi,Yu,{description:"Output format: table or json (default: table)",name:"format",type:String}]},Ro={description:"Output format: table or json (default: table)",name:"format",type:String},Xu={description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},s$={argument:{description:"Task ID to explain (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Explain why a task missed the cache by diffing hash inputs against the previous run",examples:[["vis cache why @myorg/app:build","Show which inputs changed since the last run"],["vis cache why @myorg/app:build --json","Machine-readable output for CI"],["vis cache why @myorg/app:build --run 2026-04-28T...","Inspect a specific historical run"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheWhyExecute"),name:"why",options:[Ro,Xu]},i$={argument:{description:"Task ID to print the hash for (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Print the recorded hash and per-input hash details for a task",examples:[["vis cache hash @myorg/app:build","Show the resolved hash + contributing inputs"],["vis cache hash @myorg/app:build --json","Machine-readable output"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheHashExecute"),name:"hash",options:[Ro,Xu]},r$={argument:{description:"Task ID to verify (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Verify cache restore fidelity: extract the cached entry into a tmp directory and diff each file's content, mode, and mtime against the live workspace. Exits 1 on any drift (changed content, mode, mtime) or if a cached output is missing from the workspace. With --scope=all, the first cache directory containing the task is used.",examples:[["vis cache verify @myorg/app:build","Diff cached outputs vs live workspace files"],["vis cache verify @myorg/app:build --format=json","Machine-readable diff (status: ok | drift)"],["vis cache verify @myorg/app:build --cache-dir=.alt-cache","Verify against a non-default cache directory"],["vis cache verify @myorg/app:build --scope=all","Search shared and worktree caches for the task"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheVerifyExecute"),name:"verify",options:[ds,gi,Ro]},o$={commandPath:["cache"],description:"Probe the configured remote cache (HTTP HEAD or REAPI Capabilities) and report reachability, latency, and negotiated capabilities",examples:[["vis cache doctor","Probe the remoteCache configured in vis.config.ts"],["vis cache doctor --url=grpcs://cache.example.com:443 --backend=reapi","Override URL/backend ad-hoc"],["vis cache doctor --json","Machine-readable output"]],group:"Workspace",loader:Z(()=>import("./doctor-probe.js"),"cacheDoctorExecute"),name:"doctor",options:[{description:"Override remote cache URL (otherwise read from vis.config.ts remoteCache.url, or TURBO_API env var)",name:"url",type:String},{description:"Override backend selector: 'http' or 'reapi'",name:"backend",type:String},{description:"Output format: table or json (default: table)",name:"format",type:String},{defaultValue:5e3,description:"Probe timeout in milliseconds (default: 5000)",name:"timeout",type:Number}]},a$=[Qx,e$,t$,n$,s$,i$,r$,o$],c$={alias:["c","outdated"],argument:{description:"Specific packages to check (checks all if omitted)",name:"packages",type:String},description:"Check for outdated dependencies, security vulnerabilities, and supply chain settings",examples:[["vis check","Check all catalog dependencies"],["vis check react","Check specific packages"],["vis check --target minor","Only show minor/patch updates"],["vis check --exclude '@types/*'","Exclude packages by pattern"],["vis check --no-security","Skip vulnerability scanning"],["vis check --security-config","Audit supply chain security settings"],["vis check --security-config --sync","Sync security config to pnpm-workspace.yaml"]],group:"Security & Health",loader:()=>import("./handler6.js"),name:"check",options:[{alias:"t",description:"Update target: latest, minor, or patch (default: latest)",name:"target",type:String},{description:"Glob pattern to include packages (repeatable)",lazyMultiple:!0,name:"include",type:String},{description:"Glob pattern to exclude packages (repeatable)",lazyMultiple:!0,name:"exclude",type:String},{defaultValue:!1,description:"Include prerelease versions",name:"prerelease",type:Boolean},{defaultValue:!1,description:"Skip security vulnerability scanning",name:"no-security",type:Boolean},{defaultValue:!1,description:"Audit supply chain security settings",name:"security-config",type:Boolean},{defaultValue:!1,description:"Sync security settings to pnpm-workspace.yaml (pnpm only, requires --security-config)",name:"sync",type:Boolean},{description:"Output format: table, json, or minimal (default: table)",name:"format",type:String},{defaultValue:!1,description:"Exit with code 1 if outdated dependencies found (for CI)",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Run AI analysis on outdated packages",name:"ai",type:Boolean},{description:"AI analysis type: impact, security, compatibility, or recommend",name:"ai-type",type:String},{alias:"D",conflicts:"prod",description:"Check only devDependencies (npm/yarn mode)",name:"dev",type:Boolean},{alias:"P",conflicts:"dev",description:"Check only dependencies (npm/yarn mode)",name:"prod",type:Boolean},{defaultValue:!1,description:"Include peerDependencies in outdated checks",name:"peer",type:Boolean},{defaultValue:!1,description:"Also check workspace-owned package names against the registry",name:"include-internal",type:Boolean}]},l$={argument:{description:"Comma-separated list of targets to run (e.g., lint,test,build)",name:"targets",type:String},description:"Run affected targets in a CI-optimized pipeline",examples:[["vis ci lint,test,build","Run lint, test, and build on affected projects"],["vis ci test --base=origin/main","Override the base ref"],["vis ci build --no-install","Skip the install step (assume deps already present)"],["vis ci build --parallel=6","Increase concurrency"]],group:"Run & Execute",loader:()=>import("./handler7.js"),name:"ci",options:[...Ge({defaultValue:!0,description:"Install dependencies before running targets (use --no-install to skip)",name:"install",type:Boolean}),{defaultValue:!1,description:"Skip the toolchain pre-flight (no auto-install for any pinned tool: node / pnpm / yarn / npm / bun / deno / go / python / ruby / rust)",name:"skip-toolchain",type:Boolean},{description:"Git base ref for affected detection (default: auto-detected from CI env)",name:"base",type:String},{description:"Git head ref for affected detection (default: HEAD)",name:"head",type:String},{defaultValue:"none",description:"Upstream scope: none | direct | deep",name:"upstream",type:String},{defaultValue:"deep",description:"Downstream scope: none | direct | deep",name:"downstream",type:String},{defaultValue:4,description:"Maximum number of parallel tasks per target",name:"parallel",type:Number},{description:'Partition tasks for distributed CI (e.g., "1/4")',name:"partition",type:String},{description:"Filter affected projects by a query (e.g. 'language=typescript && tag=lib')",name:"query",type:String}]},d$={argument:{description:"Project name to check (required)",name:"project",type:String},commandPath:["ci"],description:'Exit with inverted codes for CI "Ignored Build Step" gating (Vercel/Netlify)',examples:[["vis ci ignore my-app","Check if my-app is affected and decide whether to build"],["vis ci ignore my-app --base $VERCEL_GIT_PREVIOUS_SHA","Explicit base ref"],["vis ci ignore my-app --json","Emit the decision as JSON instead of text"],["vis ci ignore my-app --verbose","Print debug info about the decision path"],["vis ci ignore my-app --exit-zero-on-build","Normal exit semantics (0=build, 0=skip)"]],group:"Run & Execute",loader:()=>import("./handler52.js"),name:"ignore",options:[{description:"Git base ref for comparison. Defaults to CI provider env vars, then HEAD~1.",name:"base",type:String},{defaultValue:"HEAD",description:"Git head ref for comparison",name:"head",type:String},{defaultValue:"deep",description:'Downstream scope: "none", "direct", or "deep"',name:"downstream",type:String},{defaultValue:"none",description:'Upstream scope: "none", "direct", or "deep"',name:"upstream",type:String},{defaultValue:!1,description:"Emit the decision as JSON on stdout instead of human text",name:"json",type:Boolean},{defaultValue:!1,description:"Exit 0 on build (normal semantics) instead of 1 (inverted Vercel/Netlify semantics)",name:"exit-zero-on-build",type:Boolean},{defaultValue:!1,description:"Enable verbose debug output",name:"verbose",type:Boolean}]},u$={description:"Remove node_modules from all workspace projects",examples:[["vis clean","Remove all node_modules directories"],["vis clean --lockfile","Also remove lockfiles"],["vis clean --empty-packages","Also remove workspace directories that have no package.json"],["vis clean --dry-run","Preview what would be removed"]],group:"Workspace",loader:()=>import("./handler8.js"),name:"clean",options:[{alias:"l",defaultValue:!1,description:"Also remove lockfiles (pnpm-lock.yaml, package-lock.json, etc.)",name:"lockfile",type:Boolean},{alias:"e",defaultValue:!1,description:"Also remove stale workspace directories that match a workspace pattern but have no package.json",name:"empty-packages",type:Boolean},{defaultValue:!1,description:"Preview what would be removed without deleting",name:"dry-run",type:Boolean}]},p$={argument:{description:"Template to use (e.g., vis:app, create-vite, user/repo) — omit for interactive mode",name:"template",type:String},description:"Create a new project from a template",examples:[["vis create","Interactive project scaffolding"],["vis create vis:monorepo my-workspace","Create a monorepo workspace"],["vis create vis:app my-app","Scaffold a Vite application"],["vis create vis:library my-lib","Create a TypeScript library"],["vis create vite my-app -- --template react-ts","Use create-vite with React TypeScript"],["vis create user/repo my-project","Clone a GitHub template"],["vis create --list","Show available templates"]],group:"Scaffold & Config",loader:()=>import("./handler69.js"),name:"create",options:[{defaultValue:!1,description:"Show available templates",name:"list",type:Boolean},{description:"Generate editor configs (vscode)",name:"editor",type:String},{defaultValue:!1,description:"Initialize a git repository",name:"git-init",type:Boolean},{defaultValue:!1,description:"Skip interactive prompts",name:"no-interactive",type:Boolean}]},Zu=(e,t,n)=>{const s=r=>nl(r)?r:ln(e,r);if(t&&t.length>0)return s(t);if(n&&n.length>0)return s(n);const i=process.env.VIS_CACHE_DIRECTORY;return i&&i.length>0?s(i):ln(e,ll)},f$=(e,t)=>t===!1?e:rh(e)??e,Pc=(e,t,n,s)=>{const i=t??n??process.env.VIS_CACHE_DIRECTORY;if(i&&i.length>0)return Zu(e,t,n);const r=f$(e,s);return ln(r,ll)},h$=/[^\w.-]+/g,m$=/^-+|-+$/g,g$=e=>e.trim().replaceAll(h$,"-").replaceAll(m$,"").slice(0,64),y$=e=>{try{const t=Ff("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return!t||t==="HEAD"?void 0:t}catch{return}},Qj=(e,t,n)=>{if(n!==!0)return e;const s=y$(t);if(!s)return e;const i=g$(s);return i.length===0?e:ln(e,"branches",i)},v$=(e,t)=>{const n=ss(t,e);return n.length===0?!1:n!==".."&&!n.startsWith("../")&&!nl(n)},b$="x-hono-already-sent";var De=class extends Error{constructor(e,t){super(e,t),this.name="RequestError"}};const w$=/^\/[!#$&-;=?-\[\]_a-z~]*$/,k$=/\/\.\.?(?:[/?#]|$)/,S$=/^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/,x$=(e,t,n)=>{const s=`${e}://${t}${n}`;if(S$.test(t)){if(n.length===0)return s+"/";if(n.charCodeAt(0)!==47)throw new De("Invalid URL");return!w$.test(n)||k$.test(n)?new URL(s).href:s}else{const i=new URL(s);if(i.hostname.length!==t.length&&i.hostname!==(t.includes(":")?t.replace(/:\d+$/,""):t).toLowerCase())throw new De("Invalid host header");return i.href}},$$=e=>e instanceof De?e:new De(e.message,{cause:e}),E$=global.Request;var fn=class extends E${constructor(e,t){if(typeof e=="object"&&at in e){const n=t!==void 0&&"body"in t&&t.body!=null;if(e[Je]&&!n)throw new TypeError("Cannot construct a Request with a Request object that has already been used.");e=e[at]()}typeof t?.body?.getReader<"u"&&(t.duplex??="half"),super(e,t)}};const Qu=e=>{const t=[],n=e.rawHeaders;for(let s=0,i=n.length;s<i;s+=2){const r=n[s];r.charCodeAt(0)!==58&&t.push([r,n[s+1]])}return new Headers(t)},ep=Symbol("wrapBodyStream"),C$=new Set(["latin1","binary","hex","base64","base64url"]),R$=e=>e===null||C$.has(e),Xi=Symbol("bodyBufferedBeforeDisconnect"),Dr=Symbol("bodyBufferedLengthBeforeDisconnect"),tp=(e,t)=>Buffer.isBuffer(e)?e:Buffer.from(e,t??"utf8"),jo=e=>!(e instanceof nn)&&!!e.complete&&!!e.readableAborted&&typeof e.read=="function"&&R$(e.readableEncoding),Nc=e=>{if(e.readableDidRead||!jo(e))return;const t=e;t[Dr]??=e.readableLength},Ys=(e,t)=>{if(e.readableDidRead&&!t||!jo(e))return;const n=e;if(n[Xi]!==void 0)return n[Xi];let s;const i=e.errored;if(i&&i.code!=="ECONNRESET")s=i;else if(n[Dr]!==void 0&&e.readableLength!==n[Dr])s=Xs();else{const r=t??[],o=e.read();o!==null&&r.push(tp(o,e.readableEncoding));const a=r.length===1?r[0]:Buffer.concat(r);s=a;const c=e.headers["content-length"];if(typeof c=="string"&&/^\d+$/.test(c)){const l=Number(c);Number.isSafeInteger(l)&&a.length!==l&&(s=Xs())}}return n[Xi]=s,s},Dc=(e,t)=>{if(t instanceof Error){e.error(t);return}t.length>0&&e.enqueue(t),e.close()},j$=(e,t,n,s,i)=>{const r={method:e,headers:n,signal:i.signal};if(e==="TRACE"){r.method="GET";const o=new fn(t,r);return Object.defineProperty(o,"method",{get(){return"TRACE"}}),o}if(!(e==="GET"||e==="HEAD"))if("rawBody"in s&&s.rawBody instanceof Buffer)r.body=new ReadableStream({start(o){o.enqueue(s.rawBody),o.close()}});else if(s[ep]){let o;r.body=new ReadableStream({async pull(a){try{if(!o){const d=Ys(s);if(d!==void 0){Dc(a,d);return}}o||=Qo.toWeb(s).getReader();const{done:c,value:l}=await o.read();c?a.close():a.enqueue(l)}catch(c){a.error(c)}}})}else{const o=Ys(s);o!==void 0?r.body=new ReadableStream({start(a){Dc(a,o)}}):r.body=Qo.toWeb(s)}return new fn(t,r)},at=Symbol("getRequestCache"),We=Symbol("requestCache"),hn=Symbol("incomingKey"),zn=Symbol("urlKey"),np=Symbol("methodKey"),sp=Symbol("headersKey"),Tn=Symbol("abortControllerKey"),Mr=Symbol("getAbortController"),Lr=Symbol("abortRequest"),st=Symbol("bodyBuffer"),Cs=Symbol("bodyReadPromise"),Je=Symbol("bodyConsumedDirectly"),Mc=Symbol("bodyLockReader"),_n=Symbol("abortReason"),Xs=()=>new TypeError("Body is unusable"),us=()=>Promise.reject(Xs()),T$=new TextDecoder,O$=e=>{if(e[Je])return us();e[Je]=!0},A$=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),I$=e=>(e[sp]||=Qu(e[hn])).get("content-type")||"",B$=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,P$=e=>{if(typeof e!="string"||e.length===0)return"GET";switch(e){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"PATCH":case"POST":case"PUT":case"QUERY":return e}const t=e.toUpperCase();switch(t){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"POST":case"PUT":return t;default:return e}},N$=e=>{if(!B$.test(e))return new TypeError(`'${e}' is not a valid HTTP method.`);const t=e.toUpperCase();if(t==="CONNECT"||t==="TRACK"||t==="TRACE"&&e!=="TRACE")return new TypeError(`'${e}' HTTP method is unsupported.`)},To=(e,t,n)=>{if(e[Je])return us();const s=e.method;if(s==="GET"||s==="HEAD")return e[at]()[t]();const i=N$(s);if(i)return Promise.reject(i);if(e[We]&&s!=="TRACE")return e[We][t]();const r=O$(e);if(r)return r;const o=D$(e);if(o){const a=Promise.resolve(n(o,e));return e[st]=void 0,a}return M$(e).then(a=>{const c=n(a,e);return e[st]=void 0,c})},D$=e=>{const t=e[hn];if("rawBody"in t&&t.rawBody instanceof Buffer)return t.rawBody},Lc=(e,t)=>{if(t.errored)return t.errored;const n=e[_n];return n!==void 0?n instanceof Error?n:new Error(String(n)):new Error("Client connection prematurely closed.")},M$=e=>{if(e[st])return Promise.resolve(e[st]);if(e[Cs])return e[Cs];const t=e[hn];if(t.readableDidRead)return us();const n=Ys(t);if(n!==void 0)return n instanceof Error?Promise.reject(n):(e[st]=n,Promise.resolve(n));const s=new Promise((i,r)=>{const o=[];let a=!1;const c=m=>{a||(a=!0,h(),m())},l=m=>{const b=t.errored??m;return!jo(t)||b&&b.code!=="ECONNRESET"?!1:(c(()=>{const $=Ys(t,o);$ instanceof Error?r($):$===void 0?r(m??Lc(e,t)):(e[st]=$,i($))}),!0)},d=m=>{o.push(tp(m,t.readableEncoding))},u=()=>{c(()=>{const m=o.length===1?o[0]:Buffer.concat(o);e[st]=m,i(m)})},p=m=>{l(m)||c(()=>{r(m)})},f=()=>{if(t.readableEnded){u();return}l()||c(()=>{r(Lc(e,t))})},h=()=>{t.off("data",d),t.off("end",u),t.off("error",p),t.off("close",f),e[Cs]=void 0};t.on("data",d),t.on("end",u),t.on("error",p),t.on("close",f),queueMicrotask(()=>{a||(t.readableEnded?u():t.errored?p(t.errored):t.destroyed&&f())})});return e[Cs]=s,s},_e={get method(){return this[np]},get url(){return this[zn]},get headers(){return this[sp]||=Qu(this[hn])},[Lr](e){this[_n]===void 0&&(this[_n]=e);const t=this[Tn];t&&!t.signal.aborted&&t.abort(e)},[Mr](){return this[Tn]||=new AbortController,this[_n]!==void 0&&!this[Tn].signal.aborted&&this[Tn].abort(this[_n]),this[Tn]},[at](){const e=this[Mr]();if(this[We])return this[We];const t=this.method;if(this[Je]&&!(t==="GET"||t==="HEAD")){this[st]=void 0;const n={method:t==="TRACE"?"GET":t,headers:this.headers,signal:e.signal};t!=="TRACE"&&(n.body=new ReadableStream({start(i){i.close()}}),n.duplex="half");const s=new fn(this[zn],n);return t==="TRACE"&&Object.defineProperty(s,"method",{get(){return"TRACE"}}),this[We]=s}return this[We]=j$(this.method,this[zn],this.headers,this[hn],e)},get body(){if(!this[Je])return this[at]().body;const e=this[at]();return!this[Mc]&&e.body&&(this[Mc]=e.body.getReader()),e.body},get bodyUsed(){return this[Je]?!0:this[We]?this[We].bodyUsed:!1}};Object.defineProperty(_e,"signal",{get(){return this[Mr]().signal}});["cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","keepalive"].forEach(e=>{Object.defineProperty(_e,e,{get(){return this[at]()[e]}})});["clone","formData"].forEach(e=>{Object.defineProperty(_e,e,{value:function(){if(this[Je]){if(e==="clone")throw Xs();return us()}return this[at]()[e]()}})});Object.defineProperty(_e,"text",{value:function(){return To(this,"text",e=>T$.decode(e))}});Object.defineProperty(_e,"arrayBuffer",{value:function(){return To(this,"arrayBuffer",e=>A$(e))}});Object.defineProperty(_e,"blob",{value:function(){return To(this,"blob",(e,t)=>{const n=I$(t),s=n?{headers:{"content-type":n}}:void 0;return new Response(e,s).blob()})}});Object.defineProperty(_e,"json",{value:function(){return this[Je]?us():this.text().then(JSON.parse)}});Object.defineProperty(_e,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,n){return`Request (lightweight) ${n({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[We]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(_e,fn.prototype);const L$=(e,t)=>{const n=Object.create(_e);n[hn]=e,n[np]=P$(e.method);const s=e.url||"";if(s[0]!=="/"&&(s.startsWith("http://")||s.startsWith("https://"))){if(e instanceof nn)throw new De("Absolute URL for :path is not allowed in HTTP/2");try{n[zn]=new URL(s).href}catch(o){throw new De("Invalid absolute URL",{cause:o})}return n}const i=(e instanceof nn?e.authority:e.headers.host)||t;if(!i)throw new De("Missing host header");let r;if(e instanceof nn){if(r=e.scheme,!(r==="http"||r==="https"))throw new De("Unsupported scheme")}else r=e.socket&&e.socket.encrypted?"https":"http";try{n[zn]=x$(r,i,s)}catch(o){throw o instanceof De?o:new De("Invalid URL",{cause:o})}return n},tt="text/plain; charset=UTF-8",_r=Symbol("responseCache"),Qt=Symbol("getResponseCache"),ze=Symbol("cache"),Oo=global.Response;var Le=class ip{#e;#t;[Qt](){const t=this[ze],n=t&&t[2]instanceof Headers?t[2]:void 0;return delete this[ze],this[_r]||=new Oo(this.#e,n?{status:this.#t?.status,statusText:this.#t?.statusText,headers:n}:this.#t)}constructor(t,n){let s;if(this.#e=t,n instanceof ip){const i=n[_r];if(i){this.#t=i,this[Qt]();return}else this.#t=n.#t,s=new Headers(n.headers)}else this.#t=n;(t==null||typeof t=="string"||typeof t?.getReader<"u"||t instanceof Blob||t instanceof Uint8Array)&&(this[ze]=[n?.status||200,t??null,s||n?.headers])}get headers(){const t=this[ze];return t?(t[2]instanceof Headers||(t[2]=new Headers(t[2]||(t[1]===null?void 0:{"content-type":tt}))),t[2]):this[Qt]().headers}get status(){return this[ze]?.[0]??this[Qt]().status}get ok(){const t=this.status;return t>=200&&t<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(Le.prototype,e,{get(){return this[Qt]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(Le.prototype,e,{value:function(){return this[Qt]()[e]()}})});Object.defineProperty(Le.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,n){return`Response (lightweight) ${n({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[_r]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(Le,Oo);Object.setPrototypeOf(Le.prototype,Oo.prototype);const _$=/^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/,F$=e=>e instanceof URL?e.href:_$.test(e)?e:new URL(e).href,V$=new Set([301,302,303,307,308]);Object.defineProperty(Le,"redirect",{value:function(t,n=302){if(!V$.has(n))throw new RangeError("Invalid status code");return new Le(null,{status:n,headers:{location:F$(t)}})},writable:!0,configurable:!0});Object.defineProperty(Le,"json",{value:function(t,n){const s=JSON.stringify(t);if(s===void 0)throw new TypeError("The data is not JSON serializable");const i=n?.headers;let r;return i?(r=new Headers(i),r.has("content-type")||r.set("content-type","application/json")):r={"content-type":"application/json"},new Le(s,{status:n?.status??200,statusText:n?.statusText,headers:r})},writable:!0,configurable:!0});async function H$(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function rp(e,t,n){const s=a=>{e.cancel(a).catch(()=>{})};return t.on("close",s),t.on("error",s),(n??e.read()).then(o,i),e.closed.finally(()=>{t.off("close",s),t.off("error",s)});function i(a){a&&t.destroy(a)}function r(){e.read().then(o,i)}function o({done:a,value:c}){try{if(a)t.end();else if(!t.write(c))t.once("drain",r);else return e.read().then(o,i)}catch(l){i(l)}}}function _c(e,t){if(e.locked)throw new TypeError("ReadableStream is locked.");return t.destroyed?void 0:rp(e.getReader(),t)}const Fr=(e,t)=>{const n={};if(e instanceof Headers||(e=new Headers(e??void 0)),e.has("set-cookie")){const s=[];for(const[i,r]of e)i==="set-cookie"?s.push(r):n[i]=r;s.length>0&&(n["set-cookie"]=s)}else for(const[s,i]of e)n[s]=i;return t&&(n["content-type"]??=t),n},Zs=Symbol("outgoingEnded"),Fc=Symbol("incomingDraining"),W$=500,U$=64*1024*1024,op=e=>{const t=e;if(e.destroyed||t[Fc])return;if(t[Fc]=!0,e instanceof nn){try{e.stream?.close?.(ph.NGHTTP2_NO_ERROR)}catch{}return}let n=0;const s=()=>{clearTimeout(r),e.off("data",o),e.off("end",s),e.off("error",s)},i=()=>{s();const a=e.socket;a&&!a.destroyed&&a.destroySoon()},r=setTimeout(i,W$);r.unref?.();const o=a=>{n+=a.length,n>U$&&i()};e.on("data",o),e.on("end",s),e.on("error",s),e.resume()},G$=(e,t,n,s)=>()=>{t.errored?(Nc(t),e[Lr](t.errored.toString())):n.writableFinished||(Nc(t),e[Lr]("Client connection prematurely closed.")),s&&!t.readableEnded&&setTimeout(()=>{t.readableEnded||setTimeout(()=>{op(t)})})},z$=e=>{if(!(ze in e))return!1;const t=e[ze][1];return t===null||typeof t=="string"||t instanceof Uint8Array},J$=()=>new Response(null,{status:400}),ap=e=>new Response(null,{status:e instanceof Error&&(e.name==="TimeoutError"||e.constructor.name==="TimeoutError")?504:500}),Qs=(e,t)=>{const n=e instanceof Error?e:new Error("unknown error",{cause:e});n.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Error: ${n.message}`),t.destroy(n))},Vr=e=>{"flushHeaders"in e&&e.writable&&e.flushHeaders()},cp=async(e,t)=>{let[n,s,i]=e[ze];if(!i){s===null?(t.writeHead(n),t.end()):typeof s=="string"?(t.writeHead(n,{"Content-Type":tt,"Content-Length":Buffer.byteLength(s)}),t.end(s)):s instanceof Uint8Array?(t.writeHead(n,{"Content-Type":tt,"Content-Length":s.byteLength}),t.end(s)):s instanceof Blob?(t.writeHead(n,{"Content-Type":tt,"Content-Length":s.size}),t.end(new Uint8Array(await s.arrayBuffer()))):(t.writeHead(n,{"Content-Type":tt}),Vr(t),await _c(s,t)?.catch(o=>Qs(o,t))),t[Zs]?.();return}let r=!1;if(i instanceof Headers)r=i.has("content-length"),i=Fr(i,s===null?void 0:tt);else if(Array.isArray(i)){const o=new Headers(i);r=o.has("content-length"),i=Fr(o,s===null?void 0:tt)}else for(const o in i)if(o.length===14&&o.toLowerCase()==="content-length"){r=!0;break}r||(typeof s=="string"?i["Content-Length"]=Buffer.byteLength(s):s instanceof Uint8Array?i["Content-Length"]=s.byteLength:s instanceof Blob&&(i["Content-Length"]=s.size)),t.writeHead(n,i),s==null?t.end():typeof s=="string"||s instanceof Uint8Array?t.end(s):s instanceof Blob?t.end(new Uint8Array(await s.arrayBuffer())):(Vr(t),await _c(s,t)?.catch(o=>Qs(o,t))),t[Zs]?.()},lp=e=>typeof e.then=="function",K$=async(e,t,n={})=>{if(lp(e))if(n.errorHandler)try{e=await e}catch(i){const r=await n.errorHandler(i);if(!r)return;e=r}else e=await e.catch(ap);if(ze in e)return cp(e,t);const s=Fr(e.headers,e.body===null?void 0:tt);if(e.body){const i=e.body.getReader(),r=[];let o=!1,a;if(s["transfer-encoding"]!=="chunked"){let c=2;for(let l=0;l<c;l++){a||=i.read();const d=await H$(a).catch(u=>{console.error(u),o=!0});if(!d){if(l===1){await new Promise(u=>setTimeout(u)),c=3;continue}break}if(a=void 0,d.value&&r.push(d.value),d.done){o=!0;break}}o&&!("content-length"in s)&&(s["content-length"]=r.reduce((l,d)=>l+d.length,0))}t.writeHead(e.status,s),r.forEach(c=>{t.write(c)}),o?t.end():(r.length===0&&Vr(t),await rp(i,t,a))}else s[b$]||(t.writeHead(e.status,s),t.end());t[Zs]?.()},q$=(e,t={})=>{const n=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==fn&&(Object.defineProperty(global,"Request",{value:fn}),Object.defineProperty(global,"Response",{value:Le})),async(s,i)=>{let r,o,a=!1,c=!1;const l=()=>{!o||c||(c=!0,i.on("close",G$(o,s,i,a)))};try{if(o=L$(s,t.hostname),a=n&&!(s.method==="GET"||s.method==="HEAD"),a&&(s[ep]=!0,s instanceof nn&&(i[Zs]=()=>{s.readableEnded||setTimeout(()=>{s.readableEnded||setTimeout(()=>{s.destroy(),i.destroy()})})})),r=e(o,{incoming:s,outgoing:i}),!lp(r)&&z$(r))return a&&!s.readableEnded&&i.once("finish",()=>{s.readableEnded||op(s)}),cp(r,i);l()}catch(d){if(r)return Qs(d,i);if(t.errorHandler){if(l(),r=await t.errorHandler(o?d:$$(d)),!r)return}else o?r=ap(d):r=J$()}try{return await K$(r,i,t)}catch(d){return Qs(d,i)}}},Y$=Symbol("CONNECTION_SYMBOL_KEY"),X$=Symbol("WAIT_FOR_WEBSOCKET_SYMBOL"),Z$=new Set(["connection","content-length","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","sec-websocket-accept","sec-websocket-extensions","sec-websocket-protocol"]),dp=(e,t)=>{t&&t.forEach((n,s)=>{Z$.has(s.toLowerCase())||e.push(`${s}: ${n}`)})},Vc=(e,t,n)=>{const s=["Connection: close","Content-Length: 0"];dp(s,n),e.end(`HTTP/1.1 ${t.toString()} ${uh[t]??""}\r
|
|
189
|
+
${Vr(m,{...this.#r,filterStacktrace:Yr,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:S})}`),h&&C.push(`
|
|
190
|
+
`,S+Ae(this.styles.underline.suffix?Dc(h):h)),C.join("")}_log(t,n){const s=wu(n)?"stderr":"stdout",r=s==="stderr"?this.#t:this.#e;this.#i&&this.#n!==void 0&&r.isTTY?this.#n.update(s,t.split(`
|
|
191
|
+
`),0):ku(`${t}
|
|
192
|
+
`,r)}}const j2=()=>Hn.NODE_ENV==="debug"||Hn.DEBUG!==void 0?"debug":Hn.NODE_ENV==="test"?"warning":"informational",Ku=e=>{let t=j2();return Hn.PAIL_LOG_LEVEL!==void 0&&(t=Hn.PAIL_LOG_LEVEL),new t2({logLevel:t,processors:[new w2],reporters:[new R2],stderr:Co,stdout:Eo,...e})};Ku();const E=Ku(),T2=e=>`MARSHALL_DISABLE_${e.replaceAll(/([A-Z])/g,"_$1").toUpperCase()}`,Xr=(e,t=process.env)=>Zo(t.MARSHALL_DISABLE_ALL)?!0:Zo(t[T2(e)]),Yu=(e,t)=>{const n={errors:[],warnings:[]},{security:s}=e;if(!s)return n.warnings.push("No security settings configured. Use defineConfig() from '@visulima/vis/config' to get secure defaults automatically."),n;const r=s.policies??{},{installScripts:i}=r,o=i?.allow,a=o&&Object.keys(o).length>0;if(a||n.warnings.push(t==="pnpm"?"security.policies.installScripts.allow is not configured. pnpm blocks build scripts by default since v10. Run 'vis approve-builds' to review.":"security.policies.installScripts.allow is not configured. Consider listing which packages are allowed to run install/postinstall scripts."),r.firstSeen?.minutes===0&&n.warnings.push("security.policies.firstSeen.minutes is explicitly set to 0. New packages can be installed immediately after publishing."),r.publisherChange?.mode==="off"&&n.warnings.push("security.policies.publisherChange.mode is explicitly 'off'. Packages whose trust level has decreased will not be blocked."),s.blockExoticSubdeps===!1&&n.warnings.push("security.blockExoticSubdeps is explicitly disabled. Transitive dependencies can pull code from git repos or tarball URLs."),i?.strict===!1&&n.warnings.push("security.policies.installScripts.strict is explicitly disabled. Unapproved build scripts will only produce warnings, not errors."),i?.strict&&!a&&n.errors.push("security.policies.installScripts.strict is enabled but `.allow` is empty. All dependencies with build scripts will be blocked. Run 'vis approve-builds' to review and add packages."),s.acceptedRisks){const l=Date.now();for(const[d,u]of Object.entries(s.acceptedRisks)){const p=new Date(u.acceptedAt).getTime();l-p>7776e6&&n.warnings.push(`Accepted risk for "${d}" is over 90 days old (accepted ${u.acceptedAt}). Consider re-evaluating with 'vis audit'.`)}}return n},O2=(e,t,n=!1)=>{if(ct&&!process.env.VIS_SECURITY_WARNINGS)return;const s=Yu(e,t);for(const i of s.errors)E.error(i);const r=n?s.warnings.filter(i=>!i.startsWith("security.policies.installScripts.allow is not configured")):s.warnings;r.length>0&&E.warn(`${r.length} security recommendation${r.length===1?"":"s"} found. Run 'vis check --security-config' for details.`)},mR=(e,t)=>{const n=Yu(e,t),{security:s}=e;if(s){const r=s.policies??{},{firstSeen:i}=r,{publisherChange:o}=r,{installScripts:a}=r,{score:c}=r;if(E.info("Active security settings:"),E.info(` policies.firstSeen.minutes: ${i?.minutes??"not set"} minutes`),E.info(` policies.publisherChange.mode: ${o?.mode??"not set"}`),E.info(` policies.publisherChange.ignoreAfter: ${o?.ignoreAfter??"not set"} minutes`),E.info(` blockExoticSubdeps: ${s.blockExoticSubdeps??!1}`),E.info(` policies.installScripts.strict: ${a?.strict??!1}`),E.info(` policies.installScripts.allow: ${a?.allow?`${Object.keys(a.allow).length} entries`:"not configured"}`),E.info(""),E.info("Socket.dev integration:"),E.info(` socket.enabled: ${s.socket?.enabled??!1}`),E.info(` socket.apiToken: ${s.socket?.apiToken||process.env.VIS_SOCKET_TOKEN?"configured":"using public token"}`),E.info(` policies.score.minimum: ${c?.minimum??"default (0.4)"}`),E.info(` socket.cacheTtlMs: ${s.socket?.cacheTtlMs??"default (1 hour)"}`),E.info(` socket.timeoutMs: ${s.socket?.timeoutMs??"default (15s)"}`),s.acceptedRisks){const l=Object.entries(s.acceptedRisks);E.info(` acceptedRisks: ${String(l.length)} entr${l.length===1?"y":"ies"}`);for(const[d,u]of l)E.info(` ${d}: ${u.reason} (accepted ${u.acceptedAt.slice(0,10)})`)}else E.info(" acceptedRisks: none");E.info("")}if(n.errors.length===0&&n.warnings.length===0){E.info("All recommended security settings are configured.");return}for(const r of n.errors)E.error(r);for(const r of n.warnings)E.warn(r);E.notice(""),E.notice("Secure defaults are applied by defineConfig(). You only need to add install-script allowances:"),E.notice(""),E.notice(" import { defineConfig } from '@visulima/vis/config';"),E.notice(""),E.notice(" export default defineConfig({"),E.notice(" security: {"),E.notice(" policies: {"),E.notice(" installScripts: {"),E.notice(" allow: {"),E.notice(" esbuild: true,"),E.notice(" '@prisma/client': true,"),E.notice(" },"),E.notice(" },"),E.notice(" },"),E.notice(" },"),E.notice(" });")},gR=e=>{const{security:t}=e;if(!t)return[];const n=t.policies??{},{firstSeen:s}=n,{publisherChange:r}=n,{installScripts:i}=n,o=[];return s?.minutes!==void 0&&o.push(`minimumReleaseAge: ${s.minutes}`),r?.mode&&r.mode!=="off"&&o.push(`trustPolicy: ${r.mode}`),t.blockExoticSubdeps&&o.push("blockExoticSubdeps: true"),i?.allow&&o.push(`allowBuilds: ${Object.keys(i.allow).length} entries`),i?.strict&&o.push("strictDepBuilds: true"),r?.ignoreAfter!==void 0&&o.push(`trustPolicyIgnoreAfter: ${r.ignoreAfter}`),o},Xu=e=>{const t=e.trim();if(t==="")return;const n=/^(\d+(?:\.\d+)?)\s*([mhdw]?)$/i.exec(t);if(!n)return;const s=Number.parseFloat(n[1]);if(!(!Number.isFinite(s)||s<0))switch(n[2]?.toLowerCase()){case"":case"m":case void 0:return Math.round(s);case"d":return Math.round(s*1440);case"h":return Math.round(s*60);case"w":return Math.round(s*10080);default:return}},A2=e=>e.startsWith("@")||e.includes("/")||/[:#\s]/.test(e),yR=e=>A2(e)?`'${e.replaceAll("'","''")}'`:e,I2=e=>{const t=e.trim();return/^\d+$/.test(t)?Number.parseInt(t,10)*1440:Xu(t)},B2=(e,t)=>{const n={};try{switch(e){case"bun":{const s=g(t,"package.json");if(x(s)){const i=le(s);Array.isArray(i.trustedDependencies)&&(n.allowBuilds=new Set(i.trustedDependencies))}const r=g(t,"bunfig.toml");if(x(r)){const i=uh(r),o=i?.install?.minimumReleaseAge;typeof o=="number"&&(n.minReleaseAgeMinutes=Math.round(o/60)),Array.isArray(i?.install?.minimumReleaseAgeExcludes)&&(n.minReleaseAgeExcludes=new Set(i.install.minimumReleaseAgeExcludes))}break}case"npm":{const s=g(t,".npmrc");if(x(s)){const r=G(s),i=/^\s*min-release-age\s*=\s*([^\s#;]+)/m.exec(r);i&&(n.minReleaseAgeMinutes=I2(i[1]))}break}case"pnpm":{const s=g(t,"pnpm-workspace.yaml");if(x(s)){const r=Tt(s);r?.allowBuilds&&typeof r.allowBuilds=="object"?n.allowBuilds=new Set(Object.entries(r.allowBuilds).filter(([,i])=>i).map(([i])=>i)):Array.isArray(r?.onlyBuiltDependencies)&&(n.allowBuilds=new Set(r.onlyBuiltDependencies)),typeof r?.minimumReleaseAge=="number"&&(n.minReleaseAgeMinutes=r.minimumReleaseAge),Array.isArray(r?.minimumReleaseAgeExclude)&&(n.minReleaseAgeExcludes=new Set(r.minimumReleaseAgeExclude))}break}case"yarn":{const s=g(t,".yarnrc.yml");if(x(s)){const r=Tt(s),i=r?.npmMinimalAgeGate;typeof i=="string"?n.minReleaseAgeMinutes=Xu(i):typeof i=="number"&&(n.minReleaseAgeMinutes=i),Array.isArray(r?.npmPreapprovedPackages)&&(n.minReleaseAgeExcludes=new Set(r.npmPreapprovedPackages))}break}default:break}}catch{}return n},P2=(e,t,n)=>{const s=B2(t,n),r={hasDrift:!1,packageManager:t},o=(e.security??{}).policies??{},{installScripts:a}=o,{firstSeen:c}=o;if(a?.allow&&(t==="pnpm"||t==="bun")){const l=new Set(Object.entries(a.allow).filter(([,f])=>f).map(([f])=>f)),d=s.allowBuilds??new Set,u=[...l].filter(f=>!d.has(f)),p=[...d].filter(f=>!l.has(f));(u.length>0||p.length>0)&&(r.allowBuilds={onlyInPm:p,onlyInVis:u},r.hasDrift=!0)}if(c?.minutes!==void 0&&!(t==="yarn"&&s.minReleaseAgeMinutes===void 0&&!x(g(n,".yarnrc.yml")))&&s.minReleaseAgeMinutes!==c.minutes&&(r.minReleaseAge={pm:s.minReleaseAgeMinutes,vis:c.minutes},r.hasDrift=!0),c?.exclude&&(t==="pnpm"||t==="bun"||t==="yarn")){const l=new Set(c.exclude),d=s.minReleaseAgeExcludes??new Set,u=[...l].filter(f=>!d.has(f)),p=[...d].filter(f=>!l.has(f));(u.length>0||p.length>0)&&(r.minReleaseAgeExcludes={onlyInPm:p,onlyInVis:u},r.hasDrift=!0)}return r},N2=e=>{if(!e.hasDrift)return[];const t=[`vis.config and ${e.packageManager}-native config disagree on security settings:`];if(e.allowBuilds&&(e.allowBuilds.onlyInVis.length>0&&t.push(` security.policies.installScripts.allow — only in vis.config: ${e.allowBuilds.onlyInVis.join(", ")}`),e.allowBuilds.onlyInPm.length>0&&t.push(` security.policies.installScripts.allow — only in ${e.packageManager} config: ${e.allowBuilds.onlyInPm.join(", ")}`)),e.minReleaseAge){const n=e.minReleaseAge.vis===void 0?"unset":`${String(e.minReleaseAge.vis)} min`,s=e.minReleaseAge.pm===void 0?"unset":`${String(e.minReleaseAge.pm)} min`;t.push(` security.policies.firstSeen.minutes — vis.config: ${n}, ${e.packageManager}: ${s}`)}return e.minReleaseAgeExcludes&&(e.minReleaseAgeExcludes.onlyInVis.length>0&&t.push(` security.policies.firstSeen.exclude — only in vis.config: ${e.minReleaseAgeExcludes.onlyInVis.join(", ")}`),e.minReleaseAgeExcludes.onlyInPm.length>0&&t.push(` security.policies.firstSeen.exclude — only in ${e.packageManager} config: ${e.minReleaseAgeExcludes.onlyInPm.join(", ")}`)),t.push(" Run 'vis security sync' to push vis.config values to the native config."),t},D2=e=>x(g(e,".yarnrc.yml")),M2=(e,t,n)=>{const s={extraArgs:[],postInstallPackages:[],scriptsBlockedByDefault:!1,warnings:[]},r=n.security?.policies?.installScripts?.allow??{},i=Object.keys(r).length>0;switch(e){case"bun":{if(s.scriptsBlockedByDefault=!0,i){const o=g(t,"package.json");try{(x(o)?le(o):{}).trustedDependencies?.length||s.warnings.push("vis security.policies.installScripts.allow is configured but trustedDependencies is empty. Run 'vis approve-builds --sync-native'.")}catch{}}break}case"npm":{s.scriptsBlockedByDefault=!1;const o=g(t,".npmrc"),a=x(o)&&/^\s*ignore-scripts\s*=\s*true\s*$/m.test(G(o));if(!a&&i?(s.warnings.push("npm does not block lifecycle scripts. vis will add --ignore-scripts automatically."),s.extraArgs.push("--ignore-scripts")):!a&&!i&&s.warnings.push("npm does not block lifecycle scripts. Add 'ignore-scripts=true' to .npmrc and configure security.policies.installScripts.allow."),i)for(const[c,l]of Object.entries(r))l&&s.postInstallPackages.push(c);break}case"pnpm":{s.scriptsBlockedByDefault=!0,i||s.warnings.push("pnpm blocks build scripts by default. Run 'vis approve-builds' to review packages that need scripts.");break}case"yarn":{if(s.scriptsBlockedByDefault=!1,D2(t)){const o=G(g(t,".yarnrc.yml"));/^\s*enableScripts\s*:\s*false\s*$/m.test(o)?s.scriptsBlockedByDefault=!0:s.warnings.push("yarn berry supports enableScripts. Add 'enableScripts: false' to .yarnrc.yml.")}else if(s.warnings.push("yarn classic does not support blocking lifecycle scripts. Consider upgrading to yarn berry."),i){s.extraArgs.push("--ignore-scripts");for(const[o,a]of Object.entries(r))a&&s.postInstallPackages.push(o)}break}}return s},Zu=(...e)=>{const t={...process.env},n=t.PATH??t.Path??"",s=e.filter(r=>r.length>0).join(Yo);return t.PATH=s.length>0?n?`${s}${Yo}${n}`:s:n,t},L2=e=>{if(e.endsWith("*"))return e.endsWith("@*")?e.slice(0,-2):e;const t=e.startsWith("@"),n=e.indexOf("@",t?1:0);return n===-1?e:e.slice(0,n)},_2=(e,t)=>{const n=g(e,"node_modules"),s=[];for(const r of t){if(!r.endsWith("*")){s.push(L2(r));continue}const i=r.slice(0,-1);try{if(i.startsWith("@")&&i.endsWith("/")){const o=g(n,i.slice(0,-1));for(const a of Te(o))!a.startsWith(".")&&Ot(g(o,a)).isDirectory()&&s.push(`${i.slice(0,-1)}/${a}`)}else for(const o of Te(n))o.startsWith(i)&&Ot(g(n,o)).isDirectory()&&s.push(o)}catch{}}return s},F2=(e,t)=>{if(t.length===0)return;const n=_2(e,t);if(n.length===0)return;const s=g(e,"node_modules"),r=g(s,".bin");let i=!1;for(const o of n){if(o.includes("..")||o.startsWith("/")||o.startsWith("\\")){E.warn(`Skipping invalid package name: ${o}`);continue}const a=(o.match(/\//g)??[]).length;if(a>1||a===1&&!o.startsWith("@")){E.warn(`Skipping invalid package name: ${o}`);continue}const c=g(s,o),l=g(c,"package.json");if(x(l))try{const d=le(l).scripts??{},u=g(c,"node_modules",".bin"),p=Zu(u,r);for(const f of["preinstall","install","postinstall"])if(d[f]){E.info(`Running ${f} for ${o}...`);try{const h=d[f];ul(h,{cwd:c,env:p,stdio:"inherit"})}catch{E.error(`${f} script failed for ${o}`),i=!0}}}catch{}}i&&(process.exitCode=1)},vR=(e,t=["prepublish","prepare"])=>{const n=g(e,"package.json");if(!x(n))return;let s;try{s=le(n).scripts??{}}catch{return}let r=!1;const i=Zu(g(e,"node_modules",".bin"));for(const o of t){const a=s[o];if(a){E.info(`Running root ${o}...`);try{ul(a,{cwd:e,env:i,stdio:"inherit"})}catch{E.error(`Root ${o} script failed.`),r=!0}}}r&&(process.exitCode=1)},Zr=new Set(["add","install","update"]),V2=new Set(["add","dedupe","install","remove","update"]),W2=/(\d+\.\d+\.\d+)/,H2=e=>{const t=g(e,"package.json");if(!x(t))return[];const n=[];try{const s=le(t),r={...s.dependencies,...s.devDependencies};for(const[i,o]of Object.entries(r)){const a=g(e,"node_modules",i,"package.json");if(x(a))try{const l=le(a);if(l.version){n.push({name:i,version:l.version});continue}}catch{}const c=W2.exec(o);c?.[1]&&n.push({name:i,version:c[1]})}}catch{}return n},U2={afterCommand:async e=>{if(process.exitCode&&process.exitCode!==0)return;const t=e.scriptEnforcement;t?.postInstallPackages.length&&e.workspaceRoot&&F2(e.workspaceRoot,t.postInstallPackages);const n=process.argv[2]??"",s=Zr.has(n)&&e.workspaceRoot?Qo(e.workspaceRoot):void 0;if(s&&e.visConfig&&e.workspaceRoot&&new Set(["bun","npm","pnpm","yarn"]).has(s.name)){const i=P2(e.visConfig,s.name,e.workspaceRoot);if(i.hasDrift){E.info("");for(const o of N2(i))E.warn(o)}}if(Zr.has(n)&&e.workspaceRoot){const r=new Set;Xr("socket")&&r.add("socket"),Xr("depsDev")&&r.add("deps-dev");const i=e.visConfig?.security?.policies?.score?.minimum,o=Wf(e.visConfig?.security,{disabled:r,minimumScore:i});if(o.length>0)try{const a=H2(e.workspaceRoot);if(a.length>0){const c=await Hf(o,a);if(c.size>0){const l=ch(c,i);if(l){E.info(""),E.info(l);let d=0;for(const u of c.values())for(const p of u.alerts)(p.severity==="critical"||p.severity==="high")&&d++;d>0&&E.warn(`${String(d)} critical/high severity alert${d===1?"":"s"} detected. Run 'vis check --security' for details.`)}}}}catch{}}},beforeCommand:async e=>{const t=process.argv[2]??"";if(V2.has(t)&&e.visConfig&&e.workspaceRoot){const n=Qo(e.workspaceRoot),s=Zr.has(t);if(O2(e.visConfig,n.name,s),s&&!Xr("installScripts")){const r=M2(n.name,e.workspaceRoot,e.visConfig);for(const i of r.warnings)e.logger.warn(`security: ${i}`);e.scriptEnforcement=r}}},name:"security-enforcement"};class To extends bf{troubleshooting;constructor(t,n,s=[]){super(t,n,{troubleshooting:s}),this.name="CompletionError",this.troubleshooting=s,s.length>0&&(this.hint=s.join(`
|
|
193
|
+
`))}}const Di=["bash","zsh","fish","powershell"],Mi=["node","bun","deno"],G2=e=>"Deno"in e,z2=e=>"Bun"in e,Mc=()=>G2(globalThis)?"deno":z2(globalThis)?"bun":"node",Lc=e=>{const t=e?.starshipShell??e?.shell;if(t){const r=t.toLowerCase();if(r.includes("zsh"))return"zsh";if(r.includes("bash"))return"bash";if(r.includes("fish"))return"fish"}const n=e?.psModulePath,s=e?.prompt;if(n||s?.includes("PS"))return"powershell";if(e?.comSpec?.toLowerCase().includes("cmd.exe"))return"bash"},J2=async()=>(await import("./index4.js")).default,q2=(e,t)=>{for(const n of t)n.hidden||(n.name&&e.option(n.name,n.description??""),n.alias&&e.option(n.alias,n.description??""))},K2=(e,t)=>{for(const[n,s]of t){if(s.name!==n||s.hidden)continue;const r=e.command(s.name,s.description??"");s.options&&q2(r,s.options)}},Y2=e=>{if(!Di.includes(e))throw new To(`Invalid shell type: ${e}`,"INVALID_SHELL",[`Valid shells are: ${Di.join(", ")}`,"Shell will be auto-detected if not specified"])},X2=e=>{if(e&&!Mi.includes(e))throw new To(`Invalid runtime: ${e}`,"INVALID_RUNTIME",[`Valid runtimes are: ${Mi.join(", ")}`,"Runtime will be auto-detected if not specified"])},Z2=(e,t)=>{e.error("Could not detect current shell");const n=[`Usage: ${t} completion --shell=<bash|zsh|fish|powershell> [--runtime=<node|bun|deno>]`,"","Examples:"," # Install completions for zsh:",` ${t} completion --shell=zsh > ~/.${t}-completion.zsh`,` echo 'source ~/.${t}-completion.zsh' >> ~/.zshrc`,""," # Install completions for bash with custom runtime:",` ${t} completion --shell=bash --runtime=bun > ~/.${t}-completion.bash`,` echo 'source ~/.${t}-completion.bash' >> ~/.bashrc`,""," # Install completions for fish:",` ${t} completion --shell=fish > ~/.config/fish/completions/${t}.fish`].join(`
|
|
194
|
+
`);e.info(n)},Q2={description:"Generate shell completion scripts",env:[{description:"Shell path (Unix-like systems). Used for shell detection.",name:"SHELL",type:String},{description:"Starship shell configuration. Takes precedence over SHELL for detection.",name:"STARSHIP_SHELL",type:String},{description:"PowerShell module path (Windows). Used for PowerShell detection.",name:"PSModulePath",type:String},{description:"Command prompt variable (Windows). Used for PowerShell detection.",name:"PROMPT",type:String},{description:"Command processor (Windows). Used for Windows Command Prompt detection.",name:"ComSpec",type:String}],execute:async({env:e,logger:t,options:n,runtime:s})=>{const r=s.getCliName(),i=n.shell??Lc(e);if(!i){Z2(t,r);return}try{Y2(i),X2(n.runtime);const o=await J2();K2(o,s.getCommands());const a=`${n.runtime??Mc()} ${r}`;o.setup(r,a,i)}catch(o){if(o instanceof To){const a=[`Failed to generate completion script: ${o.message}`,`Error code: ${o.code}`];throw o.troubleshooting.length>0&&a.push("","Troubleshooting:",...o.troubleshooting.map(c=>` • ${c}`)),t.error(a.join(`
|
|
195
|
+
`)),o}else{const a=["Failed to generate completion script",`Error: ${o instanceof Error?o.message:String(o)}`,"","Troubleshooting:"," • Ensure @bomb.sh/tab is installed: pnpm add @bomb.sh/tab",` • Verify shell is supported: ${Di.join(", ")}`,` • Verify runtime is supported: ${Mi.join(", ")}`," • Check that your CLI name is correct"];t.error(a.join(`
|
|
196
|
+
`))}}},name:"completion",options:[{defaultOption:!0,defaultValue:Lc(),description:"Shell type (bash, zsh, fish, powershell). Defaults to current shell if detected.",name:"shell",type:String,typeLabel:"{underline shell}"},{defaultValue:Mc(),description:"JavaScript runtime (node, bun, deno). Defaults to current runtime if detected.",name:"runtime",type:String,typeLabel:"{underline runtime}"}]},ex={alias:["v","V"],description:"Output the version number",execute:({logger:e,runtime:t})=>{const n=t.getPackageVersion();n===void 0?(e.warn("Unknown version"),e.debug("The version number was not provided by the cli constructor.")):e.info(n)},name:"version",options:[],usage:[]},tx={argument:{description:"Target selector (same syntax as `vis run`): `build`, `:build`, `~:test`, `#tag:lint`, …",name:"selector",type:String},description:"Show the execution plan for a target without running it",examples:[["vis action-graph build","Print the task plan for `build` on every project"],["vis action-graph :test","Moon-style selector"],["vis action-graph build --json","Emit a JSON description of the plan"],['vis action-graph lint --query "tag=frontend"',"Filter projects by query"],["vis action-graph build --projects=@org/web","Plan only the named projects (same flag as `vis run`)"]],group:"Workspace",loader:()=>import("./handler2.js"),name:"action-graph",options:[{defaultValue:!1,description:"Emit JSON instead of ASCII",name:"json",type:Boolean},{alias:"p",description:"Comma-separated list of projects to plan (same semantics as `vis run --projects`)",name:"projects",type:String},{description:"Filter matched projects by a query",name:"query",type:String},{description:'Only plan projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…".',multiple:!0,name:"tag",type:String}]},nx={argument:{description:"Packages to add (e.g., react react-dom)",name:"packages",type:String},description:"Add packages using the detected package manager",examples:[["vis add react react-dom","Add packages"],["vis add -D typescript @types/react","Add as dev dependencies"],["vis add react --filter app","Add to specific workspace package"],["vis add react --to web","Add to one package, auto-conforming the version to existing catalogs / sibling deps"],["vis add -g typescript","Add globally (uses npm)"],["vis add lodash -w","Add to workspace root"],["vis add lodash --no-socket-check","Add without Socket.dev check"],["vis add lodash --no-typosquat-check","Skip typosquat name check"],["vis add lodash --no-marshall-check","Skip the offline marshall pipeline (author, downloads, etc.)"],["vis add lodash --run-scripts","Run lifecycle scripts (opts out of vis's default block-by-default policy)"]],group:"Dependencies",loader:()=>import("./handler15.js"),name:"add",options:[{alias:"D",defaultValue:!1,description:"Add as dev dependency",name:"save-dev",type:Boolean},{alias:"E",defaultValue:!1,description:"Save exact version",name:"exact",type:Boolean},{alias:"P",defaultValue:!1,description:"Add as peer dependency",name:"save-peer",type:Boolean},{alias:"O",defaultValue:!1,description:"Add as optional dependency",name:"save-optional",type:Boolean},{alias:"g",defaultValue:!1,description:"Install globally (uses npm)",name:"global",type:Boolean},{alias:"w",defaultValue:!1,description:"Add to workspace root",name:"workspace-root",type:Boolean},{defaultValue:!1,description:"Use workspace protocol (pnpm)",name:"workspace",type:Boolean},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String},{description:"Target a single workspace package and auto-conform the version to existing catalogs / sibling deps (syncpack#285)",name:"to",type:String},{defaultValue:!1,description:"Skip typosquat name check before adding",name:"no-typosquat-check",type:Boolean},{defaultValue:!1,description:"Skip Socket.dev security check before adding",name:"no-socket-check",type:Boolean},{defaultValue:!1,description:"Skip the offline marshall pipeline (author, provenance, metadata, downloads, expired-domains, new-bin, signatures, archived-repo)",name:"no-marshall-check",type:Boolean},{defaultValue:!1,description:"Run lifecycle scripts during add (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)",name:"run-scripts",type:Boolean},{defaultValue:!1,description:"After adding, recursively install non-optional peer dependencies that aren't already in the workspace (matches nypm's installPeerDependencies)",name:"auto-install-peers",type:Boolean}]},Oo={description:"Override the cache DB path (defaults to <cache>/vis/advisories/db.sqlite via @visulima/find-cache-dir).",name:"db",type:String},ds={description:"Output format: table (default) or json.",name:"format",type:String},sx={commandPath:["advisories"],description:"Download and ingest one or more OSV ecosystem dumps into the local cache",examples:[["vis advisories sync","Sync the npm ecosystem (default)"],["vis advisories sync --ecosystem npm","Sync a single explicit ecosystem"],["vis advisories sync --ecosystem npm,PyPI","Sync several ecosystems in one pass"],["vis advisories sync --force","Re-download even when the ETag matches"],["vis advisories sync --source https://mirror.example.com","Use a corporate OSV mirror (must be in allowedHosts)"]],group:"Security & Health",loader:Z(()=>import("./sync.js"),"advisoriesSyncExecute"),name:"sync",options:[{description:"Comma-separated list of ecosystems to sync (default: npm).",name:"ecosystem",type:String},{defaultValue:!1,description:"Re-download and re-ingest even if the upstream ETag is unchanged.",name:"force",type:Boolean},{description:"Override the advisory source URL. Must be https and resolve to an allowed host.",name:"source",type:String},Oo,ds]},rx={commandPath:["advisories"],description:"Print the local advisory DB summary: path, schema version, ecosystems, row counts, last sync, ETag",examples:[["vis advisories status","Human-readable summary"],["vis advisories status --format json","Machine-readable for CI freshness checks"]],group:"Security & Health",loader:Z(()=>import("./status.js"),"advisoriesStatusExecute"),name:"status",options:[Oo,ds]},ix={commandPath:["advisories"],description:"Delete the local advisory DB. The next `vis audit --offline` will fail until you re-sync",examples:[["vis advisories prune","Confirm and delete the local DB"],["vis advisories prune --force","Delete without confirmation"]],group:"Security & Health",loader:Z(()=>import("./prune.js"),"advisoriesPruneExecute"),name:"prune",options:[Oo,{defaultValue:!1,description:"Skip the confirmation prompt.",name:"force",type:Boolean},ds]},Qu={description:"Override the bloom cache directory (defaults to <cache>/vis/osv-bloom/).",name:"cache-dir",type:String},ox={commandPath:["advisories","bloom"],description:"Fetch and verify the endevco/osv-bloom MAL-* prefilter into the local cache",examples:[["vis advisories bloom sync","Fetch the bloom filter from the default upstream"],["vis advisories bloom sync --force","Re-download even when the set digest matches"],["vis advisories bloom sync --source https://bloom.example.com","Use an internal mirror (must be in allowedHosts)"]],group:"Security & Health",loader:Z(()=>import("./bloom-sync.js"),"advisoriesBloomSyncExecute"),name:"sync",options:[{defaultValue:!1,description:"Re-download and re-verify even when the upstream set digest is unchanged.",name:"force",type:Boolean},{description:"Override the bloom source URL. Must be https and resolve to an allowed host.",name:"source",type:String},Qu,ds]},ax={commandPath:["advisories","bloom"],description:"Print the local osv-bloom cache freshness: built-at, filter size, m/k parameters, set digest",examples:[["vis advisories bloom status","Human-readable summary"],["vis advisories bloom status --format json","Machine-readable for CI freshness checks"]],group:"Security & Health",loader:Z(()=>import("./bloom-status.js"),"advisoriesBloomStatusExecute"),name:"status",options:[Qu,ds]},cx=[sx,rx,ix,ox,ax],Ge=e=>[e,{description:`Disable --${e.name}.`,hidden:!0,name:`no-${e.name}`,type:Boolean}],lx={argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target only on projects affected by recent changes",examples:[["vis affected build","Run build on affected projects"],["vis affected test --base=main","Run tests on projects changed since main"],["vis affected destroy --reverse","Tear down affected projects leaves-first"],["vis affected build --sparse-checkout","Print a git sparse-checkout cone set for the affected projects and exit"]],group:"Run & Execute",loader:()=>import("./handler3.js"),name:"affected",options:[{description:"Git base ref for comparison. When omitted, vis auto-resolves it from the active CI provider (GitHub/GitLab/Buildkite/CircleCI) or falls back to `git merge-base HEAD origin/<defaultBase>` locally. Default base branch comes from `vis.config.ts#defaultBase` (or `main`).",name:"base",type:String},{description:"Git head ref for comparison. When omitted, auto-resolves from CI env (e.g. `$GITHUB_SHA`) or defaults to `HEAD`.",name:"head",type:String},...Ge({description:"Include uncommitted working-tree changes (tracked edits and untracked files) in the changed-file set. Defaults to on for local runs and off in CI; use --no-uncommitted to force off.",name:"uncommitted",type:Boolean}),{defaultValue:"deep",description:'Downstream scope: "none", "direct", or "deep" — controls how far to include dependents of changed projects',name:"downstream",type:String},{defaultValue:"none",description:'Upstream scope: "none", "direct", or "deep" — controls how far to include dependencies of changed projects',name:"upstream",type:String},{defaultValue:3,description:"Maximum number of parallel tasks",name:"parallel",type:Number},...Ge({defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean}),{defaultValue:!1,description:"Show what would run without executing",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Instead of running, print the affected project roots as a git sparse-checkout cone set (one path per line) and exit. Pipe into `git sparse-checkout set --stdin` to shrink huge-monorepo CI checkouts.",name:"sparse-checkout",type:Boolean},{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',name:"partition",type:String},{description:"Filter affected projects by a query (e.g. 'language=typescript && tag=lib')",name:"query",type:String},{description:'Only run affected projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…"; combines with --query as AND.',multiple:!0,name:"tag",type:String},{defaultValue:!1,description:"Run the dependency graph in reverse (leaves first, then their dependents). Useful for teardown targets like `destroy`/`undeploy` where dependents must run before the things they depend on.",name:"reverse",type:Boolean},{description:"Comma-separated tags this runner advertises (e.g. 'gpu,slow'). Forwarded verbatim to the downstream `vis run` so capability-gated tasks resolve identically. Falls back to VIS_RUNNER_TAGS env var.",name:"runner-tags",type:String}]},ep={description:"Output format: table or json (default: table)",name:"format",type:String},dx={commandPath:["ai"],description:"List detected AI providers and show which one is selected",examples:[["vis ai providers","List all AI providers and their status"],["vis ai providers --format json","Output as JSON"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiProvidersExecute"),name:"providers",options:[ep]},ux={commandPath:["ai"],description:"Test the best available AI provider with a quick prompt",examples:[["vis ai test","Test the selected provider"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiTestExecute"),name:"test",options:[]},px={argument:{description:"Task ID to propose a fix for (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["ai"],description:"Read a failed task's logs and propose a structured patch (Phase 1: local-only, no git)",examples:[["vis ai fix @myorg/app:build","Print proposed patch for the failed task"],["vis ai fix @myorg/app:build --apply","Apply the patch to disk after confirming"],["vis ai fix @myorg/app:build --format json","Machine-readable patch output"],["vis ai fix @myorg/app:build --run 2026-04-28T...","Inspect a specific historical run"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiFixExecute"),name:"fix",options:[ep,{description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},{defaultValue:!1,description:"Apply the proposed patch to disk after printing it",name:"apply",type:Boolean},{defaultValue:!1,description:"Bypass the AI response cache",name:"no-cache",type:Boolean},{defaultValue:!1,description:"Skip the confirmation prompt before applying",name:"yes",type:Boolean}]},fx={description:"AI-assisted commands: provider detection and failure-fix proposals (cache management lives under `vis cache`)",examples:[["vis ai","List all AI subcommands"],["vis ai discover-help","Machine-readable subcommand catalogue (for AI agents)"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiRootExecute"),name:"ai",options:[]},hx={commandPath:["ai"],description:"Print the machine-readable AI subcommand catalogue (JSON to stdout, designed for AI agents)",examples:[["vis ai discover-help","Emit the discovery payload as JSON"],["vis ai discover-help | jq '.subcommands[].path'","List all available paths"]],group:"System",loader:Z(()=>import("./handler50.js"),"aiDiscoverHelpExecute"),name:"discover-help",options:[]},mx={commandPath:["ai"],description:"Diagnose the most recent failed task and post a structured patch as a PR/MR comment (or Buildkite annotation)",examples:[["vis ai heal","Heal the most recent failure"],["vis ai heal --dry-run","Propose a patch but skip apply / validate / post"],["vis ai heal --run 2026-04-28T...","Heal a specific historical run"]],group:"System",loader:Z(()=>import("./heal.js").then(e=>e.h),"aiHeal"),name:"heal",options:[{defaultValue:!1,description:"Show the proposal and exit without applying or posting it",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Bypass the AI response cache",name:"no-cache",type:Boolean},{description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},{description:"Per-task validation timeout in seconds (default: 1800)",name:"validation-timeout",type:Number}]},gx={commandPath:["ai","heal"],description:"Re-run the proposed fix and commit it to the PR/MR branch when validation passes",examples:[["vis ai heal accept","Triggered automatically by a `/vis heal accept` PR comment (GitHub/GitLab) or a Buildkite block-step unblock"]],group:"System",loader:Z(()=>import("./heal-accept.js"),"aiHealAccept"),name:"accept",options:[{description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},{description:"Per-task validation timeout in seconds (default: 1800)",name:"validation-timeout",type:Number}]},tp=[fx,hx,dx,ux,px,mx,gx],bR=Object.defineProperty({__proto__:null,default:tp},Symbol.toStringTag,{value:"Module"}),yx={argument:{description:"Package name to analyze (e.g., react)",name:"package",required:!0,type:String},description:"Analyze a single package update with AI",examples:[["vis analyze react","Analyze updating react to latest"],["vis analyze react 19.0.0","Analyze updating react to specific version"],["vis analyze react --ai-type security","Run security-focused analysis"],["vis analyze react --format json","Output as JSON"]],group:"System",loader:()=>import("./handler4.js"),name:"analyze",options:[{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",name:"ai-type",type:String},{defaultValue:!1,description:"Check for known security vulnerabilities",name:"security",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]},vx={description:"Review and approve dependencies with build scripts",examples:[["vis approve-builds","Scan and list unapproved build scripts"],["vis approve-builds --all","Approve all pending builds (pnpm)"],["vis approve-builds --write","Write unapproved entries into vis.config.ts security.policies.installScripts.allow"],["vis approve-builds --sync-native","Sync allowBuilds to native PM config"]],group:"Security & Health",loader:()=>import("./handler51.js"),name:"approve-builds",options:[{defaultValue:!1,description:"Approve all pending builds without prompting (pnpm only)",name:"all",type:Boolean},{defaultValue:!1,description:"Force vis scanning even for pnpm (instead of delegating)",name:"scan",type:Boolean},{defaultValue:!1,description:"Sync allowBuilds to native PM config (bun: trustedDependencies, npm: .npmrc, yarn: .yarnrc.yml)",name:"sync-native",type:Boolean},{defaultValue:!1,description:"Write unapproved entries directly into vis.config.ts security.policies.installScripts.allow (LavaMoat 'auto' parity)",name:"write",type:Boolean}]},np={description:"Output format: table, json, or ndjson (default: table). json/ndjson go to stdout, logs to stderr.",name:"format",type:String},bx={commandPath:["attest"],description:"Verify inbound provenance + registry signatures across the locked dependency graph and gate on regressions",examples:[["vis attest verify","Check every locked dep for provenance regressions and signature problems"],["vis attest verify --prod-only","Skip devDependencies"],["vis attest verify --format json","Machine-readable findings for CI (Axis A)"],["vis attest verify --fail-on error","Exit non-zero only on error-severity findings (default: any finding)"]],group:"Security & Health",loader:Z(()=>import("./handler5.js"),"attestVerifyExecute"),name:"verify",options:[np,{defaultValue:!1,description:"Skip devDependencies — verify the production graph only.",name:"prod-only",type:Boolean},{description:"Severity that triggers a non-zero exit: 'warning' (any finding, default) or 'error'.",name:"fail-on",type:String},{description:"Comma-separated package names to exclude from both marshalls.",name:"allowlist",type:String}]},wx={argument:{description:"Path to the built artifact to attest (e.g. dist/app.tgz). Its sha256 becomes the in-toto subject digest.",name:"subject",type:String},description:"Build an in-toto SLSA v1 provenance statement for an artifact and keyless-sign it via Sigstore",examples:[["vis attest dist/app.tgz","Emit dist/app.tgz.sigstore (keyless-signed in CI)"],["vis attest dist/app.tgz --output attest.sigstore","Write the bundle to a specific path"],["vis attest dist/app.tgz --predicate slsaProvenance","Predicate type (default: slsaProvenance)"],["vis attest dist/app.tgz --require-signing","Fail instead of skip-with-warn when no ambient OIDC (outside CI)"],["vis attest dist/app.tgz --format json","Print the signed bundle summary as JSON (Axis A)"]],group:"Security & Health",loader:Z(()=>import("./handler5.js"),"attestEmitExecute"),name:"attest",options:[np,{description:"Write the serialized Sigstore bundle here (default: <subject>.sigstore).",name:"output",type:String},{description:"Predicate type: 'slsaProvenance' (default, https://slsa.dev/provenance/v1).",name:"predicate",type:String},{defaultValue:!1,description:"Error instead of skip-with-warn when no ambient OIDC token is available (i.e. outside CI).",name:"require-signing",type:Boolean}]},kx=[wx,bx],Sx={description:"Audit installed packages for vulnerabilities and supply chain risks",examples:[["vis audit","Full audit of all installed packages"],["vis audit --severity high","Show only high/critical issues"],["vis audit --format json","Output as JSON for CI integration"],["vis audit --format sarif","Output SARIF 2.1.0 for code-scanning uploads"],["vis audit --format csaf","Output CSAF 2.0 csaf_vex for enterprise vuln pipelines"],["vis audit --format cyclonedx-vex","Output a CycloneDX 1.7 BOM with vulnerabilities[] (SBOM + VEX)"],["vis audit --format gitlab","Output a GitLab dependency-scanning report (gl-dependency-scanning.json)"],["vis audit --format junit","Output a Surefire-compatible JUnit XML report"],["vis audit --report report.html","Write a self-contained HTML report to ./report.html"],["vis audit --usage","Only report vulnerabilities in statically-imported packages"],["vis audit --offline","Query the local OSV cache only (no network)"],["vis audit --offline --db ./vendor.sqlite","Use a specific advisory DB"],["vis audit --ecosystem npm,pypi","Scan multiple OSV ecosystems (npm, pypi, crates.io, maven, go, rubygems)"],["vis audit --prod-only","Skip devDependencies"],["vis audit --fail-on high","Exit non-zero on any high or critical finding"],["vis audit --show-fixes","Print fix-suggestion lines (no apply, no rescan)"],["vis audit --fix","Apply direct-dep upgrades for vulnerable packages, then rescan (dry-run preview by default)"],["vis audit --fix --yes","Skip the confirmation prompt and run the upgrades immediately"],["vis audit --fix --allow-major","Permit major-version bumps when the lowest fix is outside the existing range"],["vis audit --fix-transitive","Write PM-specific overrides for vulnerable transitives (dry-run preview by default)"],["vis audit --exit-code","Exit with code 1 if issues found (for CI)"],["vis audit --show-accepted","Include acknowledged risks in output"],["vis audit --sync","Sync accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)"],["vis audit --policies license,vulnerability","Run only the named policies (default: every configured policy)"],["vis audit --policies none","Skip the policy engine entirely"],["vis audit --explain","Add a plain-English AI explanation under every finding (auto-detects an installed AI CLI)"],["vis audit --explain CVE-2021-23337","Explain only the finding with this CVE/GHSA id"],["vis audit --explain 2","Explain only the 2nd finding"]],group:"Security & Health",loader:()=>import("./handler72.js"),name:"audit",options:[{description:"Minimum severity to report: low, medium, high, critical (default: low)",name:"severity",type:String},{description:"Output format: table, json, sarif, csaf, cyclonedx-vex, gitlab, or junit (default: table)",name:"format",type:String},{description:"Write a self-contained HTML report to this path. Auto-opens in a TTY when not in CI.",name:"report",type:String},{defaultValue:!1,description:"Only report vulnerabilities in statically-imported packages (reachability filter).",name:"usage",type:Boolean},{defaultValue:!1,description:"Disable the reachability filter even if enabled in config.",name:"no-usage",type:Boolean},{defaultValue:!1,description:"Query the local OSV advisory cache only — no network calls. Errors if the cache is missing.",name:"offline",type:Boolean},{description:"Override the offline advisory DB path (default: <cache>/vis/advisories/db.sqlite).",name:"db",type:String},{description:"Comma-separated list of OSV ecosystems to scan (default: npm). Supported: npm, pypi, crates.io (or 'cargo'), maven, go, rubygems. Non-npm ecosystems require --offline (online OSV path is npm-only).",name:"ecosystem",type:String},{defaultValue:!1,description:"Skip devDependencies — scan production graph only.",name:"prod-only",type:Boolean},{description:"Exit non-zero when any finding is at this severity or higher. One of: low, medium, high, critical.",name:"fail-on",type:String},{defaultValue:!1,description:"Print fix-suggestion lines for each finding (no apply, no rescan)",name:"show-fixes",type:Boolean},{defaultValue:!1,description:"Apply direct-dep fixes for vulnerable packages by running the active PM update command, then rescan",name:"fix",type:Boolean},{defaultValue:!1,description:"Apply transitive fixes by writing PM-specific overrides (pnpm-workspace.yaml / package.json overrides / resolutions)",name:"fix-transitive",type:Boolean},{defaultValue:!1,description:"Skip confirmation prompt for --fix / --fix-transitive (required in CI)",name:"yes",type:Boolean},{defaultValue:!1,description:"Allow --fix to bump a direct dep across a major version when the lowest fix is outside the existing range",name:"allow-major",type:Boolean},{defaultValue:!1,description:"Exit with code 1 if any issues found (for CI)",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Include acknowledged (accepted risk) issues in output",name:"show-accepted",type:Boolean},{defaultValue:!1,description:"Sync vis accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)",name:"sync",type:Boolean},{description:"Comma-separated list of supply-chain policies to evaluate (default: every configured policy). Use 'none' to skip the engine entirely, 'all' to force the full set. Known: malware, firstSeen, unexpectedDeps, publisherChange, installScripts, score, vulnerability, license.",name:"policies",type:String},{description:"Audit backend: 'auto' (default, delegates to 'aube audit' when aube is the installer), 'aube' (force delegate), or 'vis' (always use vis's OSV/Socket scanner).",name:"backend",type:String},{description:"Add a plain-English AI explanation to findings. Bare flag explains all findings at/above --severity; pass a finding index (e.g. 2) or a CVE/GHSA id to explain just one. Auto-detects an installed AI CLI; mutually exclusive with --offline.",name:"explain",type:String}]},us={description:"Cache directory (overrides config and default). Relative paths are resolved against the workspace root.",name:"cache-dir",type:String},vr={description:"Cache scope: 'shared' (default — main worktree's cache), 'worktree' (this checkout's local cache), or 'all' (both)",name:"scope",type:String},sp={description:"Cache type: 'task' (workspace task cache), 'ai' (AI response cache), 'socket' (Socket.dev reports), 'deps-dev' (Google deps.dev reports), or 'all' (default)",name:"type",type:String},xx={commandPath:["cache"],description:"List all cache entries",examples:[["vis cache list","List all cache entries"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheListExecute"),name:"list",options:[us,vr,{description:"Output format: table or json (default: table)",name:"format",type:String}]},$x={commandPath:["cache"],description:"Remove cache entries (defaults to all stores: workspace task cache, AI responses, Socket.dev reports)",examples:[["vis cache clean","Remove all cache entries from every store"],["vis cache clean --type=ai","Clear only the AI response cache"],["vis cache clean --type=task","Clear only the workspace task cache"],["vis cache clean --dry-run","Preview what clean would remove"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheCleanExecute"),name:"clean",options:[us,sp,{defaultValue:!1,description:"Preview without deleting",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Skip the confirmation prompt for out-of-workspace cache directories",name:"force",type:Boolean}]},Ex={commandPath:["cache"],description:"Remove old and oversized cache entries",examples:[["vis cache prune","Remove old and oversized entries"],["vis cache prune --max-age-days=3 --max-size=500MB","Prune with custom limits"],["vis cache prune --keep-last=30","Keep only the 30 most recent entries"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cachePruneExecute"),name:"prune",options:[us,vr,{description:"Remove entries older than N days",name:"max-age-days",type:Number},{description:"Evict oldest entries until cache is under this size (e.g. 500MB)",name:"max-size",type:String},{description:"Keep only the N most recent entries (sorted newest-first by mtime)",name:"keep-last",type:Number}]},Cx={commandPath:["cache"],description:"Print on-disk footprint and stats for one or more cache stores (task / ai / socket)",examples:[["vis cache size","Show stats for every cache store"],["vis cache size --type=ai","Show only the AI response cache (entries, size, oldest, newest)"],["vis cache size --type=task --format=json","Machine-readable task cache size"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheSizeExecute"),name:"size",options:[us,vr,sp,{description:"Output format: table or json (default: table)",name:"format",type:String}]},Ao={description:"Output format: table or json (default: table)",name:"format",type:String},rp={description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},Rx={argument:{description:"Task ID to explain (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Explain why a task missed the cache by diffing hash inputs against the previous run",examples:[["vis cache why @myorg/app:build","Show which inputs changed since the last run"],["vis cache why @myorg/app:build --json","Machine-readable output for CI"],["vis cache why @myorg/app:build --run 2026-04-28T...","Inspect a specific historical run"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheWhyExecute"),name:"why",options:[Ao,rp]},jx={argument:{description:"Task ID to print the hash for (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Print the recorded hash and per-input hash details for a task",examples:[["vis cache hash @myorg/app:build","Show the resolved hash + contributing inputs"],["vis cache hash @myorg/app:build --json","Machine-readable output"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheHashExecute"),name:"hash",options:[Ao,rp]},Tx={argument:{description:"Task ID to verify (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Verify cache restore fidelity: extract the cached entry into a tmp directory and diff each file's content, mode, and mtime against the live workspace. Exits 1 on any drift (changed content, mode, mtime) or if a cached output is missing from the workspace. With --scope=all, the first cache directory containing the task is used.",examples:[["vis cache verify @myorg/app:build","Diff cached outputs vs live workspace files"],["vis cache verify @myorg/app:build --format=json","Machine-readable diff (status: ok | drift)"],["vis cache verify @myorg/app:build --cache-dir=.alt-cache","Verify against a non-default cache directory"],["vis cache verify @myorg/app:build --scope=all","Search shared and worktree caches for the task"]],group:"Workspace",loader:Z(()=>Promise.resolve().then(()=>Lt),"cacheVerifyExecute"),name:"verify",options:[us,vr,Ao]},Ox={commandPath:["cache"],description:"Probe the configured remote cache (HTTP HEAD or REAPI Capabilities) and report reachability, latency, and negotiated capabilities",examples:[["vis cache doctor","Probe the remoteCache configured in vis.config.ts"],["vis cache doctor --url=grpcs://cache.example.com:443 --backend=reapi","Override URL/backend ad-hoc"],["vis cache doctor --json","Machine-readable output"]],group:"Workspace",loader:Z(()=>import("./doctor-probe.js"),"cacheDoctorExecute"),name:"doctor",options:[{description:"Override remote cache URL (otherwise read from vis.config.ts remoteCache.url, or TURBO_API env var)",name:"url",type:String},{description:"Override backend selector: 'http' or 'reapi'",name:"backend",type:String},{description:"Output format: table or json (default: table)",name:"format",type:String},{defaultValue:5e3,description:"Probe timeout in milliseconds (default: 5000)",name:"timeout",type:Number}]},Ax=[xx,$x,Ex,Cx,Rx,jx,Tx,Ox],Ix={alias:["c","outdated"],argument:{description:"Specific packages to check (checks all if omitted)",name:"packages",type:String},description:"Check for outdated dependencies, security vulnerabilities, and supply chain settings",examples:[["vis check","Check all catalog dependencies"],["vis check react","Check specific packages"],["vis check --target minor","Only show minor/patch updates"],["vis check --exclude '@types/*'","Exclude packages by pattern"],["vis check --no-security","Skip vulnerability scanning"],["vis check --security-config","Audit supply chain security settings"],["vis check --security-config --sync","Sync security config to pnpm-workspace.yaml"]],group:"Security & Health",loader:()=>import("./handler6.js"),name:"check",options:[{alias:"t",description:"Update target: latest, minor, or patch (default: latest)",name:"target",type:String},{description:"Glob pattern to include packages (repeatable)",lazyMultiple:!0,name:"include",type:String},{description:"Glob pattern to exclude packages (repeatable)",lazyMultiple:!0,name:"exclude",type:String},{defaultValue:!1,description:"Include prerelease versions",name:"prerelease",type:Boolean},{defaultValue:!1,description:"Skip security vulnerability scanning",name:"no-security",type:Boolean},{defaultValue:!1,description:"Audit supply chain security settings",name:"security-config",type:Boolean},{defaultValue:!1,description:"Sync security settings to pnpm-workspace.yaml (pnpm only, requires --security-config)",name:"sync",type:Boolean},{description:"Output format: table, json, or minimal (default: table)",name:"format",type:String},{defaultValue:!1,description:"Exit with code 1 if outdated dependencies found (for CI)",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Run AI analysis on outdated packages",name:"ai",type:Boolean},{description:"AI analysis type: impact, security, compatibility, or recommend",name:"ai-type",type:String},{alias:"D",conflicts:"prod",description:"Check only devDependencies (npm/yarn mode)",name:"dev",type:Boolean},{alias:"P",conflicts:"dev",description:"Check only dependencies (npm/yarn mode)",name:"prod",type:Boolean},{defaultValue:!1,description:"Include peerDependencies in outdated checks",name:"peer",type:Boolean},{defaultValue:!1,description:"Also check workspace-owned package names against the registry",name:"include-internal",type:Boolean}]},Bx={argument:{description:"Comma-separated list of targets to run (e.g., lint,test,build)",name:"targets",type:String},description:"Run affected targets in a CI-optimized pipeline",examples:[["vis ci lint,test,build","Run lint, test, and build on affected projects"],["vis ci test --base=origin/main","Override the base ref"],["vis ci build --no-install","Skip the install step (assume deps already present)"],["vis ci build --parallel=6","Increase concurrency"]],group:"Run & Execute",loader:()=>import("./handler7.js"),name:"ci",options:[...Ge({defaultValue:!0,description:"Install dependencies before running targets (use --no-install to skip)",name:"install",type:Boolean}),{defaultValue:!1,description:"Skip the toolchain pre-flight (no auto-install for any pinned tool: node / pnpm / yarn / npm / bun / deno / go / python / ruby / rust)",name:"skip-toolchain",type:Boolean},{description:"Git base ref for affected detection (default: auto-detected from CI env)",name:"base",type:String},{description:"Git head ref for affected detection (default: HEAD)",name:"head",type:String},{defaultValue:"none",description:"Upstream scope: none | direct | deep",name:"upstream",type:String},{defaultValue:"deep",description:"Downstream scope: none | direct | deep",name:"downstream",type:String},{defaultValue:4,description:"Maximum number of parallel tasks per target",name:"parallel",type:Number},{description:'Partition tasks for distributed CI (e.g., "1/4")',name:"partition",type:String},{description:"Filter affected projects by a query (e.g. 'language=typescript && tag=lib')",name:"query",type:String}]},Px={argument:{description:"Project name to check (required)",name:"project",type:String},commandPath:["ci"],description:'Exit with inverted codes for CI "Ignored Build Step" gating (Vercel/Netlify)',examples:[["vis ci ignore my-app","Check if my-app is affected and decide whether to build"],["vis ci ignore my-app --base $VERCEL_GIT_PREVIOUS_SHA","Explicit base ref"],["vis ci ignore my-app --json","Emit the decision as JSON instead of text"],["vis ci ignore my-app --verbose","Print debug info about the decision path"],["vis ci ignore my-app --exit-zero-on-build","Normal exit semantics (0=build, 0=skip)"]],group:"Run & Execute",loader:()=>import("./handler52.js"),name:"ignore",options:[{description:"Git base ref for comparison. Defaults to CI provider env vars, then HEAD~1.",name:"base",type:String},{defaultValue:"HEAD",description:"Git head ref for comparison",name:"head",type:String},{defaultValue:"deep",description:'Downstream scope: "none", "direct", or "deep"',name:"downstream",type:String},{defaultValue:"none",description:'Upstream scope: "none", "direct", or "deep"',name:"upstream",type:String},{defaultValue:!1,description:"Emit the decision as JSON on stdout instead of human text",name:"json",type:Boolean},{defaultValue:!1,description:"Exit 0 on build (normal semantics) instead of 1 (inverted Vercel/Netlify semantics)",name:"exit-zero-on-build",type:Boolean},{defaultValue:!1,description:"Enable verbose debug output",name:"verbose",type:Boolean}]},Nx={description:"Remove node_modules from all workspace projects",examples:[["vis clean","Remove all node_modules directories"],["vis clean --lockfile","Also remove lockfiles"],["vis clean --empty-packages","Also remove workspace directories that have no package.json"],["vis clean --dry-run","Preview what would be removed"]],group:"Workspace",loader:()=>import("./handler8.js"),name:"clean",options:[{alias:"l",defaultValue:!1,description:"Also remove lockfiles (pnpm-lock.yaml, package-lock.json, etc.)",name:"lockfile",type:Boolean},{alias:"e",defaultValue:!1,description:"Also remove stale workspace directories that match a workspace pattern but have no package.json",name:"empty-packages",type:Boolean},{defaultValue:!1,description:"Preview what would be removed without deleting",name:"dry-run",type:Boolean}]},Dx={argument:{description:"Template to use (e.g., vis:app, create-vite, user/repo) — omit for interactive mode",name:"template",type:String},description:"Create a new project from a template",examples:[["vis create","Interactive project scaffolding"],["vis create vis:monorepo my-workspace","Create a monorepo workspace"],["vis create vis:app my-app","Scaffold a Vite application"],["vis create vis:library my-lib","Create a TypeScript library"],["vis create vite my-app -- --template react-ts","Use create-vite with React TypeScript"],["vis create user/repo my-project","Clone a GitHub template"],["vis create --list","Show available templates"]],group:"Scaffold & Config",loader:()=>import("./handler68.js"),name:"create",options:[{defaultValue:!1,description:"Show available templates",name:"list",type:Boolean},{description:"Generate editor configs (vscode)",name:"editor",type:String},{defaultValue:!1,description:"Initialize a git repository",name:"git-init",type:Boolean},{defaultValue:!1,description:"Skip interactive prompts",name:"no-interactive",type:Boolean}]},ip=(e,t,n)=>{const s=i=>cl(i)?i:dn(e,i);if(t&&t.length>0)return s(t);if(n&&n.length>0)return s(n);const r=process.env.VIS_CACHE_DIRECTORY;return r&&r.length>0?s(r):dn(e,ml)},Mx=(e,t)=>t===!1?e:ph(e)??e,_c=(e,t,n,s)=>{const r=t??n??process.env.VIS_CACHE_DIRECTORY;if(r&&r.length>0)return ip(e,t,n);const i=Mx(e,s);return dn(i,ml)},Lx=/[^\w.-]+/g,_x=/^-+|-+$/g,Fx=e=>e.trim().replaceAll(Lx,"-").replaceAll(_x,"").slice(0,64),Vx=e=>{try{const t=Jf("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return!t||t==="HEAD"?void 0:t}catch{return}},wR=(e,t,n)=>{if(n!==!0)return e;const s=Vx(t);if(!s)return e;const r=Fx(s);return r.length===0?e:dn(e,"branches",r)},Wx=(e,t)=>{const n=rs(t,e);return n.length===0?!1:n!==".."&&!n.startsWith("../")&&!cl(n)},Hx="x-hono-already-sent";var De=class extends Error{constructor(e,t){super(e,t),this.name="RequestError"}};const Ux=/^\/[!#$&-;=?-\[\]_a-z~]*$/,Gx=/\/\.\.?(?:[/?#]|$)/,zx=/^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/,Jx=(e,t,n)=>{const s=`${e}://${t}${n}`;if(zx.test(t)){if(n.length===0)return s+"/";if(n.charCodeAt(0)!==47)throw new De("Invalid URL");return!Ux.test(n)||Gx.test(n)?new URL(s).href:s}else{const r=new URL(s);if(r.hostname.length!==t.length&&r.hostname!==(t.includes(":")?t.replace(/:\d+$/,""):t).toLowerCase())throw new De("Invalid host header");return r.href}},qx=e=>e instanceof De?e:new De(e.message,{cause:e}),Kx=global.Request;var fn=class extends Kx{constructor(e,t){if(typeof e=="object"&&at in e){const n=t!==void 0&&"body"in t&&t.body!=null;if(e[Je]&&!n)throw new TypeError("Cannot construct a Request with a Request object that has already been used.");e=e[at]()}typeof t?.body?.getReader<"u"&&(t.duplex??="half"),super(e,t)}};const op=e=>{const t=[],n=e.rawHeaders;for(let s=0,r=n.length;s<r;s+=2){const i=n[s];i.charCodeAt(0)!==58&&t.push([i,n[s+1]])}return new Headers(t)},ap=Symbol("wrapBodyStream"),Yx=new Set(["latin1","binary","hex","base64","base64url"]),Xx=e=>e===null||Yx.has(e),Qr=Symbol("bodyBufferedBeforeDisconnect"),Li=Symbol("bodyBufferedLengthBeforeDisconnect"),cp=(e,t)=>Buffer.isBuffer(e)?e:Buffer.from(e,t??"utf8"),Io=e=>!(e instanceof rn)&&!!e.complete&&!!e.readableAborted&&typeof e.read=="function"&&Xx(e.readableEncoding),Fc=e=>{if(e.readableDidRead||!Io(e))return;const t=e;t[Li]??=e.readableLength},Ks=(e,t)=>{if(e.readableDidRead&&!t||!Io(e))return;const n=e;if(n[Qr]!==void 0)return n[Qr];let s;const r=e.errored;if(r&&r.code!=="ECONNRESET")s=r;else if(n[Li]!==void 0&&e.readableLength!==n[Li])s=Ys();else{const i=t??[],o=e.read();o!==null&&i.push(cp(o,e.readableEncoding));const a=i.length===1?i[0]:Buffer.concat(i);s=a;const c=e.headers["content-length"];if(typeof c=="string"&&/^\d+$/.test(c)){const l=Number(c);Number.isSafeInteger(l)&&a.length!==l&&(s=Ys())}}return n[Qr]=s,s},Vc=(e,t)=>{if(t instanceof Error){e.error(t);return}t.length>0&&e.enqueue(t),e.close()},Zx=(e,t,n,s,r)=>{const i={method:e,headers:n,signal:r.signal};if(e==="TRACE"){i.method="GET";const o=new fn(t,i);return Object.defineProperty(o,"method",{get(){return"TRACE"}}),o}if(!(e==="GET"||e==="HEAD"))if("rawBody"in s&&s.rawBody instanceof Buffer)i.body=new ReadableStream({start(o){o.enqueue(s.rawBody),o.close()}});else if(s[ap]){let o;i.body=new ReadableStream({async pull(a){try{if(!o){const d=Ks(s);if(d!==void 0){Vc(a,d);return}}o||=ta.toWeb(s).getReader();const{done:c,value:l}=await o.read();c?a.close():a.enqueue(l)}catch(c){a.error(c)}}})}else{const o=Ks(s);o!==void 0?i.body=new ReadableStream({start(a){Vc(a,o)}}):i.body=ta.toWeb(s)}return new fn(t,i)},at=Symbol("getRequestCache"),He=Symbol("requestCache"),hn=Symbol("incomingKey"),Gn=Symbol("urlKey"),lp=Symbol("methodKey"),dp=Symbol("headersKey"),Tn=Symbol("abortControllerKey"),_i=Symbol("getAbortController"),Fi=Symbol("abortRequest"),st=Symbol("bodyBuffer"),Cs=Symbol("bodyReadPromise"),Je=Symbol("bodyConsumedDirectly"),Wc=Symbol("bodyLockReader"),_n=Symbol("abortReason"),Ys=()=>new TypeError("Body is unusable"),ps=()=>Promise.reject(Ys()),Qx=new TextDecoder,e$=e=>{if(e[Je])return ps();e[Je]=!0},t$=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),n$=e=>(e[dp]||=op(e[hn])).get("content-type")||"",s$=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,r$=e=>{if(typeof e!="string"||e.length===0)return"GET";switch(e){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"PATCH":case"POST":case"PUT":case"QUERY":return e}const t=e.toUpperCase();switch(t){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"POST":case"PUT":return t;default:return e}},i$=e=>{if(!s$.test(e))return new TypeError(`'${e}' is not a valid HTTP method.`);const t=e.toUpperCase();if(t==="CONNECT"||t==="TRACK"||t==="TRACE"&&e!=="TRACE")return new TypeError(`'${e}' HTTP method is unsupported.`)},Bo=(e,t,n)=>{if(e[Je])return ps();const s=e.method;if(s==="GET"||s==="HEAD")return e[at]()[t]();const r=i$(s);if(r)return Promise.reject(r);if(e[He]&&s!=="TRACE")return e[He][t]();const i=e$(e);if(i)return i;const o=o$(e);if(o){const a=Promise.resolve(n(o,e));return e[st]=void 0,a}return a$(e).then(a=>{const c=n(a,e);return e[st]=void 0,c})},o$=e=>{const t=e[hn];if("rawBody"in t&&t.rawBody instanceof Buffer)return t.rawBody},Hc=(e,t)=>{if(t.errored)return t.errored;const n=e[_n];return n!==void 0?n instanceof Error?n:new Error(String(n)):new Error("Client connection prematurely closed.")},a$=e=>{if(e[st])return Promise.resolve(e[st]);if(e[Cs])return e[Cs];const t=e[hn];if(t.readableDidRead)return ps();const n=Ks(t);if(n!==void 0)return n instanceof Error?Promise.reject(n):(e[st]=n,Promise.resolve(n));const s=new Promise((r,i)=>{const o=[];let a=!1;const c=m=>{a||(a=!0,h(),m())},l=m=>{const v=t.errored??m;return!Io(t)||v&&v.code!=="ECONNRESET"?!1:(c(()=>{const $=Ks(t,o);$ instanceof Error?i($):$===void 0?i(m??Hc(e,t)):(e[st]=$,r($))}),!0)},d=m=>{o.push(cp(m,t.readableEncoding))},u=()=>{c(()=>{const m=o.length===1?o[0]:Buffer.concat(o);e[st]=m,r(m)})},p=m=>{l(m)||c(()=>{i(m)})},f=()=>{if(t.readableEnded){u();return}l()||c(()=>{i(Hc(e,t))})},h=()=>{t.off("data",d),t.off("end",u),t.off("error",p),t.off("close",f),e[Cs]=void 0};t.on("data",d),t.on("end",u),t.on("error",p),t.on("close",f),queueMicrotask(()=>{a||(t.readableEnded?u():t.errored?p(t.errored):t.destroyed&&f())})});return e[Cs]=s,s},_e={get method(){return this[lp]},get url(){return this[Gn]},get headers(){return this[dp]||=op(this[hn])},[Fi](e){this[_n]===void 0&&(this[_n]=e);const t=this[Tn];t&&!t.signal.aborted&&t.abort(e)},[_i](){return this[Tn]||=new AbortController,this[_n]!==void 0&&!this[Tn].signal.aborted&&this[Tn].abort(this[_n]),this[Tn]},[at](){const e=this[_i]();if(this[He])return this[He];const t=this.method;if(this[Je]&&!(t==="GET"||t==="HEAD")){this[st]=void 0;const n={method:t==="TRACE"?"GET":t,headers:this.headers,signal:e.signal};t!=="TRACE"&&(n.body=new ReadableStream({start(r){r.close()}}),n.duplex="half");const s=new fn(this[Gn],n);return t==="TRACE"&&Object.defineProperty(s,"method",{get(){return"TRACE"}}),this[He]=s}return this[He]=Zx(this.method,this[Gn],this.headers,this[hn],e)},get body(){if(!this[Je])return this[at]().body;const e=this[at]();return!this[Wc]&&e.body&&(this[Wc]=e.body.getReader()),e.body},get bodyUsed(){return this[Je]?!0:this[He]?this[He].bodyUsed:!1}};Object.defineProperty(_e,"signal",{get(){return this[_i]().signal}});["cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","keepalive"].forEach(e=>{Object.defineProperty(_e,e,{get(){return this[at]()[e]}})});["clone","formData"].forEach(e=>{Object.defineProperty(_e,e,{value:function(){if(this[Je]){if(e==="clone")throw Ys();return ps()}return this[at]()[e]()}})});Object.defineProperty(_e,"text",{value:function(){return Bo(this,"text",e=>Qx.decode(e))}});Object.defineProperty(_e,"arrayBuffer",{value:function(){return Bo(this,"arrayBuffer",e=>t$(e))}});Object.defineProperty(_e,"blob",{value:function(){return Bo(this,"blob",(e,t)=>{const n=n$(t),s=n?{headers:{"content-type":n}}:void 0;return new Response(e,s).blob()})}});Object.defineProperty(_e,"json",{value:function(){return this[Je]?ps():this.text().then(JSON.parse)}});Object.defineProperty(_e,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,n){return`Request (lightweight) ${n({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[He]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(_e,fn.prototype);const c$=(e,t)=>{const n=Object.create(_e);n[hn]=e,n[lp]=r$(e.method);const s=e.url||"";if(s[0]!=="/"&&(s.startsWith("http://")||s.startsWith("https://"))){if(e instanceof rn)throw new De("Absolute URL for :path is not allowed in HTTP/2");try{n[Gn]=new URL(s).href}catch(o){throw new De("Invalid absolute URL",{cause:o})}return n}const r=(e instanceof rn?e.authority:e.headers.host)||t;if(!r)throw new De("Missing host header");let i;if(e instanceof rn){if(i=e.scheme,!(i==="http"||i==="https"))throw new De("Unsupported scheme")}else i=e.socket&&e.socket.encrypted?"https":"http";try{n[Gn]=Jx(i,r,s)}catch(o){throw o instanceof De?o:new De("Invalid URL",{cause:o})}return n},tt="text/plain; charset=UTF-8",Vi=Symbol("responseCache"),en=Symbol("getResponseCache"),ze=Symbol("cache"),Xs=global.Response;var Le=class up{#e;#t;[en](){const t=this[ze],n=t&&t[2]instanceof Headers?t[2]:void 0;return delete this[ze],this[Vi]||=new Xs(this.#e,n?{status:this.#t?.status,statusText:this.#t?.statusText,headers:n}:this.#t)}constructor(t,n){let s;if(this.#e=t,n instanceof Xs){const r=n[Vi];if(r){this.#t=r,this[en]();return}this.#t=n instanceof up?n.#t:n,s=new Headers(n.headers)}else this.#t=n;(t==null||typeof t=="string"||typeof t?.getReader<"u"||t instanceof Blob||t instanceof Uint8Array)&&(this[ze]=[n?.status||200,t??null,s||n?.headers])}get headers(){const t=this[ze];return t?(t[2]instanceof Headers||(t[2]=new Headers(t[2]||(t[1]===null?void 0:{"content-type":tt}))),t[2]):this[en]().headers}get status(){return this[ze]?.[0]??this[en]().status}get ok(){const t=this.status;return t>=200&&t<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(Le.prototype,e,{get(){return this[en]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(Le.prototype,e,{value:function(){return this[en]()[e]()}})});Object.defineProperty(Le.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,n){return`Response (lightweight) ${n({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[Vi]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(Le,Xs);Object.setPrototypeOf(Le.prototype,Xs.prototype);const l$=/^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/,d$=e=>e instanceof URL?e.href:l$.test(e)?e:new URL(e).href,u$=new Set([301,302,303,307,308]);Object.defineProperty(Le,"redirect",{value:function(t,n=302){if(!u$.has(n))throw new RangeError("Invalid status code");return new Le(null,{status:n,headers:{location:d$(t)}})},writable:!0,configurable:!0});Object.defineProperty(Le,"json",{value:function(t,n){const s=JSON.stringify(t);if(s===void 0)throw new TypeError("The data is not JSON serializable");const r=n?.headers;let i;return r?(i=new Headers(r),i.has("content-type")||i.set("content-type","application/json")):i={"content-type":"application/json"},new Le(s,{status:n?.status??200,statusText:n?.statusText,headers:i})},writable:!0,configurable:!0});async function p$(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function pp(e,t,n){const s=a=>{e.cancel(a).catch(()=>{})};return t.on("close",s),t.on("error",s),(n??e.read()).then(o,r),e.closed.finally(()=>{t.off("close",s),t.off("error",s)});function r(a){a&&t.destroy(a)}function i(){e.read().then(o,r)}function o({done:a,value:c}){try{if(a)t.end();else if(!t.write(c))t.once("drain",i);else return e.read().then(o,r)}catch(l){r(l)}}}function Uc(e,t){if(e.locked)throw new TypeError("ReadableStream is locked.");return t.destroyed?void 0:pp(e.getReader(),t)}const Wi=(e,t)=>{const n={};if(e instanceof Headers||(e=new Headers(e??void 0)),e.has("set-cookie")){const s=[];for(const[r,i]of e)r==="set-cookie"?s.push(i):n[r]=i;s.length>0&&(n["set-cookie"]=s)}else for(const[s,r]of e)n[s]=r;return t&&(n["content-type"]??=t),n},Zs=Symbol("outgoingEnded"),Gc=Symbol("incomingDraining"),f$=500,h$=64*1024*1024,fp=e=>{const t=e;if(e.destroyed||t[Gc])return;if(t[Gc]=!0,e instanceof rn){try{e.stream?.close?.(bh.NGHTTP2_NO_ERROR)}catch{}return}let n=0;const s=()=>{clearTimeout(i),e.off("data",o),e.off("end",s),e.off("error",s)},r=()=>{s();const a=e.socket;a&&!a.destroyed&&(typeof a.destroySoon=="function"?a.destroySoon():typeof a.destroy=="function"&&a.destroy())},i=setTimeout(r,f$);i.unref?.();const o=a=>{n+=a.length,n>h$&&r()};e.on("data",o),e.on("end",s),e.on("error",s),e.resume()},m$=(e,t,n,s)=>()=>{t.errored?(Fc(t),e[Fi](t.errored.toString())):n.writableFinished||(Fc(t),e[Fi]("Client connection prematurely closed.")),s&&!t.readableEnded&&setTimeout(()=>{t.readableEnded||setTimeout(()=>{fp(t)})})},g$=e=>{if(!(ze in e))return!1;const t=e[ze][1];return t===null||typeof t=="string"||t instanceof Uint8Array},y$=()=>new Response(null,{status:400}),hp=e=>new Response(null,{status:e instanceof Error&&(e.name==="TimeoutError"||e.constructor.name==="TimeoutError")?504:500}),Qs=(e,t)=>{const n=e instanceof Error?e:new Error("unknown error",{cause:e});n.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Error: ${n.message}`),t.destroy(n))},Hi=e=>{"flushHeaders"in e&&e.writable&&e.flushHeaders()},mp=async(e,t)=>{let[n,s,r]=e[ze];if(!r){s===null?(t.writeHead(n),t.end()):typeof s=="string"?(t.writeHead(n,{"Content-Type":tt,"Content-Length":Buffer.byteLength(s)}),t.end(s)):s instanceof Uint8Array?(t.writeHead(n,{"Content-Type":tt,"Content-Length":s.byteLength}),t.end(s)):s instanceof Blob?(t.writeHead(n,{"Content-Type":tt,"Content-Length":s.size}),t.end(new Uint8Array(await s.arrayBuffer()))):(t.writeHead(n,{"Content-Type":tt}),Hi(t),await Uc(s,t)?.catch(o=>Qs(o,t))),t[Zs]?.();return}let i=!1;if(r instanceof Headers)i=r.has("content-length"),r=Wi(r,s===null?void 0:tt);else if(Array.isArray(r)){const o=new Headers(r);i=o.has("content-length"),r=Wi(o,s===null?void 0:tt)}else for(const o in r)if(o.length===14&&o.toLowerCase()==="content-length"){i=!0;break}i||(typeof s=="string"?r["Content-Length"]=Buffer.byteLength(s):s instanceof Uint8Array?r["Content-Length"]=s.byteLength:s instanceof Blob&&(r["Content-Length"]=s.size)),t.writeHead(n,r),s==null?t.end():typeof s=="string"||s instanceof Uint8Array?t.end(s):s instanceof Blob?t.end(new Uint8Array(await s.arrayBuffer())):(Hi(t),await Uc(s,t)?.catch(o=>Qs(o,t))),t[Zs]?.()},gp=e=>typeof e.then=="function",v$=async(e,t,n={})=>{if(gp(e))if(n.errorHandler)try{e=await e}catch(r){const i=await n.errorHandler(r);if(!i)return;e=i}else e=await e.catch(hp);if(ze in e)return mp(e,t);const s=Wi(e.headers,e.body===null?void 0:tt);if(e.body){const r=e.body.getReader(),i=[];let o=!1,a;if(s["transfer-encoding"]!=="chunked"){let c=2;for(let l=0;l<c;l++){a||=r.read();const d=await p$(a).catch(u=>{console.error(u),o=!0});if(!d){if(l===1){await new Promise(u=>setTimeout(u)),c=3;continue}break}if(a=void 0,d.value&&i.push(d.value),d.done){o=!0;break}}o&&!("content-length"in s)&&(s["content-length"]=i.reduce((l,d)=>l+d.length,0))}t.writeHead(e.status,s),i.forEach(c=>{t.write(c)}),o?t.end():(i.length===0&&Hi(t),await pp(r,t,a))}else s[Hx]||(t.writeHead(e.status,s),t.end());t[Zs]?.()},b$=(e,t={})=>{const n=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==fn&&(Object.defineProperty(global,"Request",{value:fn}),Object.defineProperty(global,"Response",{value:Le})),async(s,r)=>{let i,o,a=!1,c=!1;const l=()=>{!o||c||(c=!0,r.on("close",m$(o,s,r,a)))};try{if(o=c$(s,t.hostname),a=n&&!(s.method==="GET"||s.method==="HEAD"),a&&(s[ap]=!0,s instanceof rn&&(r[Zs]=()=>{s.readableEnded||setTimeout(()=>{s.readableEnded||setTimeout(()=>{s.destroy(),r.destroy()})})})),i=e(o,{incoming:s,outgoing:r}),!gp(i)&&g$(i))return a&&!s.readableEnded&&r.once("finish",()=>{s.readableEnded||fp(s)}),mp(i,r);l()}catch(d){if(i)return Qs(d,r);if(t.errorHandler){if(l(),i=await t.errorHandler(o?d:qx(d)),!i)return}else o?i=hp(d):i=y$()}try{return await v$(i,r,t)}catch(d){return Qs(d,r)}}},w$=Symbol("CONNECTION_SYMBOL_KEY"),k$=Symbol("WAIT_FOR_WEBSOCKET_SYMBOL"),S$=new Set(["connection","content-length","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","sec-websocket-accept","sec-websocket-extensions","sec-websocket-protocol"]),yp=(e,t)=>{t&&t.forEach((n,s)=>{S$.has(s.toLowerCase())||e.push(`${s}: ${n}`)})},zc=(e,t,n)=>{const s=["Connection: close","Content-Length: 0"];yp(s,n),e.end(`HTTP/1.1 ${t.toString()} ${vh[t]??""}\r
|
|
199
197
|
${s.join(`\r
|
|
200
198
|
`)}\r
|
|
201
199
|
\r
|
|
202
|
-
`)},Q$=e=>{const t=e.socket.encrypted?"https":"http",n=new URL(e.url??"/",`${t}://${e.headers.host??"localhost"}`),s=new Headers;for(const i in e.headers){const r=e.headers[i];r&&s.append(i,Array.isArray(r)?r[0]:r)}return new Request(n,{headers:s})},e2=e=>{const{server:t,fetchCallback:n,wss:s}=e,i=new Map;s.on("connection",(a,c)=>{const l=i.get(c);l&&(l.resolve(a),i.delete(c))});const r=a=>{const c=i.get(a);c&&(i.delete(a),c.reject(new Error("WebSocket handshake aborted")))},o=(a,c)=>new Promise((l,d)=>{i.set(a,{resolve:l,reject:d,connectionSymbol:c})});t.on("upgrade",async(a,c,l)=>{if(a.headers.upgrade?.toLowerCase()!=="websocket")return;const d={incoming:a,outgoing:void 0,wss:s,[X$]:o};let u=400,p;try{const b=await n(Q$(a),d);b instanceof Response&&(u=b.status,p=b.headers)}catch{t.listenerCount("upgrade")===1&&Vc(c,500);return}const f=i.get(a);if(!f||f.connectionSymbol!==d[Y$]){r(a),t.listenerCount("upgrade")===1&&Vc(c,u,p);return}const h=b=>{dp(b,p)},m=()=>r(a);c.once("close",m),s.on("headers",h);try{s.handleUpgrade(a,c,l,b=>{c.off("close",m),s.emit("connection",b,a)})}finally{s.off("headers",h)}}),t.on("close",()=>{s.close()})},t2=e=>{const t=e.fetch,n=q$(t,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming}),s=(e.createServer||dh)(e.serverOptions||{},n);if(e.websocket&&e.websocket.server){if(e.websocket.server.options.noServer!==!0)throw new Error("WebSocket server must be created with { noServer: true } option");e2({server:s,fetchCallback:t,wss:e.websocket.server})}return s},n2=(e,t)=>{const n=t2(e);return n.listen(e?.port??3e3,e.hostname,()=>{n.address()}),n};var Hc=(e,t,n)=>(s,i)=>{let r=-1;return o(0);async function o(a){if(a<=r)throw new Error("next() called multiple times");r=a;let c,l=!1,d;if(e[a]?(d=e[a][0][0],s.req.routeIndex=a):d=a===e.length&&i||void 0,d)try{c=await d(s,()=>o(a+1))}catch(u){if(u instanceof Error&&t)s.error=u,c=await t(u,s),l=!0;else throw u}else s.finalized===!1&&n&&(c=await n(s));return c&&(s.finalized===!1||l)&&(s.res=c),s}},s2=Symbol(),i2=(e,t)=>new Response(e,{headers:{"Content-Type":t.replace(/^[^;]+/,s=>s.toLowerCase())}}).formData(),Ds=e=>"headers"in e,r2=async(e,t=Object.create(null))=>{const{all:n=!1,dot:s=!1}=t,o=(Ds(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return o==="multipart/form-data"||o==="application/x-www-form-urlencoded"?o2(e,{all:n,dot:s}):{}};async function o2(e,t){if(!Ds(e)&&e.bodyCache.formData)return Wc(await e.bodyCache.formData,t);const n=Ds(e)?e.headers:e.raw.headers,s=await e.arrayBuffer(),i=i2(s,n.get("Content-Type")||"");Ds(e)||(e.bodyCache.formData=i);const r=await i;return r?Wc(r,t):{}}function Wc(e,t){const n=Object.create(null);return e.forEach((s,i)=>{t.all||i.endsWith("[]")?a2(n,i,s):n[i]=s}),t.dot&&Object.entries(n).forEach(([s,i])=>{s.includes(".")&&(c2(n,s,i),delete n[s])}),n}var a2=(e,t,n)=>{e[t]!==void 0?Array.isArray(e[t])?e[t].push(n):e[t]=[e[t],n]:t.endsWith("[]")?e[t]=[n]:e[t]=n},c2=(e,t,n)=>{if(/(?:^|\.)__proto__\./.test(t))return;let s=e;const i=t.split(".");i.forEach((r,o)=>{o===i.length-1?s[r]=n:((!s[r]||typeof s[r]!="object"||Array.isArray(s[r])||s[r]instanceof File)&&(s[r]=Object.create(null)),s=s[r])})},up=e=>{const t=e.split("/");return t[0]===""&&t.shift(),t},l2=e=>{const{groups:t,path:n}=d2(e),s=up(n);return u2(s,t)},d2=e=>{const t=[];return e=e.replace(/\{[^}]+\}/g,(n,s)=>{const i=`@${s}`;return t.push([i,n]),i}),{groups:t,path:e}},u2=(e,t)=>{for(let n=t.length-1;n>=0;n--){const[s]=t[n];for(let i=e.length-1;i>=0;i--)if(e[i].includes(s)){e[i]=e[i].replace(s,t[n][1]);break}}return e},Rs={},p2=(e,t)=>{if(e==="*")return"*";const n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){const s=`${e}#${t}`;return Rs[s]||(n[2]?Rs[s]=t&&t[0]!==":"&&t[0]!=="*"?[s,n[1],new RegExp(`^${n[2]}(?=/${t})`)]:[e,n[1],new RegExp(`^${n[2]}$`)]:Rs[s]=[e,n[1],!0]),Rs[s]}return null},Ao=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,n=>{try{return t(n)}catch{return n}})}},f2=e=>Ao(e,decodeURI),pp=e=>{const t=e.url,n=t.indexOf("/",t.indexOf(":")+4);let s=n;for(;s<t.length;s++){const i=t.charCodeAt(s);if(i===37){const r=t.indexOf("?",s),o=t.indexOf("#",s),a=r===-1?o===-1?void 0:o:o===-1?r:Math.min(r,o),c=t.slice(n,a);return f2(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(i===63||i===35)break}return t.slice(n,s)},h2=e=>{const t=pp(e);return t.length>1&&t.at(-1)==="/"?t.slice(0,-1):t},St=(e,t,...n)=>(n.length&&(t=St(t,...n)),`${e?.[0]==="/"?"":"/"}${e}${t==="/"?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),fp=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;const t=e.split("/"),n=[];let s="";return t.forEach(i=>{if(i!==""&&!/\:/.test(i))s+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){n.length===0&&s===""?n.push("/"):n.push(s);const r=i.replace("?","");s+="/"+r,n.push(s)}else s+="/"+i}),n.filter((i,r,o)=>o.indexOf(i)===r)},Zi=e=>/[%+]/.test(e)?(e.indexOf("+")!==-1&&(e=e.replace(/\+/g," ")),e.indexOf("%")!==-1?Ao(e,mp):e):e,hp=(e,t,n)=>{let s;if(!n&&t&&!/[%+]/.test(t)){let o=e.indexOf("?",8);if(o===-1)return;for(e.startsWith(t,o+1)||(o=e.indexOf(`&${t}`,o+1));o!==-1;){const a=e.charCodeAt(o+t.length+1);if(a===61){const c=o+t.length+2,l=e.indexOf("&",c);return Zi(e.slice(c,l===-1?void 0:l))}else if(a==38||isNaN(a))return"";o=e.indexOf(`&${t}`,o+1)}if(s=/[%+]/.test(e),!s)return}const i=Object.create(null);s??=/[%+]/.test(e);let r=e.indexOf("?",8);for(;r!==-1;){const o=e.indexOf("&",r+1);let a=e.indexOf("=",r);a>o&&o!==-1&&(a=-1);let c=e.slice(r+1,a===-1?o===-1?void 0:o:a);if(s&&(c=Zi(c)),r=o,c==="")continue;let l;a===-1?l="":(l=e.slice(a+1,o===-1?void 0:o),s&&(l=Zi(l))),n?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(l)):i[c]??=l}return t?i[t]:i},m2=hp,g2=(e,t)=>hp(e,t,!0),mp=decodeURIComponent,Uc=e=>Ao(e,mp),y2=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",n=[[]]){this.raw=e,this.path=t,this.#t=n,this.#e={}}param(e){return e?this.#n(e):this.#r()}#n(e){const t=this.#t[0][this.routeIndex][1][e],n=this.#s(t);return n&&/\%/.test(n)?Uc(n):n}#r(){const e={},t=Object.keys(this.#t[0][this.routeIndex][1]);for(const n of t){const s=this.#s(this.#t[0][this.routeIndex][1][n]);s!==void 0&&(e[n]=/\%/.test(s)?Uc(s):s)}return e}#s(e){return this.#t[1]?this.#t[1][e]:e}query(e){return m2(this.url,e)}queries(e){return g2(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;const t=Object.create(null);return this.raw.headers.forEach((n,s)=>{t[s]=n}),t}async parseBody(e){return r2(this,e)}#i=e=>{const{bodyCache:t,raw:n}=this,s=t[e];if(s)return s;const i=Object.keys(t)[0];return i?t[i].then(r=>(i==="json"&&(r=JSON.stringify(r)),new Response(r)[e]())):t[e]=n[e]()};json(){return this.#i("text").then(e=>JSON.parse(e))}text(){return this.#i("text")}arrayBuffer(){return this.#i("arrayBuffer")}bytes(){return this.#i("arrayBuffer").then(e=>new Uint8Array(e))}blob(){return this.#i("blob")}formData(){return this.#i("formData")}addValidatedData(e,t){this.#e[e]=t}valid(e){return this.#e[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[s2](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}},gp={Stringify:1},Io=async(e,t,n,s,i)=>{typeof e=="object"&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));const r=e.callbacks;return r?.length?(i?i[0]+=e:i=[e],Promise.all(r.map(a=>a({phase:t,buffer:i,context:s}))).then(a=>Promise.all(a.filter(Boolean).map(c=>Io(c,t,!1,s,i))).then(()=>i[0]))):Promise.resolve(e)},v2="text/plain; charset=UTF-8",Qi=(e,t)=>({"Content-Type":e,...t}),On=(e,t)=>new Response(e,t),b2=class{#e;#t;env={};#n;finalized=!1;error;#r;#s;#i;#o;#a;#c;#l;#d;#p;constructor(e,t){this.#e=e,t&&(this.#s=t.executionCtx,this.env=t.env,this.#c=t.notFoundHandler,this.#p=t.path,this.#d=t.matchResult)}get req(){return this.#t??=new y2(this.#e,this.#p,this.#d),this.#t}get event(){if(this.#s&&"respondWith"in this.#s)return this.#s;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#s)return this.#s;throw Error("This context has no ExecutionContext")}get res(){return this.#i||=On(null,{headers:this.#l??=new Headers})}set res(e){if(this.#i&&e){e=On(e.body,e);for(const[t,n]of this.#i.headers.entries())if(t!=="content-type")if(t==="set-cookie"){const s=this.#i.headers.getSetCookie();e.headers.delete("set-cookie");for(const i of s)e.headers.append("set-cookie",i)}else e.headers.set(t,n)}this.#i=e,this.finalized=!0}render=(...e)=>(this.#a??=t=>this.html(t),this.#a(...e));setLayout=e=>this.#o=e;getLayout=()=>this.#o;setRenderer=e=>{this.#a=e};header=(e,t,n)=>{this.finalized&&(this.#i=On(this.#i.body,this.#i));const s=this.#i?this.#i.headers:this.#l??=new Headers;t===void 0?s.delete(e):n?.append?s.append(e,t):s.set(e,t)};status=e=>{this.#r=e};set=(e,t)=>{this.#n??=new Map,this.#n.set(e,t)};get=e=>this.#n?this.#n.get(e):void 0;get var(){return this.#n?Object.fromEntries(this.#n):{}}#u(e,t,n){const s=this.#i?new Headers(this.#i.headers):this.#l??new Headers;if(typeof t=="object"&&"headers"in t){const r=t.headers instanceof Headers?t.headers:new Headers(t.headers);for(const[o,a]of r)o.toLowerCase()==="set-cookie"?s.append(o,a):s.set(o,a)}if(n)for(const[r,o]of Object.entries(n))if(typeof o=="string")s.set(r,o);else{s.delete(r);for(const a of o)s.append(r,a)}const i=typeof t=="number"?t:t?.status??this.#r;return On(e,{status:i,headers:s})}newResponse=(...e)=>this.#u(...e);body=(e,t,n)=>this.#u(e,t,n);text=(e,t,n)=>!this.#l&&!this.#r&&!t&&!n&&!this.finalized?new Response(e):this.#u(e,t,Qi(v2,n));json=(e,t,n)=>this.#u(JSON.stringify(e),t,Qi("application/json",n));html=(e,t,n)=>{const s=i=>this.#u(i,t,Qi("text/html; charset=UTF-8",n));return typeof e=="object"?Io(e,gp.Stringify,!1,{}).then(s):s(e)};redirect=(e,t)=>{const n=String(e);return this.header("Location",/[^\x00-\xFF]/.test(n)?encodeURI(n):n),this.newResponse(null,t??302)};notFound=()=>(this.#c??=()=>On(),this.#c(this))},pe="ALL",w2="all",k2=["get","post","put","delete","options","patch"],yp="Can not add a route since the matcher is already built.",vp=class extends Error{},S2="__COMPOSED_HANDLER",x2=e=>e.text("404 Not Found",404),Gc=(e,t)=>{if("getResponse"in e){const n=e.getResponse();return t.newResponse(n.body,n)}return console.error(e),t.text("Internal Server Error",500)},$2=class bp{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(t={}){[...k2,w2].forEach(r=>{this[r]=(o,...a)=>(typeof o=="string"?this.#e=o:this.#r(r,this.#e,o),a.forEach(c=>{this.#r(r,this.#e,c)}),this)}),this.on=(r,o,...a)=>{for(const c of[o].flat()){this.#e=c;for(const l of[r].flat())a.map(d=>{this.#r(l.toUpperCase(),this.#e,d)})}return this},this.use=(r,...o)=>(typeof r=="string"?this.#e=r:(this.#e="*",o.unshift(r)),o.forEach(a=>{this.#r(pe,this.#e,a)}),this);const{strict:s,...i}=t;Object.assign(this,i),this.getPath=s??!0?t.getPath??pp:h2}#t(){const t=new bp({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#n=this.#n,t.routes=this.routes,t}#n=x2;errorHandler=Gc;route(t,n){const s=this.basePath(t);return n.routes.map(i=>{let r;n.errorHandler===Gc?r=i.handler:(r=async(o,a)=>(await Hc([],n.errorHandler)(o,()=>i.handler(o,a))).res,r[S2]=i.handler),s.#r(i.method,i.path,r,i.basePath)}),this}basePath(t){const n=this.#t();return n._basePath=St(this._basePath,t),n}onError=t=>(this.errorHandler=t,this);notFound=t=>(this.#n=t,this);mount(t,n,s){let i,r;s&&(typeof s=="function"?r=s:(r=s.optionHandler,s.replaceRequest===!1?i=c=>c:i=s.replaceRequest));const o=r?c=>{const l=r(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};i||=(()=>{const c=St(this._basePath,t),l=c==="/"?0:c.length;return d=>{const u=new URL(d.url);return u.pathname=this.getPath(d).slice(l)||"/",new Request(u,d)}})();const a=async(c,l)=>{const d=await n(i(c.req.raw),...o(c));if(d)return d;await l()};return this.#r(pe,St(t,"*"),a),this}#r(t,n,s,i){t=t.toUpperCase(),n=St(this._basePath,n);const r={basePath:i!==void 0?St(this._basePath,i):this._basePath,path:n,method:t,handler:s};this.router.add(t,n,[s,r]),this.routes.push(r)}#s(t,n){if(t instanceof Error)return this.errorHandler(t,n);throw t}#i(t,n,s,i){if(i==="HEAD")return(async()=>new Response(null,await this.#i(t,n,s,"GET")))();const r=this.getPath(t,{env:s}),o=this.router.match(i,r),a=new b2(t,{path:r,matchResult:o,env:s,executionCtx:n,notFoundHandler:this.#n});if(o[0].length===1){let l;try{l=o[0][0][0][0](a,async()=>{a.res=await this.#n(a)})}catch(d){return this.#s(d,a)}return l instanceof Promise?l.then(d=>d||(a.finalized?a.res:this.#n(a))).catch(d=>this.#s(d,a)):l??this.#n(a)}const c=Hc(o[0],this.errorHandler,this.#n);return(async()=>{try{const l=await c(a);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#s(l,a)}})()}fetch=(t,...n)=>this.#i(t,n[1],n[0],t.method);request=(t,n,s,i)=>t instanceof Request?this.fetch(n?new Request(t,n):t,s,i):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${St("/",t)}`,n),s,i));fire=()=>{addEventListener("fetch",t=>{t.respondWith(this.#i(t.request,t,void 0,t.request.method))})}},wp=[];function E2(e,t){const n=this.buildAllMatchers(),s=((i,r)=>{const o=n[i]||n[pe],a=o[2][r];if(a)return a;const c=r.match(o[0]);if(!c)return[[],wp];const l=c.indexOf("",1);return[o[1][l],c]});return this.match=s,s(e,t)}var ei="[^/]+",Jn=".*",Kn="(?:|/.*)",Xt=Symbol(),C2=new Set(".\\+*[^]$()");function R2(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1||e===Jn||e===Kn?1:t===Jn||t===Kn?-1:e===ei?1:t===ei?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var j2=class Hr{#e;#t;#n=Object.create(null);insert(t,n,s,i,r){if(t.length===0){if(this.#e!==void 0)throw Xt;if(r)return;this.#e=n;return}const[o,...a]=t,c=o==="*"?a.length===0?["","",Jn]:["","",ei]:o==="/*"?["","",Kn]:o.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let l;if(c){const d=c[1];let u=c[2]||ei;if(d&&c[2]&&(u===".*"||(u=u.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(u))))throw Xt;if(l=this.#n[u],!l){if(Object.keys(this.#n).some(p=>p!==Jn&&p!==Kn))throw Xt;if(r)return;l=this.#n[u]=new Hr,d!==""&&(l.#t=i.varIndex++)}!r&&d!==""&&s.push([d,l.#t])}else if(l=this.#n[o],!l){if(Object.keys(this.#n).some(d=>d.length>1&&d!==Jn&&d!==Kn))throw Xt;if(r)return;l=this.#n[o]=new Hr}l.insert(a,n,s,i,r)}buildRegExpStr(){const n=Object.keys(this.#n).sort(R2).map(s=>{const i=this.#n[s];return(typeof i.#t=="number"?`(${s})@${i.#t}`:C2.has(s)?`\\${s}`:s)+i.buildRegExpStr()});return typeof this.#e=="number"&&n.unshift(`#${this.#e}`),n.length===0?"":n.length===1?n[0]:"(?:"+n.join("|")+")"}},T2=class{#e={varIndex:0};#t=new j2;insert(e,t,n){const s=[],i=[];for(let o=0;;){let a=!1;if(e=e.replace(/\{[^}]+\}/g,c=>{const l=`@\\${o}`;return i[o]=[l,c],o++,a=!0,l}),!a)break}const r=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let o=i.length-1;o>=0;o--){const[a]=i[o];for(let c=r.length-1;c>=0;c--)if(r[c].indexOf(a)!==-1){r[c]=r[c].replace(a,i[o][1]);break}}return this.#t.insert(r,t,s,this.#e,n),s}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let t=0;const n=[],s=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,r,o)=>r!==void 0?(n[++t]=Number(r),"$()"):(o!==void 0&&(s[Number(o)]=++t),"")),[new RegExp(`^${e}`),n,s]}},O2=[/^$/,[],Object.create(null)],kp=Object.create(null);function Sp(e){return kp[e]??=new RegExp(e==="*"?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(t,n)=>n?`\\${n}`:"(?:|/.*)")}$`)}function A2(){kp=Object.create(null)}function I2(e){const t=new T2,n=[];if(e.length===0)return O2;const s=e.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,d],[u,p])=>l?1:u?-1:d.length-p.length),i=Object.create(null);for(let l=0,d=-1,u=s.length;l<u;l++){const[p,f,h]=s[l];p?i[f]=[h.map(([b])=>[b,Object.create(null)]),wp]:d++;let m;try{m=t.insert(f,d,p)}catch(b){throw b===Xt?new vp(f):b}p||(n[d]=h.map(([b,$])=>{const v=Object.create(null);for($-=1;$>=0;$--){const[S,C]=m[$];v[S]=C}return[b,v]}))}const[r,o,a]=t.buildRegExp();for(let l=0,d=n.length;l<d;l++)for(let u=0,p=n[l].length;u<p;u++){const f=n[l][u]?.[1];if(!f)continue;const h=Object.keys(f);for(let m=0,b=h.length;m<b;m++)f[h[m]]=a[f[h[m]]]}const c=[];for(const l in o)c[l]=n[o[l]];return[r,c,i]}function Ut(e,t){if(e){for(const n of Object.keys(e).sort((s,i)=>i.length-s.length))if(Sp(n).test(t))return[...e[n]]}}var B2=class{name="RegExpRouter";#e;#t;constructor(){this.#e={[pe]:Object.create(null)},this.#t={[pe]:Object.create(null)}}add(e,t,n){const s=this.#e,i=this.#t;if(!s||!i)throw new Error(yp);s[e]||[s,i].forEach(a=>{a[e]=Object.create(null),Object.keys(a[pe]).forEach(c=>{a[e][c]=[...a[pe][c]]})}),t==="/*"&&(t="*");const r=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){const a=Sp(t);e===pe?Object.keys(s).forEach(c=>{s[c][t]||=Ut(s[c],t)||Ut(s[pe],t)||[]}):s[e][t]||=Ut(s[e],t)||Ut(s[pe],t)||[],Object.keys(s).forEach(c=>{(e===pe||e===c)&&Object.keys(s[c]).forEach(l=>{a.test(l)&&s[c][l].push([n,r])})}),Object.keys(i).forEach(c=>{(e===pe||e===c)&&Object.keys(i[c]).forEach(l=>a.test(l)&&i[c][l].push([n,r]))});return}const o=fp(t)||[t];for(let a=0,c=o.length;a<c;a++){const l=o[a];Object.keys(i).forEach(d=>{(e===pe||e===d)&&(i[d][l]||=[...Ut(s[d],l)||Ut(s[pe],l)||[]],i[d][l].push([n,r-c+a+1]))})}}match=E2;buildAllMatchers(){const e=Object.create(null);return Object.keys(this.#t).concat(Object.keys(this.#e)).forEach(t=>{e[t]||=this.#n(t)}),this.#e=this.#t=void 0,A2(),e}#n(e){const t=[];let n=e===pe;return[this.#e,this.#t].forEach(s=>{const i=s[e]?Object.keys(s[e]).map(r=>[r,s[e][r]]):[];i.length!==0?(n||=!0,t.push(...i)):e!==pe&&t.push(...Object.keys(s[pe]).map(r=>[r,s[pe][r]]))}),n?I2(t):null}},P2=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,t,n){if(!this.#t)throw new Error(yp);this.#t.push([e,t,n])}match(e,t){if(!this.#t)throw new Error("Fatal error");const n=this.#e,s=this.#t,i=n.length;let r=0,o;for(;r<i;r++){const a=n[r];try{for(let c=0,l=s.length;c<l;c++)a.add(...s[c]);o=a.match(e,t)}catch(c){if(c instanceof vp)continue;throw c}this.match=a.match.bind(a),this.#e=[a],this.#t=void 0;break}if(r===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,o}get activeRouter(){if(this.#t||this.#e.length!==1)throw new Error("No active router has been determined yet.");return this.#e[0]}},An=Object.create(null),N2=e=>{for(const t in e)return!0;return!1},D2=class xp{#e;#t;#n;#r=0;#s=An;constructor(t,n,s){if(this.#t=s||Object.create(null),this.#e=[],t&&n){const i=Object.create(null);i[t]={handler:n,possibleKeys:[],score:0},this.#e=[i]}this.#n=[]}insert(t,n,s){this.#r=++this.#r;let i=this;const r=l2(n),o=[];for(let a=0,c=r.length;a<c;a++){const l=r[a],d=r[a+1],u=p2(l,d),p=Array.isArray(u)?u[0]:l;if(p in i.#t){i=i.#t[p],u&&o.push(u[1]);continue}i.#t[p]=new xp,u&&(i.#n.push(u),o.push(u[1])),i=i.#t[p]}return i.#e.push({[t]:{handler:s,possibleKeys:o.filter((a,c,l)=>l.indexOf(a)===c),score:this.#r}}),i}#i(t,n,s,i,r){for(let o=0,a=n.#e.length;o<a;o++){const c=n.#e[o],l=c[s]||c[pe],d={};if(l!==void 0&&(l.params=Object.create(null),t.push(l),i!==An||r&&r!==An))for(let u=0,p=l.possibleKeys.length;u<p;u++){const f=l.possibleKeys[u],h=d[l.score];l.params[f]=r?.[f]&&!h?r[f]:i[f]??r?.[f],d[l.score]=!0}}}search(t,n){const s=[];this.#s=An;let r=[this];const o=up(n),a=[],c=o.length;let l=null;for(let d=0;d<c;d++){const u=o[d],p=d===c-1,f=[];for(let m=0,b=r.length;m<b;m++){const $=r[m],v=$.#t[u];v&&(v.#s=$.#s,p?(v.#t["*"]&&this.#i(s,v.#t["*"],t,$.#s),this.#i(s,v,t,$.#s)):f.push(v));for(let S=0,C=$.#n.length;S<C;S++){const P=$.#n[S],j=$.#s===An?{}:{...$.#s};if(P==="*"){const ie=$.#t["*"];ie&&(this.#i(s,ie,t,$.#s),ie.#s=j,f.push(ie));continue}const[B,L,D]=P;if(!u&&!(D instanceof RegExp))continue;const K=$.#t[B];if(D instanceof RegExp){if(l===null){l=new Array(c);let te=n[0]==="/"?1:0;for(let se=0;se<c;se++)l[se]=te,te+=o[se].length+1}const ie=n.substring(l[d]),ee=D.exec(ie);if(ee){if(j[L]=ee[0],this.#i(s,K,t,$.#s,j),ee[0].length===ie.length&&K.#t["*"]&&this.#i(s,K.#t["*"],t,$.#s,j),N2(K.#t)){K.#s=j;const te=ee[0].match(/\//)?.length??0;(a[te]||=[]).push(K)}continue}}(D===!0||D.test(u))&&(j[L]=u,p?(this.#i(s,K,t,j,$.#s),K.#t["*"]&&this.#i(s,K.#t["*"],t,j,$.#s)):(K.#s=j,f.push(K)))}}const h=a.shift();r=h?f.concat(h):f}return s.length>1&&s.sort((d,u)=>d.score-u.score),[s.map(({handler:d,params:u})=>[d,u])]}},M2=class{name="TrieRouter";#e;constructor(){this.#e=new D2}add(e,t,n){const s=fp(t);if(s){for(let i=0,r=s.length;i<r;i++)this.#e.insert(e,s[i],n);return}this.#e.insert(e,t,n)}match(e,t){return this.#e.search(e,t)}},L2=class extends $2{constructor(e={}){super(e),this.router=e.router??new P2({routers:[new B2,new M2]})}},_2=class{writer;encoder;writable;abortSubscribers=[];responseReadable;aborted=!1;closed=!1;constructor(e,t){this.writable=e,this.writer=e.getWriter(),this.encoder=new TextEncoder;const n=t.getReader();this.abortSubscribers.push(async()=>{await n.cancel()}),this.responseReadable=new ReadableStream({async pull(s){const{done:i,value:r}=await n.read();i?s.close():s.enqueue(r)},cancel:()=>{this.closed||this.abort()}})}async write(e){try{typeof e=="string"&&(e=this.encoder.encode(e)),await this.writer.write(e)}catch{}return this}async writeln(e){return await this.write(e+`
|
|
203
|
-
`),this}sleep(e){return new Promise(t=>setTimeout(t,e))}async close(){this.closed=!0;try{await this.writer.close()}catch{}}async pipe(e){this.writer.releaseLock()
|
|
204
|
-
`);for(const
|
|
200
|
+
`)},x$=e=>{const t=e.socket.encrypted?"https":"http",n=new URL(e.url??"/",`${t}://${e.headers.host??"localhost"}`),s=new Headers;for(const r in e.headers){const i=e.headers[r];i&&s.append(r,Array.isArray(i)?i[0]:i)}return new Request(n,{headers:s})},$$=e=>{const{server:t,fetchCallback:n,wss:s}=e,r=new Map;s.on("connection",(a,c)=>{const l=r.get(c);l&&(l.resolve(a),r.delete(c))});const i=a=>{const c=r.get(a);c&&(r.delete(a),c.reject(new Error("WebSocket handshake aborted")))},o=(a,c)=>new Promise((l,d)=>{r.set(a,{resolve:l,reject:d,connectionSymbol:c})});t.on("upgrade",async(a,c,l)=>{if(a.headers.upgrade?.toLowerCase()!=="websocket")return;const d={incoming:a,outgoing:void 0,wss:s,[k$]:o};let u=400,p;try{const v=await n(x$(a),d);v instanceof Response&&(u=v.status,p=v.headers)}catch{t.listenerCount("upgrade")===1&&zc(c,500);return}const f=r.get(a);if(!f||f.connectionSymbol!==d[w$]){i(a),t.listenerCount("upgrade")===1&&zc(c,u,p);return}const h=v=>{yp(v,p)},m=()=>i(a);c.once("close",m),s.on("headers",h);try{s.handleUpgrade(a,c,l,v=>{c.off("close",m),s.emit("connection",v,a)})}finally{s.off("headers",h)}}),t.on("close",()=>{s.close()})},E$=e=>{const t=e.fetch,n=b$(t,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming}),s=(e.createServer||yh)(e.serverOptions||{},n);if(e.websocket&&e.websocket.server){if(e.websocket.server.options.noServer!==!0)throw new Error("WebSocket server must be created with { noServer: true } option");$$({server:s,fetchCallback:t,wss:e.websocket.server})}return s},C$=(e,t)=>{const n=E$(e);return n.listen(e?.port??3e3,e.hostname,()=>{n.address()}),n};var Jc=(e,t,n)=>(s,r)=>{let i=-1;return o(0);async function o(a){if(a<=i)throw new Error("next() called multiple times");i=a;let c,l=!1,d;if(e[a]?(d=e[a][0][0],s.req.routeIndex=a):d=a===e.length&&r||void 0,d)try{c=await d(s,()=>o(a+1))}catch(u){if(u instanceof Error&&t)s.error=u,c=await t(u,s),l=!0;else throw u}else s.finalized===!1&&n&&(c=await n(s));return c&&(s.finalized===!1||l)&&(s.res=c),s}},R$=Symbol(),j$=(e,t)=>new Response(e,{headers:{"Content-Type":t.replace(/^[^;]+/,s=>s.toLowerCase())}}).formData(),Ms=e=>"headers"in e,T$=async(e,t=Object.create(null))=>{const{all:n=!1,dot:s=!1}=t,o=(Ms(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return o==="multipart/form-data"||o==="application/x-www-form-urlencoded"?O$(e,{all:n,dot:s}):{}};async function O$(e,t){if(!Ms(e)&&e.bodyCache.formData)return qc(await e.bodyCache.formData,t);const n=Ms(e)?e.headers:e.raw.headers,s=await e.arrayBuffer(),r=j$(s,n.get("Content-Type")||"");Ms(e)||(e.bodyCache.formData=r);const i=await r;return i?qc(i,t):{}}function qc(e,t){const n=Object.create(null);return e.forEach((s,r)=>{t.all||r.endsWith("[]")?A$(n,r,s):n[r]=s}),t.dot&&Object.entries(n).forEach(([s,r])=>{s.includes(".")&&(I$(n,s,r),delete n[s])}),n}var A$=(e,t,n)=>{e[t]!==void 0?Array.isArray(e[t])?e[t].push(n):e[t]=[e[t],n]:t.endsWith("[]")?e[t]=[n]:e[t]=n},I$=(e,t,n)=>{if(/(?:^|\.)__proto__\./.test(t))return;let s=e;const r=t.split(".");r.forEach((i,o)=>{o===r.length-1?s[i]=n:((!s[i]||typeof s[i]!="object"||Array.isArray(s[i])||s[i]instanceof File)&&(s[i]=Object.create(null)),s=s[i])})},vp=e=>{const t=e.split("/");return t[0]===""&&t.shift(),t},B$=e=>{const{groups:t,path:n}=P$(e),s=vp(n);return N$(s,t)},P$=e=>{const t=[];return e=e.replace(/\{[^}]+\}/g,(n,s)=>{const r=`@${s}`;return t.push([r,n]),r}),{groups:t,path:e}},N$=(e,t)=>{for(let n=t.length-1;n>=0;n--){const[s]=t[n];for(let r=e.length-1;r>=0;r--)if(e[r].includes(s)){e[r]=e[r].replace(s,t[n][1]);break}}return e},Rs={},D$=(e,t)=>{if(e==="*")return"*";const n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){const s=`${e}#${t}`;return Rs[s]||(n[2]?Rs[s]=t&&t[0]!==":"&&t[0]!=="*"?[s,n[1],new RegExp(`^${n[2]}(?=/${t})`)]:[e,n[1],new RegExp(`^${n[2]}$`)]:Rs[s]=[e,n[1],!0]),Rs[s]}return null},bp=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,n=>{try{return t(n)}catch{return n}})}},M$=e=>bp(e,decodeURI),wp=e=>{const t=e.url,n=t.indexOf("/",t.indexOf(":")+4);let s=n;for(;s<t.length;s++){const r=t.charCodeAt(s);if(r===37){const i=t.indexOf("?",s),o=t.indexOf("#",s),a=i===-1?o===-1?void 0:o:o===-1?i:Math.min(i,o),c=t.slice(n,a);return M$(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(r===63||r===35)break}return t.slice(n,s)},L$=e=>{const t=wp(e);return t.length>1&&t.at(-1)==="/"?t.slice(0,-1):t},St=(e,t,...n)=>(n.length&&(t=St(t,...n)),`${e?.[0]==="/"?"":"/"}${e}${t==="/"?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),kp=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;const t=e.split("/"),n=[];let s="";return t.forEach(r=>{if(r!==""&&!/\:/.test(r))s+="/"+r;else if(/\:/.test(r))if(/\?/.test(r)){n.length===0&&s===""?n.push("/"):n.push(s);const i=r.replace("?","");s+="/"+i,n.push(s)}else s+="/"+r}),n.filter((r,i,o)=>o.indexOf(r)===i)},Ui=e=>e.indexOf("%")!==-1?bp(e,V$):e,ei=e=>(e.indexOf("+")!==-1&&(e=e.replace(/\+/g," ")),Ui(e)),Sp=(e,t,n)=>{let s;if(!n&&t&&t.indexOf("%")===-1&&t.indexOf("+")===-1){let o=e.indexOf("?",8);if(o===-1)return;for(e.startsWith(t,o+1)||(o=e.indexOf(`&${t}`,o+1));o!==-1;){const a=e.charCodeAt(o+t.length+1);if(a===61){const c=o+t.length+2,l=e.indexOf("&",c);return ei(e.slice(c,l===-1?void 0:l))}else if(a==38||isNaN(a))return"";o=e.indexOf(`&${t}`,o+1)}if(s=/[%+]/.test(e),!s)return}const r=Object.create(null);s??=/[%+]/.test(e);let i=e.indexOf("?",8);for(;i!==-1;){const o=e.indexOf("&",i+1);let a=e.indexOf("=",i);a>o&&o!==-1&&(a=-1);let c=e.slice(i+1,a===-1?o===-1?void 0:o:a);if(s&&(c=ei(c)),i=o,c==="")continue;let l;a===-1?l="":(l=e.slice(a+1,o===-1?void 0:o),s&&(l=ei(l))),n?(r[c]&&Array.isArray(r[c])||(r[c]=[]),r[c].push(l)):r[c]??=l}return t?r[t]:r},_$=Sp,F$=(e,t)=>Sp(e,t,!0),V$=decodeURIComponent,W$=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",n=[[]]){this.raw=e,this.path=t,this.#t=n}param(e){return e?this.#n(e):this.#i()}#n(e){const t=this.#t[0][this.routeIndex][1][e],n=this.#s(t);return n&&Ui(n)}#i(){const e={},t=Object.keys(this.#t[0][this.routeIndex][1]);for(const n of t){const s=this.#s(this.#t[0][this.routeIndex][1][n]);s!==void 0&&(e[n]=Ui(s))}return e}#s(e){return this.#t[1]?this.#t[1][e]:e}query(e){return _$(this.url,e)}queries(e){return F$(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;const t=Object.create(null);return this.raw.headers.forEach((n,s)=>{t[s]=n}),t}async parseBody(e){return T$(this,e)}#r=e=>{const{bodyCache:t,raw:n}=this,s=t[e];if(s)return s;for(const r in t)return t[r].then(i=>(r==="json"&&(i=JSON.stringify(i)),new Response(i)[e]()));return t[e]=n[e]()};json(){return this.#r("text").then(e=>JSON.parse(e))}text(){return this.#r("text")}arrayBuffer(){return this.#r("arrayBuffer")}bytes(){return this.#r("arrayBuffer").then(e=>new Uint8Array(e))}blob(){return this.#r("blob")}formData(){return this.#r("formData")}addValidatedData(e,t){(this.#e??={})[e]=t}valid(e){return this.#e?.[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[R$](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}},xp={Stringify:1},Po=async(e,t,n,s,r)=>{typeof e=="object"&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));const i=e.callbacks;return i?.length?(r?r[0]+=e:r=[e],Promise.all(i.map(a=>a({phase:t,buffer:r,context:s}))).then(a=>Promise.all(a.filter(Boolean).map(c=>Po(c,t,!1,s,r))).then(()=>r[0]))):Promise.resolve(e)},H$="text/plain; charset=UTF-8",ti=(e,t)=>({"Content-Type":e,...t}),On=(e,t)=>new Response(e,t),U$=class{#e;#t;env={};#n;finalized=!1;error;#i;#s;#r;#o;#a;#c;#l;#d;#p;constructor(e,t){this.#e=e,t&&(this.#s=t.executionCtx,this.env=t.env,this.#c=t.notFoundHandler,this.#p=t.path,this.#d=t.matchResult)}get req(){return this.#t??=new W$(this.#e,this.#p,this.#d),this.#t}get event(){if(this.#s&&"respondWith"in this.#s)return this.#s;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#s)return this.#s;throw Error("This context has no ExecutionContext")}get res(){return this.#r||=On(null,{headers:this.#l??=new Headers})}set res(e){if(this.#r&&e){e=On(e.body,e);for(const[t,n]of this.#r.headers.entries())if(t!=="content-type")if(t==="set-cookie"){const s=this.#r.headers.getSetCookie();e.headers.delete("set-cookie");for(const r of s)e.headers.append("set-cookie",r)}else e.headers.set(t,n)}this.#r=e,this.finalized=!0}render=(...e)=>(this.#a??=t=>this.html(t),this.#a(...e));setLayout=e=>this.#o=e;getLayout=()=>this.#o;setRenderer=e=>{this.#a=e};header=(e,t,n)=>{this.finalized&&(this.#r=On(this.#r.body,this.#r));const s=this.#r?this.#r.headers:this.#l??=new Headers;t===void 0?s.delete(e):n?.append?s.append(e,t):s.set(e,t)};status=e=>{this.#i=e};set=(e,t)=>{this.#n??=new Map,this.#n.set(e,t)};get=e=>this.#n?this.#n.get(e):void 0;get var(){return this.#n?Object.fromEntries(this.#n):{}}#u(e,t,n){let s=this.#r?new Headers(this.#r.headers):this.#l;if(typeof t=="object"&&t.headers){s??=new Headers;for(const[i,o]of new Headers(t.headers))i==="set-cookie"?s.append(i,o):s.set(i,o)}if(n){if(!s){let i=0;for(const o in n)if(++i>1||typeof n[o]!="string"){s=new Headers;break}}if(s)for(const i in n){const o=n[i];if(typeof o=="string")s.set(i,o);else{s.delete(i);for(const a of o)s.append(i,a)}}}const r=typeof t=="number"?t:t?.status??this.#i;return On(e,{status:r,headers:s??n})}newResponse=(...e)=>this.#u(...e);body=(e,t,n)=>this.#u(e,t,n);text=(e,t,n)=>!this.#l&&!this.#i&&!t&&!n&&!this.finalized?new Response(e):this.#u(e,t,ti(H$,n));json=(e,t,n)=>this.#u(JSON.stringify(e),t,ti("application/json",n));html=(e,t,n)=>{const s=r=>this.#u(r,t,ti("text/html; charset=UTF-8",n));return typeof e=="object"?Po(e,xp.Stringify,!1,{}).then(s):s(e)};redirect=(e,t)=>{const n=String(e);return this.header("Location",/[^\x00-\xFF]/.test(n)?encodeURI(n):n),this.newResponse(null,t??302)};notFound=()=>(this.#c??=()=>On(),this.#c(this))},ge="ALL",G$="all",z$=["get","post","put","delete","options","patch","query"],$p="Can not add a route since the matcher is already built.",Ep=class extends Error{},J$="__COMPOSED_HANDLER",q$=e=>e.text("404 Not Found",404),Kc=(e,t)=>{if("getResponse"in e){const n=e.getResponse();return t.newResponse(n.body,n)}return console.error(e),t.text("Internal Server Error",500)},K$=class Cp{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(t={}){[...z$,G$].forEach(i=>{this[i]=(o,...a)=>(typeof o=="string"?this.#e=o:this.#i(i,this.#e,o),a.forEach(c=>{this.#i(i,this.#e,c)}),this)}),this.on=(i,o,...a)=>{for(const c of[o].flat()){this.#e=c;for(const l of[i].flat())a.map(d=>{this.#i(l.toUpperCase(),this.#e,d)})}return this},this.use=(i,...o)=>(typeof i=="string"?this.#e=i:(this.#e="*",o.unshift(i)),o.forEach(a=>{this.#i(ge,this.#e,a)}),this);const{strict:s,...r}=t;Object.assign(this,r),this.getPath=s??!0?t.getPath??wp:L$}#t(){const t=new Cp({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#n=this.#n,t.routes=this.routes,t}#n=q$;errorHandler=Kc;route(t,n){const s=this.basePath(t);return n.routes.map(r=>{let i;n.errorHandler===Kc?i=r.handler:(i=async(o,a)=>(await Jc([],n.errorHandler)(o,()=>r.handler(o,a))).res,i[J$]=r.handler),s.#i(r.method,r.path,i,r.basePath)}),this}basePath(t){const n=this.#t();return n._basePath=St(this._basePath,t),n}onError=t=>(this.errorHandler=t,this);notFound=t=>(this.#n=t,this);mount(t,n,s){let r,i;s&&(typeof s=="function"?i=s:(i=s.optionHandler,s.replaceRequest===!1?r=c=>c:r=s.replaceRequest));const o=i?c=>{const l=i(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};r||=(()=>{const c=St(this._basePath,t),l=c==="/"?0:c.length;return d=>{const u=new URL(d.url);return u.pathname=this.getPath(d).slice(l)||"/",new Request(u,d)}})();const a=async(c,l)=>{const d=await n(r(c.req.raw),...o(c));if(d)return d;await l()};return this.#i(ge,St(t,"*"),a),this}#i(t,n,s,r){t=t.toUpperCase(),n=St(this._basePath,n);const i={basePath:r!==void 0?St(this._basePath,r):this._basePath,path:n,method:t,handler:s};this.router.add(t,n,[s,i]),this.routes.push(i)}#s(t,n){if(t instanceof Error)return this.errorHandler(t,n);throw t}#r(t,n,s,r){if(r==="HEAD")return(async()=>new Response(null,await this.#r(t,n,s,"GET")))();const i=this.getPath(t,{env:s}),o=this.router.match(r,i),a=new U$(t,{path:i,matchResult:o,env:s,executionCtx:n,notFoundHandler:this.#n});if(o[0].length===1){let l;try{l=o[0][0][0][0](a,async()=>{a.res=await this.#n(a)})}catch(d){return this.#s(d,a)}return l instanceof Promise?l.then(d=>d||(a.finalized?a.res:this.#n(a))).catch(d=>this.#s(d,a)):l??this.#n(a)}const c=Jc(o[0],this.errorHandler,this.#n);return(async()=>{try{const l=await c(a);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#s(l,a)}})()}fetch=(t,...n)=>this.#r(t,n[1],n[0],t.method);request=(t,n,s,r)=>t instanceof Request?this.fetch(n?new Request(t,n):t,s,r):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${St("/",t)}`,n),s,r));fire=()=>{addEventListener("fetch",t=>{t.respondWith(this.#r(t.request,t,void 0,t.request.method))})}},Rp=[];function Y$(e,t){const n=this.buildAllMatchers(),s=((r,i)=>{const o=n[r]||n[ge],a=o[2][i];if(a)return a;const c=i.match(o[0]);if(!c)return[[],Rp];const l=c.indexOf("",1);return[o[1][l],c]});return this.match=s,s(e,t)}var er="[^/]+",tn=".*",Et="(?:|/.*)",xt=Symbol(),Yc=new Set(".\\+*[^]$()");function X$(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1?1:e===tn||e===Et?t===Et?-1:1:t===tn||t===Et?-1:e===er?1:t===er?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var Z$=class Gi{#e;#t;#n=Object.create(null);insert(t,n,s,r,i){let o=this;for(let a=0,c=t.length;a<c;a++){const l=t[a],d=l.length===1?l==="*"?a===c-1?["","",tn]:["","",er]:null:l==="/*"?["","",Et]:l.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(d){const p=d[1];let f=d[2]||er;if(p&&d[2]&&(f===".*"||(f=f.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(f))||f.length===1&&Yc.has(f)))throw xt;if(u=o.#n[f],!u){if(f!==tn&&f!==Et){for(const h in o.#n)if((f.length>1||h.length>1)&&h!==tn&&h!==Et)throw xt}u=o.#n[f]=new Gi}p!==""&&(u.#t??=r.varIndex++,s.push([p,u.#t]))}else if(u=o.#n[l],!u){for(const p in o.#n)if(p.length>1&&p!==tn&&p!==Et)throw xt;u=o.#n[l]=new Gi}o=u}if(o.#e!==void 0)throw xt;o.#e=i?-1:n}buildRegExpStr(){const n=Object.keys(this.#n).sort(X$).map(s=>{const r=this.#n[s],i=r.buildRegExpStr();return i===""?"":(typeof r.#t=="number"?`(${s})@${r.#t}`:Yc.has(s)?`\\${s}`:s)+i}).filter(Boolean);return typeof this.#e=="number"&&this.#e!==-1&&n.unshift(`#${this.#e}`),n.length===0?"":n.length===1?n[0]:"(?:"+n.join("|")+")"}},Xc=class{#e={varIndex:0};#t=new Z$;#n=0;paths=Object.create(null);insert(e,t){if(t){this.#t.insert(e.split(""),0,[],this.#e,!0);return}const n=[],s=[];let r=e;for(let o=0;;){let a=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const l=`@\\${o}`;return s[o]=[l,c],o++,a=!0,l}),!a)break}const i=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let o=s.length-1;o>=0;o--){const[a]=s[o];for(let c=i.length-1;c>=0;c--)if(i[c].indexOf(a)!==-1){i[c]=i[c].replace(a,s[o][1]);break}}this.#t.insert(i,this.#n,n,this.#e,!1),this.paths[e]=[this.#n++,n]}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let t=0;const n=[],s=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(r,i,o)=>i!==void 0?(n[++t]=Number(i),"$()"):(o!==void 0&&(s[Number(o)]=++t),"")),[new RegExp(`^${e}`),n,s]}},jp=Object.create(null);function Tp(e){return jp[e]??=new RegExp(e==="*"?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(t,n)=>n?`\\${n}`:"(?:|/.*)")}$`)}function Q$(){jp=Object.create(null)}function js(e,t){if(e){for(const n of Object.keys(e).sort((s,r)=>r.length-s.length))if(Tp(n).test(t))return[...e[n]]}}var eE=class{name="RegExpRouter";#e;#t;#n;constructor(){this.#e={[ge]:Object.create(null)},this.#t={[ge]:Object.create(null)},this.#n={[ge]:new Xc}}#i(e,t){try{this.#n[e].insert(t,!/\*|\/:/.test(t))}catch(n){throw n===xt?new Ep(t):n}}add(e,t,n){const s=this.#e,r=this.#t;if(!s||!r)throw new Error($p);s[e]||(this.#n[e]=new Xc,[s,r].forEach(a=>{a[e]=Object.create(null),Object.keys(a[ge]).forEach(c=>{a[e][c]=[...a[ge][c]],this.#i(e,c)})})),t==="/*"&&(t="*");const i=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){const a=Tp(t);Object.keys(s).forEach(c=>{(e===ge||e===c)&&!s[c][t]&&(this.#i(c,t),s[c][t]=js(s[c],t)||js(s[ge],t)||[])}),Object.keys(s).forEach(c=>{(e===ge||e===c)&&Object.keys(s[c]).forEach(l=>{a.test(l)&&s[c][l].push([n,i])})}),Object.keys(r).forEach(c=>{(e===ge||e===c)&&Object.keys(r[c]).forEach(l=>a.test(l)&&r[c][l].push([n,i]))});return}const o=kp(t)||[t];for(let a=0,c=o.length;a<c;a++){const l=o[a];Object.keys(r).forEach(d=>{(e===ge||e===d)&&(r[d][l]||(this.#i(d,l),r[d][l]=[...js(s[d],l)||js(s[ge],l)||[]]),r[d][l].push([n,i-c+a+1]))})}}match=Y$;buildAllMatchers(){const e=Object.create(null);return Object.keys(this.#t).concat(Object.keys(this.#e)).forEach(t=>{e[t]||=this.#s(t)}),this.#e=this.#t=this.#n=void 0,Q$(),e}#s(e){const t=this.#e[e],n=this.#t[e],s=this.#n[e],r=Object.create(null),i=[];[t,n].forEach(d=>{for(const u in d){const p=d[u],f=s.paths[u];if(!f){r[u]=[p.map(([m])=>[m,Object.create(null)]),Rp];continue}const h=f[1];i[f[0]]=p.map(([m,v])=>{const $=Object.create(null);for(v-=1;v>=0;v--){const[b,S]=h[v];$[b]=S}return[m,$]})}});const[o,a,c]=s.buildRegExp();for(let d=0,u=i.length;d<u;d++)for(let p=0,f=i[d].length;p<f;p++){const h=i[d][p]?.[1];if(!h)continue;const m=Object.keys(h);for(let v=0,$=m.length;v<$;v++)h[m[v]]=c[h[m[v]]]}const l=[];for(const d in a)l[d]=i[a[d]];return[o,l,r]}},tE=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,t,n){if(!this.#t)throw new Error($p);this.#t.push([e,t,n])}match(e,t){if(!this.#t)throw new Error("Fatal error");const n=this.#e,s=this.#t,r=n.length;let i=0,o;for(;i<r;i++){const a=n[i];try{for(let c=0,l=s.length;c<l;c++)a.add(...s[c]);o=a.match(e,t)}catch(c){if(c instanceof Ep)continue;throw c}this.match=a.match.bind(a),this.#e=[a],this.#t=void 0;break}if(i===r)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,o}get activeRouter(){if(this.#t||this.#e.length!==1)throw new Error("No active router has been determined yet.");return this.#e[0]}},An=Object.create(null),nE=e=>{for(const t in e)return!0;return!1},sE=class Op{#e;#t;#n;#i=0;#s=An;constructor(t,n,s){if(this.#t=s||Object.create(null),this.#e=[],t&&n){const r=Object.create(null);r[t]={handler:n,possibleKeys:[],score:0},this.#e=[r]}this.#n=[]}insert(t,n,s){this.#i=++this.#i;let r=this;const i=B$(n),o=[];for(let a=0,c=i.length;a<c;a++){const l=i[a],d=i[a+1],u=D$(l,d),p=Array.isArray(u)?u[0]:l;if(p in r.#t){r=r.#t[p],u&&o.push(u[1]);continue}r.#t[p]=new Op,u&&(r.#n.push(u),o.push(u[1])),r=r.#t[p]}return r.#e.push({[t]:{handler:s,possibleKeys:o.filter((a,c,l)=>l.indexOf(a)===c),score:this.#i}}),r}#r(t,n,s,r,i){for(let o=0,a=n.#e.length;o<a;o++){const c=n.#e[o],l=c[s]||c[ge],d={};if(l!==void 0&&(l.params=Object.create(null),t.push(l),r!==An||i&&i!==An))for(let u=0,p=l.possibleKeys.length;u<p;u++){const f=l.possibleKeys[u],h=d[l.score];l.params[f]=i?.[f]&&!h?i[f]:r[f]??i?.[f],d[l.score]=!0}}}search(t,n){const s=[];this.#s=An;let i=[this];const o=vp(n),a=[],c=o.length;let l=null;for(let d=0;d<c;d++){const u=o[d],p=d===c-1,f=[];for(let m=0,v=i.length;m<v;m++){const $=i[m],b=$.#t[u];b&&(b.#s=$.#s,p?(b.#t["*"]&&this.#r(s,b.#t["*"],t,$.#s),this.#r(s,b,t,$.#s)):f.push(b));for(let S=0,C=$.#n.length;S<C;S++){const P=$.#n[S],T=$.#s===An?{}:{...$.#s};if(P==="*"){const re=$.#t["*"];re&&(this.#r(s,re,t,$.#s),re.#s=T,f.push(re));continue}const[N,_,F]=P;if(!u&&!(F instanceof RegExp))continue;const Y=$.#t[N];if(F instanceof RegExp){if(l===null){l=new Array(c);let te=n[0]==="/"?1:0;for(let se=0;se<c;se++)l[se]=te,te+=o[se].length+1}const re=n.substring(l[d]),ee=F.exec(re);if(ee){if(T[_]=ee[0],this.#r(s,Y,t,$.#s,T),ee[0].length===re.length&&Y.#t["*"]&&this.#r(s,Y.#t["*"],t,$.#s,T),nE(Y.#t)){Y.#s=T;const te=ee[0].match(/\//g)?.length??0;(a[te]||=[]).push(Y)}continue}}(F===!0||F.test(u))&&(T[_]=u,p?(this.#r(s,Y,t,T,$.#s),Y.#t["*"]&&this.#r(s,Y.#t["*"],t,T,$.#s)):(Y.#s=T,f.push(Y)))}}const h=a.shift();i=h?f.concat(h):f}return s.length>1&&s.sort((d,u)=>d.score-u.score),[s.map(({handler:d,params:u})=>[d,u])]}},rE=class{name="TrieRouter";#e;constructor(){this.#e=new sE}add(e,t,n){const s=kp(t);if(s){for(let r=0,i=s.length;r<i;r++)this.#e.insert(e,s[r],n);return}this.#e.insert(e,t,n)}match(e,t){return this.#e.search(e,t)}},iE=class extends K${constructor(e={}){super(e),this.router=e.router??new tE({routers:[new eE,new rE]})}},oE=class{writer;encoder;writable;abortSubscribers=[];responseReadable;aborted=!1;closed=!1;constructor(e,t){this.writable=e,this.writer=e.getWriter(),this.encoder=new TextEncoder;const n=t.getReader();this.abortSubscribers.push(async()=>{await n.cancel()}),this.responseReadable=new ReadableStream({async pull(s){const{done:r,value:i}=await n.read();r?s.close():s.enqueue(i)},cancel:()=>{this.closed||this.abort()}})}async write(e){try{typeof e=="string"&&(e=this.encoder.encode(e)),await this.writer.write(e)}catch{}return this}async writeln(e){return await this.write(e+`
|
|
201
|
+
`),this}sleep(e){return new Promise(t=>setTimeout(t,e))}async close(){this.closed=!0;try{await this.writer.close()}catch{}}async pipe(e){this.writer.releaseLock();try{await e.pipeTo(this.writable,{preventClose:!0,preventAbort:!0})}finally{this.writer=this.writable.getWriter()}}onAbort(e){this.abortSubscribers.push(e)}abort(){this.aborted||(this.aborted=!0,this.abortSubscribers.forEach(e=>e()))}},Ap=()=>{const e=typeof Bun<"u"?Bun.version:void 0;if(e===void 0)return!1;const t=e.startsWith("1.1")||e.startsWith("1.0")||e.startsWith("0.");return Ap=()=>t,t},aE=class extends oE{constructor(e,t){super(e,t)}async writeSSE(e){const n=(await Po(e.data,xp.Stringify,!1,{})).split(/\r\n|\r|\n/).map(r=>`data: ${r}`).join(`
|
|
202
|
+
`);for(const r of["event","id"]){const i=e[r];if(i&&/[\r\n]/.test(i))throw new Error(`${r} must not contain "\\r" or "\\n"`)}const s=[e.event&&`event: ${e.event}`,n,e.id!==void 0&&`id: ${e.id}`,e.retry!==void 0&&`retry: ${e.retry}`].filter(Boolean).join(`
|
|
205
203
|
`)+`
|
|
206
204
|
|
|
207
|
-
`;await this.write(s)}},
|
|
205
|
+
`;await this.write(s)}},cE=async(e,t,n)=>{try{await t(e)}catch(s){console.error(s)}finally{e.close()}},lE=new WeakMap,dE=(e,t,n)=>{const{readable:s,writable:r}=new TransformStream,i=new aE(r,s);return Ap()&&e.req.raw.signal.addEventListener("abort",()=>{i.closed||i.abort()}),lE.set(i.responseReadable,e),e.header("Transfer-Encoding","chunked"),e.header("Content-Type","text/event-stream"),e.header("Cache-Control","no-cache"),e.header("Connection","keep-alive"),cE(i,t),e.newResponse(i.responseReadable)};const ln=(1n<<128n)-1n,z=(1n<<64n)-1n,ss=(1n<<32n)-1n,Ip=0x9E3779B1n,Bp=0x85EBCA77n,uE=0xC2B2AE3Dn,dt=0x9E3779B185EBCA87n,Nt=0xC2B2AE3D27D4EB4Fn,Pp=0x165667B19E3779F9n,No=0x85EBCA77C2B2AE63n,pE=0x27D4EB2F165667C5n,fE=0x165667919E3779F9n,hE=0x9FB21C651E98DF25n,Ue=64,Np=Ue/8,mE=8,Ce=Buffer.from("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e","hex"),gE=e=>{let t=e&z;return t=(t&0x00000000FFFFFFFFn)<<32n|(t&0xFFFFFFFF00000000n)>>32n,t=(t&0x0000FFFF0000FFFFn)<<16n|(t&0xFFFF0000FFFF0000n)>>16n,t=(t&0x00FF00FF00FF00FFn)<<8n|(t&0xFF00FF00FF00FF00n)>>8n,t&z},Dp=e=>{let t=e;return t=(t&0x0000FFFFn)<<16n|(t&0xFFFF0000n)>>16n,t=(t&0x00FF00FFn)<<8n|(t&0xFF00FF00n)>>8n,t},yE=(e,t)=>(e&ss)*(t&ss)&z,vE=(e,t)=>(e<<t|e>>32n-t)&ss,zi=(e,t)=>e^e>>t,Ji=e=>~e+1n&z,Mp=(e,t)=>{const n=e*t&ln;return n&z^n>>64n},Me=e=>{let t=e;return t^=t>>37n,t=t*fE&z,t^=t>>32n,t},tr=e=>{let t=e;return t^=t>>33n,t=t*Nt&z,t^=t>>29n,t=t*Pp&z,t^=t>>32n,t},Lp=(e,t,n,s=0,r=0)=>{for(let i=0;i<Np;i++){const o=t.readBigUInt64LE(s+i*8),a=o^n.readBigUInt64LE(r+i*8);e[i^1]+=o,e[i]+=yE(a,a>>32n)}return e},Zc=(e,t,n,s,r=0)=>{for(let i=0;i<s;i++)Lp(e,t,n,r+i*Ue,i*8);return e},bE=(e,t,n=0)=>{for(let s=0;s<Np;s++){const r=t.readBigUInt64LE(n+s*8);let i=e[s];i=zi(i,47n),i^=r,i*=Ip,e[s]=i&z}return e},Ts=(e,t,n,s)=>Mp(e[t]^n.readBigUInt64LE(s),e[t+1]^n.readBigUInt64LE(s+mE)),Qc=(e,t,n,s)=>{let r=s;return r+=Ts(e,0,t,n+0),r+=Ts(e,2,t,n+16),r+=Ts(e,4,t,n+32),r+=Ts(e,6,t,n+48),Me(r&z)},wE=(e,t,n)=>{const s=Math.floor((n.byteLength-Ue)/8),r=Ue*s,i=Math.floor((t.byteLength-1)/r);for(let a=0;a<i;a++)Zc(e,t,n,s,a*r),bE(e,n,n.byteLength-Ue);const o=Math.floor((t.byteLength-1-r*i)/Ue);return Zc(e,t,n,o,i*r),Lp(e,t,n,t.byteLength-Ue,n.byteLength-Ue-7),e},kE=e=>{const t=Buffer.from(Ce),n=Ce.byteLength>>4;for(let s=0;s<n;s++){const r=t.readBigUInt64LE(s*16)+e&z,i=t.readBigUInt64LE(s*16+8)-e&z;t.writeBigUInt64LE(r,s*16),t.writeBigUInt64LE(i,s*16+8)}return t},SE=(e,t)=>{const n=new BigUint64Array([uE,dt,Nt,Pp,No,Bp,pE,Ip]);wE(n,e,t);const s=Qc(n,t,11,BigInt(e.byteLength)*dt&z);return Qc(n,t,t.byteLength-Ue-11,~(BigInt(e.byteLength)*Nt)&z)<<64n|s},el=(e,t,n,s,r)=>Mp((e.readBigUInt64LE(t)^n.readBigUInt64LE(s)+r)&z,(e.readBigUInt64LE(t+8)^n.readBigUInt64LE(s+8)-r)&z),Ls=(e,t,n,s,r,i,o)=>{let a=e&z,c=e>>64n&z;return a+=el(t,n,r,i,o),a^=t.readBigUInt64LE(s)+t.readBigUInt64LE(s+8),a&=z,c+=el(t,s,r,i+16,o),c^=t.readBigUInt64LE(n)+t.readBigUInt64LE(n+8),c&=z,c<<64n|a},xE=(e,t,n)=>{const s=e.byteLength,r=BigInt(e.readUInt8(s-1))|BigInt(s)<<8n|BigInt(e.readUInt8(0))<<16n|BigInt(e.readUInt8(s>>1))<<24n,i=(BigInt(t.readUInt32LE(0))^BigInt(t.readUInt32LE(4)))+n,o=(r^i)&z,a=(BigInt(t.readUInt32LE(8))^BigInt(t.readUInt32LE(12)))-n,c=(vE(Dp(r),13n)^a)&z;return(tr(c)&z)<<64n|tr(o)},$E=(e,t,n)=>{const s=e.byteLength;n=(n^Dp(n&ss)<<32n)&z;const r=e.readUInt32LE(0),i=e.readUInt32LE(s-4),o=BigInt(r)|BigInt(i)<<32n,a=(t.readBigUInt64LE(16)^t.readBigUInt64LE(24))+n&z;let l=(o^a)*(dt+(BigInt(s)<<2n))&ln;return l+=(l&z)<<65n,l&=ln,l^=l>>67n,zi(zi(l&z,35n)*hE&z,28n)|Me(l>>64n)<<64n},EE=(e,t,n)=>{const s=e.byteLength,r=(t.readBigUInt64LE(32)^t.readBigUInt64LE(40))-n&z,i=(t.readBigUInt64LE(48)^t.readBigUInt64LE(56))+n&z,o=e.readBigUInt64LE();let a=e.readBigUInt64LE(s-8),c=(o^a^r)*dt;const l=(c&z)+(BigInt(s-1)<<54n);c=c&(ln^z)|l,a^=i,c+=a+(a&ss)*(Bp-1n)<<64n,c&=ln,c^=gE(c>>64n);let d=(c&z)*Nt;return d+=(c>>64n)*Nt<<64n,d&=ln,Me(d&z)|Me(d>>64n)<<64n},CE=(e,t)=>{const n=e.byteLength;return n>8?EE(e,Ce,t):n>=4?$E(e,Ce,t):n>0?xE(e,Ce,t):tr(t^Ce.readBigUInt64LE(64)^Ce.readBigUInt64LE(72))|tr(t^Ce.readBigUInt64LE(80)^Ce.readBigUInt64LE(88))<<64n},RE=(e,t,n)=>{let s=BigInt(e.byteLength)*dt&z,r=BigInt(e.byteLength-1)/32n;for(;r>=0n;){const a=Number(r);s=Ls(s,e,16*a,e.byteLength-16*(a+1),t,32*a,n),r--}let i=s+(s>>64n)&z;i=Me(i);let o=(s&z)*dt+(s>>64n)*No+(BigInt(e.byteLength)-n&z)*Nt;return o&=z,o=Ji(Me(o)),i|o<<64n},jE=(e,t,n)=>{let s=BigInt(e.byteLength)*dt&z;for(let o=32;o<160;o+=32)s=Ls(s,e,o-32,o-16,t,o-32,n);s=Me(s&z)|Me(s>>64n)<<64n;for(let o=160;o<=e.byteLength;o+=32)s=Ls(s,e,o-32,o-16,t,3+o-160,n);s=Ls(s,e,e.byteLength-16,e.byteLength-32,t,103,Ji(n));let r=s+(s>>64n)&z;r=Me(r);let i=(s&z)*dt+(s>>64n)*No+(BigInt(e.byteLength)-n&z)*Nt;return i&=z,i=Ji(Me(i)),r|i<<64n},TE=(e,t=0n)=>{const n=e.byteLength;return n<=16?CE(e,t):n<=128?RE(e,Ce,t):n<=240?jE(e,Ce,t):SE(e,t===0n?Ce:kE(t))},OE=e=>{const t=e>>64n&z,n=e&z;return t.toString(16).padStart(16,"0")+n.toString(16).padStart(16,"0")},_p=(e,t=0n)=>OE(TE(typeof e=="string"?Buffer.from(e):e,BigInt.asUintN(64,t))),Mt=()=>g(lh(),"ai"),AE=3600*1e3,IE=1800*1e3,Fp=()=>{ft(Mt())},Vp=(e,t)=>{const n=`${e}.${String(process.pid)}.${wh()}.tmp`;try{ae(n,t,"utf8"),pl(n,e)}catch(s){try{pt(n)}catch{}throw s}},kR=(e,t,n)=>{const s=n.map(i=>({currentRange:i.currentRange,name:i.packageName,targetVersion:i.targetVersion})).toSorted((i,o)=>i.name.localeCompare(o.name)),r=JSON.stringify({analysisType:t,packages:s,provider:e});return _p(Buffer.from(r))},SR=e=>{const t=g(Mt(),`${e}.json`);if(x(t))try{const n=le(t);if(Date.now()-n.createdAt>n.ttlMs){un(t,{force:!0});return}return n.result}catch{un(t,{force:!0});return}},xR=(e,t,n)=>{Fp();const s=Mt(),r={createdAt:Date.now(),result:t,ttlMs:n};Vp(g(s,`${e}.json`),JSON.stringify(r,void 0,2))},$R=(e,t)=>t!==void 0&&t>0?t:e==="security"?IE:AE,qi=()=>{const e=Mt();if(!x(e))return{entries:0,newestEntry:void 0,oldestEntry:void 0,totalSizeBytes:0};const t=Te(e).filter(i=>i.endsWith(".json"));let n=0,s,r;for(const i of t){const o=g(e,i),a=Ot(o);n+=a.size;const{mtimeMs:c}=a;(s===void 0||c<s)&&(s=c),(r===void 0||c>r)&&(r=c)}return{entries:t.length,newestEntry:r,oldestEntry:s,totalSizeBytes:n}},ER=e=>_p(Buffer.from(JSON.stringify(e))),CR=e=>{const t=g(Mt(),`${e}.json`);if(x(t))try{const n=le(t);if(Date.now()-n.createdAt>n.ttlMs){un(t,{force:!0});return}return n.result}catch{un(t,{force:!0});return}},RR=(e,t,n)=>{Fp();const s=Mt(),r={createdAt:Date.now(),result:t,ttlMs:n};Vp(g(s,`${e}.json`),JSON.stringify(r,void 0,2))},BE=()=>{const e=Mt();if(!x(e))return 0;const t=Te(e).filter(n=>n.endsWith(".json"));for(const n of t)un(g(e,n),{force:!0});return t.length},Ki=(e,t)=>e.tasks.find(n=>n.taskId===t),ni=(e,t)=>{const n=e??{},s=t??{},r=[],i=[],o=[];for(const a of Object.keys(n))a in s?n[a]!==s[a]&&o.push(a):r.push(a);for(const a of Object.keys(s))a in n||i.push(a);return r.sort(),i.sort(),o.sort(),{added:r,changed:o,removed:i}},PE=(e,t)=>({commandChanged:(e?.command??"")!==(t?.command??""),implicitDeps:ni(e?.implicitDeps,t?.implicitDeps),nodes:ni(e?.nodes,t?.nodes),runtime:ni(e?.runtime,t?.runtime)}),Wp=async(e,t)=>{const n=g(mt(e),`${t}.json`);try{const s=await bl(n,"utf8");return JSON.parse(s)}catch{return}},NE=async(e,t)=>{const n=mt(e);let s;try{s=await is(n)}catch{return}const r=[];for(const i of s){if(!i.endsWith(".json")||t!==void 0&&i===`${t}.json`)continue;const o=g(n,i);try{const a=await gn(o);a.isFile()&&r.push({mtimeMs:a.mtimeMs,path:o})}catch{}}if(r.length!==0){r.sort((i,o)=>o.mtimeMs-i.mtimeMs);try{const i=await bl(r[0].path,"utf8");return JSON.parse(i)}catch{return}}},jR=async e=>{const t=mt(e);let n;try{n=await is(t)}catch{return[]}const s=[];for(const r of n){if(!r.endsWith(".json"))continue;const i=g(t,r);try{const o=await gn(i);o.isFile()&&s.push({id:r.slice(0,-5),mtimeMs:o.mtimeMs,path:i})}catch{}}return s.sort((r,i)=>i.mtimeMs-r.mtimeMs),s},Hp=async e=>{let t=0;try{const n=await is(e,{withFileTypes:!0});for(const s of n){const r=g(e,s.name);if(s.isDirectory())t+=await Hp(r);else if(s.isFile()){const i=await gn(r);t+=i.size}}}catch{}return t},ut=async e=>{const t=[];let n;try{n=await is(e)}catch{return[]}for(const s of n){if(s.startsWith("."))continue;const r=g(e,s);try{const i=await gn(r);if(!i.isDirectory())continue;const o=await Hp(r);t.push({hash:s,mtimeMs:i.mtimeMs,path:r,sizeBytes:o})}catch{}}return t.sort((s,r)=>r.mtimeMs-s.mtimeMs),t},Up=(e,t=Date.now())=>{const n=Math.max(0,Math.floor((t-e)/1e3));return n<60?`${String(n)}s`:n<3600?`${String(Math.floor(n/60))}m`:n<86400?`${String(Math.floor(n/3600))}h`:`${String(Math.floor(n/86400))}d`},DE=e=>new Promise(t=>{const n=hl({input:process.stdin,output:process.stderr});n.question(`${e} (y/N) `,s=>{n.close();const r=s.trim().toLowerCase();t(r==="y"||r==="yes")})}),Gp=async(e,t,n)=>{if(!x(e)){if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
|
|
208
206
|
`);return}E.info(`No cache directory found at ${e}`);return}const s=await ut(e);if(s.length===0){if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
|
|
209
|
-
`);return}E.info(`Cache directory is empty: ${e}`);return}const
|
|
210
|
-
`);return}E.info(`Cache directory: ${e}`),E.info(`Entries: ${String(s.length)} (${
|
|
211
|
-
`),process.exitCode=1;return}
|
|
212
|
-
`),process.exitCode=1;return}E.error(`Task "${e}" was not part of run ${o.id}.`),E.info(`Tasks in this run: ${o.tasks.map(p=>p.taskId).join(", ")||"(none)"}`),process.exitCode=1;return}const c=await
|
|
213
|
-
`);return}if(E.info(`Why ${e}? (run ${o.id})`),n.info(""),n.info(` status: ${a.cacheStatus}`),n.info(` hash: ${a.hash??"(none)"}`),l?n.info(` prev: ${l.hash??"(none)"} [run ${c?.id??"?"}]`):n.info(" prev: (no prior run found)"),n.info(""),!l){E.info("No previous run to diff against — first time this task was recorded.");return}if(!d.commandChanged&&d.nodes.added.length===0&&d.nodes.changed.length===0&&d.nodes.removed.length===0&&d.runtime.added.length===0&&d.runtime.changed.length===0&&d.runtime.removed.length===0&&d.implicitDeps.added.length===0&&d.implicitDeps.changed.length===0&&d.implicitDeps.removed.length===0){E.success("No hash inputs changed since the previous run.");return}n.info("Hash inputs that changed since the previous run:"),n.info(""),d.commandChanged&&n.info(" command: changed");for(const p of["nodes","runtime","implicitDeps"]){const f=d[p];if(!(f.added.length===0&&f.changed.length===0&&f.removed.length===0)){n.info(` ${p}:`);for(const h of f.added)n.info(` + ${h}`);for(const h of f.changed)n.info(` ~ ${h}`);for(const h of f.removed)n.info(` - ${h}`)}}n.info(""),E.info(`Last summary file: ${
|
|
214
|
-
`),process.exitCode=1;return}
|
|
207
|
+
`);return}E.info(`Cache directory is empty: ${e}`);return}const r=s.reduce((d,u)=>d+u.sizeBytes,0);if(t==="json"){const d=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:s.map(u=>({ageMs:d-u.mtimeMs,hash:u.hash,mtimeIso:new Date(u.mtimeMs).toISOString(),sizeBytes:u.sizeBytes})),totalBytes:r,totalCount:s.length},void 0,2)}
|
|
208
|
+
`);return}E.info(`Cache directory: ${e}`),E.info(`Entries: ${String(s.length)} (${pn(r,{decimals:1,space:!1})})`),n.info("");const i=Date.now(),o=s.map(d=>({age:Up(d.mtimeMs,i),hash:d.hash.slice(0,12),size:pn(d.sizeBytes,{decimals:1,space:!1})})),a=Math.max(4,...o.map(d=>d.hash.length)),c=Math.max(4,...o.map(d=>d.size.length)),l=Math.max(3,...o.map(d=>d.age.length));n.info(` ${"hash".padEnd(a)} ${"size".padEnd(c)} ${"age".padEnd(l)}`),n.info(` ${"-".repeat(a)} ${"-".repeat(c)} ${"-".repeat(l)}`);for(const d of o)n.info(` ${d.hash.padEnd(a)} ${d.size.padEnd(c)} ${d.age.padEnd(l)}`)},zp=()=>{try{const e=BE();e>0&&E.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},Jp=()=>{try{const e=dh();e>0&&E.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},qp=()=>{try{const e=Uf();e>0&&E.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Kp=()=>{try{const e=Gf();e>0&&E.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},Yp=async(e,t,n)=>{if(!x(e)){E.info(`No cache directory to clean at ${e}`);return}if(n.dryRun){const r=await ut(e),i=r.reduce((o,a)=>o+a.sizeBytes,0);E.info(`Would remove ${String(r.length)} cache entr${r.length===1?"y":"ies"} (${pn(i,{decimals:1,space:!1})}) from ${e}`);return}const s=Wx(e,t);try{const r=await ea(e),i=await ea(t);if(r===i){E.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!s&&!n.force){if(E.warn(`Cache directory is outside the workspace root: ${e}`),E.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){E.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await DE(" Continue?")){E.info("Aborted.");return}}s?await new Vs({cacheDirectory:e,workspaceRoot:t}).clear():await Xi(e,{force:!0,recursive:!0}),E.success(`Cleared cache: ${e}`)},Xp=async(e,t,n)=>{if(!x(e)){E.info(`No cache directory to prune at ${e}`);return}if(n.maxCacheAgeDays!==void 0&&(!Number.isFinite(n.maxCacheAgeDays)||n.maxCacheAgeDays<0)){E.error(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(n.maxCacheAgeDays)}`),process.exitCode=1;return}if(n.keepLast!==void 0&&(!Number.isFinite(n.keepLast)||n.keepLast<0||!Number.isInteger(n.keepLast))){E.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(n.keepLast)}`),process.exitCode=1;return}if(n.maxCacheSize!==void 0){let u;try{u=fh(n.maxCacheSize)}catch(p){E.error(`Invalid --max-size value: ${p instanceof Error?p.message:String(p)}`),process.exitCode=1;return}if(!Number.isFinite(u)||u<=0){E.error(`Invalid --max-size value: expected a positive size, got "${n.maxCacheSize}" (${String(u)} bytes)`),process.exitCode=1;return}}const s=n.maxCacheAgeDays===void 0?void 0:n.maxCacheAgeDays*24*60*60*1e3,r=await ut(e),i=r.reduce((u,p)=>u+p.sizeBytes,0);if(n.keepLast!==void 0&&r.length>n.keepLast){const u=r.slice(n.keepLast);await Promise.all(u.map(p=>Xi(p.path,{force:!0,recursive:!0})))}await new Vs({cacheDirectory:e,maxCacheAge:s,maxCacheSize:n.maxCacheSize,workspaceRoot:t}).removeOldEntries();const a=await ut(e),c=a.reduce((u,p)=>u+p.sizeBytes,0),l=r.length-a.length,d=i-c;if(l<=0){E.info("Nothing to prune — all entries are within the configured limits.");return}E.success(`Pruned ${String(l)} entr${l===1?"y":"ies"}, freed ${pn(d,{decimals:1,space:!1})}.`)},tl=16,Zp=e=>e.length>tl?`${e.slice(0,tl)}…`:e,si=(e,t,n)=>{const s=Object.entries(t??{});if(s.length!==0){n.info(` ${e}:`),s.sort(([r],[i])=>r.localeCompare(i));for(const[r,i]of s)n.info(` ${r.padEnd(40)} ${Zp(i)}`)}},Qp=async(e,t,n)=>{const{format:s,runId:r,workspaceRoot:i}=t,o=r===void 0?await yl(i,{dataDirectory:Fn(i)}):await Wp(i,r);if(!o){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:r??null,taskId:e},void 0,2)}
|
|
209
|
+
`),process.exitCode=1;return}r===void 0?E.error(`No previous run summary found. Run a task first to populate \`${ui(i,{dataDirectory:Fn(i)})}\`.`):E.error(`Run summary "${r}" not found in ${mt(i)}/.`),process.exitCode=1;return}const a=Ki(o,e);if(!a){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
|
|
210
|
+
`),process.exitCode=1;return}E.error(`Task "${e}" was not part of run ${o.id}.`),E.info(`Tasks in this run: ${o.tasks.map(p=>p.taskId).join(", ")||"(none)"}`),process.exitCode=1;return}const c=await NE(i,o.id),l=c?Ki(c,e):void 0,d=PE(a.hashDetails,l?.hashDetails);if(s==="json"){process.stdout.write(`${JSON.stringify({diff:d,previousRunId:c?.id??null,previousTask:l?{cacheStatus:l.cacheStatus,hash:l.hash??null,hashDetails:l.hashDetails??null}:null,runId:o.id,task:{cacheStatus:a.cacheStatus,hash:a.hash??null,hashDetails:a.hashDetails??null,taskId:a.taskId}},void 0,2)}
|
|
211
|
+
`);return}if(E.info(`Why ${e}? (run ${o.id})`),n.info(""),n.info(` status: ${a.cacheStatus}`),n.info(` hash: ${a.hash??"(none)"}`),l?n.info(` prev: ${l.hash??"(none)"} [run ${c?.id??"?"}]`):n.info(" prev: (no prior run found)"),n.info(""),!l){E.info("No previous run to diff against — first time this task was recorded.");return}if(!d.commandChanged&&d.nodes.added.length===0&&d.nodes.changed.length===0&&d.nodes.removed.length===0&&d.runtime.added.length===0&&d.runtime.changed.length===0&&d.runtime.removed.length===0&&d.implicitDeps.added.length===0&&d.implicitDeps.changed.length===0&&d.implicitDeps.removed.length===0){E.success("No hash inputs changed since the previous run.");return}n.info("Hash inputs that changed since the previous run:"),n.info(""),d.commandChanged&&n.info(" command: changed");for(const p of["nodes","runtime","implicitDeps"]){const f=d[p];if(!(f.added.length===0&&f.changed.length===0&&f.removed.length===0)){n.info(` ${p}:`);for(const h of f.added)n.info(` + ${h}`);for(const h of f.changed)n.info(` ~ ${h}`);for(const h of f.removed)n.info(` - ${h}`)}}n.info(""),E.info(`Last summary file: ${ui(i,{dataDirectory:Fn(i)})}`)},ef=async(e,t,n)=>{const{format:s,runId:r,workspaceRoot:i}=t,o=r===void 0?await yl(i,{dataDirectory:Fn(i)}):await Wp(i,r);if(!o){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:r??null,taskId:e},void 0,2)}
|
|
212
|
+
`),process.exitCode=1;return}r===void 0?E.error(`No previous run summary found. Run a task first to populate \`${ui(i,{dataDirectory:Fn(i)})}\`.`):E.error(`Run summary "${r}" not found in ${mt(i)}/.`),process.exitCode=1;return}const a=Ki(o,e);if(!a){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
|
|
215
213
|
`),process.exitCode=1;return}E.error(`Task "${e}" was not part of run ${o.id}.`),process.exitCode=1;return}if(s==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:a.cacheStatus,hash:a.hash??null,hashDetails:a.hashDetails??null,runId:o.id,taskId:a.taskId},void 0,2)}
|
|
216
|
-
`);return}E.info(`Hash for ${e} (run ${o.id})`),n.info(""),n.info(` status: ${a.cacheStatus}`),n.info(` hash: ${a.hash??"(none)"}`),a.hashDetails?(n.info(""),n.info(` command: ${
|
|
217
|
-
`);return}E.info(`No cache directory at ${e}`);return}const n=await ut(e),s=n.reduce((i
|
|
218
|
-
`);return}E.info(`Cache directory: ${e}`),E.info(`Entries: ${String(n.length)}`),E.info(`Total size: ${
|
|
219
|
-
`):E.error("No cache directory resolved — pass --cache-dir or run inside a workspace."),process.exitCode=1;return}let o,a;for(const l of s){const d=await new
|
|
220
|
-
`):E.error(`No cached entry found for task "${e}". Run it once before verifying.`),process.exitCode=1;return}const c=await
|
|
221
|
-
`):E.error(`Cache restore failed for ${e} (hash ${a.hash}).`),process.exitCode=1;return}const u=await
|
|
222
|
-
`):E.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const p=Array.from({length:u.length});for(let h=0;h<u.length;h+=
|
|
223
|
-
`),f.length>0&&(process.exitCode=1);return}if(E.info(`Verify ${e} (hash ${a.hash})`),n.info(""),n.info(` cache: ${o}`),n.info(` files: ${String(u.length)}`),f.length===0){n.info(""),E.success("Cache restore is faithful — all files match content, mode, and mtime.");return}n.info(` drift: ${String(f.length)} file(s)`),n.info("");for(const h of f){const m=h.issues.includes("missing")?"MISSING":h.issues.join(",").toUpperCase();n.info(` [${m}] ${h.relativePath}`),!h.issues.includes("missing")&&h.expected&&h.actual&&(h.issues.includes("content")&&(n.info(` expected hash: ${h.expected.hash||"(none)"}`),n.info(` actual hash: ${h.actual.hash??"(unreadable)"}`)),h.issues.includes("mode")&&(n.info(` expected mode: ${h.expected.mode.toString(8)}`),n.info(` actual mode: ${(h.actual.mode??0).toString(8)}`)),h.issues.includes("mtime")&&(n.info(` expected mtime: ${new Date(h.expected.mtimeMs).toISOString()}`),n.info(` actual mtime: ${h.actual.mtimeMs===void 0?"(unreadable)":new Date(h.actual.mtimeMs).toISOString()}`)))}process.exitCode=1}finally{await
|
|
224
|
-
`);return}if(ye(s,"task")){const{cacheDirectories:
|
|
214
|
+
`);return}E.info(`Hash for ${e} (run ${o.id})`),n.info(""),n.info(` status: ${a.cacheStatus}`),n.info(` hash: ${a.hash??"(none)"}`),a.hashDetails?(n.info(""),n.info(` command: ${Zp(a.hashDetails.command)}`),si("nodes",a.hashDetails.nodes,n),si("runtime",a.hashDetails.runtime,n),si("implicitDeps",a.hashDetails.implicitDeps,n)):(n.info(""),E.info("No hash details recorded for this task."))},tf=async(e,t)=>{if(!x(e)){if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
|
|
215
|
+
`);return}E.info(`No cache directory at ${e}`);return}const n=await ut(e),s=n.reduce((r,i)=>r+i.sizeBytes,0);if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:s,totalCount:n.length})}
|
|
216
|
+
`);return}E.info(`Cache directory: ${e}`),E.info(`Entries: ${String(n.length)}`),E.info(`Total size: ${pn(s,{decimals:1,space:!1})}`)},ME=async e=>{const t=[],n=async s=>{const i=(await is(s,{withFileTypes:!0})).toSorted((o,a)=>o.name.localeCompare(a.name));for(const o of i){const a=g(s,o.name);if(o.isDirectory()){await n(a);continue}if(!o.isFile())continue;const[c,l]=await Promise.all([gn(a),vl(a)]);t.push({hash:l?.hash??"",mode:c.mode&4095,mtimeMs:c.mtimeMs,relativePath:rs(e,a).replaceAll("\\","/"),sizeBytes:c.size})}};return await n(e),t},LE=(e,t)=>Math.floor(e/1e3)===Math.floor(t/1e3),nl=16,_E=async(e,t)=>{const n=g(t,e.relativePath),s=await gn(n).catch(()=>{});if(!s)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const r=await vl(n),i=[];(r?.hash??"")!==e.hash&&i.push("content");const o=s.mode&4095;if(process.platform!=="win32"&&o!==e.mode&&i.push("mode"),LE(s.mtimeMs,e.mtimeMs)||i.push("mtime"),i.length!==0)return{actual:{hash:r?.hash,mode:o,mtimeMs:s.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:i,relativePath:e.relativePath}},nf=async(e,t,n)=>{const{cacheDirectories:s,format:r,workspaceRoot:i}=t;if(s.length===0){r==="json"?process.stdout.write(`${JSON.stringify({error:"no-cache-directory",taskId:e},void 0,2)}
|
|
217
|
+
`):E.error("No cache directory resolved — pass --cache-dir or run inside a workspace."),process.exitCode=1;return}let o,a;for(const l of s){const d=await new Vs({cacheDirectory:l,workspaceRoot:i}).getByTaskId(e);if(d){o=l,a=d;break}}if(!a||!o){r==="json"?process.stdout.write(`${JSON.stringify({error:"no-cached-entry",searchedCaches:s,taskId:e},void 0,2)}
|
|
218
|
+
`):E.error(`No cached entry found for task "${e}". Run it once before verifying.`),process.exitCode=1;return}const c=await hh(g(ah(),"vis-cache-verify-"));try{if(!await new Vs({cacheDirectory:o,workspaceRoot:c}).restoreOutputs(a.hash)){r==="json"?process.stdout.write(`${JSON.stringify({error:"restore-failed",hash:a.hash,taskId:e},void 0,2)}
|
|
219
|
+
`):E.error(`Cache restore failed for ${e} (hash ${a.hash}).`),process.exitCode=1;return}const u=await ME(c);if(u.length===0){r==="json"?process.stdout.write(`${JSON.stringify({diffs:[],hash:a.hash,status:"no-outputs",taskId:e},void 0,2)}
|
|
220
|
+
`):E.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const p=Array.from({length:u.length});for(let h=0;h<u.length;h+=nl){const m=u.slice(h,h+nl),v=await Promise.all(m.map(async $=>_E($,i)));for(const[$,b]of v.entries())p[h+$]=b}const f=p.filter(h=>h!==void 0);if(r==="json"){process.stdout.write(`${JSON.stringify({cachedFileCount:u.length,cacheDirectory:o,diffs:f,hash:a.hash,status:f.length===0?"ok":"drift",taskId:e},void 0,2)}
|
|
221
|
+
`),f.length>0&&(process.exitCode=1);return}if(E.info(`Verify ${e} (hash ${a.hash})`),n.info(""),n.info(` cache: ${o}`),n.info(` files: ${String(u.length)}`),f.length===0){n.info(""),E.success("Cache restore is faithful — all files match content, mode, and mtime.");return}n.info(` drift: ${String(f.length)} file(s)`),n.info("");for(const h of f){const m=h.issues.includes("missing")?"MISSING":h.issues.join(",").toUpperCase();n.info(` [${m}] ${h.relativePath}`),!h.issues.includes("missing")&&h.expected&&h.actual&&(h.issues.includes("content")&&(n.info(` expected hash: ${h.expected.hash||"(none)"}`),n.info(` actual hash: ${h.actual.hash??"(unreadable)"}`)),h.issues.includes("mode")&&(n.info(` expected mode: ${h.expected.mode.toString(8)}`),n.info(` actual mode: ${(h.actual.mode??0).toString(8)}`)),h.issues.includes("mtime")&&(n.info(` expected mtime: ${new Date(h.expected.mtimeMs).toISOString()}`),n.info(` actual mtime: ${h.actual.mtimeMs===void 0?"(unreadable)":new Date(h.actual.mtimeMs).toISOString()}`)))}process.exitCode=1}finally{await Xi(c,{force:!0,recursive:!0}).catch(()=>{})}},sf=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&E.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),ye=(e,t)=>e==="all"||e===t,Pe=e=>e===void 0?null:new Date(e).toISOString(),Os=(e,t)=>{E.info(`${e}:`),E.info(` Entries: ${String(t.entries)}`),E.info(` Total size: ${pn(t.totalSizeBytes,{decimals:1,space:!1})}`),E.info(` Oldest: ${t.oldestEntry?new Date(t.oldestEntry).toISOString():"N/A"}`),E.info(` Newest: ${t.newestEntry?new Date(t.newestEntry).toISOString():"N/A"}`)},FE=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&E.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),mn=(e,t,n)=>{const s=e??process.cwd(),r=n??{},i=r.taskRunner??{},o=FE(t.scope),a=t.cacheDir,c=_c(s,a,i.cacheDirectory,!1),l=_c(s,a,i.cacheDirectory,r.sharedWorktreeCache);let d,u;switch(o){case"all":{d=l,u=l===c?[l]:[l,c];break}case"worktree":{d=c,u=[c];break}default:d=l,u=[l]}return{cacheDirectories:u,cacheDirectory:d,scope:o,sharedWorktreeCache:r.sharedWorktreeCache,workspaceRoot:s}},VE=async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{const{cacheDirectories:r}=mn(s,t,n),i=t.format??"table";for(const o of r)r.length>1&&E.info(`# ${o}`),await Gp(o,i,e)},WE=async({options:e,visConfig:t,workspaceRoot:n})=>{const s=sf(e.type),r=!!e.dryRun;if(ye(s,"task")){const{cacheDirectory:i,workspaceRoot:o}=mn(n,e,t);await Yp(i,o,{dryRun:r,force:!!e.force})}if(ye(s,"ai"))if(r){const i=qi();E.info(`Would clear ${String(i.entries)} cached AI response${i.entries===1?"":"s"}.`)}else zp();if(ye(s,"socket"))if(r){const i=di();E.info(`Would clear ${String(i.entries)} cached Socket.dev report${i.entries===1?"":"s"}.`)}else Jp();if(ye(s,"deps-dev"))if(r){const i=ai();E.info(`Would clear ${String(i.entries)} cached deps.dev record${i.entries===1?"":"s"}.`)}else qp();if(ye(s,"snyk"))if(r){const i=ci();E.info(`Would clear ${String(i.entries)} cached Snyk record${i.entries===1?"":"s"}.`)}else Kp()},HE=async({options:e,visConfig:t,workspaceRoot:n})=>{const{cacheDirectories:s,workspaceRoot:r}=mn(n,e,t);for(const i of s)s.length>1&&E.info(`# ${i}`),await Xp(i,r,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},rf=e=>e??process.cwd(),UE=async({argument:e,logger:t,options:n,workspaceRoot:s})=>{const r=e[0];if(!r){E.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await Qp(r,{format:n.format??"table",runId:n.run,workspaceRoot:rf(s)},t)},GE=async({argument:e,logger:t,options:n,workspaceRoot:s})=>{const r=e[0];if(!r){E.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}await ef(r,{format:n.format??"table",runId:n.run,workspaceRoot:rf(s)},t)},zE=async({options:e,visConfig:t,workspaceRoot:n})=>{const s=sf(e.type);if((e.format??"table")==="json"){const i={};if(ye(s,"task")){const{cacheDirectories:o}=mn(n,e,t);i.task=await Promise.all(o.map(async a=>{const c=x(a),l=c?await ut(a):[],d=l.reduce((u,p)=>u+p.sizeBytes,0);return{directory:a,entries:l.length,exists:c,newestEntry:Pe(l[0]?.mtimeMs),oldestEntry:Pe(l.at(-1)?.mtimeMs),totalBytes:d}}))}if(ye(s,"ai")){const o=qi();i.ai={entries:o.entries,newestEntry:Pe(o.newestEntry),oldestEntry:Pe(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(ye(s,"socket")){const o=di();i.socket={entries:o.entries,newestEntry:Pe(o.newestEntry),oldestEntry:Pe(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(ye(s,"deps-dev")){const o=ai();i["deps-dev"]={entries:o.entries,newestEntry:Pe(o.newestEntry),oldestEntry:Pe(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(ye(s,"snyk")){const o=ci();i.snyk={entries:o.entries,newestEntry:Pe(o.newestEntry),oldestEntry:Pe(o.oldestEntry),totalBytes:o.totalSizeBytes}}process.stdout.write(`${JSON.stringify(i,void 0,2)}
|
|
222
|
+
`);return}if(ye(s,"task")){const{cacheDirectories:i}=mn(n,e,t);for(const o of i)i.length>1&&E.info(`# ${o}`),await tf(o,"table")}ye(s,"ai")&&Os("AI response cache",qi()),ye(s,"socket")&&Os("Socket.dev report cache",di()),ye(s,"deps-dev")&&Os("deps.dev cache",ai()),ye(s,"snyk")&&Os("Snyk issue cache",ci())},JE=async({argument:e,logger:t,options:n,visConfig:s,workspaceRoot:r})=>{const i=e[0];if(!i){E.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{cacheDirectories:o,workspaceRoot:a}=mn(r,n,s);await nf(i,{cacheDirectories:o,format:n.format??"table",workspaceRoot:a},t)},Lt=Object.defineProperty({__proto__:null,cacheCleanExecute:WE,cacheHashExecute:GE,cacheListExecute:VE,cachePruneExecute:HE,cacheSizeExecute:zE,cacheVerifyExecute:JE,cacheWhyExecute:UE,clearAiCacheSafe:zp,clearDepsDevCacheSafe:qp,clearSnykCacheSafe:Kp,clearSocketCacheSafe:Jp,collectCacheEntries:ut,formatAge:Up,runClean:Yp,runHash:ef,runList:Gp,runPrune:Xp,runSize:tf,runVerify:nf,runWhy:Qp},Symbol.toStringTag,{value:"Module"}),TR=(e,t)=>{let n=0,s=0,r=0;for(const[,a]of e)switch(a.status){case"failure":{r+=1;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{s+=1;break}case"success":{n+=1;break}}const i=[];n>0&&i.push(`${String(n)} succeeded`),s>0&&i.push(`${String(s)} cached`),r>0&&i.push(`${String(r)} failed`);const o=(t/1e3).toFixed(1);return i.push(`${o}s`),i.join(" · ")},zn=e=>{const t=mt(e);if(x(t)){const s=Te(t).filter(i=>i.endsWith(".json")),r=[];for(const i of s)try{r.push(le(g(t,i)))}catch{}if(r.length>0)return r}const n=gl(e);if(x(n))try{return[le(n)]}catch{}return[]},OR=(e,t,n)=>{const s=n??zn(e);if(s.length<2)return;let r=0,i=0;for(const l of s)typeof l.duration=="number"&&l.duration>0&&(r+=l.duration,i+=1);if(i<2)return;const a=r/i-t,c=Math.abs(a/1e3).toFixed(1);return Math.abs(a)<500?"(about average)":a>0?`(${c}s faster than avg)`:`(${c}s slower than avg)`},qE=(e,t={},n)=>{const s=n??zn(e);if(s.length===0)return[];const r=new Map;for(const a of s)if(!(t.since&&(a.startTime===void 0||a.startTime<t.since))&&Array.isArray(a.tasks))for(const c of a.tasks){if(c.cacheStatus==="HIT"||c.cacheStatus==="REMOTE_HIT"||c.cacheStatus==="SKIPPED")continue;const l=r.get(c.taskId)??{failures:0,project:c.target.project,retriedSuccesses:0,successes:0,target:c.target.target,totalRuns:0};l.totalRuns+=1,c.exitCode!==void 0&&c.exitCode!==0?(l.failures+=1,l.lastFailure=c.startTime??a.startTime):(c.retryAttempts&&c.retryAttempts>0&&(l.retriedSuccesses+=1,l.lastRetry=c.startTime??a.startTime),l.successes+=1),r.set(c.taskId,l)}const i=t.minRuns??2,o=[];for(const[a,c]of r){if(c.totalRuns<i||c.failures===0&&c.retriedSuccesses===0)continue;const l=(c.failures+.5*c.retriedSuccesses)/c.totalRuns;o.push({failures:c.failures,flakinessRate:l,lastFailure:c.lastFailure,lastRetry:c.lastRetry,project:c.project,retriedSuccesses:c.retriedSuccesses,successes:c.successes,target:c.target,taskId:a,totalRuns:c.totalRuns})}return o.sort((a,c)=>c.flakinessRate-a.flakinessRate),o},AR=e=>{if(e.length===0)return["No flaky tasks detected."];const t=["Task","Runs","Failures","Retried","Rate","Last Failure"],n=e.map(a=>[a.taskId,String(a.totalRuns),String(a.failures),String(a.retriedSuccesses),`${(a.flakinessRate*100).toFixed(1)}%`,a.lastFailure??a.lastRetry??"—"]),s=t.map((a,c)=>{let l=0;for(const d of n)l=Math.max(l,(d[c]??"").length);return Math.max(a.length,l)}),r=(a,c)=>a.padEnd(c),i=s.map(a=>"─".repeat(a)).join("──"),o=[t.map((a,c)=>r(a,s[c])).join(" "),i];for(const a of n)o.push(a.map((c,l)=>r(c,s[l])).join(" "));return o},ri=(e,t,n)=>{const s=[],r=t??{},i=n??{},o=new Set([...Object.keys(r),...Object.keys(i)]);for(const a of o){const c=r[a],l=i[a];c!==l&&(c===void 0?s.push({change:"added",current:l,key:a,kind:e,previous:void 0}):l===void 0?s.push({change:"removed",current:void 0,key:a,kind:e,previous:c}):s.push({change:"modified",current:l,key:a,kind:e,previous:c}))}return s.sort((a,c)=>a.key.localeCompare(c.key)),s},KE=e=>{if(e.length===0)return"No input changes detected. The cache may have been evicted or was never stored.";if(e.some(i=>i.kind==="command"))return"The resolved command changed.";const n=new Map;for(const i of e)n.set(i.kind,(n.get(i.kind)??0)+1);const[s]=[...n.entries()].sort((i,o)=>o[1]-i[1])[0]??["nodes",0],r={command:"command",implicitDeps:"lockfile or dependency",nodes:"input file",runtime:"runtime value"};return`${String(e.length)} ${r[s]??s} change(s) detected.`},YE=(e,t,n)=>{const s=e.find(o=>o.id===n)?.startTime,i=[...e].sort((o,a)=>(a.startTime??"").localeCompare(o.startTime??"")).filter(o=>!(o.id!==void 0&&o.id===n||s!==void 0&&o.startTime!==void 0&&o.startTime>s));for(const o of i){const a=o.tasks?.find(c=>c.taskId===t);if(a&&(a.cacheStatus==="HIT"||a.cacheStatus==="REMOTE_HIT"))return{run:o,task:a}}for(const o of i){const a=o.tasks?.find(c=>c.taskId===t);if(a?.hashDetails)return{run:o,task:a}}},XE=(e,t,n)=>{const s=e,r=n.taskId??"",i=YE(s,r,t);if(!i)return{currentHash:n.hash,entries:[],previousHash:void 0,previousRunId:void 0,previousRunStartTime:void 0,reason:"No previous run recorded this task — first observation.",taskId:r};const o=[],a=i.task.hashDetails?.command,c=n.hashDetails?.command;return a!==c&&o.push({change:a===void 0?"added":c===void 0?"removed":"modified",current:c,key:"command",kind:"command",previous:a}),o.push(...ri("nodes",i.task.hashDetails?.nodes,n.hashDetails?.nodes)),o.push(...ri("implicitDeps",i.task.hashDetails?.implicitDeps,n.hashDetails?.implicitDeps)),o.push(...ri("runtime",i.task.hashDetails?.runtime,n.hashDetails?.runtime)),{currentHash:n.hash,entries:o,previousHash:i.task.hash,previousRunId:i.run.id,previousRunStartTime:i.run.startTime,reason:KE(o),taskId:r}},sl=fl(kh(import.meta.url)),ZE=[_s(sl,"..","..","dashboard","dist","index.html"),_s(sl,"..","dashboard","dist","index.html")],rl=`<!DOCTYPE html>
|
|
225
223
|
<html lang="en">
|
|
226
224
|
<head>
|
|
227
225
|
<meta charset="UTF-8" />
|
|
@@ -239,9 +237,9 @@ ${s.join(`\r
|
|
|
239
237
|
<p>Or run the full vis build:</p>
|
|
240
238
|
<pre><code>pnpm --filter @visulima/vis run build</code></pre>
|
|
241
239
|
</body>
|
|
242
|
-
</html>`;let bt;const IE=()=>{for(const e of AE)try{if(Tt(e).isFile())return e}catch{}},BE=()=>{if(bt!==void 0&&!process.env.VIS_DASHBOARD_NO_CACHE)return bt;const e=IE();if(!e)return bt=Zc,bt;try{const t=Gf(e,"utf8");return bt=t,t}catch{return bt=Zc,bt}},PE=e=>{if(e.length===0)return;const t=[...e].sort((s,i)=>s-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]},NE=e=>{const t=new Map;for(const s of e)if(Array.isArray(s.tasks))for(const i of s.tasks){if(!i.taskId)continue;const r=t.get(i.taskId)??{durations:[],failures:0,hits:0,misses:0,project:i.target?.project??"",runs:0,target:i.target?.target??"",taskId:i.taskId};i.cacheStatus==="HIT"||i.cacheStatus==="REMOTE_HIT"?(r.runs+=1,r.hits+=1):i.cacheStatus==="MISS"&&(r.runs+=1,r.misses+=1,typeof i.duration=="number"&&i.duration>0&&r.durations.push(i.duration),i.exitCode!==void 0&&i.exitCode!==0&&(r.failures+=1)),t.set(i.taskId,r)}const n=new Map;for(const[s,i]of t){const r=i.durations.length===0?0:i.durations.reduce((o,a)=>o+a,0)/i.durations.length;n.set(s,{averageDurationMs:r,failures:i.failures,hitRate:i.runs===0?0:i.hits/i.runs,hits:i.hits,misses:i.misses,project:i.project,runs:i.runs,target:i.target,taskId:s,timeSavedMs:r*i.hits})}return n},DE=e=>{const t=e,n=[...t].sort((v,S)=>(v.startTime??"").localeCompare(S.startTime??""));let s=0,i=0,r=0,o=0,a=0,c=0;const l=[],d=[],u=[];for(const v of n){const S=v.stats??{};s+=S.total??0,i+=S.succeeded??0,r+=S.failed??0,o+=S.cached??0,a+=S.skipped??0,typeof v.duration=="number"&&v.duration>0&&(c+=v.duration,l.push(v.duration),v.startTime&&u.push({timestamp:v.startTime,value:v.duration})),(S.total??0)>0&&v.startTime&&d.push({timestamp:v.startTime,value:(S.cached??0)/(S.total??1)})}const f=[...NE(n).values()],h=f.filter(v=>v.averageDurationMs>0).sort((v,S)=>S.averageDurationMs-v.averageDurationMs).slice(0,10),m=f.filter(v=>v.runs>=2).sort((v,S)=>S.timeSavedMs-v.timeSavedMs||S.hitRate-v.hitRate).slice(0,10),b=f.filter(v=>v.runs>=3&&v.hits>0&&v.misses>0).sort((v,S)=>S.misses/S.runs-v.misses/v.runs).slice(0,10),$=f.reduce((v,S)=>v+S.timeSavedMs,0);return{averageRunDurationMs:l.length===0?null:l.reduce((v,S)=>v+S,0)/l.length,cacheHitRate:o+i+r===0?null:o/(o+i+r),durationOverTime:u,hitRateOverTime:d,medianRunDurationMs:PE(l)??null,mostCachedTasks:m,mostInvalidatedTasks:b,slowestTasks:h,totals:{cached:o,estimatedTimeSavedMs:$,failed:r,runs:t.length,skipped:a,succeeded:i,tasks:s,totalDurationMs:c}}},ME=(e,t)=>{if(e===void 0||e==="")return!1;let n=e;if(n.startsWith("[")){const s=n.indexOf("]");n=s===-1?n.slice(1):n.slice(1,s)}else if(!n.includes("::")){const s=n.indexOf(":");n=s===-1?n:n.slice(0,s)}return n=n.toLowerCase(),n==="localhost"||n===t.toLowerCase()?!0:lh(n)!==0},Qc=(e,t)=>{const n=t.replaceAll(/[^\w.\-:]/g,"");if(n.length===0||n!==t)return;const s=g(mt(e),`${n}.json`);if(x(s))try{return le(s)}catch{return}const i=dl(e);if(x(i))try{const r=le(i);return r.id===n?r:void 0}catch{return}},LE=async e=>{const t=new Set,n=mt(e);try{await ch(n,{recursive:!0})}catch{}let s,i;const r=a=>{i=a,s&&clearTimeout(s),s=setTimeout(()=>{if(s=void 0,!i)return;const c=i;i=void 0;for(const l of t)try{l(c)}catch{}},200)};let o;try{o=zf(n,(a,c)=>{if(!c||typeof c!="string"||!c.endsWith(".json"))return;const l=c.slice(0,-5);r({id:l,type:"run-changed"})})}catch{o=void 0}return{close:()=>{s&&clearTimeout(s),o?.close(),t.clear()},subscribe:a=>(t.add(a),()=>{t.delete(a)})}},_E=(e,t)=>{const n=new L2;return n.use("*",async(s,i)=>ME(s.req.header("host"),e.host)?i():s.json({error:"Forbidden"},403)),n.get("/",s=>s.html(BE())),n.get("/api/overview",s=>{const i=qn(e.workspaceRoot),r=DE(i),o=RE(e.workspaceRoot,{minRuns:2},i);return s.json({flaky:o,metrics:r})}),n.get("/api/runs",s=>{const r=qn(e.workspaceRoot).filter(o=>typeof o.id=="string"&&typeof o.startTime=="string"&&typeof o.endTime=="string"&&typeof o.duration=="number").map(o=>{const a=o.stats,c=a?{cached:typeof a.cached=="number"?a.cached:void 0,failed:typeof a.failed=="number"?a.failed:void 0,skipped:typeof a.skipped=="number"?a.skipped:void 0,succeeded:typeof a.succeeded=="number"?a.succeeded:void 0,total:typeof a.total=="number"?a.total:void 0}:void 0;return{duration:o.duration,endTime:o.endTime,id:o.id,startTime:o.startTime,stats:c}}).sort((o,a)=>a.startTime.localeCompare(o.startTime));return s.json({runs:r})}),n.get("/api/runs/:id",s=>{const i=Qc(e.workspaceRoot,s.req.param("id"));return i?s.json(i):s.json({error:"Not found"},404)}),n.get("/api/runs/:runId/tasks/:taskId/diff",s=>{const i=Qc(e.workspaceRoot,s.req.param("runId"));if(!i)return s.json({error:"Run not found"},404);const r=s.req.param("taskId"),o=i.tasks?.find(l=>l.taskId===r);if(!o)return s.json({error:"Task not found"},404);const a=qn(e.workspaceRoot),c=OE(a,i.id,o);return s.json(c)}),n.get("/api/cache",async s=>{if(!x(e.cacheDirectory))return s.json({directory:e.cacheDirectory,entries:[],exists:!1,totalBytes:0});const i=await ut(e.cacheDirectory),r=i.reduce((a,c)=>a+c.sizeBytes,0),o=Date.now();return s.json({directory:e.cacheDirectory,entries:i.map(a=>({ageMs:o-a.mtimeMs,hash:a.hash,mtimeIso:new Date(a.mtimeMs).toISOString(),sizeBytes:a.sizeBytes})),exists:!0,totalBytes:r})}),n.get("/api/environment",s=>s.json({arch:process.arch,cacheDirectory:e.cacheDirectory,node:process.version,platform:process.platform,workspaceRoot:e.workspaceRoot})),n.get("/api/events",s=>W2(s,async i=>{const r=[];let o;const a=t(l=>{if(r.push(l),o){const d=o;o=void 0,d()}});i.onAbort(()=>{if(a(),o){const l=o;o=void 0,l()}}),await i.writeSSE({data:JSON.stringify({ok:!0}),event:"ready"});const c=15e3;for(;!i.aborted;){if(r.length===0){const d=i.sleep(c),u=new Promise(p=>{o=p});if(await Promise.race([d,u]),i.aborted)break;if(r.length===0){await i.writeSSE({data:"",event:"heartbeat"});continue}}const l=r.shift();await i.writeSSE({data:JSON.stringify(l),event:"change"})}})),n},FE=async e=>{const t=await LE(e.workspaceRoot),n=_E(e,t.subscribe),s=n2({fetch:n.fetch,hostname:e.host,port:e.port});await new Promise((l,d)=>{s.once("listening",()=>{l()}),s.once("error",u=>{d(u)})});const i=s.address(),r=typeof i=="object"&&i?i.port:e.port,c=`http://${e.host==="0.0.0.0"||e.host==="::"||e.host==="::0"?"localhost":e.host}:${String(r)}`;return{close:()=>new Promise((l,d)=>{t.close(),s.close(u=>{u?d(u):l()})}),port:r,url:c}},VE=e=>{const{platform:t}=process,[n,s]=t==="darwin"?["open",[e]]:t==="win32"?["cmd",["/c","start","",e]]:["xdg-open",[e]];Vf(n,s,i=>{})},HE={description:"Open a browser dashboard with cache, run history, and cache-miss diffs",examples:[["vis dashboard","Start the dashboard on a random port (server only — does not open a browser)"],["vis dashboard --open","Start the dashboard and open it in the default browser"],["vis dashboard --port=7788","Pin the server to a specific port"],["vis dashboard --host=0.0.0.0 --port=7788","Expose the dashboard on all interfaces"]],execute:async({options:e,process:t,visConfig:n,workspaceRoot:s})=>{const i=s??t.cwd,r=Zu(i,e.cacheDir,n?.taskRunner?.cacheDirectory),o=typeof e.port=="number"&&Number.isFinite(e.port)?e.port:0,a=typeof e.host=="string"&&e.host.length>0?e.host:"127.0.0.1",c=await FE({cacheDirectory:r,host:a,port:o,workspaceRoot:i});E.success(`Dashboard listening on ${c.url}`),E.info(`Workspace: ${i}`),E.info(`Cache: ${r}`),E.info("Press Ctrl+C to stop."),e.open===!0&&VE(c.url),await new Promise(l=>{let d=!1;const u=()=>{d||(d=!0,process.off("SIGINT",u),process.off("SIGTERM",u),(async()=>{try{await c.close()}catch{}finally{l()}})())};process.once("SIGINT",u),process.once("SIGTERM",u)})},group:"Workspace",name:"dashboard",options:[{defaultValue:0,description:"Port to bind the dashboard server to (0 = auto-assign)",name:"port",type:Number},{defaultValue:"127.0.0.1",description:"Host interface to bind to. Default binds to localhost only.",name:"host",type:String},{defaultValue:!1,description:"Open the dashboard in the default browser after starting",name:"open",type:Boolean},{description:"Cache directory to inspect (overrides config and default). Relative paths resolve against the workspace root.",name:"cache-dir",type:String}]},WE={description:"Deduplicate dependencies using the detected package manager",examples:[["vis dedupe","Run deduplication"],["vis dedupe --check","Preview changes without modifying (CI-friendly)"]],group:"Dependencies",loader:()=>import("./handler9.js"),name:"dedupe",options:[{defaultValue:!1,description:"Preview changes without modifying files (dry-run)",name:"check",type:Boolean}]},UE={description:"Lint workspace dependency policies (workspace-protocol, banned-deps, redefine-root, workspace-versions, custom-types, empty-deps, root-private, root-package-manager, root-deps, missing-package-json, dead-workspace-patterns, types-in-deps, similar-deps)",examples:[["vis deps","Run every enabled lint and exit non-zero on failures"],["vis deps --workspace-protocol","Only check that internal deps use workspace:*"],["vis deps --workspace-protocol --fix","Auto-rewrite internal deps to use workspace:*"],["vis deps --redefine-root","Flag deps duplicated between root and child packages"],["vis deps --banned-deps","Flag deps matching policy.bannedDeps in vis config"],["vis deps --workspace-versions","Flag external deps declared at different versions across packages"],["vis deps --workspace-versions --fix","Rewrite drifting deps to the highest sibling version"],["vis deps --workspace-versions --dep react","Limit version-drift check to a single dep"],["vis deps --workspace-versions --resolve catalog --fix","Rewrite drifting deps to catalog: when a catalog already pins them"],["vis deps --workspace-versions --resolve catalog --propose-min 3","Suggest new catalog entries for deps ≥3 packages already agree on"],["vis deps --custom-types","Flag drift in engines.{node,pnpm}, packageManager, volta.{node,pnpm,yarn}, devEngines"],["vis deps --custom-types --fix","Align all engines/packageManager/volta versions to the highest sibling"],["vis deps --empty-deps --fix","Drop empty `dependencies` / `devDependencies` / etc. blocks across the workspace"],["vis deps --root-private --fix",'Ensure the workspace root package.json has "private": true'],["vis deps --root-package-manager","Ensure the root package.json declares a `packageManager` field"],["vis deps --root-deps --fix","Move runtime deps off the private workspace root into devDependencies"],["vis deps --missing-package-json","Flag workspace dirs that don't contain a package.json"],["vis deps --dead-workspace-patterns --fix","Drop workspace patterns that match zero packages"],["vis deps --types-in-deps --fix","Move @types/* out of dependencies on private packages"],["vis deps --similar-deps","Flag drift across related dep families (react+react-dom, @babel/*, …)"],["vis deps --ban left-pad --ban request","One-off ban: flag any package declaring left-pad or request"],["vis deps --pin react@18.2.0","One-off pin: flag any package declaring react at a different version"],["vis deps --format json","Emit findings as JSON for CI / editor integrations"]],group:"Security & Health",loader:()=>import("./handler68.js"),name:"deps",options:[{defaultValue:!1,description:"Lint that internal deps use the workspace: protocol",name:"workspace-protocol",type:Boolean},{defaultValue:!1,description:"Lint that no child re-declares a dep already pinned in the workspace root",name:"redefine-root",type:Boolean},{defaultValue:!1,description:"Lint deps against policy.bannedDeps in vis config",name:"banned-deps",type:Boolean},{defaultValue:!1,description:"Lint that all packages declare external deps at the same version",name:"workspace-versions",type:Boolean},{defaultValue:!1,description:"Lint engines.{node,pnpm}, packageManager, volta.*, devEngines.* for drift across packages",name:"custom-types",type:Boolean},{defaultValue:!1,description:"Flag empty dependency blocks (`dependencies: {}`, `devDependencies: {}`, …) across the workspace",name:"empty-deps",type:Boolean},{defaultValue:!1,description:'Ensure the workspace root package.json sets `"private": true`',name:"root-private",type:Boolean},{defaultValue:!1,description:"Ensure the workspace root package.json declares a `packageManager` field",name:"root-package-manager",type:Boolean},{defaultValue:!1,description:"Flag runtime dependencies on the private workspace root (move them to devDependencies)",name:"root-deps",type:Boolean},{defaultValue:!1,description:"Flag workspace directories that lack a package.json",name:"missing-package-json",type:Boolean},{defaultValue:!1,description:"Flag workspace patterns (in `pnpm-workspace.yaml` / `package.json#workspaces`) that match zero packages",name:"dead-workspace-patterns",type:Boolean},{defaultValue:!1,description:"Flag `@types/*` declared in `dependencies` on a private package (should be in devDependencies)",name:"types-in-deps",type:Boolean},{defaultValue:!1,description:"Flag version drift across related dep families (react+react-dom, @babel/*, @storybook/*, …)",name:"similar-deps",type:Boolean},{description:"Restrict --workspace-versions to a single dep",name:"dep",type:String},{description:"Ban a dep name or glob for this run (repeatable). Auto-enables --banned-deps.",multiple:!0,name:"ban",type:String},{description:"Pin a dep to an exact specifier for this run, e.g. react@^18.2.0 (repeatable). Auto-enables --workspace-versions.",multiple:!0,name:"pin",type:String},{description:"Conflict resolution for --workspace-versions: highest, lowest, or catalog (default: highest)",name:"resolve",type:String},{description:"Propose catalog entries for deps ≥N packages already agree on. Activates with --resolve catalog.",name:"propose-min",type:Number},{defaultValue:!1,description:"Auto-fix violations in place (writes package.json files)",name:"fix",type:Boolean},{description:"Specifier used by --fix for workspace-protocol (default: workspace:*)",name:"fix-specifier",type:String},{description:"Output format: human, json, or minimal (default: human)",name:"format",type:String},{defaultValue:!1,description:"Suppress all output except errors",name:"quiet",type:Boolean}]},GE={alias:"dc",description:"Create or update .devcontainer/devcontainer.json interactively",examples:[["vis devcontainer","Launch interactive devcontainer config editor"],["vis dc","Alias for devcontainer"],["vis devcontainer --template node-pnpm","Start from Node.js + pnpm template"]],group:"Scaffold & Config",loader:()=>import("./handler76.js"),name:"devcontainer",options:[{alias:"t",description:"Start from a template: node, node-pnpm, node-postgres, node-dind, fullstack, python, go, rust, java, devops, minimal, custom",name:"template",type:String},{alias:"o",description:"Output path (default: .devcontainer/devcontainer.json)",name:"output",type:String}]},yi="Workspace",zE={commandPath:["docker"],description:"Build a minimal, cache-friendly Docker context for a focus project + its deps",examples:[["vis docker scaffold --focus=my-app","Generate .vis/docker/workspace for my-app + its deps"],["vis docker scaffold --focus=my-app --include-sources","Also copy focus source trees"],["vis docker scaffold --focus=my-app,other --out=.vis/docker","Focus multiple projects"]],group:yi,loader:Z(()=>import("./handler59.js"),"scaffoldExecute"),name:"scaffold",options:[{description:"Project name(s) to focus on — comma-separated for multiple",name:"focus",type:String},{description:"Output directory for the scaffold (default: .vis/docker)",name:"out",type:String},{defaultValue:!1,description:"Also copy focus project source trees to <out>/sources",name:"include-sources",type:Boolean},...Ge({defaultValue:!0,description:"Rewrite the workspace lockfile to drop unfocused projects (use --no-prune-lockfile to copy verbatim)",name:"prune-lockfile",type:Boolean})]},JE={commandPath:["docker"],description:"Strip unfocused workspace projects from a scaffolded context (run inside a build stage)",examples:[["vis docker prune --context=.vis/docker","Strip unfocused projects inside a build stage"]],group:yi,loader:Z(()=>import("./handler59.js"),"pruneExecute"),name:"prune",options:[{description:"Scaffold root for prune (default: .vis/docker)",name:"context",type:String}]},KE={argument:{description:"Output path for the Dockerfile (default: ./Dockerfile)",name:"path",type:String},commandPath:["docker"],description:"Generate a multi-stage Dockerfile wired to the scaffold/prune flow (create-only)",examples:[["vis docker init","Generate ./Dockerfile for the detected package manager"],["vis docker init --focus=my-app","Target a specific project's build"],["vis docker init --node=24 --force","Use Node 24 and overwrite without prompting"],["vis docker init --dry-run","Print the Dockerfile instead of writing it"]],group:yi,loader:Z(()=>import("./handler59.js"),"initExecute"),name:"init",options:[{description:"Focus project name for the build filter",name:"focus",type:String},{description:"Node.js version tag for the base image (default: 22)",name:"node",type:String},{defaultValue:!1,description:"Overwrite an existing Dockerfile without prompting",name:"force",type:Boolean},{defaultValue:!1,description:"Print the Dockerfile to stdout instead of writing it",name:"dry-run",type:Boolean}]},qE={argument:{description:"Dockerfile path(s) to lint (default: ./Dockerfile)",name:"file",type:String},commandPath:["docker"],description:"Lint a Dockerfile with hadolint (downloaded on demand); --fix applies safe autofixes",examples:[["vis docker lint","Lint ./Dockerfile (prompts to download hadolint on first use)"],["vis docker lint apps/web/Dockerfile","Lint a specific Dockerfile"],["vis docker lint --fix","Apply safe autofixes, then report what remains"],["vis docker lint --install --json","Auto-download hadolint and emit JSON"]],group:yi,loader:Z(()=>import("./handler59.js"),"lintExecute"),name:"lint",options:[{defaultValue:!1,description:"Apply safe autofixes, then re-lint and report what remains",name:"fix",type:Boolean},{defaultValue:!1,description:"Download hadolint without prompting if it is missing",name:"install",type:Boolean},{description:"Path to a hadolint config (.hadolint.yaml)",name:"config",type:String},{defaultValue:!1,description:"Emit findings as JSON",name:"json",type:Boolean}]},YE=[zE,JE,KE,qE],XE={description:"Run a full project health check (outdated, security, duplicates, optimizations)",examples:[["vis doctor","Full project health check"],["vis doctor --fix","Check and auto-apply safe fixes"],["vis doctor --format json","Machine-readable output for CI"],["vis doctor --only security","Only run the security scans"],["vis doctor --skip optimization,runtime","Skip the listed sections"],["vis doctor --quiet","Summary only, no per-section breakdown"],["vis doctor --no-progress","Disable live progress UI (sequential logs)"],["vis doctor --exit-code","Exit with code 1 if security issues found"],["vis doctor --exit-code --strict","Fail on any issue (outdated, duplicates, security)"]],group:"Security & Health",loader:()=>import("./handler70.js"),name:"doctor",options:[{description:"Output format: table or json (default: table). Alias: --json",name:"format",type:String},{defaultValue:!1,description:"Shorthand for --format json",name:"json",type:Boolean},{defaultValue:!1,description:"Exit with code 1 if issues found",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Auto-apply safe fixes (security overrides + codemods, SIGTERM orphans)",name:"fix",type:Boolean},{defaultValue:!1,description:"With --fix: escalate orphan cleanup to SIGKILL / taskkill /F (use when SIGTERM is ignored)",name:"fix-force",type:Boolean},{defaultValue:!1,description:"With --exit-code: also fail on outdated and duplicate deps",name:"strict",type:Boolean},{description:"Comma-separated sections to run: dependencies,security,optimization,runtime",name:"only",type:String},{description:"Comma-separated sections to skip",name:"skip",type:String},{defaultValue:!1,description:"Suppress per-section detail; print summary only",name:"quiet",type:Boolean},{defaultValue:!1,description:"Disable live progress UI (forces sequential logs)",name:"no-progress",type:Boolean},{defaultValue:!1,description:"Bypass the doctor result cache (~/.vis/cache/doctor)",name:"no-cache",type:Boolean},{description:"Comma-separated package name patterns to scope findings (supports * globs, e.g. '@types/*,react')",name:"filter",type:String}]},ZE={description:"Orchestrate detected formatters (prettier, …) across the workspace",examples:[["vis fmt","Apply formatting in place using every detected formatter"],["vis fmt --check","Report files that would change without writing"],["vis fmt --check --format json","Emit findings as JSON for CI / editor integrations"],["vis fmt --check --format sarif","Emit a SARIF 2.1.0 document for code-scanning uploads"],["vis fmt --check --format junit","Emit a JUnit XML report for CI dashboards"],["vis fmt --check --format github","Emit GitHub Actions workflow commands for inline PR annotations"],["vis fmt src/foo.ts src/bar.ts","Format a specific file list"],["vis fmt --quiet","Suppress per-file logs"],["vis fmt --since main","Only format files changed vs the main branch"],["vis fmt --staged","Only format files currently staged in the git index"],["vis fmt --watch","Re-run formatters when watched files change (cache makes incremental --check near-free)"],["vis fmt --check --format sarif --output fmt.sarif","Write the SARIF report to fmt.sarif instead of stdout"]],group:"Lint & Format",loader:()=>import("./handler60.js"),name:"fmt",options:[{defaultValue:!1,description:"Report files that would change without writing",name:"check",type:Boolean},{defaultValue:"human",description:"Output format: human, json, minimal, sarif, junit, or github",name:"format",type:String},{defaultValue:!1,description:"Suppress per-file logs",name:"quiet",type:Boolean},{description:"Only format files changed vs the given git ref (branch, tag, sha)",name:"since",type:String},{defaultValue:!1,description:"Only format files currently staged in the git index",name:"staged",type:Boolean},{description:"Write formatted output to a file path instead of stdout (also accepts `-`/`stdout`/`stderr`)",name:"output",type:String},{defaultValue:!1,description:"Re-run formatters whenever watched files change",name:"watch",type:Boolean}]},QE={argument:{description:"Template name (or remote source like git://… or npm://…) — omit for interactive picker",name:"template",type:String},description:"Scaffold files from an in-repo template",examples:[["vis generate","Pick a template interactively"],["vis generate package","Run the 'package' template"],["vis generate component -- --name=Button --style=primary","Pre-fill option values"],["vis generate package --to=./packages/new --force","Custom destination + overwrite"],["vis generate package --dry-run","Print planned writes without touching disk"],["vis generate git://github.com/org/template#main","Fetch and run a remote template"],["vis generate --list","Show discovered templates"],["vis generate --list --json","Machine-readable template list"],["vis generate package --describe --json","Print template metadata (variables, destination) as JSON"]],group:"Scaffold & Config",loader:()=>import("./handler61.js"),name:"generate",options:[{defaultValue:!1,description:"List discovered templates",name:"list",type:Boolean},{defaultValue:!1,description:"Print template metadata (about, destination, variables) without running produce",name:"describe",type:Boolean},{defaultValue:!1,description:"Emit JSON output (with --list or --describe)",name:"json",type:Boolean},{description:"Destination directory",name:"to",type:String},{defaultValue:!1,description:"Print planned writes without touching disk",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Overwrite existing files without prompting",name:"force",type:Boolean},{defaultValue:!1,description:"Skip prompts; use template defaults",name:"defaults",type:Boolean},{defaultValue:!1,description:"Skip running post-generation scripts",name:"skip-scripts",type:Boolean},{defaultValue:!1,description:"Skip interactive prompts (errors on missing required values)",name:"no-interactive",type:Boolean},{defaultValue:!1,description:"Prefer locally cached remote templates over re-downloading",name:"prefer-offline",type:Boolean}]},eC={description:"Visualize the project dependency graph",examples:[["vis graph","Show colored dependency graph (TUI in TTY, ASCII otherwise)"],["vis graph --format=ascii","Force ASCII tree output"],["vis graph --format=dot","Output in Graphviz DOT format"],["vis graph --format=html --output=graph.html","Generate interactive HTML graph"],["vis graph --format=json --output=graph.json","Save JSON graph to file"]],group:"Workspace",loader:()=>import("./handler73.js"),name:"graph",options:[{alias:"f",defaultValue:void 0,description:"Output format: tui, ascii, dot, json, html (default: tui in TTY, ascii otherwise)",name:"format",type:String},{alias:"o",description:"Write output to file instead of stdout",name:"output",type:String},{alias:"d",description:"Maximum dependency tree depth for ASCII output (default: unlimited)",name:"depth",type:Number}]},_t={defaultValue:to,description:"Custom hooks directory",name:"hooks-dir",type:String},Ft=[{defaultValue:void 0,description:"Set to 0 to disable git hooks, 1 to force-enable them under CI (override skipInCI), 2 for debug output",name:"VIS_GIT_HOOKS",type:String}],tC={commandPath:["hook"],description:"Install git hooks for the workspace (migrates husky / prek on prompt)",env:[...Ft],examples:[["vis hook install","Install git hooks in .vis/hooks/"],["vis hook install --hooks-dir=.githooks","Install hooks in a custom directory"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookInstallExecute})),name:"install",options:[_t]},nC={commandPath:["hook"],description:"Remove git hooks and reset core.hooksPath",env:[...Ft],examples:[["vis hook uninstall","Remove git hooks and reset core.hooksPath"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookUninstallExecute})),name:"uninstall",options:[_t]},sC={commandPath:["hook"],description:"Migrate from husky or prek to vis hooks (auto-detected)",env:[...Ft],examples:[["vis hook migrate","Migrate from husky or prek to vis hooks (auto-detected)"],["vis hook migrate --dry-run","Preview what a migration would write without touching disk"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookMigrateExecute})),name:"migrate",options:[_t,{defaultValue:!1,description:"Preview migrate without writing files",name:"dry-run",type:Boolean}]},iC={commandPath:["hook"],description:"Show configured hooks grouped by stage",env:[...Ft],examples:[["vis hook list","Show configured hooks grouped by stage"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookListExecute})),name:"list",options:[_t]},rC={commandPath:["hook"],description:"Sanity-check installed hooks and the bundled runner",env:[...Ft],examples:[["vis hook validate","Sanity-check installed hooks and the bundled runner"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookValidateExecute})),name:"validate",options:[_t]},oC={argument:{description:"Hook stage to run (e.g. pre-commit, commit-msg). Defaults to pre-commit.",name:"stage",type:String},commandPath:["hook"],description:"Run a specific hook stage against tracked files",env:[...Ft],examples:[["vis hook run pre-commit --all-files","Run the pre-commit hooks against every tracked file"],["vis hook run pre-commit --from-ref=main --to-ref=HEAD","Run pre-commit hooks on files changed between two refs"],["vis hook run pre-commit --last-commit","Shortcut for --from-ref HEAD~1 --to-ref HEAD"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookRunExecute})),name:"run",options:[_t,{defaultValue:!1,description:"Run against every tracked file",name:"all-files",type:Boolean},{defaultValue:void 0,description:"Include files changed since this ref",name:"from-ref",type:String},{defaultValue:void 0,description:"Include files changed up to this ref",name:"to-ref",type:String},{defaultValue:!1,description:"Shortcut for --from-ref HEAD~1 --to-ref HEAD",name:"last-commit",type:Boolean}]},aC={argument:{description:"Target to add (currently: `secrets`)",name:"target",type:String},commandPath:["hook"],description:"Add a managed hook snippet (e.g. `vis secrets --staged`)",env:[...Ft],examples:[["vis hook add secrets","Add a pre-commit hook that runs `vis secrets --staged`"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookAddExecute})),name:"add",options:[_t]},cC=[tC,nC,sC,iC,rC,oC,aC],lC={description:"Generate or merge an ignore file (.dockerignore/.vercelignore/.npmignore/.slugignore) without duplicate entries",examples:[["vis ignore","Print a .dockerignore (deduped against an existing one)"],["vis ignore --write","Write/merge the .dockerignore in place"],["vis ignore --target=vercel --write","Write a deduped .vercelignore"],["vis ignore --target=npm --json","Emit the npm-target result as JSON"]],group:"Scaffold & Config",loader:()=>import("./handler53.js"),name:"ignore",options:[{description:"Ignore-file target: docker | vercel | npm | slug (default: docker)",name:"target",type:String},{defaultValue:!1,description:"Write the result to disk instead of printing to stdout",name:"write",type:Boolean},{defaultValue:!1,description:"Emit the result as JSON",name:"json",type:Boolean}]},dC={description:"Remove vis from the system (self-uninstall)",examples:[["vis implode","Interactive uninstall"],["vis implode --yes","Non-interactive uninstall (CI)"]],group:"System",loader:()=>import("./handler10.js"),name:"implode",options:[{alias:"y",defaultValue:!1,description:"Skip confirmation prompt",name:"yes",type:Boolean}]},uC={argument:{description:"Source git repository URL or local path to import",name:"source",type:String},description:"Import an external repo into the monorepo under a prefix, preserving history",examples:[["vis import git@github.com:me/foo.git --prefix packages/tooling/foo","Import a repo under packages/tooling/foo"],["vis import ../foo --prefix packages/foo --ref v1.2.0","Import a specific tag/branch/commit"],["vis import ../foo --prefix packages/foo --squash","Collapse the incoming history into one commit"],["vis import ../foo --prefix packages/foo --dry-run","Print the git plan without making changes"]],group:"Workspace",loader:()=>import("./handler54.js"),name:"import",options:[{alias:"p",description:"Target directory in the monorepo (e.g. packages/tooling/foo)",name:"prefix",type:String},{alias:"r",description:"Branch, tag, or commit to import (default: HEAD)",name:"ref",type:String},{defaultValue:!1,description:"Collapse the incoming history into a single merge commit",name:"squash",type:Boolean},{alias:"m",description:"Commit message for the subtree merge",name:"message",type:String},{defaultValue:!1,description:"Do not register the package into the workspace config",name:"no-register",type:Boolean},{defaultValue:!1,description:"Print the git plan instead of executing it",name:"dry-run",type:Boolean}]},pC={alias:"view",argument:{description:"Package name followed by optional metadata fields (e.g. 'react version dependencies')",name:"args",type:String},description:"Show npm registry metadata for a package (alias of `npm view` / `pnpm view` / `yarn info` / `bun pm view`)",examples:[["vis info react","Full registry metadata for react"],["vis info react version","Latest version only"],["vis info react versions","All published versions"],["vis info react@18 dependencies","Dependencies of react@18"],["vis info react --json","Emit JSON"],["vis view react","Alias matching npm/pnpm"]],group:"Dependencies",loader:()=>import("./handler11.js"),name:"info",options:[{defaultValue:!1,description:"Output as JSON",name:"json",type:Boolean}]},fC={description:"Initialize vis.config.ts with best-practice security defaults",examples:[["vis init","Interactive setup wizard"],["vis init --no-interactive","Create minimal config without prompts"],["vis init --force","Overwrite existing config"],["vis init --sync-native","Also sync to native PM config files"],["vis init --schema","Print the workspace-relative `$schema` refs to paste into project.json and vis.config.ts"]],group:"Scaffold & Config",loader:()=>import("./handler12.js"),name:"init",options:[{defaultValue:!1,description:"Overwrite existing config file",name:"force",type:Boolean},{defaultValue:!1,description:"Skip interactive prompts",name:"no-interactive",type:Boolean},{defaultValue:!1,description:"Sync settings to native PM config files",name:"sync-native",type:Boolean},{defaultValue:!1,description:"Print workspace-relative $schema paths for project.json and vis.config.ts, then exit",name:"schema",type:Boolean}]},hC={argument:{description:"Package to inspect, optionally pinned: `<name>` or `<name>@<spec>`. `<spec>` may be a version, range, or dist-tag.",name:"package"},description:"Run all marshalls against a package without installing it",examples:[["vis inspect express","Run every marshall against express@latest"],["vis inspect lodash@4.17.21","Pin to an exact version"],["vis inspect react@^18","Resolve a semver range, then inspect the best match"],["vis inspect express --json","Emit findings as JSON for CI integration"],["vis inspect express --strict","Exit non-zero on any warning, not just errors"],["vis inspect express --only author,downloads","Run a subset of marshalls"],["vis inspect express --only signatures","Signatures are off by default; opt in with --only"]],group:"Security & Health",loader:()=>import("./handler13.js"),name:"inspect",options:[{defaultValue:!1,description:"Emit findings as a JSON document instead of the human-readable table.",name:"json",type:Boolean},{defaultValue:!1,description:"Exit non-zero on any finding (warnings included). Default exits non-zero only on errors.",name:"strict",type:Boolean},{description:"Comma-separated subset of marshalls to run. Known: author, archivedRepo, downloads, expiredDomains, metadata, newBin, provenance, signatures. Signatures only runs when explicitly requested here.",name:"only",type:String}]},mC={alias:"i",argument:{description:"Optional package names. When provided, delegates to `vis add` (enables npm-style `alias npm='vis install'` wrappers).",name:"packages",type:String},description:"Install dependencies using the detected package manager",examples:[["vis install","Install all dependencies (frozen-lockfile by default when a lockfile is present)"],["vis install react react-dom","Delegates to `vis add` — enables shell aliases like `alias npm='vis install'`"],["vis i --no-frozen-lockfile","Allow lockfile updates (escape hatch for the default)"],["vis install --ci","Clean install: wipe node_modules + frozen lockfile (mirrors npm ci / pnpm ci)"],["vis install --prefer-offline","Use cached packages when available, fall back to network"],["vis install --prod","Install production dependencies only"],["vis install --filter app","Install for specific workspace package"],["vis install --run-scripts","Run lifecycle scripts (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)"],["vis install --no-typosquat-check","Skip typosquat name check"],["vis install --installer aube","Force aube as the installer (errors if not on PATH)"],["vis install --no-aube","Bypass aube; use the lockfile-detected PM"]],group:"Dependencies",loader:()=>import("./handler14.js"),name:"install",options:[{alias:"P",conflicts:"dev",description:"Skip devDependencies (no positional args) / add as peer (with positional args, npm-style)",name:"prod",type:Boolean},{alias:"D",conflicts:"prod",description:"Install devDependencies only (no positional args) / add as dev (with positional args, npm-style)",name:"dev",type:Boolean},{defaultValue:!1,description:"Add as optional dependency (only with positional args; mirrors `npm install -O`)",name:"save-optional",type:Boolean},{alias:"E",defaultValue:!1,description:"Save exact version (only with positional args; mirrors `npm install -E`)",name:"exact",type:Boolean},{defaultValue:!1,description:"Skip Socket.dev security check (only with positional args; mirrors `vis add --no-socket-check`)",name:"no-socket-check",type:Boolean},{defaultValue:!1,description:"Skip the offline marshall pipeline (only with positional args; mirrors `vis add --no-marshall-check`)",name:"no-marshall-check",type:Boolean},{defaultValue:!1,description:"Use frozen lockfile (CI mode, maps to npm ci)",name:"frozen-lockfile",type:Boolean},{defaultValue:!1,description:"Opt out of vis's default frozen-lockfile behavior and allow lockfile updates",name:"no-frozen-lockfile",type:Boolean},{defaultValue:!1,description:"Clean install: wipe node_modules then install with frozen lockfile",name:"ci",type:Boolean},{alias:"f",defaultValue:!1,description:"Force reinstall all dependencies",name:"force",type:Boolean},{defaultValue:!1,description:"Run lifecycle scripts (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)",name:"run-scripts",type:Boolean},{defaultValue:!1,description:"Update lockfile without installing",name:"lockfile-only",type:Boolean},{defaultValue:!1,description:"Skip optional dependencies",name:"no-optional",type:Boolean},{defaultValue:!1,description:"Use only cached packages",name:"offline",type:Boolean},{defaultValue:!1,description:"Prefer cached packages, fall back to network when missing",name:"prefer-offline",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output",name:"silent",type:Boolean},{alias:"r",defaultValue:!1,description:"Install in all workspace packages",name:"recursive",type:Boolean},{alias:"w",defaultValue:!1,description:"Target workspace root",name:"workspace-root",type:Boolean},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String},{defaultValue:!1,description:"Skip typosquat name check",name:"no-typosquat-check",type:Boolean},{description:"Pick the installer explicitly. One of: auto, aube, pnpm, npm, yarn, bun. Overrides VIS_INSTALLER and install.backend in vis.config.",name:"installer",type:String},{defaultValue:!1,description:"Skip aube and use the lockfile-detected PM. Wins over --installer / VIS_INSTALLER / install.backend.",name:"no-aube",type:Boolean}]},gC={alias:"ln",argument:{description:"Package name or directory path to link (omit to register current package)",name:"target",type:String},description:"Link a local package for development",examples:[["vis link ./packages/utils","Link local directory package (works on all PMs)"],["vis link","Register current package globally (pnpm <=10, yarn, npm, bun)"],["vis link react","Link global package into current project (pnpm <=10, yarn, npm, bun)"]],group:"Dependencies",loader:()=>import("./handler16.js"),name:"link"},yC={description:"Orchestrate detected source-code linters (eslint, …) across the workspace",examples:[["vis lint","Run every detected linter against the workspace"],["vis lint --fix","Apply auto-fixes where the tool supports them"],["vis lint --format json","Emit findings as JSON for CI / editor integrations"],["vis lint --format sarif","Emit a SARIF 2.1.0 document for code-scanning uploads"],["vis lint --format junit","Emit a JUnit XML report for CI dashboards"],["vis lint --format github","Emit GitHub Actions workflow commands for inline PR annotations"],["vis lint src/foo.ts src/bar.ts","Lint a specific file list"],["vis lint --quiet","Suppress warnings — only errors are reported"],["vis lint --max-warnings 0","Treat any warning as a failure"],["vis lint --since main","Only lint files changed vs the main branch"],["vis lint --staged","Only lint files currently staged in the git index"],["vis lint --watch","Re-run linters when watched files change (cache makes incremental near-free)"],["vis lint --format sarif --output lint.sarif","Write the SARIF report to lint.sarif instead of stdout"]],group:"Lint & Format",loader:()=>import("./handler63.js"),name:"lint",options:[{defaultValue:!1,description:"Apply auto-fixes in place",name:"fix",type:Boolean},{defaultValue:"human",description:"Output format: human, json, minimal, sarif, junit, or github",name:"format",type:String},{defaultValue:!1,description:"Suppress warnings — report errors only",name:"quiet",type:Boolean},{description:"Fail the run if more than N warnings are reported",name:"max-warnings",type:Number},{description:"Only lint files changed vs the given git ref (branch, tag, sha)",name:"since",type:String},{defaultValue:!1,description:"Only lint files currently staged in the git index",name:"staged",type:Boolean},{description:"Write formatted output to a file path instead of stdout (also accepts `-`/`stdout`/`stderr`)",name:"output",type:String},{defaultValue:!1,description:"Re-run linters whenever watched files change",name:"watch",type:Boolean}]},vC={description:"List all workspace projects with metadata",examples:[["vis list","Show all projects"],["vis list --targets","Per-target rows with type, cache status and description"],["vis list --targets --inferred","Only show targets synthesized by Project Crystal-style inference"],["vis list --deps","Human-readable table of every dep-instance across the workspace"],["vis list --deps --internal-only","Only workspace deps in human form"],["vis list --deps --format=ndjson","Stream every dep-instance as NDJSON for jq pipelines"],["vis list --deps --format=json --pretty","Single pretty-printed JSON array of dep-instances"],["vis list --format=json","Machine-readable project listing"],['vis list --query "tag=frontend"',"Filter by query"],["vis list --tag=type:package","Filter by tag (shorthand for the query above)"]],group:"Workspace",loader:()=>import("./handler55.js"),name:"list",options:[{defaultValue:!1,description:"Filter target rows to only inferred targets (implies --targets)",name:"inferred",type:Boolean},{description:"Output format: table (default), json (single document), or ndjson (one record per line; --deps only)",name:"format",type:String},{defaultValue:!1,description:"Pretty-print with 2-space indent (only meaningful with --format=json)",name:"pretty",type:Boolean},{description:"Filter projects by query",name:"query",type:String},{description:'Only list projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…".',multiple:!0,name:"tag",type:String},{defaultValue:!1,description:"Show per-target rows (type, cache, description)",name:"targets",type:Boolean},{defaultValue:!1,description:"Render a dep-instance view (table by default; use --format=ndjson|json for jq-friendly streams)",name:"deps",type:Boolean},{description:"Restrict --deps to specific dep blocks (repeatable)",multiple:!0,name:"dep-type",type:String},{defaultValue:!1,description:"With --deps: only show internal/workspace deps",name:"internal-only",type:Boolean},{defaultValue:!1,description:"With --deps: only show external/registry deps",name:"external-only",type:Boolean},{description:"With --deps: glob of declaring package names to keep (repeatable)",multiple:!0,name:"include",type:String},{description:"With --deps: glob of declaring package names to drop (repeatable)",multiple:!0,name:"exclude",type:String}]},$e=[{defaultValue:!1,description:"Preview changes without applying",name:"dry-run",type:Boolean},{alias:"y",defaultValue:!1,description:"Skip the confirmation prompt",name:"yes",type:Boolean}],bC={commandPath:["migrate"],description:"Migrate dependencies and scripts to vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateDepsExecute})),name:"deps",options:[...$e]},wC={commandPath:["migrate"],description:"Inline lint-staged configuration into vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateLintStagedExecute})),name:"lint-staged",options:[...$e]},kC={commandPath:["migrate"],description:"Inline nano-staged configuration into vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateNanoStagedExecute})),name:"nano-staged",options:[...$e]},SC={commandPath:["migrate"],description:"Migrate turborepo tasks/config to vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateTurborepoExecute})),name:"turborepo",options:[...$e]},xC={commandPath:["migrate"],description:"Migrate nx targets/config to vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateNxExecute})),name:"nx",options:[...$e,{defaultValue:!1,description:"Overwrite an existing vis.config.ts (a .bak is taken first)",name:"force",type:Boolean},{defaultValue:!1,description:"For each project.json `syncGenerators`, add a `pre<target>` script to sibling package.json (with a TODO for the user to wire up)",name:"rewrite-sync-generators",type:Boolean},{defaultValue:!1,description:"Auto-apply the safe cleanup items the migrator would otherwise leave on the checklist: delete nx.json + ignore-files-for-nx-affected.yml, strip nx/@nx/*/@nrwl/* devDependencies, rewrite mechanical `nx run-many|run|affected` scripts. Implies --force.",name:"aggressive",type:Boolean}]},$C={commandPath:["migrate"],description:"Migrate moon tasks/templates to vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateMoonExecute})),name:"moon",options:[...$e,{defaultValue:!1,description:"Copy .moon/templates/* into .vis/templates/* so `vis generate` works without .moon/",name:"copy-templates",type:Boolean}]},EC={commandPath:["migrate"],description:"Migrate gitleaks config/baseline/hooks to `vis secrets`",examples:[["vis migrate gitleaks","Migrate gitleaks config/baseline/hooks to `vis secrets`"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateGitleaksExecute})),name:"gitleaks",options:[...$e]},CC={commandPath:["migrate"],description:"Migrate Kingfisher baseline/hooks/scripts to `vis secrets`",examples:[["vis migrate kingfisher","Migrate Kingfisher baseline/hooks/scripts to `vis secrets`"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateKingfisherExecute})),name:"kingfisher",options:[...$e]},RC={commandPath:["migrate"],description:"Replace secretlint with `vis secrets`",examples:[["vis migrate secretlint","Replace secretlint with `vis secrets`"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateSecretlintExecute})),name:"secretlint",options:[...$e]},jC={commandPath:["migrate"],description:"Translate syncpack customTypes into vis policy and strip the syncpack dep/scripts",examples:[["vis migrate syncpack","Translate syncpack customTypes into vis policy and strip the syncpack dep/scripts"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateSyncpackExecute})),name:"syncpack",options:[...$e]},TC={commandPath:["migrate"],description:"Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command",examples:[["vis migrate sherif","Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateSherifExecute})),name:"sherif",options:[...$e]},OC={commandPath:["migrate"],description:"Auto-rewrite vis.config.ts to use renamed fields (targetDefaults → tasks, taskDefaults → scopedTasks, taskRunnerOptions → taskRunner)",examples:[["vis migrate self","Rewrite vis.config.ts in-place (a .bak is taken first)"],["vis migrate self --dry-run","Preview the rewrite without writing"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateSelfExecute})),name:"self",options:[...$e]},AC={commandPath:["migrate"],description:"Audit the workspace for stray gitleaks/secretlint/sherif/syncpack references (exit 1 on issues)",examples:[["vis migrate verify","Audit the workspace for stray gitleaks/secretlint/sherif/syncpack references (exit 1 on issues)"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateVerifyExecute})),name:"verify",options:[]},IC={commandPath:["migrate"],description:"Prove a turbo/nx/moon → vis migration preserved the task graph + cache-key surface (exit 1 on divergence)",examples:[["vis migrate verify-graph","Auto-detect the source tool and diff its task graph against the migrated vis.config.ts"],["vis migrate verify-graph --from turbo --format json","Machine-readable equivalence report on stdout (Axis A)"],["vis migrate verify-graph --fail-on warning","Also gate CI on additive/extra-target warnings"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateVerifyGraphExecute})),name:"verify-graph",options:[{description:"Source tool to compare against (turbo|nx|moon). Auto-detected when omitted.",name:"from",type:String},{description:"Output format: table | json | ndjson (default: table)",name:"format",type:String},{description:"Exit non-zero on: error (default) | warning",name:"fail-on",type:String}]},BC={commandPath:["migrate"],description:"Run every applicable migration non-interactively (autodetected)",examples:[["vis migrate all --yes","Run every detected migration without prompting (CI-friendly)"],["vis migrate all --dry-run","Preview every detected migration without writing files"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateAllExecute})),name:"all",options:[...$e]},PC=[BC,bC,wC,kC,SC,xC,$C,OC,EC,CC,RC,jC,TC,AC,IC],NC={description:"Analyze and optimize dependencies using e18e replacements and @socketregistry overrides",examples:[["vis optimize","Interactive TUI to select and apply optimizations"],["vis optimize --dry-run","Preview available optimizations"],["vis optimize --pin","Pin Socket.dev overrides to exact versions"],["vis optimize --prod","Only optimize production dependencies"]],group:"Workspace",loader:()=>import("./handler67.js").then(e=>e.h),name:"optimize",options:[{alias:"d",defaultValue:!1,description:"Preview available optimizations without applying",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Pin Socket.dev overrides to exact versions",name:"pin",type:Boolean},{defaultValue:!1,description:"Only optimize production dependencies",name:"prod",type:Boolean},{defaultValue:!1,description:"Skip running install after applying overrides",name:"no-install",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]},DC={argument:{description:"Subcommand and arguments (e.g., cache dir, publish --dry-run, list --depth 0)",name:"args",type:String},description:"Package manager utilities (cache, publish, audit, list, config, etc.)",examples:[["vis pm cache dir","Show cache directory"],["vis pm cache clean","Clean cache"],["vis pm publish --dry-run","Preview publishing"],["vis pm list --depth 0","List direct dependencies"],["vis pm audit","Run security audit"],["vis pm whoami","Show logged-in user"]],group:"System",loader:()=>import("./handler17.js"),name:"pm"},MC={commandPath:["release"],description:"Author a new change file (interactive, or non-interactive via --packages)",examples:[["vis release add","Interactive prompt"],["vis release add --packages '@scope/cerebro:minor,@scope/string:patch' --message 'Add tab completion'","Non-interactive"],["vis release add --empty","Author an empty change file (acknowledges PR but releases nothing)"],["vis release add --name fix-tab-completion","Use a fixed slug instead of a random animal name"],["vis release add --from-bot-pr","Generate a change file from the current Dependabot / Renovate PR (changesets #647)"]],group:"Release",loader:()=>import("./handler31.js"),name:"add",options:[{description:"Comma-separated package:level pairs (e.g. '@scope/a:minor,@scope/b:patch')",name:"packages",type:String},{description:"Changelog body for the change file",name:"message",type:String},{description:"Slug for the filename (default: random animal name)",name:"name",type:String},{description:"Author an empty change file (no bumps; satisfies non-strict `check`)",name:"empty",type:Boolean},{description:"Author a `none` change file (acknowledged but no direct bump)",name:"none",type:Boolean},{description:"Inspect the current PR (via `gh pr view`) and author a change file from its Dependabot / Renovate title (changesets #647)",name:"from-bot-pr",type:Boolean}]},LC={commandPath:["release"],description:"Render the would-be changelog entries without writing to disk",examples:[["vis release changelog","Print rendered entries for the pending plan"],["vis release changelog --json","Emit ChangelogResult (with projectChangelogs[]) as JSON"]],group:"Release",loader:()=>import("./handler32.js"),name:"changelog",options:[{description:"Emit machine-readable JSON",name:"json",type:Boolean},{description:"Limit to packages matching this glob (CSV)",name:"filter",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},_C={commandPath:["release"],description:"Verify pending change files cover changed packages — CI / husky gate",examples:[["vis release check","Pass if at least one change file exists"],["vis release check --strict","Fail if any changed package isn't covered by a change file"],["vis release check --hook pre-commit","Run as a husky pre-commit hook"],["vis release check --no-fail","Print warnings but always exit 0"]],group:"Release",loader:()=>import("./handler33.js"),name:"check",options:[{description:"Require every changed package to have its own non-empty change file",name:"strict",type:Boolean},{description:"Hook context (pre-commit, pre-push) — affects which file states are counted",name:"hook",type:String},{description:"Always exit 0; warnings still print to stderr",name:"no-fail",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},FC={commandPath:["release","ci"],description:"CI: post or update a sticky PR comment with the pending release plan",examples:[["vis release ci check","Resolve PR from GITHUB_REF, post/update the release plan comment"],["vis release ci check --strict","Fail if any changed package isn't covered"]],group:"Release",loader:()=>import("./handler34.js"),name:"check",options:[{description:"Require every changed package to be covered by a change file",name:"strict",type:Boolean},{description:"Always exit 0 (warnings still print)",name:"no-fail",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},VC={commandPath:["release","ci"],description:"CI: emit JSON plan + write to $GITHUB_OUTPUT for workflow gating",examples:[["vis release ci plan","Emit { mode, packages, json } and set $GITHUB_OUTPUT"]],group:"Release",loader:()=>import("./handler35.js"),name:"plan",options:[{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},HC={commandPath:["release","ci"],description:"CI: rebase the open version-PR onto the base branch and force-push",examples:[["vis release ci rebase-pr","Rebase the version-PR branch onto base + force-push"],["vis release ci rebase-pr --branch=release/version","Override the version-PR branch"]],group:"Release",loader:()=>import("./handler36.js"),name:"rebase-pr",options:[{description:"Override the version-PR branch (default: vis-release/version-packages)",name:"branch",type:String},{description:"Override the base branch (default: release.baseBranch)",name:"base",type:String}]},WC={commandPath:["release","ci"],description:"CI: maintain a rolling version-PR (default) or version+publish inline (--auto-publish)",examples:[["vis release ci release","On push to main: open/update Versioned release PR; on PR merge: publish"],["vis release ci release --auto-publish","Skip version-PR; version + publish inline (alpha/beta workflow)"]],group:"Release",loader:()=>import("./handler56.js"),name:"release",options:[{description:"Skip version-PR; version + publish inline",name:"auto-publish",type:Boolean},{description:"Override version-PR branch (default: vis-release/version-packages)",name:"branch",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",name:"first-release",type:Boolean}]},UC={commandPath:["release","ci"],description:"CI: print setup checklist for tokens (VIS_GH_TOKEN, NPM_TOKEN, OIDC) and workflow permissions",examples:[["vis release ci setup","Walk through the recommended secrets + workflow setup"]],group:"Release",loader:()=>import("./handler37.js"),name:"setup",options:[]},GC={commandPath:["release","ci"],description:"CI: publish snapshot of affected packages + post sticky PR comment with install instructions",examples:[["vis release ci snapshot --tag pr-1234","Publish PR snapshot + post install snippet"]],group:"Release",loader:()=>import("./handler38.js"),name:"snapshot",options:[{description:"Override dist-tag (default: pr-<PR_NUMBER>)",name:"tag",type:String},{description:"PR-close cleanup mode — enumerate the closed PR's commit SHAs and remove their snapshot tags from the registry (when supported by the backend)",name:"on-close",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},zC={commandPath:["release"],description:"Preflight diagnostics for the release subsystem (workspace, PM, OIDC, NAPI, guards)",examples:[["vis release doctor","Run all checks; exit non-zero if any error"],["vis release doctor --json","Emit machine-readable report"]],group:"Release",loader:()=>import("./handler39.js"),name:"doctor",options:[{description:"Emit machine-readable JSON instead of a table",name:"json",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Bootstrap mode for greenfield monorepos: doctor asserts the workspace has no release tags and no package has been published yet. Pair with `vis release version --first-release`.",name:"first-release",type:Boolean}]},JC={commandPath:["release"],description:"Auto-derive a change file from branch commits (conventional-commits + path heuristics)",examples:[["vis release generate","Walk commits since the merge-base with baseBranch"],["vis release generate --from origin/main","Walk commits since the given ref"],["vis release generate --dry-run","Print the would-be content without writing"]],group:"Release",loader:()=>import("./handler65.js"),name:"generate",options:[{description:"Git ref to compare against (default: merge-base with baseBranch)",name:"from",type:String},{description:"Slug for the generated filename (default: random animal name)",name:"name",type:String},{description:"Print would-be content without writing",name:"dry-run",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},KC={commandPath:["release"],description:"Scaffold .vis/release; migrate from changesets / bumpy / semantic-release",examples:[["vis release init","Auto-detect source tool and scaffold"],["vis release init --from-semantic-release","Force semantic-release migration"],["vis release init --from-changesets","Force changesets migration"],["vis release init --fresh","Skip migration; start clean"],["vis release init --dry-run","Print what would happen without writing files"],["vis release init --from-semantic-release --apply","Actually perform the semantic-release migration writes"]],group:"Release",loader:()=>import("./handler40.js"),name:"init",options:[{description:"Force migration from semantic-release / multi-semantic-release",name:"from-semantic-release",type:Boolean},{description:"Force migration from changesets",name:"from-changesets",type:Boolean},{description:"Force migration from bumpy",name:"from-bumpy",type:Boolean},{description:"Skip migration; start clean",name:"fresh",type:Boolean},{description:"Print what would happen without writing files",name:"dry-run",type:Boolean},{alias:"y",description:"Auto-confirm prompts (CI-safe)",name:"yes",type:Boolean},{description:"Generate CI workflow files. GitHub → `.github/workflows/vis-release{,-check,-snapshot}.yml`. GitLab → `.gitlab-ci.yml`.",name:"workflows",type:Boolean},{description:"Override package manager when generating workflows (npm | pnpm | yarn | bun). Default: auto-detect",name:"package-manager",type:String},{description:"Actually perform the migration writes (not dry-run)",name:"apply",type:Boolean},{description:"Append a 'Releasing with vis' section to AGENTS.md so AI agents know how to drive the release flow",name:"agent",type:Boolean}]},qC={commandPath:["release"],description:"Print the next computed version for each package in the release plan. Read-only; no mutations.",examples:[["vis release next-version","Print `<pkg> <old> -> <new>` for every package in the plan"],["vis release next-version --package=@scope/a","Single-package mode"],["vis release next-version --json","Emit a `{ name: { from, to } }` JSON map"]],group:"Release",loader:()=>import("./handler41.js"),name:"next-version",options:[{description:"Limit output to a single package",name:"package",type:String},{description:"Emit a JSON `{ name: { from, to } }` map instead of pretty lines",name:"json",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Bootstrap mode for greenfield monorepos: preview the plan without registry / tag lookups (matches `vis release version --first-release`).",name:"first-release",type:Boolean}]},YC={commandPath:["release"],description:"Dry-run the configured notification channels (slack / discord / webhook / plugins) with a synthetic release",examples:[["vis release notifications test","Dispatch a fake release to every configured channel"],["vis release notifications test --channel=slack","Dispatch to every Slack channel only"],["vis release notifications test --channel=slack:eng","Dispatch to the slack channel with id=eng only"],["vis release notifications test --custom-context=./fake.json","Use operator-supplied JSON instead of the built-in synthetic release"],["vis release notifications test --json","Emit machine-readable results"]],group:"Release",loader:()=>import("./handler42.js"),name:"notifications",options:[{defaultOption:!0,defaultValue:"test",description:"Subcommand: test",name:"action",type:String},{description:"Restrict dispatch to a single channel kind (`slack`, `discord`, `webhook`) or an id'd channel (`slack:eng`)",name:"channel",type:String},{description:"Path to a JSON file containing a NotificationContext to use instead of the synthetic default",name:"custom-context",type:String},{description:"Emit machine-readable JSON instead of a per-channel report",name:"json",type:Boolean}]},XC={commandPath:["release"],description:"Inspect the release plan; with --interactive, walk through and override bump levels",examples:[["vis release plan","Emit pending plan as JSON"],["vis release plan --interactive","Walk through pending releases, accept or override each bump"],["vis release plan -i --write","Walk through interactively and write the chosen overrides to a change file"]],group:"Release",loader:()=>import("./handler43.js"),name:"plan",options:[{description:"Filter packages by name glob",name:"filter",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{alias:"i",description:"Walk through pending releases interactively and accept / override each bump level",name:"interactive",type:Boolean},{description:"When used with --interactive, write the chosen overrides to a new change file (.vis/release/<id>.md)",name:"write",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},ZC={commandPath:["release"],description:"Enter / exit pre-release mode (changesets-compatible — every `version` produces a prerelease until exit)",examples:[["vis release pre enter alpha","Enter pre-mode with the `alpha` tag"],["vis release pre enter rc --no-commit","Enter pre-mode locally without committing pre.json"],["vis release pre exit","Flag the next `version` to consolidate + exit pre-mode"],["vis release pre status","Print whether pre-mode is active, exit-pending, or off"]],group:"Release",loader:()=>import("./handler45.js"),name:"pre",options:[{defaultOption:!0,defaultValue:"status",description:"Subcommand: enter | exit | status",name:"action",type:String},{description:"Prerelease tag (e.g. alpha, beta, rc). Required for `enter`",multiple:!0,name:"tag",type:String},{defaultValue:!0,description:"Commit pre.json after writing. Default: commit",name:"commit",type:Boolean},{defaultValue:!0,description:"Push the commit. Default: push",name:"push",type:Boolean}]},QC={commandPath:["release"],description:"Publish non-functional placeholder packages so npm Trusted Publishing (OIDC) can be configured before the first release",examples:[["vis release pretrust","Publish a placeholder for every managed package missing from the registry"],["vis release pretrust --filter '@scope/*'","Limit to a glob"],["vis release pretrust --dry-run","Print what would be published without uploading"]],group:"Release",loader:()=>import("./handler57.js"),name:"pretrust",options:[{description:"Glob filter (CSV) — limit to specific packages",name:"filter",type:String},{description:"dist-tag for the placeholder (default: placeholder — keeps `latest` unset)",name:"tag",type:String},{description:"Placeholder version (default: 0.0.0)",name:"version",type:String},{description:"Publish access: public | restricted (default: public)",name:"access",type:String},{description:"Override registry URL",name:"registry",type:String},{description:"Publish a placeholder even if the package already exists on the registry",name:"force",type:Boolean},{description:"Skip the `npm trust` step (only publish placeholders)",name:"no-trust",type:Boolean},{description:"Trust claim: forge provider (github | gitlab). Default: auto-detect from the git remote",name:"provider",type:String},{description:"Trust claim: owner/repo (github) or group/project (gitlab). Default: detect from git remote",name:"repo",type:String},{description:"Trust claim: workflow/pipeline filename (npm trust --file). Default: auto-detect the release workflow",name:"workflow",type:String},{description:"Trust claim: restrict to a deployment environment (npm trust --env)",name:"env",type:String},{description:"Trust claim: also grant the staged-publish permission (--allow-stage-publish)",name:"allow-stage-publish",type:Boolean},{description:"Print what would publish without uploading",name:"dry-run",type:Boolean},{description:"Print the resolved release config and exit",name:"print-config",type:String}]},eR={commandPath:["release"],description:"Pack-then-publish unpublished packages, push tags, create GH releases",examples:[["vis release publish","Publish all pending packages"],["vis release publish --dry-run","Print what would publish without uploading"],["vis release publish --tag alpha","Override dist-tag"],["vis release publish --filter '@scope/*'","Limit to packages matching the glob"]],group:"Release",loader:()=>import("./handler46.js"),name:"publish",options:[{description:"Skip uploads — print what would happen",name:"dry-run",type:Boolean},{description:"Override npm dist-tag",name:"tag",type:String},{description:"Limit to packages matching this glob (CSV)",name:"filter",type:String},{description:"Skip `git push --tags` after publish (lands in M5)",name:"no-push",type:Boolean},{description:"2FA OTP token",name:"otp",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Resume from a previous run's state file (skips already-published packages)",name:"resume",type:Boolean},{description:"Run preflight checks (config + workspace + plan + auth) and exit. No mutations.",name:"check-only",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",name:"first-release",type:Boolean}]},tR={commandPath:["release"],description:"Publish 0.0.0-<tag>-<sha> snapshot versions of affected packages",examples:[["vis release snapshot --tag pr-1234","Publish snapshots tagged with the PR number"],["vis release snapshot --tag canary --filter '@scope/*'","Limit to a glob"],["vis release snapshot --tag pr-1234 --dry-run","Preview without uploading"]],group:"Release",loader:()=>import("./handler47.js"),name:"snapshot",options:[{description:"Required: dist-tag for the snapshot release",name:"tag",type:String},{description:"Override registry URL (defaults to pkg-pr-new backend or `release.snapshot.registry`)",name:"registry",type:String},{description:"Glob filter (CSV) — limit snapshots to specific packages",name:"filter",type:String},{description:"Print what would publish without uploading",name:"dry-run",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},nR={commandPath:["release"],description:"List, approve, or reject npm staged-publish records (RFC §13.6 — approve/reject need 2FA)",examples:[["vis release stage list","List every staged version (both npm + the local .vis/release/staged.json registry)"],["vis release stage list @scope/pkg","List staged versions for a single package"],["vis release stage list --json","Emit a machine-readable view of both sources"],["vis release stage approve <stage-id>","Promote a staged version, drain it from staged.json, commit + push the registry"],["vis release stage approve --all","Approve every pending stage tracked in .vis/release/staged.json"],["vis release stage reject <stage-id>","Reject a staged version (permanent — cannot be re-approved unless re-staged)"],["vis release stage approve <stage-id> --no-push","Approve, update the registry, commit locally (skip the push)"],["vis release stage approve <stage-id> --no-commit","Approve and update the registry only — no git commit"]],group:"Release",loader:()=>import("./handler48.js"),name:"stage",options:[{defaultOption:!0,defaultValue:"list",description:"Subcommand: list | approve | reject",name:"action",type:String},{description:"Stage IDs (positional args after the action)",multiple:!0,name:"stage-ids",type:String},{description:"Approve every pending stage tracked in .vis/release/staged.json",name:"all",type:Boolean},{description:"Package name filter for `list`",name:"filter",type:String},{description:"Emit machine-readable JSON",name:"json",type:Boolean},{defaultValue:!0,description:"Update .vis/release/staged.json but skip the auto-commit. Default: commit",name:"commit",type:Boolean},{defaultValue:!0,description:"Skip pushing the registry commit to the remote. Default: push",name:"push",type:Boolean}]},sR={commandPath:["release"],description:"Print pending release plan (which packages will bump and to what version)",examples:[["vis release status","Print pending plan in human-readable format"],["vis release status --json","Emit the plan as JSON for scripting / CI"],["vis release status --bump major,minor","Filter to packages getting major or minor bumps"],["vis release status --filter '@scope/*'","Show only packages matching the glob"]],group:"Release",loader:()=>import("./handler44.js"),name:"status",options:[{description:"Emit machine-readable JSON instead of a table",name:"json",type:Boolean},{description:"Filter packages by name glob",name:"filter",type:String},{description:"Filter by bump level (CSV: major,minor,patch)",name:"bump",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},iR={commandPath:["release"],description:"Apply pending change files to disk: bump versions + write CHANGELOG entries",examples:[["vis release version","Apply the plan to disk"],["vis release version --dry-run","Print what would change without touching disk"],["vis release version --channel alpha","Force a specific channel (overrides branch detection)"]],group:"Release",loader:()=>import("./handler49.js"),name:"version",options:[{description:"Skip writes — print the diff and exit",name:"dry-run",type:Boolean},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Limit to packages matching this glob (CSV)",name:"filter",type:String},{description:"Auto-commit after applying",name:"commit",type:Boolean},{description:"Run preflight checks (config + workspace + plan) and exit. No mutations.",name:"check-only",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",name:"first-release",type:Boolean}]},rR=[MC,JC,sR,XC,LC,_C,zC,qC,iR,eR,tR,nR,ZC,QC,KC,YC,FC,VC,WC,HC,GC,UC],oR={alias:["rm","un","uninstall"],argument:{description:"Packages to remove",name:"packages",type:String},description:"Remove packages using the detected package manager",examples:[["vis remove lodash","Remove a package"],["vis rm old-package","Remove using alias"],["vis remove --filter app react","Remove from specific workspace"],["vis remove -g typescript","Remove global package"]],group:"Dependencies",loader:()=>import("./handler18.js"),name:"remove",options:[{alias:"D",defaultValue:!1,description:"Remove from devDependencies",name:"save-dev",type:Boolean},{alias:"g",defaultValue:!1,description:"Remove global package",name:"global",type:Boolean},{alias:"r",defaultValue:!1,description:"Remove from all workspace packages",name:"recursive",type:Boolean},{alias:"w",defaultValue:!1,description:"Remove from workspace root",name:"workspace-root",type:Boolean},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String}]},aR={description:"Replay a previous task run from .vis/runs/ — show task results without re-executing",examples:[["vis replay","Show the most recent run summary"],["vis replay --run 2026-04-28T12-34-56_ab12","Inspect a specific historical run"],["vis replay --list","List every recorded run, newest first"],["vis replay --task @myorg/app:build","Focus on one task within the loaded run"],["vis replay --failed","Filter to only failed tasks"],["vis replay --format=json","Machine-readable output for CI"]],group:"Workspace",loader:Z(()=>import("./handler19.js"),"replayExecute"),name:"replay",options:[{description:"Run id to replay (defaults to the most recent run)",name:"run",type:String},{defaultValue:!1,description:"List every available run instead of replaying one",name:"list",type:Boolean},{description:"Filter the replay to a single task id (e.g. @my/app:build)",name:"task",type:String},{defaultValue:!1,description:"Filter the replay to failed tasks only",name:"failed",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]},cR={argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target across workspace projects",examples:[["vis run","List all available targets"],["vis run build","Run build on all projects"],["vis run :build","Run build on all projects (moon-style)"],["vis run ~:test","Run test on the project closest to the current directory"],['vis run "#frontend:build"',"Run build on projects tagged 'frontend'"],['vis run :build --query "language=typescript"',"Filter by project metadata"],['vis run build --filter "@org/web"',"Run build on a single package (pnpm filter)"],['vis run build --filter "...@org/web"',"Run build on @org/web and everything that depends on it"],['vis run build -F "@org/web..."',"Run build on @org/web and its dependencies"],['vis run build -F "...[origin/main]"',"Run build on packages changed since origin/main + their dependents"],['vis run build -F "./packages/*"',"Run build on packages matched by a path glob"],["vis run test --affected","Run test only on git-changed projects"],["vis run build --fail-fast","Stop on first failure"],["vis run build --dry-run","Show execution plan without running"],["vis run destroy --reverse","Run leaves-first (teardown order, e.g. CDK/Pulumi destroy)"]],group:"Run & Execute",loader:()=>import("./handler77.js"),name:"run",options:[{alias:"p",description:"Comma-separated list of projects to run",name:"projects",type:String},{alias:"F",description:"pnpm-style package selector (repeatable). Supports name globs (@org/*), graph modifiers (...pkg dependents, pkg... dependencies, ...^pkg / pkg^... exclude self), changed-since ([main], ...[origin/main]), and path globs (./packages/*, {glob}).",multiple:!0,name:"filter",type:String},{defaultValue:!1,description:"Skip the toolchain pre-flight (no auto-install for any pinned tool: node / pnpm / yarn / npm / bun / deno / go / python / ruby / rust)",name:"skip-toolchain",type:Boolean},...Ge({description:"Detect lockfile/node_modules drift before running (warns in TTY, fails in CI). Use --no-preflight to disable.",name:"preflight",type:Boolean}),{defaultValue:3,description:"Maximum number of parallel tasks (falls back to VIS_RUN_CONCURRENCY_LIMIT env var, then 3)",name:"parallel",type:Number},...Ge({defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean}),{description:"Comma-separated selectors of tasks to bypass cache for (e.g. 'app:test', ':e2e', '#flaky:lint'). Other tasks in the run still cache normally. --no-cache wins when both are set.",name:"skip-cache",type:String},{description:"Custom cache directory",name:"cache-dir",type:String},{description:"Remote cache mode: read | write | readwrite (defaults to readwrite when remoteCache is configured)",name:"cache-mode",type:String},{description:"Remote cache wire backend: http (Turborepo-compatible) or reapi (Bazel Remote Execution API gRPC)",name:"cache-backend",type:String},{description:"Override how the requested target is hashed for this run: declared (hash listed inputs) or trace (hash the files the task actually reads). Overrides per-target hashMode config for the directly-run target.",name:"hash-mode",type:String},{defaultValue:!1,description:"Show what would run without executing",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Generate a run summary after execution",name:"summarize",type:Boolean},{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',name:"partition",type:String},{defaultValue:!1,description:"Skip project constraint validation",name:"skip-constraints",type:Boolean},{description:"Filter matched projects by a query (e.g. 'language=typescript && tag=lib')",name:"query",type:String},{description:'Only run projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…"; combines with --query as AND.',multiple:!0,name:"tag",type:String},{defaultValue:!1,description:"Only run on projects affected by git changes. Honors --base/--head/--downstream/--upstream, same as `vis affected`.",name:"affected",type:Boolean},{description:"Git base ref for --affected. When omitted, vis auto-resolves it from the active CI provider (GitHub/GitLab/Buildkite/CircleCI) or falls back to `git merge-base HEAD origin/<defaultBase>` locally. Default base branch comes from `vis.config.ts#defaultBase` (or `main`). Requires --affected.",name:"base",type:String},{description:"Git head ref for --affected. When omitted, auto-resolves from CI env (e.g. `$GITHUB_SHA`) or defaults to `HEAD`. Requires --affected.",name:"head",type:String},{description:'Downstream scope for --affected: "none", "direct", or "deep" — controls how far to include dependents of changed projects (default "deep"). Requires --affected.',name:"downstream",type:String},{description:'Upstream scope for --affected: "none", "direct", or "deep" — controls how far to include dependencies of changed projects (default "none"). Requires --affected.',name:"upstream",type:String},...Ge({description:"Include uncommitted working-tree changes when computing --affected. Defaults to on for local runs and off in CI; use --no-uncommitted to force off.",name:"uncommitted",type:Boolean}),{defaultValue:!1,description:"Rerun affected tasks on file change. Ctrl+C to exit.",name:"watch",type:Boolean},{defaultValue:!1,description:"Stop all tasks on first failure",name:"fail-fast",type:Boolean},{defaultValue:!1,description:"Run the dependency graph in reverse (leaves first, then their dependents). Useful for teardown targets like `destroy`/`undeploy` where dependents must run before the things they depend on.",name:"reverse",type:Boolean},{description:"Output mode: interleaved (pass-through), labeled (prefix each line with [pkg#task]), or grouped (vite-task-style block)",name:"log",type:String},{description:"Output style: normal (print every task) or quiet (skip output for successful/cached tasks; failed tasks still print in CI mode, and remain in TUI scrollback in interactive mode). Defaults to normal; set run.quietOnSuccess in config to make quiet the default. Per-target options.outputStyle overrides this.",name:"output-style",type:String},{defaultValue:!1,description:"Run every task through a pseudo-terminal so color-aware tools render as if attached to a TTY (disables caching)",name:"pty",type:Boolean},{description:"Global retry budget: cap on total task retries across the run (per-target retryCount is still honored up to the budget)",name:"retry-budget",type:Number},{description:"Write a Chrome Tracing JSON profile of the run to this path (open in chrome://tracing or Perfetto)",name:"profile",type:String},{defaultValue:!1,description:"Render the most-recent run's saved summary (from .vis/last-summary.json) and exit without executing any tasks",name:"last-details",type:Boolean},...Ge({defaultValue:!0,description:"Show flaky task report on failure (use --no-flaky to suppress)",name:"flaky",type:Boolean}),{defaultValue:!1,description:"Treat any task that needed at least one retry as a run failure (exit non-zero), even when retries eventually succeeded. Use in CI to surface flakes that retries would otherwise mask.",name:"fail-on-retry",type:Boolean},...Ge({description:"Fail a task if its command references an env var that is unset (no silent empty-string substitution). Use --no-strict-env to disable when set in config.",name:"strict-env",type:Boolean}),{description:"Comma-separated tags this runner advertises (e.g. 'gpu,slow'). Tasks declaring `options.runnerTags` only run when at least one tag overlaps. Untagged tasks always run. Falls back to VIS_RUNNER_TAGS env var.",name:"runner-tags",type:String},{description:"Auto-start service deps. One of: auto | ephemeral | persistent | off. Defaults to `auto` in TTY, `off` in CI.",name:"services",type:String},{defaultValue:!1,description:"Stop services this run auto-started in registry mode when the run exits (clean, q, or Ctrl+C). Ephemeral services already die with the run.",name:"stop-services",type:Boolean}]},lR={description:"Generate a CycloneDX 1.7 Software Bill of Materials for the workspace",examples:[["vis sbom","Write the full-workspace SBOM to sbom.cdx.json"],["vis sbom --focus=my-app","Scope the SBOM to my-app's transitive closure"],["vis sbom --focus=my-app,other","Focus multiple projects"],["vis sbom --format=xml --output=sbom.cdx.xml","Emit XML instead of JSON"],["vis sbom --include-dev","Include devDependencies (default: production only)"],["vis sbom --output=-","Write to stdout"]],group:"Security & Health",loader:()=>import("./handler20.js"),name:"sbom",options:[{description:"Project name(s) to focus on — comma-separated for multiple",name:"focus",type:String},{defaultValue:"json",description:"Output format: json (default) or xml",name:"format",type:String},{description:"Output path (use '-' for stdout; default: sbom.cdx.json)",name:"output",type:String},{defaultValue:!1,description:"Include devDependencies (default: production only)",name:"include-dev",type:Boolean}]},dR={argument:{description:"One or more paths to scan (defaults to workspace root)",name:"paths",type:String},description:"Scan a repository for hardcoded secrets and credentials",examples:[["vis secrets","Scan the workspace with grouped, colourised output"],["vis secrets --staged","Scan only files staged for the current commit (pre-commit hooks)"],["vis secrets --since main","Scan only files changed since the `main` branch"],["vis secrets --affected","Scan only projects affected by the current branch"],["vis secrets --history","Scan the full git history for secrets that were committed then removed"],["vis secrets --history --history-range main..HEAD","Scan only commits on the current branch since main"],["vis secrets --history --max-commits 100 --redact","Scan the last 100 commits, masking any secret values"],["vis secrets --init","Write an initial baseline from current findings"],["vis secrets --list-rules","Print all bundled detection rules"],["vis secrets --list-validators","Print non-HTTP validator types in the ruleset + install hints for each"],["vis secrets --exclude-rule generic-api-key --exclude-rule aws-access-token","Drop noisy rules"],["vis secrets --include-rule stripe-access-token","Check a single rule"],["vis secrets --enable-rule tag:preset:weak-passwords","Enable an opt-in rule group additively (defaults still fire)"],["vis secrets --include-rule tag:preset:password-manager","Restrict output to one opt-in group only"],["vis secrets --min-confidence high","Drop rules without a high confidence label (CI-friendly precision filter)"],["vis secrets --validate --only-verified","Live-verify each finding against its provider (one HTTP call per finding)"],["vis secrets --exclude 'dist/**' --exclude-from .secretsignore","Extra gitignore-syntax exclusions for the walker"],["vis secrets --config ./leaks.json --no-extend-bundled","Use only the supplied config, skip the bundled ruleset"],["vis secrets --concurrency 4","Cap the rayon thread pool (0 / omit = auto)"],["vis secrets --baseline .secrets-baseline.json","Suppress known findings; print diff vs. baseline"],["vis secrets --update-baseline","Merge current findings into the baseline (use --replace-baseline to overwrite)"],["vis secrets --format sarif > report.sarif","SARIF output for GitHub code-scanning"]],group:"Security",loader:()=>import("./handler78.js"),name:"secrets",options:[{description:"Path to a JSON config (gitleaks-compatible shape). Defaults to the bundled ruleset.",name:"config",type:String},{description:"Drop rules below this author-declared confidence: low (default), medium, high. Rules without a declared confidence (every gitleaks rule) are treated as low, so --min-confidence medium or higher drops them along with explicit low-confidence rules.",name:"min-confidence",type:String},{defaultValue:!1,description:"Live-verify each finding against its provider (one HTTP call per finding, max 8 concurrent). Only supports Kingfisher-style HTTP validators with StatusMatch / WordMatch response matchers; other types (gRPC, multi-step, checksum) mark the finding as validation=skipped. WARNING: sends candidate secrets to the provider — some providers alert their security team on failed auth attempts.",name:"validate",type:Boolean},{defaultValue:!1,description:"With --validate, drop every finding whose validation is not 'verified'. Useful for CI gating.",name:"only-verified",type:Boolean},{defaultValue:!1,description:"With --config, do not merge on top of the bundled ruleset — replace it.",name:"no-extend-bundled",type:Boolean},{defaultValue:"text",description:"Output format: text (default), json, sarif",name:"format",type:String},{description:"Path to a baseline JSON of previously-triaged findings",name:"baseline",type:String},{defaultValue:!1,description:"Scan only files staged for commit",name:"staged",type:Boolean},{description:"Scan only files changed since <ref> (e.g. main, origin/HEAD)",name:"since",type:String},{defaultValue:!1,description:"Scan only projects affected by the current branch",name:"affected",type:Boolean},{defaultValue:!1,description:"Scan the entire git history (every added/modified blob across commits) instead of the working tree. Surfaces secrets that were committed and later removed. Cannot be combined with --staged/--since/--affected.",name:"history",type:Boolean},{description:"With --history, limit the walk to a rev-list range (e.g. main..HEAD, HEAD~50..HEAD, or a single ref). Defaults to all reachable history of HEAD.",name:"history-range",type:String},{description:"With --history, cap the number of commits walked (most-recent first)",name:"max-commits",type:Number},{description:"Enable an opt-in rule or tag without restricting output — additive (e.g. tag:preset:weak-passwords, tag:preset:password-manager). Repeatable.",multiple:!0,name:"enable-rule",type:String},{description:"Rule id or tag:<name> selector — whitelist, only matching findings are emitted. Implies enablement. Repeatable.",multiple:!0,name:"include-rule",type:String},{description:"Rule id or tag:<name> selector — drop matching findings. Repeatable.",multiple:!0,name:"exclude-rule",type:String},{description:"Gitignore-syntax pattern to exclude from the walk (repeatable)",multiple:!0,name:"exclude",type:String},{description:"Path to a gitignore-shaped file the walker should honor (repeatable)",multiple:!0,name:"exclude-from",type:String},{defaultValue:!1,description:"Mask secret values in output",name:"redact",type:Boolean},{defaultValue:!1,description:"Scan dotfiles",name:"include-hidden",type:Boolean},{defaultValue:!1,description:"Do not respect .gitignore",name:"no-gitignore",type:Boolean},{description:"Skip files larger than this (bytes). Default: 10 MiB",name:"max-size",type:Number},{description:"Rayon worker threads (0 / omit = auto)",name:"concurrency",type:Number},{defaultValue:!1,description:"Merge current findings into the baseline and exit 0",name:"update-baseline",type:Boolean},{defaultValue:!1,description:"With --update-baseline, replace rather than merge",name:"replace-baseline",type:Boolean},{defaultValue:!1,description:"Scaffold a baseline from current findings",name:"init",type:Boolean},{defaultValue:!1,description:"With --init, preview the baseline without writing files",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Print all bundled detection rules and exit",name:"list-rules",type:Boolean},{defaultValue:!1,description:"Print non-HTTP validator types referenced by the current ruleset, with install hints for their optional peer dependencies.",name:"list-validators",type:Boolean},{defaultValue:!1,description:"Suppress all progress output (only emit findings)",name:"quiet",type:Boolean},{defaultValue:!1,description:"Print diagnostic info (skipped rules, etc.)",name:"verbose",type:Boolean}]},uR={commandPath:["security"],description:"List build-script status — allowed, unapproved, and stale allowlist entries",examples:[["vis security list","Show the full build-script triage report"],["vis security list --json","Emit the report as JSON for tooling"]],group:"Security & Health",loader:()=>import("./list.js"),name:"list",options:[{defaultValue:!1,description:"Emit the report as JSON instead of human-readable text",name:"json",type:Boolean}]},pR={commandPath:["security"],description:"Push vis.config security settings to the package manager's native config",examples:[["vis security sync","Sync allowBuilds + minimumReleaseAge to the PM-native config files"],["vis security sync --skip-allow-builds","Sync only the minimumReleaseAge knobs"],["vis security sync --skip-min-release-age","Sync only allowBuilds (trustedDependencies / onlyBuiltDependencies)"]],group:"Security & Health",loader:()=>import("./sync2.js"),name:"sync",options:[{defaultValue:!1,description:"Skip syncing allowBuilds (trustedDependencies, onlyBuiltDependencies)",name:"skip-allow-builds",type:Boolean},{defaultValue:!1,description:"Skip syncing minimumReleaseAge and its excludes",name:"skip-min-release-age",type:Boolean}]},fR={commandPath:["security"],description:"Run lifecycle scripts for packages in security.policies.installScripts.allow (LavaMoat 'run' parity)",examples:[["vis security run","Run preinstall/install/postinstall for every approved package"],["vis security run --with-root","Also run the workspace root's prepublish + prepare hooks"],["vis security run --root-only","Run only the workspace root's prepublish + prepare hooks"]],group:"Security & Health",loader:()=>import("./run.js"),name:"run",options:[{defaultValue:!1,description:"Also run the workspace root's prepublish + prepare hooks after dependencies",name:"with-root",type:Boolean},{defaultValue:!1,description:"Skip dependency scripts and only run the workspace root's prepublish + prepare hooks",name:"root-only",type:Boolean}]},hR={commandPath:["security"],description:"Install @lavamoat/preinstall-always-fail as a devDep so a missing ignore-scripts setting fails loudly",examples:[["vis security tripwire","Install the tripwire devDependency"],["vis security tripwire --status","Report whether the tripwire is installed"],["vis security tripwire --remove","Remove the tripwire from package.json"]],group:"Security & Health",loader:()=>import("./tripwire.js"),name:"tripwire",options:[{defaultValue:!1,description:"Report whether @lavamoat/preinstall-always-fail is installed",name:"status",type:Boolean},{defaultValue:!1,description:"Remove @lavamoat/preinstall-always-fail from package.json",name:"remove",type:Boolean}]},mR={commandPath:["security"],description:"Force-refresh the cached npm signing keys used by the signatures marshall",examples:[["vis security keys-refresh","Drop the disk cache and fetch a fresh key set from registry.npmjs.org"],["vis security keys-refresh --clear","Only drop the cache, do not refetch"],["vis security keys-refresh --json","Emit the refresh result as JSON for tooling"]],group:"Security & Health",loader:()=>import("./keys-refresh.js"),name:"keys-refresh",options:[{defaultValue:!1,description:"Only clear the cache, do not refetch",name:"clear",type:Boolean},{defaultValue:!1,description:"Emit the result as JSON instead of human-readable text",name:"json",type:Boolean}]},gR={commandPath:["security"],description:"Verify the entire lockfile closure against supply-chain policies (firstSeen, publisherChange, blockExoticSubdeps)",examples:[["vis security verify-lockfile","Re-validate every locked entry; exit non-zero on a policy violation"],["vis security verify-lockfile --offline","Verify without network (skips firstSeen / publisherChange)"],["vis security verify-lockfile --json","Emit the verification result as JSON for CI"]],group:"Security & Health",loader:()=>import("./verify-lockfile.js"),name:"verify-lockfile",options:[{defaultValue:!1,description:"Emit the result as JSON instead of human-readable text",name:"json",type:Boolean},{defaultValue:!1,description:"Skip network-bound policies (firstSeen, publisherChange)",name:"offline",type:Boolean}]},yR=[uR,pR,fR,hR,mR,gR],vi={description:"Target id, e.g. @my/api:db",name:"targetId",type:String},vR={description:"Output format: table or json (default: table)",name:"format",type:String},bR={argument:vi,commandPath:["service"],description:"Start a service target detached so it survives across `vis run` invocations",examples:[["vis service start @my/api:db","Boot the db target as a long-lived service"],["vis service start @my/api:db --timeout=60000","Override readiness timeout"],["vis service start @my/api:db --no-readiness","Skip the readiness probe"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceStartExecute"),name:"start",options:[{description:"Readiness probe timeout in milliseconds",name:"timeout",type:Number},{defaultValue:!1,description:"Skip the readiness probe",name:"no-readiness",type:Boolean}]},wR={argument:{description:"Target id to stop, or omit when using --all",name:"targetId",required:!1,type:String},commandPath:["service"],description:"Stop a running service",examples:[["vis service stop @my/api:db","Stop the db service"],["vis service stop --all","Stop every running service in this workspace"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceStopExecute"),name:"stop",options:[{defaultValue:!1,description:"Stop every service registered for this workspace",name:"all",type:Boolean},{description:"Override the SIGTERM→SIGKILL grace period in milliseconds",name:"grace-ms",type:Number}]},kR={commandPath:["service"],description:"List services registered for this workspace",examples:[["vis service list","Print running services"],["vis service list --format=json","Machine-readable list"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceListExecute"),name:"list",options:[vR]},SR={argument:vi,commandPath:["service"],description:"Re-run the readiness probe and report a service's health",examples:[["vis service status @my/api:db","Check whether the db service is reachable"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceStatusExecute"),name:"status",options:[{description:"Probe timeout in milliseconds",name:"timeout",type:Number}]},xR={argument:vi,commandPath:["service"],description:"Stop and re-start a running service",examples:[["vis service restart @my/api:db","Recycle the db service"],["vis service restart @my/api:db --no-readiness","Recycle and skip the readiness probe"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceRestartExecute"),name:"restart",options:[{description:"Readiness probe timeout in milliseconds",name:"timeout",type:Number},{description:"Override the SIGTERM→SIGKILL grace period in milliseconds",name:"grace-ms",type:Number},{defaultValue:!1,description:"Skip the readiness probe after restart",name:"no-readiness",type:Boolean}]},$R={argument:vi,commandPath:["service"],description:"Print or tail a service's captured stdout/stderr",examples:[["vis service logs @my/api:db","Print the captured log"],["vis service logs @my/api:db -f","Tail the log (Ctrl-C to exit)"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceLogsExecute"),name:"logs",options:[{alias:"f",defaultValue:!1,description:"Follow the log file (like `tail -f`)",name:"follow",type:Boolean}]},ER=[bR,wR,kR,SR,xR,$R],CR={commandPath:["shim"],description:"Install project-local PM shims (.vis/shims) that enforce the project's package manager",examples:[["vis shim install","Write npm/pnpm/yarn/… wrapper scripts in .vis/shims"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimInstallExecute})),name:"install"},RR={commandPath:["shim"],description:"Remove the project-local PM shim dir (.vis/shims)",examples:[["vis shim uninstall","Delete .vis/shims"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimUninstallExecute})),name:"uninstall"},jR={commandPath:["shim"],description:"Report whether the PM shims are installed and active on PATH",examples:[["vis shim status","Show shim install + PATH state"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimStatusExecute})),name:"status"},TR=[CR,RR,jR],OR={description:"Sort package.json files across the workspace using the sort-package-json Rust crate",examples:[["vis sort-package-json","Sort all package.json files in the workspace"],["vis sort-package-json --check","Check if files are already sorted (exit 1 if not)"],["vis sort-package-json --sort-scripts","Also sort the scripts field alphabetically"],["vis sort-package-json --indent 4","Force 4-space indentation (overrides per-file detection)"],["vis sort-package-json --indent tab","Force tab indentation"],["vis sort-package-json --ignore '**/fixtures/**'","Skip files matching one or more glob patterns"],["vis sort-package-json --sort-order name,version,license","Pin a custom prefix order before the default field order"],["vis sort-package-json --unsorted dependencies,devDependencies","Preserve original key order for the listed top-level sections"],["vis sort-package-json --no-final-newline","Do not append a trailing newline"],["vis sort-package-json --line-ending crlf","Force CRLF line endings (default: auto-detect per file)"]],group:"Workspace",loader:()=>import("./handler64.js"),name:"sort-package-json",options:[{alias:"c",defaultValue:!1,description:"Check if package.json files are sorted without writing (exits 1 if unsorted)",name:"check",type:Boolean},{defaultValue:!1,description:"Also sort the scripts field alphabetically",name:"sort-scripts",type:Boolean},{description:"Indent override: a number of spaces, the literal `tab`, or a literal whitespace string. When unset, the original file's indent is preserved.",name:"indent",type:String},{description:"Glob pattern of files to skip (basename match, or path-relative when the pattern contains `/`). Repeatable.",multiple:!0,name:"ignore",type:String},{description:"Comma-separated list of top-level keys to place first, before the default field order. Repeatable.",multiple:!0,name:"sort-order",type:String},{description:"Comma-separated list of top-level sections whose key order should be preserved (e.g. dependencies,devDependencies). Repeatable.",multiple:!0,name:"unsorted",type:String},{defaultValue:!1,description:"Do not append a trailing newline to the output (default: append one).",name:"no-final-newline",type:Boolean},{defaultValue:"auto",description:"Line ending to write: auto (per-file detection, default), lf, or crlf.",name:"line-ending",type:String},{description:"Disable collapsing `bugs: { url }` to the bare string form (default: enabled).",name:"no-format-bugs",type:Boolean},{description:"Disable collapsing `repository: { type, url }` to the GitHub `owner/repo` shorthand (default: enabled).",name:"no-format-repository",type:Boolean},{description:"Disable canonical sorting of `exports` condition keys (default: enabled).",name:"no-sort-exports",type:Boolean},{description:"Disable .editorconfig discovery for indent / line-ending defaults (default: enabled).",name:"no-editorconfig",type:Boolean}]},AR={argument:{description:"Project name or workspace-relative path of the package to extract",name:"package",type:String},description:"Extract a package into a standalone git repo, preserving its history",examples:[["vis split @scope/pkg --output ../pkg-repo","Extract a package into a new repo at ../pkg-repo"],["vis split packages/tooling/foo -o ../foo --remote git@github.com:me/foo.git --push","Extract, set origin, and push"],["vis split @scope/pkg -o ../pkg --remove","Extract, then delete the package from the monorepo (committed)"],["vis split @scope/pkg --dry-run","Print the git plan without making changes"]],group:"Workspace",loader:()=>import("./handler23.js"),name:"split",options:[{alias:"o",description:"Destination directory for the new repo (required unless --dry-run)",name:"output",type:String},{alias:"b",description:'Default branch name in the new repo (default: vis.config defaultBase or "main")',name:"branch",type:String},{description:"Git remote URL to set as origin on the new repo",name:"remote",type:String},{defaultValue:!1,description:"Push the new repo to origin (requires --remote)",name:"push",type:Boolean},{defaultValue:!1,description:"Delete the package from the monorepo after extracting and commit the removal",name:"remove",type:Boolean},{defaultValue:!1,description:"Prefix the rewritten commit messages with the package name",name:"annotate",type:Boolean},{defaultValue:!1,description:"Use a non-empty --output directory anyway",name:"force",type:Boolean},{defaultValue:!1,description:"Print the git plan instead of executing it",name:"dry-run",type:Boolean}]},IR={description:"Run linters on staged files using config from vis.config.ts",examples:[["vis staged","Run staged linters"],["vis staged --verbose","Run with verbose output"],["vis staged --no-stash","Run without backup stash"],["vis staged --diff HEAD~1","Run against a specific diff"]],group:"Run & Execute",loader:()=>import("./handler75.js"),name:"staged",options:[{defaultValue:!1,description:"Allow empty commits when tasks revert all staged changes",name:"allow-empty",type:Boolean},{defaultValue:!1,description:"Automatically stage new files that tasks create during the run",name:"auto-stage",type:Boolean},{description:"Number of concurrent tasks or false for serial",name:"concurrent",type:String},{defaultValue:!1,description:"Run all tasks to completion even if one fails",name:"continue-on-error",type:Boolean},{description:"Working directory to run all tasks in",name:"cwd",type:String},{defaultValue:!1,description:"Enable debug output",name:"debug",type:Boolean},{description:"Override the default --staged flag of git diff",name:"diff",type:String},{description:"Override the default diff-filter",name:"diff-filter",type:String},{defaultValue:!1,description:"Fail with exit code 1 when tasks modify tracked files",name:"fail-on-changes",type:Boolean},{defaultValue:!1,description:"Kill in-flight tasks with SIGKILL on fast-fail instead of the default SIGTERM",name:"force-kill",type:Boolean},{defaultValue:!1,description:"Hide unstaged changes from partially staged files",name:"hide-partially-staged",type:Boolean},{defaultValue:!1,description:"Hide all unstaged changes before running tasks",name:"hide-unstaged",type:Boolean},{defaultValue:!1,description:"Suppress console output",name:"quiet",type:Boolean},{defaultValue:!1,description:"Pass filepaths relative to cwd to tasks",name:"relative",type:Boolean},{defaultValue:!1,description:"Revert to original state in case of errors",name:"revert",type:Boolean},{defaultValue:!0,description:"Enable backup stash",name:"stash",type:Boolean},{defaultValue:!1,description:"Show task output even when tasks succeed",name:"verbose",type:Boolean}]},BR={description:"Show a workspace health dashboard at a glance",examples:[["vis status","Full status overview"],["vis status --json","Machine-readable output"]],group:"Workspace",loader:()=>import("./handler24.js"),name:"status",options:[{defaultValue:!1,description:"Emit JSON output",name:"json",type:Boolean}]},PR={argument:{description:"What to sync: codeowners | package-json-fields",name:"kind",type:String},description:"Synchronise derived workspace artefacts (codeowners, package.json fields, tsconfig refs, …)",examples:[["vis sync codeowners","Generate CODEOWNERS at the repository root"],["vis sync codeowners --out=.github/CODEOWNERS","Write to .github/CODEOWNERS instead"],["vis sync codeowners --check","Fail if the existing file is stale"],["vis sync codeowners --from=project-json,nested-codeowners","Also aggregate nested CODEOWNERS files in the tree"],["vis sync codeowners --regeneration-command='pnpm codeowners'","Set a custom header instruction"],["vis sync codeowners --preserve-block","Splice the generated block between markers in an existing CODEOWNERS"],["vis sync codeowners --write-guard","Also emit GitHub + GitLab Write Guard CI for restricted projects"],["vis sync package-json-fields","Mirror license/author/repository/bugs/homepage/engines from root to every workspace package"],["vis sync package-json-fields --check","Fail if any workspace package.json is out of sync"],["vis sync package-json-fields --fields license,engines","Override the default field list for this run"]],group:"Workspace",loader:()=>import("./handler62.js"),name:"sync",options:[{description:"Output path for the generated file (default: <workspace>/CODEOWNERS) — codeowners kind only",name:"out",type:String},{defaultValue:!1,description:"Verify state without writing (exit non-zero if drift is found)",name:"check",type:Boolean},{description:"Input sources for codeowners. Comma-separated or repeated. Values: project-json | nested-codeowners | package-json-maintainers. Defaults to project-json.",multiple:!0,name:"from",type:String},{description:"Glob (repeatable) used to discover nested CODEOWNERS files. Defaults to `**/CODEOWNERS`.",multiple:!0,name:"nested-includes",type:String},{description:"Header instruction shown to reviewers (replaces the default 'update project.json' note). Codeowners kind only.",name:"regeneration-command",type:String},{defaultValue:!1,description:"Splice the generated block between markers in the existing file instead of overwriting it. Codeowners kind only.",name:"preserve-block",type:Boolean},{defaultValue:!1,description:"Also emit a .github/workflows/write-guard.yml scoped to projects with `restricted: true` in project.json. Codeowners kind only.",name:"write-guard",type:Boolean},{description:"Comma-separated list of fields to mirror from root → workspace packages (package-json-fields kind only). Repeatable.",multiple:!0,name:"fields",type:String},{description:"Glob pattern of package names to skip (package-json-fields kind only). Repeatable.",multiple:!0,name:"ignore-package-name",type:String},{defaultValue:"human",description:"Output format for package-json-fields: human | json",name:"format",type:String},{defaultValue:!1,description:"Suppress per-package log lines; print only the summary (package-json-fields kind only)",name:"quiet",type:Boolean}]},NR={argument:{description:"Task ID to explain (e.g. @my/app:build)",name:"taskId",type:String},description:"Explain why a task is included in the graph by walking its dependency chain to a root",examples:[["vis task-why @myorg/app:build","Show what pulls build in"],["vis task-why lib-a:test","Check the test task's triggers"]],group:"Workspace",loader:()=>import("./handler25.js"),name:"task-why"},ps="Workspace",DR={commandPath:["toolchain"],description:"Show every detected manager + expected vs actual tool versions",examples:[["vis toolchain status","Show every detected manager + expected vs actual tool versions"],["vis toolchain status --json","Emit the status as JSON"],["vis toolchain status --exit-code","Exit 1 if any tool mismatches (for CI)"]],group:ps,loader:Z(()=>import("./handler26.js"),"statusExecute"),name:"status",options:[{defaultValue:!1,description:"Exit 1 if any tool mismatches",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Emit JSON",name:"json",type:Boolean}]},MR={commandPath:["toolchain"],description:"Print the primary manager's name (for scripts)",examples:[["vis toolchain detect","Print the primary manager's name"]],group:ps,loader:Z(()=>import("./handler26.js"),"detectExecute"),name:"detect"},LR={commandPath:["toolchain"],description:"Install pinned versions — per-tool delegation to the right manager",examples:[["vis toolchain install","Install pinned versions"],["vis toolchain install --dry-run","Print the commands that would run, but don't execute"]],group:ps,loader:Z(()=>import("./handler26.js"),"installExecute"),name:"install",options:[{defaultValue:!1,description:"Print the command that would run, but don't execute",name:"dry-run",type:Boolean}]},_R={argument:{description:"Tool and version to pin, e.g. node@22.13.0 or pnpm@10.32.1",name:"spec",type:String},commandPath:["toolchain"],description:"Pin a version via the best manager for that tool",examples:[["vis toolchain use node@22.13.0","Pin node 22.13.0 via the best runtime manager"],["vis toolchain use pnpm@10.32.1","Update the packageManager field; pnpm self-activates"],["vis toolchain use node@22.13.0 --dry-run","Print the command without running it"]],group:ps,loader:Z(()=>import("./handler26.js"),"useExecute"),name:"use",options:[{defaultValue:!1,description:"Print the command that would run, but don't execute",name:"dry-run",type:Boolean},{defaultValue:!0,description:"Also mirror the version into engines.<tool> when that field already exists. --no-engines to skip.",name:"engines",type:Boolean}]},FR={argument:{description:"Tool to resolve, e.g. node",name:"tool",type:String},commandPath:["toolchain"],description:"Print the resolved binary path a manager would launch for a tool",examples:[["vis toolchain which node","Resolve the node binary the manager would launch"]],group:ps,loader:Z(()=>import("./handler26.js"),"whichExecute"),name:"which"},VR=[DR,MR,LR,_R,FR],HR={argument:{description:"Packages to unlink (omit for current package)",name:"packages",type:String},description:"Unlink a previously linked package",examples:[["vis unlink","Unlink current package"],["vis unlink react","Unlink specific package"],["vis unlink -r","Unlink in all workspace packages"]],group:"Dependencies",loader:()=>import("./handler27.js"),name:"unlink",options:[{alias:"r",defaultValue:!1,description:"Unlink in all workspace packages",name:"recursive",type:Boolean}]},WR={alias:"up",argument:{description:"Packages to update (updates all if omitted)",name:"packages",type:String},description:"Update packages to their latest versions",examples:[["vis update react","Update react within semver range"],["vis up react -L","Update react to latest"],["vis update -i","Interactive mode"],["vis update --filter app","Update in specific workspace"],["vis update -r","Update in all workspaces"],["vis update --target minor","Only apply minor/patch updates (catalog mode)"],["vis update --dry-run","Preview changes without applying"],["vis update --exclude '@types/*'","Exclude packages by pattern"],["vis update --changelog","Show changelog links after updating"],["vis update --rollback","Restore catalog from last backup"],["vis update --ai","Run AI analysis before applying updates"]],group:"Dependencies",loader:()=>import("./handler74.js"),name:"update",options:[{alias:"L",conflicts:"target",description:"Update to latest version (ignore semver range; equivalent to --target latest)",name:"latest",type:Boolean},{defaultValue:!1,description:"Ignore the minimumReleaseAge gate and select the truly latest version even if freshly published. The selected packages are added to the package manager's native age-gate exclude list (pnpm minimumReleaseAgeExclude, bun minimumReleaseAgeExcludes, yarn npmPreapprovedPackages) so the follow-up install isn't blocked; npm has no per-package exclude. Combine with --latest to also cross the semver range.",name:"ignore-release-age",type:Boolean},{alias:"t",conflicts:"latest",description:"Update target: latest, minor, or patch (default: latest, catalog mode)",name:"target",type:String},{alias:"d",defaultValue:!1,description:"Preview changes without applying",name:"dry-run",type:Boolean},{alias:"g",defaultValue:!1,description:"Update global packages",name:"global",type:Boolean},{alias:"r",defaultValue:!1,description:"Update recursively in all workspace packages",name:"recursive",type:Boolean},{description:"Filter packages in monorepo (pm-wrapper mode; catalog mode uses --include/--exclude)",name:"filter",type:String},{alias:"w",defaultValue:!1,description:"Include workspace root",name:"workspace-root",type:Boolean},{alias:"D",conflicts:"prod",description:"Update only devDependencies",name:"dev",type:Boolean},{alias:"P",conflicts:"dev",description:"Update only dependencies",name:"prod",type:Boolean},{alias:"i",defaultValue:!1,description:"Interactive mode",name:"interactive",type:Boolean},{defaultValue:!1,description:"Don't update optionalDependencies",name:"no-optional",type:Boolean},{defaultValue:!1,description:"Include peerDependencies in update checks",name:"peer",type:Boolean},{defaultValue:!1,description:"Also check workspace-owned package names against the registry (catalog mode)",name:"include-internal",type:Boolean},{alias:"l",defaultValue:!1,description:"Include packages with pinned/exact versions (no ^ or ~ prefix; catalog mode)",name:"include-locked",type:Boolean},{defaultValue:!1,description:"Update lockfile only",name:"no-save",type:Boolean},{description:"Glob pattern to include packages (repeatable, catalog mode)",lazyMultiple:!0,name:"include",type:String},{description:"Glob pattern to exclude packages (repeatable, catalog mode)",lazyMultiple:!0,name:"exclude",type:String},{defaultValue:!1,description:"Include prerelease versions (catalog mode)",name:"prerelease",type:Boolean},{description:"Check for known security vulnerabilities via OSV.dev (default: true; --no-security to skip)",name:"security",type:Boolean},{defaultValue:!1,description:"Skip catalog mode, use package manager directly",name:"no-catalog",type:Boolean},{description:"Output format: table, json, or minimal (default: table)",name:"format",type:String},{defaultValue:!1,description:"Show changelog URLs for updated packages",name:"changelog",type:Boolean},{description:"Run install after catalog update, --no-install to skip (default: true)",name:"install",type:Boolean},{defaultValue:!1,description:"Restore catalog file from the last backup",name:"rollback",type:Boolean},{defaultValue:!1,description:"Run AI analysis on outdated packages before updating (catalog mode)",name:"ai",type:Boolean},{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",name:"ai-type",type:String},{defaultValue:!1,description:"Skip typosquat name check for package arguments",name:"no-typosquat-check",type:Boolean},{defaultValue:!1,description:"Skip the offline marshall pipeline (author, provenance, metadata, downloads, expired-domains, new-bin, signatures, archived-repo) when explicit package arguments are supplied",name:"no-marshall-check",type:Boolean},{description:"Cap concurrent registry requests during outdated checks (default: 8)",name:"max-concurrent-requests",type:Number},{description:"Release channel filter: stable (default), same (match current's prerelease channel), or any",name:"release-channel",type:String},{alias:"y",defaultValue:!1,description:"Skip the confirmation prompt for blanket --latest updates. Required in non-TTY contexts (CI) when running `vis update --latest` without explicit package arguments.",name:"yes",type:Boolean},{defaultValue:!1,description:"Skip the GitHub Actions ecosystem scan (workflows + composite action.yml files)",name:"no-actions",type:Boolean},{defaultValue:!1,description:"Skip the Docker ecosystem scan (Dockerfile + docker-compose images)",name:"no-docker",type:Boolean},{defaultValue:!1,description:"Skip the GitLab CI ecosystem scan (.gitlab-ci.yml + .gitlab/ci/**)",name:"no-gitlab",type:Boolean},{defaultValue:!1,description:"Include branch references (e.g. actions/checkout@main) when scanning workflows",name:"include-branches",type:Boolean},{description:"Reference style for GitHub Actions updates: sha (default, pin to commit SHA + version comment) or preserve",name:"style",type:String},{description:"GitHub token for actions resolution (overrides GITHUB_TOKEN / GH_TOKEN env)",name:"actions-token",type:String},{description:"GitLab token for include-ref resolution (overrides GITLAB_TOKEN / CI_JOB_TOKEN env)",name:"gitlab-token",type:String}]},UR={argument:{description:"Target version (defaults to latest)",name:"version",type:String},description:"Update vis itself to the latest version",examples:[["vis self-update","Update to latest"],["vis self-update 2.0.0","Install specific version"],["vis self-update --check","Check for updates without installing"]],group:"System",loader:()=>import("./handler28.js"),name:"self-update",options:[{defaultValue:!1,description:"Check for updates without installing",name:"check",type:Boolean},{defaultValue:!1,description:"Reinstall even if already current",name:"force",type:Boolean},{defaultValue:!1,description:"Suppress output (CI mode)",name:"silent",type:Boolean}]},GR={alias:"explain",argument:{description:"Package(s) to explain",name:"packages",type:String},description:"Show why a package is installed (dependency chain)",examples:[["vis why react","Show why react is installed"],["vis why react --json","Output as JSON"],["vis why react -r","Check across all workspaces"],["vis explain react","Alias matching npm's command"]],group:"Dependencies",loader:()=>import("./handler29.js"),name:"why",options:[{defaultValue:!1,description:"Output as JSON",name:"json",type:Boolean},{defaultValue:!1,description:"Show extended information (pnpm)",name:"long",type:Boolean},{defaultValue:!1,description:"Machine-readable output (pnpm)",name:"parseable",type:Boolean},{alias:"r",defaultValue:!1,description:"Check across all workspaces",name:"recursive",type:Boolean},{alias:"D",conflicts:"prod",description:"Filter to dev dependencies (pnpm)",name:"dev",type:Boolean},{alias:"P",conflicts:"dev",description:"Filter to production dependencies (pnpm)",name:"prod",type:Boolean},{defaultValue:!1,description:"Exclude optional dependencies (pnpm)",name:"no-optional",type:Boolean},{alias:"g",defaultValue:!1,description:"Check globally installed packages (pnpm)",name:"global",type:Boolean},{description:"Limit dependency tree depth",name:"depth",type:Number},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String}]},zR={argument:{description:"File to run, with any args to forward to it",name:"file",type:String},description:"Run a TypeScript/JavaScript file directly under the selected runtime (node | bun)",examples:[["vis x script.ts","Run a TypeScript file (full TS surface: enums, decorators)"],["vis x --runtime bun server.ts","Run under Bun"],["vis x build.ts foo bar","Forward positional args to the file"],["vis x task.ts -- --watch","Forward flags after -- to the file"]],group:"Run & Execute",loader:()=>import("./handler30.js"),name:"x",options:[]},JR=e=>{e.addCommand(cR),e.addCommand(l$),e.addCommand(eC),e.addCommand(Ax),e.addCommand(_x),e.addCommand(NR),e.addCommand(aR),e.addCommand(lC),e.addCommand(WR),e.addCommand(c$),e.addCommand(UE),e.addCommand(Jx),e.addCommand(OR),e.addCommand(IR),e.addCommand(BR),e.addCommand(HE),e.addCommand(PR),e.addCommand(vC),e.addCommand(Tx),e.addCommand(Ox),e.addCommand(yC),e.addCommand(ZE),e.addCommand(mC),e.addCommand(Ix),e.addCommand(oR),e.addCommand(WE),e.addCommand(GR),e.addCommand(pC),e.addCommand(gC),e.addCommand(HR),e.addCommand(ff),e.addCommand(mh),e.addCommand(zR),e.addCommand(DC),e.addCommand(fC),e.addCommand(u$),e.addCommand(p$),e.addCommand(QE),e.addCommand(GE),e.addCommand(UR),e.addCommand(dC),e.addCommand(AR),e.addCommand(uC),e.addCommand(Kx),e.addCommand(Zx),e.addCommand(hC),e.addCommand(XE),e.addCommand(NC),e.addCommand(lR),e.addCommand(dR);for(const t of cC)e.addCommand(t);for(const t of PC)e.addCommand(t);for(const t of a$)e.addCommand(t);for(const t of Lx)e.addCommand(t);for(const t of Ku)e.addCommand(t);for(const t of ER)e.addCommand(t);for(const t of yR)e.addCommand(t);for(const t of Xx)e.addCommand(t);for(const t of YE)e.addCommand(t);for(const t of VR)e.addCommand(t);for(const t of TR)e.addCommand(t);e.addCommand(d$);for(const t of rR)e.addCommand(t)},KR=e=>{for(let t=0;t<e.length;t+=1){const n=e[t];if(n==="--ca-cert"){const s=e[t+1];return s===void 0||s.startsWith("-")?void 0:Ls(s)}if(n.startsWith("--ca-cert=")){const s=n.slice(10);return s===""?void 0:Ls(s)}}},qR=()=>process.platform==="win32"?!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color":process.env.TERM!=="linux",In=qR(),YR={arrow:In?"→":"->",dash:In?"—":"-",failure:In?"✗":"x",success:In?"✓":"v",warning:In?"⚠":"!"},Jr=g(ht(),"upgrade-check.json"),XR=1440*60*1e3,ZR=1440*60*1e3,QR=500,ej=new Set(["--help","--version","-h","-V","help","implode","upgrade"]),tj=()=>{try{if(x(Jr))return le(Jr)}catch{}},Zp=e=>{try{ft(ht()),ge(Jr,JSON.stringify(e))}catch{}},nj=async e=>{try{const t=new AbortController,n=setTimeout(()=>{t.abort()},QR),s=await fetch(`https://registry.npmjs.org/${e}/latest`,{headers:{accept:"application/json"},signal:t.signal});return clearTimeout(n),s.ok?(await s.json()).version:void 0}catch{return}},el=(e,t)=>{let n;try{n=ar.gt(t.latestVersion,e,{loose:!0})}catch{return}if(!n)return;const s=Date.now();s-t.lastNoticeAt<ZR||(process.stderr.write(`
|
|
243
|
-
${
|
|
244
|
-
`),t.lastNoticeAt=s,
|
|
240
|
+
</html>`;let bt;const QE=()=>{for(const e of ZE)try{if(Ot(e).isFile())return e}catch{}},eC=()=>{if(bt!==void 0&&!process.env.VIS_DASHBOARD_NO_CACHE)return bt;const e=QE();if(!e)return bt=rl,bt;try{const t=Zf(e,"utf8");return bt=t,t}catch{return bt=rl,bt}},tC=e=>{if(e.length===0)return;const t=[...e].sort((s,r)=>s-r),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]},nC=e=>{const t=new Map;for(const s of e)if(Array.isArray(s.tasks))for(const r of s.tasks){if(!r.taskId)continue;const i=t.get(r.taskId)??{durations:[],failures:0,hits:0,misses:0,project:r.target?.project??"",runs:0,target:r.target?.target??"",taskId:r.taskId};r.cacheStatus==="HIT"||r.cacheStatus==="REMOTE_HIT"?(i.runs+=1,i.hits+=1):r.cacheStatus==="MISS"&&(i.runs+=1,i.misses+=1,typeof r.duration=="number"&&r.duration>0&&i.durations.push(r.duration),r.exitCode!==void 0&&r.exitCode!==0&&(i.failures+=1)),t.set(r.taskId,i)}const n=new Map;for(const[s,r]of t){const i=r.durations.length===0?0:r.durations.reduce((o,a)=>o+a,0)/r.durations.length;n.set(s,{averageDurationMs:i,failures:r.failures,hitRate:r.runs===0?0:r.hits/r.runs,hits:r.hits,misses:r.misses,project:r.project,runs:r.runs,target:r.target,taskId:s,timeSavedMs:i*r.hits})}return n},sC=e=>{const t=e,n=[...t].sort((b,S)=>(b.startTime??"").localeCompare(S.startTime??""));let s=0,r=0,i=0,o=0,a=0,c=0;const l=[],d=[],u=[];for(const b of n){const S=b.stats??{};s+=S.total??0,r+=S.succeeded??0,i+=S.failed??0,o+=S.cached??0,a+=S.skipped??0,typeof b.duration=="number"&&b.duration>0&&(c+=b.duration,l.push(b.duration),b.startTime&&u.push({timestamp:b.startTime,value:b.duration})),(S.total??0)>0&&b.startTime&&d.push({timestamp:b.startTime,value:(S.cached??0)/(S.total??1)})}const f=[...nC(n).values()],h=f.filter(b=>b.averageDurationMs>0).sort((b,S)=>S.averageDurationMs-b.averageDurationMs).slice(0,10),m=f.filter(b=>b.runs>=2).sort((b,S)=>S.timeSavedMs-b.timeSavedMs||S.hitRate-b.hitRate).slice(0,10),v=f.filter(b=>b.runs>=3&&b.hits>0&&b.misses>0).sort((b,S)=>S.misses/S.runs-b.misses/b.runs).slice(0,10),$=f.reduce((b,S)=>b+S.timeSavedMs,0);return{averageRunDurationMs:l.length===0?null:l.reduce((b,S)=>b+S,0)/l.length,cacheHitRate:o+r+i===0?null:o/(o+r+i),durationOverTime:u,hitRateOverTime:d,medianRunDurationMs:tC(l)??null,mostCachedTasks:m,mostInvalidatedTasks:v,slowestTasks:h,totals:{cached:o,estimatedTimeSavedMs:$,failed:i,runs:t.length,skipped:a,succeeded:r,tasks:s,totalDurationMs:c}}},rC=(e,t)=>{if(e===void 0||e==="")return!1;let n=e;if(n.startsWith("[")){const s=n.indexOf("]");n=s===-1?n.slice(1):n.slice(1,s)}else if(!n.includes("::")){const s=n.indexOf(":");n=s===-1?n:n.slice(0,s)}return n=n.toLowerCase(),n==="localhost"||n===t.toLowerCase()?!0:gh(n)!==0},il=(e,t)=>{const n=t.replaceAll(/[^\w.\-:]/g,"");if(n.length===0||n!==t)return;const s=g(mt(e),`${n}.json`);if(x(s))try{return le(s)}catch{return}const r=gl(e);if(x(r))try{const i=le(r);return i.id===n?i:void 0}catch{return}},iC=async e=>{const t=new Set,n=mt(e);try{await mh(n,{recursive:!0})}catch{}let s,r;const i=a=>{r=a,s&&clearTimeout(s),s=setTimeout(()=>{if(s=void 0,!r)return;const c=r;r=void 0;for(const l of t)try{l(c)}catch{}},200)};let o;try{o=Qf(n,(a,c)=>{if(!c||typeof c!="string"||!c.endsWith(".json"))return;const l=c.slice(0,-5);i({id:l,type:"run-changed"})})}catch{o=void 0}return{close:()=>{s&&clearTimeout(s),o?.close(),t.clear()},subscribe:a=>(t.add(a),()=>{t.delete(a)})}},oC=(e,t)=>{const n=new iE;return n.use("*",async(s,r)=>rC(s.req.header("host"),e.host)?r():s.json({error:"Forbidden"},403)),n.get("/",s=>s.html(eC())),n.get("/api/overview",s=>{const r=zn(e.workspaceRoot),i=sC(r),o=qE(e.workspaceRoot,{minRuns:2},r);return s.json({flaky:o,metrics:i})}),n.get("/api/runs",s=>{const i=zn(e.workspaceRoot).filter(o=>typeof o.id=="string"&&typeof o.startTime=="string"&&typeof o.endTime=="string"&&typeof o.duration=="number").map(o=>{const a=o.stats,c=a?{cached:typeof a.cached=="number"?a.cached:void 0,failed:typeof a.failed=="number"?a.failed:void 0,skipped:typeof a.skipped=="number"?a.skipped:void 0,succeeded:typeof a.succeeded=="number"?a.succeeded:void 0,total:typeof a.total=="number"?a.total:void 0}:void 0;return{duration:o.duration,endTime:o.endTime,id:o.id,startTime:o.startTime,stats:c}}).sort((o,a)=>a.startTime.localeCompare(o.startTime));return s.json({runs:i})}),n.get("/api/runs/:id",s=>{const r=il(e.workspaceRoot,s.req.param("id"));return r?s.json(r):s.json({error:"Not found"},404)}),n.get("/api/runs/:runId/tasks/:taskId/diff",s=>{const r=il(e.workspaceRoot,s.req.param("runId"));if(!r)return s.json({error:"Run not found"},404);const i=s.req.param("taskId"),o=r.tasks?.find(l=>l.taskId===i);if(!o)return s.json({error:"Task not found"},404);const a=zn(e.workspaceRoot),c=XE(a,r.id,o);return s.json(c)}),n.get("/api/cache",async s=>{if(!x(e.cacheDirectory))return s.json({directory:e.cacheDirectory,entries:[],exists:!1,totalBytes:0});const r=await ut(e.cacheDirectory),i=r.reduce((a,c)=>a+c.sizeBytes,0),o=Date.now();return s.json({directory:e.cacheDirectory,entries:r.map(a=>({ageMs:o-a.mtimeMs,hash:a.hash,mtimeIso:new Date(a.mtimeMs).toISOString(),sizeBytes:a.sizeBytes})),exists:!0,totalBytes:i})}),n.get("/api/environment",s=>s.json({arch:process.arch,cacheDirectory:e.cacheDirectory,node:process.version,platform:process.platform,workspaceRoot:e.workspaceRoot})),n.get("/api/events",s=>dE(s,async r=>{const i=[];let o;const a=t(l=>{if(i.push(l),o){const d=o;o=void 0,d()}});r.onAbort(()=>{if(a(),o){const l=o;o=void 0,l()}}),await r.writeSSE({data:JSON.stringify({ok:!0}),event:"ready"});const c=15e3;for(;!r.aborted;){if(i.length===0){const d=r.sleep(c),u=new Promise(p=>{o=p});if(await Promise.race([d,u]),r.aborted)break;if(i.length===0){await r.writeSSE({data:"",event:"heartbeat"});continue}}const l=i.shift();await r.writeSSE({data:JSON.stringify(l),event:"change"})}})),n},aC=async e=>{const t=await iC(e.workspaceRoot),n=oC(e,t.subscribe),s=C$({fetch:n.fetch,hostname:e.host,port:e.port});await new Promise((l,d)=>{s.once("listening",()=>{l()}),s.once("error",u=>{d(u)})});const r=s.address(),i=typeof r=="object"&&r?r.port:e.port,c=`http://${e.host==="0.0.0.0"||e.host==="::"||e.host==="::0"?"localhost":e.host}:${String(i)}`;return{close:()=>new Promise((l,d)=>{t.close(),s.close(u=>{u?d(u):l()})}),port:i,url:c}},cC=e=>{const{platform:t}=process,[n,s]=t==="darwin"?["open",[e]]:t==="win32"?["cmd",["/c","start","",e]]:["xdg-open",[e]];qf(n,s,r=>{})},lC={description:"Open a browser dashboard with cache, run history, and cache-miss diffs",examples:[["vis dashboard","Start the dashboard on a random port (server only — does not open a browser)"],["vis dashboard --open","Start the dashboard and open it in the default browser"],["vis dashboard --port=7788","Pin the server to a specific port"],["vis dashboard --host=0.0.0.0 --port=7788","Expose the dashboard on all interfaces"]],execute:async({options:e,process:t,visConfig:n,workspaceRoot:s})=>{const r=s??t.cwd,i=ip(r,e.cacheDir,n?.taskRunner?.cacheDirectory),o=typeof e.port=="number"&&Number.isFinite(e.port)?e.port:0,a=typeof e.host=="string"&&e.host.length>0?e.host:"127.0.0.1",c=await aC({cacheDirectory:i,host:a,port:o,workspaceRoot:r});E.success(`Dashboard listening on ${c.url}`),E.info(`Workspace: ${r}`),E.info(`Cache: ${i}`),E.info("Press Ctrl+C to stop."),e.open===!0&&cC(c.url),await new Promise(l=>{let d=!1;const u=()=>{d||(d=!0,process.off("SIGINT",u),process.off("SIGTERM",u),(async()=>{try{await c.close()}catch{}finally{l()}})())};process.once("SIGINT",u),process.once("SIGTERM",u)})},group:"Workspace",name:"dashboard",options:[{defaultValue:0,description:"Port to bind the dashboard server to (0 = auto-assign)",name:"port",type:Number},{defaultValue:"127.0.0.1",description:"Host interface to bind to. Default binds to localhost only.",name:"host",type:String},{defaultValue:!1,description:"Open the dashboard in the default browser after starting",name:"open",type:Boolean},{description:"Cache directory to inspect (overrides config and default). Relative paths resolve against the workspace root.",name:"cache-dir",type:String}]},dC={description:"Deduplicate dependencies using the detected package manager",examples:[["vis dedupe","Run deduplication"],["vis dedupe --check","Preview changes without modifying (CI-friendly)"]],group:"Dependencies",loader:()=>import("./handler9.js"),name:"dedupe",options:[{defaultValue:!1,description:"Preview changes without modifying files (dry-run)",name:"check",type:Boolean}]},uC={description:"Lint workspace dependency policies (workspace-protocol, banned-deps, redefine-root, workspace-versions, custom-types, empty-deps, root-private, root-package-manager, root-deps, missing-package-json, dead-workspace-patterns, types-in-deps, similar-deps)",examples:[["vis deps","Run every enabled lint and exit non-zero on failures"],["vis deps --workspace-protocol","Only check that internal deps use workspace:*"],["vis deps --workspace-protocol --fix","Auto-rewrite internal deps to use workspace:*"],["vis deps --redefine-root","Flag deps duplicated between root and child packages"],["vis deps --banned-deps","Flag deps matching policy.bannedDeps in vis config"],["vis deps --workspace-versions","Flag external deps declared at different versions across packages"],["vis deps --workspace-versions --fix","Rewrite drifting deps to the highest sibling version"],["vis deps --workspace-versions --dep react","Limit version-drift check to a single dep"],["vis deps --workspace-versions --resolve catalog --fix","Rewrite drifting deps to catalog: when a catalog already pins them"],["vis deps --workspace-versions --resolve catalog --propose-min 3","Suggest new catalog entries for deps ≥3 packages already agree on"],["vis deps --custom-types","Flag drift in engines.{node,pnpm}, packageManager, volta.{node,pnpm,yarn}, devEngines"],["vis deps --custom-types --fix","Align all engines/packageManager/volta versions to the highest sibling"],["vis deps --empty-deps --fix","Drop empty `dependencies` / `devDependencies` / etc. blocks across the workspace"],["vis deps --root-private --fix",'Ensure the workspace root package.json has "private": true'],["vis deps --root-package-manager","Ensure the root package.json declares a `packageManager` field"],["vis deps --root-deps --fix","Move runtime deps off the private workspace root into devDependencies"],["vis deps --missing-package-json","Flag workspace dirs that don't contain a package.json"],["vis deps --dead-workspace-patterns --fix","Drop workspace patterns that match zero packages"],["vis deps --types-in-deps --fix","Move @types/* out of dependencies on private packages"],["vis deps --similar-deps","Flag drift across related dep families (react+react-dom, @babel/*, …)"],["vis deps --ban left-pad --ban request","One-off ban: flag any package declaring left-pad or request"],["vis deps --pin react@18.2.0","One-off pin: flag any package declaring react at a different version"],["vis deps --format json","Emit findings as JSON for CI / editor integrations"]],group:"Security & Health",loader:()=>import("./handler67.js"),name:"deps",options:[{defaultValue:!1,description:"Lint that internal deps use the workspace: protocol",name:"workspace-protocol",type:Boolean},{defaultValue:!1,description:"Lint that no child re-declares a dep already pinned in the workspace root",name:"redefine-root",type:Boolean},{defaultValue:!1,description:"Lint deps against policy.bannedDeps in vis config",name:"banned-deps",type:Boolean},{defaultValue:!1,description:"Lint that all packages declare external deps at the same version",name:"workspace-versions",type:Boolean},{defaultValue:!1,description:"Lint engines.{node,pnpm}, packageManager, volta.*, devEngines.* for drift across packages",name:"custom-types",type:Boolean},{defaultValue:!1,description:"Flag empty dependency blocks (`dependencies: {}`, `devDependencies: {}`, …) across the workspace",name:"empty-deps",type:Boolean},{defaultValue:!1,description:'Ensure the workspace root package.json sets `"private": true`',name:"root-private",type:Boolean},{defaultValue:!1,description:"Ensure the workspace root package.json declares a `packageManager` field",name:"root-package-manager",type:Boolean},{defaultValue:!1,description:"Flag runtime dependencies on the private workspace root (move them to devDependencies)",name:"root-deps",type:Boolean},{defaultValue:!1,description:"Flag workspace directories that lack a package.json",name:"missing-package-json",type:Boolean},{defaultValue:!1,description:"Flag workspace patterns (in `pnpm-workspace.yaml` / `package.json#workspaces`) that match zero packages",name:"dead-workspace-patterns",type:Boolean},{defaultValue:!1,description:"Flag `@types/*` declared in `dependencies` on a private package (should be in devDependencies)",name:"types-in-deps",type:Boolean},{defaultValue:!1,description:"Flag version drift across related dep families (react+react-dom, @babel/*, @storybook/*, …)",name:"similar-deps",type:Boolean},{description:"Restrict --workspace-versions to a single dep",name:"dep",type:String},{description:"Ban a dep name or glob for this run (repeatable). Auto-enables --banned-deps.",multiple:!0,name:"ban",type:String},{description:"Pin a dep to an exact specifier for this run, e.g. react@^18.2.0 (repeatable). Auto-enables --workspace-versions.",multiple:!0,name:"pin",type:String},{description:"Conflict resolution for --workspace-versions: highest, lowest, or catalog (default: highest)",name:"resolve",type:String},{description:"Propose catalog entries for deps ≥N packages already agree on. Activates with --resolve catalog.",name:"propose-min",type:Number},{defaultValue:!1,description:"Auto-fix violations in place (writes package.json files)",name:"fix",type:Boolean},{description:"Specifier used by --fix for workspace-protocol (default: workspace:*)",name:"fix-specifier",type:String},{description:"Output format: human, json, or minimal (default: human)",name:"format",type:String},{defaultValue:!1,description:"Suppress all output except errors",name:"quiet",type:Boolean}]},pC={alias:"dc",description:"Create or update .devcontainer/devcontainer.json interactively",examples:[["vis devcontainer","Launch interactive devcontainer config editor"],["vis dc","Alias for devcontainer"],["vis devcontainer --template node-pnpm","Start from Node.js + pnpm template"]],group:"Scaffold & Config",loader:()=>import("./handler76.js"),name:"devcontainer",options:[{alias:"t",description:"Start from a template: node, node-pnpm, node-postgres, node-dind, fullstack, python, go, rust, java, devops, minimal, custom",name:"template",type:String},{alias:"o",description:"Output path (default: .devcontainer/devcontainer.json)",name:"output",type:String}]},br="Workspace",fC={commandPath:["docker"],description:"Build a minimal, cache-friendly Docker context for a focus project + its deps",examples:[["vis docker scaffold --focus=my-app","Generate .vis/docker/workspace for my-app + its deps"],["vis docker scaffold --focus=my-app --include-sources","Also copy focus source trees"],["vis docker scaffold --focus=my-app,other --out=.vis/docker","Focus multiple projects"]],group:br,loader:Z(()=>import("./handler59.js"),"scaffoldExecute"),name:"scaffold",options:[{description:"Project name(s) to focus on — comma-separated for multiple",name:"focus",type:String},{description:"Output directory for the scaffold (default: .vis/docker)",name:"out",type:String},{defaultValue:!1,description:"Also copy focus project source trees to <out>/sources",name:"include-sources",type:Boolean},...Ge({defaultValue:!0,description:"Rewrite the workspace lockfile to drop unfocused projects (use --no-prune-lockfile to copy verbatim)",name:"prune-lockfile",type:Boolean})]},hC={commandPath:["docker"],description:"Strip unfocused workspace projects from a scaffolded context (run inside a build stage)",examples:[["vis docker prune --context=.vis/docker","Strip unfocused projects inside a build stage"]],group:br,loader:Z(()=>import("./handler59.js"),"pruneExecute"),name:"prune",options:[{description:"Scaffold root for prune (default: .vis/docker)",name:"context",type:String}]},mC={argument:{description:"Output path for the Dockerfile (default: ./Dockerfile)",name:"path",type:String},commandPath:["docker"],description:"Generate a multi-stage Dockerfile wired to the scaffold/prune flow (create-only)",examples:[["vis docker init","Generate ./Dockerfile for the detected package manager"],["vis docker init --focus=my-app","Target a specific project's build"],["vis docker init --node=24 --force","Use Node 24 and overwrite without prompting"],["vis docker init --dry-run","Print the Dockerfile instead of writing it"]],group:br,loader:Z(()=>import("./handler59.js"),"initExecute"),name:"init",options:[{description:"Focus project name for the build filter",name:"focus",type:String},{description:"Node.js version tag for the base image (default: 22)",name:"node",type:String},{defaultValue:!1,description:"Overwrite an existing Dockerfile without prompting",name:"force",type:Boolean},{defaultValue:!1,description:"Print the Dockerfile to stdout instead of writing it",name:"dry-run",type:Boolean}]},gC={argument:{description:"Dockerfile path(s) to lint (default: ./Dockerfile)",name:"file",type:String},commandPath:["docker"],description:"Lint a Dockerfile with hadolint (downloaded on demand); --fix applies safe autofixes",examples:[["vis docker lint","Lint ./Dockerfile (prompts to download hadolint on first use)"],["vis docker lint apps/web/Dockerfile","Lint a specific Dockerfile"],["vis docker lint --fix","Apply safe autofixes, then report what remains"],["vis docker lint --install --json","Auto-download hadolint and emit JSON"]],group:br,loader:Z(()=>import("./handler59.js"),"lintExecute"),name:"lint",options:[{defaultValue:!1,description:"Apply safe autofixes, then re-lint and report what remains",name:"fix",type:Boolean},{defaultValue:!1,description:"Download hadolint without prompting if it is missing",name:"install",type:Boolean},{description:"Path to a hadolint config (.hadolint.yaml)",name:"config",type:String},{defaultValue:!1,description:"Emit findings as JSON",name:"json",type:Boolean}]},yC=[fC,hC,mC,gC],vC={description:"Run a full project health check (outdated, security, duplicates, optimizations)",examples:[["vis doctor","Full project health check"],["vis doctor --fix","Check and auto-apply safe fixes"],["vis doctor --format json","Machine-readable output for CI"],["vis doctor --only security","Only run the security scans"],["vis doctor --skip optimization,runtime","Skip the listed sections"],["vis doctor --quiet","Summary only, no per-section breakdown"],["vis doctor --no-progress","Disable live progress UI (sequential logs)"],["vis doctor --exit-code","Exit with code 1 if security issues found"],["vis doctor --exit-code --strict","Fail on any issue (outdated, duplicates, security)"]],group:"Security & Health",loader:()=>import("./handler69.js"),name:"doctor",options:[{description:"Output format: table or json (default: table). Alias: --json",name:"format",type:String},{defaultValue:!1,description:"Shorthand for --format json",name:"json",type:Boolean},{defaultValue:!1,description:"Exit with code 1 if issues found",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Auto-apply safe fixes (security overrides + codemods, SIGTERM orphans)",name:"fix",type:Boolean},{defaultValue:!1,description:"With --fix: escalate orphan cleanup to SIGKILL / taskkill /F (use when SIGTERM is ignored)",name:"fix-force",type:Boolean},{defaultValue:!1,description:"With --exit-code: also fail on outdated and duplicate deps",name:"strict",type:Boolean},{description:"Comma-separated sections to run: dependencies,security,optimization,runtime",name:"only",type:String},{description:"Comma-separated sections to skip",name:"skip",type:String},{defaultValue:!1,description:"Suppress per-section detail; print summary only",name:"quiet",type:Boolean},{defaultValue:!1,description:"Disable live progress UI (forces sequential logs)",name:"no-progress",type:Boolean},{defaultValue:!1,description:"Bypass the doctor result cache (~/.vis/cache/doctor)",name:"no-cache",type:Boolean},{description:"Comma-separated package name patterns to scope findings (supports * globs, e.g. '@types/*,react')",name:"filter",type:String}]},bC={description:"Orchestrate detected formatters (prettier, …) across the workspace",examples:[["vis fmt","Apply formatting in place using every detected formatter"],["vis fmt --check","Report files that would change without writing"],["vis fmt --check --format json","Emit findings as JSON for CI / editor integrations"],["vis fmt --check --format sarif","Emit a SARIF 2.1.0 document for code-scanning uploads"],["vis fmt --check --format junit","Emit a JUnit XML report for CI dashboards"],["vis fmt --check --format github","Emit GitHub Actions workflow commands for inline PR annotations"],["vis fmt src/foo.ts src/bar.ts","Format a specific file list"],["vis fmt --quiet","Suppress per-file logs"],["vis fmt --since main","Only format files changed vs the main branch"],["vis fmt --staged","Only format files currently staged in the git index"],["vis fmt --watch","Re-run formatters when watched files change (cache makes incremental --check near-free)"],["vis fmt --check --format sarif --output fmt.sarif","Write the SARIF report to fmt.sarif instead of stdout"]],group:"Lint & Format",loader:()=>import("./handler60.js"),name:"fmt",options:[{defaultValue:!1,description:"Report files that would change without writing",name:"check",type:Boolean},{defaultValue:"human",description:"Output format: human, json, minimal, sarif, junit, or github",name:"format",type:String},{defaultValue:!1,description:"Suppress per-file logs",name:"quiet",type:Boolean},{description:"Only format files changed vs the given git ref (branch, tag, sha)",name:"since",type:String},{defaultValue:!1,description:"Only format files currently staged in the git index",name:"staged",type:Boolean},{description:"Write formatted output to a file path instead of stdout (also accepts `-`/`stdout`/`stderr`)",name:"output",type:String},{defaultValue:!1,description:"Re-run formatters whenever watched files change",name:"watch",type:Boolean}]},wC={argument:{description:"Template name (or remote source like git://… or npm://…) — omit for interactive picker",name:"template",type:String},description:"Scaffold files from an in-repo template",examples:[["vis generate","Pick a template interactively"],["vis generate package","Run the 'package' template"],["vis generate component -- --name=Button --style=primary","Pre-fill option values"],["vis generate package --to=./packages/new --force","Custom destination + overwrite"],["vis generate package --dry-run","Print planned writes without touching disk"],["vis generate git://github.com/org/template#main","Fetch and run a remote template"],["vis generate --list","Show discovered templates"],["vis generate --list --json","Machine-readable template list"],["vis generate package --describe --json","Print template metadata (variables, destination) as JSON"]],group:"Scaffold & Config",loader:()=>import("./handler61.js"),name:"generate",options:[{defaultValue:!1,description:"List discovered templates",name:"list",type:Boolean},{defaultValue:!1,description:"Print template metadata (about, destination, variables) without running produce",name:"describe",type:Boolean},{defaultValue:!1,description:"Emit JSON output (with --list or --describe)",name:"json",type:Boolean},{description:"Destination directory",name:"to",type:String},{defaultValue:!1,description:"Print planned writes without touching disk",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Overwrite existing files without prompting",name:"force",type:Boolean},{defaultValue:!1,description:"Skip prompts; use template defaults",name:"defaults",type:Boolean},{defaultValue:!1,description:"Skip running post-generation scripts",name:"skip-scripts",type:Boolean},{defaultValue:!1,description:"Skip interactive prompts (errors on missing required values)",name:"no-interactive",type:Boolean},{defaultValue:!1,description:"Prefer locally cached remote templates over re-downloading",name:"prefer-offline",type:Boolean}]},kC={description:"Visualize the project dependency graph",examples:[["vis graph","Show colored dependency graph (TUI in TTY, ASCII otherwise)"],["vis graph --format=ascii","Force ASCII tree output"],["vis graph --format=dot","Output in Graphviz DOT format"],["vis graph --format=html --output=graph.html","Generate interactive HTML graph"],["vis graph --format=json --output=graph.json","Save JSON graph to file"]],group:"Workspace",loader:()=>import("./handler73.js"),name:"graph",options:[{alias:"f",defaultValue:void 0,description:"Output format: tui, ascii, dot, json, html (default: tui in TTY, ascii otherwise)",name:"format",type:String},{alias:"o",description:"Write output to file instead of stdout",name:"output",type:String},{alias:"d",description:"Maximum dependency tree depth for ASCII output (default: unlimited)",name:"depth",type:Number}]},_t={defaultValue:io,description:"Custom hooks directory",name:"hooks-dir",type:String},Ft=[{defaultValue:void 0,description:"Set to 0 to disable git hooks, 1 to force-enable them under CI (override skipInCI), 2 for debug output",name:"VIS_GIT_HOOKS",type:String}],SC={commandPath:["hook"],description:"Install git hooks for the workspace (migrates husky / prek on prompt)",env:[...Ft],examples:[["vis hook install","Install git hooks in .vis/hooks/"],["vis hook install --hooks-dir=.githooks","Install hooks in a custom directory"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookInstallExecute})),name:"install",options:[_t]},xC={commandPath:["hook"],description:"Remove git hooks and reset core.hooksPath",env:[...Ft],examples:[["vis hook uninstall","Remove git hooks and reset core.hooksPath"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookUninstallExecute})),name:"uninstall",options:[_t]},$C={commandPath:["hook"],description:"Migrate from husky or prek to vis hooks (auto-detected)",env:[...Ft],examples:[["vis hook migrate","Migrate from husky or prek to vis hooks (auto-detected)"],["vis hook migrate --dry-run","Preview what a migration would write without touching disk"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookMigrateExecute})),name:"migrate",options:[_t,{defaultValue:!1,description:"Preview migrate without writing files",name:"dry-run",type:Boolean}]},EC={commandPath:["hook"],description:"Show configured hooks grouped by stage",env:[...Ft],examples:[["vis hook list","Show configured hooks grouped by stage"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookListExecute})),name:"list",options:[_t]},CC={commandPath:["hook"],description:"Sanity-check installed hooks and the bundled runner",env:[...Ft],examples:[["vis hook validate","Sanity-check installed hooks and the bundled runner"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookValidateExecute})),name:"validate",options:[_t]},RC={argument:{description:"Hook stage to run (e.g. pre-commit, commit-msg). Defaults to pre-commit.",name:"stage",type:String},commandPath:["hook"],description:"Run a specific hook stage against tracked files",env:[...Ft],examples:[["vis hook run pre-commit --all-files","Run the pre-commit hooks against every tracked file"],["vis hook run pre-commit --from-ref=main --to-ref=HEAD","Run pre-commit hooks on files changed between two refs"],["vis hook run pre-commit --last-commit","Shortcut for --from-ref HEAD~1 --to-ref HEAD"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookRunExecute})),name:"run",options:[_t,{defaultValue:!1,description:"Run against every tracked file",name:"all-files",type:Boolean},{defaultValue:void 0,description:"Include files changed since this ref",name:"from-ref",type:String},{defaultValue:void 0,description:"Include files changed up to this ref",name:"to-ref",type:String},{defaultValue:!1,description:"Shortcut for --from-ref HEAD~1 --to-ref HEAD",name:"last-commit",type:Boolean}]},jC={argument:{description:"Target to add (currently: `secrets`)",name:"target",type:String},commandPath:["hook"],description:"Add a managed hook snippet (e.g. `vis secrets --staged`)",env:[...Ft],examples:[["vis hook add secrets","Add a pre-commit hook that runs `vis secrets --staged`"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookAddExecute})),name:"add",options:[_t]},TC=[SC,xC,$C,EC,CC,RC,jC],OC={description:"Generate or merge an ignore file (.dockerignore/.vercelignore/.npmignore/.slugignore) without duplicate entries",examples:[["vis ignore","Print a .dockerignore (deduped against an existing one)"],["vis ignore --write","Write/merge the .dockerignore in place"],["vis ignore --target=vercel --write","Write a deduped .vercelignore"],["vis ignore --target=npm --json","Emit the npm-target result as JSON"]],group:"Scaffold & Config",loader:()=>import("./handler53.js"),name:"ignore",options:[{description:"Ignore-file target: docker | vercel | npm | slug (default: docker)",name:"target",type:String},{defaultValue:!1,description:"Write the result to disk instead of printing to stdout",name:"write",type:Boolean},{defaultValue:!1,description:"Emit the result as JSON",name:"json",type:Boolean}]},AC={description:"Remove vis from the system (self-uninstall)",examples:[["vis implode","Interactive uninstall"],["vis implode --yes","Non-interactive uninstall (CI)"]],group:"System",loader:()=>import("./handler10.js"),name:"implode",options:[{alias:"y",defaultValue:!1,description:"Skip confirmation prompt",name:"yes",type:Boolean}]},IC={argument:{description:"Source git repository URL or local path to import",name:"source",type:String},description:"Import an external repo into the monorepo under a prefix, preserving history",examples:[["vis import git@github.com:me/foo.git --prefix packages/tooling/foo","Import a repo under packages/tooling/foo"],["vis import ../foo --prefix packages/foo --ref v1.2.0","Import a specific tag/branch/commit"],["vis import ../foo --prefix packages/foo --squash","Collapse the incoming history into one commit"],["vis import ../foo --prefix packages/foo --dry-run","Print the git plan without making changes"]],group:"Workspace",loader:()=>import("./handler54.js"),name:"import",options:[{alias:"p",description:"Target directory in the monorepo (e.g. packages/tooling/foo)",name:"prefix",type:String},{alias:"r",description:"Branch, tag, or commit to import (default: HEAD)",name:"ref",type:String},{defaultValue:!1,description:"Collapse the incoming history into a single merge commit",name:"squash",type:Boolean},{alias:"m",description:"Commit message for the subtree merge",name:"message",type:String},{defaultValue:!1,description:"Do not register the package into the workspace config",name:"no-register",type:Boolean},{defaultValue:!1,description:"Print the git plan instead of executing it",name:"dry-run",type:Boolean}]},BC={alias:"view",argument:{description:"Package name followed by optional metadata fields (e.g. 'react version dependencies')",name:"args",type:String},description:"Show npm registry metadata for a package (alias of `npm view` / `pnpm view` / `yarn info` / `bun pm view`)",examples:[["vis info react","Full registry metadata for react"],["vis info react version","Latest version only"],["vis info react versions","All published versions"],["vis info react@18 dependencies","Dependencies of react@18"],["vis info react --json","Emit JSON"],["vis view react","Alias matching npm/pnpm"]],group:"Dependencies",loader:()=>import("./handler11.js"),name:"info",options:[{defaultValue:!1,description:"Output as JSON",name:"json",type:Boolean}]},PC={description:"Initialize vis.config.ts with best-practice security defaults",examples:[["vis init","Interactive setup wizard"],["vis init --no-interactive","Create minimal config without prompts"],["vis init --force","Overwrite existing config"],["vis init --sync-native","Also sync to native PM config files"],["vis init --schema","Print the workspace-relative `$schema` refs to paste into project.json and vis.config.ts"]],group:"Scaffold & Config",loader:()=>import("./handler12.js"),name:"init",options:[{defaultValue:!1,description:"Overwrite existing config file",name:"force",type:Boolean},{defaultValue:!1,description:"Skip interactive prompts",name:"no-interactive",type:Boolean},{defaultValue:!1,description:"Sync settings to native PM config files",name:"sync-native",type:Boolean},{defaultValue:!1,description:"Print workspace-relative $schema paths for project.json and vis.config.ts, then exit",name:"schema",type:Boolean}]},NC={argument:{description:"Package to inspect, optionally pinned: `<name>` or `<name>@<spec>`. `<spec>` may be a version, range, or dist-tag.",name:"package"},description:"Run all marshalls against a package without installing it",examples:[["vis inspect express","Run every marshall against express@latest"],["vis inspect lodash@4.17.21","Pin to an exact version"],["vis inspect react@^18","Resolve a semver range, then inspect the best match"],["vis inspect express --json","Emit findings as JSON for CI integration"],["vis inspect express --strict","Exit non-zero on any warning, not just errors"],["vis inspect express --only author,downloads","Run a subset of marshalls"],["vis inspect express --only signatures","Signatures are off by default; opt in with --only"]],group:"Security & Health",loader:()=>import("./handler13.js"),name:"inspect",options:[{defaultValue:!1,description:"Emit findings as a JSON document instead of the human-readable table.",name:"json",type:Boolean},{defaultValue:!1,description:"Exit non-zero on any finding (warnings included). Default exits non-zero only on errors.",name:"strict",type:Boolean},{description:"Comma-separated subset of marshalls to run. Known: author, archivedRepo, downloads, expiredDomains, metadata, newBin, provenance, signatures. Signatures only runs when explicitly requested here.",name:"only",type:String}]},DC={alias:"i",argument:{description:"Optional package names. When provided, delegates to `vis add` (enables npm-style `alias npm='vis install'` wrappers).",name:"packages",type:String},description:"Install dependencies using the detected package manager",examples:[["vis install","Install all dependencies (frozen-lockfile by default when a lockfile is present)"],["vis install react react-dom","Delegates to `vis add` — enables shell aliases like `alias npm='vis install'`"],["vis i --no-frozen-lockfile","Allow lockfile updates (escape hatch for the default)"],["vis install --ci","Clean install: wipe node_modules + frozen lockfile (mirrors npm ci / pnpm ci)"],["vis install --prefer-offline","Use cached packages when available, fall back to network"],["vis install --prod","Install production dependencies only"],["vis install --filter app","Install for specific workspace package"],["vis install --run-scripts","Run lifecycle scripts (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)"],["vis install --no-typosquat-check","Skip typosquat name check"],["vis install --installer aube","Force aube as the installer (errors if not on PATH)"],["vis install --no-aube","Bypass aube; use the lockfile-detected PM"]],group:"Dependencies",loader:()=>import("./handler14.js"),name:"install",options:[{alias:"P",conflicts:"dev",description:"Skip devDependencies (no positional args) / add as peer (with positional args, npm-style)",name:"prod",type:Boolean},{alias:"D",conflicts:"prod",description:"Install devDependencies only (no positional args) / add as dev (with positional args, npm-style)",name:"dev",type:Boolean},{defaultValue:!1,description:"Add as optional dependency (only with positional args; mirrors `npm install -O`)",name:"save-optional",type:Boolean},{alias:"E",defaultValue:!1,description:"Save exact version (only with positional args; mirrors `npm install -E`)",name:"exact",type:Boolean},{defaultValue:!1,description:"Skip Socket.dev security check (only with positional args; mirrors `vis add --no-socket-check`)",name:"no-socket-check",type:Boolean},{defaultValue:!1,description:"Skip the offline marshall pipeline (only with positional args; mirrors `vis add --no-marshall-check`)",name:"no-marshall-check",type:Boolean},{defaultValue:!1,description:"Use frozen lockfile (CI mode, maps to npm ci)",name:"frozen-lockfile",type:Boolean},{defaultValue:!1,description:"Opt out of vis's default frozen-lockfile behavior and allow lockfile updates",name:"no-frozen-lockfile",type:Boolean},{defaultValue:!1,description:"Clean install: wipe node_modules then install with frozen lockfile",name:"ci",type:Boolean},{alias:"f",defaultValue:!1,description:"Force reinstall all dependencies",name:"force",type:Boolean},{defaultValue:!1,description:"Run lifecycle scripts (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)",name:"run-scripts",type:Boolean},{defaultValue:!1,description:"Update lockfile without installing",name:"lockfile-only",type:Boolean},{defaultValue:!1,description:"Skip optional dependencies",name:"no-optional",type:Boolean},{defaultValue:!1,description:"Use only cached packages",name:"offline",type:Boolean},{defaultValue:!1,description:"Prefer cached packages, fall back to network when missing",name:"prefer-offline",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output",name:"silent",type:Boolean},{alias:"r",defaultValue:!1,description:"Install in all workspace packages",name:"recursive",type:Boolean},{alias:"w",defaultValue:!1,description:"Target workspace root",name:"workspace-root",type:Boolean},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String},{defaultValue:!1,description:"Skip typosquat name check",name:"no-typosquat-check",type:Boolean},{description:"Pick the installer explicitly. One of: auto, aube, pnpm, npm, yarn, bun. Overrides VIS_INSTALLER and install.backend in vis.config.",name:"installer",type:String},{defaultValue:!1,description:"Skip aube and use the lockfile-detected PM. Wins over --installer / VIS_INSTALLER / install.backend.",name:"no-aube",type:Boolean}]},MC={alias:"ln",argument:{description:"Package name or directory path to link (omit to register current package)",name:"target",type:String},description:"Link a local package for development",examples:[["vis link ./packages/utils","Link local directory package (works on all PMs)"],["vis link","Register current package globally (pnpm <=10, yarn, npm, bun)"],["vis link react","Link global package into current project (pnpm <=10, yarn, npm, bun)"]],group:"Dependencies",loader:()=>import("./handler16.js"),name:"link"},LC={description:"Orchestrate detected source-code linters (eslint, …) across the workspace",examples:[["vis lint","Run every detected linter against the workspace"],["vis lint --fix","Apply auto-fixes where the tool supports them"],["vis lint --format json","Emit findings as JSON for CI / editor integrations"],["vis lint --format sarif","Emit a SARIF 2.1.0 document for code-scanning uploads"],["vis lint --format junit","Emit a JUnit XML report for CI dashboards"],["vis lint --format github","Emit GitHub Actions workflow commands for inline PR annotations"],["vis lint src/foo.ts src/bar.ts","Lint a specific file list"],["vis lint --quiet","Suppress warnings — only errors are reported"],["vis lint --max-warnings 0","Treat any warning as a failure"],["vis lint --since main","Only lint files changed vs the main branch"],["vis lint --staged","Only lint files currently staged in the git index"],["vis lint --watch","Re-run linters when watched files change (cache makes incremental near-free)"],["vis lint --format sarif --output lint.sarif","Write the SARIF report to lint.sarif instead of stdout"]],group:"Lint & Format",loader:()=>import("./handler63.js"),name:"lint",options:[{defaultValue:!1,description:"Apply auto-fixes in place",name:"fix",type:Boolean},{defaultValue:"human",description:"Output format: human, json, minimal, sarif, junit, or github",name:"format",type:String},{defaultValue:!1,description:"Suppress warnings — report errors only",name:"quiet",type:Boolean},{description:"Fail the run if more than N warnings are reported",name:"max-warnings",type:Number},{description:"Only lint files changed vs the given git ref (branch, tag, sha)",name:"since",type:String},{defaultValue:!1,description:"Only lint files currently staged in the git index",name:"staged",type:Boolean},{description:"Write formatted output to a file path instead of stdout (also accepts `-`/`stdout`/`stderr`)",name:"output",type:String},{defaultValue:!1,description:"Re-run linters whenever watched files change",name:"watch",type:Boolean}]},_C={description:"List all workspace projects with metadata",examples:[["vis list","Show all projects"],["vis list --targets","Per-target rows with type, cache status and description"],["vis list --targets --inferred","Only show targets synthesized by Project Crystal-style inference"],["vis list --deps","Human-readable table of every dep-instance across the workspace"],["vis list --deps --internal-only","Only workspace deps in human form"],["vis list --deps --format=ndjson","Stream every dep-instance as NDJSON for jq pipelines"],["vis list --deps --format=json --pretty","Single pretty-printed JSON array of dep-instances"],["vis list --format=json","Machine-readable project listing"],['vis list --query "tag=frontend"',"Filter by query"],["vis list --tag=type:package","Filter by tag (shorthand for the query above)"]],group:"Workspace",loader:()=>import("./handler55.js"),name:"list",options:[{defaultValue:!1,description:"Filter target rows to only inferred targets (implies --targets)",name:"inferred",type:Boolean},{description:"Output format: table (default), json (single document), or ndjson (one record per line; --deps only)",name:"format",type:String},{defaultValue:!1,description:"Pretty-print with 2-space indent (only meaningful with --format=json)",name:"pretty",type:Boolean},{description:"Filter projects by query",name:"query",type:String},{description:'Only list projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…".',multiple:!0,name:"tag",type:String},{defaultValue:!1,description:"Show per-target rows (type, cache, description)",name:"targets",type:Boolean},{defaultValue:!1,description:"Render a dep-instance view (table by default; use --format=ndjson|json for jq-friendly streams)",name:"deps",type:Boolean},{description:"Restrict --deps to specific dep blocks (repeatable)",multiple:!0,name:"dep-type",type:String},{defaultValue:!1,description:"With --deps: only show internal/workspace deps",name:"internal-only",type:Boolean},{defaultValue:!1,description:"With --deps: only show external/registry deps",name:"external-only",type:Boolean},{description:"With --deps: glob of declaring package names to keep (repeatable)",multiple:!0,name:"include",type:String},{description:"With --deps: glob of declaring package names to drop (repeatable)",multiple:!0,name:"exclude",type:String}]},$e=[{defaultValue:!1,description:"Preview changes without applying",name:"dry-run",type:Boolean},{alias:"y",defaultValue:!1,description:"Skip the confirmation prompt",name:"yes",type:Boolean}],FC={commandPath:["migrate"],description:"Migrate dependencies and scripts to vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateDepsExecute})),name:"deps",options:[...$e]},VC={commandPath:["migrate"],description:"Inline lint-staged configuration into vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateLintStagedExecute})),name:"lint-staged",options:[...$e]},WC={commandPath:["migrate"],description:"Inline nano-staged configuration into vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateNanoStagedExecute})),name:"nano-staged",options:[...$e]},HC={commandPath:["migrate"],description:"Migrate turborepo tasks/config to vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateTurborepoExecute})),name:"turborepo",options:[...$e]},UC={commandPath:["migrate"],description:"Migrate nx targets/config to vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateNxExecute})),name:"nx",options:[...$e,{defaultValue:!1,description:"Overwrite an existing vis.config.ts (a .bak is taken first)",name:"force",type:Boolean},{defaultValue:!1,description:"For each project.json `syncGenerators`, add a `pre<target>` script to sibling package.json (with a TODO for the user to wire up)",name:"rewrite-sync-generators",type:Boolean},{defaultValue:!1,description:"Auto-apply the safe cleanup items the migrator would otherwise leave on the checklist: delete nx.json + ignore-files-for-nx-affected.yml, strip nx/@nx/*/@nrwl/* devDependencies, rewrite mechanical `nx run-many|run|affected` scripts. Implies --force.",name:"aggressive",type:Boolean}]},GC={commandPath:["migrate"],description:"Migrate moon tasks/templates to vis",group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateMoonExecute})),name:"moon",options:[...$e,{defaultValue:!1,description:"Copy .moon/templates/* into .vis/templates/* so `vis generate` works without .moon/",name:"copy-templates",type:Boolean}]},zC={commandPath:["migrate"],description:"Migrate gitleaks config/baseline/hooks to `vis secrets`",examples:[["vis migrate gitleaks","Migrate gitleaks config/baseline/hooks to `vis secrets`"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateGitleaksExecute})),name:"gitleaks",options:[...$e]},JC={commandPath:["migrate"],description:"Migrate Kingfisher baseline/hooks/scripts to `vis secrets`",examples:[["vis migrate kingfisher","Migrate Kingfisher baseline/hooks/scripts to `vis secrets`"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateKingfisherExecute})),name:"kingfisher",options:[...$e]},qC={commandPath:["migrate"],description:"Replace secretlint with `vis secrets`",examples:[["vis migrate secretlint","Replace secretlint with `vis secrets`"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateSecretlintExecute})),name:"secretlint",options:[...$e]},KC={commandPath:["migrate"],description:"Translate syncpack customTypes into vis policy and strip the syncpack dep/scripts",examples:[["vis migrate syncpack","Translate syncpack customTypes into vis policy and strip the syncpack dep/scripts"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateSyncpackExecute})),name:"syncpack",options:[...$e]},YC={commandPath:["migrate"],description:"Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command",examples:[["vis migrate sherif","Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateSherifExecute})),name:"sherif",options:[...$e]},XC={commandPath:["migrate"],description:"Auto-rewrite vis.config.ts to use renamed fields (targetDefaults → tasks, taskDefaults → scopedTasks, taskRunnerOptions → taskRunner)",examples:[["vis migrate self","Rewrite vis.config.ts in-place (a .bak is taken first)"],["vis migrate self --dry-run","Preview the rewrite without writing"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateSelfExecute})),name:"self",options:[...$e]},ZC={commandPath:["migrate"],description:"Audit the workspace for stray gitleaks/secretlint/sherif/syncpack references (exit 1 on issues)",examples:[["vis migrate verify","Audit the workspace for stray gitleaks/secretlint/sherif/syncpack references (exit 1 on issues)"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateVerifyExecute})),name:"verify",options:[]},QC={commandPath:["migrate"],description:"Prove a turbo/nx/moon → vis migration preserved the task graph + cache-key surface (exit 1 on divergence)",examples:[["vis migrate verify-graph","Auto-detect the source tool and diff its task graph against the migrated vis.config.ts"],["vis migrate verify-graph --from turbo --format json","Machine-readable equivalence report on stdout (Axis A)"],["vis migrate verify-graph --fail-on warning","Also gate CI on additive/extra-target warnings"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateVerifyGraphExecute})),name:"verify-graph",options:[{description:"Source tool to compare against (turbo|nx|moon). Auto-detected when omitted.",name:"from",type:String},{description:"Output format: table | json | ndjson (default: table)",name:"format",type:String},{description:"Exit non-zero on: error (default) | warning",name:"fail-on",type:String}]},e8={commandPath:["migrate"],description:"Run every applicable migration non-interactively (autodetected)",examples:[["vis migrate all --yes","Run every detected migration without prompting (CI-friendly)"],["vis migrate all --dry-run","Preview every detected migration without writing files"]],group:"Migrate",loader:()=>import("./handler58.js").then(e=>({default:e.migrateAllExecute})),name:"all",options:[...$e]},t8=[e8,FC,VC,WC,HC,UC,GC,XC,zC,JC,qC,KC,YC,ZC,QC],n8={description:"Analyze and optimize dependencies using e18e replacements and @socketregistry overrides",examples:[["vis optimize","Interactive TUI to select and apply optimizations"],["vis optimize --dry-run","Preview available optimizations"],["vis optimize --pin","Pin Socket.dev overrides to exact versions"],["vis optimize --prod","Only optimize production dependencies"]],group:"Workspace",loader:()=>import("./handler70.js").then(e=>e.h),name:"optimize",options:[{alias:"d",defaultValue:!1,description:"Preview available optimizations without applying",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Pin Socket.dev overrides to exact versions",name:"pin",type:Boolean},{defaultValue:!1,description:"Only optimize production dependencies",name:"prod",type:Boolean},{defaultValue:!1,description:"Skip running install after applying overrides",name:"no-install",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]},s8={argument:{description:"Subcommand and arguments (e.g., cache dir, publish --dry-run, list --depth 0)",name:"args",type:String},description:"Package manager utilities (cache, publish, audit, list, config, etc.)",examples:[["vis pm cache dir","Show cache directory"],["vis pm cache clean","Clean cache"],["vis pm publish --dry-run","Preview publishing"],["vis pm list --depth 0","List direct dependencies"],["vis pm audit","Run security audit"],["vis pm whoami","Show logged-in user"]],group:"System",loader:()=>import("./handler17.js"),name:"pm"},r8={commandPath:["release"],description:"Author a new change file (interactive, or non-interactive via --packages)",examples:[["vis release add","Interactive prompt"],["vis release add --packages '@scope/cerebro:minor,@scope/string:patch' --message 'Add tab completion'","Non-interactive"],["vis release add --empty","Author an empty change file (acknowledges PR but releases nothing)"],["vis release add --name fix-tab-completion","Use a fixed slug instead of a random animal name"],["vis release add --from-bot-pr","Generate a change file from the current Dependabot / Renovate PR (changesets #647)"]],group:"Release",loader:()=>import("./handler31.js"),name:"add",options:[{description:"Comma-separated package:level pairs (e.g. '@scope/a:minor,@scope/b:patch')",name:"packages",type:String},{description:"Changelog body for the change file",name:"message",type:String},{description:"Slug for the filename (default: random animal name)",name:"name",type:String},{description:"Author an empty change file (no bumps; satisfies non-strict `check`)",name:"empty",type:Boolean},{description:"Author a `none` change file (acknowledged but no direct bump)",name:"none",type:Boolean},{description:"Inspect the current PR (via `gh pr view`) and author a change file from its Dependabot / Renovate title (changesets #647)",name:"from-bot-pr",type:Boolean}]},i8={commandPath:["release"],description:"Render the would-be changelog entries without writing to disk",examples:[["vis release changelog","Print rendered entries for the pending plan"],["vis release changelog --json","Emit ChangelogResult (with projectChangelogs[]) as JSON"]],group:"Release",loader:()=>import("./handler32.js"),name:"changelog",options:[{description:"Emit machine-readable JSON",name:"json",type:Boolean},{description:"Limit to packages matching this glob (CSV)",name:"filter",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},o8={commandPath:["release"],description:"Verify pending change files cover changed packages — CI / husky gate",examples:[["vis release check","Pass if at least one change file exists"],["vis release check --strict","Fail if any changed package isn't covered by a change file"],["vis release check --hook pre-commit","Run as a husky pre-commit hook"],["vis release check --no-fail","Print warnings but always exit 0"]],group:"Release",loader:()=>import("./handler33.js"),name:"check",options:[{description:"Require every changed package to have its own non-empty change file",name:"strict",type:Boolean},{description:"Hook context (pre-commit, pre-push) — affects which file states are counted",name:"hook",type:String},{description:"Always exit 0; warnings still print to stderr",name:"no-fail",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},a8={commandPath:["release","ci"],description:"CI: post or update a sticky PR comment with the pending release plan",examples:[["vis release ci check","Resolve PR from GITHUB_REF, post/update the release plan comment"],["vis release ci check --strict","Fail if any changed package isn't covered"]],group:"Release",loader:()=>import("./handler34.js"),name:"check",options:[{description:"Require every changed package to be covered by a change file",name:"strict",type:Boolean},{description:"Always exit 0 (warnings still print)",name:"no-fail",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},c8={commandPath:["release","ci"],description:"CI: emit JSON plan + write to $GITHUB_OUTPUT for workflow gating",examples:[["vis release ci plan","Emit { mode, packages, json } and set $GITHUB_OUTPUT"]],group:"Release",loader:()=>import("./handler35.js"),name:"plan",options:[{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},l8={commandPath:["release","ci"],description:"CI: rebase the open version-PR onto the base branch and force-push",examples:[["vis release ci rebase-pr","Rebase the version-PR branch onto base + force-push"],["vis release ci rebase-pr --branch=release/version","Override the version-PR branch"]],group:"Release",loader:()=>import("./handler36.js"),name:"rebase-pr",options:[{description:"Override the version-PR branch (default: vis-release/version-packages)",name:"branch",type:String},{description:"Override the base branch (default: release.baseBranch)",name:"base",type:String}]},d8={commandPath:["release","ci"],description:"CI: maintain a rolling version-PR (default) or version+publish inline (--auto-publish)",examples:[["vis release ci release","On push to main: open/update Versioned release PR; on PR merge: publish"],["vis release ci release --auto-publish","Skip version-PR; version + publish inline (alpha/beta workflow)"]],group:"Release",loader:()=>import("./handler56.js"),name:"release",options:[{description:"Skip version-PR; version + publish inline",name:"auto-publish",type:Boolean},{description:"Override version-PR branch (default: vis-release/version-packages)",name:"branch",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",name:"first-release",type:Boolean}]},u8={commandPath:["release","ci"],description:"CI: print setup checklist for tokens (VIS_GH_TOKEN, NPM_TOKEN, OIDC) and workflow permissions",examples:[["vis release ci setup","Walk through the recommended secrets + workflow setup"]],group:"Release",loader:()=>import("./handler37.js"),name:"setup",options:[]},p8={commandPath:["release","ci"],description:"CI: publish snapshot of affected packages + post sticky PR comment with install instructions",examples:[["vis release ci snapshot --tag pr-1234","Publish PR snapshot + post install snippet"]],group:"Release",loader:()=>import("./handler38.js"),name:"snapshot",options:[{description:"Override dist-tag (default: pr-<PR_NUMBER>)",name:"tag",type:String},{description:"PR-close cleanup mode — enumerate the closed PR's commit SHAs and remove their snapshot tags from the registry (when supported by the backend)",name:"on-close",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},f8={commandPath:["release"],description:"Preflight diagnostics for the release subsystem (workspace, PM, OIDC, NAPI, guards)",examples:[["vis release doctor","Run all checks; exit non-zero if any error"],["vis release doctor --json","Emit machine-readable report"]],group:"Release",loader:()=>import("./handler39.js"),name:"doctor",options:[{description:"Emit machine-readable JSON instead of a table",name:"json",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Bootstrap mode for greenfield monorepos: doctor asserts the workspace has no release tags and no package has been published yet. Pair with `vis release version --first-release`.",name:"first-release",type:Boolean}]},h8={commandPath:["release"],description:"Auto-derive a change file from branch commits (conventional-commits + path heuristics)",examples:[["vis release generate","Walk commits since the merge-base with baseBranch"],["vis release generate --from origin/main","Walk commits since the given ref"],["vis release generate --dry-run","Print the would-be content without writing"]],group:"Release",loader:()=>import("./handler65.js"),name:"generate",options:[{description:"Git ref to compare against (default: merge-base with baseBranch)",name:"from",type:String},{description:"Slug for the generated filename (default: random animal name)",name:"name",type:String},{description:"Print would-be content without writing",name:"dry-run",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},m8={commandPath:["release"],description:"Scaffold .vis/release; migrate from changesets / bumpy / semantic-release",examples:[["vis release init","Auto-detect source tool and scaffold"],["vis release init --from-semantic-release","Force semantic-release migration"],["vis release init --from-changesets","Force changesets migration"],["vis release init --fresh","Skip migration; start clean"],["vis release init --dry-run","Print what would happen without writing files"],["vis release init --from-semantic-release --apply","Actually perform the semantic-release migration writes"]],group:"Release",loader:()=>import("./handler40.js"),name:"init",options:[{description:"Force migration from semantic-release / multi-semantic-release",name:"from-semantic-release",type:Boolean},{description:"Force migration from changesets",name:"from-changesets",type:Boolean},{description:"Force migration from bumpy",name:"from-bumpy",type:Boolean},{description:"Skip migration; start clean",name:"fresh",type:Boolean},{description:"Print what would happen without writing files",name:"dry-run",type:Boolean},{alias:"y",description:"Auto-confirm prompts (CI-safe)",name:"yes",type:Boolean},{description:"Generate CI workflow files. GitHub → `.github/workflows/vis-release{,-check,-snapshot}.yml`. GitLab → `.gitlab-ci.yml`.",name:"workflows",type:Boolean},{description:"Override package manager when generating workflows (npm | pnpm | yarn | bun). Default: auto-detect",name:"package-manager",type:String},{description:"Actually perform the migration writes (not dry-run)",name:"apply",type:Boolean},{description:"Append a 'Releasing with vis' section to AGENTS.md so AI agents know how to drive the release flow",name:"agent",type:Boolean}]},g8={commandPath:["release"],description:"Print the next computed version for each package in the release plan. Read-only; no mutations.",examples:[["vis release next-version","Print `<pkg> <old> -> <new>` for every package in the plan"],["vis release next-version --package=@scope/a","Single-package mode"],["vis release next-version --json","Emit a `{ name: { from, to } }` JSON map"]],group:"Release",loader:()=>import("./handler41.js"),name:"next-version",options:[{description:"Limit output to a single package",name:"package",type:String},{description:"Emit a JSON `{ name: { from, to } }` map instead of pretty lines",name:"json",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Bootstrap mode for greenfield monorepos: preview the plan without registry / tag lookups (matches `vis release version --first-release`).",name:"first-release",type:Boolean}]},y8={commandPath:["release"],description:"Dry-run the configured notification channels (slack / discord / webhook / plugins) with a synthetic release",examples:[["vis release notifications test","Dispatch a fake release to every configured channel"],["vis release notifications test --channel=slack","Dispatch to every Slack channel only"],["vis release notifications test --channel=slack:eng","Dispatch to the slack channel with id=eng only"],["vis release notifications test --custom-context=./fake.json","Use operator-supplied JSON instead of the built-in synthetic release"],["vis release notifications test --json","Emit machine-readable results"]],group:"Release",loader:()=>import("./handler42.js"),name:"notifications",options:[{defaultOption:!0,defaultValue:"test",description:"Subcommand: test",name:"action",type:String},{description:"Restrict dispatch to a single channel kind (`slack`, `discord`, `webhook`) or an id'd channel (`slack:eng`)",name:"channel",type:String},{description:"Path to a JSON file containing a NotificationContext to use instead of the synthetic default",name:"custom-context",type:String},{description:"Emit machine-readable JSON instead of a per-channel report",name:"json",type:Boolean}]},v8={commandPath:["release"],description:"Inspect the release plan; with --interactive, walk through and override bump levels",examples:[["vis release plan","Emit pending plan as JSON"],["vis release plan --interactive","Walk through pending releases, accept or override each bump"],["vis release plan -i --write","Walk through interactively and write the chosen overrides to a change file"]],group:"Release",loader:()=>import("./handler43.js"),name:"plan",options:[{description:"Filter packages by name glob",name:"filter",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{alias:"i",description:"Walk through pending releases interactively and accept / override each bump level",name:"interactive",type:Boolean},{description:"When used with --interactive, write the chosen overrides to a new change file (.vis/release/<id>.md)",name:"write",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},b8={commandPath:["release"],description:"Enter / exit pre-release mode (changesets-compatible — every `version` produces a prerelease until exit)",examples:[["vis release pre enter alpha","Enter pre-mode with the `alpha` tag"],["vis release pre enter rc --no-commit","Enter pre-mode locally without committing pre.json"],["vis release pre exit","Flag the next `version` to consolidate + exit pre-mode"],["vis release pre status","Print whether pre-mode is active, exit-pending, or off"]],group:"Release",loader:()=>import("./handler45.js"),name:"pre",options:[{defaultOption:!0,defaultValue:"status",description:"Subcommand: enter | exit | status",name:"action",type:String},{description:"Prerelease tag (e.g. alpha, beta, rc). Required for `enter`",multiple:!0,name:"tag",type:String},{defaultValue:!0,description:"Commit pre.json after writing. Default: commit",name:"commit",type:Boolean},{defaultValue:!0,description:"Push the commit. Default: push",name:"push",type:Boolean}]},w8={commandPath:["release"],description:"Publish non-functional placeholder packages so npm Trusted Publishing (OIDC) can be configured before the first release",examples:[["vis release pretrust","Publish a placeholder for every managed package missing from the registry"],["vis release pretrust --filter '@scope/*'","Limit to a glob"],["vis release pretrust --dry-run","Print what would be published without uploading"]],group:"Release",loader:()=>import("./handler57.js"),name:"pretrust",options:[{description:"Glob filter (CSV) — limit to specific packages",name:"filter",type:String},{description:"dist-tag for the placeholder (default: placeholder — keeps `latest` unset)",name:"tag",type:String},{description:"Placeholder version (default: 0.0.0)",name:"version",type:String},{description:"Publish access: public | restricted (default: public)",name:"access",type:String},{description:"Override registry URL",name:"registry",type:String},{description:"Publish a placeholder even if the package already exists on the registry",name:"force",type:Boolean},{description:"Skip the `npm trust` step (only publish placeholders)",name:"no-trust",type:Boolean},{description:"Trust claim: forge provider (github | gitlab). Default: auto-detect from the git remote",name:"provider",type:String},{description:"Trust claim: owner/repo (github) or group/project (gitlab). Default: detect from git remote",name:"repo",type:String},{description:"Trust claim: workflow/pipeline filename (npm trust --file). Default: auto-detect the release workflow",name:"workflow",type:String},{description:"Trust claim: restrict to a deployment environment (npm trust --env)",name:"env",type:String},{description:"Trust claim: also grant the staged-publish permission (--allow-stage-publish)",name:"allow-stage-publish",type:Boolean},{description:"Print what would publish without uploading",name:"dry-run",type:Boolean},{description:"Print the resolved release config and exit",name:"print-config",type:String}]},k8={commandPath:["release"],description:"Pack-then-publish unpublished packages, push tags, create GH releases",examples:[["vis release publish","Publish all pending packages"],["vis release publish --dry-run","Print what would publish without uploading"],["vis release publish --tag alpha","Override dist-tag"],["vis release publish --filter '@scope/*'","Limit to packages matching the glob"]],group:"Release",loader:()=>import("./handler46.js"),name:"publish",options:[{description:"Skip uploads — print what would happen",name:"dry-run",type:Boolean},{description:"Override npm dist-tag",name:"tag",type:String},{description:"Limit to packages matching this glob (CSV)",name:"filter",type:String},{description:"Skip `git push --tags` after publish (lands in M5)",name:"no-push",type:Boolean},{description:"2FA OTP token",name:"otp",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Resume from a previous run's state file (skips already-published packages)",name:"resume",type:Boolean},{description:"Run preflight checks (config + workspace + plan + auth) and exit. No mutations.",name:"check-only",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",name:"first-release",type:Boolean}]},S8={commandPath:["release"],description:"Publish 0.0.0-<tag>-<sha> snapshot versions of affected packages",examples:[["vis release snapshot --tag pr-1234","Publish snapshots tagged with the PR number"],["vis release snapshot --tag canary --filter '@scope/*'","Limit to a glob"],["vis release snapshot --tag pr-1234 --dry-run","Preview without uploading"]],group:"Release",loader:()=>import("./handler47.js"),name:"snapshot",options:[{description:"Required: dist-tag for the snapshot release",name:"tag",type:String},{description:"Override registry URL (defaults to pkg-pr-new backend or `release.snapshot.registry`)",name:"registry",type:String},{description:"Glob filter (CSV) — limit snapshots to specific packages",name:"filter",type:String},{description:"Print what would publish without uploading",name:"dry-run",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},x8={commandPath:["release"],description:"List, approve, or reject npm staged-publish records (RFC §13.6 — approve/reject need 2FA)",examples:[["vis release stage list","List every staged version (both npm + the local .vis/release/staged.json registry)"],["vis release stage list @scope/pkg","List staged versions for a single package"],["vis release stage list --json","Emit a machine-readable view of both sources"],["vis release stage approve <stage-id>","Promote a staged version, drain it from staged.json, commit + push the registry"],["vis release stage approve --all","Approve every pending stage tracked in .vis/release/staged.json"],["vis release stage reject <stage-id>","Reject a staged version (permanent — cannot be re-approved unless re-staged)"],["vis release stage approve <stage-id> --no-push","Approve, update the registry, commit locally (skip the push)"],["vis release stage approve <stage-id> --no-commit","Approve and update the registry only — no git commit"]],group:"Release",loader:()=>import("./handler48.js"),name:"stage",options:[{defaultOption:!0,defaultValue:"list",description:"Subcommand: list | approve | reject",name:"action",type:String},{description:"Stage IDs (positional args after the action)",multiple:!0,name:"stage-ids",type:String},{description:"Approve every pending stage tracked in .vis/release/staged.json",name:"all",type:Boolean},{description:"Package name filter for `list`",name:"filter",type:String},{description:"Emit machine-readable JSON",name:"json",type:Boolean},{defaultValue:!0,description:"Update .vis/release/staged.json but skip the auto-commit. Default: commit",name:"commit",type:Boolean},{defaultValue:!0,description:"Skip pushing the registry commit to the remote. Default: push",name:"push",type:Boolean}]},$8={commandPath:["release"],description:"Print pending release plan (which packages will bump and to what version)",examples:[["vis release status","Print pending plan in human-readable format"],["vis release status --json","Emit the plan as JSON for scripting / CI"],["vis release status --bump major,minor","Filter to packages getting major or minor bumps"],["vis release status --filter '@scope/*'","Show only packages matching the glob"]],group:"Release",loader:()=>import("./handler44.js"),name:"status",options:[{description:"Emit machine-readable JSON instead of a table",name:"json",type:Boolean},{description:"Filter packages by name glob",name:"filter",type:String},{description:"Filter by bump level (CSV: major,minor,patch)",name:"bump",type:String},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String}]},E8={commandPath:["release"],description:"Apply pending change files to disk: bump versions + write CHANGELOG entries",examples:[["vis release version","Apply the plan to disk"],["vis release version --dry-run","Print what would change without touching disk"],["vis release version --channel alpha","Force a specific channel (overrides branch detection)"]],group:"Release",loader:()=>import("./handler49.js"),name:"version",options:[{description:"Skip writes — print the diff and exit",name:"dry-run",type:Boolean},{description:"Override channel (defaults to current branch lookup)",name:"channel",type:String},{description:"Limit to packages matching this glob (CSV)",name:"filter",type:String},{description:"Auto-commit after applying",name:"commit",type:Boolean},{description:"Run preflight checks (config + workspace + plan) and exit. No mutations.",name:"check-only",type:Boolean},{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",name:"print-config",type:String},{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",name:"first-release",type:Boolean}]},C8=[r8,h8,$8,v8,i8,o8,f8,g8,E8,k8,S8,x8,b8,w8,m8,y8,a8,c8,d8,l8,p8,u8],R8={alias:["rm","un","uninstall"],argument:{description:"Packages to remove",name:"packages",type:String},description:"Remove packages using the detected package manager",examples:[["vis remove lodash","Remove a package"],["vis rm old-package","Remove using alias"],["vis remove --filter app react","Remove from specific workspace"],["vis remove -g typescript","Remove global package"]],group:"Dependencies",loader:()=>import("./handler18.js"),name:"remove",options:[{alias:"D",defaultValue:!1,description:"Remove from devDependencies",name:"save-dev",type:Boolean},{alias:"g",defaultValue:!1,description:"Remove global package",name:"global",type:Boolean},{alias:"r",defaultValue:!1,description:"Remove from all workspace packages",name:"recursive",type:Boolean},{alias:"w",defaultValue:!1,description:"Remove from workspace root",name:"workspace-root",type:Boolean},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String}]},j8={description:"Replay a previous task run from .vis/runs/ — show task results without re-executing",examples:[["vis replay","Show the most recent run summary"],["vis replay --run 2026-04-28T12-34-56_ab12","Inspect a specific historical run"],["vis replay --list","List every recorded run, newest first"],["vis replay --task @myorg/app:build","Focus on one task within the loaded run"],["vis replay --failed","Filter to only failed tasks"],["vis replay --format=json","Machine-readable output for CI"]],group:"Workspace",loader:Z(()=>import("./handler19.js"),"replayExecute"),name:"replay",options:[{description:"Run id to replay (defaults to the most recent run)",name:"run",type:String},{defaultValue:!1,description:"List every available run instead of replaying one",name:"list",type:Boolean},{description:"Filter the replay to a single task id (e.g. @my/app:build)",name:"task",type:String},{defaultValue:!1,description:"Filter the replay to failed tasks only",name:"failed",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]},T8={argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target across workspace projects",examples:[["vis run","List all available targets"],["vis run build","Run build on all projects"],["vis run :build","Run build on all projects (moon-style)"],["vis run ~:test","Run test on the project closest to the current directory"],['vis run "#frontend:build"',"Run build on projects tagged 'frontend'"],['vis run :build --query "language=typescript"',"Filter by project metadata"],['vis run build --filter "@org/web"',"Run build on a single package (pnpm filter)"],['vis run build --filter "...@org/web"',"Run build on @org/web and everything that depends on it"],['vis run build -F "@org/web..."',"Run build on @org/web and its dependencies"],['vis run build -F "...[origin/main]"',"Run build on packages changed since origin/main + their dependents"],['vis run build -F "./packages/*"',"Run build on packages matched by a path glob"],["vis run test --affected","Run test only on git-changed projects"],["vis run build --fail-fast","Stop on first failure"],["vis run build --dry-run","Show execution plan without running"],["vis run destroy --reverse","Run leaves-first (teardown order, e.g. CDK/Pulumi destroy)"]],group:"Run & Execute",loader:()=>import("./handler77.js"),name:"run",options:[{alias:"p",description:"Comma-separated list of projects to run",name:"projects",type:String},{alias:"F",description:"pnpm-style package selector (repeatable). Supports name globs (@org/*), graph modifiers (...pkg dependents, pkg... dependencies, ...^pkg / pkg^... exclude self), changed-since ([main], ...[origin/main]), and path globs (./packages/*, {glob}).",multiple:!0,name:"filter",type:String},{defaultValue:!1,description:"Skip the toolchain pre-flight (no auto-install for any pinned tool: node / pnpm / yarn / npm / bun / deno / go / python / ruby / rust)",name:"skip-toolchain",type:Boolean},...Ge({description:"Detect lockfile/node_modules drift before running (warns in TTY, fails in CI). Use --no-preflight to disable.",name:"preflight",type:Boolean}),{defaultValue:3,description:"Maximum number of parallel tasks (falls back to VIS_RUN_CONCURRENCY_LIMIT env var, then 3)",name:"parallel",type:Number},...Ge({defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean}),{description:"Comma-separated selectors of tasks to bypass cache for (e.g. 'app:test', ':e2e', '#flaky:lint'). Other tasks in the run still cache normally. --no-cache wins when both are set.",name:"skip-cache",type:String},{description:"Custom cache directory",name:"cache-dir",type:String},{description:"Remote cache mode: read | write | readwrite (defaults to readwrite when remoteCache is configured)",name:"cache-mode",type:String},{description:"Remote cache wire backend: http (Turborepo-compatible) or reapi (Bazel Remote Execution API gRPC)",name:"cache-backend",type:String},{description:"Override how the requested target is hashed for this run: declared (hash listed inputs) or trace (hash the files the task actually reads). Overrides per-target hashMode config for the directly-run target.",name:"hash-mode",type:String},{defaultValue:!1,description:"Show what would run without executing",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Generate a run summary after execution",name:"summarize",type:Boolean},{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',name:"partition",type:String},{defaultValue:!1,description:"Skip project constraint validation",name:"skip-constraints",type:Boolean},{description:"Filter matched projects by a query (e.g. 'language=typescript && tag=lib')",name:"query",type:String},{description:'Only run projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…"; combines with --query as AND.',multiple:!0,name:"tag",type:String},{defaultValue:!1,description:"Only run on projects affected by git changes. Honors --base/--head/--downstream/--upstream, same as `vis affected`.",name:"affected",type:Boolean},{description:"Git base ref for --affected. When omitted, vis auto-resolves it from the active CI provider (GitHub/GitLab/Buildkite/CircleCI) or falls back to `git merge-base HEAD origin/<defaultBase>` locally. Default base branch comes from `vis.config.ts#defaultBase` (or `main`). Requires --affected.",name:"base",type:String},{description:"Git head ref for --affected. When omitted, auto-resolves from CI env (e.g. `$GITHUB_SHA`) or defaults to `HEAD`. Requires --affected.",name:"head",type:String},{description:'Downstream scope for --affected: "none", "direct", or "deep" — controls how far to include dependents of changed projects (default "deep"). Requires --affected.',name:"downstream",type:String},{description:'Upstream scope for --affected: "none", "direct", or "deep" — controls how far to include dependencies of changed projects (default "none"). Requires --affected.',name:"upstream",type:String},...Ge({description:"Include uncommitted working-tree changes when computing --affected. Defaults to on for local runs and off in CI; use --no-uncommitted to force off.",name:"uncommitted",type:Boolean}),{defaultValue:!1,description:"Rerun affected tasks on file change. Ctrl+C to exit.",name:"watch",type:Boolean},{defaultValue:!1,description:"Stop all tasks on first failure",name:"fail-fast",type:Boolean},{defaultValue:!1,description:"Run the dependency graph in reverse (leaves first, then their dependents). Useful for teardown targets like `destroy`/`undeploy` where dependents must run before the things they depend on.",name:"reverse",type:Boolean},{description:"Output mode: interleaved (pass-through), labeled (prefix each line with [pkg#task]), or grouped (vite-task-style block)",name:"log",type:String},{description:"Output style: normal (print every task) or quiet (skip output for successful/cached tasks; failed tasks still print in CI mode, and remain in TUI scrollback in interactive mode). Defaults to normal; set run.quietOnSuccess in config to make quiet the default. Per-target options.outputStyle overrides this.",name:"output-style",type:String},{defaultValue:!1,description:"Run every task through a pseudo-terminal so color-aware tools render as if attached to a TTY (disables caching)",name:"pty",type:Boolean},{description:"Global retry budget: cap on total task retries across the run (per-target retryCount is still honored up to the budget)",name:"retry-budget",type:Number},{description:"Write a Chrome Tracing JSON profile of the run to this path (open in chrome://tracing or Perfetto)",name:"profile",type:String},{defaultValue:!1,description:"Render the most-recent run's saved summary (from .vis/last-summary.json) and exit without executing any tasks",name:"last-details",type:Boolean},...Ge({defaultValue:!0,description:"Show flaky task report on failure (use --no-flaky to suppress)",name:"flaky",type:Boolean}),{defaultValue:!1,description:"Treat any task that needed at least one retry as a run failure (exit non-zero), even when retries eventually succeeded. Use in CI to surface flakes that retries would otherwise mask.",name:"fail-on-retry",type:Boolean},...Ge({description:"Fail a task if its command references an env var that is unset (no silent empty-string substitution). Use --no-strict-env to disable when set in config.",name:"strict-env",type:Boolean}),{description:"Comma-separated tags this runner advertises (e.g. 'gpu,slow'). Tasks declaring `options.runnerTags` only run when at least one tag overlaps. Untagged tasks always run. Falls back to VIS_RUNNER_TAGS env var.",name:"runner-tags",type:String},{description:"Auto-start service deps. One of: auto | ephemeral | persistent | off. Defaults to `auto` in TTY, `off` in CI.",name:"services",type:String},{defaultValue:!1,description:"Stop services this run auto-started in registry mode when the run exits (clean, q, or Ctrl+C). Ephemeral services already die with the run.",name:"stop-services",type:Boolean}]},O8={description:"Generate a CycloneDX 1.7 Software Bill of Materials for the workspace",examples:[["vis sbom","Write the full-workspace SBOM to sbom.cdx.json"],["vis sbom --focus=my-app","Scope the SBOM to my-app's transitive closure"],["vis sbom --focus=my-app,other","Focus multiple projects"],["vis sbom --format=xml --output=sbom.cdx.xml","Emit XML instead of JSON"],["vis sbom --include-dev","Include devDependencies (default: production only)"],["vis sbom --output=-","Write to stdout"]],group:"Security & Health",loader:()=>import("./handler20.js"),name:"sbom",options:[{description:"Project name(s) to focus on — comma-separated for multiple",name:"focus",type:String},{defaultValue:"json",description:"Output format: json (default) or xml",name:"format",type:String},{description:"Output path (use '-' for stdout; default: sbom.cdx.json)",name:"output",type:String},{defaultValue:!1,description:"Include devDependencies (default: production only)",name:"include-dev",type:Boolean}]},A8={argument:{description:"One or more paths to scan (defaults to workspace root)",name:"paths",type:String},description:"Scan a repository for hardcoded secrets and credentials",examples:[["vis secrets","Scan the workspace with grouped, colourised output"],["vis secrets --staged","Scan only files staged for the current commit (pre-commit hooks)"],["vis secrets --since main","Scan only files changed since the `main` branch"],["vis secrets --affected","Scan only projects affected by the current branch"],["vis secrets --history","Scan the full git history for secrets that were committed then removed"],["vis secrets --history --history-range main..HEAD","Scan only commits on the current branch since main"],["vis secrets --history --max-commits 100 --redact","Scan the last 100 commits, masking any secret values"],["vis secrets --init","Write an initial baseline from current findings"],["vis secrets --list-rules","Print all bundled detection rules"],["vis secrets --list-validators","Print non-HTTP validator types in the ruleset + install hints for each"],["vis secrets --exclude-rule generic-api-key --exclude-rule aws-access-token","Drop noisy rules"],["vis secrets --include-rule stripe-access-token","Check a single rule"],["vis secrets --enable-rule tag:preset:weak-passwords","Enable an opt-in rule group additively (defaults still fire)"],["vis secrets --include-rule tag:preset:password-manager","Restrict output to one opt-in group only"],["vis secrets --min-confidence high","Drop rules without a high confidence label (CI-friendly precision filter)"],["vis secrets --validate --only-verified","Live-verify each finding against its provider (one HTTP call per finding)"],["vis secrets --exclude 'dist/**' --exclude-from .secretsignore","Extra gitignore-syntax exclusions for the walker"],["vis secrets --config ./leaks.json --no-extend-bundled","Use only the supplied config, skip the bundled ruleset"],["vis secrets --concurrency 4","Cap the rayon thread pool (0 / omit = auto)"],["vis secrets --baseline .secrets-baseline.json","Suppress known findings; print diff vs. baseline"],["vis secrets --update-baseline","Merge current findings into the baseline (use --replace-baseline to overwrite)"],["vis secrets --format sarif > report.sarif","SARIF output for GitHub code-scanning"]],group:"Security",loader:()=>import("./handler78.js"),name:"secrets",options:[{description:"Path to a JSON config (gitleaks-compatible shape). Defaults to the bundled ruleset.",name:"config",type:String},{description:"Drop rules below this author-declared confidence: low (default), medium, high. Rules without a declared confidence (every gitleaks rule) are treated as low, so --min-confidence medium or higher drops them along with explicit low-confidence rules.",name:"min-confidence",type:String},{defaultValue:!1,description:"Live-verify each finding against its provider (one HTTP call per finding, max 8 concurrent). Only supports Kingfisher-style HTTP validators with StatusMatch / WordMatch response matchers; other types (gRPC, multi-step, checksum) mark the finding as validation=skipped. WARNING: sends candidate secrets to the provider — some providers alert their security team on failed auth attempts.",name:"validate",type:Boolean},{defaultValue:!1,description:"With --validate, drop every finding whose validation is not 'verified'. Useful for CI gating.",name:"only-verified",type:Boolean},{defaultValue:!1,description:"With --config, do not merge on top of the bundled ruleset — replace it.",name:"no-extend-bundled",type:Boolean},{defaultValue:"text",description:"Output format: text (default), json, sarif",name:"format",type:String},{description:"Path to a baseline JSON of previously-triaged findings",name:"baseline",type:String},{defaultValue:!1,description:"Scan only files staged for commit",name:"staged",type:Boolean},{description:"Scan only files changed since <ref> (e.g. main, origin/HEAD)",name:"since",type:String},{defaultValue:!1,description:"Scan only projects affected by the current branch",name:"affected",type:Boolean},{defaultValue:!1,description:"Scan the entire git history (every added/modified blob across commits) instead of the working tree. Surfaces secrets that were committed and later removed. Cannot be combined with --staged/--since/--affected.",name:"history",type:Boolean},{description:"With --history, limit the walk to a rev-list range (e.g. main..HEAD, HEAD~50..HEAD, or a single ref). Defaults to all reachable history of HEAD.",name:"history-range",type:String},{description:"With --history, cap the number of commits walked (most-recent first)",name:"max-commits",type:Number},{description:"Enable an opt-in rule or tag without restricting output — additive (e.g. tag:preset:weak-passwords, tag:preset:password-manager). Repeatable.",multiple:!0,name:"enable-rule",type:String},{description:"Rule id or tag:<name> selector — whitelist, only matching findings are emitted. Implies enablement. Repeatable.",multiple:!0,name:"include-rule",type:String},{description:"Rule id or tag:<name> selector — drop matching findings. Repeatable.",multiple:!0,name:"exclude-rule",type:String},{description:"Gitignore-syntax pattern to exclude from the walk (repeatable)",multiple:!0,name:"exclude",type:String},{description:"Path to a gitignore-shaped file the walker should honor (repeatable)",multiple:!0,name:"exclude-from",type:String},{defaultValue:!1,description:"Mask secret values in output",name:"redact",type:Boolean},{defaultValue:!1,description:"Scan dotfiles",name:"include-hidden",type:Boolean},{defaultValue:!1,description:"Do not respect .gitignore",name:"no-gitignore",type:Boolean},{description:"Skip files larger than this (bytes). Default: 10 MiB",name:"max-size",type:Number},{description:"Rayon worker threads (0 / omit = auto)",name:"concurrency",type:Number},{defaultValue:!1,description:"Merge current findings into the baseline and exit 0",name:"update-baseline",type:Boolean},{defaultValue:!1,description:"With --update-baseline, replace rather than merge",name:"replace-baseline",type:Boolean},{defaultValue:!1,description:"Scaffold a baseline from current findings",name:"init",type:Boolean},{defaultValue:!1,description:"With --init, preview the baseline without writing files",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Print all bundled detection rules and exit",name:"list-rules",type:Boolean},{defaultValue:!1,description:"Print non-HTTP validator types referenced by the current ruleset, with install hints for their optional peer dependencies.",name:"list-validators",type:Boolean},{defaultValue:!1,description:"Suppress all progress output (only emit findings)",name:"quiet",type:Boolean},{defaultValue:!1,description:"Print diagnostic info (skipped rules, etc.)",name:"verbose",type:Boolean}]},I8={commandPath:["security"],description:"List build-script status — allowed, unapproved, and stale allowlist entries",examples:[["vis security list","Show the full build-script triage report"],["vis security list --json","Emit the report as JSON for tooling"]],group:"Security & Health",loader:()=>import("./list.js"),name:"list",options:[{defaultValue:!1,description:"Emit the report as JSON instead of human-readable text",name:"json",type:Boolean}]},B8={commandPath:["security"],description:"Push vis.config security settings to the package manager's native config",examples:[["vis security sync","Sync allowBuilds + minimumReleaseAge to the PM-native config files"],["vis security sync --skip-allow-builds","Sync only the minimumReleaseAge knobs"],["vis security sync --skip-min-release-age","Sync only allowBuilds (trustedDependencies / onlyBuiltDependencies)"]],group:"Security & Health",loader:()=>import("./sync2.js"),name:"sync",options:[{defaultValue:!1,description:"Skip syncing allowBuilds (trustedDependencies, onlyBuiltDependencies)",name:"skip-allow-builds",type:Boolean},{defaultValue:!1,description:"Skip syncing minimumReleaseAge and its excludes",name:"skip-min-release-age",type:Boolean}]},P8={commandPath:["security"],description:"Run lifecycle scripts for packages in security.policies.installScripts.allow (LavaMoat 'run' parity)",examples:[["vis security run","Run preinstall/install/postinstall for every approved package"],["vis security run --with-root","Also run the workspace root's prepublish + prepare hooks"],["vis security run --root-only","Run only the workspace root's prepublish + prepare hooks"]],group:"Security & Health",loader:()=>import("./run.js"),name:"run",options:[{defaultValue:!1,description:"Also run the workspace root's prepublish + prepare hooks after dependencies",name:"with-root",type:Boolean},{defaultValue:!1,description:"Skip dependency scripts and only run the workspace root's prepublish + prepare hooks",name:"root-only",type:Boolean}]},N8={commandPath:["security"],description:"Install @lavamoat/preinstall-always-fail as a devDep so a missing ignore-scripts setting fails loudly",examples:[["vis security tripwire","Install the tripwire devDependency"],["vis security tripwire --status","Report whether the tripwire is installed"],["vis security tripwire --remove","Remove the tripwire from package.json"]],group:"Security & Health",loader:()=>import("./tripwire.js"),name:"tripwire",options:[{defaultValue:!1,description:"Report whether @lavamoat/preinstall-always-fail is installed",name:"status",type:Boolean},{defaultValue:!1,description:"Remove @lavamoat/preinstall-always-fail from package.json",name:"remove",type:Boolean}]},D8={commandPath:["security"],description:"Force-refresh the cached npm signing keys used by the signatures marshall",examples:[["vis security keys-refresh","Drop the disk cache and fetch a fresh key set from registry.npmjs.org"],["vis security keys-refresh --clear","Only drop the cache, do not refetch"],["vis security keys-refresh --json","Emit the refresh result as JSON for tooling"]],group:"Security & Health",loader:()=>import("./keys-refresh.js"),name:"keys-refresh",options:[{defaultValue:!1,description:"Only clear the cache, do not refetch",name:"clear",type:Boolean},{defaultValue:!1,description:"Emit the result as JSON instead of human-readable text",name:"json",type:Boolean}]},M8={commandPath:["security"],description:"Verify the entire lockfile closure against supply-chain policies (firstSeen, publisherChange, blockExoticSubdeps)",examples:[["vis security verify-lockfile","Re-validate every locked entry; exit non-zero on a policy violation"],["vis security verify-lockfile --offline","Verify without network (skips firstSeen / publisherChange)"],["vis security verify-lockfile --json","Emit the verification result as JSON for CI"]],group:"Security & Health",loader:()=>import("./verify-lockfile.js"),name:"verify-lockfile",options:[{defaultValue:!1,description:"Emit the result as JSON instead of human-readable text",name:"json",type:Boolean},{defaultValue:!1,description:"Skip network-bound policies (firstSeen, publisherChange)",name:"offline",type:Boolean}]},L8=[I8,B8,P8,N8,D8,M8],wr={description:"Target id, e.g. @my/api:db",name:"targetId",type:String},_8={description:"Output format: table or json (default: table)",name:"format",type:String},F8={argument:wr,commandPath:["service"],description:"Start a service target detached so it survives across `vis run` invocations",examples:[["vis service start @my/api:db","Boot the db target as a long-lived service"],["vis service start @my/api:db --timeout=60000","Override readiness timeout"],["vis service start @my/api:db --no-readiness","Skip the readiness probe"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceStartExecute"),name:"start",options:[{description:"Readiness probe timeout in milliseconds",name:"timeout",type:Number},{defaultValue:!1,description:"Skip the readiness probe",name:"no-readiness",type:Boolean}]},V8={argument:{description:"Target id to stop, or omit when using --all",name:"targetId",required:!1,type:String},commandPath:["service"],description:"Stop a running service",examples:[["vis service stop @my/api:db","Stop the db service"],["vis service stop --all","Stop every running service in this workspace"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceStopExecute"),name:"stop",options:[{defaultValue:!1,description:"Stop every service registered for this workspace",name:"all",type:Boolean},{description:"Override the SIGTERM→SIGKILL grace period in milliseconds",name:"grace-ms",type:Number}]},W8={commandPath:["service"],description:"List services registered for this workspace",examples:[["vis service list","Print running services"],["vis service list --format=json","Machine-readable list"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceListExecute"),name:"list",options:[_8]},H8={argument:wr,commandPath:["service"],description:"Re-run the readiness probe and report a service's health",examples:[["vis service status @my/api:db","Check whether the db service is reachable"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceStatusExecute"),name:"status",options:[{description:"Probe timeout in milliseconds",name:"timeout",type:Number}]},U8={argument:wr,commandPath:["service"],description:"Stop and re-start a running service",examples:[["vis service restart @my/api:db","Recycle the db service"],["vis service restart @my/api:db --no-readiness","Recycle and skip the readiness probe"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceRestartExecute"),name:"restart",options:[{description:"Readiness probe timeout in milliseconds",name:"timeout",type:Number},{description:"Override the SIGTERM→SIGKILL grace period in milliseconds",name:"grace-ms",type:Number},{defaultValue:!1,description:"Skip the readiness probe after restart",name:"no-readiness",type:Boolean}]},G8={argument:wr,commandPath:["service"],description:"Print or tail a service's captured stdout/stderr",examples:[["vis service logs @my/api:db","Print the captured log"],["vis service logs @my/api:db -f","Tail the log (Ctrl-C to exit)"]],group:"Workspace",loader:Z(()=>import("./handler21.js"),"serviceLogsExecute"),name:"logs",options:[{alias:"f",defaultValue:!1,description:"Follow the log file (like `tail -f`)",name:"follow",type:Boolean}]},z8=[F8,V8,W8,H8,U8,G8],J8={commandPath:["shim"],description:"Install project-local PM shims (.vis/shims) that enforce the project's package manager",examples:[["vis shim install","Write npm/pnpm/yarn/… wrapper scripts in .vis/shims"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimInstallExecute})),name:"install"},q8={commandPath:["shim"],description:"Remove the project-local PM shim dir (.vis/shims)",examples:[["vis shim uninstall","Delete .vis/shims"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimUninstallExecute})),name:"uninstall"},K8={commandPath:["shim"],description:"Report whether the PM shims are installed and active on PATH",examples:[["vis shim status","Show shim install + PATH state"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimStatusExecute})),name:"status"},Y8=[J8,q8,K8],X8={description:"Sort package.json files across the workspace using the sort-package-json Rust crate",examples:[["vis sort-package-json","Sort all package.json files in the workspace"],["vis sort-package-json --check","Check if files are already sorted (exit 1 if not)"],["vis sort-package-json --sort-scripts","Also sort the scripts field alphabetically"],["vis sort-package-json --indent 4","Force 4-space indentation (overrides per-file detection)"],["vis sort-package-json --indent tab","Force tab indentation"],["vis sort-package-json --ignore '**/fixtures/**'","Skip files matching one or more glob patterns"],["vis sort-package-json --sort-order name,version,license","Pin a custom prefix order before the default field order"],["vis sort-package-json --unsorted dependencies,devDependencies","Preserve original key order for the listed top-level sections"],["vis sort-package-json --no-final-newline","Do not append a trailing newline"],["vis sort-package-json --line-ending crlf","Force CRLF line endings (default: auto-detect per file)"]],group:"Workspace",loader:()=>import("./handler64.js"),name:"sort-package-json",options:[{alias:"c",defaultValue:!1,description:"Check if package.json files are sorted without writing (exits 1 if unsorted)",name:"check",type:Boolean},{defaultValue:!1,description:"Also sort the scripts field alphabetically",name:"sort-scripts",type:Boolean},{description:"Indent override: a number of spaces, the literal `tab`, or a literal whitespace string. When unset, the original file's indent is preserved.",name:"indent",type:String},{description:"Glob pattern of files to skip (basename match, or path-relative when the pattern contains `/`). Repeatable.",multiple:!0,name:"ignore",type:String},{description:"Comma-separated list of top-level keys to place first, before the default field order. Repeatable.",multiple:!0,name:"sort-order",type:String},{description:"Comma-separated list of top-level sections whose key order should be preserved (e.g. dependencies,devDependencies). Repeatable.",multiple:!0,name:"unsorted",type:String},{defaultValue:!1,description:"Do not append a trailing newline to the output (default: append one).",name:"no-final-newline",type:Boolean},{defaultValue:"auto",description:"Line ending to write: auto (per-file detection, default), lf, or crlf.",name:"line-ending",type:String},{description:"Disable collapsing `bugs: { url }` to the bare string form (default: enabled).",name:"no-format-bugs",type:Boolean},{description:"Disable collapsing `repository: { type, url }` to the GitHub `owner/repo` shorthand (default: enabled).",name:"no-format-repository",type:Boolean},{description:"Disable canonical sorting of `exports` condition keys (default: enabled).",name:"no-sort-exports",type:Boolean},{description:"Disable .editorconfig discovery for indent / line-ending defaults (default: enabled).",name:"no-editorconfig",type:Boolean}]},Z8={argument:{description:"Project name or workspace-relative path of the package to extract",name:"package",type:String},description:"Extract a package into a standalone git repo, preserving its history",examples:[["vis split @scope/pkg --output ../pkg-repo","Extract a package into a new repo at ../pkg-repo"],["vis split packages/tooling/foo -o ../foo --remote git@github.com:me/foo.git --push","Extract, set origin, and push"],["vis split @scope/pkg -o ../pkg --remove","Extract, then delete the package from the monorepo (committed)"],["vis split @scope/pkg --dry-run","Print the git plan without making changes"]],group:"Workspace",loader:()=>import("./handler23.js"),name:"split",options:[{alias:"o",description:"Destination directory for the new repo (required unless --dry-run)",name:"output",type:String},{alias:"b",description:'Default branch name in the new repo (default: vis.config defaultBase or "main")',name:"branch",type:String},{description:"Git remote URL to set as origin on the new repo",name:"remote",type:String},{defaultValue:!1,description:"Push the new repo to origin (requires --remote)",name:"push",type:Boolean},{defaultValue:!1,description:"Delete the package from the monorepo after extracting and commit the removal",name:"remove",type:Boolean},{defaultValue:!1,description:"Prefix the rewritten commit messages with the package name",name:"annotate",type:Boolean},{defaultValue:!1,description:"Use a non-empty --output directory anyway",name:"force",type:Boolean},{defaultValue:!1,description:"Print the git plan instead of executing it",name:"dry-run",type:Boolean}]},Q8={description:"Run linters on staged files using config from vis.config.ts",examples:[["vis staged","Run staged linters"],["vis staged --verbose","Run with verbose output"],["vis staged --no-stash","Run without backup stash"],["vis staged --diff HEAD~1","Run against a specific diff"]],group:"Run & Execute",loader:()=>import("./handler75.js"),name:"staged",options:[{defaultValue:!1,description:"Allow empty commits when tasks revert all staged changes",name:"allow-empty",type:Boolean},{defaultValue:!1,description:"Automatically stage new files that tasks create during the run",name:"auto-stage",type:Boolean},{description:"Number of concurrent tasks or false for serial",name:"concurrent",type:String},{defaultValue:!1,description:"Run all tasks to completion even if one fails",name:"continue-on-error",type:Boolean},{description:"Working directory to run all tasks in",name:"cwd",type:String},{defaultValue:!1,description:"Enable debug output",name:"debug",type:Boolean},{description:"Override the default --staged flag of git diff",name:"diff",type:String},{description:"Override the default diff-filter",name:"diff-filter",type:String},{defaultValue:!1,description:"Fail with exit code 1 when tasks modify tracked files",name:"fail-on-changes",type:Boolean},{defaultValue:!1,description:"Kill in-flight tasks with SIGKILL on fast-fail instead of the default SIGTERM",name:"force-kill",type:Boolean},{defaultValue:!1,description:"Hide unstaged changes from partially staged files",name:"hide-partially-staged",type:Boolean},{defaultValue:!1,description:"Hide all unstaged changes before running tasks",name:"hide-unstaged",type:Boolean},{defaultValue:!1,description:"Suppress console output",name:"quiet",type:Boolean},{defaultValue:!1,description:"Pass filepaths relative to cwd to tasks",name:"relative",type:Boolean},{defaultValue:!1,description:"Revert to original state in case of errors",name:"revert",type:Boolean},{defaultValue:!0,description:"Enable backup stash",name:"stash",type:Boolean},{defaultValue:!1,description:"Show task output even when tasks succeed",name:"verbose",type:Boolean}]},e3={description:"Show a workspace health dashboard at a glance",examples:[["vis status","Full status overview"],["vis status --json","Machine-readable output"]],group:"Workspace",loader:()=>import("./handler24.js"),name:"status",options:[{defaultValue:!1,description:"Emit JSON output",name:"json",type:Boolean}]},t3={argument:{description:"What to sync: codeowners | package-json-fields",name:"kind",type:String},description:"Synchronise derived workspace artefacts (codeowners, package.json fields, tsconfig refs, …)",examples:[["vis sync codeowners","Generate CODEOWNERS at the repository root"],["vis sync codeowners --out=.github/CODEOWNERS","Write to .github/CODEOWNERS instead"],["vis sync codeowners --check","Fail if the existing file is stale"],["vis sync codeowners --from=project-json,nested-codeowners","Also aggregate nested CODEOWNERS files in the tree"],["vis sync codeowners --regeneration-command='pnpm codeowners'","Set a custom header instruction"],["vis sync codeowners --preserve-block","Splice the generated block between markers in an existing CODEOWNERS"],["vis sync codeowners --write-guard","Also emit GitHub + GitLab Write Guard CI for restricted projects"],["vis sync package-json-fields","Mirror license/author/repository/bugs/homepage/engines from root to every workspace package"],["vis sync package-json-fields --check","Fail if any workspace package.json is out of sync"],["vis sync package-json-fields --fields license,engines","Override the default field list for this run"]],group:"Workspace",loader:()=>import("./handler62.js"),name:"sync",options:[{description:"Output path for the generated file (default: <workspace>/CODEOWNERS) — codeowners kind only",name:"out",type:String},{defaultValue:!1,description:"Verify state without writing (exit non-zero if drift is found)",name:"check",type:Boolean},{description:"Input sources for codeowners. Comma-separated or repeated. Values: project-json | nested-codeowners | package-json-maintainers. Defaults to project-json.",multiple:!0,name:"from",type:String},{description:"Glob (repeatable) used to discover nested CODEOWNERS files. Defaults to `**/CODEOWNERS`.",multiple:!0,name:"nested-includes",type:String},{description:"Header instruction shown to reviewers (replaces the default 'update project.json' note). Codeowners kind only.",name:"regeneration-command",type:String},{defaultValue:!1,description:"Splice the generated block between markers in the existing file instead of overwriting it. Codeowners kind only.",name:"preserve-block",type:Boolean},{defaultValue:!1,description:"Also emit a .github/workflows/write-guard.yml scoped to projects with `restricted: true` in project.json. Codeowners kind only.",name:"write-guard",type:Boolean},{description:"Comma-separated list of fields to mirror from root → workspace packages (package-json-fields kind only). Repeatable.",multiple:!0,name:"fields",type:String},{description:"Glob pattern of package names to skip (package-json-fields kind only). Repeatable.",multiple:!0,name:"ignore-package-name",type:String},{defaultValue:"human",description:"Output format for package-json-fields: human | json",name:"format",type:String},{defaultValue:!1,description:"Suppress per-package log lines; print only the summary (package-json-fields kind only)",name:"quiet",type:Boolean}]},n3={argument:{description:"Task ID to explain (e.g. @my/app:build)",name:"taskId",type:String},description:"Explain why a task is included in the graph by walking its dependency chain to a root",examples:[["vis task-why @myorg/app:build","Show what pulls build in"],["vis task-why lib-a:test","Check the test task's triggers"]],group:"Workspace",loader:()=>import("./handler25.js"),name:"task-why"},fs="Workspace",s3={commandPath:["toolchain"],description:"Show every detected manager + expected vs actual tool versions",examples:[["vis toolchain status","Show every detected manager + expected vs actual tool versions"],["vis toolchain status --json","Emit the status as JSON"],["vis toolchain status --exit-code","Exit 1 if any tool mismatches (for CI)"]],group:fs,loader:Z(()=>import("./handler26.js"),"statusExecute"),name:"status",options:[{defaultValue:!1,description:"Exit 1 if any tool mismatches",name:"exit-code",type:Boolean},{defaultValue:!1,description:"Emit JSON",name:"json",type:Boolean}]},r3={commandPath:["toolchain"],description:"Print the primary manager's name (for scripts)",examples:[["vis toolchain detect","Print the primary manager's name"]],group:fs,loader:Z(()=>import("./handler26.js"),"detectExecute"),name:"detect"},i3={commandPath:["toolchain"],description:"Install pinned versions — per-tool delegation to the right manager",examples:[["vis toolchain install","Install pinned versions"],["vis toolchain install --dry-run","Print the commands that would run, but don't execute"]],group:fs,loader:Z(()=>import("./handler26.js"),"installExecute"),name:"install",options:[{defaultValue:!1,description:"Print the command that would run, but don't execute",name:"dry-run",type:Boolean}]},o3={argument:{description:"Tool and version to pin, e.g. node@22.13.0 or pnpm@10.32.1",name:"spec",type:String},commandPath:["toolchain"],description:"Pin a version via the best manager for that tool",examples:[["vis toolchain use node@22.13.0","Pin node 22.13.0 via the best runtime manager"],["vis toolchain use pnpm@10.32.1","Update the packageManager field; pnpm self-activates"],["vis toolchain use node@22.13.0 --dry-run","Print the command without running it"]],group:fs,loader:Z(()=>import("./handler26.js"),"useExecute"),name:"use",options:[{defaultValue:!1,description:"Print the command that would run, but don't execute",name:"dry-run",type:Boolean},{defaultValue:!0,description:"Also mirror the version into engines.<tool> when that field already exists. --no-engines to skip.",name:"engines",type:Boolean}]},a3={argument:{description:"Tool to resolve, e.g. node",name:"tool",type:String},commandPath:["toolchain"],description:"Print the resolved binary path a manager would launch for a tool",examples:[["vis toolchain which node","Resolve the node binary the manager would launch"]],group:fs,loader:Z(()=>import("./handler26.js"),"whichExecute"),name:"which"},c3=[s3,r3,i3,o3,a3],l3={argument:{description:"Packages to unlink (omit for current package)",name:"packages",type:String},description:"Unlink a previously linked package",examples:[["vis unlink","Unlink current package"],["vis unlink react","Unlink specific package"],["vis unlink -r","Unlink in all workspace packages"]],group:"Dependencies",loader:()=>import("./handler27.js"),name:"unlink",options:[{alias:"r",defaultValue:!1,description:"Unlink in all workspace packages",name:"recursive",type:Boolean}]},d3={alias:"up",argument:{description:"Packages to update (updates all if omitted)",name:"packages",type:String},description:"Update packages to their latest versions",examples:[["vis update react","Update react within semver range"],["vis up react -L","Update react to latest"],["vis update -i","Interactive mode"],["vis update --filter app","Update in specific workspace"],["vis update -r","Update in all workspaces"],["vis update --target minor","Only apply minor/patch updates (catalog mode)"],["vis update --dry-run","Preview changes without applying"],["vis update --exclude '@types/*'","Exclude packages by pattern"],["vis update --changelog","Show changelog links after updating"],["vis update --rollback","Restore catalog from last backup"],["vis update --ai","Run AI analysis before applying updates"]],group:"Dependencies",loader:()=>import("./handler74.js"),name:"update",options:[{alias:"L",conflicts:"target",description:"Update to latest version (ignore semver range; equivalent to --target latest)",name:"latest",type:Boolean},{defaultValue:!1,description:"Ignore the minimumReleaseAge gate and select the truly latest version even if freshly published. The selected packages are added to the package manager's native age-gate exclude list (pnpm minimumReleaseAgeExclude, bun minimumReleaseAgeExcludes, yarn npmPreapprovedPackages) so the follow-up install isn't blocked; npm has no per-package exclude. Combine with --latest to also cross the semver range.",name:"ignore-release-age",type:Boolean},{alias:"t",conflicts:"latest",description:"Update target: latest, minor, or patch (default: latest, catalog mode)",name:"target",type:String},{alias:"d",defaultValue:!1,description:"Preview changes without applying",name:"dry-run",type:Boolean},{alias:"g",defaultValue:!1,description:"Update global packages",name:"global",type:Boolean},{alias:"r",defaultValue:!1,description:"Update recursively in all workspace packages",name:"recursive",type:Boolean},{description:"Filter packages in monorepo (pm-wrapper mode; catalog mode uses --include/--exclude)",name:"filter",type:String},{alias:"w",defaultValue:!1,description:"Include workspace root",name:"workspace-root",type:Boolean},{alias:"D",conflicts:"prod",description:"Update only devDependencies",name:"dev",type:Boolean},{alias:"P",conflicts:"dev",description:"Update only dependencies",name:"prod",type:Boolean},{alias:"i",defaultValue:!1,description:"Interactive mode",name:"interactive",type:Boolean},{defaultValue:!1,description:"Don't update optionalDependencies",name:"no-optional",type:Boolean},{defaultValue:!1,description:"Include peerDependencies in update checks",name:"peer",type:Boolean},{defaultValue:!1,description:"Also check workspace-owned package names against the registry (catalog mode)",name:"include-internal",type:Boolean},{alias:"l",defaultValue:!1,description:"Include packages with pinned/exact versions (no ^ or ~ prefix; catalog mode)",name:"include-locked",type:Boolean},{defaultValue:!1,description:"Update lockfile only",name:"no-save",type:Boolean},{description:"Glob pattern to include packages (repeatable, catalog mode)",lazyMultiple:!0,name:"include",type:String},{description:"Glob pattern to exclude packages (repeatable, catalog mode)",lazyMultiple:!0,name:"exclude",type:String},{defaultValue:!1,description:"Include prerelease versions (catalog mode)",name:"prerelease",type:Boolean},{description:"Check for known security vulnerabilities via OSV.dev (default: true; --no-security to skip)",name:"security",type:Boolean},{defaultValue:!1,description:"Skip catalog mode, use package manager directly",name:"no-catalog",type:Boolean},{description:"Output format: table, json, or minimal (default: table)",name:"format",type:String},{defaultValue:!1,description:"Show changelog URLs for updated packages",name:"changelog",type:Boolean},{description:"Run install after catalog update, --no-install to skip (default: true)",name:"install",type:Boolean},{defaultValue:!1,description:"Restore catalog file from the last backup",name:"rollback",type:Boolean},{defaultValue:!1,description:"Run AI analysis on outdated packages before updating (catalog mode)",name:"ai",type:Boolean},{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",name:"ai-type",type:String},{defaultValue:!1,description:"Skip typosquat name check for package arguments",name:"no-typosquat-check",type:Boolean},{defaultValue:!1,description:"Skip the offline marshall pipeline (author, provenance, metadata, downloads, expired-domains, new-bin, signatures, archived-repo) when explicit package arguments are supplied",name:"no-marshall-check",type:Boolean},{description:"Cap concurrent registry requests during outdated checks (default: 8)",name:"max-concurrent-requests",type:Number},{description:"Release channel filter: stable (default), same (match current's prerelease channel), or any",name:"release-channel",type:String},{alias:"y",defaultValue:!1,description:"Skip the confirmation prompt for blanket --latest updates. Required in non-TTY contexts (CI) when running `vis update --latest` without explicit package arguments.",name:"yes",type:Boolean},{defaultValue:!1,description:"Skip the GitHub Actions ecosystem scan (workflows + composite action.yml files)",name:"no-actions",type:Boolean},{defaultValue:!1,description:"Skip the Docker ecosystem scan (Dockerfile + docker-compose images)",name:"no-docker",type:Boolean},{defaultValue:!1,description:"Skip the GitLab CI ecosystem scan (.gitlab-ci.yml + .gitlab/ci/**)",name:"no-gitlab",type:Boolean},{defaultValue:!1,description:"Include branch references (e.g. actions/checkout@main) when scanning workflows",name:"include-branches",type:Boolean},{description:"Reference style for GitHub Actions updates: sha (default, pin to commit SHA + version comment) or preserve",name:"style",type:String},{description:"GitHub token for actions resolution (overrides GITHUB_TOKEN / GH_TOKEN env)",name:"actions-token",type:String},{description:"GitLab token for include-ref resolution (overrides GITLAB_TOKEN / CI_JOB_TOKEN env)",name:"gitlab-token",type:String}]},u3={argument:{description:"Target version (defaults to latest)",name:"version",type:String},description:"Update vis itself to the latest version",examples:[["vis self-update","Update to latest"],["vis self-update 2.0.0","Install specific version"],["vis self-update --check","Check for updates without installing"]],group:"System",loader:()=>import("./handler28.js"),name:"self-update",options:[{defaultValue:!1,description:"Check for updates without installing",name:"check",type:Boolean},{defaultValue:!1,description:"Reinstall even if already current",name:"force",type:Boolean},{defaultValue:!1,description:"Suppress output (CI mode)",name:"silent",type:Boolean}]},p3={alias:"explain",argument:{description:"Package(s) to explain",name:"packages",type:String},description:"Show why a package is installed (dependency chain)",examples:[["vis why react","Show why react is installed"],["vis why react --json","Output as JSON"],["vis why react -r","Check across all workspaces"],["vis explain react","Alias matching npm's command"]],group:"Dependencies",loader:()=>import("./handler29.js"),name:"why",options:[{defaultValue:!1,description:"Output as JSON",name:"json",type:Boolean},{defaultValue:!1,description:"Show extended information (pnpm)",name:"long",type:Boolean},{defaultValue:!1,description:"Machine-readable output (pnpm)",name:"parseable",type:Boolean},{alias:"r",defaultValue:!1,description:"Check across all workspaces",name:"recursive",type:Boolean},{alias:"D",conflicts:"prod",description:"Filter to dev dependencies (pnpm)",name:"dev",type:Boolean},{alias:"P",conflicts:"dev",description:"Filter to production dependencies (pnpm)",name:"prod",type:Boolean},{defaultValue:!1,description:"Exclude optional dependencies (pnpm)",name:"no-optional",type:Boolean},{alias:"g",defaultValue:!1,description:"Check globally installed packages (pnpm)",name:"global",type:Boolean},{description:"Limit dependency tree depth",name:"depth",type:Number},{alias:"F",description:"Filter by workspace package name",multiple:!0,name:"filter",type:String}]},f3={argument:{description:"File to run, with any args to forward to it",name:"file",type:String},description:"Run a TypeScript/JavaScript file directly under the selected runtime (node | bun)",examples:[["vis x script.ts","Run a TypeScript file (full TS surface: enums, decorators)"],["vis x --runtime bun server.ts","Run under Bun"],["vis x build.ts foo bar","Forward positional args to the file"],["vis x task.ts -- --watch","Forward flags after -- to the file"]],group:"Run & Execute",loader:()=>import("./handler30.js"),name:"x",options:[]},h3=e=>{e.addCommand(T8),e.addCommand(Bx),e.addCommand(kC),e.addCommand(tx),e.addCommand(lx),e.addCommand(n3),e.addCommand(j8),e.addCommand(OC),e.addCommand(d3),e.addCommand(Ix),e.addCommand(uC),e.addCommand(yx),e.addCommand(X8),e.addCommand(Q8),e.addCommand(e3),e.addCommand(lC),e.addCommand(t3),e.addCommand(_C),e.addCommand(Q2),e.addCommand(ex),e.addCommand(LC),e.addCommand(bC),e.addCommand(DC),e.addCommand(nx),e.addCommand(R8),e.addCommand(dC),e.addCommand(p3),e.addCommand(BC),e.addCommand(MC),e.addCommand(l3),e.addCommand(wf),e.addCommand(Sh),e.addCommand(f3),e.addCommand(s8),e.addCommand(PC),e.addCommand(Nx),e.addCommand(Dx),e.addCommand(wC),e.addCommand(pC),e.addCommand(u3),e.addCommand(AC),e.addCommand(Z8),e.addCommand(IC),e.addCommand(vx),e.addCommand(Sx),e.addCommand(NC),e.addCommand(vC),e.addCommand(n8),e.addCommand(O8),e.addCommand(A8);for(const t of TC)e.addCommand(t);for(const t of t8)e.addCommand(t);for(const t of Ax)e.addCommand(t);for(const t of cx)e.addCommand(t);for(const t of tp)e.addCommand(t);for(const t of z8)e.addCommand(t);for(const t of L8)e.addCommand(t);for(const t of kx)e.addCommand(t);for(const t of yC)e.addCommand(t);for(const t of c3)e.addCommand(t);for(const t of Y8)e.addCommand(t);e.addCommand(Px);for(const t of C8)e.addCommand(t)},m3=e=>{for(let t=0;t<e.length;t+=1){const n=e[t];if(n==="--ca-cert"){const s=e[t+1];return s===void 0||s.startsWith("-")?void 0:_s(s)}if(n.startsWith("--ca-cert=")){const s=n.slice(10);return s===""?void 0:_s(s)}}},g3=()=>process.platform==="win32"?!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color":process.env.TERM!=="linux",In=g3(),y3={arrow:In?"→":"->",dash:In?"—":"-",failure:In?"✗":"x",success:In?"✓":"v",warning:In?"⚠":"!"},Yi=g(ht(),"upgrade-check.json"),v3=1440*60*1e3,b3=1440*60*1e3,w3=500,k3=new Set(["--help","--version","-h","-V","help","implode","upgrade"]),S3=()=>{try{if(x(Yi))return le(Yi)}catch{}},of=e=>{try{ft(ht()),me(Yi,JSON.stringify(e))}catch{}},x3=async e=>{try{const t=new AbortController,n=setTimeout(()=>{t.abort()},w3),s=await fetch(`https://registry.npmjs.org/${e}/latest`,{headers:{accept:"application/json"},signal:t.signal});return clearTimeout(n),s.ok?(await s.json()).version:void 0}catch{return}},ol=(e,t)=>{let n;try{n=li.gt(t.latestVersion,e,{loose:!0})}catch{return}if(!n)return;const s=Date.now();s-t.lastNoticeAt<b3||(process.stderr.write(`
|
|
241
|
+
${sn("vis update available:")} ${Bn(e)} ${sn(y3.arrow)} ${rh(Ne(t.latestVersion))}${sn(", run")} ${Qe("vis upgrade")}
|
|
242
|
+
`),t.lastNoticeAt=s,of(t))},$3=e=>{if(ct||process.env.VIS_CLI_TEST||process.env.VIS_NO_UPDATE_CHECK==="1"||!process.stderr.isTTY||k3.has(e))return!1;const t=new Set(process.argv.slice(2));return!(t.has("--silent")||t.has("-s")||t.has("--json"))},E3=(e,t)=>{if(!$3(t))return;const n=S3(),s=Date.now();if(n&&s-n.lastQueryAt<v3)return()=>{ol(e,n)};let r=n;return x3("@visulima/vis").then(i=>{i&&(r={lastNoticeAt:n?.lastNoticeAt??0,lastQueryAt:s,latestVersion:i},of(r))}).catch(()=>{}),()=>{r&&ol(e,r)}},C3=async()=>{const e=m3(process.argv);e!==void 0&&!process.env.NODE_EXTRA_CA_CERTS&&(process.env.NODE_EXTRA_CA_CERTS=e);try{const r=Sl(process.cwd()).path;process.env.VIS_MONOREPO_ROOT=r;const i=le(g(r,"package.json"));i.name&&nh(i.name)}catch{}const t=E3(Fs(),process.argv[2]??""),n=kf("vis",{packageName:"vis",packageVersion:Fs()}),s=process.argv.includes("--debug")||!!process.env.DEBUG;if(n.addPlugin(Sf({concise:$f,detailed:s,exitOnError:!1})),n.addGlobalOption({description:"Override workspace root directory",name:"cwd",type:String}),n.addGlobalOption({description:"Target JS runtime: node (default) or bun. Overrides VIS_RUNTIME and config; falls back to lockfile detection.",name:"runtime",type:String}),n.addGlobalOption({description:"Path to a vis config file (overrides discovery)",name:"config",type:String}),n.addGlobalOption({description:"Path to a CA bundle (PEM) to trust for HTTPS — for corporate proxies. Equivalent to NODE_EXTRA_CA_CERTS.",name:"ca-cert",type:String}),n.addPlugin(E0),n.addPlugin(U2),h3(n),n.addPlugin(K0(t)),_h(process.argv.slice(2))){const{loadVisConfig:r}=await import("./CONFIG_FILES.js"),i=process.env.VIS_MONOREPO_ROOT||process.cwd();let o;try{o=await r(i)}catch{o=void 0}try{await $0({logger:{info:a=>{process.stdout.write(`${a}
|
|
245
243
|
`)},warn:a=>{process.stderr.write(`${a}
|
|
246
|
-
`)}},visConfig:o,workspaceRoot:
|
|
247
|
-
`),process.exitCode=1}return}await
|
|
244
|
+
`)}},visConfig:o,workspaceRoot:i})}catch(a){const c=s?a.stack??a.message:a.message;process.stderr.write(`${c}
|
|
245
|
+
`),process.exitCode=1}return}await xf(n)},IR=Object.defineProperty({__proto__:null,runCli:C3},Symbol.toStringTag,{value:"Module"});export{fo as $,k0 as A,w0 as B,S0 as C,Aa as D,Ma as E,Va as F,Ka as G,Yv as H,Wa as I,La as J,Ia as K,Pa as L,Ha as M,qa as N,Ah as O,Ua as P,Ee as Q,wd as R,y3 as S,ed as T,ld as U,cd as V,nd as W,yi as X,Oa as Y,_c as Z,pr as _,mR as a,kR as a0,SR as a1,xR as a2,$R as a3,cR as a4,lR as a5,dR as a6,uR as a7,_p as a8,vd as a9,eR as aa,Wy as ab,Ay as ac,iR as ad,rR as ae,nR as af,Ar as ag,sR as ah,tR as ai,My as aj,io as ak,Gy as al,oR as am,q3 as an,wR as ao,TR as ap,zn as aq,OR as ar,AR as as,Hw as at,zs as au,bR as av,IR as aw,gR as b,Xr as c,Bg as d,Kv as e,Wp as f,F2 as g,vR as h,D2 as i,Up as j,qE as k,jR as l,Il as m,Ki as n,NE as o,E as p,PE as q,yR as r,CR as s,RR as t,ER as u,ro as v,aR as w,P2 as x,N2 as y,ie as z};
|