@visulima/vis 1.0.0-alpha.5 → 1.0.0-alpha.6
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 +147 -81
- package/README.md +144 -14
- package/dist/ai-analysis.d.ts +3 -17
- package/dist/ai-cache.d.ts +1 -1
- package/dist/ai-types.d.ts +16 -0
- package/dist/bin.js +352 -221
- package/dist/cache-directory.d.ts +73 -0
- package/dist/codeowners.d.ts +30 -0
- package/dist/commands/action-graph.d.ts +8 -0
- package/dist/commands/audit.d.ts +3 -3
- package/dist/commands/cache.d.ts +86 -0
- package/dist/commands/ci.d.ts +19 -0
- package/dist/commands/docker.d.ts +22 -0
- package/dist/commands/generate.d.ts +10 -0
- package/dist/commands/ignore-helpers.d.ts +157 -0
- package/dist/commands/ignore.d.ts +17 -0
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/migrate/backup.d.ts +8 -0
- package/dist/commands/migrate/constants.d.ts +6 -2
- package/dist/commands/migrate/gitleaks.d.ts +29 -0
- package/dist/commands/migrate/json.d.ts +4 -2
- package/dist/commands/migrate/kingfisher.d.ts +14 -0
- package/dist/commands/migrate/moon.d.ts +5 -0
- package/dist/commands/migrate/nano-staged.d.ts +30 -0
- package/dist/commands/migrate/nx.d.ts +12 -0
- package/dist/commands/migrate/prompt.d.ts +2 -0
- package/dist/commands/migrate/secretlint.d.ts +14 -0
- package/dist/commands/migrate/shared.d.ts +29 -0
- package/dist/commands/migrate/turborepo.d.ts +11 -0
- package/dist/commands/migrate/types.d.ts +8 -1
- package/dist/commands/migrate/verify.d.ts +12 -0
- package/dist/commands/run.d.ts +13 -0
- package/dist/commands/sbom.d.ts +10 -0
- package/dist/commands/secrets.d.ts +3 -0
- package/dist/commands/staged.d.ts +7 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/sync.d.ts +16 -0
- package/dist/commands/task-why.d.ts +3 -0
- package/dist/config.d.ts +17 -2
- package/dist/config.js +1 -1
- package/dist/docker.d.ts +73 -0
- package/dist/flakiness.d.ts +40 -0
- package/dist/generate/discover.d.ts +29 -0
- package/dist/generate/index.d.ts +32 -0
- package/dist/generate/index.js +1 -0
- package/dist/generate/loader.d.ts +15 -0
- package/dist/generate/moon-adapter/filename-interp.d.ts +42 -0
- package/dist/generate/moon-adapter/filters.d.ts +22 -0
- package/dist/generate/moon-adapter/frontmatter.d.ts +39 -0
- package/dist/generate/moon-adapter/index.d.ts +19 -0
- package/dist/generate/moon-adapter/tera-subset.d.ts +85 -0
- package/dist/generate/moon-adapter/util.d.ts +14 -0
- package/dist/generate/prompts.d.ts +25 -0
- package/dist/generate/remote.d.ts +43 -0
- package/dist/generate/runner.d.ts +37 -0
- package/dist/generate/types.d.ts +152 -0
- package/dist/hooks.d.ts +118 -0
- package/dist/native-binding.d.ts +8 -1
- package/dist/packem_chunks/index.js +7 -0
- package/dist/packem_chunks/loader.js +1 -0
- package/dist/packem_shared/otelPlugin-CJLkguJ8.js +1 -0
- package/dist/plugins/otel.d.ts +63 -0
- package/dist/pm-runner.d.ts +24 -3
- package/dist/run-report.d.ts +40 -0
- package/dist/runtime-check.d.ts +27 -0
- package/dist/sbom/cyclonedx.d.ts +39 -0
- package/dist/sbom/installed-package.d.ts +49 -0
- package/dist/sbom/license.d.ts +31 -0
- package/dist/sbom/lockfile.d.ts +34 -0
- package/dist/sbom/purl.d.ts +25 -0
- package/dist/sbom/resolve-specifier.d.ts +24 -0
- package/dist/sbom/types.d.ts +196 -0
- package/dist/secrets/baseline.d.ts +20 -0
- package/dist/secrets/format.d.ts +14 -0
- package/dist/secrets/git.d.ts +6 -0
- package/dist/secrets/spinner.d.ts +9 -0
- package/dist/selectors.d.ts +81 -0
- package/dist/shell-history.d.ts +16 -0
- package/dist/staged/cli-parse.d.ts +18 -0
- package/dist/staged/config.d.ts +14 -0
- package/dist/staged/errors/apply-empty-commit-error.d.ts +4 -0
- package/dist/staged/errors/config-error.d.ts +4 -0
- package/dist/staged/errors/get-backup-stash-error.d.ts +4 -0
- package/dist/staged/errors/git-error.d.ts +6 -0
- package/dist/staged/errors/index.d.ts +12 -0
- package/dist/staged/errors/restore-original-state-error.d.ts +4 -0
- package/dist/staged/errors/staged-error.d.ts +8 -0
- package/dist/staged/errors/task-error.d.ts +6 -0
- package/dist/staged/git/diff.d.ts +76 -0
- package/dist/staged/git/exec.d.ts +43 -0
- package/dist/staged/git/index.d.ts +77 -0
- package/dist/staged/git/stash.d.ts +37 -0
- package/dist/staged/index.d.ts +13 -0
- package/dist/staged/match.d.ts +12 -0
- package/dist/staged/renderer/index.d.ts +9 -0
- package/dist/staged/renderer/ink/index.d.ts +4 -0
- package/dist/staged/renderer/plain.d.ts +12 -0
- package/dist/staged/tasks/build.d.ts +13 -0
- package/dist/staged/tasks/exec.d.ts +56 -0
- package/dist/staged/tasks/run.d.ts +26 -0
- package/dist/staged/types.d.ts +173 -0
- package/dist/target-discovery.d.ts +59 -0
- package/dist/target-options.d.ts +261 -0
- package/dist/tui/components/OutputPanel.d.ts +2 -1
- package/dist/tui/components/TaskListPanel.d.ts +1 -1
- package/dist/tui/components/TaskStore.d.ts +1 -1
- package/dist/tui/components/devcontainer/DevcontainerStore.d.ts +1 -1
- package/dist/tui/components/devcontainer/catalogs/mount-suggestions.d.ts +1 -1
- package/dist/tui/components/devcontainer/sections/GeneralSection.d.ts +1 -1
- package/dist/tui/components/devcontainer/sections/PreviewPanel.d.ts +1 -1
- package/dist/tui/components/devcontainer/types.d.ts +4 -4
- package/dist/tui/components/graph/GraphStore.d.ts +1 -1
- package/dist/tui/components/graph/ProjectDetailPanel.d.ts +1 -1
- package/dist/tui/components/optimize/OptimizeDetailPanel.d.ts +1 -1
- package/dist/tui/components/optimize/OptimizeStore.d.ts +1 -1
- package/dist/tui/components/update/PackageDetailPanel.d.ts +1 -1
- package/dist/tui/components/update/PackageListPanel.d.ts +2 -2
- package/dist/tui/components/update/UpdateStore.d.ts +1 -1
- package/dist/tui/components/update/VisUpdateApp.d.ts +3 -3
- package/dist/tui/dynamic-life-cycle.d.ts +2 -1
- package/dist/tui/static-life-cycle.d.ts +7 -1
- package/dist/watch.d.ts +65 -0
- package/dist/workspace.d.ts +326 -6
- package/index.js +727 -554
- package/package.json +37 -32
- package/schemas/project.schema.json +344 -0
- package/schemas/vis-config.schema.json +331 -0
package/dist/bin.js
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`)
|
|
14
|
-
`),"formatAcceptedRiskSnippet");var cl=Object.defineProperty,Ne=$((t,e)=>cl(t,"name",{value:e,configurable:!0}),"o$g");const ll={a:["4","e"],b:["d"],d:["b"],e:["3","a"],g:["9","q"],i:["1","l"],l:["1","i"],m:["n"],n:["m"],o:["0"],s:["5","z"],t:["7"],u:["v"],v:["u"]},dl=Ne(t=>{const e=new Set;if(t.length<3)return e;for(let n=0;n<t.length;n++){const i=t[n]==="-"||t[n]==="."||t[n]==="_";if(i||e.add(t.slice(0,n)+t.slice(n+1)),i||e.add(t.slice(0,n)+t[n]+t.slice(n)),n<t.length-1&&t[n]!==t[n+1]){const l=t[n+1]==="-"||t[n+1]==="."||t[n+1]==="_";if(!i&&!l){const d=t.split("");[d[n],d[n+1]]=[d[n+1],d[n]],e.add(d.join(""))}}const o=t[n].toLowerCase(),s=ll[o];if(s)for(const l of s)e.add(t.slice(0,n)+l+t.slice(n+1))}const r=/[-._]/g;if(r.test(t))e.add(t.replaceAll(r,"")),e.add(t.replaceAll(r,"-")),e.add(t.replaceAll(r,".")),e.add(t.replaceAll(r,"_"));else if(t.length>5)for(let n=2;n<t.length-2;n++)e.add(`${t.slice(0,n)}-${t.slice(n)}`),e.add(`${t.slice(0,n)}.${t.slice(n)}`),e.add(`${t.slice(0,n)}_${t.slice(n)}`);return t.startsWith("@")||(e.add(`${t}-js`),e.add(`${t}js`),e.add(`${t}-node`)),e.delete(t),e},"generateVariants");let hn,Cr;const qi=Ne(()=>{if(!hn){const t=rt(Pi(nc(import.meta.url)),"../data/typosquats.json");hn=JSON.parse(K(t,"utf8"))}return hn},"loadBlocklist"),ul=Ne(()=>{if(!Cr){Cr=new Map;for(const[t,e]of Object.entries(qi()))for(const r of e)Cr.set(r,t)}return Cr},"getReverseLookup"),pl=Ne(t=>t.startsWith("@")?t.split("/")[1]??t:t,"bareName"),fl=Ne(t=>{const e=pl(t),r=ul().get(e);if(r)return{input:t,legitimate:r,method:"blocklist"};for(const n of Object.keys(qi()))if(dl(n).has(e))return{input:t,legitimate:n,method:"heuristic"}},"checkTyposquat"),Yi=Ne((t,e)=>{const r=e?new Set(e):void 0,n=[];for(const i of t){if(r?.has(i))continue;const o=fl(i);o&&n.push(o)}return n},"checkTyposquats"),Xi=Ne((t,e)=>{ae(""),ae(ct(`Possible typosquat${t.length===1?"":"s"} ${e}:`));for(const r of t){const n=r.method==="blocklist"?"known typosquat":"similar name";ae(` ${Ie("⚠")} ${ct(r.input)} — did you mean ${Ie(r.legitimate)}? (${n})`)}ae("")},"printTyposquatWarnings"),Ki=Ne(async t=>{if(!process.stdin.isTTY){ae("Aborting: potential typosquat detected in non-interactive mode. Use --no-typosquat-check to skip.");return}const e=Vt({input:process.stdin,output:process.stdout}),r=await new Promise(n=>{e.question(t,i=>{n(i.trim().toLowerCase())})});return e.close(),r},"askConfirmation"),Qi=Ne(async(t,e)=>{const r=Yi(t,e);if(r.length===0)return{ok:!0,packages:t};Xi(r,"detected");const n=await Ki(`Use suggested package${r.length===1?"":"s"} instead? [S]uggested / [y]es, keep original / [N]o, abort (default: N) `);if(n===void 0)return{ok:!1,packages:t};if(n==="s"||n==="suggested"){const i=new Map(r.map(o=>[o.input,o.legitimate]));return{ok:!0,packages:t.map(o=>i.get(o)??o)}}return n==="y"||n==="yes"?{ok:!0,packages:t}:{ok:!1,packages:t}},"runTyposquatCheck"),gl=/^(?:npm|pnpm|yarn):(.+?)(?:@.*)?$/,hl=Ne(t=>gl.exec(t)?.[1],"parseAliasTarget"),ml=Ne(t=>{if(!F(t))return[];const e=JSON.parse(K(t,"utf8")),r={...e.dependencies,...e.devDependencies,...e.optionalDependencies,...e.peerDependencies},n=new Set;for(const[i,o]of Object.entries(r)){n.add(i);const s=hl(o);s&&n.add(s)}return[...n]},"readDepsFromPackageJson"),Zi=Ne(async(t,e)=>{const r=L(t,"package.json"),n=ml(r);if(n.length===0)return!0;const i=Yi(n,e);if(i.length===0)return!0;Xi(i,"in package.json dependencies"),ae("Fix the package name in package.json before proceeding.");const o=await Ki("Continue anyway? [y/N] ");return o==="y"||o==="yes"},"scanDepsForTyposquats");var yl=Object.defineProperty,Jn=$((t,e)=>yl(t,"name",{value:e,configurable:!0}),"s$j");const gr=Jn(t=>t?Array.isArray(t)?t:[t]:[],"toStringArray"),Sn=Jn(t=>t instanceof Error?t.message:typeof t=="string"?t:String(t),"errorMessage"),vl=/^(.+?)(?:@(.+))?$/,qn=Jn(t=>{if(t.startsWith("@")){const r=t.indexOf("/");if(r===-1)return{name:t,versionSpec:void 0};const n=t.slice(r+1),i=n.indexOf("@");return i===-1?{name:t,versionSpec:void 0}:{name:t.slice(0,r+1+i),versionSpec:n.slice(i+1)}}const e=vl.exec(t);return e?{name:e[1],versionSpec:e[2]}:{name:t,versionSpec:void 0}},"parsePackageArgument");var wl=Object.defineProperty,Bt=$((t,e)=>wl(t,"name",{value:e,configurable:!0}),"m$k");const kl=Bt(async(t,e=1e4)=>{const r=new Map,n=new AbortController,i=setTimeout(()=>{n.abort()},e);try{const o=t.map(async s=>{try{const l=await fetch(`https://registry.npmjs.org/${s}/latest`,{headers:{Accept:"application/json"},signal:n.signal});if(l.ok){const d=await l.json();d.version&&r.set(s,d.version)}}catch{}});await Promise.all(o)}finally{clearTimeout(i)}return r},"resolveLatestVersions"),bl=Bt((t,e,r)=>{const n=[];for(const i of t.values()){const{overall:o}=i.score,s=fr(o),l=`${String(Math.round(o*100))}%`,d=i.alerts.length,f=Mt(i),p=Hn(f,i.version,r),h=s==="red"?ct:s==="yellow"?Ie:Ai;if(k(p?` ${h(l)} ${Ao(i)} ${Be(`[accepted: ${p.reason}]`)}`:` ${h(l)} ${Ao(i)}`),d>0){const m=i.alerts.filter(y=>y.severity==="critical"||y.severity==="high").length;m>0&&ae(` ${String(m)} critical/high alert${m===1?"":"s"}`)}o<e&&!p&&n.push(i)}return n},"displaySecurityReports"),$l=Bt(async(t,e)=>{const r=Vt({input:process.stdin,output:process.stdout}),n=Bt(l=>new Promise(d=>{r.question(l,f=>{d(f.trim())})}),"ask"),i=String(Math.round(e*100));ae(""),ae(`${String(t.length)} package${t.length===1?"":"s"} scored below the minimum threshold (${i}%):`);for(const l of t){const d=Mt(l),f=`${String(Math.round(l.score.overall*100))}%`;ae(` • ${d}@${l.version} — score: ${f} (${_n(l.score.overall)})`)}ae("");const o=await n("Continue adding these packages? [y/N] ");if(o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes")return r.close(),!1;const s=await n("Remember this decision? (prints config snippet) [y/N] ");if(r.close(),s.toLowerCase()==="y"||s.toLowerCase()==="yes"){te(""),te("Add the following to security.socket.acceptedRisks in vis.config.ts:"),te("");for(const l of t){const d=Mt(l),f=al(d,l.version,l.score.overall,"Reviewed and accepted");te(f)}te("")}return!0},"confirmLowScorePackages"),xl=Bt(async(t,e,r,n)=>{const i=t.map(qn),o=new Map;for(const h of i)if(h.versionSpec){const m=qr(h.versionSpec);m&&o.set(h.name,m.version)}const s=i.filter(h=>!o.has(h.name)).map(h=>h.name),l=s.length>0?await kl(s):new Map,d=[];for(const h of i){const m=o.get(h.name)??l.get(h.name);m&&d.push({name:h.name,version:m})}if(d.length===0)return!0;k(""),k("Socket.dev security check:");const f=await Wt(d,e);if(f.size===0)return k(" Could not fetch security data. Proceeding."),!0;const p=bl(f,r,n);return p.length===0?(k(""),!0):process.stdin.isTTY?$l(p,r):(ae(`Aborting: ${String(p.length)} package${p.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},"runSocketPreCheck"),Sl={group:"Dependencies",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 -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"]],execute:Bt(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:i})=>{let o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(!r.noTyposquatCheck){const f=o.map(h=>qn(h)),p=await Qi(f.map(h=>h.name),n?.security?.typosquatAllowlist);if(!p.ok){process.exitCode=1;return}o=f.map((h,m)=>{const y=p.packages[m];return y!==h.name?h.versionSpec?`${y}@${h.versionSpec}`:y:o[m]})}if(!r.noSocketCheck){const f=It(n?.security?.socket);if(f){const p=f.minimumScore??at;if(!await xl(o,f,p,n?.security?.socket?.acceptedRisks)){process.exitCode=1;return}}}const s=process.cwd(),l=me(i??s),d=Gc(l,{exact:r.exact||!1,filter:gr(r.filter),global:r.global||!1,optional:r.saveOptional||!1,packages:o,peer:r.savePeer||!1,saveDev:r.saveDev||!1,workspace:r.workspace||!1,workspaceRoot:r.workspaceRoot||!1},s,e);d!==0&&(process.exitCode=d)},"execute"),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},{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}]};var Cl=Object.defineProperty,Qe=$((t,e)=>Cl(t,"name",{value:e,configurable:!0}),"a$b");const El=/\/+$/,jl=/\/\*\*$/,Tl=/\/\*\/\*$/,Al=/^['"]|['"]$/g,es=/node_modules/,ts=/\.git/,Rr=Qe(t=>{try{return Ue(t)}catch{return}},"readJsonFileSafe"),Il=Qe((t,e,r)=>{for(const n of Mn(t,{includeFiles:!1,includeSymlinks:!1,skip:[es,ts]}))if(n.path!==t&&le(T(n.path,"package.json"))){const i=n.path.slice(t.length+1);r.push(`${e}/${i}`)}},"scanDirectoryRecursive"),Rl=Qe((t,e,r)=>{const n=e.slice(0,-2),i=Ft(t,n);if(le(i))for(const o of Mn(i,{includeFiles:!1,includeSymlinks:!1,maxDepth:1,skip:[es,ts]}))o.path!==i&&le(T(o.path,"package.json"))&&r.push(T(n,o.name))},"resolveSimpleGlob"),Ol=Qe((t,e,r)=>{const n=e.replace(jl,"").replace(Tl,""),i=Ft(t,n);le(i)&&Il(i,n,r)},"resolveDoubleGlob"),Pl=Qe((t,e,r)=>{const n=Ft(t,e);le(n)&&le(T(n,"package.json"))&&r.push(e)},"resolveExactDirectory"),Ct=Qe((t,e)=>{const r=[];for(const n of e){const i=n.replace(El,"");i.startsWith("!")||(i.endsWith("/*")?Rl(t,i,r):i.endsWith("/**")||i.endsWith("/*/*")?Ol(t,i,r):Pl(t,i,r))}return r},"resolveWorkspacePatterns"),tn=Qe(t=>{const e=T(t,"pnpm-workspace.yaml");if(!le(e))return;const r=Xe(e),n=[];let i=!1;for(const o of r.split(`
|
|
15
|
-
`)){const s=o.trim();if(s==="packages:"){i=!0;continue}if(i){if(s.startsWith("- ")){const l=s.slice(2).replaceAll(Al,"");n.push(l)}else if(s&&!s.startsWith("#"))break}}return n.length>0?n:void 0},"readPnpmWorkspacePatterns"),Nl=Qe((t,e)=>{const r={};for(const[n,i]of Object.entries(t)){const o=e?.[n];r[n]={...o,command:i}}return r},"createTargetsFromScripts"),rn=Qe((t,e={})=>{const r={},n=tn(t),i=Rr(T(t,"package.json"));let o;if(n?o=n:i?.workspaces&&(o=Array.isArray(i.workspaces)?i.workspaces:i.workspaces.packages),!o)throw new Error("No workspace configuration found. Expected pnpm-workspace.yaml or package.json workspaces field.");const s=Ct(t,o);for(const l of s){const d=T(t,l,"package.json"),f=Rr(d);if(!f?.name)continue;const p=T(t,l,"project.json"),h=Rr(p),m=f.scripts?Nl(f.scripts,e.targetDefaults):{};let y="library";h?.projectType?y=h.projectType:f.bin!==void 0&&(y="application"),r[f.name]={projectType:y,root:l,sourceRoot:h?.sourceRoot??`${l}/src`,tags:h?.tags,targets:m}}return{config:e,workspace:{projects:r}}},"discoverWorkspace"),Yn=Qe((t,e)=>{const r={},n={},i=new Set(Object.keys(e.projects));for(const[o,s]of Object.entries(e.projects)){r[o]={data:s,name:o,type:s.projectType??"library"},n[o]=[];const l=Rr(T(t,s.root,"package.json"));if(!l)continue;const d=[[l.dependencies,"static"],[l.devDependencies,"devDependency"],[l.peerDependencies,"peerDependency"]],f=new Set;for(const[p,h]of d)if(p)for(const m of Object.keys(p))i.has(m)&&!f.has(m)&&(f.add(m),n[o]?.push({source:o,target:m,type:h}))}return{dependencies:n,nodes:r}},"buildProjectGraph");var Dl=Object.defineProperty,Ml=$((t,e)=>Dl(t,"name",{value:e,configurable:!0}),"u$f");const Bl={group:"Run & Execute",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"]],execute:Ml(async({argument:t,logger:e,options:r,runtime:n,visConfig:i,workspaceRoot:o})=>{const s=t[0];if(!s)throw new Error("Missing target. Usage: vis affected <target>");if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const l=o,{workspace:d}=rn(l,i),f=Yn(l,d),p=new Set(["deep","direct","none"]),h=r.downstream??"deep",m=r.upstream??"none";if(!p.has(h))throw new Error(`Invalid --downstream value: "${h}". Must be "none", "direct", or "deep".`);if(!p.has(m))throw new Error(`Invalid --upstream value: "${m}". Must be "none", "direct", or "deep".`);const y={base:r.base,downstream:h,head:r.head,projectGraph:f,projects:d.projects,upstream:m,workspaceRoot:l},b=await oc(y);if(b.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}if(b.affectedProjects.length===0){e.info("No projects affected by the changes.");return}e.info(`Affected projects: ${b.affectedProjects.join(", ")}`);const x=[s,`--projects=${b.affectedProjects.join(",")}`];r.parallel!==void 0&&x.push(`--parallel=${String(r.parallel)}`),r.cache||x.push("--no-cache"),r.dryRun&&x.push("--dry-run"),r.partition&&x.push(`--partition=${String(r.partition)}`),await n.runCommand("run",{argv:x})},"execute"),name:"affected",options:[{defaultValue:"HEAD~1",description:"Git base ref for comparison",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" — 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},{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},{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}]};var Ll=Object.defineProperty,de=$((t,e)=>Ll(t,"name",{value:e,configurable:!0}),"f$g");const Dt=(1n<<128n)-1n,ee=(1n<<64n)-1n,Dr=(1n<<32n)-1n,rs=0x9E3779B1n,ns=0x85EBCA77n,Fl=0xC2B2AE3Dn,ut=0x9E3779B185EBCA87n,Et=0xC2B2AE3D27D4EB4Fn,os=0x165667B19E3779F9n,Xn=0x85EBCA77C2B2AE63n,Vl=0x27D4EB2F165667C5n,Ul=0x165667919E3779F9n,Gl=0x9FB21C651E98DF25n,tt=64,is=tt/8,zl=8,He=Buffer.from("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e","hex"),ue=de((t,e=0)=>Buffer.from(t.buffer,t.byteOffset+e,t.length-e),"getView"),Wl=de(t=>{const e=Buffer.allocUnsafe(8);return e.writeBigUInt64LE(t),e.readBigUInt64BE()},"bswap64"),_l=de(t=>{let e=t;return e=(e&0x0000FFFFn)<<16n|(e&0xFFFF0000n)>>16n,e=(e&0x00FF00FFn)<<8n|(e&0xFF00FF00n)>>8n,e},"bswap32"),Hl=de((t,e)=>(t&Dr)*(e&Dr)&ee,"multU32ToU64"),Jl=de((t,e)=>(t<<e|t>>32n-e)&Dr,"rotl32"),Cn=de((t,e)=>t^t>>e,"xorshift64"),En=de(t=>~t+1n&ee,"inv64"),ss=de((t,e)=>{const r=t*e&Dt;return r&ee^r>>64n},"mul128Fold64"),Je=de(t=>{let e=t;return e^=e>>37n,e=e*Ul&ee,e^=e>>32n,e},"avalanche"),Mr=de(t=>{let e=t;return e^=e>>33n,e=e*Et&ee,e^=e>>29n,e=e*os&ee,e^=e>>32n,e},"avalanche64"),as=de((t,e,r)=>{for(let n=0;n<is;n++){const i=e.readBigUInt64LE(n*8),o=i^r.readBigUInt64LE(n*8);t[n^1]+=i,t[n]+=Hl(o,o>>32n)}return t},"accumulate512"),Io=de((t,e,r,n)=>{for(let i=0;i<n;i++)as(t,ue(e,i*tt),ue(r,i*8));return t},"accumulate"),ql=de((t,e)=>{for(let r=0;r<is;r++){const n=e.readBigUInt64LE(r*8);let i=t[r];i=Cn(i,47n),i^=n,i*=rs,t[r]=i&ee}return t},"scrambleAcc"),Er=de((t,e)=>ss(t[0]^e.readBigUInt64LE(0),t[1]^e.readBigUInt64LE(zl)),"mix2Accs"),Ro=de((t,e,r)=>{let n=r;return n+=Er(t.slice(0),ue(e,0)),n+=Er(t.slice(2),ue(e,16)),n+=Er(t.slice(4),ue(e,32)),n+=Er(t.slice(6),ue(e,48)),Je(n&ee)},"mergeAccs"),Yl=de((t,e,r)=>{const n=Math.floor((r.byteLength-tt)/8),i=tt*n,o=Math.floor((e.byteLength-1)/i);for(let l=0;l<o;l++)Io(t,ue(e,l*i),r,n),ql(t,ue(r,r.byteLength-tt));const s=Math.floor((e.byteLength-1-i*o)/tt);return Io(t,ue(e,o*i),r,s),as(t,ue(e,e.byteLength-tt),ue(r,r.byteLength-tt-7)),t},"hashLong"),Xl=de((t,e)=>{const r=new BigUint64Array([Fl,ut,Et,os,Xn,ns,Vl,rs]);Yl(r,t,e);const n=Ro(r,ue(e,11),BigInt(t.byteLength)*ut&ee);return Ro(r,ue(e,e.byteLength-tt-11),~(BigInt(t.byteLength)*Et)&ee)<<64n|n},"hashLong128b"),Oo=de((t,e,r)=>ss((t.readBigUInt64LE(0)^e.readBigUInt64LE(0)+r)&ee,(t.readBigUInt64LE(8)^e.readBigUInt64LE(8)-r)&ee),"mix16B"),Or=de((t,e,r,n,i)=>{let o=t&ee,s=t>>64nⅇreturn o+=Oo(e,n,i),o^=r.readBigUInt64LE(0)+r.readBigUInt64LE(8),o&=ee,s+=Oo(r,ue(n,16),i),s^=e.readBigUInt64LE(0)+e.readBigUInt64LE(8),s&=ee,s<<64n|o},"mix32B"),Kl=de((t,e,r)=>{const n=t.byteLength,i=BigInt(t.readUInt8(n-1))|BigInt(n<<8)|BigInt(t.readUInt8(0)<<16)|BigInt(t.readUInt8(n>>1)<<24),o=(BigInt(e.readUInt32LE(0))^BigInt(e.readUInt32LE(4)))+r,s=(i^o)&ee,l=(BigInt(e.readUInt32LE(8))^BigInt(e.readUInt32LE(12)))-r,d=(Jl(_l(i),13n)^l)ⅇreturn(Mr(d)&ee)<<64n|Mr(s)},"len1to3_128b"),Ql=de((t,e,r)=>{const n=t.byteLength,i=t.readUInt32LE(0),o=t.readUInt32LE(n-4),s=BigInt(i)|BigInt(o)<<32n,l=(e.readBigUInt64LE(16)^e.readBigUInt64LE(24))+rⅇlet d=(s^l)*(ut+(BigInt(n)<<2n))&Dt;return d+=(d&ee)<<65n,d&=Dt,d^=d>>67n,Cn(Cn(d&ee,35n)*Gl&ee,28n)|Je(d>>64n)<<64n},"len4to8_128b"),Zl=de((t,e,r)=>{const n=t.byteLength,i=(e.readBigUInt64LE(32)^e.readBigUInt64LE(40))+r&ee,o=(e.readBigUInt64LE(48)^e.readBigUInt64LE(56))-r&ee,s=t.readBigUInt64LE();let l=t.readBigUInt64LE(n-8),d=(s^l^i)*ut;const f=(d&ee)+(BigInt(n-1)<<54n);d=d&(Dt^ee)|f,l^=o,d+=l+(l&Dr)*(ns-1n)<<64n,d&=Dt,d^=Wl(d>>64n);let p=(d&ee)*Et;return p+=(d>>64n)*Et<<64n,p&=Dt,Je(p&ee)|Je(p>>64n)<<64n},"len9to16_128b"),ed=de((t,e)=>{const r=t.byteLength;return r>8?Zl(t,He,e):r>=4?Ql(t,He,e):r>0?Kl(t,He,e):Mr(e^He.readBigUInt64LE(64)^He.readBigUInt64LE(72))|Mr(e^He.readBigUInt64LE(80)^He.readBigUInt64LE(88))<<64n},"len0to16_128b"),td=de((t,e,r)=>{let n=BigInt(t.byteLength)*ut&ee,i=BigInt(t.byteLength-1)/32n;for(;i>=0n;){const l=Number(i);n=Or(n,ue(t,16*l),ue(t,t.byteLength-16*(l+1)),ue(e,32*l),r),i--}let o=n+(n>>64n)ⅇo=Je(o);let s=(n&ee)*ut+(n>>64n)*Xn+(BigInt(t.byteLength)-r&ee)*Et;return s&=ee,s=En(Je(s)),o|s<<64n},"len17to128_128b"),rd=de((t,e,r)=>{let n=BigInt(t.byteLength)*utⅇfor(let s=32;s<160;s+=32)n=Or(n,ue(t,s-32),ue(t,s-16),ue(e,s-32),r);n=Je(n&ee)|Je(n>>64n)<<64n;for(let s=160;s<=t.byteLength;s+=32)n=Or(n,ue(t,s-32),ue(t,s-16),ue(e,3+s-160),r);n=Or(n,ue(t,t.byteLength-16),ue(t,t.byteLength-32),ue(e,103),En(r));let i=n+(n>>64n)ⅇi=Je(i);let o=(n&ee)*ut+(n>>64n)*Xn+(BigInt(t.byteLength)-r&ee)*Et;return o&=ee,o=En(Je(o)),i|o<<64n},"len129to240_128b"),nd=de((t,e=0n)=>{const r=t.byteLength;return r<=16?ed(t,e):r<=128?td(t,He,e):r<=240?rd(t,He,e):Xl(t,He)},"xxh3_128"),od=de(t=>{const e=t>>64n&ee,r=tⅇreturn e.toString(16).padStart(16,"0")+r.toString(16).padStart(16,"0")},"bigintToHex"),cs=de(t=>od(nd(t)),"xxh3Hash");class id{static{$(this,"gn")}static{de(this,"Xxh3Hasher")}#e=[];update(e){return typeof e=="string"?this.#e.push(Buffer.from(e)):this.#e.push(e),this}digest(){return cs(Buffer.concat(this.#e))}}de(()=>new id,"createXxh3Hasher");var sd=Object.defineProperty,ht=$((t,e)=>sd(t,"name",{value:e,configurable:!0}),"i$8");const hr=ht(()=>T(Oe(),".vis","cache","ai"),"getCacheDirectory"),ad=3600*1e3,cd=1800*1e3,ld=ht(()=>{const t=hr();F(t)||$e(t,{recursive:!0})},"ensureCacheDirectory"),dd=ht((t,e,r)=>{const n=r.map(o=>({currentRange:o.currentRange,name:o.packageName,targetVersion:o.targetVersion})).toSorted((o,s)=>o.name.localeCompare(s.name)),i=JSON.stringify({analysisType:e,packages:n,provider:t});return cs(Buffer.from(i))},"buildCacheKey"),ud=ht(t=>{const e=T(hr(),`${t}.json`);if(F(e))try{const r=K(e,"utf8"),n=JSON.parse(r);if(Date.now()-n.createdAt>n.ttlMs){lt(e,{force:!0});return}return n.result}catch{lt(e,{force:!0});return}},"getCachedAnalysis"),pd=ht((t,e,r)=>{ld();const n=hr(),i={createdAt:Date.now(),result:e,ttlMs:r};H(T(n,`${t}.json`),JSON.stringify(i,void 0,2),"utf8")},"setCachedAnalysis"),fd=ht((t,e)=>e!==void 0&&e>0?e:t==="security"?cd:ad,"getTtlForAnalysisType"),gd=ht(()=>{const t=hr();if(!F(t))return{entries:0,newestEntry:void 0,oldestEntry:void 0,totalSizeBytes:0};const e=ft(t).filter(o=>o.endsWith(".json"));let r=0,n,i;for(const o of e){const s=T(t,o),l=Yr(s);r+=l.size;const{mtimeMs:d}=l;(n===void 0||d<n)&&(n=d),(i===void 0||d>i)&&(i=d)}return{entries:e.length,newestEntry:i,oldestEntry:n,totalSizeBytes:r}},"getCacheStats"),hd=ht(()=>{const t=hr();if(!F(t))return 0;const e=ft(t).filter(r=>r.endsWith(".json"));for(const r of e)lt(T(t,r),{force:!0});return e.length},"clearCache");var md=Object.defineProperty,ve=$((t,e)=>md(t,"name",{value:e,configurable:!0}),"o$d");const Pr={amp:30,claude:80,codex:60,copilot:50,crush:35,cursor:40,droid:20,gemini:100,kimi:25,opencode:35,qwen:30},Kn=ve(t=>{if(t?.provider){if(!pc.includes(t.provider))return;const n=fc(t.provider);return n.available?n:void 0}const e=gc();if(e.length===0)return;const r={...Pr,...t?.priority};return e.toSorted((n,i)=>(r[i.name]??0)-(r[n.name]??0))[0]},"resolveProvider"),yd=new Set(["defer","review","skip","update"]),vd=new Set(["critical","high","low","medium"]),wd=new Set(["high","low","medium"]),kd=50,mn=30,bd=2,$d=1e3,xd=12e4,Sd=ve(t=>t.map(e=>{const r=e.vulnerabilities&&e.vulnerabilities.length>0?` [VULNERABILITIES: ${e.vulnerabilities.map(i=>`${i.severity} ${i.id}`).join(", ")}]`:"";let n="";if(e.socketReport){const i=Math.round(e.socketReport.score.overall*100),o=[`score:${String(i)}%`];if(e.socketReport.alerts.length>0){const s=e.socketReport.alerts.reduce((d,f)=>(d[f.severity]=(d[f.severity]??0)+1,d),{}),l=Object.entries(s).map(([d,f])=>`${String(f)} ${d}`).join(", ");o.push(`alerts: ${l}`)}o.push(`supply-chain:${String(Math.round(e.socketReport.score.supplyChain*100))}%`),o.push(`quality:${String(Math.round(e.socketReport.score.quality*100))}%`),n=` [SOCKET.DEV: ${o.join(", ")}]`}return`- ${e.packageName}: ${e.currentRange} → ${e.newRange} (${e.updateType})${r}${n}`}).join(`
|
|
16
|
-
`),"
|
|
2
|
+
var Iu=Object.defineProperty;var b=(t,e)=>Iu(t,"name",{value:e,configurable:!0});import{createRequire as Au}from"node:module";import{createCerebro as Pu}from"@visulima/cerebro";import Nu from"@visulima/cerebro/command/completion";import Mu from"@visulima/cerebro/compile-cache";import{applyHeapTuning as Du}from"@visulima/cerebro/heap-tuning";import{errorHandlerPlugin as Bu}from"@visulima/cerebro/plugins/error-handler";import{isAccessibleSync as T,readFileSync as ee,isFsCaseSensitive as Fu,walkSync as Rn,readJsonSync as ue,ensureDirSync as je,writeJsonSync as Mi,writeFileSync as Q,removeSync as Lu,glob as Vu}from"@visulima/fs";import{findPackageManagerSync as $o,parseLockFileContent as Sc,getPackageManagerVersion as Uu,findMonorepoRootSync as xc}from"@visulima/package";import{relative as _e,join as w,isAbsolute as nt,basename as So,resolve as $e,dirname as Nt,parse as _u,sep as Cc}from"@visulima/path";import{createTaskGraph as Di,getAffectedProjects as jc,DEFAULT_CACHE_DIRECTORY_NAME as Gu,Cache as Tc,parseCacheSize as Wu,projectGraphToDot as zu,runConcurrently as Bi,TerminalBuffer as Ec,readLastRunSummary as Hu,enforceProjectConstraints as Rc,parsePartition as qu,TaskScheduler as Ju,generateRunSummary as Ps,writeChromeTrace as Yu,CompositeLifeCycle as Ns,defaultTaskRunner as Ms,createLogReporter as Ku,writeRunSummary as Xu}from"@visulima/task-runner";import{dim as be,green as Et,yellow as Re,cyan as st,red as Ue,magenta as Ac,bold as fr}from"@visulima/colorize";import Zu,{coerce as In,lt as ep,rcompare as tp,parse as rp,validRange as np,satisfies as op}from"semver";import{hyperlink as ip}from"@visulima/ansi";import{runProvider as Dc,PROVIDER_NAMES as fp,detectProvider as gp,detectAvailableProviders as hp,detectAllProviders as mp}from"@visulima/find-ai-runner";import{Spinner as Vi,Text as l,Box as h,render as Ut,renderToString as Oe,Table as Ui,useWindowSize as zr,useApp as Hr,useInput as mt,Dialog as wr,ScrollView as qr,Tabs as Bc,Tab as Fc,ScrollBar as An,TextInput as _i,StaticRender as Fs}from"@visulima/tui";import X,{useState as ve,useRef as Ve,useEffect as Rt,useCallback as It,useSyncExternalStore as On,useMemo as At}from"react";import{findCacheDirSync as Lc}from"@visulima/find-cache-dir";import{readYamlSync as Jr}from"@visulima/fs/yaml";import{formatBytes as wn,duration as Gc}from"@visulima/humanizer";import{jsx as u,jsxs as f,Fragment as gn}from"react/jsx-runtime";import{getRandomWord as Vs}from"@nkzw/safe-word-list";import wp from"validate-npm-package-name";import{downloadTemplate as Wc}from"giget";import{stripJsonComments as kp}from"@visulima/fs/utils";import{getManifestData as bp}from"@socketsecurity/registry";import $p from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import Sp from"module-replacements/manifests/native.json"with{type:"json"};import xp from"module-replacements/manifests/preferred.json"with{type:"json"};import{findVisConfigFile as Yr,loadVisConfig as Us}from"./config.js";import{createHooks as Tp}from"hookable";import{toXML as Rp}from"jstoxml";import{fingerprint as Br,listRules as zc,listRequiredValidators as Ip,scan as Hc,scanFiles as Ap,inspectRuleset as Op}from"@visulima/secret-scanner";import{execa as qc}from"execa";import Jc from"zeptomatch";const Ou=Au(import.meta.url),Dr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,wt=b(t=>{if(typeof Dr<"u"&&Dr.versions&&Dr.versions.node){const[e,r]=Dr.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Dr.getBuiltinModule(t)}return Ou(t)},"__cjs_getBuiltinModule"),{createInterface:dt}=wt("node:readline"),{platform:Ic,availableParallelism:Ds,homedir:Xe,tmpdir:Qu}=wt("node:os"),{env:Yo,cwd:Fi,stdin:Bs,stdout:sp}=Dr,{readFileSync:Oc,writeFileSync:Se,unlinkSync:Wr,readdirSync:Ge,rmSync:ot,statSync:br,lstatSync:Pc,chmodSync:Nc,cpSync:Li,mkdtempSync:ap,copyFileSync:cp,mkdirSync:lp,watch:dp}=wt("node:fs"),{createRequire:up}=wt("node:module"),{fileURLToPath:pp,pathToFileURL:Mc}=wt("node:url"),{execSync:Pn,spawnSync:ct,execFileSync:Vc,execFile:yp}=wt("node:child_process"),{readdir:Uc,stat:_c,realpath:Ls,rm:vp,appendFile:Gi}=wt("node:fs/promises"),{promisify:Cp}=wt("node:util"),{createInterface:jp}=wt("node:readline/promises"),{randomUUID:Ep}=wt("node:crypto"),{resolve:Pp,join:Np}=wt("node:path");var Mp="1.0.0-alpha.5";const kn={version:Mp};var Dp=Object.defineProperty,kr=b((t,e)=>Dp(t,"name",{value:e,configurable:!0}),"g$v");const Bp=/^#([\w\-/]+):(.+)$/,Fp=/^([@\w\-/]+):(.+)$/,Lp=kr(t=>{if(t==="")return;if(t.startsWith(":"))return{kind:"all",target:t.slice(1)};if(t.startsWith("~:"))return{kind:"closest",target:t.slice(2)};const e=Bp.exec(t);if(e?.[1]&&e[2])return{kind:"tag",tag:e[1],target:e[2]};const r=Fp.exec(t);return r?.[1]&&r[2]&&(r[1].startsWith("@")||r[1].includes("/")||r[1].includes("-"))?{kind:"project",projects:[r[1]],target:r[2]}:{kind:"all",target:t}},"parseTargetSelector"),Yc=kr(async(t,e,r,n)=>{const o=Lp(t);if(!o)throw new Error(`Invalid target selector: "${t}"`);const i=Object.keys(e.projects);if(o.kind==="all")return{projects:i,target:o.target};if(o.kind==="project")return{projects:o.projects??[],target:o.target};if(o.kind==="tag"){const d=o.tag;return{projects:i.filter(p=>e.projects[p]?.tags?.includes(d)??!1),target:o.target}}const s=_e(n,r)||".";let a,c=-1;for(const[d,p]of Object.entries(e.projects)){const g=p.root;g&&(s===g||s.startsWith(`${g}/`))&&g.length>c&&(c=g.length,a=d)}if(!a){if(process.stdout.isTTY){const d=dt({input:process.stdin,output:process.stderr}),p=Object.keys(e.projects).sort();process.stderr.write(`No project found at ${s}. Pick one:
|
|
3
|
+
`);for(const[y,v]of p.entries())process.stderr.write(` ${String(y+1)}) ${v}
|
|
4
|
+
`);const g=await new Promise(y=>{d.question("> ",y)});d.close();const m=Number.parseInt(g,10)-1;if(m>=0&&m<p.length)return{projects:[p[m]],target:o.target}}throw new Error(`No project found at or above ${s} for selector "${t}".`)}return{projects:[a],target:o.target}},"resolveSelector"),Vp=/^(\w+)\s*(!?=)\s*(.+)$/,Up=kr(t=>{const e=t.trim();if(e==="")return;const r=e.split("&&").map(d=>d.trim()),n=e.split("||").map(d=>d.trim()),o=r.length>1,i=n.length>1;if(o&&i)throw new Error("Query language does not support mixed && / || — split into multiple --query flags or simplify.");const s=i?n:r,a=i?"||":"&&",c=[];for(const d of s){const p=Vp.exec(d);if(!p)throw new Error(`Invalid query clause: "${d}". Expected <field>=<value> or <field>!=<value>.`);const[,g,m,y]=p;c.push({field:g,op:m==="!="?"!=":"=",value:y.trim().replaceAll(/^["']|["']$/g,"")})}return{clauses:c,op:a}},"parseQuery"),_s=kr((t,e,r)=>{const{field:n,op:o,value:i}=t,s=kr(c=>{const d=c===i;return o==="="?d:!d},"test"),a=kr(c=>{const d=(c??[]).includes(i);return o==="="?d:!d},"testList");switch(n){case"id":case"project":return s(e);case"language":return s(r.language);case"layer":return s(r.layer);case"projectType":case"type":return s(r.projectType);case"stack":return s(r.stack);case"tag":case"tags":return a(r.tags);default:return!1}},"matchClause"),xo=kr((t,e,r)=>{if(!r||r.trim()==="")return t;const n=Up(r);return n?t.filter(o=>{const i=e.projects[o];return i?n.op==="&&"?n.clauses.every(s=>_s(s,o,i)):n.clauses.some(s=>_s(s,o,i)):!1}):t},"filterProjectsByQuery");var _p=Object.defineProperty,kt=b((t,e)=>_p(t,"name",{value:e,configurable:!0}),"s$v");const Gp=kt((t,e=process.env,r=process.platform)=>{if(t===void 0)return!0;if(typeof t=="string"){const n=t.trim();if(n.startsWith("!")){const o=n.slice(1);return!e[o]}if(n.startsWith("$")){const o=n.slice(1);return!!e[o]}return!!e[n]}if(t.platform!==void 0&&!(Array.isArray(t.platform)?t.platform:[t.platform]).includes(r))return!1;if(t.env!==void 0){const n=e[t.env];return t.equals!==void 0?n===t.equals:t.in!==void 0?typeof n=="string"&&t.in.includes(n):!!n}return!0},"evaluateWhen"),Wp={server:{cache:!1,interactive:!1,persistent:!0,runInCI:!1},utility:{cache:!1,runInCI:!1}},zp=kt(t=>{const e=t.preset??t.options?.preset;if(!e)return t;const r=Wp[e];if(!r)return t;const{cache:n,...o}=r;return{...t,cache:t.cache??n,options:{...o,...t.options}}},"applyPreset"),Hp=kt(t=>{if(t!==void 0)return Array.isArray(t)?t:[t]},"normalizeOsType"),Wi=kt(()=>{const t=Ic();return t==="darwin"?"macos":t==="win32"?"windows":"linux"},"detectCurrentOs"),qp=kt((t,e=Wi())=>{const r=Hp(t?.osType);return!r||r.length===0?!0:r.includes(e)},"matchesOs"),Jp=kt((t,e,r=!0)=>{const n=t?.runInCI??!0;return n===!0||n==="always"?!0:n===!1?!e:n==="affected"?!e||r:!0},"shouldRunInCI"),Kc=kt((t,e)=>{if(e===!1)return{};const r=e===!0?Yp("production"):Array.isArray(e)?e:[e],n={};for(const o of r)Object.assign(n,Kp(t,o));return n},"loadEnvFile"),Yp=kt(t=>{const e=[".env"];return t&&e.push(`.env.${t}`),t!=="test"&&e.push(".env.local"),t&&t!=="test"&&e.push(`.env.${t}.local`),e},"resolveEnvCascade"),Kp=kt((t,e)=>{const r=e.startsWith("/")?e:w(t,e);if(!T(r))return{};let n;try{n=ee(r)}catch{return{}}const o={};for(const i of n.split(/\r?\n/)){const s=i.trim();if(s===""||s.startsWith("#"))continue;const a=s.indexOf("=");if(a===-1)continue;const c=s.slice(0,a).trim();if(c==="")continue;let d=s.slice(a+1).trim();(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))&&(d=d.slice(1,-1)),o[c]=d}return o},"loadSingleEnvFile"),Xp=kt((t,e=Wi())=>{if(t)return e==="windows"&&t.windowsShell?t.windowsShell:(e==="linux"||e==="macos")&&t.unixShell?t.unixShell:t.shell},"resolveTargetShell"),Qp=kt(t=>{if(t==="run")return!1;if(t==="build"||t==="test")return!0},"defaultCacheForType");var Zp=Object.defineProperty,ef=b((t,e)=>Zp(t,"name",{value:e,configurable:!0}),"s$u");class jr extends Error{static{b(this,"StagedError")}static{ef(this,"StagedError")}constructor(e,r){super(e,r),this.name=this.constructor.name}}var tf=Object.defineProperty,rf=b((t,e)=>tf(t,"name",{value:e,configurable:!0}),"o$v");class nf extends jr{static{b(this,"ApplyEmptyCommitError")}static{rf(this,"ApplyEmptyCommitError")}}var of=Object.defineProperty,sf=b((t,e)=>of(t,"name",{value:e,configurable:!0}),"o$u");class vt extends jr{static{b(this,"ConfigError")}static{sf(this,"ConfigError")}}var af=Object.defineProperty,cf=b((t,e)=>af(t,"name",{value:e,configurable:!0}),"t$l");class Gs extends jr{static{b(this,"GetBackupStashError")}static{cf(this,"GetBackupStashError")}}var lf=Object.defineProperty,df=b((t,e)=>lf(t,"name",{value:e,configurable:!0}),"s$t");class hn extends jr{static{b(this,"GitError")}static{df(this,"GitError")}stderr;constructor(e,r,n){super(e,n),this.stderr=r}}var uf=Object.defineProperty,pf=b((t,e)=>uf(t,"name",{value:e,configurable:!0}),"e$a");class Ws extends jr{static{b(this,"RestoreOriginalStateError")}static{pf(this,"RestoreOriginalStateError")}}var ff=Object.defineProperty,gf=b((t,e)=>ff(t,"name",{value:e,configurable:!0}),"o$r");class yr extends jr{static{b(this,"TaskError")}static{gf(this,"TaskError")}commandTitle;constructor(e,r,n){super(r,n),this.commandTitle=e}}var hf=Object.defineProperty,Co=b((t,e)=>hf(t,"name",{value:e,configurable:!0}),"i$h");const mf=Co(async t=>{if(t.config!==void 0)return t.config;throw new vt(`No staged config provided. Add \`staged\` to your vis.config.ts:
|
|
5
|
+
|
|
6
|
+
import { defineConfig } from "@visulima/vis/config";
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
staged: { "*.ts": "eslint --fix" },
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},"resolveConfig"),zs=Co(t=>{if(typeof t!="object"||t===null)throw new vt("Staged config must be an object mapping glob patterns to tasks.");const e=Object.entries(t);if(e.length===0)throw new vt("Staged config is empty — at least one glob pattern is required.");for(const[r,n]of e){if(!r||r.trim()==="")throw new vt("Staged config keys must be non-empty glob patterns.");Xc(r,n)}return t},"validateConfig"),Xc=Co((t,e)=>{if(typeof e=="string"){if(e.trim()==="")throw new vt(`Task for "${t}" is an empty string.`);return}if(Array.isArray(e)){if(e.length===0)throw new vt(`Task array for "${t}" is empty.`);for(const r of e)Xc(t,r);return}if(typeof e!="function"&&!yf(e))throw new vt(`Invalid task for "${t}" — expected string, string[], function, or { title, task } object.`)},"validateTask"),yf=Co(t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function","isCustomTask");var vf=Object.defineProperty,Ht=b((t,e)=>vf(t,"name",{value:e,configurable:!0}),"n$d");const Hs=2048,Ee=Ht(async(t,e)=>{const r=await qc("git",[...t],{cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,input:e.input,reject:!1,stderr:"pipe",stdin:e.input===void 0?"ignore":"pipe",stdout:"pipe"}),n=typeof r.exitCode=="number"?r.exitCode:1;if(n!==0&&!e.lenient){const o=typeof r.stderr=="string"?r.stderr:"",i=o.length>Hs?`${o.slice(0,Hs)}…`:o;throw new hn(`git ${t.join(" ")} failed with exit code ${n}: ${i.trim()}`,o)}return{exitCode:n,stderr:typeof r.stderr=="string"?r.stderr:"",stdout:typeof r.stdout=="string"?r.stdout:""}},"git"),Kr=Ht(async(t,e)=>{const{stdout:r}=await Ee(t,e);return r.trim()},"gitOut"),wf=Ht(async t=>{const e=await Ee(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},"isGitRepo"),kf=Ht(async t=>Kr(["rev-parse","--absolute-git-dir"],{cwd:t}),"getGitDirectory"),Qc=Ht(async t=>Kr(["rev-parse","--show-toplevel"],{cwd:t}),"getWorkTree"),qs=Ht(async t=>Kr(["write-tree"],{cwd:t}),"writeIndexTree"),bf=Ht(async t=>{const e=await Ee(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},"headTreeSha"),sn={major:2,minor:32},$f=Ht(t=>{const e=/git version (\d+)\.(\d+)/.exec(t);if(!e)return null;const r=Number.parseInt(e[1]??"",10),n=Number.parseInt(e[2]??"",10);return Number.isNaN(r)||Number.isNaN(n)?null:{major:r,minor:n}},"parseGitVersion"),Sf=Ht(async t=>{const e=$f(await Kr(["--version"],{cwd:t}));if(e!==null&&(e.major<sn.major||e.major===sn.major&&e.minor<sn.minor))throw new hn(`Git ${sn.major}.${sn.minor} or newer is required; found ${e.major}.${e.minor}.`)},"assertGitVersion");var xf=Object.defineProperty,nr=b((t,e)=>xf(t,"name",{value:e,configurable:!0}),"a$q");const Cf="ACMR",Js=500,jf=nr(async t=>{const{stdout:e}=await Ee(["diff-files","--raw","-z"],{cwd:t}),r=e.split("\0").filter(o=>o.length>0),n=[];for(let o=0;o<r.length;o+=1){const i=r[o];if(!i?.startsWith(":"))continue;const s=i.slice(1).split(" "),a=s[3],c=s[4],d=r[o+1];o+=1,c==="A"&&a!==void 0&&/^0+$/.test(a)&&d!==void 0&&n.push(d)}return n},"getIntentToAddPaths"),Ys=nr(async t=>{const{stdout:e}=await Ee(["ls-files","--others","--exclude-standard","-z"],{cwd:t});return e.split("\0").filter(r=>r.length>0)},"getUntrackedFiles"),Tf=nr(async(t,e)=>{if(t.length===0)return;const r=`${t.join("\0")}\0`;await Ee(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:r})},"removeFromIndex"),Ef=nr(async t=>{const e=t.diffFilter??Cf,r=t.diff===void 0?["diff","--name-only","-z",`--diff-filter=${e}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${e}`,...t.diff.split(/\s+/).filter(Boolean)],{stdout:n}=await Ee(r,{cwd:t.cwd}),o=n.split("\0").filter(s=>s.length>0);if(o.length===0)return[];const i=t.workTree??await Qc(t.cwd);return o.map(s=>nt(s)?s:w(i,s))},"getFiles"),Rf=nr(async(t,e)=>{if(t.length===0)return null;const r=[];for(let i=0;i<t.length;i+=Js){const s=t.slice(i,i+Js),{stdout:a}=await Ee(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...s],{cwd:e.cwd});a.length>0&&r.push(a)}if(r.length===0)return null;const n=r.join(""),o=n.endsWith(`
|
|
13
|
+
`)?n:`${n}
|
|
14
|
+
`;return Buffer.from(o,"utf8")},"capturePatch"),If=nr(async t=>{const{stdout:e}=await Ee(["status","--porcelain=v1","-z"],{cwd:t}),r=e.split("\0"),n=[];for(let o=0;o<r.length;o+=1){const i=r[o];if(i===void 0||i.length<4)continue;const s=i.charAt(0),a=i.charAt(1),c=i.slice(3),d=s==="R"||s==="C"||a==="R"||a==="C";s!==" "&&s!=="?"&&a!==" "&&a!=="?"&&n.push(c),d&&(o+=1)}return n},"getPartiallyStagedFiles"),Af=nr(async(t,e)=>{if(t.length===0)return;const r=`${t.join("\0")}\0`;await Ee(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:r})},"checkoutPaths"),Of=nr(async(t,e)=>{if(await Ee(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const r=`${t.join("\0")}\0`;await Ee(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:r})},"updateIndexAgain");var Pf=Object.defineProperty,Tr=b((t,e)=>Pf(t,"name",{value:e,configurable:!0}),"r$p");const Nf="vis_staged_automatic_backup",Zc=Tr(()=>`${Nf}-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,"buildMessage"),Mf=Tr(async t=>{const e=await Kr(["stash","create"],{cwd:t});return e.length===0?null:(await Ee(["stash","store","-m",Zc(),e],{cwd:t}),e)},"createBackupStash"),Df=Tr(async t=>{const e=Zc(),{exitCode:r,stdout:n}=await Ee(["stash","push","--keep-index","--include-untracked","--quiet","-m",e],{cwd:t,lenient:!0});if(r!==0)return null;const o=n.trim();return o.length>0&&/no local changes/i.test(o)?null:Kr(["rev-parse","stash@{0}"],{cwd:t})},"createHideAllStash"),zi=Tr(async(t,e)=>{const{exitCode:r,stdout:n}=await Ee(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(r!==0)return null;for(const o of n.split(/\r?\n/)){const[i,s]=o.split(/\s+/,2);if(i===e&&s!==void 0)return s}return null},"findStashRefBySha"),Ks=Tr(async(t,e)=>{if(e===null)return;const r=await zi(t,e);r!==null&&await Ee(["stash","drop","--quiet",r],{cwd:t})},"dropBackupStash"),Bf=Tr(async(t,e)=>{if(e===null)throw new Gs("Backup stash was not found — can't revert working tree.");const r=await zi(t,e);if(r===null)throw new Gs(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await Ee(["reset","--hard","HEAD"],{cwd:t}),await Ee(["stash","apply","--index","--quiet",r],{cwd:t})},"applyBackupStash"),Ff=Tr(async(t,e)=>{if(e===null)return;const r=await zi(t,e);r!==null&&await Ee(["stash","pop","--quiet",r],{cwd:t})},"popHideAllStash");var Lf=Object.defineProperty,Vf=b((t,e)=>Lf(t,"name",{value:e,configurable:!0}),"l$t");class Uf{static{b(this,"GitWorkflow")}static{Vf(this,"GitWorkflow")}stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(e){this.cwd=e.cwd??process.cwd(),this.options=e,this.shouldStash=e.stash!==!1&&e.diff===void 0,this.shouldHidePartial=e.hidePartiallyStaged!==!1,this.shouldHideUnstaged=e.hideUnstaged===!0,this.shouldHideAll=e.hideAll===!0}async prepare(){if(!await wf(this.cwd))throw new hn(`Not a git repository: ${this.cwd}`);await Sf(this.cwd),this.workTree=await Qc(this.cwd),this.gitDir=await kf(this.cwd),this.stagedFiles=await Ef({cwd:this.cwd,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await If(this.cwd),this.snapshotMergeState(),this.intentToAddPaths=await jf(this.workTree),this.intentToAddPaths.length>0&&await Tf(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await Mf(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await Df(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await qs(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await bf(this.workTree),this.preTaskUntracked=new Set(await Ys(this.workTree))}async applyModifications({autoStage:e=!1}={}){if(this.stagedFiles.length===0)return;const r=this.stagedFiles.map(n=>_e(this.workTree,n));if(await Of(r,{cwd:this.workTree}),e){const n=(await Ys(this.workTree)).filter(o=>!this.preTaskUntracked.has(o));if(n.length>0){const o=`${n.join("\0")}\0`;await Ee(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:o})}}if(this.intentToAddPaths.length>0)try{await Ee(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await qs(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const e=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let r;try{await Ee(e,{cwd:this.workTree,input:this.patch});return}catch(n){r=n instanceof hn?n.stderr:String(n)}try{await Ee([...e,"--3way"],{cwd:this.workTree,input:this.patch})}catch(n){const o=n instanceof hn&&n.stderr?n.stderr:String(n);throw new Ws(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
|
|
15
|
+
First attempt: ${r??"(no stderr)"}
|
|
16
|
+
Second attempt: ${o}`,{cause:n})}}async revert(){if(this.backupStashSha!==null){try{await Bf(this.workTree,this.backupStashSha)}catch(e){throw new Ws("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await Ks(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await Ee(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await Ff(this.workTree,this.hideAllStashSha)}catch{}e&&this.backupStashSha!==null&&!this.revertApplied&&await Ks(this.workTree,this.backupStashSha)}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const e=new Set(this.stagedFiles.map(n=>_e(this.workTree,n))),r=this.shouldHideUnstaged?[...e]:this.shouldHidePartial?this.partiallyStaged.filter(n=>e.has(n)):[];r.length!==0&&(this.patch=await Rf(r,{cwd:this.workTree}),this.patch!==null&&await Af(r,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(e=>{const r=w(this.gitDir,e);return T(r)?{body:Oc(r),existed:!0,name:e}:{body:null,existed:!1,name:e}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const e of this.merge){const r=w(this.gitDir,e.name);try{e.existed&&e.body!==null?Se(r,e.body):T(r)&&Wr(r)}catch{}}}}var _f=Object.defineProperty,jo=b((t,e)=>_f(t,"name",{value:e,configurable:!0}),"r$o");const el=jo(t=>t.includes("/"),"isPathStyle"),ao=jo((t,e)=>e?t.toLowerCase():t,"normalizeForMatch"),Gf=jo((t,e,r,n={})=>{const o=el(t),i=n.caseInsensitive===!0,s=ao(t,i),a=[];for(const c of e){const d=o?_e(r,c):So(c);Jc(s,ao(d,i))&&a.push(c)}return a},"matchFiles"),Wf=jo((t,e,r,n={})=>{if(!e||e.length===0)return[...t];const o=n.caseInsensitive===!0;return t.filter(i=>{for(const s of e){const a=el(s)?_e(r,i):So(i),c=ao(s,o);if(Jc(c,ao(a,o)))return!1}return!0})},"applyIgnore");var zf=Object.defineProperty,Hf=b((t,e)=>zf(t,"name",{value:e,configurable:!0}),"e$9");const qf=Hf(()=>process.platform==="win32"?!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color":process.env.TERM!=="linux","isUnicodeSupported"),To=qf(),Eo=To?"✓":"√",Nn=To?"✖":"×",tl=To?"…":"...",Zt=To?"—":"-";var Jf=Object.defineProperty,bn=b((t,e)=>Jf(t,"name",{value:e,configurable:!0}),"g$s");const Yf=bn(t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},"colorForStatus"),Xs=bn(t=>{if(t==="running")return u(Vi,{type:"dots"});const e=t==="failed"?Nn:t==="skipped"?Zt:t==="success"?Eo:Zt;return u(l,{color:Yf(t),children:e})},"iconForStatus"),Qs=bn(({state:t,tick:e,verbose:r})=>f(h,{flexDirection:"column",children:[[...t.patterns.values()].map(n=>f(h,{flexDirection:"column",children:[f(h,{children:[Xs(n.status),f(l,{children:[" ",n.title]})]}),[...n.commands.values()].map(o=>f(h,{flexDirection:"column",marginLeft:2,children:[f(h,{children:[Xs(o.status),f(l,{children:[" ",o.title," "]}),o.status!=="pending"&&o.status!=="running"?f(l,{color:"gray",children:["(",o.durationMs,"ms)"]}):null]}),r&&o.output?u(h,{flexDirection:"column",marginLeft:2,children:o.output.split(/\r?\n/).slice(0,20).map((i,s)=>u(l,{color:"gray",children:i},`${o.id}-line-${s}`))}):null,o.status==="failed"&&o.error?u(h,{marginLeft:2,children:u(l,{color:"red",children:o.error.message})}):null]},o.id))]},n.id)),t.infoMessages.map((n,o)=>u(l,{color:"gray",children:n},`info-${o}`)),t.warnMessages.map((n,o)=>u(l,{color:"yellow",children:n},`warn-${o}`)),t.errorMessages.map(({message:n},o)=>u(l,{color:"red",children:n},`err-${o}`))]}),"App"),Kf=bn((t={})=>{const e=t.verbose===!0,r={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let n=0;const o=Ut(u(Qs,{state:r,tick:n,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),i=bn(()=>{n+=1,o.rerender(u(Qs,{state:r,tick:n,verbose:e}))},"refresh");return{commandEnd({commandId:s,durationMs:a,error:c,output:d,patternId:p,status:g}){const m=r.patterns.get(p)?.commands.get(s);m&&(m.status=g,m.durationMs=a,m.output=d,m.error=c,i())},commandStart({commandId:s,patternId:a}){const c=r.patterns.get(a)?.commands.get(s);c&&(c.status="running",i())},error({error:s,message:a}){r.errorMessages.push({error:s,message:a}),i()},info({message:s}){r.infoMessages.push(s),i()},patternEnd({patternId:s,status:a}){const c=r.patterns.get(s);c&&(c.status=a,i())},patternStart({patternId:s}){const a=r.patterns.get(s);a&&(a.status="running",i())},start({patterns:s}){r.started=!0;for(const a of s){const c=new Map;for(const d of a.commands)c.set(d.id,{durationMs:0,id:d.id,status:"pending",title:d.title});r.patterns.set(a.id,{commands:c,id:a.id,status:"pending",title:a.title})}i()},async stop(){o.unmount(),await o.waitUntilExit()},warn({message:s}){r.warnMessages.push(s),i()}}},"createInkRenderer");var Xf=Object.defineProperty,Ko=b((t,e)=>Xf(t,"name",{value:e,configurable:!0}),"a$p");const Zs=Ko((t={})=>{const{quiet:e=!1,verbose:r=!1}=t,n=new Map,o=new Map,i=Ko(a=>{e||process.stderr.write(`${a}
|
|
17
|
+
`)},"print"),s=Ko(a=>{switch(a){case"failed":return Ue(Nn);case"running":return st(">");case"skipped":return Re(Zt);case"success":return Et(Eo);default:return be(Zt)}},"iconFor");return{commandEnd({commandId:a,durationMs:c,error:d,output:p,status:g}){const m=o.get(a)??a,y=be(`(${c}ms)`);if(i(` ${s(g)} ${m} ${y}`),g==="failed"&&d&&i(be(d.message)),(g==="failed"||r)&&p&&p.trim().length>0)for(const v of p.split(/\r?\n/))i(` ${be(v)}`)},commandStart({commandId:a}){if(!r)return;const c=o.get(a)??a;i(` ${be("…")} ${c}`)},error({error:a,message:c}){e?process.stderr.write(`${Ue(c)}
|
|
18
|
+
`):i(Ue(c)),a?.stack&&(r||!e)&&process.stderr.write(`${be(a.stack)}
|
|
19
|
+
`)},info({message:a}){i(be(a))},patternEnd({patternId:a,status:c}){const d=n.get(a)??a;i(`${s(c)} ${d}`)},patternStart({patternId:a}){const c=n.get(a)??a;i(`${st(">")} ${c}`)},start({patterns:a}){if(a.length===0){i(be("No staged files matched any pattern."));return}const c=new Set(a.flatMap(d=>d.files)).size;i(`${st(">")} Running staged tasks on ${c} file${c===1?"":"s"} across ${a.length} pattern${a.length===1?"":"s"}`);for(const d of a){n.set(d.id,d.title);for(const p of d.commands)o.set(p.id,p.title)}},stop(){},warn({message:a}){i(Re(a))}}},"createPlainRenderer");var Qf=Object.defineProperty,Zf=b((t,e)=>Qf(t,"name",{value:e,configurable:!0}),"t$j");const eg=Zf(async t=>{const{env:e}=process;if(t.debug===!0||t.quiet===!0||e.NODE_ENV==="test"||e.TERM==="dumb"||e.CI!==void 0||!process.stderr.isTTY)return Zs({quiet:t.quiet,verbose:t.verbose});try{return Kf({verbose:t.verbose})}catch{return Zs({quiet:t.quiet,verbose:t.verbose})}},"pickRenderer");var tg=Object.defineProperty,un=b((t,e)=>tg(t,"name",{value:e,configurable:!0}),"a$o");const Xo=un(t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function","isCustomTask"),rg=un(async t=>{let e=0,r=0;const n=un(()=>(e+=1,`pattern-${e}`),"nextPatternId"),o=un(()=>(r+=1,`cmd-${r}`),"nextCommandId"),i=un(async(a,c,d)=>{if(typeof a=="string"){d.push({command:a,files:c,id:o(),source:"string",title:a});return}if(Array.isArray(a)){for(const p of a)await i(p,c,d);return}if(typeof a=="function"){const p=await a([...c]);if(typeof p=="string"){d.push({command:p,files:c,id:o(),source:"function",title:p});return}if(Array.isArray(p)){for(const g of p)if(typeof g=="string")d.push({command:g,files:c,id:o(),source:"function",title:g});else if(Xo(g))d.push({files:c,id:o(),run:g.task,source:"custom",title:g.title});else throw new vt("Task function returned an array with an unsupported entry — expected strings or { title, task }.");return}if(Xo(p)){d.push({files:c,id:o(),run:p.task,source:"custom",title:p.title});return}throw new vt("Task function returned an unsupported value — expected string, string[], or { title, task }.")}if(Xo(a)){d.push({files:c,id:o(),run:a.task,source:"custom",title:a.title});return}throw new vt("Unsupported task value — expected string, string[], function, or { title, task }.")},"expandTask"),s=[];for(const[a,c]of Object.entries(t.config)){const d=Gf(a,t.files,t.cwd,{caseInsensitive:t.caseInsensitive===!0});if(d.length===0)continue;const p=t.relative?d.map(m=>_e(t.cwd,m)):d,g=[];await i(c,p,g),g.length!==0&&s.push({commands:g,files:p,id:n(),pattern:a,title:`${a} — ${d.length} file${d.length===1?"":"s"}`})}return s},"buildTaskGraph");var ng=Object.defineProperty,Ro=b((t,e)=>ng(t,"name",{value:e,configurable:!0}),"d$A");const og=Ro(t=>{const e=[];let r="",n=!1,o=!1;for(let i=0;i<t.length;i+=1){const s=t[i];if(s===void 0)break;if(s==="\\"&&!n&&i+1<t.length){const a=t[i+1];if(a!==void 0){o&&a!=='"'&&a!=="\\"&&(r+=s),r+=a,i+=1;continue}}if(s==='"'&&!n){o=!o;continue}if(s==="'"&&!o){n=!n;continue}if(!n&&!o&&/\s/.test(s)){r.length>0&&(e.push(r),r="");continue}r+=s}if(n||o)throw new vt(`Unterminated ${n?"single":"double"} quote in command: ${t}`);return r.length>0&&e.push(r),e},"parseCommandString"),rl=process.platform==="win32"?28e3:131072,ig=Ro((t,e,r)=>{const n=[];let o=[],i=e;const s=r<=0?rl:r;for(const a of t){const c=Buffer.byteLength(a)+1;o.length>0&&i+c>s&&(n.push(o),o=[],i=e),o.push(a),i+=c}return o.length>0&&n.push(o),n},"chunkFiles"),sg=Ro(async(t,e,r)=>{const n=og(t);if(n.length===0)throw new yr(t,"Empty command for staged task.");const[o,...i]=n;if(o===void 0)throw new yr(t,"Empty command for staged task.");const s=Buffer.byteLength(o)+i.reduce((p,g)=>p+Buffer.byteLength(g)+1,0),a=ig(e,s,r.maxArgLength??rl),c=Date.now(),d=[];for(const p of a){if(r.signal?.aborted===!0)throw new yr(t,"Task aborted by earlier failure.");const g=await qc(o,[...i,...p],{cancelSignal:r.signal,cwd:r.cwd,env:ag(r.env),killSignal:r.killSignal??"SIGTERM",reject:!1,stderr:"pipe",stdout:"pipe"}),m=typeof g.stdout=="string"?g.stdout:"",y=typeof g.stderr=="string"?g.stderr:"",v=[m,y].filter(k=>k.length>0).join(`
|
|
20
|
+
`);if(v.length>0&&d.push(v),g.isCanceled||g.isTerminated||typeof g.exitCode!="number"){const k=g.isCanceled?"Task aborted by earlier failure.":g.isTerminated?`Task killed by signal ${g.signal??"(unknown)"}.`:v.trim()||"Task exited without a numeric status code.";throw new yr(t,k)}if(g.exitCode!==0)throw new yr(t,v.trim()||`Exit code ${g.exitCode} from ${o}`)}return{durationMs:Date.now()-c,output:d.join(`
|
|
21
|
+
`)}},"execCommand"),ag=Ro(t=>{const e={...process.env};return process.stderr.isTTY&&e.FORCE_COLOR===void 0&&e.NO_COLOR===void 0&&(e.FORCE_COLOR="1"),t?{...e,...t}:e},"buildTaskEnv");var cg=Object.defineProperty,vr=b((t,e)=>cg(t,"name",{value:e,configurable:!0}),"o$o");const lg=vr(async(t,e,r)=>{const n=ug(r.concurrent,t.length),o=[],i=new AbortController;let s=!1,a=0;const c=vr(()=>{s||(s=!0,r.continueOnError||i.abort())},"cancel");r.externalSignal&&(r.externalSignal.aborted?c():r.externalSignal.addEventListener("abort",()=>{c()},{once:!0}));const d=vr(v=>{for(const k of v.commands)e.commandEnd({commandId:k.id,durationMs:0,patternId:v.id,status:"skipped"})},"emitSkippedCommands"),p=vr(async v=>{if(s){d(v),e.patternEnd({patternId:v.id,status:"skipped"});return}e.patternStart({patternId:v.id});let k="success";for(const $ of v.commands){if(s){e.commandEnd({commandId:$.id,durationMs:0,patternId:v.id,status:"skipped"}),k=k==="success"?"skipped":k;continue}e.commandStart({commandId:$.id,patternId:v.id});const x=await dg($,r,i.signal),E=x.status==="failed"&&i.signal.aborted?{...x,status:"skipped"}:x;if(e.commandEnd({commandId:$.id,durationMs:E.durationMs,error:E.error,output:E.output,patternId:v.id,status:E.status}),E.status==="failed"){o.push($.title),k="failed",c();break}if(E.status==="skipped"){k=k==="success"?"skipped":k;break}}e.patternEnd({patternId:v.id,status:k})},"runOne"),g=vr(async()=>{for(;a<t.length;){const v=t[a];a+=1,v&&await p(v)}},"pickNext"),m=[];for(let v=0;v<Math.min(n,t.length);v+=1)m.push(g());await Promise.all(m);const y=r.externalSignal?.aborted===!0;return{failedCommands:o,success:o.length===0&&!y}},"runTasks"),dg=vr(async(t,e,r)=>{const n=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-n,status:"success"};if(t.command){const o=await sg(t.command,t.files,{cwd:e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:r});return{durationMs:o.durationMs,output:e.verbose?o.output:void 0,status:"success"}}return{durationMs:Date.now()-n,error:new yr(t.title,"Command has no invocation target."),status:"failed"}}catch(o){const i=o instanceof Error?o:new Error(String(o));return{durationMs:Date.now()-n,error:i,output:i instanceof yr?i.message:void 0,status:"failed"}}},"runCommand"),ug=vr((t,e)=>{if(t===!1)return 1;if(t===!0){const n=Math.max(1,typeof Ds=="function"?Ds():4);return Math.min(Math.max(1,e),n)}const r=Math.floor(t);return r>0?r:1},"concurrencyLimit");var pg=Object.defineProperty,hi=b((t,e)=>pg(t,"name",{value:e,configurable:!0}),"u$p");const fg=!0,gg=hi(t=>{try{return!Fu(t)}catch{return!1}},"detectCaseInsensitive"),hg=hi(async(t={})=>{const e=t.cwd??process.cwd(),r=await eg(t),n=await mf(t);typeof n!="function"&&zs(n);const o=new Uf({...t,cwd:e}),i=new AbortController;let s=!1;const a=hi(g=>{if(s){process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),process.kill(process.pid,g);return}s=!0,r.warn({message:`Received ${g} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),i.abort()},"onInterrupt");process.on("SIGINT",a),process.on("SIGTERM",a);let c={failedCommands:[],ranTasks:!1,success:!0},d=!1,p=!1;try{await o.prepare(),d=!0;for(const x of o.warnings)r.warn({message:x});if(o.stagedFiles.length===0)return t.allowEmpty!==!0&&r.info({message:"No staged files found."}),p=!0,{failedCommands:[],ranTasks:!1,success:!0};const g=gg(e),m=Wf(o.stagedFiles,t.ignore,e,{caseInsensitive:g});if(m.length===0&&o.stagedFiles.length>0)return r.info({message:"Every staged file was excluded by the `ignore` list."}),p=!0,{failedCommands:[],ranTasks:!1,success:!0};const y=typeof n=="function"?zs(await n([...m])):n,v=await rg({caseInsensitive:g,config:y,cwd:e,files:m,relative:t.relative});if(r.start({patterns:v}),v.length===0)return r.info({message:"No staged files matched any pattern."}),p=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:k,success:$}=await lg(v,r,{concurrent:t.concurrent??fg,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:i.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(c={failedCommands:k,ranTasks:!0,success:$},$){if(t.diff===void 0&&(await o.applyModifications({autoStage:t.autoStage===!0}),t.failOnChanges===!0&&o.indexTreeChanged()&&(r.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),c={failedCommands:[...k],ranTasks:!0,success:!1}),t.allowEmpty!==!0&&o.postTaskIndexMatchesHead()))throw new nf("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(t.revert===!0)r.info({message:"Reverting working tree from backup stash."}),await o.revert();else{const x=o.recoveryHint();x&&r.warn({message:x})}return await o.restoreUnstagedChanges(),p=c.success,c}catch(g){const m=g instanceof Error?g.message:String(g),y=g instanceof Error?g:new Error(m);if(r.error({error:y,message:m}),g instanceof jr)return{failedCommands:c.failedCommands,ranTasks:c.ranTasks,success:!1};throw g}finally{if(process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),d)try{await o.cleanup(p)}catch(g){r.error({error:g,message:"Cleanup failed."})}await r.stop()}},"runStaged");var mg=Object.defineProperty,qe=b((t,e)=>mg(t,"name",{value:e,configurable:!0}),"c$y");const yg=/\/+$/,vg=/\/\*\*$/,wg=/\/\*\/\*$/,kg=/^['"]|['"]$/g,nl=/node_modules/,ol=/\.git/,to=qe(t=>{try{return ue(t)}catch{return}},"readJsonFileSafe"),bg=qe((t,e,r)=>{for(const n of Rn(t,{includeFiles:!1,includeSymlinks:!1,skip:[nl,ol]}))if(n.path!==t&&T(w(n.path,"package.json"))){const o=n.path.slice(t.length+1);r.push(`${e}/${o}`)}},"scanDirectoryRecursive"),$g=qe((t,e,r)=>{const n=e.slice(0,-2),o=$e(t,n);if(T(o))for(const i of Rn(o,{includeFiles:!1,includeSymlinks:!1,maxDepth:1,skip:[nl,ol]}))i.path!==o&&T(w(i.path,"package.json"))&&r.push(w(n,i.name))},"resolveSimpleGlob"),Sg=qe((t,e,r)=>{const n=e.replace(vg,"").replace(wg,""),o=$e(t,n);T(o)&&bg(o,n,r)},"resolveDoubleGlob"),xg=qe((t,e,r)=>{const n=$e(t,e);T(n)&&T(w(n,"package.json"))&&r.push(e)},"resolveExactDirectory"),$r=qe((t,e)=>{const r=[];for(const n of e){const o=n.replace(yg,"");o.startsWith("!")||(o.endsWith("/*")?$g(t,o,r):o.endsWith("/**")||o.endsWith("/*/*")?Sg(t,o,r):xg(t,o,r))}return r},"resolveWorkspacePatterns"),il=qe((t,e,r=new Set)=>{if(!t)return[];const n=[];for(const o of t){if(typeof o=="object"&&o&&"group"in o){const i=o.group;if(r.has(i))throw new Error(`Cycle detected in vis.config taskGroups: ${[...r,i].join(" → ")}`);const s=e?.[i];if(!s)throw new Error(`Unknown taskGroup "${i}" referenced in dependsOn. Declare it under \`taskGroups\` in vis.config.ts.`);n.push(...il(s,e,new Set([...r,i])));continue}n.push(o)}return n},"expandTaskGroups"),sl=qe(t=>{if(Array.isArray(t)){if(t.length===0)throw new Error('Invalid package.json `workspaces`: empty array. Add at least one pattern like "packages/*" or remove the field.');for(const e of t)if(typeof e!="string"||e.trim().length===0)throw new TypeError(`Invalid package.json \`workspaces\` entry: expected a non-empty glob string, got ${JSON.stringify(e)}.`);return t}if(t&&typeof t=="object"){const{packages:e}=t;if(e===void 0)throw new Error('Invalid package.json `workspaces`: object form requires a `packages` array (e.g. `{ "packages": ["packages/*"] }`).');if(!Array.isArray(e))throw new TypeError(`Invalid package.json \`workspaces.packages\`: expected an array of glob strings, got ${typeof e}.`);return sl(e)}throw new TypeError(`Invalid package.json \`workspaces\`: expected an array or { packages: string[] } object, got ${typeof t}.`)},"validateWorkspacesField"),Io=qe(t=>{const e=w(t,"pnpm-workspace.yaml");if(!T(e))return;const r=ee(e),n=[];let o=!1;for(const i of r.split(`
|
|
22
|
+
`)){const s=i.trim();if(s==="packages:"){o=!0;continue}if(o){if(s.startsWith("- ")){const a=s.slice(2).replaceAll(kg,"");n.push(a)}else if(s&&!s.startsWith("#"))break}}return n.length>0?n:void 0},"readPnpmWorkspacePatterns"),ea="@filegroup:",Cg=qe((t,e,r)=>{if(!t)return!0;if(t.projectType&&t.projectType!==r)return!1;if(t.tags&&t.tags.length>0){const n=new Set(e?.tags);if(!t.tags.some(o=>n.has(o)))return!1}if(t.layer){const n=Array.isArray(t.layer)?t.layer:[t.layer];if(e?.layer===void 0||!n.includes(e.layer))return!1}if(t.stack){const n=Array.isArray(t.stack)?t.stack:[t.stack];if(e?.stack===void 0||!n.includes(e.stack))return!1}if(t.language){const n=Array.isArray(t.language)?t.language:[t.language];if(e?.language===void 0||!n.includes(e.language))return!1}return!0},"scopeMatches"),jg=qe((t,e,r)=>{const n={};for(const[o,i]of Object.entries(t.targetDefaults??{}))n[o]={...i};for(const o of t.taskDefaults??[])if(Cg(o.scope,e,r))for(const[i,s]of Object.entries(o.targets))n[i]={...n[i],...s};return n},"collectTargetDefaults"),Tg=qe((t,e)=>{if(!t)return t;const r=[];for(const n of t){if(typeof n=="string"&&n.startsWith(ea)){const o=n.slice(ea.length),i=e?.[o];i&&r.push(...i);continue}r.push(n)}return r},"resolveFileGroupInputs"),ta=qe((t,e,r,n,o)=>{const i={...n,...r,options:{...n?.options,...r?.options}};e&&i.command===void 0&&i.executor===void 0&&(i.command=e),i.inputs&&(i.inputs=Tg(i.inputs,o));const s=zp(i);return s.cache===void 0&&(s.cache=Qp(s.type)),s},"mergeTarget"),Eg=qe((t,e,r,n)=>{const o={},i=new Set;for(const[s,a]of Object.entries(t??{}))i.add(s),o[s]=ta(s,a,e?.[s],r[s],n);for(const[s,a]of Object.entries(e??{}))i.has(s)||(o[s]=ta(s,void 0,a,r[s],n));return o},"createTargetsFromScripts"),ut=qe((t,e={})=>{const r={},n=new Map,o=new Map,i=Io(t),s=to(w(t,"package.json"));let a;if(i?a=i:s?.workspaces!==void 0&&(a=sl(s.workspaces)),!a)throw new Error("No workspace configuration found. Expected pnpm-workspace.yaml or package.json workspaces field.");const c=$r(t,a);for(const d of c){const p=w(t,d,"package.json"),g=to(p);if(!g?.name)continue;o.set(g.name,g);const m=w(t,d,"project.json"),y=to(m);let v="library";y?.projectType?v=y.projectType:g.bin!==void 0&&(v="application");const k=jg(e,y,v),$=Eg(g.scripts,y?.targets,k,e.fileGroups);n.set(g.name,$);const x={};for(const[E,A]of Object.entries($)){const{options:L,preset:I,type:M,...F}=A,_=A.dependsOn?il(A.dependsOn,e.taskGroups):void 0;x[E]={...F,..._?{dependsOn:_}:{},...L?{options:L}:{}}}r[g.name]={implicitDependencies:y?.implicitDependencies,language:y?.language,layer:y?.layer,owners:y?.owners,project:y?.project,projectType:v,root:d,sourceRoot:y?.sourceRoot??`${d}/src`,stack:y?.stack,tags:y?.tags,targets:x}}return{config:e,packageJsons:o,projectOptions:n,workspace:{projects:r}}},"discoverWorkspace"),qt=qe((t,e,r)=>{const n={},o={},i=new Set(Object.keys(e.projects));for(const[s,a]of Object.entries(e.projects)){n[s]={data:a,name:s,type:a.projectType??"library"},o[s]=[];const c=r?.get(s)??to(w(t,a.root,"package.json"));if(!c)continue;const d=[[c.dependencies,"static"],[c.devDependencies,"devDependency"],[c.peerDependencies,"peerDependency"]],p=new Set;for(const[g,m]of d)if(g)for(const y of Object.keys(g))i.has(y)&&!p.has(y)&&(p.add(y),o[s]?.push({source:s,target:y,type:m}))}return{dependencies:o,nodes:n}},"buildProjectGraph");var Rg=Object.defineProperty,co=b((t,e)=>Rg(t,"name",{value:e,configurable:!0}),"u$o");const Ig=co((t,e,r)=>{const n=[],o=new Set,i=co((s,a)=>{if(o.has(s))return;o.add(s);const c=e[s]??[];for(const g of c)i(g,a+1);const d=r[s],p=" ".repeat(a);n.push(`${p}${s}${d?.cache===!1?" (no-cache)":""}`)},"walk");for(const s of t)i(s,0);return n},"renderPlan"),Ag=co((t,e,r)=>({roots:t,tasks:Object.fromEntries(Object.entries(r).map(([n,o])=>[n,{cache:o.cache,dependsOn:e[n]??[],outputs:o.outputs,parallelism:o.parallelism,projectRoot:o.projectRoot,target:o.target}]))}),"toJson"),Og={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"]],execute:co(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{const i=t[0];if(!i)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!o)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:s,packageJsons:a,workspace:c}=ut(o,n),d=qt(o,c,a),p=await Yc(i,c,process.cwd(),o),{target:g}=p;let m=p.projects;r.query&&(m=xo(m,c,r.query));const y=m.filter(x=>c.projects[x]?.targets?.[g]!==void 0);if(y.length===0){e.info(`No projects have a "${g}" target.`);return}const v=y.map(x=>{const E=c.projects[x],A=E.targets?.[g],L={project:x,target:g};return{cache:A?.cache,id:`${x}:${g}`,outputs:A?.outputs??[],overrides:{command:A?.command},parallelism:A?.parallelism,projectRoot:E.root,target:L}}),k=Di(v,{projectGraph:d,targetDefaults:s.targetDefaults,workspace:c});if(r.json){e.info(JSON.stringify(Ag(k.roots,k.dependencies,k.tasks),null,2));return}const $=Ig(k.roots,k.dependencies,k.tasks);e.info(`Execution plan (${Object.keys(k.tasks).length} task(s), ${k.roots.length} root(s)):`),e.info("");for(const x of $)e.info(x)},"execute"),group:"Workspace",name:"action-graph",options:[{defaultValue:!1,description:"Emit JSON instead of ASCII",name:"json",type:Boolean},{description:"Filter matched projects by a query",name:"query",type:String}]};var Pg=Object.defineProperty,Ng=b((t,e)=>Pg(t,"name",{value:e,configurable:!0}),"t$i");const ra=Ng(t=>t in Yo&&Yo[t]!=="0"&&Yo[t]!=="false","check"),lt=ra("CI")||ra("CONTINUOUS_INTEGRATION");var Mg=Object.defineProperty,it=b((t,e)=>Mg(t,"name",{value:e,configurable:!0}),"r$m");const Dg=it(()=>process.env.NO_COLOR!==void 0?!1:process.env.FORCE_COLOR!==void 0?!0:!!process.stderr.isTTY,"supportsColor"),Bg=Dg(),or=it((t,e)=>r=>Bg?`\x1B[${t}m${r}\x1B[${e}m`:r,"ansi"),ye=or("1","22"),re=or("2","22"),al=or("31","39"),cl=or("32","39"),ll=or("33","39"),Fg=or("34","39"),Be=or("36","39"),Lg=or("90","39"),Vg=it(()=>process.platform==="win32"?!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color":process.env.TERM!=="linux","isUnicodeSupported"),Qo=Vg(),Hi={arrow:Qo?"→":"->",failure:Qo?"✗":"x",success:Qo?"✓":"v"},S=it(t=>{process.stderr.write(`${ye(Fg("info:"))} ${t}
|
|
23
|
+
`)},"info"),se=it(t=>{process.stderr.write(`${ye(ll("warn:"))} ${t}
|
|
24
|
+
`)},"warn"),er=it(t=>{process.stderr.write(`${ye(al("error:"))} ${t}
|
|
25
|
+
`)},"error"),ie=it(t=>{process.stderr.write(`${ye(Lg("note:"))} ${t}
|
|
26
|
+
`)},"note"),Z=it(t=>{process.stderr.write(`${cl(Hi.success)} ${t}
|
|
27
|
+
`)},"success"),ze=it(t=>{process.stderr.write(`${al(Hi.failure)} ${t}
|
|
28
|
+
`)},"failure");it((t,e)=>!process.stderr.isTTY||process.env.TERM==="dumb"?t===e?e:`${t} (${re(e)})`:ip(t,e),"link");const Ug=it(()=>{if(process.env.VIS_VERSION)return process.env.VIS_VERSION;try{const t=new URL("../../package.json",import.meta.url);return ue(t).version}catch{return"0.0.0"}},"getVersion"),_g=it(()=>{process.env.VIS_VERSION=Ug()},"injectVersion"),Gg=it(t=>{!process.stdout.isTTY||lt||process.env.TERM==="dumb"||process.stdout.write(`\x1B]0;${t}\x07`)},"setTerminalTitle");var Wg=Object.defineProperty,dl=b((t,e)=>Wg(t,"name",{value:e,configurable:!0}),"n$c");const zg=1;let Hn,na=!1;const Hg=up(import.meta.url),Ao=dl(()=>{if(na)return Hn;na=!0;try{const t=Hg("../index.js");typeof t.detectPackageManager=="function"&&typeof t.execPmCommand=="function"&&typeof t.resolveLink=="function"&&t.NATIVE_BINDING_VERSION===zg&&(Hn=t)}catch{Hn=void 0}return Hn},"loadNativeBindings");dl(()=>Ao()!==void 0,"isNativeAvailable");var qg=Object.defineProperty,De=b((t,e)=>qg(t,"name",{value:e,configurable:!0}),"t$f");const qi=De(()=>{const t=Ao();if(!t)throw new Error("Native bindings for package manager operations failed to load. Ensure the correct platform binary is installed.");return t},"requireNative"),qn=De((t,e)=>{try{const r=w(t,"package.json");if(T(r)){const n=ue(r);if(n.packageManager?.startsWith(`${e}@`))return n.packageManager.slice(e.length+1)}}catch{}},"readPackageManagerVersion"),Jg=De(t=>{let e;try{e=new Set(Ge(t))}catch{return}if(e.has("pnpm-lock.yaml")||e.has("pnpm-workspace.yaml"))return{name:"pnpm",version:qn(t,"pnpm")??"latest"};if(e.has("yarn.lock"))return{name:"yarn",version:qn(t,"yarn")??"latest"};if(e.has("bun.lock")||e.has("bun.lockb"))return{name:"bun",version:qn(t,"bun")??"latest"};if(e.has("package-lock.json")||e.has("npm-shrinkwrap.json"))return{name:"npm",version:qn(t,"npm")??"latest"};if(e.has("package.json"))try{const r=ue(w(t,"package.json"));if(r.packageManager){const n=/^(pnpm|yarn|npm|bun)@(.+)$/.exec(r.packageManager);if(n)return{name:n[1],version:n[2]}}}catch{}},"detectPmInDir"),Yg=De(t=>{let e=t;for(;;){const r=Jg(e);if(r)return r;const n=Nt(e);if(n===e||_u(e).root===e)break;e=n}throw new Error(`Could not detect package manager in ${t}. No lockfile or packageManager field found.`)},"detectPmFallback"),Ne=De(t=>{if(!T(t))throw new Error(`Could not detect package manager in ${t}. Directory does not exist.`);try{const e=qi().detectPackageManager(t);return{name:e.name,version:e.version||"latest"}}catch{return Yg(t)}},"detectPm"),ul=De((t,e,r)=>{for(const n of t.warnings)r.warn(`warning: ${n}`);return qi().execPmCommandInteractive(t.bin,t.args,e)},"runResolved"),bt=De((t,e,r)=>{const n=t(qi());return ul(n,e,r)},"resolveAndRun"),Oo=De((t,e,r,n)=>bt(o=>o.resolveInstall(t.name,t.version,e),r,n),"runInstall"),Kg=De((t,e,r,n)=>bt(o=>o.resolveAdd(t.name,t.version,e),r,n),"runAdd"),Xg=De((t,e,r,n)=>bt(o=>o.resolveRemove(t.name,t.version,e),r,n),"runRemove"),Qg=De((t,e,r,n)=>bt(o=>o.resolveDedupe(t.name,t.version,e),r,n),"runDedupe"),Zg=De((t,e,r,n)=>bt(o=>o.resolveWhy(t.name,t.version,e),r,n),"runWhy");De((t,e,r,n)=>bt(o=>o.resolveOutdated(t.name,t.version,e),r,n),"runOutdated");const eh=De((t,e)=>{const r=[],n=[],o=t.name;switch(t.name){case"bun":{const i=In(t.version);i&&ep(i,"1.3.0")&&n.push(`bun ${t.version} does not support \`bun pm view\` (added in bun 1.3). Upgrade bun, or run \`npm view ${e.package}\` instead.`),r.push("pm","view","--",e.package,...e.fields),e.json&&r.push("--json");break}case"npm":case"pnpm":{r.push("view","--",e.package,...e.fields),e.json&&r.push("--json");break}case"yarn":{if(t.version.startsWith("1.")){r.push("info","--",e.package);const[i,...s]=e.fields;i!==void 0&&(s.length>0&&n.push("yarn v1 only supports querying one field at a time; using the first."),r.push(i)),e.json&&r.push("--json")}else r.push("npm","info","--",e.package),e.fields.length>0&&n.push("yarn berry does not support field arguments to 'npm info'; ignoring."),e.json&&r.push("--json");break}default:{const i=t.name;throw new Error(`Unsupported package manager: ${i}`)}}return{args:r,bin:o,warnings:n}},"resolveInfo"),th=De((t,e,r,n)=>ul(eh(t,e),r,n),"runInfo"),rh=De((t,e,r,n)=>bt(o=>o.resolveLink(t.name,t.version,e),r,n),"runLink"),nh=De((t,e,r,n,o)=>bt(i=>i.resolveUnlink(t.name,t.version,e,r),n,o),"runUnlink"),Ji=De((t,e,r,n)=>bt(o=>o.resolveDlx(t.name,t.version,e),r,n),"runDlx"),oh=De((t,e,r,n)=>bt(o=>o.resolveExec(t.name,t.version,e),r,n),"runExec"),ih=De((t,e,r,n,o)=>bt(i=>i.resolvePmCommand(t.name,t.version,e,r),n,o),"runPmSubcommand");var sh=Object.defineProperty,Le=b((t,e)=>sh(t,"name",{value:e,configurable:!0}),"a$l");const ah="https://api.socket.dev/v0/purl?alerts=true",Po=Le(()=>w(Xe(),".vis","cache","socket-security"),"getCacheDirectory"),ch=3600*1e3,Qt=.4,oa=100,lh=Le(t=>typeof t=="object"&&t!=null&&"id"in t&&"type"in t&&"name"in t&&"version"in t&&"alerts"in t&&"score"in t&&t.type==="npm","isPackageReportData"),dh=Le(()=>{je(Po())},"ensureCacheDirectory"),pl=Le((t,e)=>`${encodeURIComponent(t)}@${encodeURIComponent(e)}`,"buildCacheKey"),uh=Le((t,e)=>{const r=pl(t,e),n=w(Po(),`${r}.json`);try{const o=ue(n);if(Date.now()-o.createdAt>o.ttlMs){ot(n,{force:!0});return}return o.report}catch{return}},"getCachedReport"),ph=Le((t,e,r,n)=>{const o=pl(t,e),i={createdAt:Date.now(),report:r,ttlMs:n};Se(w(Po(),`${o}.json`),JSON.stringify(i),"utf8")},"setCachedReport"),fh=Le(t=>{const e=[t.license,t.maintenance,t.quality,t.supplyChain,t.vulnerability];return Number((e.reduce((r,n)=>r+n,0)/e.length).toFixed(2))},"calculateOverallScore"),Xr=Le(async(t,e={})=>{const{apiToken:r,cacheTtlMs:n=ch,timeoutMs:o=15e3}=e,i=new Map;if(t.length===0||!r)return i;const s=[];for(const d of t){const p=uh(d.name,d.version);p?i.set(`${d.name}@${d.version}`,p):s.push(d)}if(s.length===0)return i;const a=`Basic ${Buffer.from(`${r}:`).toString("base64")}`;dh();const c=[];for(let d=0;d<s.length;d+=oa)c.push(s.slice(d,d+oa));for(const d of c){const p=d.map(y=>({purl:`pkg:npm/${y.name}@${y.version}`})),g=new AbortController,m=setTimeout(()=>{g.abort()},o);try{const y=await fetch(ah,{body:JSON.stringify({components:p}),headers:{Authorization:a,"Content-Type":"application/json","User-Agent":"@visulima/vis"},method:"POST",signal:g.signal});if(!y.ok)continue;const v=await y.text();gh(v,d,i,n)}catch{}finally{clearTimeout(m)}}return i},"fetchSocketReports"),gh=Le((t,e,r,n)=>{const o=new Map;for(const s of e)o.set(`${s.name}@${s.version}`,s);const i=t.split(`}
|
|
29
|
+
`);for(const s of i){const a=s.trim();if(a)try{const c=JSON.parse(a.endsWith("}")?a:`${a}}`),d=`${c.namespace?`${c.namespace}/`:""}${c.name}`,p=`${d}@${c.version}`;if(!o.has(p))continue;const g=c.score.overall??fh(c.score),m={alerts:c.alerts,author:c.author,id:c.id,license:c.license,name:c.name,score:{...c.score,overall:g},size:c.size,type:"npm",version:c.version};c.namespace&&(m.namespace=c.namespace),lh(m)&&(r.set(p,m),ph(d,c.version,m,n))}catch{}}},"parseNdjsonResponse"),Vr=Le(t=>t.namespace?`${t.namespace}/${t.name}`:t.name,"getFullPackageName"),Yi=Le(t=>t>=.8?"excellent":t>=.6?"good":t>=.4?"fair":t>=.2?"poor":"critical","scoreLabel"),Mn=Le(t=>t>=.6?"green":t>=.4?"yellow":"red","scoreColor"),ia=Le(t=>{const e=Vr(t),r=`score: ${String(Math.round(t.score.overall*100))}%`,n=t.alerts.length,o=n>0?`${String(n)} alert${n===1?"":"s"}`:"no alerts";return`${e}@${t.version} (${r}, ${o})`},"formatReportSummary");Le(t=>{const e=[`${Vr(t)}@${t.version}`,` License: ${t.license||"unknown"}`];if(e.push(` Overall Score: ${String(Math.round(t.score.overall*100))}% (${Yi(t.score.overall)})`),e.push(` Supply Chain: ${String(Math.round(t.score.supplyChain*100))}%`),e.push(` Quality: ${String(Math.round(t.score.quality*100))}%`),e.push(` Maintenance: ${String(Math.round(t.score.maintenance*100))}%`),e.push(` Vulnerability: ${String(Math.round(t.score.vulnerability*100))}%`),e.push(` License: ${String(Math.round(t.score.license*100))}%`),t.alerts.length>0){e.push(` Alerts (${String(t.alerts.length)}):`);for(const r of t.alerts){const n=r.props?.cveId?` (${r.props.cveId})`:"";e.push(` [${r.severity.toUpperCase()}] ${r.type}${n} — ${r.category}`)}}return e.join(`
|
|
30
|
+
`)},"formatReportDetailed");const hh=Le(t=>{if(t.size===0)return"";let e=0,r=0,n=0,o=0,i=0,s=0;for(const c of t.values()){for(const d of c.alerts)switch(e++,d.severity){case"critical":{r++;break}case"high":{n++;break}case"medium":{o++;break}default:i++}c.score.overall<Qt&&s++}const a=[];if(a.push(`Socket.dev: scanned ${String(t.size)} package${t.size===1?"":"s"}`),e>0){const c=[];r>0&&c.push(`${String(r)} critical`),n>0&&c.push(`${String(n)} high`),o>0&&c.push(`${String(o)} medium`),i>0&&c.push(`${String(i)} low`),a.push(` Alerts: ${String(e)} total (${c.join(", ")})`)}else a.push(" No security alerts found.");return s>0&&a.push(` ${String(s)} package${s===1?"":"s"} with low security score (<40%)`),a.join(`
|
|
31
|
+
`)},"formatSecurityOverview"),mh=Le(()=>{const t=Po();if(!T(t))return 0;const e=Ge(t).filter(r=>r.endsWith(".json"));for(const r of e)ot(w(t,r),{force:!0});return e.length},"clearSocketCache"),Er=Le(t=>t?.enabled?{apiToken:t.apiToken??process.env.VIS_SOCKET_TOKEN,cacheTtlMs:t.cacheTtlMs,minimumScore:t.minimumScore,timeoutMs:t.timeoutMs}:void 0,"buildSocketOptions"),Ki=Le((t,e,r)=>{if(!r)return;const n=`${t}@${e}`;if(r[n])return r[n];if(r[t])return r[t];for(const[o,i]of Object.entries(r))if(o.endsWith("*")&&t.startsWith(o.slice(0,-1)))return i},"findAcceptedRisk"),yh=Le((t,e,r,n)=>[" // Add to security.socket.acceptedRisks in vis.config.ts:",` ${`"${t}"`}: {`,` reason: "${n}",`,` acceptedAt: "${new Date().toISOString()}",`,` acceptedScore: ${String(r)},`," },"].join(`
|
|
32
|
+
`),"formatAcceptedRiskSnippet");var vh=Object.defineProperty,pt=b((t,e)=>vh(t,"name",{value:e,configurable:!0}),"o$l");const wh={a:["4","e"],b:["d"],d:["b"],e:["3","a"],g:["9","q"],i:["1","l"],l:["1","i"],m:["n"],n:["m"],o:["0"],s:["5","z"],t:["7"],u:["v"],v:["u"]},kh=pt(t=>{const e=new Set;if(t.length<3)return e;for(let n=0;n<t.length;n++){const o=t[n]==="-"||t[n]==="."||t[n]==="_";if(o||e.add(t.slice(0,n)+t.slice(n+1)),o||e.add(t.slice(0,n)+t[n]+t.slice(n)),n<t.length-1&&t[n]!==t[n+1]){const a=t[n+1]==="-"||t[n+1]==="."||t[n+1]==="_";if(!o&&!a){const c=t.split("");[c[n],c[n+1]]=[c[n+1],c[n]],e.add(c.join(""))}}const i=t[n].toLowerCase(),s=wh[i];if(s)for(const a of s)e.add(t.slice(0,n)+a+t.slice(n+1))}const r=/[-._]/g;if(r.test(t))e.add(t.replaceAll(r,"")),e.add(t.replaceAll(r,"-")),e.add(t.replaceAll(r,".")),e.add(t.replaceAll(r,"_"));else if(t.length>5)for(let n=2;n<t.length-2;n++)e.add(`${t.slice(0,n)}-${t.slice(n)}`),e.add(`${t.slice(0,n)}.${t.slice(n)}`),e.add(`${t.slice(0,n)}_${t.slice(n)}`);return t.startsWith("@")||(e.add(`${t}-js`),e.add(`${t}js`),e.add(`${t}-node`)),e.delete(t),e},"generateVariants");let Zo,Jn;const fl=pt(()=>{if(!Zo){const t=$e(Nt(pp(import.meta.url)),"../data/typosquats.json");Zo=ue(t)}return Zo},"loadBlocklist"),bh=pt(()=>{if(!Jn){Jn=new Map;for(const[t,e]of Object.entries(fl()))for(const r of e)Jn.set(r,t)}return Jn},"getReverseLookup"),$h=pt(t=>t.startsWith("@")?t.split("/")[1]??t:t,"bareName"),Sh=pt(t=>{const e=$h(t),r=bh().get(e);if(r)return{input:t,legitimate:r,method:"blocklist"};for(const n of Object.keys(fl()))if(kh(n).has(e))return{input:t,legitimate:n,method:"heuristic"}},"checkTyposquat"),gl=pt((t,e)=>{const r=e?new Set(e):void 0,n=[];for(const o of t){if(r?.has(o))continue;const i=Sh(o);i&&n.push(i)}return n},"checkTyposquats"),hl=pt((t,e)=>{se(""),se(Ue(`Possible typosquat${t.length===1?"":"s"} ${e}:`));for(const r of t){const n=r.method==="blocklist"?"known typosquat":"similar name";se(` ${Re("⚠")} ${Ue(r.input)} — did you mean ${Re(r.legitimate)}? (${n})`)}se("")},"printTyposquatWarnings"),ml=pt(async t=>{if(!process.stdin.isTTY){se("Aborting: potential typosquat detected in non-interactive mode. Use --no-typosquat-check to skip.");return}const e=dt({input:process.stdin,output:process.stdout}),r=await new Promise(n=>{e.question(t,o=>{n(o.trim().toLowerCase())})});return e.close(),r},"askConfirmation"),yl=pt(async(t,e)=>{const r=gl(t,e);if(r.length===0)return{ok:!0,packages:t};hl(r,"detected");const n=await ml(`Use suggested package${r.length===1?"":"s"} instead? [S]uggested / [y]es, keep original / [N]o, abort (default: N) `);if(n===void 0)return{ok:!1,packages:t};if(n==="s"||n==="suggested"){const o=new Map(r.map(i=>[i.input,i.legitimate]));return{ok:!0,packages:t.map(i=>o.get(i)??i)}}return n==="y"||n==="yes"?{ok:!0,packages:t}:{ok:!1,packages:t}},"runTyposquatCheck"),xh=/^(?:npm|pnpm|yarn):(.+?)(?:@.*)?$/,Ch=pt(t=>xh.exec(t)?.[1],"parseAliasTarget"),jh=pt(t=>{if(!T(t))return[];const e=ue(t),r={...e.dependencies,...e.devDependencies,...e.optionalDependencies,...e.peerDependencies},n=new Set;for(const[o,i]of Object.entries(r)){n.add(o);const s=Ch(i);s&&n.add(s)}return[...n]},"readDepsFromPackageJson"),vl=pt(async(t,e)=>{const r=w(t,"package.json"),n=jh(r);if(n.length===0)return!0;const o=gl(n,e);if(o.length===0)return!0;hl(o,"in package.json dependencies"),se("Fix the package name in package.json before proceeding.");const i=await ml("Continue anyway? [y/N] ");return i==="y"||i==="yes"},"scanDepsForTyposquats");var Th=Object.defineProperty,Xi=b((t,e)=>Th(t,"name",{value:e,configurable:!0}),"s$o");const Dn=Xi(t=>t?Array.isArray(t)?t:[t]:[],"toStringArray"),mi=Xi(t=>t instanceof Error?t.message:typeof t=="string"?t:String(t),"errorMessage"),Eh=/^(.+?)(?:@(.+))?$/,Qi=Xi(t=>{if(t.startsWith("@")){const r=t.indexOf("/");if(r===-1)return{name:t,versionSpec:void 0};const n=t.slice(r+1),o=n.indexOf("@");return o===-1?{name:t,versionSpec:void 0}:{name:t.slice(0,r+1+o),versionSpec:n.slice(o+1)}}const e=Eh.exec(t);return e?{name:e[1]??t,versionSpec:e[2]}:{name:t,versionSpec:void 0}},"parsePackageArgument");var Rh=Object.defineProperty,Ur=b((t,e)=>Rh(t,"name",{value:e,configurable:!0}),"m$q");const Ih=Ur(async(t,e=1e4)=>{const r=new Map,n=new AbortController,o=setTimeout(()=>{n.abort()},e);try{const i=t.map(async s=>{try{const a=await fetch(`https://registry.npmjs.org/${s}/latest`,{headers:{Accept:"application/json"},signal:n.signal});if(a.ok){const c=await a.json();c.version&&r.set(s,c.version)}}catch{}});await Promise.all(i)}finally{clearTimeout(o)}return r},"resolveLatestVersions"),Ah=Ur((t,e,r)=>{const n=[];for(const o of t.values()){const{overall:i}=o.score,s=Mn(i),a=`${String(Math.round(i*100))}%`,c=o.alerts.length,d=Vr(o),p=Ki(d,o.version,r),g=s==="red"?Ue:s==="yellow"?Re:Et;if(S(p?` ${g(a)} ${ia(o)} ${be(`[accepted: ${p.reason}]`)}`:` ${g(a)} ${ia(o)}`),c>0){const m=o.alerts.filter(y=>y.severity==="critical"||y.severity==="high").length;m>0&&se(` ${String(m)} critical/high alert${m===1?"":"s"}`)}i<e&&!p&&n.push(o)}return n},"displaySecurityReports"),Oh=Ur(async(t,e)=>{const r=dt({input:process.stdin,output:process.stdout}),n=Ur(a=>new Promise(c=>{r.question(a,d=>{c(d.trim())})}),"ask"),o=String(Math.round(e*100));se(""),se(`${String(t.length)} package${t.length===1?"":"s"} scored below the minimum threshold (${o}%):`);for(const a of t){const c=Vr(a),d=`${String(Math.round(a.score.overall*100))}%`;se(` • ${c}@${a.version} — score: ${d} (${Yi(a.score.overall)})`)}se("");const i=await n("Continue adding these packages? [y/N] ");if(i.toLowerCase()!=="y"&&i.toLowerCase()!=="yes")return r.close(),!1;const s=await n("Remember this decision? (prints config snippet) [y/N] ");if(r.close(),s.toLowerCase()==="y"||s.toLowerCase()==="yes"){ie(""),ie("Add the following to security.socket.acceptedRisks in vis.config.ts:"),ie("");for(const a of t){const c=Vr(a),d=yh(c,a.version,a.score.overall,"Reviewed and accepted");ie(d)}ie("")}return!0},"confirmLowScorePackages"),Ph=Ur(async(t,e,r,n)=>{const o=t.map(Qi),i=new Map;for(const g of o)if(g.versionSpec){const m=In(g.versionSpec);m&&i.set(g.name,m.version)}const s=o.filter(g=>!i.has(g.name)).map(g=>g.name),a=s.length>0?await Ih(s):new Map,c=[];for(const g of o){const m=i.get(g.name)??a.get(g.name);m&&c.push({name:g.name,version:m})}if(c.length===0)return!0;S(""),S("Socket.dev security check:");const d=await Xr(c,e);if(d.size===0)return S(" Could not fetch security data. Proceeding."),!0;const p=Ah(d,r,n);return p.length===0?(S(""),!0):process.stdin.isTTY?Oh(p,r):(se(`Aborting: ${String(p.length)} package${p.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},"runSocketPreCheck"),Nh={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 -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"]],execute:Ur(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{let i=t;if(!i||i.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(!r.noTyposquatCheck){const d=i.map(g=>Qi(g)),p=await yl(d.map(g=>g.name),n?.security?.typosquatAllowlist);if(!p.ok){process.exitCode=1;return}i=d.map((g,m)=>{const y=p.packages[m];return y!==g.name?g.versionSpec?`${y}@${g.versionSpec}`:y??"":i[m]??""})}if(!r.noSocketCheck){const d=Er(n?.security?.socket);if(d){const p=d.minimumScore??Qt;if(!await Ph(i,d,p,n?.security?.socket?.acceptedRisks)){process.exitCode=1;return}}}const s=process.cwd(),a=Ne(o??s),c=Kg(a,{exact:r.exact||!1,filter:Dn(r.filter),global:r.global||!1,optional:r.saveOptional||!1,packages:i,peer:r.savePeer||!1,saveDev:r.saveDev||!1,workspace:r.workspace||!1,workspaceRoot:r.workspaceRoot||!1},s,e);c!==0&&(process.exitCode=c)},"execute"),group:"Dependencies",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},{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}]};var Mh=Object.defineProperty,Dh=b((t,e)=>Mh(t,"name",{value:e,configurable:!0}),"l$q");const Bh={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"]],execute:Dh(async({argument:t,logger:e,options:r,runtime:n,visConfig:o,workspaceRoot:i})=>{const s=t[0];if(!s)throw new Error("Missing target. Usage: vis affected <target>");if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const a=i,{packageJsons:c,workspace:d}=ut(a,o),p=qt(a,d,c),g=new Set(["deep","direct","none"]),m=r.downstream??"deep",y=r.upstream??"none";if(!g.has(m))throw new Error(`Invalid --downstream value: "${m}". Must be "none", "direct", or "deep".`);if(!g.has(y))throw new Error(`Invalid --upstream value: "${y}". Must be "none", "direct", or "deep".`);const v={base:r.base,downstream:m,head:r.head,projectGraph:p,projects:d.projects,upstream:y,workspaceRoot:a},k=await jc(v);if(k.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}if(k.affectedProjects.length===0){e.info("No projects affected by the changes.");return}let{affectedProjects:$}=k;if(r.query&&($=xo($,d,r.query),$.length===0)){e.info(`Query "${String(r.query)}" matched no affected projects.`);return}e.info(`Affected projects: ${$.join(", ")}`),k.changedFiles.length>0&&(process.env.VIS_AFFECTED_FILES=k.changedFiles.join(`
|
|
33
|
+
`));const x=[s,`--projects=${$.join(",")}`];r.parallel!==void 0&&x.push(`--parallel=${String(r.parallel)}`),r.cache||x.push("--no-cache"),r.dryRun&&x.push("--dry-run"),r.partition&&x.push(`--partition=${String(r.partition)}`);try{await n.runCommand("run",{argv:x})}finally{delete process.env.VIS_AFFECTED_FILES}},"execute"),group:"Run & Execute",name:"affected",options:[{defaultValue:"HEAD~1",description:"Git base ref for comparison",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" — 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},{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},{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}]};var Fh=Object.defineProperty,we=b((t,e)=>Fh(t,"name",{value:e,configurable:!0}),"f$p");const Fr=(1n<<128n)-1n,ae=(1n<<64n)-1n,lo=(1n<<32n)-1n,wl=0x9E3779B1n,kl=0x85EBCA77n,Lh=0xC2B2AE3Dn,tr=0x9E3779B185EBCA87n,Sr=0xC2B2AE3D27D4EB4Fn,bl=0x165667B19E3779F9n,Zi=0x85EBCA77C2B2AE63n,Vh=0x27D4EB2F165667C5n,Uh=0x165667919E3779F9n,_h=0x9FB21C651E98DF25n,Vt=64,$l=Vt/8,Gh=8,jt=Buffer.from("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e","hex"),Ce=we((t,e=0)=>Buffer.from(t.buffer,t.byteOffset+e,t.length-e),"getView"),Wh=we(t=>{const e=Buffer.allocUnsafe(8);return e.writeBigUInt64LE(t),e.readBigUInt64BE()},"bswap64"),zh=we(t=>{let e=t;return e=(e&0x0000FFFFn)<<16n|(e&0xFFFF0000n)>>16n,e=(e&0x00FF00FFn)<<8n|(e&0xFF00FF00n)>>8n,e},"bswap32"),Hh=we((t,e)=>(t&lo)*(e&lo)&ae,"multU32ToU64"),qh=we((t,e)=>(t<<e|t>>32n-e)&lo,"rotl32"),yi=we((t,e)=>t^t>>e,"xorshift64"),vi=we(t=>~t+1n&ae,"inv64"),Sl=we((t,e)=>{const r=t*e&Fr;return r&ae^r>>64n},"mul128Fold64"),Tt=we(t=>{let e=t;return e^=e>>37n,e=e*Uh&ae,e^=e>>32n,e},"avalanche"),uo=we(t=>{let e=t;return e^=e>>33n,e=e*Sr&ae,e^=e>>29n,e=e*bl&ae,e^=e>>32n,e},"avalanche64"),xl=we((t,e,r)=>{for(let n=0;n<$l;n++){const o=e.readBigUInt64LE(n*8),i=o^r.readBigUInt64LE(n*8);t[n^1]+=o,t[n]+=Hh(i,i>>32n)}return t},"accumulate512"),sa=we((t,e,r,n)=>{for(let o=0;o<n;o++)xl(t,Ce(e,o*Vt),Ce(r,o*8));return t},"accumulate"),Jh=we((t,e)=>{for(let r=0;r<$l;r++){const n=e.readBigUInt64LE(r*8);let o=t[r];o=yi(o,47n),o^=n,o*=wl,t[r]=o&ae}return t},"scrambleAcc"),Yn=we((t,e)=>Sl(t[0]^e.readBigUInt64LE(0),t[1]^e.readBigUInt64LE(Gh)),"mix2Accs"),aa=we((t,e,r)=>{let n=r;return n+=Yn(t.slice(0),Ce(e,0)),n+=Yn(t.slice(2),Ce(e,16)),n+=Yn(t.slice(4),Ce(e,32)),n+=Yn(t.slice(6),Ce(e,48)),Tt(n&ae)},"mergeAccs"),Yh=we((t,e,r)=>{const n=Math.floor((r.byteLength-Vt)/8),o=Vt*n,i=Math.floor((e.byteLength-1)/o);for(let a=0;a<i;a++)sa(t,Ce(e,a*o),r,n),Jh(t,Ce(r,r.byteLength-Vt));const s=Math.floor((e.byteLength-1-o*i)/Vt);return sa(t,Ce(e,i*o),r,s),xl(t,Ce(e,e.byteLength-Vt),Ce(r,r.byteLength-Vt-7)),t},"hashLong"),Kh=we((t,e)=>{const r=new BigUint64Array([Lh,tr,Sr,bl,Zi,kl,Vh,wl]);Yh(r,t,e);const n=aa(r,Ce(e,11),BigInt(t.byteLength)*tr&ae);return aa(r,Ce(e,e.byteLength-Vt-11),~(BigInt(t.byteLength)*Sr)&ae)<<64n|n},"hashLong128b"),ca=we((t,e,r)=>Sl((t.readBigUInt64LE(0)^e.readBigUInt64LE(0)+r)&ae,(t.readBigUInt64LE(8)^e.readBigUInt64LE(8)-r)&ae),"mix16B"),ro=we((t,e,r,n,o)=>{let i=t&ae,s=t>>64n&ae;return i+=ca(e,n,o),i^=r.readBigUInt64LE(0)+r.readBigUInt64LE(8),i&=ae,s+=ca(r,Ce(n,16),o),s^=e.readBigUInt64LE(0)+e.readBigUInt64LE(8),s&=ae,s<<64n|i},"mix32B"),Xh=we((t,e,r)=>{const n=t.byteLength,o=BigInt(t.readUInt8(n-1))|BigInt(n<<8)|BigInt(t.readUInt8(0)<<16)|BigInt(t.readUInt8(n>>1)<<24),i=(BigInt(e.readUInt32LE(0))^BigInt(e.readUInt32LE(4)))+r,s=(o^i)&ae,a=(BigInt(e.readUInt32LE(8))^BigInt(e.readUInt32LE(12)))-r,c=(qh(zh(o),13n)^a)&ae;return(uo(c)&ae)<<64n|uo(s)},"len1to3_128b"),Qh=we((t,e,r)=>{const n=t.byteLength,o=t.readUInt32LE(0),i=t.readUInt32LE(n-4),s=BigInt(o)|BigInt(i)<<32n,a=(e.readBigUInt64LE(16)^e.readBigUInt64LE(24))+r&ae;let c=(s^a)*(tr+(BigInt(n)<<2n))&Fr;return c+=(c&ae)<<65n,c&=Fr,c^=c>>67n,yi(yi(c&ae,35n)*_h&ae,28n)|Tt(c>>64n)<<64n},"len4to8_128b"),Zh=we((t,e,r)=>{const n=t.byteLength,o=(e.readBigUInt64LE(32)^e.readBigUInt64LE(40))+r&ae,i=(e.readBigUInt64LE(48)^e.readBigUInt64LE(56))-r&ae,s=t.readBigUInt64LE();let a=t.readBigUInt64LE(n-8),c=(s^a^o)*tr;const d=(c&ae)+(BigInt(n-1)<<54n);c=c&(Fr^ae)|d,a^=i,c+=a+(a&lo)*(kl-1n)<<64n,c&=Fr,c^=Wh(c>>64n);let p=(c&ae)*Sr;return p+=(c>>64n)*Sr<<64n,p&=Fr,Tt(p&ae)|Tt(p>>64n)<<64n},"len9to16_128b"),em=we((t,e)=>{const r=t.byteLength;return r>8?Zh(t,jt,e):r>=4?Qh(t,jt,e):r>0?Xh(t,jt,e):uo(e^jt.readBigUInt64LE(64)^jt.readBigUInt64LE(72))|uo(e^jt.readBigUInt64LE(80)^jt.readBigUInt64LE(88))<<64n},"len0to16_128b"),tm=we((t,e,r)=>{let n=BigInt(t.byteLength)*tr&ae,o=BigInt(t.byteLength-1)/32n;for(;o>=0n;){const a=Number(o);n=ro(n,Ce(t,16*a),Ce(t,t.byteLength-16*(a+1)),Ce(e,32*a),r),o--}let i=n+(n>>64n)&ae;i=Tt(i);let s=(n&ae)*tr+(n>>64n)*Zi+(BigInt(t.byteLength)-r&ae)*Sr;return s&=ae,s=vi(Tt(s)),i|s<<64n},"len17to128_128b"),rm=we((t,e,r)=>{let n=BigInt(t.byteLength)*tr&ae;for(let s=32;s<160;s+=32)n=ro(n,Ce(t,s-32),Ce(t,s-16),Ce(e,s-32),r);n=Tt(n&ae)|Tt(n>>64n)<<64n;for(let s=160;s<=t.byteLength;s+=32)n=ro(n,Ce(t,s-32),Ce(t,s-16),Ce(e,3+s-160),r);n=ro(n,Ce(t,t.byteLength-16),Ce(t,t.byteLength-32),Ce(e,103),vi(r));let o=n+(n>>64n)&ae;o=Tt(o);let i=(n&ae)*tr+(n>>64n)*Zi+(BigInt(t.byteLength)-r&ae)*Sr;return i&=ae,i=vi(Tt(i)),o|i<<64n},"len129to240_128b"),nm=we((t,e=0n)=>{const r=t.byteLength;return r<=16?em(t,e):r<=128?tm(t,jt,e):r<=240?rm(t,jt,e):Kh(t,jt)},"xxh3_128"),om=we(t=>{const e=t>>64n&ae,r=t&ae;return e.toString(16).padStart(16,"0")+r.toString(16).padStart(16,"0")},"bigintToHex"),Cl=we(t=>om(nm(t)),"xxh3Hash");class im{static{b(this,"gn")}static{we(this,"Xxh3Hasher")}#e=[];update(e){return typeof e=="string"?this.#e.push(Buffer.from(e)):this.#e.push(e),this}digest(){return Cl(Buffer.concat(this.#e))}}we(()=>new im,"createXxh3Hasher");var sm=Object.defineProperty,ir=b((t,e)=>sm(t,"name",{value:e,configurable:!0}),"s$n");const Bn=ir(()=>w(Xe(),".vis","cache","ai"),"getCacheDirectory"),am=3600*1e3,cm=1800*1e3,lm=ir(()=>{je(Bn())},"ensureCacheDirectory"),dm=ir((t,e,r)=>{const n=r.map(i=>({currentRange:i.currentRange,name:i.packageName,targetVersion:i.targetVersion})).toSorted((i,s)=>i.name.localeCompare(s.name)),o=JSON.stringify({analysisType:e,packages:n,provider:t});return Cl(Buffer.from(o))},"buildCacheKey"),um=ir(t=>{const e=w(Bn(),`${t}.json`);if(T(e))try{const r=ue(e);if(Date.now()-r.createdAt>r.ttlMs){ot(e,{force:!0});return}return r.result}catch{ot(e,{force:!0});return}},"getCachedAnalysis"),pm=ir((t,e,r)=>{lm();const n=Bn(),o={createdAt:Date.now(),result:e,ttlMs:r};Se(w(n,`${t}.json`),JSON.stringify(o,void 0,2),"utf8")},"setCachedAnalysis"),fm=ir((t,e)=>e!==void 0&&e>0?e:t==="security"?cm:am,"getTtlForAnalysisType"),gm=ir(()=>{const t=Bn();if(!T(t))return{entries:0,newestEntry:void 0,oldestEntry:void 0,totalSizeBytes:0};const e=Ge(t).filter(i=>i.endsWith(".json"));let r=0,n,o;for(const i of e){const s=w(t,i),a=br(s);r+=a.size;const{mtimeMs:c}=a;(n===void 0||c<n)&&(n=c),(o===void 0||c>o)&&(o=c)}return{entries:e.length,newestEntry:o,oldestEntry:n,totalSizeBytes:r}},"getCacheStats"),hm=ir(()=>{const t=Bn();if(!T(t))return 0;const e=Ge(t).filter(r=>r.endsWith(".json"));for(const r of e)ot(w(t,r),{force:!0});return e.length},"clearCache");var mm=Object.defineProperty,Fe=b((t,e)=>mm(t,"name",{value:e,configurable:!0}),"o$j");const no={amp:30,claude:80,codex:60,copilot:50,crush:35,cursor:40,droid:20,gemini:100,kimi:25,opencode:35,qwen:30},es=Fe(t=>{if(t?.provider){if(!fp.includes(t.provider))return;const n=gp(t.provider);return n.available?n:void 0}const e=hp();if(e.length===0)return;const r={...no,...t?.priority};return e.toSorted((n,o)=>(r[o.name]??0)-(r[n.name]??0))[0]},"resolveProvider"),ym=new Set(["defer","review","skip","update"]),vm=new Set(["critical","high","low","medium"]),wm=new Set(["high","low","medium"]),km=50,ei=30,bm=2,$m=1e3,Sm=12e4,xm=Fe(t=>t.map(e=>{const r=e.vulnerabilities&&e.vulnerabilities.length>0?` [VULNERABILITIES: ${e.vulnerabilities.map(o=>`${o.severity} ${o.id}`).join(", ")}]`:"";let n="";if(e.socketReport){const o=Math.round(e.socketReport.score.overall*100),i=[`score:${String(o)}%`];if(e.socketReport.alerts.length>0){const s=e.socketReport.alerts.reduce((c,d)=>(c[d.severity]=(c[d.severity]??0)+1,c),{}),a=Object.entries(s).map(([c,d])=>`${String(d)} ${c}`).join(", ");i.push(`alerts: ${a}`)}i.push(`supply-chain:${String(Math.round(e.socketReport.score.supplyChain*100))}%`),i.push(`quality:${String(Math.round(e.socketReport.score.quality*100))}%`),n=` [SOCKET.DEV: ${i.join(", ")}]`}return`- ${e.packageName}: ${e.currentRange} → ${e.newRange} (${e.updateType})${r}${n}`}).join(`
|
|
34
|
+
`),"buildPackageList"),Kn=`Respond ONLY with valid JSON in this exact structure:
|
|
17
35
|
{
|
|
18
36
|
"summary": "Brief overall summary",
|
|
19
37
|
"recommendations": [
|
|
@@ -27,7 +45,7 @@ const Va=Fa(import.meta.url),Nt=typeof globalThis<"u"&&typeof globalThis.process
|
|
|
27
45
|
}
|
|
28
46
|
],
|
|
29
47
|
"warnings": ["warning1"]
|
|
30
|
-
}`,
|
|
48
|
+
}`,Cm={compatibility:Fe(t=>`Analyze the compatibility of these package updates:
|
|
31
49
|
|
|
32
50
|
${t}
|
|
33
51
|
|
|
@@ -38,7 +56,7 @@ For each package:
|
|
|
38
56
|
4. Check for deprecated features being removed
|
|
39
57
|
5. Evaluate Node.js version requirements
|
|
40
58
|
|
|
41
|
-
${
|
|
59
|
+
${Kn}`,"compatibility"),impact:Fe(t=>`Analyze the impact of updating these npm packages:
|
|
42
60
|
|
|
43
61
|
${t}
|
|
44
62
|
|
|
@@ -49,7 +67,7 @@ For each package, provide:
|
|
|
49
67
|
4. Known breaking changes (if any)
|
|
50
68
|
5. Estimated migration effort (low/medium/high)
|
|
51
69
|
|
|
52
|
-
${
|
|
70
|
+
${Kn}`,"impact"),recommend:Fe(t=>`Provide smart recommendations for updating these packages:
|
|
53
71
|
|
|
54
72
|
${t}
|
|
55
73
|
|
|
@@ -61,7 +79,7 @@ Consider:
|
|
|
61
79
|
5. Suggested update order
|
|
62
80
|
6. If Socket.dev scores are provided, prioritize packages with low supply chain or quality scores
|
|
63
81
|
|
|
64
|
-
${
|
|
82
|
+
${Kn}`,"recommend"),security:Fe(t=>`Analyze the security implications of these package updates:
|
|
65
83
|
|
|
66
84
|
${t}
|
|
67
85
|
|
|
@@ -73,86 +91,98 @@ For each package:
|
|
|
73
91
|
5. Flag any packages where skipping the update poses security risk
|
|
74
92
|
6. If Socket.dev scores are provided, factor in supply chain and quality scores — low scores indicate higher risk
|
|
75
93
|
|
|
76
|
-
${
|
|
77
|
-
`),
|
|
78
|
-
`),s;const
|
|
79
|
-
`);try{let
|
|
80
|
-
`);const
|
|
81
|
-
`),
|
|
82
|
-
`);return}e.info("AI Cache Statistics:"),e.info(` Entries: ${String(r.entries)}`),e.info(` Total size: ${String(Math.round(r.totalSizeBytes/1024))} KB`),e.info(` Oldest: ${r.oldestEntry?new Date(r.oldestEntry).toISOString():"N/A"}`),e.info(` Newest: ${r.newestEntry?new Date(r.newestEntry).toISOString():"N/A"}`)},"handleCacheStats"),
|
|
83
|
-
`);return}const
|
|
84
|
-
Selected provider: ${
|
|
85
|
-
No AI provider available. Install one of the supported AI CLI tools.`)},"handleProviderStatus"),
|
|
86
|
-
`)){const o
|
|
87
|
-
`)){const o
|
|
88
|
-
`),"formatOutdatedMinimal"),
|
|
89
|
-
${
|
|
90
|
-
`)}},"formatOutdatedTable"),
|
|
91
|
-
`),
|
|
92
|
-
`))},"applyPnpmCatalogUpdates");
|
|
94
|
+
${Kn}`,"security")},jm=new Set(["compatibility","impact","recommend","security"]),ts=Fe(t=>jm.has(t)?t:"impact","validateAnalysisType"),jl=Fe((t,e="impact")=>{const r=xm(t);return Cm[e](r)},"buildAnalysisPrompt"),Tm=/```(?:json)?\s*([\s\S]*?)```/,Em=/\{[\s\S]*\}/,Rm=Fe(t=>{try{return JSON.parse(t)}catch{}const e=Tm.exec(t);if(e?.[1])try{return JSON.parse(e[1])}catch{}const r=Em.exec(t);if(r?.[0])try{return JSON.parse(r[0])}catch{}},"extractJson"),Im=Fe(t=>({action:ym.has(t.action)?t.action:"review",breakingChanges:Array.isArray(t.breakingChanges)?t.breakingChanges:[],effort:wm.has(t.effort)?t.effort:"medium",package:typeof t.package=="string"?t.package:"",reason:typeof t.reason=="string"?t.reason:"",riskLevel:vm.has(t.riskLevel)?t.riskLevel:"medium"}),"normalizeRecommendation"),Tl=Fe((t,e,r)=>{const n=Rm(t);if(!n||typeof n!="object")return{analysisType:r,provider:e,recommendations:[],summary:"Failed to parse AI response.",warnings:["AI response was not valid JSON."]};const o=n,i=Array.isArray(o.recommendations)?o.recommendations:[];return{analysisType:r,provider:e,recommendations:i.map(s=>Im(s)),summary:typeof o.summary=="string"?o.summary:"",warnings:Array.isArray(o.warnings)?o.warnings:[]}},"parseAiResponse"),Am={eslint:["ESLint 9.0: Flat config required","ESLint 8.0+: New rule formats"],next:["Next.js 13+: App router changes","Next.js 14+: Server components default"],react:["React 17 to 18: Concurrent features","React 18+: Strict mode changes"],typescript:["TypeScript 5.0: New decorators","TypeScript 4.7+: ESM changes"],vite:["Vite 5: Node.js 18+ required"],vue:["Vue 3: Composition API","Vue 3: Breaking template changes"],webpack:["Webpack 5: Node.js polyfills removed"]},Om=new Set(["bcrypt","cors","crypto-js","express-session","helmet","jose","jsonwebtoken","node-forge","oauth","passport"]),la=Fe((t,e)=>{const r=t.map(n=>{const o=n.vulnerabilities&&n.vulnerabilities.length>0,i=Om.has(n.packageName),s=Am[n.packageName]??[];let a="low",c="update",d="low",p="Patch/minor update, safe to apply.";return n.updateType==="major"?(a="high",c=s.length>0?"review":"update",d="medium",p=s.length>0?`Major update with known breaking changes: ${s[0]}`:"Major version update, review changelog before applying."):n.updateType==="minor"&&(a="medium",p="Minor update, generally safe."),o&&(a="high",c="update",p="Security update — current version has known vulnerabilities."),i&&n.updateType==="major"&&(c="review",p="Security-sensitive package with major update, careful review needed.",d="high"),{action:c,breakingChanges:s,effort:d,package:n.packageName,reason:p,riskLevel:a}});return{analysisType:e,provider:"rule-engine",recommendations:r,summary:`Rule-based ${e} analysis for ${String(t.length)} packages.`,warnings:["No AI provider available — using built-in rule engine."]}},"ruleBasedAnalysis"),Pm=Fe(t=>new Promise(e=>{setTimeout(e,t)}),"sleep"),El=Fe(async(t,e,r=bm)=>{let n;for(let o=0;o<=r;o+=1)try{return(await Dc(t,e,{timeoutMs:Sm})).stdout}catch(i){if(n=i instanceof Error?i:new Error(String(i)),n.message.includes("timed out"))throw n;if(o<r){const s=$m*2**o;await Pm(s)}}throw n??new Error("AI analysis failed after retries")},"runWithRetry"),Nm=Fe(async(t,e,r)=>{const n=jl(e,r),o=await El(t,n);return Tl(o,t.name,r)},"analyzeChunk"),Mm=Fe((t,e,r)=>{const n=[],o=[],i=[];for(const s of t)n.push(...s.recommendations),o.push(...s.warnings),s.summary&&i.push(s.summary);return{analysisType:r,provider:e,recommendations:n,summary:i.length===1?i[0]??"":`Analyzed ${String(n.length)} packages in ${String(t.length)} batches.`,warnings:[...new Set(o)]}},"mergeResults"),Rl={compatibility:"Compatibility",impact:"Impact",recommend:"Recommendations",security:"Security"},po=Fe(t=>{const e=`${Rl[t.analysisType]??t.analysisType} Analysis (${t.provider})`,r=t.recommendations.flatMap(o=>{const i=[{action:o.action,effort:o.effort,package:o.package,reason:o.reason,risk:o.riskLevel}];return o.breakingChanges.length>0&&i.push({action:"",effort:"",package:"",reason:`Breaking: ${o.breakingChanges.join("; ")}`,risk:""}),i}),n=process.stdout.columns||80;return Oe(X.createElement(h,{borderStyle:"round",flexDirection:"column",paddingLeft:1,paddingRight:1},X.createElement(l,{bold:!0},e),X.createElement(l,null,""),X.createElement(l,null,t.summary),X.createElement(l,null,""),X.createElement(Ui,{borderStyle:"none",data:r}),...t.warnings.length>0?[X.createElement(l,null,""),...t.warnings.map((o,i)=>X.createElement(l,{dimColor:!0,key:String(i)},` ${o}`))]:[]),{columns:n})},"formatAiAnalysis");Fe(t=>JSON.stringify(t,void 0,2),"formatAiAnalysisJson");const rs=Fe(async(t,e,r,n="impact")=>{const o=es(r);if(!o)return e.info(`No AI CLI tool found, using rule-based analysis.
|
|
95
|
+
`),la(t,n);const i=dm(o.name,n,t),s=um(i);if(s)return e.info(`Using cached ${n} analysis from ${s.provider}.
|
|
96
|
+
`),s;const a=Rl[n]??n;e.info(`Running ${a.toLowerCase()} analysis with ${o.name}...
|
|
97
|
+
`);try{let c;if(t.length>km){e.info(`Splitting ${String(t.length)} packages into batches of ${String(ei)}...
|
|
98
|
+
`);const d=[];for(let g=0;g<t.length;g+=ei)d.push(t.slice(g,g+ei));const p=[];for(let g=0;g<d.length;g+=1){e.info(` Batch ${String(g+1)}/${String(d.length)}...`);const m=d[g];m&&p.push(await Nm(o,m,n))}c=Mm(p,o.name,n)}else{const d=await El(o,jl(t,n));c=Tl(d,o.name,n)}return pm(i,c,fm(n,r?.cacheTtl)),c}catch(c){const d=c instanceof Error?c.message:String(c);return e.warn(`AI analysis failed (${d}), falling back to rule engine.
|
|
99
|
+
`),la(t,n)}},"runAiAnalysis");var Dm=Object.defineProperty,No=b((t,e)=>Dm(t,"name",{value:e,configurable:!0}),"c$s");const Bm=No((t,e)=>{const r=gm();if(t==="json"){process.stdout.write(`${JSON.stringify(r,void 0,2)}
|
|
100
|
+
`);return}e.info("AI Cache Statistics:"),e.info(` Entries: ${String(r.entries)}`),e.info(` Total size: ${String(Math.round(r.totalSizeBytes/1024))} KB`),e.info(` Oldest: ${r.oldestEntry?new Date(r.oldestEntry).toISOString():"N/A"}`),e.info(` Newest: ${r.newestEntry?new Date(r.newestEntry).toISOString():"N/A"}`)},"handleCacheStats"),Fm=No(async(t,e)=>{const r=es(e);if(!r){t.error("No AI provider available to test."),process.exitCode=1;return}t.info(`Testing ${r.name}...`);try{const n=await Dc(r,"Reply with exactly: OK",{timeoutMs:3e4});t.info(`Provider ${r.name} responded: ${n.stdout.trim().slice(0,200)}`)}catch(n){const o=n instanceof Error?n.message:String(n);t.error(`Provider ${r.name} failed: ${o}`),process.exitCode=1}},"handleTest"),Lm=No((t,e,r)=>{const n=mp(),o=es(r);if(t==="json"){const c=n.map(d=>({available:d.available,method:d.detectionMethod,name:d.name,path:d.path,priority:no[d.name]??0,selected:d.name===o?.name,version:d.version}));process.stdout.write(`${JSON.stringify(c,void 0,2)}
|
|
101
|
+
`);return}const i=n.map(c=>({method:c.detectionMethod??"-",path:c.path??"-",priority:String(no[c.name]??0),provider:c.name,selected:c.name===o?.name?">>>":"",status:c.available?"available":"not found",version:c.version??"-"})),s=process.stdout.columns||80,a=Oe(X.createElement(Ui,{data:i}),{columns:s});e.info(a),o?e.info(`
|
|
102
|
+
Selected provider: ${o.name} (priority ${String(no[o.name]??0)})`):e.info(`
|
|
103
|
+
No AI provider available. Install one of the supported AI CLI tools.`)},"handleProviderStatus"),Vm={alias:"a",description:"Show AI provider status, test connectivity, and manage cache",examples:[["vis ai","Show all AI providers and their status"],["vis ai --test","Test the best available provider"],["vis ai --cache-stats","Show AI response cache statistics"],["vis ai --clear-cache","Clear the AI response cache"],["vis ai --format json","Output as JSON"]],execute:No(async({logger:t,options:e,visConfig:r})=>{const n=e.format??"table";if(e.cacheStats){Bm(n,t);return}if(e.clearCache){const o=hm(),i=mh();t.info(`Cleared ${String(o)} cached AI response${o===1?"":"s"}.`),i>0&&t.info(`Cleared ${String(i)} cached Socket.dev report${i===1?"":"s"}.`);return}if(e.test){await Fm(t,r?.ai);return}Lm(n,t,r?.ai)},"execute"),group:"System",name:"ai",options:[{defaultValue:!1,description:"Test the best available AI provider with a quick prompt",name:"test",type:Boolean},{defaultValue:!1,description:"Show AI response cache statistics",name:"cache-stats",type:Boolean},{defaultValue:!1,description:"Clear the AI response cache",name:"clear-cache",type:Boolean},{description:"Output format: table or json (default: table)",name:"format",type:String}]};var Um=Object.defineProperty,U=b((t,e)=>Um(t,"name",{value:e,configurable:!0}),"c$r");const _m=/^([\^~]|>=|<=|[><=])/,Gm=/^(?:'([^']+)'|"([^"]+)"|([^:\s]+)):\s*(?:'([^']+)'|"([^"]+)"|(\S+))/,Wm=/^catalog:/m,zm=/^catalogs:/m,Hm=/^(@[^:]+):registry$/,qm=/^\/\/(.+)\/:_authToken$/,Jm=/\*+/g,Ym=/[.+^${}()|[\]\\]/g,da=/[.*+?^${}()|[\]\\]/g,Il=/^['"]|['"]$/g,Km=/^https?:\/\//,Al=/\/$/,Xm=/\n(\s+)/,Ol=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Qm=new Set([...Ol,"overrides","pnpm.overrides","resolutions"]),ns=U(t=>{const e=Lc("vis",{create:!0,cwd:t});if(!e)throw new Error("Cannot resolve cache directory. Ensure node_modules exists in your workspace. Run your package manager's install command first.");return w(e,"backup")},"getBackupDir"),_t=U(t=>{const e=t.replace(/^[\^~]|^>=|^<=|^[><]/,""),r=rp(e);if(r)return{major:r.major,minor:r.minor,patch:r.patch,prerelease:Array.isArray(r.prerelease)?r.prerelease.join("."):String(r.prerelease??"")};const n=In(t);if(n)return{major:n.major,minor:n.minor,patch:n.patch,prerelease:""}},"parseVersion"),os=U(t=>_m.exec(t)?.[1]??"","extractPrefix"),Zm=U(t=>{const e=`${String(t.major)}.${String(t.minor)}.${String(t.patch)}`;return t.prerelease?`${e}-${t.prerelease}`:e},"versionToString"),Pl=U((t,e)=>t.major!==e.major?"major":t.minor!==e.minor?"minor":t.patch!==e.patch||t.prerelease!==e.prerelease?"patch":"none","getUpdateType"),ey=U((t,e)=>t.major!==e.major?t.major-e.major:t.minor!==e.minor?t.minor-e.minor:t.patch!==e.patch?t.patch-e.patch:!t.prerelease&&e.prerelease?1:t.prerelease&&!e.prerelease?-1:t.prerelease&&e.prerelease?t.prerelease<e.prerelease?-1:t.prerelease>e.prerelease?1:0:0,"compareVersions"),Nl=U((t,e)=>ey(e,t)>0,"isNewer"),$n=U((t,e)=>{const r=e.replaceAll(Jm,"*").replaceAll(Ym,String.raw`\$&`);return new RegExp(`^${r.replaceAll("*",".*").replaceAll("?",".")}$`).test(t)},"matchesPattern"),ty=U((t,e,r)=>r.some(n=>$n(t,n))?!1:e.length>0?e.some(n=>$n(t,n)):!0,"matchesFilters"),Ml=U(t=>{const e=Gm.exec(t);if(!e)return;const r=e[1]??e[2]??e[3],n=e[4]??e[5]??e[6];if(!(!r||!n))return[r,n]},"parseYamlEntry"),Dl=U((t,e,r,n)=>{t.has(e)||t.set(e,new Map);const o=t.get(e);o&&o.set(r,n)},"setCatalogEntry"),ry=U((t,e,r)=>{if(r<2)return;const n=Ml(e);n&&Dl(t,"default",n[0],n[1])},"parseCatalogSection"),ny=U((t,e,r,n)=>{if(r===2&&e.endsWith(":"))return e.slice(0,-1).trim().replaceAll(Il,"");if(r>=4&&n){const o=Ml(e);o&&Dl(t,n,o[0],o[1])}return n},"parseCatalogsSection"),Bl=U(t=>t==="catalog:"||t.startsWith("catalog:")?"catalog":t==="catalogs:"||t.startsWith("catalogs:")?"catalogs":"none","detectTopLevelSection"),oy=U(t=>{const e=new Map;let r="none",n="";for(const o of t.split(`
|
|
104
|
+
`)){const i=o.trimStart(),s=o.length-i.length;if(s===0&&i.length>0&&!i.startsWith("#")){r=Bl(i),r==="catalogs"&&(n="");continue}i.length===0||i.startsWith("#")||(r==="catalog"&&ry(e,i,s),r==="catalogs"&&(n=ny(e,i,s,n)))}return e},"parseCatalogsFromYaml"),iy=U(t=>{const e=w(t,"pnpm-workspace.yaml");if(!T(e))return!1;const r=ee(e);return Wm.test(r)||zm.test(r)},"hasPnpmCatalogs"),sy=U(t=>{const e=w(t,"pnpm-workspace.yaml");if(!T(e))return new Map;const r=ee(e);return oy(r)},"readPnpmCatalogs"),Fl=U(t=>{if(T(t))try{return ue(t)}catch{return}},"readPackageJsonSafe"),ay=U(t=>{const e=Fl(w(t,"package.json"));return!!(e?.workspaces?.catalog||e?.workspaces?.catalogs)},"hasBunCatalogs"),cy=U(t=>{const e=new Map;if(t.workspaces?.catalog&&typeof t.workspaces.catalog=="object"&&e.set("default",new Map(Object.entries(t.workspaces.catalog))),t.workspaces?.catalogs&&typeof t.workspaces.catalogs=="object")for(const[r,n]of Object.entries(t.workspaces.catalogs))typeof n=="object"&&n!==void 0&&e.set(r,new Map(Object.entries(n)));return e},"parseBunCatalogs"),ly=U(t=>{const e=Fl(w(t,"package.json"));return e?cy(e):new Map},"readBunCatalogs"),Fn=U(t=>{const e=t.lastIndexOf(":");if(e===-1)return;const r=t.slice(e+1);if(Qm.has(r))return{depType:r,relativePath:t.slice(0,e)}},"parseCompositeCatalogName"),dy=U(t=>t?.dev?["devDependencies"]:t?.prod?["dependencies"]:t?.depFields&&t.depFields.length>0?t.depFields:Ol,"getDepTypesToInclude"),uy=U((t,e,r)=>{const n=new Set;e&&n.add(e);for(const o of r){const i=w(t,o,"package.json");if(T(i))try{const s=ue(i);s.name&&n.add(s.name)}catch{}}return n},"collectInternalPackageNames"),Ll=U((t,e)=>{const r=e.split(".");let n=t;for(const o of r)if(n&&typeof n=="object")n=n[o];else return;return typeof n=="object"&&n!==null?n:void 0},"getNestedField"),py=U((t,e,r,n)=>{const o=e.split(".");let i=t;for(const a of o.slice(0,-1))(!i[a]||typeof i[a]!="object")&&(i[a]={}),i=i[a];const s=o.at(-1);(!i[s]||typeof i[s]!="object")&&(i[s]={}),i[s][r]=n},"setNestedField"),fy=U((t,e)=>{const r=new Map;for(const[n,o]of Object.entries(t))e.has(n)||o.startsWith("workspace:")||o.startsWith("file:")||o.startsWith("link:")||o.startsWith("catalog:")||o.startsWith("$")||r.set(n,o);return r},"filterExternalDeps"),gy=U((t,e,r,n,o,i)=>{const s=e==="."?r:w(t,e,"package.json");if(!T(s))return;let a;try{a=ue(s)}catch{return}for(const c of n){const d=c.includes(".")?Ll(a,c):a[c];if(!d||typeof d!="object")continue;const p=fy(d,o);p.size>0&&i.set(`${e}:${c}`,p)}},"scanDirectoryDeps"),hy=U((t,e)=>{const r=new Map,n=w(t,"package.json");if(!T(n))return r;const o=ue(n);let i=[];const s=o.workspaces;if(s){const p=Array.isArray(s)?s:s.packages;p&&(i=$r(t,p))}if(i.length===0){const p=Io(t);p&&(i=$r(t,p))}const a=uy(t,o.name,i),c=dy(e),d=[".",...i];for(const p of d)gy(t,p,n,c,a,r);return r},"readPackageJsonDeps"),ti=U(t=>{const e=w(t,"package.json");if(!T(e))return!1;try{const r=ue(e);return!!(r.dependencies||r.devDependencies||r.peerDependencies||r.optionalDependencies||r.overrides||r.resolutions||Ll(r,"pnpm.overrides"))}catch{return!1}},"hasPackageJsonDeps"),ua=U((t,e)=>{const r=new Map;for(const n of e){const o=Fn(n.catalogName);if(!o)continue;const i=o.relativePath==="."?w(t,"package.json"):w(t,o.relativePath,"package.json");r.has(i)||r.set(i,[]);const s=r.get(i);s&&s.push({depType:o.depType,newRange:n.newRange,packageName:n.packageName})}for(const[n,o]of r){const i=ue(n);for(const{depType:s,newRange:a,packageName:c}of o)s.includes(".")?py(i,s,c,a):i[s]&&(i[s][c]=a);Mi(n,i,{detectIndent:!0,overwrite:!0})}},"applyPackageJsonUpdates"),my=U((t,e)=>e==="bun"?ay(t)||ti(t):e==="npm"||e==="yarn"?ti(t):iy(t)||ti(t),"hasCatalogs"),Mo=U((t,e,r)=>{let n;e==="bun"?n=ly(t):e==="npm"||e==="yarn"?n=new Map:n=sy(t);const o=hy(t,r);for(const[i,s]of o)n.has(i)||n.set(i,s);return n},"readCatalogs"),pa=U(t=>{const e=new Map,r=new Map;let n="https://registry.npmjs.org";for(const o of t.split(`
|
|
105
|
+
`)){const i=o.trim();if(!i||i.startsWith("#")||i.startsWith(";"))continue;const s=i.indexOf("=");if(s===-1)continue;const a=i.slice(0,s).trim(),c=i.slice(s+1).trim(),d=Hm.exec(a);if(d?.[1]){e.set(d[1],c);continue}if(a==="registry"){n=c;continue}const p=qm.exec(a);p?.[1]&&r.set(p[1],c)}return{authTokens:r,defaultRegistry:n,registries:e}},"parseNpmrc"),yy=U((t,e)=>({authTokens:new Map([...t.authTokens,...e.authTokens]),defaultRegistry:e.defaultRegistry==="https://registry.npmjs.org"?t.defaultRegistry:e.defaultRegistry,registries:new Map([...t.registries,...e.registries])}),"mergeNpmrcConfigs"),is=U(t=>{const e={authTokens:new Map,defaultRegistry:"https://registry.npmjs.org",registries:new Map},r=process.env.HOME??process.env.USERPROFILE??"",n=w(r,".npmrc");let o=r&&T(n)?pa(ee(n)):e;const i=w(t,".npmrc");return T(i)&&(o=yy(o,pa(ee(i)))),o},"loadNpmrc"),vy=U((t,e)=>{let r=e.defaultRegistry;if(t.startsWith("@")){const o=t.split("/")[0];if(o&&e.registries.has(o)){const i=e.registries.get(o);i&&(r=i)}}const n=r.replace(Km,"").replace(Al,"");return{token:e.authTokens.get(n),url:r}},"getRegistryForPackage"),Vl=15e3,Ul=U(async(t,e,r=Vl,n=!1)=>{const o=`${(e?.url??"https://registry.npmjs.org").replace(Al,"")}/${t}`,i=n?{Accept:"application/json"}:{Accept:"application/vnd.npm.install-v1+json"};e?.authToken&&(i.Authorization=`Bearer ${e.authToken}`);const s=new AbortController,a=setTimeout(()=>{s.abort()},r);try{const c=await fetch(o,{headers:i,signal:s.signal});if(!c.ok)throw new Error(`Failed to fetch ${t}: ${String(c.status)} ${c.statusText}`);const d=await c.json(),p={latest:d["dist-tags"]?.latest??"",versions:Object.keys(d.versions??{})};return n&&d.time&&(p.publishTimes=new Map(Object.entries(d.time))),p}finally{clearTimeout(a)}},"fetchPackageVersions"),wy=U(t=>{const e=t.database_specific?.severity?.toUpperCase();if(e==="CRITICAL"||e==="HIGH"||e==="MODERATE"||e==="LOW")return e;const r=t.severity?.find(n=>n.type==="CVSS_V3")?.score;if(r){const n=Number.parseFloat(r);return n>=9?"CRITICAL":n>=7?"HIGH":n>=4?"MODERATE":"LOW"}return"UNKNOWN"},"mapOsvSeverity"),ky=U(t=>{const e=t.severity?.find(r=>r.type==="CVSS_V3")?.score;return e?Number.parseFloat(e):void 0},"mapOsvCvss"),by=U(t=>{const e=[];for(const r of t.affected??[])for(const n of r.ranges??[])for(const o of n.events??[])o.fixed&&e.push(o.fixed);return e},"mapOsvFixedVersions"),$y=U(t=>({aliases:t.aliases?.length?t.aliases:void 0,cvssScore:ky(t),fixedVersions:by(t),id:t.id,severity:wy(t),summary:t.summary??""}),"mapOsvVuln"),Do=U(async(t,e=1e4)=>{if(t.length===0)return new Map;const r=t.map(i=>({package:{ecosystem:"npm",name:i.name},version:i.version})),n=new AbortController,o=setTimeout(()=>{n.abort()},e);try{const i=await fetch("https://api.osv.dev/v1/querybatch",{body:JSON.stringify({queries:r}),headers:{"Content-Type":"application/json"},method:"POST",signal:n.signal});if(!i.ok)return new Map;const s=await i.json(),a=new Map;for(const[c,d]of t.entries()){const p=s.results[c]?.vulns;p&&p.length>0&&a.set(d.name,p.map(g=>$y(g)))}return a}catch{return new Map}finally{clearTimeout(o)}},"fetchVulnerabilities"),fa=new Map,Sy=U((t,e,r)=>{if(!r)return e;const n=r[t];if(n!==void 0)return n;for(const[o,i]of Object.entries(r))if(o!==t){if(o.startsWith("/")&&o.endsWith("/")){let s=fa.get(o);if(s||(s=new RegExp(o.slice(1,-1)),fa.set(o,s)),s.test(t))return i}else if($n(t,o))return i}return e},"resolvePackageTarget"),_l=U((t,e,r)=>{const n=e?.get(t);return n?Date.now()-new Date(n).getTime()<r:!1},"isTooNew"),xy=U(t=>t?.minimumReleaseAge?t.packageName&&t.minimumReleaseAgeExclude?.some(e=>$n(t.packageName,e))?0:t.minimumReleaseAge*60*1e3:0,"resolveMinAgeMs"),ga=U((t,e,r,n,o,i)=>t.map(s=>({parsed:_t(s),raw:s})).filter(s=>!s.parsed||!r&&s.parsed.prerelease!==""||!Nl(e,s.parsed)||n&&_l(s.raw,o,n)?!1:i?i(s.parsed):!0).toSorted((s,a)=>tp(s.raw,a.raw))[0]?.raw,"filterCandidates"),Cy=U((t,e,r,n,o,i)=>{const s=_t(r);if(!s)return;const a=xy(i);if(n==="latest"){const d=_t(e);return!d||!o&&d.prerelease!==""||!Nl(s,d)?void 0:!a||!_l(e,i?.publishTimes,a)?e:ga(t,s,o,a,i?.publishTimes)}const c=n==="patch"?d=>d.major===s.major&&d.minor===s.minor:d=>d.major===s.major;return ga(t,s,o,a,i?.publishTimes,c)},"findTargetVersion"),jy=U((t,e)=>{const r=[],n=new Set;for(const[o,i]of t)for(const[s,a]of i)if(!(a.startsWith("workspace:")||a.startsWith("file:")||a.startsWith("link:")||a==="*")&&!(!e.includeLocked&&!os(a))){if(e.ignore.some(c=>$n(s,c))){n.add(s);continue}ty(s,e.include,e.exclude)&&r.push({catalogName:o,packageName:s,range:a})}return{entries:r,ignored:[...n]}},"collectEntries"),Ty=U(async(t,e,r,n=!1)=>{const o=new Map,i=[],s=8;let a=0;for(let c=0;c<t.length;c+=s){const d=t.slice(c,c+s),p=await Promise.allSettled(d.map(async g=>{const m=e?vy(g,e):void 0,y=await Ul(g,m?{authToken:m.token,url:m.url}:void 0,Vl,n);return o.set(g,y),g}));for(const[g,m]of p.entries())if(a+=1,m.status==="rejected"){const y=d[g];y&&i.push(y)}r&&r(a,t.length)}return{failed:i,versionCache:o}},"fetchVersionsBatched"),ha=U((t,e,r)=>{const n=[];for(const o of t){const i=e.get(o.packageName);if(!i)continue;const s=Sy(o.packageName,r.target,r.packageMode),a=Cy(i.versions,i.latest,o.range,s,r.includePrerelease,{minimumReleaseAge:r.minimumReleaseAge,minimumReleaseAgeExclude:r.minimumReleaseAgeExclude,packageName:o.packageName,publishTimes:i.publishTimes});if(!a)continue;const c=_t(o.range),d=_t(a);if(!c||!d)continue;const p=Pl(c,d);if(p==="none")continue;const g=os(o.range);n.push({catalogName:o.catalogName,currentRange:o.range,newRange:`${g}${a}`,packageName:o.packageName,targetVersion:a,updateType:p})}return n},"buildOutdatedEntries"),ma=U(t=>t?Zm(t):"","formatVersionString"),Ey=U(async(t,e,r,n)=>{const o=[...new Map(e.map(c=>{const d=_t(c.range);return[c.packageName,{name:c.packageName,version:ma(d)}]})).values()].filter(c=>c.version),i=r?Xr(o,r):void 0,[s,a]=await Promise.all([Do(o),i]);for(const c of t){const d=s.get(c.packageName);d&&d.length>0&&(c.vulnerabilities=d);const p=_t(c.currentRange),g=ma(p);if(a){const m=a.get(`${c.packageName}@${g}`);m&&(c.socketReport={alerts:m.alerts,license:m.license,score:m.score})}if(n){const m=Ki(c.packageName,g,n);m&&(c.acceptedRisk=m)}}},"enrichWithSecurity"),Ry=6e4,Iy=U((t,e,r,n)=>{const o=[];for(const[a,c]of t)for(const[d,p]of c)o.push(`${a}:${d}=${p}`);if(o.push(`target=${e.target},pre=${String(e.includePrerelease)},sec=${String(e.security??!1)}`),o.push(`in=${e.include.join(",")},ex=${e.exclude.join(",")},ig=${e.ignore.join(",")}`),o.push(`locked=${String(e.includeLocked)}`),o.push(`mra=${String(e.minimumReleaseAge??0)}`),e.packageMode){const a=Object.entries(e.packageMode).map(([c,d])=>`${c}=${d}`).toSorted().join(",");o.push(`pkgMode=${a}`)}o.push(`socket=${String(r??!1)}`),n&&n.length>0&&o.push(`risks=${n.toSorted().join(",")}`);let i=5381;const s=o.join("|");for(let a=0;a<s.length;a++)i=(i<<5)+i+s.charCodeAt(a)|0;return String(i)},"computeCacheHash"),Gl=U(t=>{const e=Lc("vis",{create:!0,cwd:t});return e?w(e,"outdated-cache.json"):void 0},"getOutdatedCachePath"),Ay=U((t,e)=>{const r=Gl(t);if(!(!r||!T(r)))try{const n=ue(r);if(n.hash===e&&Date.now()-n.timestamp<Ry)return n.result}catch{}},"readOutdatedCache"),Oy=U((t,e,r)=>{const n=Gl(t);if(n)try{je(Nt(n)),Mi(n,{hash:e,result:r,timestamp:Date.now()})}catch{}},"writeOutdatedCache"),ss=U(async(t,e,r,n,o,i,s)=>{const a=Iy(t,e,!!i,s?Object.keys(s):void 0);if(o){const x=Ay(o,a);if(x)return x}const{entries:c,ignored:d}=jy(t,e),p=[...new Set(c.map(x=>x.packageName))],g=!!(e.minimumReleaseAge&&e.minimumReleaseAge>0),{failed:m,versionCache:y}=await Ty(p,r,n,g),v=ha(c,y,e);let k=[];if(e.target!=="latest"){const x=new Set(v.map(A=>A.packageName)),E={...e,packageMode:void 0,target:"latest"};k=ha(c,y,E).filter(A=>!x.has(A.packageName))}(e.security||i)&&v.length>0&&await Ey(v,c,i,s);const $={checkedCount:p.length,failed:m,filteredByTarget:k,ignored:d,outdated:v};return o&&Oy(o,a,$),$},"checkOutdated"),as=U((t,e)=>e==="bun"?w(t,"package.json"):w(t,"pnpm-workspace.yaml"),"getCatalogFilePath"),ya=U((t,e)=>{const r=ns(t),n=new Set;for(const o of e){const i=Fn(o.catalogName);i&&n.add(i.relativePath==="."?"package.json":w(i.relativePath,"package.json"))}if(n.size!==0){je(r);for(const o of n){const i=w(t,o);if(T(i)){const s=w(r,o),a=Nt(s);je(a),Q(s,ee(i))}}return r}},"createPackageJsonBackup"),Py=U((t,e,r)=>{if((e==="npm"||e==="yarn")&&r)return ya(t,r);let n;const o=as(t,e);if(T(o)&&(n=`${o}.bak`,Q(n,ee(o))),r){const i=r.filter(s=>Fn(s.catalogName));i.length>0&&ya(t,i)}return n},"createBackup"),Ny=U(t=>{const e=ns(t);if(!T(e))return!1;for(const r of Rn(e,{includeDirs:!1})){const n=r.path.slice(e.length+1),o=w(t,n);Q(o,ee(r.path))}return Lu(e),!0},"restorePackageJsonBackup"),My=U((t,e)=>{if(e==="npm"||e==="yarn")return Ny(t);const r=as(t,e),n=`${r}.bak`;if(!T(n))return!1;const o=ee(n);return Q(r,o),!0},"restoreFromBackup"),Dy=U((t,e)=>{if(e==="npm"||e==="yarn")try{const n=ns(t);return T(n)}catch{return!1}const r=as(t,e);return T(`${r}.bak`)},"hasBackup"),By=U(t=>JSON.stringify(t,void 0,2),"formatOutdatedJson"),Wl=U(t=>t.map(e=>`${e.packageName} ${e.currentRange} → ${e.newRange}`).join(`
|
|
106
|
+
`),"formatOutdatedMinimal"),yt=U(t=>t?Array.isArray(t)?t:[t]:[],"toFilterArray"),Fy=U(t=>{const e=new Map;for(const r of t){e.has(r.catalogName)||e.set(r.catalogName,[]);const n=e.get(r.catalogName);n&&n.push(r)}return e},"groupByCatalog"),Ly=U(t=>{const e=Fn(t);return e?`${e.relativePath==="."?"root":e.relativePath} (${e.depType})`:`Catalog: ${t}`},"formatCatalogDisplayName"),zl=U((t,e)=>{const r=Fy(t),n=process.stdout.columns||80,o=t.some(i=>i.socketReport);for(const[i,s]of r){const a=s.flatMap(p=>{const g=p.vulnerabilities&&p.vulnerabilities.length>0,m=p.socketReport&&p.socketReport.alerts.length>0,y=`${g||m?"[SEC] ":""}${p.packageName}`,v=p.socketReport?`${String(Math.round(p.socketReport.score.overall*100))}%`:"",k={current:p.currentRange,package:y,target:p.newRange,type:p.updateType};o&&(k.score=v);const $=[k];if(p.vulnerabilities)for(const x of p.vulnerabilities){const E={current:x.summary,package:` ${x.severity} ${x.id}`,target:"",type:""};o&&(E.score=""),$.push(E)}if(p.socketReport)for(const x of p.socketReport.alerts){const E={current:x.category,package:` [${x.severity.toUpperCase()}] ${x.type}`,target:"",type:""};o&&(E.score=""),$.push(E)}return $}),c=Ly(i),d=Oe(X.createElement(Ui,{data:a}),{columns:n});e.info(`${c}
|
|
107
|
+
${d}
|
|
108
|
+
`)}},"formatOutdatedTable"),fo=U(t=>{let e=0,r=0,n=0,o=0,i=0,s=0;for(const g of t)g.updateType==="major"?e++:g.updateType==="minor"?r++:n++,g.vulnerabilities&&g.vulnerabilities.length>0&&o++,g.socketReport?.alerts.length&&i++,g.socketReport&&g.socketReport.score.overall<Qt&&s++;const a=[];e&&a.push(`${String(e)} major`),r&&a.push(`${String(r)} minor`),n&&a.push(`${String(n)} patch`),o&&a.push(`${String(o)} with vulnerabilities`),i&&a.push(`${String(i)} with Socket.dev alerts`);const c=`Found ${String(t.length)} outdated (${a.join(", ")})`,d=process.stdout.columns||80,p=[X.createElement(l,{bold:!0},"─ Summary"),X.createElement(l,null,` ${c}`)];return s>0&&p.push(X.createElement(l,{color:"yellow"},` ${String(s)} package${s===1?"":"s"} with low Socket.dev score (<${String(Qt*100)}%)`)),Oe(X.createElement(h,{flexDirection:"column",paddingX:1},...p),{columns:d})},"formatSummary"),Vy=U((t,e)=>{const r=t.replaceAll(da,String.raw`\$&`),n=e.replaceAll(da,String.raw`\$&`);return new RegExp(String.raw`^(?:'${r}'|"${r}"|${r}):\s*['"]?${n}['"]?`)},"buildLineMatchRegex"),Uy=U((t,e,r)=>Vy(e,r).test(t),"lineMatchesPackage"),_y=U(t=>{const e=new Map;for(const r of t){e.has(r.catalogName)||e.set(r.catalogName,new Map);const n=e.get(r.catalogName);n&&n.set(r.packageName,{newRange:r.newRange,oldRange:r.currentRange})}return e},"buildUpdateMap"),va=U((t,e,r)=>{if(!r)return t;for(const[n,{newRange:o,oldRange:i}]of r)if(Uy(e,n,i))return t.replace(i,o);return t},"applyLineUpdate"),Gy=U((t,e,r,n)=>{const o=t.trimStart(),i=t.length-o.length;return o.length===0||o.startsWith("#")?t:e==="catalog"&&i>=2?va(t,o,n.get("default")):e==="catalogs"&&i>=4&&r?va(t,o,n.get(r)):t},"processYamlLineForUpdate"),Wy=U((t,e)=>{const r=w(t,"pnpm-workspace.yaml"),n=ee(r).split(`
|
|
109
|
+
`),o=_y(e);let i="none",s="";const a=[];for(const c of n){const d=c.trimStart(),p=c.length-d.length;p===0&&d.length>0&&!d.startsWith("#")&&(i=Bl(d),i==="catalogs"&&(s="")),i==="catalogs"&&p===2&&d.endsWith(":")&&(s=d.slice(0,-1).trim().replaceAll(Il,"")),a.push(Gy(c,i,s,o))}Q(r,a.join(`
|
|
110
|
+
`))},"applyPnpmCatalogUpdates");U(t=>{const e=Xm.exec(t);if(!e)return 2;const r=e[1];return r?r.includes(" ")?r:r.length:2},"detectJsonIndent");const zy=U((t,e)=>{const r=w(t,"package.json"),n=ue(r);for(const o of e)if(o.catalogName==="default")n.workspaces?.catalog&&(n.workspaces.catalog[o.packageName]=o.newRange);else{const i=n.workspaces?.catalogs?.[o.catalogName];i&&(i[o.packageName]=o.newRange)}Mi(r,n,{detectIndent:!0,overwrite:!0})},"applyBunCatalogUpdates"),Hy=U((t,e,r,n=!0)=>{let o;n&&(o=Py(t,r,e));const i=[],s=[];for(const a of e)Fn(a.catalogName)?s.push(a):i.push(a);return i.length>0&&(r==="npm"||r==="yarn"?ua(t,i):r==="bun"?zy(t,i):Wy(t,i)),s.length>0&&ua(t,s),o},"applyCatalogUpdates"),qy=U(async t=>{const e=dt({input:process.stdin,output:process.stdout}),r=U(o=>new Promise(i=>{e.question(o,s=>{i(s.trim())})}),"ask");process.stdout.write(`
|
|
93
111
|
Outdated catalog dependencies:
|
|
94
|
-
`);for(const[o,
|
|
112
|
+
`);for(const[o,i]of t.entries())i&&process.stdout.write(` ${String(o+1)}. ${i.packageName}: ${i.currentRange} → ${i.newRange} (${i.updateType})
|
|
95
113
|
`);process.stdout.write(`
|
|
96
|
-
`);const
|
|
97
|
-
`);const
|
|
98
|
-
`);const
|
|
99
|
-
`):e.info(
|
|
100
|
-
`),n.push(`Updated package.json trustedDependencies with ${
|
|
114
|
+
`);const n=await r("Apply updates? [a]ll / [n]one / [s]elect: ");if(n.toLowerCase()==="a"||n.toLowerCase()==="all")return e.close(),t;if(n.toLowerCase()==="n"||n.toLowerCase()==="none")return e.close(),[];if(n.toLowerCase()==="s"||n.toLowerCase()==="select"){const o=await r("Enter numbers to apply (comma-separated): ");return e.close(),o.split(",").map(i=>Number.parseInt(i.trim(),10)-1).filter(i=>i>=0&&i<t.length).map(i=>t[i]).filter(i=>i!==void 0)}return e.close(),[]},"promptPackageSelection"),Jy=/github\.com[/:]([\w.-]+)\/([\w.-]+?)(?:\.git|\/|$)/,Hl=U(async(t,e=1e4)=>{const r=[],n=new AbortController,o=setTimeout(()=>{n.abort()},e);try{const i=t.map(async s=>{const a=`https://www.npmjs.com/package/${s.packageName}`;try{const c=await fetch(`https://registry.npmjs.org/${s.packageName}`,{headers:{Accept:"application/json"},signal:n.signal});if(!c.ok)return{npmUrl:a,packageName:s.packageName};const d=(await c.json()).repository?.url;if(!d)return{npmUrl:a,packageName:s.packageName};const p=Jy.exec(d);if(!p)return{npmUrl:a,packageName:s.packageName,repoUrl:d};const g=p[1],m=p[2],y=`https://github.com/${g}/${m}/releases/tag/v${s.targetVersion}`;return{npmUrl:a,packageName:s.packageName,releaseUrl:y,repoUrl:`https://github.com/${g}/${m}`}}catch{return{npmUrl:a,packageName:s.packageName}}});r.push(...await Promise.all(i))}finally{clearTimeout(o)}return r},"fetchChangelogInfo");var Yy=Object.defineProperty,Ky=b((t,e)=>Yy(t,"name",{value:e,configurable:!0}),"A$d");const Xy=/^[\^~>=<]+/,Qy={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"]],execute:Ky(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=t,s=i[0];if(!s)throw new Error("Package name is required. Usage: vis analyze <package> [version]");const a=i[1],{packageManager:c}=$o(o);let d,p="default";const g=Mo(o,c);for(const[L,I]of g){const M=I.get(s);if(M){d=M,p=L;break}}if(!d)throw new Error(`Package "${s}" not found in any catalog or package.json. Make sure it exists in your workspace dependencies.`);let m;if(a)m=a;else{e.info(`Fetching latest version for ${s}...
|
|
115
|
+
`);const L=await Ul(s);if(!L.latest)throw new Error(`Could not determine latest version for "${s}".`);m=L.latest}const y=_t(d),v=_t(m);if(!y||!v)throw new Error(`Could not parse versions: current="${d}", target="${m}".`);const k=Pl(y,v);if(k==="none"){e.info(`${s} is already at ${m}. Nothing to analyze.`);return}const $=os(d),x={catalogName:p,currentRange:d,newRange:`${$}${m}`,packageName:s,targetVersion:m,updateType:k},E=ts(r.aiType??"impact");if(E==="security"||r.security){e.info(`Checking for known vulnerabilities...
|
|
116
|
+
`);const L=d.replace(Xy,""),I=(await Do([{name:s,version:L}])).get(s);I&&I.length>0&&(x.vulnerabilities=I);const M=Er(n?.security?.socket);if(M){const F=(await Xr([{name:s,version:L}],M)).get(`${s}@${L}`);F&&(x.socketReport={alerts:F.alerts,license:F.license,score:F.score})}}const A=await rs([x],e,n?.ai,E);(r.format??"table")==="json"?process.stdout.write(`${JSON.stringify(A,void 0,2)}
|
|
117
|
+
`):e.info(po(A))},"execute"),group:"System",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}]};var Zy=Object.defineProperty,rt=b((t,e)=>Zy(t,"name",{value:e,configurable:!0}),"d$u");const ql=rt((t,e)=>{const r={errors:[],warnings:[]},{security:n}=t;if(!n)return r.warnings.push("No security settings configured. Use defineConfig() from '@visulima/vis/config' to get secure defaults automatically."),r;if((!n.allowBuilds||Object.keys(n.allowBuilds).length===0)&&r.warnings.push(e==="pnpm"?"security.allowBuilds is not configured. pnpm blocks build scripts by default since v10. Run 'vis approve-builds' to review.":"security.allowBuilds is not configured. Consider listing which packages are allowed to run install/postinstall scripts."),n.minimumReleaseAge===0&&r.warnings.push("security.minimumReleaseAge is explicitly set to 0. New packages can be installed immediately after publishing."),n.trustPolicy==="off"&&r.warnings.push("security.trustPolicy is explicitly set to 'off'. Packages whose trust level has decreased will not be blocked."),n.blockExoticSubdeps===!1&&r.warnings.push("security.blockExoticSubdeps is explicitly disabled. Transitive dependencies can pull code from git repos or tarball URLs."),n.strictDepBuilds===!1&&r.warnings.push("security.strictDepBuilds is explicitly disabled. Unapproved build scripts will only produce warnings, not errors."),n.strictDepBuilds&&(!n.allowBuilds||Object.keys(n.allowBuilds).length===0)&&r.errors.push("security.strictDepBuilds is enabled but security.allowBuilds is empty. All dependencies with build scripts will be blocked. Run 'vis approve-builds' to review and add packages."),n.socket?.acceptedRisks){const o=Date.now();for(const[i,s]of Object.entries(n.socket.acceptedRisks)){const a=new Date(s.acceptedAt).getTime();o-a>7776e6&&r.warnings.push(`Accepted risk for "${i}" is over 90 days old (accepted ${s.acceptedAt}). Consider re-evaluating with 'vis audit'.`)}}return r},"checkSecurityConfig"),ev=rt((t,e)=>{if(lt&&!process.env.VIS_SECURITY_WARNINGS)return;const r=ql(t,e);for(const n of r.errors)er(n);r.warnings.length>0&&se(`${r.warnings.length} security recommendation${r.warnings.length===1?"":"s"} found. Run 'vis check --security-config' for details.`)},"emitSecurityWarnings"),tv=rt((t,e)=>{const r=ql(t,e),{security:n}=t;if(n){if(S("Active security settings:"),S(` minimumReleaseAge: ${n.minimumReleaseAge??"not set"} minutes`),S(` trustPolicy: ${n.trustPolicy??"not set"}`),S(` trustPolicyIgnoreAfter: ${n.trustPolicyIgnoreAfter??"not set"} minutes`),S(` blockExoticSubdeps: ${n.blockExoticSubdeps??!1}`),S(` strictDepBuilds: ${n.strictDepBuilds??!1}`),S(` allowBuilds: ${n.allowBuilds?`${Object.keys(n.allowBuilds).length} entries`:"not configured"}`),S(""),S("Socket.dev integration:"),S(` socket.enabled: ${n.socket?.enabled??!1}`),S(` socket.apiToken: ${n.socket?.apiToken||process.env.VIS_SOCKET_TOKEN?"configured":"using public token"}`),S(` socket.minimumScore: ${n.socket?.minimumScore??"default (0.4)"}`),S(` socket.cacheTtlMs: ${n.socket?.cacheTtlMs??"default (1 hour)"}`),S(` socket.timeoutMs: ${n.socket?.timeoutMs??"default (15s)"}`),n.socket?.acceptedRisks){const o=Object.entries(n.socket.acceptedRisks);S(` socket.acceptedRisks: ${String(o.length)} entr${o.length===1?"y":"ies"}`);for(const[i,s]of o)S(` ${i}: ${s.reason} (accepted ${s.acceptedAt.slice(0,10)})`)}else S(" socket.acceptedRisks: none");S("")}if(r.errors.length===0&&r.warnings.length===0){S("All recommended security settings are configured.");return}for(const o of r.errors)er(o);for(const o of r.warnings)se(o);ie(""),ie("Secure defaults are applied by defineConfig(). You only need to add allowBuilds:"),ie(""),ie(" import { defineConfig } from '@visulima/vis/config';"),ie(""),ie(" export default defineConfig({"),ie(" security: {"),ie(" allowBuilds: {"),ie(" esbuild: true,"),ie(" '@prisma/client': true,"),ie(" },"),ie(" },"),ie(" });")},"printSecurityReport"),rv=rt(t=>{const{security:e}=t;if(!e)return[];const r=[];return e.minimumReleaseAge!==void 0&&r.push(`minimumReleaseAge: ${e.minimumReleaseAge}`),e.trustPolicy&&e.trustPolicy!=="off"&&r.push(`trustPolicy: ${e.trustPolicy}`),e.blockExoticSubdeps&&r.push("blockExoticSubdeps: true"),e.allowBuilds&&r.push(`allowBuilds: ${Object.keys(e.allowBuilds).length} entries`),e.strictDepBuilds&&r.push("strictDepBuilds: true"),e.trustPolicyIgnoreAfter!==void 0&&r.push(`trustPolicyIgnoreAfter: ${e.trustPolicyIgnoreAfter}`),r},"previewPnpmSync"),Jl=rt((t,e)=>{const r=w(t,"node_modules");if(!T(r))return[];const n=[],o=rt((i,s="")=>{let a;try{a=Ge(i)}catch{return}for(const c of a){const d=w(i,c);if(c.startsWith("@")){o(d,`${c}/`);continue}if(c.startsWith("."))continue;const p=s+c,g=w(d,"package.json");try{if(!br(d).isDirectory()||!T(g))continue;const m=ue(g).scripts??{};if(!m.preinstall&&!m.install&&!m.postinstall&&!m.prepare)continue;if(!Object.entries(e).some(([y,v])=>v?y===p?!0:y.endsWith("*")?p.startsWith(y.slice(0,-1)):!1:!1)){const y=["preinstall","install","postinstall","prepare"].filter(v=>m[v]);n.push(`${p} (${y.join(", ")})`)}}catch{}}},"scanDir");return o(r),n},"scanUnapprovedBuildScripts"),Yl=rt(t=>T(w(t,".yarnrc.yml")),"isYarnBerry"),nv=rt((t,e,r)=>{const n={extraArgs:[],postInstallPackages:[],scriptsBlockedByDefault:!1,warnings:[]},o=r.security?.allowBuilds??{},i=Object.keys(o).length>0;switch(t){case"bun":{if(n.scriptsBlockedByDefault=!0,i){const s=w(e,"package.json");try{(T(s)?ue(s):{}).trustedDependencies?.length||n.warnings.push("vis security.allowBuilds is configured but trustedDependencies is empty. Run 'vis approve-builds --sync-native'.")}catch{}}break}case"npm":{n.scriptsBlockedByDefault=!1;const s=w(e,".npmrc"),a=T(s)&&/^\s*ignore-scripts\s*=\s*true\s*$/m.test(ee(s));if(!a&&i?(n.warnings.push("npm does not block lifecycle scripts. vis will add --ignore-scripts automatically."),n.extraArgs.push("--ignore-scripts")):!a&&!i&&n.warnings.push("npm does not block lifecycle scripts. Add 'ignore-scripts=true' to .npmrc and configure security.allowBuilds."),i)for(const[c,d]of Object.entries(o))d&&n.postInstallPackages.push(c);break}case"pnpm":{n.scriptsBlockedByDefault=!0,i||n.warnings.push("pnpm blocks build scripts by default. Run 'vis approve-builds' to review packages that need scripts.");break}case"yarn":{if(n.scriptsBlockedByDefault=!1,Yl(e)){const s=ee(w(e,".yarnrc.yml"));/^\s*enableScripts\s*:\s*false\s*$/m.test(s)?n.scriptsBlockedByDefault=!0:n.warnings.push("yarn berry supports enableScripts. Add 'enableScripts: false' to .yarnrc.yml.")}else if(n.warnings.push("yarn classic does not support blocking lifecycle scripts. Consider upgrading to yarn berry."),i){n.extraArgs.push("--ignore-scripts");for(const[s,a]of Object.entries(o))a&&n.postInstallPackages.push(s)}break}}return n},"enforceScriptSecurity"),cs=rt((t,e,r)=>{const n=[],o=Object.entries(r).filter(([,i])=>i).map(([i])=>i);switch(t){case"bun":{const i=w(e,"package.json");if(T(i))try{const s=ue(i);s.trustedDependencies=o,Q(i,`${JSON.stringify(s,null,2)}
|
|
118
|
+
`),n.push(`Updated package.json trustedDependencies with ${o.length} packages`)}catch(s){n.push(`Failed to update package.json: ${s instanceof Error?s.message:String(s)}`)}break}case"npm":{const i=w(e,".npmrc");let s=T(i)?ee(i):"";/^\s*ignore-scripts\s*=\s*true\s*$/m.test(s)?n.push(".npmrc already has ignore-scripts=true"):(s=`${s.trimEnd()}
|
|
101
119
|
ignore-scripts=true
|
|
102
|
-
`,
|
|
120
|
+
`,Q(i,s),n.push("Added ignore-scripts=true to .npmrc"));break}case"pnpm":{const i=w(e,"pnpm-workspace.yaml");if(!T(i)){n.push("pnpm-workspace.yaml not found. Cannot sync allowBuilds.");break}let s={};try{s=Jr(i)?.allowBuilds??{}}catch{}const a={...s,...r},c=Object.keys(r).filter(k=>s[k]!==r[k]).length;if(c===0){n.push(`All ${String(Object.keys(r).length)} allowBuilds entries already present in pnpm-workspace.yaml.`);break}const d=Object.keys(a).sort(),p=rt(k=>k.startsWith("@")||k.includes("/")||/[:#\s]/.test(k),"needsQuote"),g=rt(k=>p(k)?`'${k.replaceAll("'","''")}'`:k,"renderKey"),m=`allowBuilds:
|
|
121
|
+
${d.map(k=>` ${g(k)}: ${String(a[k])}`).join(`
|
|
122
|
+
`)}
|
|
123
|
+
`;let y=ee(i);y.endsWith(`
|
|
124
|
+
`)||(y+=`
|
|
125
|
+
`);const v=/^allowBuilds:[ \t]*\n(?:[ \t]{2}[^\n]*\n)*/m;y=v.test(y)?y.replace(v,m):`${y.trimEnd()}
|
|
126
|
+
|
|
127
|
+
${m}`,Q(i,y),n.push(`Updated pnpm-workspace.yaml allowBuilds (${String(c)} new, ${String(d.length)} total)`);break}case"yarn":{if(Yl(e)){const i=w(e,".yarnrc.yml");let s=ee(i);const a=/^\s*enableScripts\s*:/m.test(s),c=/^\s*enableScripts\s*:\s*false\s*$/m.test(s);a?c?n.push(".yarnrc.yml already has enableScripts: false"):(s=s.replace(/^\s*enableScripts\s*:.+$/m,"enableScripts: false"),Q(i,s),n.push("Changed enableScripts to false in .yarnrc.yml")):(s=`${s.trimEnd()}
|
|
103
128
|
enableScripts: false
|
|
104
|
-
`,
|
|
129
|
+
`,Q(i,s),n.push("Added enableScripts: false to .yarnrc.yml"))}else{const i=w(e,".npmrc");let s=T(i)?ee(i):"";/^\s*ignore-scripts\s*=\s*true\s*$/m.test(s)?n.push(".npmrc already has ignore-scripts=true"):(s=`${s.trimEnd()}
|
|
105
130
|
ignore-scripts=true
|
|
106
|
-
`,
|
|
107
|
-
`);for(const
|
|
108
|
-
${p.map(
|
|
131
|
+
`,Q(i,s),n.push("Added ignore-scripts=true to .npmrc (yarn classic lacks enableScripts)"))}break}}return n},"syncAllowBuildsToNativeConfig"),ov=rt((t,e)=>{const r=w(t,"node_modules"),n=[];for(const o of e){if(!o.endsWith("*")){n.push(o);continue}const i=o.slice(0,-1);try{if(i.startsWith("@")&&i.endsWith("/")){const s=w(r,i.slice(0,-1));for(const a of Ge(s))!a.startsWith(".")&&br(w(s,a)).isDirectory()&&n.push(`${i.slice(0,-1)}/${a}`)}else for(const s of Ge(r))s.startsWith(i)&&br(w(r,s)).isDirectory()&&n.push(s)}catch{}}return n},"expandPatterns"),iv=rt((t,e)=>{if(e.length===0)return;const r=ov(t,e);if(r.length===0)return;const n=w(t,"node_modules");let o=!1;for(const i of r){if(i.includes("..")||i.startsWith("/")||i.startsWith("\\")){se(`Skipping invalid package name: ${i}`);continue}const s=(i.match(/\//g)||[]).length;if(s>1||s===1&&!i.startsWith("@")){se(`Skipping invalid package name: ${i}`);continue}const a=w(n,i),c=w(a,"package.json");if(T(c))try{const d=ue(c).scripts??{};for(const p of["preinstall","install","postinstall"])if(d[p]){S(`Running ${p} for ${i}...`);try{Pn(d[p],{cwd:a,env:{...process.env},stdio:"inherit"})}catch{er(`${p} script failed for ${i}`),o=!0}}}catch{}}o&&(process.exitCode=1)},"runApprovedScripts");var sv=Object.defineProperty,av=b((t,e)=>sv(t,"name",{value:e,configurable:!0}),"l$o");const cv={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 --sync-native","Sync allowBuilds to native PM config"]],execute:av(async({options:t,visConfig:e,workspaceRoot:r})=>{const n=r??process.cwd(),o=Ne(n);if(o.name==="pnpm"&&!t.scan){S("Delegating to pnpm approve-builds...");const i=["approve-builds"];t.all&&i.push("--all");const s=ct("pnpm",i,{cwd:n,stdio:"inherit"});if(s.error)throw new Error(`Failed to run pnpm approve-builds: ${s.error.message}`);if(s.status!==0&&s.status!==null&&(er(`pnpm approve-builds exited with code ${s.status}`),process.exitCode=s.status),!t.syncNative){ie(""),ie("Tip: vis.config.ts security.allowBuilds may now be out of sync with pnpm-workspace.yaml."),ie("Run 'vis check --security-config' to compare, or copy the new entries into vis.config.ts.");return}}else{const i=e?.security?.allowBuilds??{},s=Jl(n,i);if(s.length===0)Z("No unapproved build scripts found.");else{se(`Found ${s.length} package${s.length===1?"":"s"} with unapproved build scripts:
|
|
132
|
+
`);for(const a of s)S(` ${a}`);ie(""),ie("To approve these packages, add them to vis.config.ts:"),ie(""),ie(" security: {"),ie(" allowBuilds: {");for(const a of s){const c=a.split(" (")[0];ie(` "${c}": true,`)}ie(" },"),ie(" },"),o.name==="pnpm"&&(ie(""),ie("Or run 'pnpm approve-builds' to update pnpm-workspace.yaml directly."))}}if(t.syncNative){const i=e?.security?.allowBuilds??{};if(Object.keys(i).length===0)se("No security.allowBuilds configured in vis.config.ts. Nothing to sync.");else{const s=cs(o.name,n,i);S("");for(const a of s)Z(a)}}},"execute"),group:"Security & Health",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}]};var lv=Object.defineProperty,sr=b((t,e)=>lv(t,"name",{value:e,configurable:!0}),"o$i");const go=sr(t=>Array.isArray(t)?t.filter(e=>typeof e=="string"):[],"toStringArray"),wi=sr((t,e)=>{for(const r of e)if(r===t||r.endsWith("*")&&t.startsWith(r.slice(0,-1)))return!0;return!1},"matchesGlobList"),Kl=sr(t=>{const e=w(t,"pnpm-workspace.yaml");if(!T(e))return{excludedPackages:[],ignoredAdvisories:[]};try{const r=Jr(e);return{excludedPackages:[],ignoredAdvisories:[...go(r?.auditConfig?.ignoreCves),...go(r?.auditConfig?.ignoreGhsas)]}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readPnpmAuditExclusions"),Xl=sr(t=>{const e=w(t,".yarnrc.yml");if(!T(e))return{excludedPackages:[],ignoredAdvisories:[]};try{const r=Jr(e);return{excludedPackages:go(r?.npmAuditExcludePackages),ignoredAdvisories:go(r?.npmAuditIgnoreAdvisories)}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readYarnAuditExclusions"),dv=sr((t,e)=>{switch(e){case"pnpm":return Kl(t);case"yarn":return Xl(t);default:return{excludedPackages:[],ignoredAdvisories:[]}}},"readNativeAuditExclusions"),wa=sr((t,e,r)=>{if(wi(t,e.ignoredAdvisories))return!0;if(r){for(const n of r)if(wi(n,e.ignoredAdvisories))return!0}return!1},"isAdvisoryExcluded"),uv=sr((t,e)=>wi(t,e.excludedPackages),"isPackageExcluded"),pv=sr((t,e,r)=>{if(r.length===0)return["No advisory IDs to sync."];const n=[];switch(t){case"bun":{n.push(`bun has no audit config file. Use CLI flags: bun audit ${r.map(o=>`--ignore ${o}`).join(" ")}`);break}case"npm":{n.push("npm has no native audit exclusion config. vis accepted risks are the only layer.");break}case"pnpm":{const o=w(e,"pnpm-workspace.yaml");if(!T(o)){n.push("pnpm-workspace.yaml not found. Cannot sync.");break}const i=Kl(e),s=new Set(i.ignoredAdvisories.filter(k=>k.startsWith("CVE-"))),a=new Set(i.ignoredAdvisories.filter(k=>k.startsWith("GHSA-"))),c=r.filter(k=>k.startsWith("CVE-")),d=r.filter(k=>k.startsWith("GHSA-")),p=[...new Set([...s,...c])],g=[...new Set([...a,...d])],m=c.filter(k=>!s.has(k)).length,y=d.filter(k=>!a.has(k)).length;if(m===0&&y===0){n.push("All advisory IDs already present in pnpm-workspace.yaml.");break}let v=ee(o);if(p.length>0){const k=` ignoreCves:
|
|
133
|
+
${p.map($=>` - ${$}`).join(`
|
|
109
134
|
`)}
|
|
110
|
-
`;/auditConfig:/.test(
|
|
111
|
-
${
|
|
135
|
+
`;/auditConfig:/.test(v)?v=/ignoreCves:/.test(v)?v.replace(/ignoreCves:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,k):v.replace(/auditConfig:\s*\n/,`auditConfig:
|
|
136
|
+
${k}`):v=`${v.trimEnd()}
|
|
112
137
|
|
|
113
138
|
auditConfig:
|
|
114
|
-
${
|
|
115
|
-
${
|
|
139
|
+
${k}`,m>0&&n.push(`Added ${String(m)} new CVE${m===1?"":"s"} to pnpm-workspace.yaml (${String(p.length)} total)`)}if(g.length>0){const k=` ignoreGhsas:
|
|
140
|
+
${g.map($=>` - ${$}`).join(`
|
|
116
141
|
`)}
|
|
117
|
-
`;/auditConfig:/.test(
|
|
118
|
-
${
|
|
142
|
+
`;/auditConfig:/.test(v)&&(v=/ignoreGhsas:/.test(v)?v.replace(/ignoreGhsas:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,k):v.replace(/(auditConfig:[\s\S]*?)(\n\S|\n?$)/m,`$1${k}$2`)),y>0&&n.push(`Added ${String(y)} new GHSA${y===1?"":"s"} to pnpm-workspace.yaml (${String(g.length)} total)`)}Q(o,v);break}case"yarn":{const o=w(e,".yarnrc.yml");if(!T(o)){n.push(".yarnrc.yml not found. Cannot sync.");break}const i=Xl(e),s=new Set(i.ignoredAdvisories),a=[...new Set([...s,...r])],c=r.filter(g=>!s.has(g)).length;if(c===0){n.push("All advisory IDs already present in .yarnrc.yml.");break}let d=ee(o);const p=`npmAuditIgnoreAdvisories:
|
|
143
|
+
${a.map(g=>` - "${g}"`).join(`
|
|
119
144
|
`)}
|
|
120
|
-
`;
|
|
121
|
-
|
|
122
|
-
${p}`,
|
|
123
|
-
${r.summary}${
|
|
124
|
-
`);const y=m.map(
|
|
125
|
-
`),e.exitCode&&
|
|
126
|
-
── ${
|
|
127
|
-
── Socket.dev Supply Chain (${String(
|
|
128
|
-
── Duplicate Dependencies (${String(
|
|
129
|
-
All issues are acknowledged. No action required.`),e.sync&&
|
|
130
|
-
No advisory IDs to sync to native PM config.`)}e.exitCode&&B>0&&(process.exitCode=1)},"executeAudit"),kp={group:"Security & Health",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 --fix","Show fix suggestions for vulnerabilities"],["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)"]],execute:ot(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");await wp(n,e,r,t)},"execute"),name:"audit",options:[{description:"Minimum severity to report: low, medium, high, critical (default: low)",name:"severity",type:String},{description:"Output format: table or json (default: table)",name:"format",type:String},{defaultValue:!1,description:"Show fix suggestions for vulnerabilities",name:"fix",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}]};var bp=Object.defineProperty,$p=$((t,e)=>bp(t,"name",{value:e,configurable:!0}),"a$9");function sr({current:t,total:e}){const{columns:r}=Ut(),n=r||80,i=e>0?t/e:0,o=`${String(Math.round(i*100))}%`,s=Math.max(10,n-4),l=Math.round(s*i),d=s-l;return u(g,{flexDirection:"column",marginTop:1,paddingX:1,children:[u(g,{children:[c(Bi,{type:"dots"}),u(a,{children:[" ","Checking"," ",String(e)," ","catalog dependencies"," "]}),u(a,{dimColor:!0,children:[String(t),"/",String(e)]})]}),u(g,{children:[c(a,{color:"cyan",children:"━".repeat(l)}),c(a,{dimColor:!0,children:"─".repeat(d)}),u(a,{children:[" ",o]})]})]})}$(sr,"T$7");$p(sr,"CheckProgressApp");var xp=Object.defineProperty,er=$((t,e)=>xp(t,"name",{value:e,configurable:!0}),"r$g");const Tr=er(t=>{const e=new Map;for(const r of t){const n=e.get(r.catalogName);n?n.push(r):e.set(r.catalogName,[r])}return e},"groupByCatalog"),Ar=er((t,e,r)=>{let n=t;if(e!=="all"&&(n=e==="security"?n.filter(i=>i.vulnerabilities&&i.vulnerabilities.length>0||i.socketReport&&i.socketReport.alerts.length>0):n.filter(i=>i.updateType===e)),r){const i=r.toLowerCase();n=n.filter(o=>o.packageName.toLowerCase().includes(i))}return n},"filterEntries");class Bs{static{$(this,"UpdateStore")}static{er(this,"UpdateStore")}#e;#t=new Set;#n;#o=null;constructor(e,r=null){this.#n=e,r&&(this.#o=new Map(r.recommendations.map(n=>[n.package,n]))),this.#e={aiResult:r,allChecked:!0,applyProgress:null,checkedEntries:new Set(e.map(n=>n.packageName)),entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",groupedByCatalog:Tr(e),phase:"browsing",selectedIndex:0}}getSnapshot=er(()=>this.#e,"getSnapshot");subscribe=er(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries(){return Ar(this.#n,this.#e.filterType,this.#e.filterText)}getRecommendation(e){return this.#o?.get(e)}getCheckedEntries(){return this.#n.filter(e=>this.#e.checkedEntries.has(e.packageName))}setSelectedIndex(e){const r=this.getFilteredEntries(),n=Math.max(0,Math.min(e,r.length-1));n!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:n})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:e})}setFilterType(e){if(e!==this.#e.filterType){const r=Ar(this.#n,e,this.#e.filterText);this.#r({...this.#e,entries:r,filterType:e,groupedByCatalog:Tr(r),selectedIndex:0})}}setFilter(e){const r=Ar(this.#n,this.#e.filterType,e);this.#r({...this.#e,entries:r,filterText:e,groupedByCatalog:Tr(r),selectedIndex:0})}setFilterActive(e){if(e!==this.#e.filterActive)if(e)this.#r({...this.#e,filterActive:!0});else{const r=Ar(this.#n,this.#e.filterType,"");this.#r({...this.#e,entries:r,filterActive:!1,filterText:"",groupedByCatalog:Tr(r),selectedIndex:0})}}toggleCheck(e){const r=new Set(this.#e.checkedEntries);r.has(e)?r.delete(e):r.add(e),this.#r({...this.#e,allChecked:r.size===this.#n.length,checkedEntries:r})}checkAll(){this.#r({...this.#e,allChecked:!0,checkedEntries:new Set(this.#n.map(e=>e.packageName))})}uncheckAll(){this.#r({...this.#e,allChecked:!1,checkedEntries:new Set})}toggleAll(){this.#e.allChecked?this.uncheckAll():this.checkAll()}startApply(){const e=this.getCheckedEntries();this.#r({...this.#e,applyProgress:{current:0,total:e.length},phase:"applying"})}updateApplyProgress(e){this.#e.applyProgress&&this.#r({...this.#e,applyProgress:{...this.#e.applyProgress,current:e}})}markDone(){this.#r({...this.#e,phase:"done"})}setError(e){this.#r({...this.#e,error:e,phase:"error"})}#r(e){this.#e=e;for(const r of this.#t)try{r()}catch{}}}var Sp=Object.defineProperty,Cp=$((t,e)=>Sp(t,"name",{value:e,configurable:!0}),"f$c");const jt=Cp(({autoExitSeconds:t,onCancel:e,visible:r})=>{const{exit:n}=Gt(),[i,o]=ce(t||3),s=be(null),l=be(0);qe(()=>(r&&(o(t||3),l.current=Date.now(),s.current=setInterval(()=>{o(f=>Math.max(0,f-1))},1e3)),()=>{s.current&&(clearInterval(s.current),s.current=null)}),[r,t]),qe(()=>{i<=0&&r&&(s.current&&(clearInterval(s.current),s.current=null),n())},[i,r,n]);const d=Ye(()=>{s.current&&(clearInterval(s.current),s.current=null),e()},[e]);return De((f,p)=>{Date.now()-l.current<200||(f==="q"?n():d())},{isActive:r}),c(xt,{backgroundColor:"#1e1e1e",footer:u(a,{dimColor:!0,children:["Press"," ",c(a,{bold:!0,color:"white",children:"q"})," ","to exit,"," ",c(a,{bold:!0,color:"white",children:"any key"})," ","to stay"]}),title:`Exiting in ${i}…`,visible:r,width:50,children:c(a,{dimColor:!0,children:"Stay to explore the results interactively."})})},"QuitDialog");var Ep=Object.defineProperty,jp=$((t,e)=>Ep(t,"name",{value:e,configurable:!0}),"d$e");const Tp={major:"red",minor:"yellow",patch:"green"},Ap={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},Ip={critical:"red",high:"red",low:"gray",medium:"yellow"},Rp={critical:"red",high:"red",low:"green",medium:"yellow"},Op={defer:"gray",review:"yellow",skip:"red",update:"green"},Pp=jp(({changelogUrl:t,entry:e,focused:r,recommendation:n,scrollRef:i})=>{const o=r?"white":"gray";if(!e)return c(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:c(a,{dimColor:!0,children:"No package selected"})});const s=Tp[e.updateType]??"white",l=e.vulnerabilities&&e.vulnerabilities.length>0,d=e.socketReport?.score.overall??0,f=e.socketReport?fr(d):"gray";return u(g,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c(g,{flexShrink:0,paddingTop:1,paddingX:2,children:c(a,{bold:!0,color:"white",children:e.packageName})}),u(zt,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[c(a,{}),u(g,{children:[c(g,{width:12,children:c(a,{dimColor:!0,children:"Current:"})}),c(a,{children:e.currentRange})]}),u(g,{children:[c(g,{width:12,children:c(a,{dimColor:!0,children:"Target:"})}),c(a,{children:e.newRange}),u(a,{bold:!0,color:s,children:[" ","(",e.updateType,")"]})]}),u(g,{children:[c(g,{width:12,children:c(a,{dimColor:!0,children:"Version:"})}),c(a,{children:e.targetVersion})]}),u(g,{children:[c(g,{width:12,children:c(a,{dimColor:!0,children:"Catalog:"})}),c(a,{children:e.catalogName})]}),e.acceptedRisk&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{color:"gray",children:"── "}),c(a,{bold:!0,color:"gray",children:"ACKNOWLEDGED RISK"}),u(g,{flexDirection:"column",paddingLeft:2,children:[u(g,{children:[c(a,{dimColor:!0,children:"Reason: "}),c(a,{children:e.acceptedRisk.reason})]}),u(g,{children:[c(a,{dimColor:!0,children:"Accepted: "}),c(a,{children:e.acceptedRisk.acceptedAt.slice(0,10)})]})]})]}),l&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"red",children:"SECURITY"}),c(a,{}),e.vulnerabilities.map(p=>u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{gap:1,children:[u(a,{bold:!0,color:Ap[p.severity]??"gray",children:["⚠"," ",p.severity]}),c(a,{bold:!0,children:p.id})]}),c(g,{paddingLeft:2,children:c(a,{children:p.summary})}),u(g,{gap:2,paddingLeft:2,children:[p.cvssScore!==void 0&&u(a,{dimColor:!0,children:["CVSS:",String(p.cvssScore)]}),p.fixedVersions.length>0&&u(a,{dimColor:!0,children:["Fixed in:",p.fixedVersions.join(", ")]})]})]},p.id))]}),e.socketReport&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"cyan",children:"SOCKET.DEV"}),c(a,{}),u(g,{gap:2,children:[u(g,{children:[c(a,{dimColor:!0,children:"Overall: "}),u(a,{bold:!0,color:f,children:[String(Math.round(d*100)),"%"]})]}),u(g,{children:[c(a,{dimColor:!0,children:"Supply Chain: "}),u(a,{children:[String(Math.round(e.socketReport.score.supplyChain*100)),"%"]})]}),u(g,{children:[c(a,{dimColor:!0,children:"Quality: "}),u(a,{children:[String(Math.round(e.socketReport.score.quality*100)),"%"]})]})]}),u(g,{gap:2,children:[u(g,{children:[c(a,{dimColor:!0,children:"Maintenance: "}),u(a,{children:[String(Math.round(e.socketReport.score.maintenance*100)),"%"]})]}),u(g,{children:[c(a,{dimColor:!0,children:"Vulnerability: "}),u(a,{children:[String(Math.round(e.socketReport.score.vulnerability*100)),"%"]})]}),u(g,{children:[c(a,{dimColor:!0,children:"License: "}),u(a,{children:[e.socketReport.license||"unknown"," ","(",String(Math.round(e.socketReport.score.license*100)),"%)"]})]})]}),e.socketReport.alerts.length>0&&u(g,{flexDirection:"column",marginTop:1,children:[u(a,{bold:!0,color:"yellow",children:["⚠"," ",String(e.socketReport.alerts.length)," ","alert",e.socketReport.alerts.length===1?"":"s",":"]}),e.socketReport.alerts.map(p=>u(g,{gap:1,paddingLeft:2,children:[u(a,{bold:!0,color:Ip[p.severity]??"gray",children:["[",p.severity.toUpperCase(),"]"]}),c(a,{children:p.type}),u(a,{dimColor:!0,children:["(",p.category,")"]})]},p.key))]})]}),n&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"AI ANALYSIS"}),c(a,{}),u(g,{gap:2,children:[u(g,{children:[c(a,{dimColor:!0,children:"Action: "}),c(a,{bold:!0,color:Op[n.action]??"white",children:n.action})]}),u(g,{children:[c(a,{dimColor:!0,children:"Risk: "}),c(a,{bold:!0,color:Rp[n.riskLevel]??"white",children:n.riskLevel})]}),u(g,{children:[c(a,{dimColor:!0,children:"Effort: "}),c(a,{bold:!0,children:n.effort})]})]}),n.reason&&c(g,{marginTop:1,paddingLeft:2,children:c(a,{children:n.reason})}),n.breakingChanges.length>0&&u(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[c(a,{bold:!0,color:"yellow",children:"Breaking changes:"}),n.breakingChanges.map((p,h)=>u(a,{children:[" ","•"," ",p]},String(h)))]})]}),t&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"CHANGELOG"}),c(g,{marginTop:1,paddingLeft:2,children:c(a,{color:"cyan",underline:!0,children:t})})]}),u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"LINKS"}),c(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:u(a,{color:"cyan",underline:!0,children:["https://npmx.dev/",e.packageName]})})]}),!n&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"GUIDANCE"}),u(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.updateType==="major"&&u(Zt,{children:[u(a,{color:"red",children:["⚠"," ","Major update — likely contains breaking changes."]}),c(a,{dimColor:!0,children:" Review the changelog before updating."}),c(a,{dimColor:!0,children:" Use --changelog to fetch release URLs."})]}),e.updateType==="minor"&&u(Zt,{children:[u(a,{color:"yellow",children:["ℹ"," ","Minor update — new features, backward compatible."]}),c(a,{dimColor:!0,children:" Generally safe to update."})]}),e.updateType==="patch"&&u(Zt,{children:[u(a,{color:"green",children:["✓"," ","Patch update — bug fixes only."]}),c(a,{dimColor:!0,children:" Safe to update."})]}),!n&&c(a,{dimColor:!0,children:" Use --ai to get AI-powered analysis."})]})]})]})]})},"PackageDetailPanel");var Np=Object.defineProperty,so=$((t,e)=>Np(t,"name",{value:e,configurable:!0}),"b$g");const Dp={major:"red",minor:"yellow",patch:"green"},Mp=[{id:"all",label:"All"},{id:"major",label:"Major"},{id:"minor",label:"Minor"},{id:"patch",label:"Patch"},{id:"security",label:"Security"}],Bp=so(({checked:t,entry:e,isSelected:r})=>{const n=Dp[e.updateType]??"white",i=e.vulnerabilities&&e.vulnerabilities.length>0,o=e.socketReport&&e.socketReport.alerts.length>0,s=!!e.acceptedRisk,l=t?"☑":"☐",d=e.socketReport?`${String(Math.round(e.socketReport.score.overall*100))}%`:"",f=e.socketReport?fr(e.socketReport.score.overall):"gray";return u(g,{flexShrink:0,height:1,children:[c(a,{children:r?">":" "}),u(a,{color:t?"white":"gray",children:[" ",l," "]}),i||o?c(a,{color:s?"gray":"red",children:s?"✓ ":"⚠ "}):c(a,{children:" "}),c(g,{flexGrow:1,children:u(a,{bold:r,inverse:r,wrap:"truncate",children:[e.packageName,s?" [ack]":""]})}),d&&u(a,{color:f,children:[" ",d]}),u(a,{dimColor:!0,children:[" ",e.currentRange]}),u(a,{dimColor:!0,children:[" ","→"," "]}),u(a,{children:[e.newRange," "]}),c(a,{bold:!0,color:n,children:e.updateType})]})},"PackageRow"),Lp=so(({count:t,name:e})=>u(g,{flexShrink:0,height:1,marginTop:1,children:[u(a,{dimColor:!0,children:["▼"," "]}),c(a,{bold:!0,color:"white",children:e.toUpperCase()}),u(a,{dimColor:!0,children:[" ","(",t,")"]})]}),"CatalogHeader"),Fp=so(({checkedEntries:t,entries:e,filterActive:r,filterText:n,filterType:i,filteredOutCount:o,focused:s,groupedByCatalog:l,isDryRun:d,scrollOffset:f,selectedIndex:p,totalCatalogEntries:h,totalChecked:m,totalEntries:y,viewportHeight:b})=>{const x=s?"white":"gray";let S=0,C=0,D=0,P=0;for(const v of e)v.updateType==="major"?S++:v.updateType==="minor"?C++:D++,(v.vulnerabilities&&v.vulnerabilities.length>0||v.socketReport&&v.socketReport.alerts.length>0)&&P++;const M=[];S>0&&M.push(`${S} major`),C>0&&M.push(`${C} minor`),D>0&&M.push(`${D} patch`),P>0&&M.push(`${P} vulnerable`);const E=M.length>0?` (${M.join(", ")})`:"";let R=0;for(const v of e)t.has(v.packageName)&&R++;const A=[];let G=0;for(const[v,j]of l){A.push(c(Lp,{count:j.length,name:v},`hdr-${v}`));for(const U of j){const z=G;A.push(c(Bp,{checked:t.has(U.packageName),entry:U,isSelected:z===p},U.packageName)),G++}}let B=0;for(const[,v]of l)B+=2+v.length;const w=B>b&&b>0;return u(g,{borderColor:x,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),u(a,{wrap:"truncate",children:[y,m>0?`/${m}`:""," ","outdated",E,h>m?` · ${h-m} dupes`:""]}),!d&&R>0&&u(a,{dimColor:!0,children:[" ","—",R," ","selected"]})]}),c(g,{flexShrink:0,paddingX:1,paddingY:1,children:c(Li,{isFocused:s,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:$(()=>{},"onChange"),showIndex:!1,value:i,children:Mp.map(({id:v,label:j})=>c(Fi,{name:v,children:j},v))})}),r&&u(g,{flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:"white",children:"/ "}),c(a,{children:n}),c(a,{inverse:!0,children:" "})]}),o>0&&c(g,{flexShrink:0,paddingX:1,children:u(a,{color:"yellow",children:["⚠"," ",o," ","package",o===1?"":"s"," ","filtered out by target constraint — press"," ",c(a,{bold:!0,color:"white",children:"f"})," ","to view"]})}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-f,children:A})}),w&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:B,placement:"inset",scrollOffset:f,style:"block",viewportHeight:b})})]},`list-${i}-${n}`)]})},"PackageListPanel");var Vp=Object.defineProperty,Up=$((t,e)=>Vp(t,"name",{value:e,configurable:!0}),"Y$1");const Gp=100,zp=40,Wp=10,_p=[],Ls=Up(({autoExitSeconds:t=0,changelogUrls:e,checkedCount:r=0,filteredOutEntries:n=_p,isDryRun:i,store:o,totalCatalogEntries:s=0})=>{const{exit:l}=Gt(),{columns:d,rows:f}=Ut(),p=pr(o.subscribe,o.getSnapshot),[h,m]=ce(!1),[y,b]=ce(!1),x=be(null),S=be(null),C=be(null),D=be(null),[P,M]=ce(0),[E,R]=ce(!1),[A,G]=ce(!1),B=Ke(()=>o.getFilteredEntries(),[p.entries,p.filterType,p.filterText]),w=B[p.selectedIndex]??null,v=w?o.getRecommendation(w.packageName):void 0,j=w&&e?e.get(w.packageName):void 0,U=Ye(J=>{let q=0,se=0;for(const[,je]of p.groupedByCatalog){q+=2;for(let Ot=0;Ot<je.length;Ot++){if(se===J)return q;q+=1,se++}}return q},[p.groupedByCatalog]),z=Math.max(1,f-8-(p.filterActive?1:0)),Z=Ye(J=>{const q=U(J);M(se=>q>se+z-2?Math.max(0,q-z+2):q<se+1?Math.max(0,q-1):se)},[U,z]);if(qe(()=>{C.current?.scrollToTop()},[w?.packageName]),De((J,q)=>{if(J==="c"&&q.ctrl){l();return}if(!A){if(y){q.escape||J==="f"||J==="q"?b(!1):q.downArrow||J==="j"?S.current?.scrollBy(1):(q.upArrow||J==="k")&&S.current?.scrollBy(-1);return}if(E){J==="u"||q.return?(R(!1),o.startApply(),l(o.getCheckedEntries())):q.escape||J==="q"?R(!1):q.downArrow||J==="j"?D.current?.scrollBy(1):q.upArrow||J==="k"?D.current?.scrollBy(-1):q.pageDown?D.current?.scrollBy(5):q.pageUp&&D.current?.scrollBy(-5);return}if(h){q.escape||J==="?"?m(!1):J==="q"?(m(!1),G(!0)):q.downArrow||J==="j"?x.current?.scrollBy(1):(q.upArrow||J==="k")&&x.current?.scrollBy(-1);return}if(J==="?"){m(!0);return}if(J==="q"){G(!0);return}if(q.tab){o.setFocusedPanel(p.focusedPanel==="list"?"detail":"list");return}if(p.focusedPanel==="list"&&(q.leftArrow||q.rightArrow)){const se=["all","major","minor","patch","security"],je=se.indexOf(p.filterType),Ot=q.rightArrow?(je+1)%se.length:(je-1+se.length)%se.length;M(0),C.current?.scrollToTop(),o.setFilterType(se[Ot]);return}if(J==="f"&&n.length>0){b(se=>!se);return}if(p.filterActive){if(q.escape){o.setFilterActive(!1);return}if(q.return){o.setFilterActive(!1);return}if(q.backspace){M(0),o.setFilter(p.filterText.slice(0,-1));return}if(J&&!q.ctrl&&!q.meta){M(0),o.setFilter(p.filterText+J);return}return}if(p.focusedPanel==="list"){if(q.downArrow||J==="j"){const se=Math.min(p.selectedIndex+1,B.length-1);o.setSelectedIndex(se),Z(se);return}if(q.upArrow||J==="k"){const se=Math.max(p.selectedIndex-1,0);o.setSelectedIndex(se),Z(se);return}if(q.pageDown){const se=Math.min(p.selectedIndex+10,B.length-1);o.setSelectedIndex(se),Z(se);return}if(q.pageUp){const se=Math.max(p.selectedIndex-10,0);o.setSelectedIndex(se),Z(se);return}if(q.home){o.setSelectedIndex(0),M(0);return}if(q.end){const se=B.length-1;o.setSelectedIndex(se),Z(se);return}if(J===" "||q.return){w&&o.toggleCheck(w.packageName);return}if(J==="a"){o.toggleAll();return}if(J==="/"){o.setFilterActive(!0);return}if(J==="u"&&!i&&p.checkedEntries.size>0){R(!0);return}if(q.rightArrow){o.setFocusedPanel("detail");return}return}if(p.focusedPanel==="detail"){if(q.escape||q.leftArrow){o.setFocusedPanel("list");return}if(q.downArrow||J==="j"){C.current?.scrollBy(1);return}if(q.upArrow||J==="k"){C.current?.scrollBy(-1);return}if(q.pageDown){C.current?.scrollBy(10);return}if(q.pageUp){C.current?.scrollBy(-10);return}if(q.home){C.current?.scrollToTop();return}q.end&&C.current?.scrollToBottom()}}},{isActive:!0}),d<zp||f<Wp)return c(g,{alignItems:"center",height:f,justifyContent:"center",width:d,children:u(a,{color:"yellow",children:["Terminal too small (",d,"x",f,")"]})});const he=d>=Gp,oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Space"}),c(a,{dimColor:!0,children:"CHECK"})]},"sp"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"a"}),c(a,{dimColor:!0,children:"ALL"})]},"a")];!i&&p.checkedEntries.size>0&&oe.push(u(g,{gap:1,children:[c(a,{bold:!0,color:"green",children:"u"}),c(a,{dimColor:!0,children:"APPLY"})]},"u")),n.length>0&&oe.push(u(g,{gap:1,children:[c(a,{bold:!0,color:"yellow",children:"f"}),u(a,{dimColor:!0,children:["FILTERED (",n.length,")"]})]},"fo")),oe.push(u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"←→"}),c(a,{dimColor:!0,children:"FILTER"})]},"lr"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"/"}),c(a,{dimColor:!0,children:"SEARCH"})]},"f"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"t"));const Te=c(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:c(g,{flexWrap:"wrap",gap:2,paddingX:1,children:oe})}),ke=u(xt,{footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"?"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:x,title:"KEYBOARD SHORTCUTS",visible:h,width:52,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Move up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Move down"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Tab"]}),c(a,{dimColor:!0,children:" Switch panel"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","→","/","←"]}),c(a,{dimColor:!0,children:" Focus detail/list"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"SELECTION"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Space"]}),c(a,{dimColor:!0,children:" Toggle check on package"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","a"]}),c(a,{dimColor:!0,children:" Toggle check all"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"FILTERS"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","←→"]}),c(a,{dimColor:!0,children:" Switch filter tab"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","/"]}),c(a,{dimColor:!0,children:" Text filter"})]}),n.length>0&&u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","f"]}),c(a,{dimColor:!0,children:" View filtered-out packages"})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"ACTIONS"})]}),!i&&u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","u"]}),c(a,{dimColor:!0,children:" Apply selected updates"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","q"]}),c(a,{dimColor:!0,children:" Quit"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","?"]}),c(a,{dimColor:!0,children:" Toggle help"})]})]})]}),Se=o.getCheckedEntries(),O=Se.filter(J=>J.updateType==="major").length,I=u(g,{alignItems:"center",flexDirection:"column",children:[O>0&&c(g,{marginBottom:1,marginTop:1,children:u(a,{color:"yellow",children:["⚠"," ",O," ","major update",O===1?"":"s"," ","— review breaking changes"]})}),u(a,{dimColor:!0,children:["Press"," ",c(a,{bold:!0,color:"white",children:"u"})," ","or"," ",c(a,{bold:!0,color:"white",children:"Enter"})," ","to confirm,"," ",c(a,{bold:!0,color:"white",children:"Esc"})," ","to cancel"]})]}),Y=c(xt,{footer:I,scrollRef:D,title:`Apply ${Se.length} update${Se.length===1?"":"s"}?`,visible:E,width:70,children:Se.map(J=>u(g,{gap:1,children:[u(a,{children:[" ",J.packageName]}),u(a,{dimColor:!0,children:[J.currentRange," ","→"," ",J.newRange]}),c(a,{bold:!0,color:J.updateType==="major"?"red":J.updateType==="minor"?"yellow":"green",children:J.updateType})]},J.packageName))}),ye=n.length>0?c(xt,{footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"f"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:S,title:`${n.length} PACKAGE${n.length===1?"":"S"} FILTERED BY TARGET`,visible:y,width:70,children:u(g,{flexDirection:"column",children:[c(g,{marginBottom:1,children:u(a,{dimColor:!0,children:["These packages have newer versions available but are excluded by"," ","the current target constraint. Use"," ",c(a,{bold:!0,color:"white",children:"--target latest"})," ","to include them."]})}),n.map(J=>u(g,{gap:1,children:[u(a,{children:[" ",J.packageName]}),u(a,{dimColor:!0,children:[J.currentRange," ","→"," ",J.newRange]}),c(a,{bold:!0,color:J.updateType==="major"?"red":J.updateType==="minor"?"yellow":"green",children:J.updateType})]},J.packageName))]})}):null,Ae=c(Fp,{checkedEntries:p.checkedEntries,entries:B,filterActive:p.filterActive,filterText:p.filterText,filterType:p.filterType,filteredOutCount:n.length,focused:p.focusedPanel==="list",groupedByCatalog:p.groupedByCatalog,isDryRun:i,scrollOffset:P,selectedIndex:p.selectedIndex,totalCatalogEntries:s,totalChecked:r,totalEntries:B.length,viewportHeight:z}),Ce=c(Pp,{changelogUrl:j,entry:w,focused:p.focusedPanel==="detail",recommendation:v,scrollRef:C});if(he){const J=Math.floor(d*.35);return u(g,{flexDirection:"column",height:f,width:d,children:[u(g,{flexDirection:"row",flexGrow:1,children:[c(g,{flexGrow:1,children:Ae}),c(g,{width:J,children:Ce})]}),Te,Y,ye,c(jt,{autoExitSeconds:t||3,onCancel:$(()=>{G(!1)},"onCancel"),visible:A}),ke]})}const it=Math.floor(f*.55);return u(g,{flexDirection:"column",height:f,width:d,children:[c(g,{height:it,children:Ae}),c(g,{flexGrow:1,children:Ce}),Te,Y,ye,c(jt,{autoExitSeconds:t||3,onCancel:$(()=>{G(!1)},"onCancel"),visible:A}),ke]})},"VisUpdateApp");var Hp=Object.defineProperty,Jp=$((t,e)=>Hp(t,"name",{value:e,configurable:!0}),"T$6");const qp={group:"Security & Health",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"]],execute:Jp(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=i;if(r.securityConfig){const R=me(o);if(tp(n??{},R.name),r.sync&&R.name==="pnpm"){const A=rp(n??{});if(A.length>0){k(`
|
|
131
|
-
|
|
132
|
-
`);
|
|
133
|
-
`);
|
|
145
|
+
`;d=/npmAuditIgnoreAdvisories:/.test(d)?d.replace(/npmAuditIgnoreAdvisories:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,p):`${d.trimEnd()}
|
|
146
|
+
|
|
147
|
+
${p}`,Q(o,d),n.push(`Synced ${String(c)} advisor${c===1?"y":"ies"} to .yarnrc.yml (${String(a.length)} total)`);break}default:n.push(`Unknown package manager: ${t}`)}return n},"syncAcceptedRisksToNativeConfig");var fv=Object.defineProperty,Gt=b((t,e)=>fv(t,"name",{value:e,configurable:!0}),"k$k");const Ql=Gt(t=>{const e=w(t,"node_modules");if(!T(e))return[];const r=[],n=w(t,"package.json");let o=new Set;if(T(n))try{const s=ue(n);o=new Set(Object.keys(s.devDependencies??{}))}catch{}const i=Gt((s,a)=>{let c;try{c=Ge(s)}catch{return}for(const d of c){if(d.startsWith("."))continue;const p=w(s,d);if(d.startsWith("@")){i(p,`${d}/`);continue}const g=a+d,m=w(p,"package.json");try{if(!br(p).isDirectory()||!T(m))continue;const y=ue(m);y.version&&r.push({isDev:o.has(g),name:g,version:y.version});const v=w(p,"node_modules");T(v)&&i(v,"")}catch{}}},"scanDir");return i(e,""),r},"scanInstalledPackages"),gv={bun:{file:"bun.lock",type:"bun"},npm:{file:"package-lock.json",type:"npm"},pnpm:{file:"pnpm-lock.yaml",type:"pnpm"},yarn:{file:"yarn.lock",type:"yarn"}},Zl=Gt((t,e)=>{const r=gv[e];if(!r)return[];let n;try{n=ee(w(t,r.file))}catch{return[]}const o=Sc(n,r.type);if(o.length===0)return[];const i=new Map;for(const a of o)i.has(a.name)||i.set(a.name,new Set),i.get(a.name).add(a.version);const s=[];for(const[a,c]of i)c.size<=1||s.push({name:a,versions:[...c]});return s.sort((a,c)=>a.name.localeCompare(c.name))},"findDuplicateDependencies"),ri={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},hv={critical:Ue,high:Ac,low:st,medium:Re},ni=Gt((t,e)=>{const r=ri[e.toUpperCase()]??ri.MODERATE??2;return(ri[t.toUpperCase()]??4)<=r},"severityPassesFilter"),mv={CRITICAL:Ue,HIGH:Ac,LOW:st,MODERATE:Re,UNKNOWN:be},yv=Gt((t,e,r,n)=>{const o=mv[r.severity]??be,i=n?` ${be("[acknowledged]")}`:"",s=r.fixedVersions??[],a=s.length>0?` (fix: ${s.join(", ")})`:"";return` ${o(r.severity)} ${r.id} — ${t}@${e}${i}
|
|
148
|
+
${r.summary}${a}`},"formatVulnLine"),vv=Gt((t,e)=>{const r=Vr(t),n=`${String(Math.round(t.score.overall*100))}%`,o=e?` ${be("[acknowledged]")}`:"",i=t.alerts.length>0?`, ${String(t.alerts.length)} alert${t.alerts.length===1?"":"s"}`:"";return` ${n} ${r}@${t.version} (${Yi(t.score.overall)}${i})${o}`},"formatSocketLine"),wv=Gt(async(t,e,r,n)=>{const o=e.severity??"low",i=e.format==="json"||!!e.json,s=!!e.fix,a=!!e.showAccepted,c=r?.security?.socket,d=c?.acceptedRisks,p=Ne(t),g=dv(t,p.name);(g.ignoredAdvisories.length>0||g.excludedPackages.length>0)&&S(`Loaded ${String(g.ignoredAdvisories.length)} ignored advisor${g.ignoredAdvisories.length===1?"y":"ies"} and ${String(g.excludedPackages.length)} excluded package${g.excludedPackages.length===1?"":"s"} from ${p.name} config.`),S("Scanning installed packages...");const m=Ql(t);if(m.length===0){S("No packages found in node_modules. Run your package manager's install command first.");return}S(`Found ${String(m.length)} packages.
|
|
149
|
+
`);const y=m.map(C=>({name:C.name,version:C.version})),v=Er(c),k=Zl(t,p.name),[$,x]=await Promise.all([Do(y),v?Xr(y,v):Promise.resolve(new Map)]),E=[];for(const C of m){if(uv(C.name,g))continue;const j=$.get(C.name)??[],R=x.get(`${C.name}@${C.version}`),V=Ki(C.name,C.version,d),P=j.length>0,B=R?R.score.overall<Qt:!1,q=R?R.alerts.length>0:!1;(P||B||q)&&E.push({acceptedRisk:V,name:C.name,socketReport:R,version:C.version,vulnerabilities:j})}const A=E.filter(C=>{const j=C.vulnerabilities.some(P=>ni(P.severity,o)),R=C.socketReport?.alerts.some(P=>ni(P.severity==="medium"?"MODERATE":P.severity.toUpperCase(),o)),V=C.socketReport&&C.socketReport.score.overall<Qt;return j||R||V});if(i){const C={duplicates:k.map(j=>({name:j.name,versionCount:j.versions.length,versions:j.versions})),packages:m.length,results:A.map(j=>({acceptedRisk:j.acceptedRisk??null,name:j.name,socketAlerts:j.socketReport?.alerts??[],socketScore:j.socketReport?.score.overall??null,version:j.version,vulnerabilities:j.vulnerabilities})),summary:{accepted:A.filter(j=>j.acceptedRisk).length,duplicatePackages:k.length,issues:A.filter(j=>!j.acceptedRisk).length,total:A.length}};process.stdout.write(`${JSON.stringify(C,void 0,2)}
|
|
150
|
+
`),e.exitCode&&C.summary.issues>0&&(process.exitCode=1);return}if(A.length===0){Z(`No security issues found across ${String(m.length)} packages.`);return}const L={CRITICAL:[],HIGH:[],LOW:[],MODERATE:[]};for(const C of A)for(const j of C.vulnerabilities)if(ni(j.severity,o)){const R=j.severity==="UNKNOWN"?"LOW":j.severity;L[R]?.push({entry:C,vuln:j})}let I=0,M=0;for(const C of["CRITICAL","HIGH","MODERATE","LOW"]){const j=L[C];if(!(!j||j.length===0)){S(`
|
|
151
|
+
── ${C} (${String(j.length)}) ──`);for(const{entry:R,vuln:V}of j){const P=!!R.acceptedRisk||wa(V.id,g,V.aliases);P&&(M++,!a)||(I++,S(yv(R.name,R.version,V,P)),s&&(V.fixedVersions??[]).length>0&&ie(` Fix: update to ${V.fixedVersions.at(-1)}`))}}}const F=A.filter(C=>C.socketReport&&(C.socketReport.score.overall<Qt||C.socketReport.alerts.length>0));if(F.length>0){S(`
|
|
152
|
+
── Socket.dev Supply Chain (${String(F.length)}) ──`);for(const C of F){if(!C.socketReport)continue;const j=!!C.acceptedRisk;if(!(j&&!a)){S(vv(C.socketReport,j));for(const R of C.socketReport.alerts){const V=hv[R.severity]??be;S(` ${V(`[${R.severity.toUpperCase()}]`)} ${R.type} — ${R.category}`)}}}}if(k.length>0){S(`
|
|
153
|
+
── Duplicate Dependencies (${String(k.length)}) ──`);for(const C of k){const j=C.versions.join(", ");S(` ${C.name} — ${String(C.versions.length)} versions: ${Re(j)}`)}}const _=Gt(C=>!!C.acceptedRisk||C.vulnerabilities.length>0&&C.vulnerabilities.every(j=>wa(j.id,g,j.aliases)),"isEntryExcluded"),N=A.filter(C=>!_(C)).length;if(S(""),S("─ Audit Summary"),S(` ${String(m.length)} packages scanned`),g.ignoredAdvisories.length>0&&S(` ${String(g.ignoredAdvisories.length)} ${p.name} audit exclusion${g.ignoredAdvisories.length===1?"":"s"} applied`),I>0){const C=L.CRITICAL?.filter(R=>!_(R.entry)).length??0,j=L.HIGH?.filter(R=>!_(R.entry)).length??0;er(` ${String(I)} vulnerabilit${I===1?"y":"ies"} found`),C>0&&er(` ${String(C)} critical`),j>0&&se(` ${String(j)} high`)}else Z(" No vulnerabilities found");if(F.length>0){const C=F.filter(j=>!_(j)).length;se(` ${String(C)} package${C===1?"":"s"} with Socket.dev supply chain issues`)}if(k.length>0&&(se(` ${String(k.length)} package${k.length===1?"":"s"} with duplicate versions`),ie(" Run 'vis dedupe' or your package manager's dedupe command to reduce duplicates.")),M>0&&(S(` ${String(M)} acknowledged (accepted risks)`),a||ie(" Use --show-accepted to see acknowledged issues.")),N===0&&Z(`
|
|
154
|
+
All issues are acknowledged. No action required.`),e.sync&&d){const C=new Set;for(const R of E)if(R.acceptedRisk){for(const V of R.vulnerabilities)if((V.id.startsWith("CVE-")||V.id.startsWith("GHSA-"))&&C.add(V.id),V.aliases)for(const P of V.aliases)(P.startsWith("CVE-")||P.startsWith("GHSA-"))&&C.add(P)}const j=[...C];if(j.length>0){S("");const R=pv(p.name,t,j);for(const V of R)Z(` ${V}`)}else S(`
|
|
155
|
+
No advisory IDs to sync to native PM config.`)}e.exitCode&&N>0&&(process.exitCode=1)},"executeAudit"),kv={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 --fix","Show fix suggestions for vulnerabilities"],["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)"]],execute:Gt(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");await wv(n,e,r,t)},"execute"),group:"Security & Health",name:"audit",options:[{description:"Minimum severity to report: low, medium, high, critical (default: low)",name:"severity",type:String},{description:"Output format: table or json (default: table)",name:"format",type:String},{defaultValue:!1,description:"Show fix suggestions for vulnerabilities",name:"fix",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}]};var bv=Object.defineProperty,_r=b((t,e)=>bv(t,"name",{value:e,configurable:!0}),"e$7");const ed=_r((t,e,r)=>{const n=_r(o=>nt(o)?o:$e(t,o),"normalize");return e&&e.length>0?n(e):r&&r.length>0?n(r):$e(t,Gu)},"resolveCacheDirectory"),$v=/[^\w.-]+/g,Sv=/^-+|-+$/g,xv=_r(t=>t.trim().replaceAll($v,"-").replaceAll(Sv,"").slice(0,64),"sanitizeBranchSegment"),Cv=_r(t=>{try{const e=Vc("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return!e||e==="HEAD"?void 0:e}catch{return}},"detectGitBranch"),jv=_r((t,e,r)=>{if(r!==!0)return t;const n=Cv(e);if(!n)return t;const o=xv(n);return o.length===0?t:$e(t,"branches",o)},"applyBranchScope"),Tv=_r((t,e)=>{const r=_e(e,t);return r.length===0?!1:!(r===".."||r.startsWith("../"))&&!nt(r)},"isCacheDirectoryInsideWorkspace");var Ev=Object.defineProperty,Jt=b((t,e)=>Ev(t,"name",{value:e,configurable:!0}),"l$m");const td=Jt(async t=>{let e=0;try{const r=await Uc(t,{withFileTypes:!0});for(const n of r){const o=w(t,n.name);if(n.isDirectory())e+=await td(o);else if(n.isFile()){const i=await _c(o);e+=i.size}}}catch{}return e},"sumDirectorySize"),Sn=Jt(async t=>{const e=[];let r;try{r=await Uc(t)}catch{return[]}for(const n of r){if(n.startsWith("."))continue;const o=w(t,n);try{const i=await _c(o);if(!i.isDirectory())continue;const s=await td(o);e.push({hash:n,mtimeMs:i.mtimeMs,path:o,sizeBytes:s})}catch{}}return e.sort((n,o)=>o.mtimeMs-n.mtimeMs),e},"collectCacheEntries"),Rv=Jt((t,e=Date.now())=>{const r=Math.floor((e-t)/1e3);return r<60?`${String(r)}s`:r<3600?`${String(Math.floor(r/60))}m`:r<86400?`${String(Math.floor(r/3600))}h`:`${String(Math.floor(r/86400))}d`},"formatAge"),Iv=Jt(t=>new Promise(e=>{const r=dt({input:process.stdin,output:process.stderr});r.question(`${t} (y/N) `,n=>{r.close();const o=n.trim().toLowerCase();e(o==="y"||o==="yes")})}),"confirmPrompt"),Av=Jt(async(t,e,r)=>{if(!T(t)){if(e==="json"){process.stdout.write(`${JSON.stringify({directory:t,entries:[],totalBytes:0,totalCount:0},void 0,2)}
|
|
156
|
+
`);return}S(`No cache directory found at ${t}`);return}const n=await Sn(t);if(n.length===0){if(e==="json"){process.stdout.write(`${JSON.stringify({directory:t,entries:[],totalBytes:0,totalCount:0},void 0,2)}
|
|
157
|
+
`);return}S(`Cache directory is empty: ${t}`);return}const o=n.reduce((p,g)=>p+g.sizeBytes,0);if(e==="json"){const p=Date.now();process.stdout.write(`${JSON.stringify({directory:t,entries:n.map(g=>({ageMs:p-g.mtimeMs,hash:g.hash,mtimeIso:new Date(g.mtimeMs).toISOString(),sizeBytes:g.sizeBytes})),totalBytes:o,totalCount:n.length},void 0,2)}
|
|
158
|
+
`);return}S(`Cache directory: ${t}`),S(`Entries: ${String(n.length)} (${wn(o,{decimals:1,space:!1})})`),r.info("");const i=Date.now(),s=n.map(p=>({age:Rv(p.mtimeMs,i),hash:p.hash.slice(0,12),size:wn(p.sizeBytes,{decimals:1,space:!1})})),a=Math.max(4,...s.map(p=>p.hash.length)),c=Math.max(4,...s.map(p=>p.size.length)),d=Math.max(3,...s.map(p=>p.age.length));r.info(` ${"hash".padEnd(a)} ${"size".padEnd(c)} ${"age".padEnd(d)}`),r.info(` ${"-".repeat(a)} ${"-".repeat(c)} ${"-".repeat(d)}`);for(const p of s)r.info(` ${p.hash.padEnd(a)} ${p.size.padEnd(c)} ${p.age.padEnd(d)}`)},"runList"),Ov=Jt(async(t,e,r)=>{if(!T(t)){S(`No cache directory to clean at ${t}`);return}if(r.dryRun){const o=await Sn(t),i=o.reduce((s,a)=>s+a.sizeBytes,0);S(`Would remove ${String(o.length)} cache entr${o.length===1?"y":"ies"} (${wn(i,{decimals:1,space:!1})}) from ${t}`);return}const n=Tv(t,e);try{const o=await Ls(t),i=await Ls(e);if(o===i){ze("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!n&&!r.force){if(se(`Cache directory is outside the workspace root: ${t}`),se("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){ze("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await Iv(" Continue?")){S("Aborted.");return}}n?await new Tc({cacheDirectory:t,workspaceRoot:e}).clear():await vp(t,{force:!0,recursive:!0}),Z(`Cleared cache: ${t}`)},"runClean"),Pv=Jt(async(t,e,r)=>{if(!T(t)){S(`No cache directory to prune at ${t}`);return}if(r.maxCacheAgeDays!==void 0&&(!Number.isFinite(r.maxCacheAgeDays)||r.maxCacheAgeDays<0)){ze(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(r.maxCacheAgeDays)}`),process.exitCode=1;return}if(r.maxCacheSize!==void 0){let p;try{p=Wu(r.maxCacheSize)}catch(g){ze(`Invalid --max-size value: ${g instanceof Error?g.message:String(g)}`),process.exitCode=1;return}if(!Number.isFinite(p)||p<=0){ze(`Invalid --max-size value: expected a positive size, got "${r.maxCacheSize}" (${String(p)} bytes)`),process.exitCode=1;return}}const n=r.maxCacheAgeDays===void 0?void 0:r.maxCacheAgeDays*24*60*60*1e3,o=await Sn(t),i=o.reduce((p,g)=>p+g.sizeBytes,0);await new Tc({cacheDirectory:t,maxCacheAge:n,maxCacheSize:r.maxCacheSize,workspaceRoot:e}).removeOldEntries();const s=await Sn(t),a=s.reduce((p,g)=>p+g.sizeBytes,0),c=o.length-s.length,d=i-a;if(c<=0){S("Nothing to prune — all entries are within the configured limits.");return}Z(`Pruned ${String(c)} entr${c===1?"y":"ies"}, freed ${wn(d,{decimals:1,space:!1})}.`)},"runPrune"),Nv=Jt(async(t,e)=>{if(!T(t)){if(e==="json"){process.stdout.write(`${JSON.stringify({directory:t,exists:!1,totalBytes:0,totalCount:0})}
|
|
159
|
+
`);return}S(`No cache directory at ${t}`);return}const r=await Sn(t),n=r.reduce((o,i)=>o+i.sizeBytes,0);if(e==="json"){process.stdout.write(`${JSON.stringify({directory:t,exists:!0,totalBytes:n,totalCount:r.length})}
|
|
160
|
+
`);return}S(`Cache directory: ${t}`),S(`Entries: ${String(r.length)}`),S(`Total size: ${wn(n,{decimals:1,space:!1})}`)},"runSize"),Mv={argument:{description:"Action to perform: list, clean, prune, or size",name:"action",type:String},description:"Manage the task runner cache (list, clean, prune, size)",examples:[["vis cache list","List all cache entries"],["vis cache clean","Remove all cache entries"],["vis cache clean --dry-run","Preview what clean would remove"],["vis cache prune","Remove old and oversized entries"],["vis cache prune --max-age-days=3 --max-size=500MB","Prune with custom limits"],["vis cache size --format=json","Print total size as JSON"]],execute:Jt(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{const i=o??process.cwd(),s=t[0]??"list",a=r.format??"table",c=n?.taskRunnerOptions??{},d=ed(i,r.cacheDir,c.cacheDirectory);switch(s){case"clean":{await Ov(d,i,{dryRun:!!r.dryRun,force:!!r.force});break}case"list":{await Av(d,a,e);break}case"prune":{await Pv(d,i,{maxCacheAgeDays:typeof r.maxAgeDays=="number"?r.maxAgeDays:void 0,maxCacheSize:r.maxSize});break}case"size":{await Nv(d,a);break}default:ze(`Unknown action "${s}". Use "list", "clean", "prune", or "size".`),process.exitCode=1}},"execute"),group:"Workspace",name:"cache",options:[{description:"Cache directory (overrides config and default). Relative paths are resolved against the workspace root.",name:"cache-dir",type:String},{description:"Output format: table or json (default: table)",name:"format",type:String},{defaultValue:!1,description:"For clean: preview without deleting",name:"dry-run",type:Boolean},{defaultValue:!1,description:"For clean: skip the confirmation prompt for out-of-workspace cache directories",name:"force",type:Boolean},{description:"For prune: remove entries older than N days",name:"max-age-days",type:Number},{description:"For prune: evict oldest entries until cache is under this size (e.g. 500MB)",name:"max-size",type:String}]};var Dv=Object.defineProperty,Bv=b((t,e)=>Dv(t,"name",{value:e,configurable:!0}),"a$i");function xn({current:t,total:e}){const{columns:r}=zr(),n=r||80,o=e>0?t/e:0,i=`${String(Math.round(o*100))}%`,s=Math.max(10,n-4),a=Math.round(s*o),c=s-a;return f(h,{flexDirection:"column",paddingX:1,children:[f(h,{children:[u(Vi,{type:"dots"}),f(l,{children:[" ","Checking",String(e)," ","catalog dependencies"," "]}),f(l,{dimColor:!0,children:[String(t),"/",String(e)]})]}),f(h,{children:[u(l,{color:"cyan",children:"━".repeat(a)}),u(l,{dimColor:!0,children:"─".repeat(c)}),f(l,{children:[" ",i]})]})]})}b(xn,"f$m");Bv(xn,"CheckProgressApp");var Fv=Object.defineProperty,mn=b((t,e)=>Fv(t,"name",{value:e,configurable:!0}),"r$k");const Xn=mn(t=>{const e=new Map;for(const r of t){const n=e.get(r.catalogName);n?n.push(r):e.set(r.catalogName,[r])}return e},"groupByCatalog"),Qn=mn((t,e,r)=>{let n=t;if(e!=="all"&&(n=e==="security"?n.filter(o=>o.vulnerabilities&&o.vulnerabilities.length>0||o.socketReport&&o.socketReport.alerts.length>0):n.filter(o=>o.updateType===e)),r){const o=r.toLowerCase();n=n.filter(i=>i.packageName.toLowerCase().includes(o))}return n},"filterEntries");class rd{static{b(this,"UpdateStore")}static{mn(this,"UpdateStore")}#e;#t=new Set;#n;#o=null;constructor(e,r=null){this.#n=e,r&&(this.#o=new Map(r.recommendations.map(n=>[n.package,n]))),this.#e={aiResult:r,allChecked:!0,applyProgress:null,checkedEntries:new Set(e.map(n=>n.packageName)),entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",groupedByCatalog:Xn(e),phase:"browsing",selectedIndex:0}}getSnapshot=mn(()=>this.#e,"getSnapshot");subscribe=mn(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries(){return Qn(this.#n,this.#e.filterType,this.#e.filterText)}getRecommendation(e){return this.#o?.get(e)}getCheckedEntries(){return this.#n.filter(e=>this.#e.checkedEntries.has(e.packageName))}setSelectedIndex(e){const r=this.getFilteredEntries(),n=Math.max(0,Math.min(e,r.length-1));n!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:n})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:e})}setFilterType(e){if(e!==this.#e.filterType){const r=Qn(this.#n,e,this.#e.filterText);this.#r({...this.#e,entries:r,filterType:e,groupedByCatalog:Xn(r),selectedIndex:0})}}setFilter(e){const r=Qn(this.#n,this.#e.filterType,e);this.#r({...this.#e,entries:r,filterText:e,groupedByCatalog:Xn(r),selectedIndex:0})}setFilterActive(e){if(e!==this.#e.filterActive)if(e)this.#r({...this.#e,filterActive:!0});else{const r=Qn(this.#n,this.#e.filterType,"");this.#r({...this.#e,entries:r,filterActive:!1,filterText:"",groupedByCatalog:Xn(r),selectedIndex:0})}}toggleCheck(e){const r=new Set(this.#e.checkedEntries);r.has(e)?r.delete(e):r.add(e),this.#r({...this.#e,allChecked:r.size===this.#n.length,checkedEntries:r})}checkAll(){this.#r({...this.#e,allChecked:!0,checkedEntries:new Set(this.#n.map(e=>e.packageName))})}uncheckAll(){this.#r({...this.#e,allChecked:!1,checkedEntries:new Set})}toggleAll(){this.#e.allChecked?this.uncheckAll():this.checkAll()}startApply(){const e=this.getCheckedEntries();this.#r({...this.#e,applyProgress:{current:0,total:e.length},phase:"applying"})}updateApplyProgress(e){this.#e.applyProgress&&this.#r({...this.#e,applyProgress:{...this.#e.applyProgress,current:e}})}markDone(){this.#r({...this.#e,phase:"done"})}setError(e){this.#r({...this.#e,error:e,phase:"error"})}#r(e){this.#e=e;for(const r of this.#t)try{r()}catch{}}}var Lv=Object.defineProperty,Vv=b((t,e)=>Lv(t,"name",{value:e,configurable:!0}),"f$l");const xr=Vv(({autoExitSeconds:t,onCancel:e,visible:r})=>{const{exit:n}=Hr(),[o,i]=ve(t||3),s=Ve(null),a=Ve(0);Rt(()=>(r&&(i(t||3),a.current=Date.now(),s.current=setInterval(()=>{i(d=>Math.max(0,d-1))},1e3)),()=>{s.current&&(clearInterval(s.current),s.current=null)}),[r,t]),Rt(()=>{o<=0&&r&&(s.current&&(clearInterval(s.current),s.current=null),n())},[o,r,n]);const c=It(()=>{s.current&&(clearInterval(s.current),s.current=null),e()},[e]);return mt((d,p)=>{Date.now()-a.current<200||(d==="q"?n():c())},{isActive:r}),u(wr,{backgroundColor:"#1e1e1e",footer:f(l,{dimColor:!0,children:["Press"," ",u(l,{bold:!0,color:"white",children:"q"})," ","to exit,"," ",u(l,{bold:!0,color:"white",children:"any key"})," ","to stay"]}),title:`Exiting in ${o}…`,visible:r,width:50,children:u(l,{dimColor:!0,children:"Stay to explore the results interactively."})})},"QuitDialog");var Uv=Object.defineProperty,_v=b((t,e)=>Uv(t,"name",{value:e,configurable:!0}),"d$r");const Gv={major:"red",minor:"yellow",patch:"green"},Wv={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},zv={critical:"red",high:"red",low:"gray",medium:"yellow"},Hv={critical:"red",high:"red",low:"green",medium:"yellow"},qv={defer:"gray",review:"yellow",skip:"red",update:"green"},Jv=_v(({changelogUrl:t,entry:e,focused:r,recommendation:n,scrollRef:o})=>{const i=r?"white":"gray";if(!e)return u(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:u(l,{dimColor:!0,children:"No package selected"})});const s=Gv[e.updateType]??"white",a=e.vulnerabilities&&e.vulnerabilities.length>0,c=e.socketReport?.score.overall??0,d=e.socketReport?Mn(c):"gray";return f(h,{borderColor:i,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(h,{flexShrink:0,paddingTop:1,paddingX:2,children:u(l,{bold:!0,color:"white",children:e.packageName})}),f(qr,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[u(l,{}),f(h,{children:[u(h,{width:12,children:u(l,{dimColor:!0,children:"Current:"})}),u(l,{children:e.currentRange})]}),f(h,{children:[u(h,{width:12,children:u(l,{dimColor:!0,children:"Target:"})}),u(l,{children:e.newRange}),f(l,{bold:!0,color:s,children:[" ","(",e.updateType,")"]})]}),f(h,{children:[u(h,{width:12,children:u(l,{dimColor:!0,children:"Version:"})}),u(l,{children:e.targetVersion})]}),f(h,{children:[u(h,{width:12,children:u(l,{dimColor:!0,children:"Catalog:"})}),u(l,{children:e.catalogName})]}),e.acceptedRisk&&f(h,{flexDirection:"column",marginTop:1,children:[u(l,{color:"gray",children:"── "}),u(l,{bold:!0,color:"gray",children:"ACKNOWLEDGED RISK"}),f(h,{flexDirection:"column",paddingLeft:2,children:[f(h,{children:[u(l,{dimColor:!0,children:"Reason: "}),u(l,{children:e.acceptedRisk.reason})]}),f(h,{children:[u(l,{dimColor:!0,children:"Accepted: "}),u(l,{children:e.acceptedRisk.acceptedAt.slice(0,10)})]})]})]}),a&&f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"red",children:"SECURITY"}),u(l,{}),e.vulnerabilities.map(p=>f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{gap:1,children:[f(l,{bold:!0,color:Wv[p.severity]??"gray",children:["⚠"," ",p.severity]}),u(l,{bold:!0,children:p.id})]}),u(h,{paddingLeft:2,children:u(l,{children:p.summary})}),f(h,{gap:2,paddingLeft:2,children:[p.cvssScore!==void 0&&f(l,{dimColor:!0,children:["CVSS:",String(p.cvssScore)]}),p.fixedVersions.length>0&&f(l,{dimColor:!0,children:["Fixed in:",p.fixedVersions.join(", ")]})]})]},p.id))]}),e.socketReport&&f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"cyan",children:"SOCKET.DEV"}),u(l,{}),f(h,{gap:2,children:[f(h,{children:[u(l,{dimColor:!0,children:"Overall: "}),f(l,{bold:!0,color:d,children:[String(Math.round(c*100)),"%"]})]}),f(h,{children:[u(l,{dimColor:!0,children:"Supply Chain: "}),f(l,{children:[String(Math.round(e.socketReport.score.supplyChain*100)),"%"]})]}),f(h,{children:[u(l,{dimColor:!0,children:"Quality: "}),f(l,{children:[String(Math.round(e.socketReport.score.quality*100)),"%"]})]})]}),f(h,{gap:2,children:[f(h,{children:[u(l,{dimColor:!0,children:"Maintenance: "}),f(l,{children:[String(Math.round(e.socketReport.score.maintenance*100)),"%"]})]}),f(h,{children:[u(l,{dimColor:!0,children:"Vulnerability: "}),f(l,{children:[String(Math.round(e.socketReport.score.vulnerability*100)),"%"]})]}),f(h,{children:[u(l,{dimColor:!0,children:"License: "}),f(l,{children:[e.socketReport.license||"unknown"," ","(",String(Math.round(e.socketReport.score.license*100)),"%)"]})]})]}),e.socketReport.alerts.length>0&&f(h,{flexDirection:"column",marginTop:1,children:[f(l,{bold:!0,color:"yellow",children:["⚠"," ",String(e.socketReport.alerts.length)," ","alert",e.socketReport.alerts.length===1?"":"s",":"]}),e.socketReport.alerts.map(p=>f(h,{gap:1,paddingLeft:2,children:[f(l,{bold:!0,color:zv[p.severity]??"gray",children:["[",p.severity.toUpperCase(),"]"]}),u(l,{children:p.type}),f(l,{dimColor:!0,children:["(",p.category,")"]})]},p.key))]})]}),n&&f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"AI ANALYSIS"}),u(l,{}),f(h,{gap:2,children:[f(h,{children:[u(l,{dimColor:!0,children:"Action: "}),u(l,{bold:!0,color:qv[n.action]??"white",children:n.action})]}),f(h,{children:[u(l,{dimColor:!0,children:"Risk: "}),u(l,{bold:!0,color:Hv[n.riskLevel]??"white",children:n.riskLevel})]}),f(h,{children:[u(l,{dimColor:!0,children:"Effort: "}),u(l,{bold:!0,children:n.effort})]})]}),n.reason&&u(h,{marginTop:1,paddingLeft:2,children:u(l,{children:n.reason})}),n.breakingChanges.length>0&&f(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[u(l,{bold:!0,color:"yellow",children:"Breaking changes:"}),n.breakingChanges.map((p,g)=>f(l,{children:[" ","•"," ",p]},String(g)))]})]}),t&&f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"CHANGELOG"}),u(h,{marginTop:1,paddingLeft:2,children:u(l,{color:"cyan",underline:!0,children:t})})]}),f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"LINKS"}),u(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:f(l,{color:"cyan",underline:!0,children:["https://npmx.dev/",e.packageName]})})]}),!n&&f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"GUIDANCE"}),f(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.updateType==="major"&&f(gn,{children:[f(l,{color:"red",children:["⚠"," ","Major update — likely contains breaking changes."]}),u(l,{dimColor:!0,children:" Review the changelog before updating."}),u(l,{dimColor:!0,children:" Use --changelog to fetch release URLs."})]}),e.updateType==="minor"&&f(gn,{children:[f(l,{color:"yellow",children:["ℹ"," ","Minor update — new features, backward compatible."]}),u(l,{dimColor:!0,children:" Generally safe to update."})]}),e.updateType==="patch"&&f(gn,{children:[f(l,{color:"green",children:["✓"," ","Patch update — bug fixes only."]}),u(l,{dimColor:!0,children:" Safe to update."})]}),!n&&u(l,{dimColor:!0,children:" Use --ai to get AI-powered analysis."})]})]})]})]})},"PackageDetailPanel");var Yv=Object.defineProperty,ls=b((t,e)=>Yv(t,"name",{value:e,configurable:!0}),"b$j");const Kv={major:"red",minor:"yellow",patch:"green"},Xv=[{id:"all",label:"All"},{id:"major",label:"Major"},{id:"minor",label:"Minor"},{id:"patch",label:"Patch"},{id:"security",label:"Security"}],Qv=ls(({checked:t,entry:e,isSelected:r})=>{const n=Kv[e.updateType]??"white",o=e.vulnerabilities&&e.vulnerabilities.length>0,i=e.socketReport&&e.socketReport.alerts.length>0,s=!!e.acceptedRisk,a=t?"☑":"☐",c=e.socketReport?`${String(Math.round(e.socketReport.score.overall*100))}%`:"",d=e.socketReport?Mn(e.socketReport.score.overall):"gray";return f(h,{flexShrink:0,height:1,children:[u(l,{children:r?">":" "}),f(l,{color:t?"white":"gray",children:[" ",a," "]}),o||i?u(l,{color:s?"gray":"red",children:s?"✓ ":"⚠ "}):u(l,{children:" "}),u(h,{flexGrow:1,children:f(l,{bold:r,inverse:r,wrap:"truncate",children:[e.packageName,s?" [ack]":""]})}),c&&f(l,{color:d,children:[" ",c]}),f(l,{dimColor:!0,children:[" ",e.currentRange]}),f(l,{dimColor:!0,children:[" ","→"," "]}),f(l,{children:[e.newRange," "]}),u(l,{bold:!0,color:n,children:e.updateType})]})},"PackageRow"),Zv=ls(({count:t,name:e})=>f(h,{flexShrink:0,height:1,marginTop:1,children:[f(l,{dimColor:!0,children:["▼"," "]}),u(l,{bold:!0,color:"white",children:e.toUpperCase()}),f(l,{dimColor:!0,children:[" ","(",t,")"]})]}),"CatalogHeader"),ew=ls(({checkedEntries:t,entries:e,filterActive:r,filteredOutCount:n,filterText:o,filterType:i,focused:s,groupedByCatalog:a,isDryRun:c,scrollOffset:d,selectedIndex:p,totalCatalogEntries:g,totalChecked:m,totalEntries:y,viewportHeight:v})=>{const k=s?"white":"gray";let $=0,x=0,E=0,A=0;for(const j of e)j.updateType==="major"?$++:j.updateType==="minor"?x++:E++,(j.vulnerabilities&&j.vulnerabilities.length>0||j.socketReport&&j.socketReport.alerts.length>0)&&A++;const L=[];$>0&&L.push(`${$} major`),x>0&&L.push(`${x} minor`),E>0&&L.push(`${E} patch`),A>0&&L.push(`${A} vulnerable`);const I=L.length>0?` (${L.join(", ")})`:"";let M=0;for(const j of e)t.has(j.packageName)&&M++;const F=[];let _=0;for(const[j,R]of a){F.push(u(Zv,{count:R.length,name:j},`hdr-${j}`));for(const V of R){const P=_;F.push(u(Qv,{checked:t.has(V.packageName),entry:V,isSelected:P===p},V.packageName)),_++}}let N=0;for(const[,j]of a)N+=2+j.length;const C=N>v&&v>0;return f(h,{borderColor:k,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(h,{flexShrink:0,gap:1,paddingX:1,children:[u(l,{bold:!0,inverse:!0,children:" VIS "}),f(l,{wrap:"truncate",children:[y,m>0?`/${m}`:""," ","outdated",I,g>m?` · ${g-m} dupes`:""]}),!c&&M>0&&f(l,{dimColor:!0,children:[" ","—",M," ","selected"]})]}),u(h,{flexShrink:0,paddingX:1,paddingY:1,children:u(Bc,{isFocused:s,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:b(()=>{},"onChange"),showIndex:!1,value:i,children:Xv.map(({id:j,label:R})=>u(Fc,{name:j,children:R},j))})}),r&&f(h,{flexShrink:0,paddingX:1,children:[u(l,{bold:!0,color:"white",children:"/ "}),u(l,{children:o}),u(l,{inverse:!0,children:" "})]}),n>0&&u(h,{flexShrink:0,paddingX:1,children:f(l,{color:"yellow",children:["⚠"," ",n," ","package",n===1?"":"s"," ","filtered out by target constraint — press"," ",u(l,{bold:!0,color:"white",children:"f"})," ","to view"]})}),f(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[u(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:u(h,{flexDirection:"column",marginTop:-d,children:F})}),C&&u(h,{flexShrink:0,marginLeft:1,marginRight:1,children:u(An,{contentHeight:N,placement:"inset",scrollOffset:d,style:"block",viewportHeight:v})})]},`list-${i}-${o}`)]})},"PackageListPanel");var tw=Object.defineProperty,rw=b((t,e)=>tw(t,"name",{value:e,configurable:!0}),"Y$2");const nw=100,ow=40,iw=10,sw=[],nd=rw(({autoExitSeconds:t=0,changelogUrls:e,checkedCount:r=0,filteredOutEntries:n=sw,isDryRun:o,store:i,totalCatalogEntries:s=0})=>{const{exit:a}=Hr(),{columns:c,rows:d}=zr(),p=On(i.subscribe,i.getSnapshot),[g,m]=ve(!1),[y,v]=ve(!1),k=Ve(null),$=Ve(null),x=Ve(null),E=Ve(null),[A,L]=ve(0),[I,M]=ve(!1),[F,_]=ve(!1),N=At(()=>i.getFilteredEntries(),[p.entries,p.filterType,p.filterText]),C=N[p.selectedIndex]??null,j=C?i.getRecommendation(C.packageName):void 0,R=C&&e?e.get(C.packageName):void 0,V=It(K=>{let te=0,fe=0;for(const[,Bt]of p.groupedByCatalog){te+=2;for(let Y=0;Y<Bt.length;Y++){if(fe===K)return te;te+=1,fe++}}return te},[p.groupedByCatalog]),P=Math.max(1,d-8-(p.filterActive?1:0)),B=It(K=>{const te=V(K);L(fe=>te>fe+P-2?Math.max(0,te-P+2):te<fe+1?Math.max(0,te-1):fe)},[V,P]);if(Rt(()=>{x.current?.scrollToTop()},[C?.packageName]),mt((K,te)=>{if(K==="c"&&te.ctrl){a();return}if(!F){if(y){te.escape||K==="f"||K==="q"?v(!1):te.downArrow||K==="j"?$.current?.scrollBy(1):(te.upArrow||K==="k")&&$.current?.scrollBy(-1);return}if(I){K==="u"||te.return?(M(!1),i.startApply(),a(i.getCheckedEntries())):te.escape||K==="q"?M(!1):te.downArrow||K==="j"?E.current?.scrollBy(1):te.upArrow||K==="k"?E.current?.scrollBy(-1):te.pageDown?E.current?.scrollBy(5):te.pageUp&&E.current?.scrollBy(-5);return}if(g){te.escape||K==="?"?m(!1):K==="q"?(m(!1),_(!0)):te.downArrow||K==="j"?k.current?.scrollBy(1):(te.upArrow||K==="k")&&k.current?.scrollBy(-1);return}if(K==="?"){m(!0);return}if(K==="q"){_(!0);return}if(te.tab){i.setFocusedPanel(p.focusedPanel==="list"?"detail":"list");return}if(p.focusedPanel==="list"&&(te.leftArrow||te.rightArrow)){const fe=["all","major","minor","patch","security"],Bt=fe.indexOf(p.filterType),Y=te.rightArrow?(Bt+1)%fe.length:(Bt-1+fe.length)%fe.length;L(0),x.current?.scrollToTop(),i.setFilterType(fe[Y]);return}if(K==="f"&&n.length>0){v(fe=>!fe);return}if(p.filterActive){if(te.escape){i.setFilterActive(!1);return}if(te.return){i.setFilterActive(!1);return}if(te.backspace){L(0),i.setFilter(p.filterText.slice(0,-1));return}if(K&&!te.ctrl&&!te.meta){L(0),i.setFilter(p.filterText+K);return}return}if(p.focusedPanel==="list"){if(te.downArrow||K==="j"){const fe=Math.min(p.selectedIndex+1,N.length-1);i.setSelectedIndex(fe),B(fe);return}if(te.upArrow||K==="k"){const fe=Math.max(p.selectedIndex-1,0);i.setSelectedIndex(fe),B(fe);return}if(te.pageDown){const fe=Math.min(p.selectedIndex+10,N.length-1);i.setSelectedIndex(fe),B(fe);return}if(te.pageUp){const fe=Math.max(p.selectedIndex-10,0);i.setSelectedIndex(fe),B(fe);return}if(te.home){i.setSelectedIndex(0),L(0);return}if(te.end){const fe=N.length-1;i.setSelectedIndex(fe),B(fe);return}if(K===" "||te.return){C&&i.toggleCheck(C.packageName);return}if(K==="a"){i.toggleAll();return}if(K==="/"){i.setFilterActive(!0);return}if(K==="u"&&!o&&p.checkedEntries.size>0){M(!0);return}if(te.rightArrow){i.setFocusedPanel("detail");return}return}if(p.focusedPanel==="detail"){if(te.escape||te.leftArrow){i.setFocusedPanel("list");return}if(te.downArrow||K==="j"){x.current?.scrollBy(1);return}if(te.upArrow||K==="k"){x.current?.scrollBy(-1);return}if(te.pageDown){x.current?.scrollBy(10);return}if(te.pageUp){x.current?.scrollBy(-10);return}if(te.home){x.current?.scrollToTop();return}te.end&&x.current?.scrollToBottom()}}},{isActive:!0}),c<ow||d<iw)return u(h,{alignItems:"center",height:d,justifyContent:"center",width:c,children:f(l,{color:"yellow",children:["Terminal too small (",c,"x",d,")"]})});const q=c>=nw,J=[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"q"}),u(l,{dimColor:!0,children:"QUIT"})]},"q"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"?"}),u(l,{dimColor:!0,children:"HELP"})]},"?"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"↑↓"}),u(l,{dimColor:!0,children:"NAV"})]},"nav"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"Space"}),u(l,{dimColor:!0,children:"CHECK"})]},"sp"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"a"}),u(l,{dimColor:!0,children:"ALL"})]},"a")];!o&&p.checkedEntries.size>0&&J.push(f(h,{gap:1,children:[u(l,{bold:!0,color:"green",children:"u"}),u(l,{dimColor:!0,children:"APPLY"})]},"u")),n.length>0&&J.push(f(h,{gap:1,children:[u(l,{bold:!0,color:"yellow",children:"f"}),f(l,{dimColor:!0,children:["FILTERED (",n.length,")"]})]},"fo")),J.push(f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"←→"}),u(l,{dimColor:!0,children:"FILTER"})]},"lr"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"/"}),u(l,{dimColor:!0,children:"SEARCH"})]},"f"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"Tab"}),u(l,{dimColor:!0,children:"PANEL"})]},"t"));const ce=u(h,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:u(h,{flexWrap:"wrap",gap:2,paddingX:1,children:J})}),le=f(wr,{footer:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",u(l,{bold:!0,color:"white",children:"?"}),"/",u(l,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:k,title:"KEYBOARD SHORTCUTS",visible:g,width:52,children:[f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"NAVIGATION"})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),u(l,{dimColor:!0,children:" Move up"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),u(l,{dimColor:!0,children:" Move down"})]})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Tab"]}),u(l,{dimColor:!0,children:" Switch panel"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","→","/","←"]}),u(l,{dimColor:!0,children:" Focus detail/list"})]})]}),f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"SELECTION"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Space"]}),u(l,{dimColor:!0,children:" Toggle check on package"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","a"]}),u(l,{dimColor:!0,children:" Toggle check all"})]})]}),f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"FILTERS"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","←→"]}),u(l,{dimColor:!0,children:" Switch filter tab"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","/"]}),u(l,{dimColor:!0,children:" Text filter"})]}),n.length>0&&f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","f"]}),u(l,{dimColor:!0,children:" View filtered-out packages"})]})]}),f(h,{flexDirection:"column",children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"ACTIONS"})]}),!o&&f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","u"]}),u(l,{dimColor:!0,children:" Apply selected updates"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","q"]}),u(l,{dimColor:!0,children:" Quit"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","?"]}),u(l,{dimColor:!0,children:" Toggle help"})]})]})]}),ke=i.getCheckedEntries(),D=ke.filter(K=>K.updateType==="major").length,O=f(h,{alignItems:"center",flexDirection:"column",children:[D>0&&u(h,{marginBottom:1,marginTop:1,children:f(l,{color:"yellow",children:["⚠"," ",D," ","major update",D===1?"":"s"," ","— review breaking changes"]})}),f(l,{dimColor:!0,children:["Press"," ",u(l,{bold:!0,color:"white",children:"u"})," ","or"," ",u(l,{bold:!0,color:"white",children:"Enter"})," ","to confirm,"," ",u(l,{bold:!0,color:"white",children:"Esc"})," ","to cancel"]})]}),z=u(wr,{footer:O,scrollRef:E,title:`Apply ${ke.length} update${ke.length===1?"":"s"}?`,visible:I,width:70,children:ke.map(K=>f(h,{gap:1,children:[f(l,{children:[" ",K.packageName]}),f(l,{dimColor:!0,children:[K.currentRange," ","→"," ",K.newRange]}),u(l,{bold:!0,color:K.updateType==="major"?"red":K.updateType==="minor"?"yellow":"green",children:K.updateType})]},K.packageName))}),me=n.length>0?u(wr,{footer:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",u(l,{bold:!0,color:"white",children:"f"}),"/",u(l,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:$,title:`${n.length} PACKAGE${n.length===1?"":"S"} FILTERED BY TARGET`,visible:y,width:70,children:f(h,{flexDirection:"column",children:[u(h,{marginBottom:1,children:f(l,{dimColor:!0,children:["These packages have newer versions available but are excluded by the current target constraint. Use"," ",u(l,{bold:!0,color:"white",children:"--target latest"})," ","to include them."]})}),n.map(K=>f(h,{gap:1,children:[f(l,{children:[" ",K.packageName]}),f(l,{dimColor:!0,children:[K.currentRange," ","→"," ",K.newRange]}),u(l,{bold:!0,color:K.updateType==="major"?"red":K.updateType==="minor"?"yellow":"green",children:K.updateType})]},K.packageName))]})}):null,Te=u(ew,{checkedEntries:p.checkedEntries,entries:N,filterActive:p.filterActive,filteredOutCount:n.length,filterText:p.filterText,filterType:p.filterType,focused:p.focusedPanel==="list",groupedByCatalog:p.groupedByCatalog,isDryRun:o,scrollOffset:A,selectedIndex:p.selectedIndex,totalCatalogEntries:s,totalChecked:r,totalEntries:N.length,viewportHeight:P}),Ie=u(Jv,{changelogUrl:R,entry:C,focused:p.focusedPanel==="detail",recommendation:j,scrollRef:x});if(q){const K=Math.floor(c*.35);return f(h,{flexDirection:"column",height:d,width:c,children:[f(h,{flexDirection:"row",flexGrow:1,children:[u(h,{flexGrow:1,children:Te}),u(h,{width:K,children:Ie})]}),ce,z,me,u(xr,{autoExitSeconds:t||3,onCancel:b(()=>{_(!1)},"onCancel"),visible:F}),le]})}const xt=Math.floor(d*.55);return f(h,{flexDirection:"column",height:d,width:c,children:[u(h,{height:xt,children:Te}),u(h,{flexGrow:1,children:Ie}),ce,z,me,u(xr,{autoExitSeconds:t||3,onCancel:b(()=>{_(!1)},"onCancel"),visible:F}),le]})},"VisUpdateApp");var aw=Object.defineProperty,cw=b((t,e)=>aw(t,"name",{value:e,configurable:!0}),"T$e");const lw={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"]],execute:cw(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=o;if(r.securityConfig){const M=Ne(i);if(tv(n??{},M.name),r.sync&&M.name==="pnpm"){const F=rv(n??{});if(F.length>0){S(`
|
|
161
|
+
Settings that would sync to pnpm-workspace.yaml:`);for(const _ of F)Z(` ${_}`)}else S("No security settings to sync.")}else r.sync&&M.name!=="pnpm"&&(S(`--sync is only available for pnpm projects. Your project uses ${M.name}.`),S("vis enforces security settings at the vis layer for non-pnpm projects."));if(!r.security&&!t?.length)return}const{packageManager:s}=$o(i),a=is(i),c=n?.update??{},d=Mo(i,s,{dev:r.dev,prod:r.prod});if(d.size===0){e.info("No catalogs found.");return}const p=r.target??c.target??"latest";if(!["latest","minor","patch"].includes(p))throw new Error(`Invalid target "${p}". Use: latest, minor, or patch.`);const g={exclude:[...yt(r.exclude),...yt(c.exclude)],ignore:yt(c.ignore),include:[...yt(r.include),...yt(c.include),...t],includeLocked:!!r.includeLocked,includePrerelease:r.prerelease||c.prerelease||!1,security:!r.noSecurity,target:p};let m=0;for(const M of d.values())m+=M.size;const y=!!process.stdout.isTTY&&!lt;let v;const k=y?(M,F)=>{v?v.rerender(X.createElement(xn,{current:M,total:F})):v=Ut(X.createElement(xn,{current:M,total:F}),{interactive:!0,patchConsole:!1})}:(M,F)=>{e.info(`Checking ${String(M)}/${String(F)} dependencies...`)};y||e.info(`Checking ${String(m)} catalog dependencies against npm registry...
|
|
162
|
+
`);const $=Er(n?.security?.socket),{failed:x,outdated:E}=await ss(d,g,a,k,i,$,n?.security?.socket?.acceptedRisks);if(v&&(v.clear(),v.unmount()),x.length>0&&e.warn(`Failed to fetch: ${x.join(", ")}`),E.length===0){e.info("All catalog dependencies are up to date.");return}const A=r.format??c.format??"table",L=ts(r.aiType??"impact"),I=r.ai?await rs(E,e,n?.ai,L):void 0;if(y&&A==="table"){const M=new rd(E,I??null),F=n?.tui?.autoExit??!1,_=F===!0?3:typeof F=="number"?F:0;await Ut(X.createElement(nd,{autoExitSeconds:_,isDryRun:!0,store:M}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const N=process.stdout.columns||80;process.stdout.write(`
|
|
163
|
+
`);for(const C of E){const j=C.vulnerabilities?.length||C.socketReport&&C.socketReport.alerts.length>0,R=!!C.acceptedRisk,V=j?R?"✓":"⚠":"✓",P=R?"gray":C.updateType==="major"?"red":C.updateType==="minor"?"yellow":"green",B=C.socketReport?.score.overall,q=B===void 0?"":` [${String(Math.round(B*100))}%]`,J=B===void 0?void 0:Mn(B);process.stdout.write(`${Oe(X.createElement(l,null," ",X.createElement(l,{color:P},V),` ${C.packageName} ${C.currentRange} → ${C.newRange}`,X.createElement(l,{dimColor:!0},` ${C.updateType}`),J?X.createElement(l,{color:J},q):null),{columns:N})}
|
|
134
164
|
`)}process.stdout.write(`
|
|
135
|
-
`),e.info(
|
|
136
|
-
`)}else
|
|
137
|
-
`):(
|
|
138
|
-
`);for(const[n,
|
|
139
|
-
`)}for(;;){const n=await
|
|
140
|
-
${re(`Enter choice (1-${String(r.length)}):`)} `),
|
|
141
|
-
`)}},"select"),
|
|
142
|
-
${
|
|
143
|
-
|
|
144
|
-
`);const r=t.inMonorepo?[{hint:"Scaffold via create-vite",label:"Vis Application",value:"vis:app"},{hint:"Reusable package scaffold",label:"Vis Library",value:"vis:library"},{hint:"Code generator scaffold",label:"Vis Generator",value:"vis:generator"},{hint:"Enter an npm create-* package or GitHub URL",label:"Custom template",value:"__custom__"}]:[{hint:"Full workspace setup",label:"Vis Monorepo",value:"vis:monorepo"},{hint:"Scaffold via create-vite",label:"Vis Application",value:"vis:app"},{hint:"Reusable package scaffold",label:"Vis Library",value:"vis:library"},{hint:"Code generator scaffold",label:"Vis Generator",value:"vis:generator"},{hint:"Enter an npm create-* package or GitHub URL",label:"Custom template",value:"__custom__"}];let n=await
|
|
145
|
-
${re("Template (npm package or GitHub URL):")} `),!n))throw new Error("No template specified.");const
|
|
146
|
-
${re(`Project name (${
|
|
147
|
-
`)):p=await
|
|
148
|
-
`),{editor:y,gitInit:
|
|
149
|
-
`,"libraryPackageJson"),
|
|
150
|
-
`,"libraryTsconfig")
|
|
165
|
+
`),e.info(fo(E))}else if(A==="json"){const M={failed:x,outdated:E};I&&(M.aiAnalysis=I),process.stdout.write(`${JSON.stringify(M,void 0,2)}
|
|
166
|
+
`)}else A==="minimal"?process.stdout.write(`${Wl(E)}
|
|
167
|
+
`):(zl(E,e),e.info(fo(E)),I&&(e.info(""),e.info(po(I))));r.exitCode&&E.length>0&&(process.exitCode=1)},"execute"),group:"Security & Health",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",defaultValue:!1,description:"Check only devDependencies (npm/yarn mode)",name:"dev",type:Boolean},{alias:"P",defaultValue:!1,description:"Check only dependencies (npm/yarn mode)",name:"prod",type:Boolean}]};var dw=Object.defineProperty,od=b((t,e)=>dw(t,"name",{value:e,configurable:!0}),"r$j");const uw=od(()=>process.env.GITHUB_BASE_REF?{base:`origin/${process.env.GITHUB_BASE_REF}`,head:process.env.GITHUB_SHA??"HEAD"}:process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME?{base:`origin/${process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME}`,head:process.env.CI_COMMIT_SHA??"HEAD"}:process.env.CIRCLE_BRANCH&&process.env.CIRCLE_SHA1?{base:"origin/main",head:process.env.CIRCLE_SHA1}:{base:"origin/main",head:"HEAD"},"detectCiRefs"),pw={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"]],execute:od(async({argument:t,logger:e,options:r,runtime:n,workspaceRoot:o})=>{const i=t[0];if(!i)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const s=i.split(",").map(g=>g.trim()).filter(Boolean);if(s.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const{base:a,head:c}=uw(),d=r.base??a,p=r.head??c;r.install===!1?e.info("▸ Skipping install (--no-install)"):(e.info("▸ Installing dependencies"),await n.runCommand("install",{argv:["--frozen-lockfile"]}));for(const g of s){e.info(`▸ Running affected ${g} (base=${d}, head=${p})`);const m=[g,`--base=${d}`,`--head=${p}`,`--upstream=${String(r.upstream??"none")}`,`--downstream=${String(r.downstream??"deep")}`];r.parallel!==void 0&&m.push(`--parallel=${String(r.parallel)}`),r.partition&&m.push(`--partition=${String(r.partition)}`),r.query&&m.push(`--query=${String(r.query)}`),await n.runCommand("affected",{argv:m})}e.info("▸ CI pipeline complete")},"execute"),group:"Run & Execute",name:"ci",options:[{defaultValue:!0,description:"Install dependencies before running targets (use --no-install to skip)",name:"install",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}]};var fw=Object.defineProperty,ds=b((t,e)=>fw(t,"name",{value:e,configurable:!0}),"a$g");const gw=ds(t=>{const e=[],r=[t];for(;r.length>0;){const n=r.pop();let o;try{o=Ge(n)}catch{continue}for(const i of o){const s=w(n,i);try{const a=Pc(s);if(a.isSymbolicLink()||!a.isDirectory())continue}catch{continue}i==="node_modules"?e.push(s):i!==".git"&&i!==".hg"&&r.push(s)}}return e},"findNodeModulesDirectories"),hw=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],mw=ds((t,e,r)=>{let n=0,o=!1;for(const i of hw){const s=w(t,i);if(T(s)){if(e){r.info(` ${s}`),n++;continue}try{Wr(s),Z(`Removed ${s}`),n++}catch(a){ze(`${s}: ${mi(a)}`),o=!0}}}return{hadError:o,removed:n}},"removeLockfiles"),yw={description:"Remove node_modules from all workspace projects",examples:[["vis clean","Remove all node_modules directories"],["vis clean --lockfile","Also remove lockfiles"],["vis clean --dry-run","Preview what would be removed"]],execute:ds(async({logger:t,options:e,workspaceRoot:r})=>{const n=r??process.cwd(),o=e.lockfile||!1;if(e.dryRun){const a=gw(n);if(a.length>0){S("Would remove:");for(const c of a)t.info(` ${c}`)}else S("No node_modules directories found.");o&&mw(n,!0,t);return}const i=Ao();if(!i){ze("Native bindings unavailable. Ensure the correct platform binary is installed."),process.exitCode=1;return}const s=i.cleanWorkspace(n,o);for(const a of s.removed)Z(`Removed ${a}`);for(const a of s.lockfilesRemoved)Z(`Removed ${a}`);for(const a of s.errors)ze(a);s.removed.length===0&&s.lockfilesRemoved.length===0?S("No node_modules directories found."):S(`Cleaned ${s.removed.length} node_modules director${s.removed.length===1?"y":"ies"}`),s.errors.length>0&&(process.exitCode=1)},"execute"),group:"Workspace",name:"clean",options:[{alias:"l",defaultValue:!1,description:"Also remove lockfiles (pnpm-lock.yaml, package-lock.json, etc.)",name:"lockfile",type:Boolean},{defaultValue:!1,description:"Preview what would be removed without deleting",name:"dry-run",type:Boolean}]};var vw=Object.defineProperty,Bo=b((t,e)=>vw(t,"name",{value:e,configurable:!0}),"e$6");const ww={"vis:app":"builtin:app","vis:application":"builtin:app","vis:generator":"builtin:generator","vis:lib":"builtin:library","vis:library":"builtin:library","vis:monorepo":"builtin:monorepo"},kw=["https://github.com/","https://gitlab.com/","https://bitbucket.org/","https://raw.githubusercontent.com/","https://git.sr.ht/","git@github.com:","git@gitlab.com:","git@bitbucket.org:","git@git.sr.ht:","github:","gh:","gitlab:","bitbucket:","sourcehut:","git:","http://","https://"],bw=Bo(t=>{for(const e of kw)if(t.startsWith(e))return!0;return!!(!t.startsWith("@")&&/^[^/#@][^/#]*\/[^/#]+/.test(t))},"isGitUrl"),$w=new Set(["sv"]),Sw=Bo(t=>{if($w.has(t)||t.startsWith("create-")||t.startsWith("@")&&t.includes("/create-"))return t;if(t.startsWith("@")){const e=t.indexOf("/");if(e!==-1){const r=t.slice(0,e),n=t.slice(e+1);return`${r}/create-${n}`}return t}return`create-${t}`},"expandCreateShorthand"),xw=Bo((t,e=[])=>{if(!t)throw new Error("No template specified.");const r=t.toLowerCase(),n=ww[r];return n?{args:e,source:r,type:n}:bw(t)?{args:e,source:t,type:"remote:git"}:{args:e,source:Sw(t),type:"remote:npm"}},"discoverTemplate"),Cw=Bo(t=>{switch(t){case"builtin:app":return"apps";case"builtin:generator":case"builtin:library":return"packages";default:return"."}},"inferParentDir");var jw=Object.defineProperty,Tw=b((t,e)=>jw(t,"name",{value:e,configurable:!0}),"o$g");const Ew=Tw(()=>`${Vs()}-${Vs()}`,"randomName");var Rw=Object.defineProperty,Ln=b((t,e)=>Rw(t,"name",{value:e,configurable:!0}),"r$i");const id=Ln(t=>t?wp(t).validForNewPackages:!1,"isValidPackageName"),Cn=Ln(t=>t.toLowerCase().trim().replaceAll(/\s+/g,"-").replaceAll(/[^a-z\d\-~]/g,"-").replace(/^[._-]+/,"").replaceAll(/-{2,}/g,"-").replace(/-$/,""),"toValidPackageName"),Iw=new Set([".DS_Store",".git",".gitkeep","Thumbs.db"]),sd=Ln(t=>T(t)?Ge(t).every(e=>Iw.has(e)):!0,"isEmptyDir"),Aw=Ln((t,e)=>{const r=$e(e,t);return{packageName:Cn(So(r)),targetDir:r}},"resolveTargetDir"),Ow=Ln(t=>sd(t),"canSafelyOverwrite");var Pw=Object.defineProperty,Fo=b((t,e)=>Pw(t,"name",{value:e,configurable:!0}),"l$l");const yn=Fo((t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),"ask"),oi=Fo(async(t,e,r=!0)=>{const n=await yn(t,` ${e} ${re(r?"[Y/n]":"[y/N]")} `);return n===""?r:n.toLowerCase()==="y"||n.toLowerCase()==="yes"},"confirm"),ka=Fo(async(t,e,r)=>{process.stderr.write(` ${e}
|
|
168
|
+
`);for(const[n,o]of r.entries()){const i=ye(Be(` ${String(n+1)}.`)),s=o.hint?re(` — ${o.hint}`):"";process.stderr.write(`${i} ${o.label}${s}
|
|
169
|
+
`)}for(;;){const n=await yn(t,`
|
|
170
|
+
${re(`Enter choice (1-${String(r.length)}):`)} `),o=Number.parseInt(n,10);if(o>=1&&o<=r.length)return r[o-1].value;const i=r.find(s=>s.value===n||s.label.toLowerCase()===n.toLowerCase());if(i)return i.value;process.stderr.write(` ${re("Invalid choice. Try again.")}
|
|
171
|
+
`)}},"select"),Nw=Fo(async t=>{const e=dt({input:process.stdin,output:process.stdout});try{process.stderr.write(`
|
|
172
|
+
${ye(Be("vis create"))} ${re("— project scaffolding")}
|
|
173
|
+
|
|
174
|
+
`);const r=t.inMonorepo?[{hint:"Scaffold via create-vite",label:"Vis Application",value:"vis:app"},{hint:"Reusable package scaffold",label:"Vis Library",value:"vis:library"},{hint:"Code generator scaffold",label:"Vis Generator",value:"vis:generator"},{hint:"Enter an npm create-* package or GitHub URL",label:"Custom template",value:"__custom__"}]:[{hint:"Full workspace setup",label:"Vis Monorepo",value:"vis:monorepo"},{hint:"Scaffold via create-vite",label:"Vis Application",value:"vis:app"},{hint:"Reusable package scaffold",label:"Vis Library",value:"vis:library"},{hint:"Code generator scaffold",label:"Vis Generator",value:"vis:generator"},{hint:"Enter an npm create-* package or GitHub URL",label:"Custom template",value:"__custom__"}];let n=await ka(e,"Select a template:",r);if(n==="__custom__"&&(n=await yn(e,`
|
|
175
|
+
${re("Template (npm package or GitHub URL):")} `),!n))throw new Error("No template specified.");const o=Ew(),i=await yn(e,`
|
|
176
|
+
${re(`Project name (${o}):`)} `)||o;if(!id(Cn(i)))throw new Error(`Invalid project name: "${i}". Must be a valid npm package name.`);const s=Cn(i),a=await yn(e,` ${re(`Target directory (${s}):`)} `)||s;let c=!1;const d=$e(t.cwd,a);if(!sd(d)&&(c=await oi(e,`Directory "${a}" is not empty. Overwrite?`,!1),!c))throw new Error("Aborted — directory not empty.");let p;t.inMonorepo||(t.defaultPm?(p=t.defaultPm,process.stderr.write(` ${re(`Package manager: ${p} (from config)`)}
|
|
177
|
+
`)):p=await ka(e,"Package manager:",[{label:"pnpm",value:"pnpm"},{label:"npm",value:"npm"},{label:"yarn",value:"yarn"},{label:"bun",value:"bun"}]));let g=!1;t.inMonorepo||(g=await oi(e,"Initialize a git repository?",t.defaultGitInit??!1));const m=t.defaultEditor==="vscode",y=await oi(e,"Generate VS Code configuration?",m)?"vscode":void 0;return process.stderr.write(`
|
|
178
|
+
`),{editor:y,gitInit:g,overwrite:c,pm:p,projectName:i,targetDir:a,template:n}}finally{e.close()}},"runInteractivePrompts");var Mw=Object.defineProperty,Rr=b((t,e)=>Mw(t,"name",{value:e,configurable:!0}),"i$d");const Dw=Rr((t,e)=>{S("Scaffolding application via create-vite...");const r=[_e(e.cwd,e.targetDir)||".",...t.args];return r.includes("--no-immediate")||r.push("--no-immediate"),Ji(e.pm,{additionalPackages:[],args:r,package:"create-vite",shellMode:!1,silent:!1},e.cwd,e.logger)},"executeApp"),Bw=Rr(t=>`${JSON.stringify({devDependencies:{typescript:"^5.0.0",vitest:"^3.0.0"},exports:{".":{default:"./dist/index.js",types:"./dist/index.d.ts"}},files:["dist"],main:"./dist/index.js",name:t,scripts:{build:"tsc",dev:"tsc --watch",test:"vitest run","test:watch":"vitest"},type:"module",types:"./dist/index.d.ts",version:"0.0.1"},null,4)}
|
|
179
|
+
`,"libraryPackageJson"),Fw=Rr(()=>`${JSON.stringify({compilerOptions:{declaration:!0,declarationMap:!0,esModuleInterop:!0,module:"Node16",moduleResolution:"Node16",outDir:"./dist",rootDir:"./src",skipLibCheck:!0,sourceMap:!0,strict:!0,target:"ES2022"},include:["src/**/*"]},null,4)}
|
|
180
|
+
`,"libraryTsconfig"),Lw=Rr(t=>`/**
|
|
151
181
|
* ${t} — library entry point.
|
|
152
182
|
*/
|
|
153
183
|
|
|
154
184
|
export const greet = (name: string): string => \`Hello from ${t}, \${name}!\`;
|
|
155
|
-
`,"librarySrcIndex"),
|
|
185
|
+
`,"librarySrcIndex"),Vw=Rr(t=>`import { describe, expect, it } from "vitest";
|
|
156
186
|
|
|
157
187
|
import { greet } from "../src/index";
|
|
158
188
|
|
|
@@ -161,12 +191,12 @@ describe("${t}", () => {
|
|
|
161
191
|
expect(greet("world")).toBe("Hello from ${t}, world!");
|
|
162
192
|
});
|
|
163
193
|
});
|
|
164
|
-
`,"libraryTestIndex"),
|
|
194
|
+
`,"libraryTestIndex"),Uw=Rr((t,e)=>{const{projectName:r,targetDir:n}=e;return S("Scaffolding library package..."),je(n),je(w(n,"src")),je(w(n,"__tests__")),Q(w(n,"package.json"),Bw(r)),Z("Created package.json"),Q(w(n,"tsconfig.json"),Fw()),Z("Created tsconfig.json"),Q(w(n,"src","index.ts"),Lw(r)),Z("Created src/index.ts"),Q(w(n,"__tests__","index.test.ts"),Vw(r)),Z("Created __tests__/index.test.ts"),Q(w(n,".gitignore"),`node_modules/
|
|
165
195
|
dist/
|
|
166
196
|
.env
|
|
167
197
|
.DS_Store
|
|
168
|
-
`),
|
|
169
|
-
`,"packageJson"),
|
|
198
|
+
`),Z("Created .gitignore"),0},"executeLibrary"),_w=Rr((t,e)=>{switch(t.type){case"builtin:app":return Dw(t,e);case"builtin:library":return Uw(t,e);default:throw new Error(`Unknown built-in template type: ${t.type}`)}},"executeBuiltin");var Gw=Object.defineProperty,Vn=b((t,e)=>Gw(t,"name",{value:e,configurable:!0}),"n$8");const Ww=Vn((t,e)=>`${JSON.stringify({bin:{[t]:"./bin/index.js"},description:e,devDependencies:{typescript:"^5.0.0"},name:t,private:!0,scripts:{build:"tsc",dev:"tsc --watch"},type:"module",version:"0.0.1"},null,4)}
|
|
199
|
+
`,"packageJson"),zw=Vn(t=>`#!/usr/bin/env node
|
|
170
200
|
|
|
171
201
|
/**
|
|
172
202
|
* ${t} — code generator
|
|
@@ -175,19 +205,19 @@ dist/
|
|
|
175
205
|
*/
|
|
176
206
|
|
|
177
207
|
console.log("Hello from ${t}!");
|
|
178
|
-
`,"binIndex"),
|
|
179
|
-
`,"tsconfigJson"),
|
|
208
|
+
`,"binIndex"),Hw=Vn(()=>`${JSON.stringify({compilerOptions:{declaration:!0,esModuleInterop:!0,module:"Node16",moduleResolution:"Node16",outDir:"./dist",rootDir:"./src",skipLibCheck:!0,strict:!0,target:"ES2022"},include:["src/**/*","bin/**/*"]},null,4)}
|
|
209
|
+
`,"tsconfigJson"),qw=Vn(()=>`/**
|
|
180
210
|
* Generator core logic — export functions used by the CLI entry point.
|
|
181
211
|
*/
|
|
182
212
|
|
|
183
213
|
export const generate = (): void => {
|
|
184
214
|
// TODO: Implement your generator logic here
|
|
185
215
|
};
|
|
186
|
-
`,"srcIndex"),
|
|
187
|
-
`,"rootPackageJson"),
|
|
216
|
+
`,"srcIndex"),Jw=Vn((t,e="")=>{const{projectName:r,targetDir:n}=t;S("Scaffolding code generator..."),je(n),je(w(n,"bin")),je(w(n,"src")),Q(w(n,"package.json"),Ww(r,e||`Code generator: ${r}`)),Z("Created package.json");const o=w(n,"bin","index.js");return Q(o,zw(r)),Nc(o,493),Z("Created bin/index.js (executable)"),Q(w(n,"tsconfig.json"),Hw()),Z("Created tsconfig.json"),Q(w(n,"src","index.ts"),qw()),Z("Created src/index.ts"),0},"executeGeneratorTemplate");var Yw=Object.defineProperty,Qr=b((t,e)=>Yw(t,"name",{value:e,configurable:!0}),"s$l");const Kw=Qr(t=>`${JSON.stringify({devDependencies:{"@visulima/vis":"latest"},name:t,packageManager:"pnpm@latest",private:!0,scripts:{build:"vis run build",dev:"vis run dev",lint:"vis run lint",test:"vis run test"},type:"module",version:"0.0.0"},null,4)}
|
|
217
|
+
`,"rootPackageJson"),Xw=Qr(()=>`packages:
|
|
188
218
|
- "apps/*"
|
|
189
219
|
- "packages/*"
|
|
190
|
-
`,"pnpmWorkspaceYaml"),
|
|
220
|
+
`,"pnpmWorkspaceYaml"),Qw=Qr(()=>`# Dependencies
|
|
191
221
|
node_modules/
|
|
192
222
|
|
|
193
223
|
# Build output
|
|
@@ -217,7 +247,7 @@ pnpm-debug.log*
|
|
|
217
247
|
# Cache
|
|
218
248
|
.turbo/
|
|
219
249
|
.cache/
|
|
220
|
-
`,"gitignore"),
|
|
250
|
+
`,"gitignore"),Zw=Qr(()=>`root = true
|
|
221
251
|
|
|
222
252
|
[*]
|
|
223
253
|
indent_style = space
|
|
@@ -232,7 +262,7 @@ indent_size = 2
|
|
|
232
262
|
|
|
233
263
|
[*.md]
|
|
234
264
|
trim_trailing_whitespace = false
|
|
235
|
-
`,"editorconfig"),
|
|
265
|
+
`,"editorconfig"),ek=Qr(t=>`# ${t}
|
|
236
266
|
|
|
237
267
|
A monorepo powered by [vis](https://visulima.com/packages/vis).
|
|
238
268
|
|
|
@@ -260,11 +290,11 @@ pnpm test
|
|
|
260
290
|
├── pnpm-workspace.yaml
|
|
261
291
|
└── package.json
|
|
262
292
|
\`\`\`
|
|
263
|
-
`,"readmeMd"),
|
|
264
|
-
`),
|
|
265
|
-
`),
|
|
266
|
-
`),
|
|
267
|
-
`),
|
|
293
|
+
`,"readmeMd"),tk=Qr(t=>{const{projectName:e,targetDir:r}=t;return S("Scaffolding monorepo workspace..."),je(r),je(w(r,"apps")),je(w(r,"packages")),Q(w(r,"package.json"),Kw(e)),Z("Created package.json"),Q(w(r,"pnpm-workspace.yaml"),Xw()),Z("Created pnpm-workspace.yaml"),Q(w(r,".gitignore"),Qw()),Z("Created .gitignore"),Q(w(r,".editorconfig"),Zw()),Z("Created .editorconfig"),Q(w(r,"README.md"),ek(e)),Z("Created README.md"),Q(w(r,"apps",".gitkeep"),""),Q(w(r,"packages",".gitkeep"),""),0},"executeMonorepoTemplate");var rk=Object.defineProperty,us=b((t,e)=>rk(t,"name",{value:e,configurable:!0}),"i$c");const nk={"create-nuxt":{monoArgs:["--no-gitInit"]},"create-vite":{args:["--no-immediate"]},sv:{args:["--no-install"],prependCommand:"create"}},ok=us((t,e,r)=>{const n=nk[t];if(!n)return e;const o=[...e];if(n.prependCommand&&!o.includes(n.prependCommand)&&o.unshift(n.prependCommand),n.args)for(const i of n.args)o.includes(i)||o.push(i);if(r&&n.monoArgs)for(const i of n.monoArgs)o.includes(i)||o.push(i);return o},"applyAutoFixes"),ik=us((t,e)=>{const r=_e(e.cwd,e.targetDir)||".",n=[...t.args];n.includes(r)||n.unshift(r);const o=ok(t.source,n,e.inMonorepo);return S(`Running ${t.source} via ${e.pm.name} dlx...`),Ji(e.pm,{additionalPackages:[],args:o,package:t.source,shellMode:!1,silent:!1},e.cwd,e.logger)},"executeRemoteNpm"),sk=us(async(t,e)=>{const{createConfig:r}=e;S(`Downloading template from ${t.source}...`);try{const n=await Wc(t.source,{auth:r?.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:e.targetDir,force:!0,preferOffline:r?.preferOffline,provider:r?.defaultProvider,registry:r?.registry});return S(`Downloaded to ${n.dir}`),0}catch(n){const o=n instanceof Error?n.message:String(n);return se(`Failed to download template: ${o}`),1}},"executeRemoteGit");var ak=Object.defineProperty,ck=b((t,e)=>ak(t,"name",{value:e,configurable:!0}),"r$g");const lk=ck(async(t,e)=>{switch(t.type){case"builtin:app":case"builtin:library":return _w(t,e);case"builtin:generator":return Jw(e);case"builtin:monorepo":return tk(e);case"remote:git":return sk(t,e);case"remote:npm":return ik(t,e);default:throw new Error(`Unknown template type: ${t.type}`)}},"executeTemplate");var dk=Object.defineProperty,ar=b((t,e)=>dk(t,"name",{value:e,configurable:!0}),"m$i");const uk=ar(t=>{const e=w(t,".vscode");je(e);const r=w(e,"settings.json"),n={"editor.defaultFormatter":"oxc.oxc-vscode","editor.formatOnSave":!0};if(T(r))try{const s=ue(r);Q(r,`${JSON.stringify({...n,...s},null,4)}
|
|
294
|
+
`),Z("Merged .vscode/settings.json")}catch{se("Could not merge .vscode/settings.json, skipping")}else Q(r,`${JSON.stringify(n,null,4)}
|
|
295
|
+
`),Z("Created .vscode/settings.json");const o=w(e,"extensions.json"),i={recommendations:["oxc.oxc-vscode"]};if(T(o))try{const s=ue(o);Q(o,`${JSON.stringify({...s,recommendations:[...new Set([...s.recommendations||[],...i.recommendations])]},null,4)}
|
|
296
|
+
`),Z("Merged .vscode/extensions.json")}catch{se("Could not merge .vscode/extensions.json, skipping")}else Q(o,`${JSON.stringify(i,null,4)}
|
|
297
|
+
`),Z("Created .vscode/extensions.json")},"generateVscodeConfig"),pk=ar((t,e)=>{const r=w(t,".ai");je(r);const n=w(r,"instructions");if(T(n))return;const o=`# Project Instructions
|
|
268
298
|
|
|
269
299
|
This project was scaffolded with vis create.
|
|
270
300
|
|
|
@@ -280,43 +310,63 @@ This project was scaffolded with vis create.
|
|
|
280
310
|
- Use TypeScript strict mode
|
|
281
311
|
- ESM modules (\`"type": "module"\`)
|
|
282
312
|
- Follow Angular-style conventional commits
|
|
283
|
-
`;
|
|
284
|
-
`),
|
|
285
|
-
`),
|
|
286
|
-
`)},"printNextSteps"),
|
|
287
|
-
Use --list to see available templates, or run interactively in a terminal.`);{const
|
|
288
|
-
Use a different name or clear the directory first.`);
|
|
289
|
-
`);const
|
|
290
|
-
`,"utf8")},"writeDevcontainerJson");var cg=Object.defineProperty,lg=$((t,e)=>cg(t,"name",{value:e,configurable:!0}),"s$e");const dg={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},ug=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],_o=lg((t,e,r)=>{const n=[],i=new Set(r.map(s=>typeof s=="string"?s:s.target));if(t)for(const s of dg[t])i.has(s.target)||n.push(s);const o=Object.keys(e);for(const{featureMatch:s,mounts:l}of ug)if(o.some(d=>d.includes(s)))for(const d of l)i.has(d.target)||n.push(d);return n},"getSuggestedMounts"),bt=["general","features","ports","lifecycle","extensions","environment","mounts","compose"];var pg=Object.defineProperty,Nr=$((t,e)=>pg(t,"name",{value:e,configurable:!0}),"c$c");const Yt=Nr(t=>JSON.parse(JSON.stringify(t)),"deepClone");class fg{static{$(this,"DevcontainerStore")}static{Nr(this,"DevcontainerStore")}#e=new Set;#t;constructor(e,r,n=null){const i=e===null,o=e??{name:""},s=Yt(o);this.#t={config:s,detectedPm:n,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:r,isDirty:!1,mode:i?"create":"edit",originalConfig:i?null:Yt(o),section:"general",showTemplateSelector:i,suggestedMounts:_o(n,s.features??{},s.mounts??[]),templateIndex:0}}getSnapshot=Nr(()=>this.#t,"getSnapshot");subscribe=Nr(e=>(this.#e.add(e),()=>{this.#e.delete(e)}),"subscribe");setSection(e){e!==this.#t.section&&this.#r({...this.#t,fieldEditing:!1,fieldIndex:0,section:e})}nextSection(){const e=(bt.indexOf(this.#t.section)+1)%bt.length;this.setSection(bt[e])}previousSection(){const e=(bt.indexOf(this.#t.section)-1+bt.length)%bt.length;this.setSection(bt[e])}setFieldIndex(e){e!==this.#t.fieldIndex&&this.#r({...this.#t,fieldIndex:Math.max(0,e)})}setFieldEditing(e){e!==this.#t.fieldEditing&&this.#r({...this.#t,fieldEditing:e})}setTemplateIndex(e){const r=Math.max(0,Math.min(e,Lt.length-1));r!==this.#t.templateIndex&&this.#r({...this.#t,templateIndex:r})}applyTemplate(e){const r=Lt.find(n=>n.id===e);r&&this.#r(this.#o({...this.#t,config:Yt(r.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#r({...this.#t,showTemplateSelector:!1})}updateConfig(e){this.#r({...this.#t,config:{...this.#t.config,...e},isDirty:!0})}toggleFeature(e){const r={...this.#t.config.features};r[e]!==void 0?delete r[e]:r[e]={},this.#r(this.#o({...this.#t,config:{...this.#t.config,features:r},isDirty:!0}))}setFeatureSearch(e){this.#r({...this.#t,featureSearch:e,fieldIndex:0})}addPort(e){const r=this.#t.config.forwardPorts??[];if(r.includes(e))return;const n=[...r,e];this.#r({...this.#t,config:{...this.#t.config,forwardPorts:n},isDirty:!0})}removePort(e){const r=[...this.#t.config.forwardPorts??[]];r.splice(e,1),this.#r({...this.#t,config:{...this.#t.config,forwardPorts:r.length>0?r:void 0},isDirty:!0})}toggleExtension(e){const r={...this.#t.config.customizations},n={...r.vscode},i=[...n.extensions??[]],o=i.indexOf(e);o>=0?i.splice(o,1):i.push(e),n.extensions=i.length>0?i:void 0,r.vscode=n.extensions||n.settings?n:void 0,this.#r({...this.#t,config:{...this.#t.config,customizations:r.vscode||r.jetbrains?r:void 0},isDirty:!0})}setExtensionSearch(e){this.#r({...this.#t,extensionSearch:e,fieldIndex:0})}addEnvVar(e,r,n){const i=e==="container"?"containerEnv":"remoteEnv",o={...this.#t.config[i],[r]:n};this.#r({...this.#t,config:{...this.#t.config,[i]:o},isDirty:!0})}removeEnvVar(e,r){const n=e==="container"?"containerEnv":"remoteEnv",i={...this.#t.config[n]};delete i[r],this.#r({...this.#t,config:{...this.#t.config,[n]:Object.keys(i).length>0?i:void 0},isDirty:!0})}addMount(e){const r=[...this.#t.config.mounts??[],e];this.#r(this.#o({...this.#t,config:{...this.#t.config,mounts:r},isDirty:!0}))}removeMount(e){const r=[...this.#t.config.mounts??[]];r.splice(e,1),this.#r(this.#o({...this.#t,config:{...this.#t.config,mounts:r.length>0?r:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#t.suggestedMounts.length===0)return;const e=[...this.#t.config.mounts??[],...this.#t.suggestedMounts];this.#r(this.#o({...this.#t,config:{...this.#t.config,mounts:e},isDirty:!0}))}setLifecycleCommand(e,r){this.#r({...this.#t,config:{...this.#t.config,[e]:r||void 0},isDirty:!0})}markClean(){this.#r({...this.#t,isDirty:!1,originalConfig:Yt(this.#t.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const e=Yt(this.#t.config);for(const[r,n]of Object.entries(e))(n===""||n===void 0)&&delete e[r];return e.build&&(e.build.dockerfile===""&&delete e.build.dockerfile,e.build.context===""&&delete e.build.context,e.build.args&&Object.keys(e.build.args).length===0&&delete e.build.args,Object.keys(e.build).length===0&&delete e.build),e.forwardPorts?.length===0&&delete e.forwardPorts,e.mounts?.length===0&&delete e.mounts,e.runServices?.length===0&&delete e.runServices,e.capAdd?.length===0&&delete e.capAdd,e.securityOpt?.length===0&&delete e.securityOpt,e.features&&Object.keys(e.features).length===0&&delete e.features,e.customizations?.vscode?.extensions?.length===0&&delete e.customizations.vscode.extensions,e.customizations?.vscode&&Object.keys(e.customizations.vscode).length===0&&delete e.customizations.vscode,e.customizations&&Object.keys(e.customizations).length===0&&delete e.customizations,e.containerEnv&&Object.keys(e.containerEnv).length===0&&delete e.containerEnv,e.remoteEnv&&Object.keys(e.remoteEnv).length===0&&delete e.remoteEnv,e}#o(e){return{...e,suggestedMounts:_o(e.detectedPm,e.config.features??{},e.config.mounts??[])}}#r(e){this.#t=e;for(const r of this.#e)try{r()}catch{}}}const Ho=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],Jo=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}];var gg=Object.defineProperty,Gs=$((t,e)=>gg(t,"name",{value:e,configurable:!0}),"r$a");const lo=Gs(t=>{if(!t)return Jo;const e=t.toLowerCase();return Jo.filter(r=>r.name.toLowerCase().includes(e)||r.id.toLowerCase().includes(e)||r.description.toLowerCase().includes(e))},"filterFeatures"),uo=Gs(t=>{if(!t)return Ho;const e=t.toLowerCase();return Ho.filter(r=>r.name.toLowerCase().includes(e)||r.id.toLowerCase().includes(e)||r.description.toLowerCase().includes(e))},"filterExtensions");var hg=Object.defineProperty,mg=$((t,e)=>hg(t,"name",{value:e,configurable:!0}),"l$9");const zs=["dockerComposeFile","service"],yg={dockerComposeFile:"Compose File",service:"Service"},qo={dockerComposeFile:"docker-compose.yml",service:"app"},vg={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},wg=mg(({config:t,fieldEditing:e,fieldIndex:r,onUpdate:n})=>{const i=!!t.dockerComposeFile,o=!!(t.image||t.build);return u(g,{flexDirection:"column",paddingX:1,children:[c(g,{marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),o&&i&&c(g,{marginBottom:1,children:c(a,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),zs.map((s,l)=>{const d=l===r,f=t[s]??"",p=Array.isArray(t[s])?t[s].join(", "):f;return u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{children:[c(g,{width:20,children:u(a,{bold:d,color:d?"cyan":"white",children:[d?"❯ ":" ",yg[s],":"]})}),c(g,{flexGrow:1,children:d&&e?c(Un,{defaultValue:p,onChange:$(h=>{n({[s]:h||void 0})},"onChange"),placeholder:qo[s]}):c(a,{color:p?"white":"gray",children:p||qo[s]})})]}),c(g,{paddingLeft:4,children:c(a,{dimColor:!0,children:vg[s]})})]},s)}),c(g,{marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"Enter"})," edit field"," ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"," ",c(a,{bold:!0,color:"white",children:"Esc"})," stop editing"]})})]})},"DockerComposeSection"),kg=zs.length;var bg=Object.defineProperty,Ws=$((t,e)=>bg(t,"name",{value:e,configurable:!0}),"h$b");const $g=Ws(({config:t,fieldIndex:e})=>{const r=t.containerEnv??{},n=t.remoteEnv??{},i=Object.keys(r),o=Object.keys(n),s=i.length,l=i.length+1,d=l+o.length,f=e<=s,p=e>s;return u(g,{flexDirection:"column",paddingX:1,children:[u(g,{borderColor:f?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[u(g,{flexShrink:0,marginBottom:i.length>0?1:0,children:[c(a,{bold:!0,color:f?"cyan":"white",children:"containerEnv"}),c(a,{dimColor:!0,children:" — baked into the container image"})]}),i.map((h,m)=>{const y=m===e;return c(g,{flexShrink:0,children:u(a,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",c(a,{bold:!0,children:h}),c(a,{dimColor:!0,children:" = "}),c(a,{children:r[h]})]})},h)}),c(g,{flexShrink:0,marginTop:i.length>0?1:0,children:u(a,{color:e===s?"cyan":"gray",inverse:e===s,children:[" ","+ Add variable..."]})})]}),u(g,{borderColor:p?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[u(g,{flexShrink:0,marginBottom:o.length>0?1:0,children:[c(a,{bold:!0,color:p?"cyan":"white",children:"remoteEnv"}),c(a,{dimColor:!0,children:" — set at runtime by the IDE"})]}),o.map((h,m)=>{const y=l+m===e;return c(g,{flexShrink:0,children:u(a,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",c(a,{bold:!0,children:h}),c(a,{dimColor:!0,children:" = "}),c(a,{children:n[h]})]})},h)}),c(g,{flexShrink:0,marginTop:o.length>0?1:0,children:u(a,{color:e===d?"cyan":"gray",inverse:e===d,children:[" ","+ Add variable..."]})})]}),c(g,{flexShrink:0,marginTop:1,children:u(a,{dimColor:!0,wrap:"truncate",children:[c(a,{bold:!0,color:"white",children:"a"}),"/",c(a,{bold:!0,color:"white",children:"Enter"})," add on + row ",c(a,{bold:!0,color:"white",children:"d"})," remove ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"]})})]})},"EnvironmentSection"),xg=Ws(t=>{const e=Object.keys(t.containerEnv??{}).length,r=Object.keys(t.remoteEnv??{}).length;return e+1+r+1},"getEnvFieldCount");var Sg=Object.defineProperty,Cg=$((t,e)=>Sg(t,"name",{value:e,configurable:!0}),"h$a");const Eg=Cg(({config:t,fieldIndex:e,scrollOffset:r,searchText:n,viewportHeight:i})=>{const o=Ke(()=>new Set(t.customizations?.vscode?.extensions??[]),[t.customizations?.vscode?.extensions]),s=Ke(()=>uo(n),[n]),l=s.length,d=l>i&&i>0;return u(g,{flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[u(a,{bold:!0,color:"cyan",children:[o.size," selected"]}),n&&u(a,{dimColor:!0,children:["— filter: ",c(a,{color:"yellow",children:n})," (",s.length," results)"]})]}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-r,children:s.map((f,p)=>{const h=p===e,m=o.has(f.id);return u(g,{flexShrink:0,height:1,children:[c(a,{children:h?">":" "}),u(a,{color:m?"white":"gray",children:[" ",m?"☑":"☐"," "]}),c(g,{flexGrow:1,children:u(a,{bold:h,inverse:h,wrap:"truncate",children:[f.name,u(a,{dimColor:!0,children:[" - ",f.id]})]})})]},f.id)})})}),d&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:l,placement:"inset",scrollOffset:r,style:"block",viewportHeight:i})})]}),s.length===0&&c(g,{paddingX:1,children:c(a,{dimColor:!0,children:"No extensions match the search."})})]})},"ExtensionsSection");var jg=Object.defineProperty,Tg=$((t,e)=>jg(t,"name",{value:e,configurable:!0}),"p$d");const Ag=Tg(({config:t,fieldIndex:e,scrollOffset:r,searchText:n,viewportHeight:i})=>{const o=Ke(()=>new Set(Object.keys(t.features??{})),[t.features]),s=Ke(()=>lo(n),[n]),l=s.length,d=l>i&&i>0;return u(g,{flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[u(a,{bold:!0,color:"cyan",children:[o.size," selected"]}),n&&u(a,{dimColor:!0,children:["— filter: ",c(a,{color:"yellow",children:n})," (",s.length," results)"]})]}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-r,children:s.map((f,p)=>{const h=p===e,m=o.has(f.id);return u(g,{flexShrink:0,height:1,children:[c(a,{children:h?">":" "}),u(a,{color:m?"white":"gray",children:[" ",m?"☑":"☐"," "]}),c(g,{flexGrow:1,children:u(a,{bold:h,inverse:h,wrap:"truncate",children:[f.name,u(a,{dimColor:!0,children:[" - ",f.description]})]})})]},f.id)})})}),d&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:l,placement:"inset",scrollOffset:r,style:"block",viewportHeight:i})})]}),s.length===0&&c(g,{paddingX:1,children:c(a,{dimColor:!0,children:"No features match the search."})})]})},"FeaturesSection");var Ig=Object.defineProperty,Rg=$((t,e)=>Ig(t,"name",{value:e,configurable:!0}),"u$b");const Tn=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],Og={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},Yo={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},Vr=["privileged","overrideCommand"],Pg={overrideCommand:"Override Command",privileged:"Privileged"},Ng=Tn.length+Vr.length,Dg=Rg(({config:t,fieldEditing:e,fieldIndex:r,onUpdate:n})=>u(g,{flexDirection:"column",paddingX:1,children:[c(g,{marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"General Configuration"})}),Tn.map((i,o)=>{const s=o===r,l=t[i]??"";return u(g,{marginBottom:1,children:[c(g,{width:20,children:u(a,{bold:s,color:s?"cyan":"white",children:[s?"❯ ":" ",Og[i],":"]})}),c(g,{flexGrow:1,children:s&&e?c(Un,{defaultValue:l,onChange:$(d=>{n({[i]:d})},"onChange"),placeholder:Yo[i]}):c(a,{color:l?"white":"gray",children:l||Yo[i]})})]},i)}),Vr.map((i,o)=>{const s=Tn.length+o===r,l=t[i]??!1;return u(g,{marginBottom:o<Vr.length-1?1:0,children:[c(g,{width:20,children:u(a,{bold:s,color:s?"cyan":"white",children:[s?"❯ ":" ",Pg[i],":"]})}),c(g,{flexGrow:1,children:u(a,{color:l?"green":"gray",children:[l?"yes":"no",s&&c(a,{dimColor:!0,children:" (Space to toggle)"})]})})]},i)}),c(g,{marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"Enter"})," edit field"," ",c(a,{bold:!0,color:"white",children:"Space"})," toggle"," ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"," ",c(a,{bold:!0,color:"white",children:"Esc"})," stop editing"]})})]}),"GeneralSection"),_s=Ng,bn=Vr;var Mg=Object.defineProperty,Bg=$((t,e)=>Mg(t,"name",{value:e,configurable:!0}),"s$c");const Hs=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],Lg={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},Fg={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},Vg=Bg(({config:t,fieldEditing:e,fieldIndex:r,onSetCommand:n})=>u(g,{flexDirection:"column",paddingX:1,children:[c(g,{marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),Hs.map((i,o)=>{const s=o===r,l=t[i],d=Array.isArray(l)?l.join(" && "):l??"";return u(g,{flexDirection:"column",marginBottom:1,children:[c(g,{children:u(a,{bold:s,color:s?"cyan":"white",children:[s?"❯ ":" ",Lg[i]]})}),c(g,{paddingLeft:4,children:c(a,{dimColor:!0,children:Fg[i]})}),c(g,{paddingLeft:4,children:s&&e?c(Un,{defaultValue:d,onChange:$(f=>{n(i,f)},"onChange"),placeholder:"e.g. npm install"}):c(a,{color:d?"green":"gray",children:d||"(not set)"})})]},i)}),c(g,{marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"Enter"})," edit command"," ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"," ",c(a,{bold:!0,color:"white",children:"Esc"})," stop editing"]})})]}),"LifecycleSection"),Ug=Hs.length;var Gg=Object.defineProperty,Js=$((t,e)=>Gg(t,"name",{value:e,configurable:!0}),"s$b");const Xo=Js(t=>typeof t=="string"?t:`[${t.type}] ${t.source} → ${t.target}`,"formatMount"),zg=Js(({addingMount:t,config:e,detectedPm:r,fieldIndex:n,mountPhase:i,mountSource:o,mountTarget:s,mountType:l,suggestedMounts:d})=>{const f=e.mounts??[];return u(g,{flexDirection:"column",paddingX:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[u(a,{bold:!0,color:"cyan",children:[f.length," mounts"]}),r&&u(a,{dimColor:!0,children:["— detected: ",c(a,{color:"white",children:r})]})]}),d.length>0&&!t&&u(g,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[u(g,{flexShrink:0,children:[c(a,{bold:!0,color:"yellow",children:"Suggested mounts"}),u(a,{dimColor:!0,children:[" — press ",c(a,{bold:!0,color:"white",children:"A"})," to add all"]})]}),d.map((p,h)=>c(g,{flexShrink:0,children:u(a,{dimColor:!0,wrap:"truncate",children:[" + ",Xo(p)]})},`suggestion-${String(h)}`))]}),f.length>0&&c(g,{flexDirection:"column",marginBottom:1,children:f.map((p,h)=>{const m=h===n;return u(g,{flexShrink:0,height:1,children:[c(a,{children:m?">":" "}),c(g,{flexGrow:1,children:u(a,{bold:m,inverse:m,wrap:"truncate",children:[" ",Xo(p)]})})]},`mount-${String(h)}`)})}),!t&&c(g,{flexShrink:0,children:u(a,{color:n===f.length?"cyan":"gray",inverse:n===f.length,children:[" ","+ Add mount..."]})}),t&&u(g,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[c(g,{flexShrink:0,marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"New Mount"})}),u(g,{flexShrink:0,children:[c(g,{width:12,children:u(a,{bold:i==="source",color:i==="source"?"cyan":"white",children:[i==="source"?"❯ ":" ","Source:"]})}),c(a,{color:o?"yellow":"gray",children:o||(i==="source"?"_":"(type source, Enter to continue)")})]}),u(g,{flexShrink:0,children:[c(g,{width:12,children:u(a,{bold:i==="target",color:i==="target"?"cyan":"white",children:[i==="target"?"❯ ":" ","Target:"]})}),c(a,{color:s?"yellow":"gray",children:s||(i==="target"?"_":"/container/path")})]}),u(g,{flexShrink:0,children:[c(g,{width:12,children:u(a,{bold:i==="type",color:i==="type"?"cyan":"white",children:[i==="type"?"❯ ":" ","Type:"]})}),i==="type"?u(a,{children:[c(a,{bold:l==="volume",color:l==="volume"?"cyan":"gray",children:"[1] volume"})," ",c(a,{bold:l==="bind",color:l==="bind"?"cyan":"gray",children:"[2] bind"})," ",c(a,{bold:l==="tmpfs",color:l==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):c(a,{color:"gray",children:l})]}),c(g,{flexShrink:0,marginTop:1,children:c(a,{dimColor:!0,wrap:"truncate",children:i==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),f.length===0&&!t&&d.length===0&&c(g,{marginTop:1,children:c(a,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},"MountsSection");var Wg=Object.defineProperty,_g=$((t,e)=>Wg(t,"name",{value:e,configurable:!0}),"m$a");const Hg=_g(({addingPort:t,addPortValue:e,config:r,fieldIndex:n})=>{const i=r.forwardPorts??[],o=n===i.length;return u(g,{flexDirection:"column",paddingX:1,children:[u(g,{marginBottom:1,children:[c(a,{bold:!0,color:"cyan",children:"Forwarded Ports"}),u(a,{dimColor:!0,children:[" (",i.length," ports)"]})]}),i.map((s,l)=>{const d=l===n;return c(g,{children:u(a,{color:d?"cyan":void 0,inverse:d,children:[" ",String(s)]})},`port-${String(s)}`)}),c(g,{marginTop:i.length>0?1:0,children:u(a,{color:o?"cyan":"gray",inverse:o,children:[" ",o&&t?u(a,{children:["Enter port: ",c(a,{color:"yellow",children:e||"_"})]}):"+ Add port..."]})}),c(g,{marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"Enter"})," ",o?"type port number, Enter to confirm":"select"," ",c(a,{bold:!0,color:"white",children:"d"})," remove selected"," ",c(a,{bold:!0,color:"white",children:"↑↓"})," navigate"]})})]})},"PortsSection");var Jg=Object.defineProperty,qg=$((t,e)=>Jg(t,"name",{value:e,configurable:!0}),"a$6");const Yg=qg(({focused:t,hadComments:e,jsonPreview:r,mode:n,scrollRef:i})=>u(g,{borderColor:t?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:t?"cyan":"white",children:"Preview"}),u(a,{dimColor:!0,children:[" (",n==="create"?"new":"edit",")"]})]}),e&&n==="edit"&&c(g,{flexShrink:0,paddingX:1,children:c(a,{color:"yellow",children:"Comments will not be preserved."})}),c(zt,{flexGrow:1,ref:i,scrollbar:!0,scrollbarColor:"gray",children:r.split(`
|
|
291
|
-
`).map((o,s)=>c(a,{color:"green",children:o},`line-${String(s)}`))})]}),"PreviewPanel");var Xg=Object.defineProperty,Kg=$((t,e)=>Xg(t,"name",{value:e,configurable:!0}),"r$9");const Qg=Kg(t=>{const e=[],r=[],n=[];if(!t.image&&!t.build&&!t.dockerComposeFile&&e.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),t.build&&(t.image&&r.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),t.build.dockerfile||e.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),t.dockerComposeFile&&!t.service&&e.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),t.features!==void 0&&(typeof t.features!="object"||Array.isArray(t.features))&&e.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),t.forwardPorts)if(!Array.isArray(t.forwardPorts))e.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});else for(const[i,o]of t.forwardPorts.entries())typeof o=="number"&&(o<1||o>65535)&&e.push({field:"forwardPorts",message:`Invalid port ${String(o)} at index ${String(i)}`});return t.customizations?.vscode?.extensions&&!Array.isArray(t.customizations.vscode.extensions)&&e.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),t.customizations?.vscode?.settings&&typeof t.customizations.vscode.settings!="object"&&e.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),t.name||n.push({field:"name",message:"Consider adding a name for better identification"}),(!t.features||Object.keys(t.features).length===0)&&n.push({field:"features",message:"Consider adding features for common tools"}),(!t.customizations?.vscode?.extensions||t.customizations.vscode.extensions.length===0)&&n.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),t.privileged&&r.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:e,suggestions:n,valid:e.length===0,warnings:r}},"validateConfig");var Zg=Object.defineProperty,qs=$((t,e)=>Zg(t,"name",{value:e,configurable:!0}),"$$5");const Ko=80,Qo=15,eh=120,Zo=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],th=qs((t,e,r,n)=>{switch(t){case"general":return _s;case"features":return lo(r).length;case"ports":return(e.forwardPorts?.length??0)+1;case"lifecycle":return Ug;case"extensions":return uo(n).length;case"environment":return xg(e);case"mounts":return(e.mounts?.length??0)+1;case"compose":return kg;default:return 0}},"getFieldCount"),rh=qs(({onSave:t,store:e})=>{const{exit:r}=Gt(),{columns:n,rows:i}=Ut(),o=pr(e.subscribe,e.getSnapshot),[s,l]=ce(!1),[d,f]=ce(!1),[p,h]=ce(!1),[m,y]=ce(null),[b,x]=ce("editor"),[S,C]=ce(0),[D,P]=ce(!1),[M,E]=ce(""),[R,A]=ce(null),[G,B]=ce(""),[w,v]=ce(""),[j,U]=ce("key"),[z,Z]=ce(!1),[he,oe]=ce(""),[Te,ke]=ce(""),[Se,O]=ce("volume"),[I,Y]=ce("source"),ye=be(null),Ae=be(null),Ce=be(null),it=be(!0);qe(()=>(it.current=!0,()=>{it.current=!1,Ce.current&&clearTimeout(Ce.current)}),[]);const J=th(o.section,o.config,o.featureSearch,o.extensionSearch),q=Math.max(1,i-9);qe(()=>{o.section!=="features"&&o.section!=="extensions"||C(W=>o.fieldIndex>=W+q?o.fieldIndex-q+1:o.fieldIndex<W?o.fieldIndex:W)},[o.fieldIndex,o.section,q]),qe(()=>{C(0)},[o.section,o.featureSearch,o.extensionSearch]);const se=Ye(()=>{const W=e.cleanConfig(),X=Qg(W);if(!X.valid){const fe=X.errors[0];y(fe?`Error: ${fe.message}`:"Validation failed"),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{it.current&&y(null)},3e3);return}t(W),e.markClean();const V=X.warnings.length;y(V>0?`Saved! (${String(V)} warning${V>1?"s":""})`:"Saved!"),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{it.current&&y(null)},2e3)},[t,e]);if(De((W,X)=>{if(X.downArrow||W==="j")e.setTemplateIndex(o.templateIndex+1);else if(X.upArrow||W==="k")e.setTemplateIndex(o.templateIndex-1);else if(X.return){const V=Lt[o.templateIndex];V&&e.applyTemplate(V.id)}else X.escape&&e.dismissTemplateSelector()},{isActive:o.showTemplateSelector}),De((W,X)=>{if(X.escape){P(!1),E("");return}if(X.return){const V=Number.parseInt(M,10);!Number.isNaN(V)&&V>0&&V<=65535&&e.addPort(V),P(!1),E("");return}if(X.backspace){E(V=>V.slice(0,-1));return}W&&/^\d$/u.test(W)&&E(V=>V+W)},{isActive:D}),De((W,X)=>{if(X.escape){A(null),B(""),v(""),U("key");return}if(X.return){if(j==="key"&&G){U("value");return}if(j==="value"&&G){e.addEnvVar(R,G,w),A(null),B(""),v(""),U("key");return}}if(X.backspace){j==="key"?B(V=>V.slice(0,-1)):v(V=>V.slice(0,-1));return}W&&!X.ctrl&&!X.meta&&(j==="key"?B(V=>V+W):v(V=>V+W))},{isActive:R!==null}),De((W,X)=>{if(X.escape){Z(!1),oe(""),ke(""),Y("source");return}if(X.return){if(I==="source"&&he){Y("target");return}if(I==="target"&&Te){Y("type");return}if(I==="type"){e.addMount({source:he,target:Te,type:Se}),Z(!1),oe(""),ke(""),Y("source");return}}if(I==="type"){W==="1"?O("volume"):W==="2"?O("bind"):W==="3"&&O("tmpfs");return}if(X.backspace){I==="source"?oe(V=>V.slice(0,-1)):I==="target"&&ke(V=>V.slice(0,-1));return}W&&!X.ctrl&&!X.meta&&(I==="source"?oe(V=>V+W):I==="target"&&ke(V=>V+W))},{isActive:z}),De((W,X)=>{if(W==="c"&&X.ctrl){r();return}if(!d){if(s){X.escape||W==="?"?l(!1):X.downArrow||W==="j"?ye.current?.scrollBy(1):X.upArrow||W==="k"?ye.current?.scrollBy(-1):W==="q"&&(l(!1),f(!0));return}if(p){if(X.escape){h(!1),o.section==="features"?e.setFeatureSearch(""):e.setExtensionSearch("");return}if(X.return){h(!1);return}if(X.backspace){o.section==="features"?e.setFeatureSearch(o.featureSearch.slice(0,-1)):e.setExtensionSearch(o.extensionSearch.slice(0,-1));return}if(W&&!X.ctrl&&!X.meta){o.section==="features"?e.setFeatureSearch(o.featureSearch+W):e.setExtensionSearch(o.extensionSearch+W);return}return}if(o.fieldEditing){if(X.escape){e.setFieldEditing(!1);return}if(X.return){e.setFieldEditing(!1);return}return}if(W==="?"){l(!0);return}if(W==="q"){o.isDirty?f(!0):r();return}if(W==="s"){se();return}if(X.tab){x(V=>V==="editor"?"preview":"editor");return}if(b==="preview"){if(X.downArrow||W==="j"){Ae.current?.scrollBy(1);return}if(X.upArrow||W==="k"){Ae.current?.scrollBy(-1);return}if(X.pageDown){Ae.current?.scrollBy(10);return}if(X.pageUp){Ae.current?.scrollBy(-10);return}if(X.home){Ae.current?.scrollToTop();return}if(X.end){Ae.current?.scrollToBottom();return}X.escape&&x("editor");return}if(X.downArrow||W==="j"){J>0&&e.setFieldIndex(Math.min(o.fieldIndex+1,J-1));return}if(X.upArrow||W==="k"){e.setFieldIndex(Math.max(o.fieldIndex-1,0));return}if(X.return){if(o.section==="general"||o.section==="lifecycle"||o.section==="compose")e.setFieldEditing(!0);else if(o.section==="ports"){const V=o.config.forwardPorts??[];o.fieldIndex===V.length&&(P(!0),E(""))}else if(o.section==="environment"){const V=Object.keys(o.config.containerEnv??{}).length,fe=V,Ze=V+1+Object.keys(o.config.remoteEnv??{}).length;o.fieldIndex===fe?(A("container"),B(""),v(""),U("key")):o.fieldIndex===Ze&&(A("remote"),B(""),v(""),U("key"))}else if(o.section==="mounts"){const V=o.config.mounts??[];o.fieldIndex===V.length&&(Z(!0),oe(""),ke(""),O("volume"),Y("source"))}return}if(W===" "){if(o.section==="general"){const V=_s-bn.length,fe=o.fieldIndex-V;if(fe>=0&&fe<bn.length){const Ze=bn[fe];e.updateConfig({[Ze]:!o.config[Ze]})}}else if(o.section==="features"){const V=lo(o.featureSearch)[o.fieldIndex];V&&e.toggleFeature(V.id)}else if(o.section==="extensions"){const V=uo(o.extensionSearch)[o.fieldIndex];V&&e.toggleExtension(V.id)}return}if(W==="/"){(o.section==="features"||o.section==="extensions")&&h(!0);return}if(W==="A"&&o.section==="mounts"){e.applySuggestedMounts();return}if(W==="a"){if(o.section==="environment"){const V=Object.keys(o.config.containerEnv??{}).length,fe=o.fieldIndex<=V?"container":"remote";A(fe),B(""),v(""),U("key")}else o.section==="mounts"&&(Z(!0),oe(""),ke(""),O("volume"),Y("source"));return}if(W==="d"){if(o.section==="ports"){const V=o.config.forwardPorts??[];if(o.fieldIndex<V.length){e.removePort(o.fieldIndex);const fe=V.length-1;o.fieldIndex>=fe&&fe>0&&e.setFieldIndex(fe-1)}}else if(o.section==="mounts"){const V=o.config.mounts??[];if(o.fieldIndex<V.length){e.removeMount(o.fieldIndex);const fe=V.length-1;o.fieldIndex>=fe&&fe>0&&e.setFieldIndex(fe-1)}}else if(o.section==="environment"){const V=Object.keys(o.config.containerEnv??{}),fe=Object.keys(o.config.remoteEnv??{});if(o.fieldIndex<V.length)e.removeEnvVar("container",V[o.fieldIndex]),V.length===1||o.fieldIndex>=V.length-1&&e.setFieldIndex(V.length-2);else{const Ze=o.fieldIndex-V.length-1;Ze>=0&&Ze<fe.length&&(e.removeEnvVar("remote",fe[Ze]),fe.length===1||Ze>=fe.length-1&&e.setFieldIndex(o.fieldIndex-1))}}}}},{isActive:!o.showTemplateSelector&&!D&&R===null&&!z}),n<Ko||i<Qo)return c(g,{alignItems:"center",height:i,justifyContent:"center",width:n,children:u(a,{color:"yellow",children:["Terminal too small (",n,"x",i,"), need ",Ko,"x",Qo]})});if(o.showTemplateSelector)return c(g,{alignItems:"center",flexDirection:"column",height:i,justifyContent:"center",width:n,children:u(g,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[c(g,{justifyContent:"center",marginBottom:1,children:c(a,{bold:!0,color:"cyan",children:"Select a Template"})}),Lt.map((W,X)=>{const V=X===o.templateIndex;return c(g,{children:u(a,{color:V?"cyan":void 0,inverse:V,children:[V?" ❯ ":" ",c(a,{bold:V,children:W.name}),u(a,{dimColor:!0,children:[" - ",W.description]})]})},W.id)}),c(g,{justifyContent:"center",marginTop:1,children:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",c(a,{bold:!0,color:"white",children:"Enter"})," ","select"," ",c(a,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let je;switch(o.section){case"general":{je=c(Dg,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:$(W=>{e.updateConfig(W)},"onUpdate")});break}case"features":{je=c(Ag,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:S,searchText:o.featureSearch,viewportHeight:q});break}case"ports":{je=c(Hg,{addingPort:D,addPortValue:M,config:o.config,fieldIndex:o.fieldIndex});break}case"lifecycle":{je=c(Vg,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onSetCommand:$((W,X)=>{e.setLifecycleCommand(W,X)},"onSetCommand")});break}case"extensions":{je=c(Eg,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:S,searchText:o.extensionSearch,viewportHeight:q});break}case"environment":{je=u(g,{flexDirection:"column",children:[c($g,{config:o.config,fieldIndex:o.fieldIndex}),R!==null&&c(g,{marginTop:1,paddingX:1,children:u(a,{color:"cyan",children:["Add ",R," env:"," ",j==="key"?u(a,{children:["key=",c(a,{color:"yellow",children:G||"_"})," (Enter to set value)"]}):u(a,{children:[G,"=",c(a,{color:"yellow",children:w||"_"})," (Enter to confirm, Esc to cancel)"]})]})})]});break}case"mounts":{je=c(zg,{addingMount:z,config:o.config,detectedPm:o.detectedPm,fieldIndex:o.fieldIndex,mountPhase:I,mountSource:he,mountTarget:Te,mountType:Se,suggestedMounts:o.suggestedMounts});break}case"compose":{je=c(wg,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:$(W=>{e.updateConfig(W)},"onUpdate")});break}default:je=c(a,{children:"Unknown section"})}const Ot=u(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[u(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]}),(o.section==="features"||o.section==="extensions")&&u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Space"}),c(a,{dimColor:!0,children:"CHECK"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"←→"}),c(a,{dimColor:!0,children:"TABS"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]}),(o.section==="features"||o.section==="extensions")&&u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"/"}),c(a,{dimColor:!0,children:"FILTER"})]}),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"s"}),c(a,{dimColor:!0,children:"SAVE"})]})]}),u(g,{paddingX:1,children:[m&&u(a,{color:m.startsWith("Error")?"red":"green",children:[m," "]}),o.isDirty&&c(a,{color:"yellow",children:"[modified]"}),!o.isDirty&&!m&&c(a,{dimColor:!0,children:"[saved]"})]})]}),Na=u(xt,{footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"?"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:ye,title:"KEYBOARD SHORTCUTS",visible:s,width:56,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"←→"}),c(a,{dimColor:!0,children:" Switch tabs"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"↑↓"}),"/",c(a,{bold:!0,color:"white",children:"j/k"}),c(a,{dimColor:!0,children:" Navigate within section"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:" Switch editor/preview panel"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"Enter"}),c(a,{dimColor:!0,children:" Edit selected field"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"Esc"}),c(a,{dimColor:!0,children:" Stop editing / cancel"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"Space"}),c(a,{dimColor:!0,children:" Toggle selection"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"/"}),c(a,{dimColor:!0,children:" Search / filter"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"a"}),c(a,{dimColor:!0,children:" Add new entry"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"d"}),c(a,{dimColor:!0,children:" Delete selected entry"})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"ACTIONS"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"s"}),c(a,{dimColor:!0,children:" Save configuration"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:" Quit"})]}),u(a,{children:[" ",c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:" Toggle help"})]})]})]}),Da=Ke(()=>e.getJsonPreview(),[o.config]),Ma=c(Yg,{focused:b==="preview",hadComments:o.hadComments,jsonPreview:Da,mode:o.mode,scrollRef:Ae}),ko=n>=eh,Ba=ko?Math.floor(n*.38):0;return u(g,{flexDirection:"column",height:i,width:n,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),u(a,{wrap:"truncate",children:[o.mode==="create"?"Create":"Edit"," devcontainer"]})]}),c(g,{flexShrink:0,paddingX:1,paddingY:1,children:c(Li,{defaultValue:o.section,keyMap:{useNumbers:!1,useTab:!1},onChange:$(W=>{e.setSection(W),x("editor")},"onChange"),showIndex:!1,children:Zo.map(({id:W,label:X})=>c(Fi,{name:W,children:X},W))})}),c(g,{flexShrink:0,paddingRight:2,children:c(a,{dimColor:!0,wrap:"truncate",children:Zo.find(W=>W.id===o.section)?.description??""})}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{borderColor:b==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:je}),ko&&c(g,{flexShrink:0,width:Ba,children:Ma})]}),Ot,c(jt,{autoExitSeconds:3,onCancel:$(()=>{f(!1)},"onCancel"),visible:d}),Na]})},"VisDevcontainerApp");var nh=Object.defineProperty,ei=$((t,e)=>nh(t,"name",{value:e,configurable:!0}),"c$b");const oh={group:"Scaffold & Config",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"]],execute:ei(async({logger:t,options:e,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const n=r,i=e.template,o=e.output,s=!!process.stdout.isTTY&&!Ge;let l=null;try{l=me(n).name}catch{}const d=sg(n);let f=d?.config??null;const p=d?.hadComments??!1;if(i&&!d){const b=Lt.find(x=>x.id===i);if(!b){const x=Lt.map(S=>S.id).join(", ");throw new Error(`Unknown template "${i}". Valid templates: ${x}`)}f=b.config}if(!s){f?t.info(JSON.stringify(f,null,2)):(t.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const h=setInterval(()=>{},1e3),m=new fg(f,p,l);i&&!d&&m.dismissTemplateSelector();let y=null;if(await dt(_.createElement(rh,{onSave:ei(b=>{ag(n,b,o),y=b},"onSave"),store:m}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(h),y){const b=o??".devcontainer/devcontainer.json";t.info(`DevContainer config saved to ${b}`)}},"execute"),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}]};var ih=Object.defineProperty,sh=$((t,e)=>ih(t,"name",{value:e,configurable:!0}),"o$8");const ah={group:"Run & Execute",argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"]],execute:sh(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const i=t;if(!i||i.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[o,...s]=i,l=n??process.cwd(),d=me(l),f=r.package?Array.isArray(r.package)?r.package:[r.package]:[],p=Wn(d,{additionalPackages:f,args:s,package:o,shellMode:r.shellMode||!1,silent:r.silent||!1},l,e);p!==0&&(process.exitCode=p)},"execute"),name:"dlx",options:[{alias:"p",description:"Additional packages to install (repeatable)",multiple:!0,name:"package",type:String},{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output except command results",name:"silent",type:Boolean}]};var ch=Object.defineProperty,We=$((t,e)=>ch(t,"name",{value:e,configurable:!0}),"c$a");const lh=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],dh=["overrides","pnpm","resolutions"],uh=["engines","files"],ph=We(t=>{const e=qr(t)?.major;return e!==void 0&&e>=10},"isPnpmV10Plus"),fh=We(t=>{const e=T(t,"pnpm-workspace.yaml");if(!le(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Kr(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},"readPnpmWorkspaceOverrides"),gh=We((t,e)=>{let r={};return e==="pnpm"?r=t.pnpm?.overrides??{}:e==="yarn"||e==="bun"?r=t.resolutions??{}:r=t.overrides??{},{overrides:r,source:"package.json"}},"readPkgJsonOverrides"),hh=We((t,e,r)=>r.name==="pnpm"&&ph(r.version)?fh(t):gh(e,r.name),"readOverrides"),ti=We((t,e)=>{const r=e;for(const i of dh){const o=t.indexOf(i);if(o!==-1&&i!==r)return r==="overrides"?o:o+1}let n=-1;for(const i of lh){const o=t.indexOf(i);o>n&&(n=o)}if(n!==-1)return n+1;for(const i of uh){const o=t.indexOf(i);if(o!==-1)return o}return t.length},"findInsertIndex"),mh=We(t=>/\n(\s+)/.exec(t)?.[1]??" ","detectIndent"),yh=We((t,e)=>{const r=T(t,"pnpm-workspace.yaml");if(!F(r))throw new Error(`pnpm-workspace.yaml not found at ${r}. Cannot write overrides for pnpm v10+.`);let n=K(r,"utf8");const i=`overrides:
|
|
292
|
-
${Object.entries(e).
|
|
313
|
+
`;Q(n,o),Z("Created .ai/instructions")},"generateAiInstructions"),fk=ar(t=>{ct("git",["init"],{cwd:t,stdio:"pipe"}).status===0?Z("Initialized git repository"):se("Failed to initialize git repository")},"initGitRepo"),gk=ar((t,e,r,n=!1)=>(S("Installing dependencies..."),Oo(e,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:n,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},t,r)===0?(Z("Dependencies installed"),!0):(se("Dependency installation failed (you can run install manually)"),!1)),"installDependencies"),hk=ar(t=>{const e=t.split("#")[0].split("?")[0].replace(/\/+$/,"").replace(/\.git$/,"").split("/").filter(Boolean).at(-1)??"",r=e.includes(":")?e.split(":").pop()??e:e;return Cn(r)||"my-project"},"extractRepoName"),mk=ar(t=>{if(S(""),S(" Built-in templates:"),S(` ${ye(Be("vis:monorepo"))} ${re("Full pnpm workspace setup")}`),S(` ${ye(Be("vis:app"))} ${re("Application scaffold via create-vite")}`),S(` ${ye(Be("vis:library"))} ${re("Reusable TypeScript library package")}`),S(` ${ye(Be("vis:generator"))} ${re("Code generator scaffold with bin entry")}`),t&&Object.keys(t).length>0){S(""),S(" Config aliases (vis.config.ts → create.templates):");for(const[e,r]of Object.entries(t))S(` ${ye(Be(e))}${" ".repeat(Math.max(1,16-e.length))}${re(r)}`)}S(""),S(" Remote templates:"),S(` ${re("Any npm create-* package:")} vis create vite`),S(` ${re("GitHub repository:")} vis create user/repo`),S(` ${re("GitLab / Bitbucket:")} vis create gitlab:user/repo`),S(` ${re("Full URL:")} vis create https://github.com/user/repo`),S(""),S(` ${re("Template args after --:")} vis create vite -- --template react-ts`),S("")},"listTemplates"),yk=ar((t,e,r,n)=>{const o=$e(e)===$e(t)?"":t;process.stderr.write(`
|
|
314
|
+
`),Z("Project created successfully!"),process.stderr.write(`
|
|
315
|
+
`),ie("Next steps:"),o&&S(` cd ${o}`),n||S(` ${r} install`),S(` ${r} run dev`),process.stderr.write(`
|
|
316
|
+
`)},"printNextSteps"),vk={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"]],execute:ar(async({argument:t,logger:e,options:r,rawUnknown:n,visConfig:o,workspaceRoot:i})=>{const s=Array.isArray(t)?t:t?[t]:[],a=o?.create;if(r.list){mk(a?.templates);return}const c=r.cwd||i||process.cwd(),d=!!i,p=!!process.stdin.isTTY,g=Ne(c);let m,y,v,k=a?.defaultEditor,$=a?.gitInit??!1,x=[],E=g,A=!1;if(s.length===0&&p&&!r.noInteractive){const j=await Nw({cwd:c,defaultEditor:a?.defaultEditor,defaultGitInit:a?.gitInit,defaultPm:a?.defaultPm,inMonorepo:d});m=j.template,y=j.projectName,v=$e(c,j.targetDir),k=j.editor??k,$=j.gitInit,A=j.overwrite,j.pm&&(E={name:j.pm,version:g.version})}else{if(s.length===0)throw new Error(`No template specified. Usage: vis create <template> [name] [-- args...]
|
|
317
|
+
Use --list to see available templates, or run interactively in a terminal.`);{let j=[...n??[]];if(j.length===0){const P=process.argv.slice(2),B=P.indexOf("--");B!==-1&&(j=P.slice(B+1))}const R=s.indexOf("--"),V=R===-1?s:s.slice(0,R);x=[...R===-1?[]:s.slice(R+1),...j],m=V[0],y=V[1],y||(y=hk(m)),k=r.editor==="vscode"?"vscode":k,$=!!r.gitInit||$}}if(!m)throw new Error("No template specified.");const L=a?.templates?.[m]??m,I=xw(L,x);if(!v){const j=d?Cw(I.type):".",R=Aw(y,$e(c,j));v=R.targetDir,y=R.packageName}const M=Cn(y??"");if(!id(M))throw new Error(`Invalid project name: "${y}". Use lowercase alphanumeric characters and hyphens.`);y=M;const F=$e(v),_=_e($e(c),F);if(_===".."||_.startsWith(`..${Cc}`)||nt(_))throw new Error(`Target directory "${v}" is outside the working directory. Use a name without "../" path segments.`);if(!A&&!Ow(v))throw new Error(`Target directory "${v}" is not empty.
|
|
318
|
+
Use a different name or clear the directory first.`);L!==m&&S(`Alias: ${ye(Be(m))} → ${re(L)}`),S(`Template: ${ye(Be(L))}`),S(`Project: ${ye(y)}`),S(`Target: ${re(v)}`),process.stderr.write(`
|
|
319
|
+
`);const N=await lk(I,{createConfig:a,cwd:c,inMonorepo:d,logger:e,pm:E,projectName:y,targetDir:v});if(N!==0){process.exitCode=N;return}k==="vscode"&&uk(v),T(v)&&pk(v,E.name),$&&!d&&fk(v);let C=!1;a?.install!==!1&&T(w(v,"package.json"))&&(C=gk(v,E,e,a?.preferOffline)),yk(v,c,E.name,C)},"execute"),group:"Scaffold & Config",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}]};var wk=Object.defineProperty,kk=b((t,e)=>wk(t,"name",{value:e,configurable:!0}),"i$b");const bk={description:"Deduplicate dependencies using the detected package manager",examples:[["vis dedupe","Run deduplication"],["vis dedupe --check","Preview changes without modifying (CI-friendly)"]],execute:kk(async({logger:t,options:e,workspaceRoot:r})=>{const n=r??process.cwd(),o=Ne(n),i=Qg(o,e.check||!1,n,t);i!==0&&(process.exitCode=i)},"execute"),group:"Dependencies",name:"dedupe",options:[{defaultValue:!1,description:"Preview changes without modifying files (dry-run)",name:"check",type:Boolean}]},Gr=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}];var $k=Object.defineProperty,ad=b((t,e)=>$k(t,"name",{value:e,configurable:!0}),"s$j");const Sk=ad(t=>{const e=w(t,".devcontainer","devcontainer.json");if(!T(e))return null;const r=ee(e),n=kp(r),o=n!==r;let i;try{i=JSON.parse(n)}catch(s){const a=s instanceof Error?s.message:String(s);throw new Error(`Failed to parse ${e}: ${a}`)}return{config:i,hadComments:o}},"readDevcontainerJson"),xk=ad((t,e,r)=>{const n=r?Nt(r):w(t,".devcontainer"),o=r??w(n,"devcontainer.json");je(n),Se(o,`${JSON.stringify(e,null,2)}
|
|
320
|
+
`,"utf8")},"writeDevcontainerJson");var Ck=Object.defineProperty,jk=b((t,e)=>Ck(t,"name",{value:e,configurable:!0}),"s$i");const Tk={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},Ek=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],ba=jk((t,e,r)=>{const n=[],o=new Set(r.map(s=>typeof s=="string"?s:s.target));if(t)for(const s of Tk[t])o.has(s.target)||n.push(s);const i=Object.keys(e);for(const{featureMatch:s,mounts:a}of Ek)if(i.some(c=>c.includes(s)))for(const c of a)o.has(c.target)||n.push(c);return n},"getSuggestedMounts"),gr=["general","features","ports","lifecycle","extensions","environment","mounts","compose"];var Rk=Object.defineProperty,oo=b((t,e)=>Rk(t,"name",{value:e,configurable:!0}),"c$o");const an=oo(t=>structuredClone(t),"deepClone");class Ik{static{b(this,"DevcontainerStore")}static{oo(this,"DevcontainerStore")}#e=new Set;#t;constructor(e,r,n=null){const o=e===null,i=e??{name:""},s=an(i);this.#t={config:s,detectedPm:n,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:r,isDirty:!1,mode:o?"create":"edit",originalConfig:o?null:an(i),section:"general",showTemplateSelector:o,suggestedMounts:ba(n,s.features??{},s.mounts??[]),templateIndex:0}}getSnapshot=oo(()=>this.#t,"getSnapshot");subscribe=oo(e=>(this.#e.add(e),()=>{this.#e.delete(e)}),"subscribe");setSection(e){e!==this.#t.section&&this.#r({...this.#t,fieldEditing:!1,fieldIndex:0,section:e})}nextSection(){const e=(gr.indexOf(this.#t.section)+1)%gr.length;this.setSection(gr[e])}previousSection(){const e=(gr.indexOf(this.#t.section)-1+gr.length)%gr.length;this.setSection(gr[e])}setFieldIndex(e){e!==this.#t.fieldIndex&&this.#r({...this.#t,fieldIndex:Math.max(0,e)})}setFieldEditing(e){e!==this.#t.fieldEditing&&this.#r({...this.#t,fieldEditing:e})}setTemplateIndex(e){const r=Math.max(0,Math.min(e,Gr.length-1));r!==this.#t.templateIndex&&this.#r({...this.#t,templateIndex:r})}applyTemplate(e){const r=Gr.find(n=>n.id===e);r&&this.#r(this.#o({...this.#t,config:an(r.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#r({...this.#t,showTemplateSelector:!1})}updateConfig(e){this.#r({...this.#t,config:{...this.#t.config,...e},isDirty:!0})}toggleFeature(e){const r={...this.#t.config.features};r[e]===void 0?r[e]={}:delete r[e],this.#r(this.#o({...this.#t,config:{...this.#t.config,features:r},isDirty:!0}))}setFeatureSearch(e){this.#r({...this.#t,featureSearch:e,fieldIndex:0})}addPort(e){const r=this.#t.config.forwardPorts??[];if(r.includes(e))return;const n=[...r,e];this.#r({...this.#t,config:{...this.#t.config,forwardPorts:n},isDirty:!0})}removePort(e){const r=[...this.#t.config.forwardPorts??[]];r.splice(e,1),this.#r({...this.#t,config:{...this.#t.config,forwardPorts:r.length>0?r:void 0},isDirty:!0})}toggleExtension(e){const r={...this.#t.config.customizations},n={...r.vscode},o=[...n.extensions??[]],i=o.indexOf(e);i===-1?o.push(e):o.splice(i,1),n.extensions=o.length>0?o:void 0,r.vscode=n.extensions||n.settings?n:void 0,this.#r({...this.#t,config:{...this.#t.config,customizations:r.vscode||r.jetbrains?r:void 0},isDirty:!0})}setExtensionSearch(e){this.#r({...this.#t,extensionSearch:e,fieldIndex:0})}addEnvVar(e,r,n){const o=e==="container"?"containerEnv":"remoteEnv",i={...this.#t.config[o],[r]:n};this.#r({...this.#t,config:{...this.#t.config,[o]:i},isDirty:!0})}removeEnvVar(e,r){const n=e==="container"?"containerEnv":"remoteEnv",o={...this.#t.config[n]};delete o[r],this.#r({...this.#t,config:{...this.#t.config,[n]:Object.keys(o).length>0?o:void 0},isDirty:!0})}addMount(e){const r=[...this.#t.config.mounts??[],e];this.#r(this.#o({...this.#t,config:{...this.#t.config,mounts:r},isDirty:!0}))}removeMount(e){const r=[...this.#t.config.mounts??[]];r.splice(e,1),this.#r(this.#o({...this.#t,config:{...this.#t.config,mounts:r.length>0?r:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#t.suggestedMounts.length===0)return;const e=[...this.#t.config.mounts??[],...this.#t.suggestedMounts];this.#r(this.#o({...this.#t,config:{...this.#t.config,mounts:e},isDirty:!0}))}setLifecycleCommand(e,r){this.#r({...this.#t,config:{...this.#t.config,[e]:r||void 0},isDirty:!0})}markClean(){this.#r({...this.#t,isDirty:!1,originalConfig:an(this.#t.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const e=an(this.#t.config);for(const[r,n]of Object.entries(e))(n===""||n===void 0)&&delete e[r];return e.build&&(e.build.dockerfile===""&&delete e.build.dockerfile,e.build.context===""&&delete e.build.context,e.build.args&&Object.keys(e.build.args).length===0&&delete e.build.args,Object.keys(e.build).length===0&&delete e.build),e.forwardPorts?.length===0&&delete e.forwardPorts,e.mounts?.length===0&&delete e.mounts,e.runServices?.length===0&&delete e.runServices,e.capAdd?.length===0&&delete e.capAdd,e.securityOpt?.length===0&&delete e.securityOpt,e.features&&Object.keys(e.features).length===0&&delete e.features,e.customizations?.vscode?.extensions?.length===0&&delete e.customizations.vscode.extensions,e.customizations?.vscode&&Object.keys(e.customizations.vscode).length===0&&delete e.customizations.vscode,e.customizations&&Object.keys(e.customizations).length===0&&delete e.customizations,e.containerEnv&&Object.keys(e.containerEnv).length===0&&delete e.containerEnv,e.remoteEnv&&Object.keys(e.remoteEnv).length===0&&delete e.remoteEnv,e}#o(e){return{...e,suggestedMounts:ba(e.detectedPm,e.config.features??{},e.config.mounts??[])}}#r(e){this.#t=e;for(const r of this.#e)try{r()}catch{}}}const $a=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],Sa=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}];var Ak=Object.defineProperty,cd=b((t,e)=>Ak(t,"name",{value:e,configurable:!0}),"r$d");const ps=cd(t=>{if(!t)return Sa;const e=t.toLowerCase();return Sa.filter(r=>r.name.toLowerCase().includes(e)||r.id.toLowerCase().includes(e)||r.description.toLowerCase().includes(e))},"filterFeatures"),fs=cd(t=>{if(!t)return $a;const e=t.toLowerCase();return $a.filter(r=>r.name.toLowerCase().includes(e)||r.id.toLowerCase().includes(e)||r.description.toLowerCase().includes(e))},"filterExtensions");var Ok=Object.defineProperty,Pk=b((t,e)=>Ok(t,"name",{value:e,configurable:!0}),"l$g");const ld=["dockerComposeFile","service"],Nk={dockerComposeFile:"Compose File",service:"Service"},xa={dockerComposeFile:"docker-compose.yml",service:"app"},Mk={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},Dk=Pk(({config:t,fieldEditing:e,fieldIndex:r,onUpdate:n})=>{const o=!!t.dockerComposeFile,i=!!(t.image||t.build);return f(h,{flexDirection:"column",paddingX:1,children:[u(h,{marginBottom:1,children:u(l,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),i&&o&&u(h,{marginBottom:1,children:u(l,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),ld.map((s,a)=>{const c=a===r,d=t[s]??"",p=Array.isArray(t[s])?t[s].join(", "):d;return f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{children:[u(h,{width:20,children:f(l,{bold:c,color:c?"cyan":"white",children:[c?"❯ ":" ",Nk[s],":"]})}),u(h,{flexGrow:1,children:c&&e?u(_i,{defaultValue:p,onChange:b(g=>{n({[s]:g||void 0})},"onChange"),placeholder:xa[s]}):u(l,{color:p?"white":"gray",children:p||xa[s]})})]}),u(h,{paddingLeft:4,children:u(l,{dimColor:!0,children:Mk[s]})})]},s)}),u(h,{marginTop:1,children:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",u(l,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",u(l,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},"DockerComposeSection"),Bk=ld.length;var Fk=Object.defineProperty,dd=b((t,e)=>Fk(t,"name",{value:e,configurable:!0}),"h$m");const Lk=dd(({config:t,fieldIndex:e})=>{const r=t.containerEnv??{},n=t.remoteEnv??{},o=Object.keys(r),i=Object.keys(n),s=o.length,a=o.length+1,c=a+i.length,d=e<=s,p=e>s;return f(h,{flexDirection:"column",paddingX:1,children:[f(h,{borderColor:d?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[f(h,{flexShrink:0,marginBottom:o.length>0?1:0,children:[u(l,{bold:!0,color:d?"cyan":"white",children:"containerEnv"}),u(l,{dimColor:!0,children:" — baked into the container image"})]}),o.map((g,m)=>{const y=m===e;return u(h,{flexShrink:0,children:f(l,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",u(l,{bold:!0,children:g}),u(l,{dimColor:!0,children:" = "}),u(l,{children:r[g]})]})},g)}),u(h,{flexShrink:0,marginTop:o.length>0?1:0,children:f(l,{color:e===s?"cyan":"gray",inverse:e===s,children:[" ","+ Add variable..."]})})]}),f(h,{borderColor:p?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[f(h,{flexShrink:0,marginBottom:i.length>0?1:0,children:[u(l,{bold:!0,color:p?"cyan":"white",children:"remoteEnv"}),u(l,{dimColor:!0,children:" — set at runtime by the IDE"})]}),i.map((g,m)=>{const y=a+m===e;return u(h,{flexShrink:0,children:f(l,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",u(l,{bold:!0,children:g}),u(l,{dimColor:!0,children:" = "}),u(l,{children:n[g]})]})},g)}),u(h,{flexShrink:0,marginTop:i.length>0?1:0,children:f(l,{color:e===c?"cyan":"gray",inverse:e===c,children:[" ","+ Add variable..."]})})]}),u(h,{flexShrink:0,marginTop:1,children:f(l,{dimColor:!0,wrap:"truncate",children:[u(l,{bold:!0,color:"white",children:"a"}),"/",u(l,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",u(l,{bold:!0,color:"white",children:"d"})," ","remove"," ",u(l,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},"EnvironmentSection"),Vk=dd(t=>{const e=Object.keys(t.containerEnv??{}).length,r=Object.keys(t.remoteEnv??{}).length;return e+1+r+1},"getEnvFieldCount");var Uk=Object.defineProperty,_k=b((t,e)=>Uk(t,"name",{value:e,configurable:!0}),"h$l");const Gk=_k(({config:t,fieldIndex:e,scrollOffset:r,searchText:n,viewportHeight:o})=>{const i=At(()=>new Set(t.customizations?.vscode?.extensions),[t.customizations?.vscode?.extensions]),s=At(()=>fs(n),[n]),a=s.length,c=a>o&&o>0;return f(h,{flexDirection:"column",flexGrow:1,children:[f(h,{flexShrink:0,gap:1,paddingX:1,children:[f(l,{bold:!0,color:"cyan",children:[i.size," ","selected"]}),n&&f(l,{dimColor:!0,children:["— filter:"," ",u(l,{color:"yellow",children:n})," ","(",s.length," ","results)"]})]}),f(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[u(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:u(h,{flexDirection:"column",marginTop:-r,children:s.map((d,p)=>{const g=p===e,m=i.has(d.id);return f(h,{flexShrink:0,height:1,children:[u(l,{children:g?">":" "}),f(l,{color:m?"white":"gray",children:[" ",m?"☑":"☐"," "]}),u(h,{flexGrow:1,children:f(l,{bold:g,inverse:g,wrap:"truncate",children:[d.name,f(l,{dimColor:!0,children:[" ","-",d.id]})]})})]},d.id)})})}),c&&u(h,{flexShrink:0,marginLeft:1,marginRight:1,children:u(An,{contentHeight:a,placement:"inset",scrollOffset:r,style:"block",viewportHeight:o})})]}),s.length===0&&u(h,{paddingX:1,children:u(l,{dimColor:!0,children:"No extensions match the search."})})]})},"ExtensionsSection");var Wk=Object.defineProperty,zk=b((t,e)=>Wk(t,"name",{value:e,configurable:!0}),"p$t");const Hk=zk(({config:t,fieldIndex:e,scrollOffset:r,searchText:n,viewportHeight:o})=>{const i=At(()=>new Set(Object.keys(t.features??{})),[t.features]),s=At(()=>ps(n),[n]),a=s.length,c=a>o&&o>0;return f(h,{flexDirection:"column",flexGrow:1,children:[f(h,{flexShrink:0,gap:1,paddingX:1,children:[f(l,{bold:!0,color:"cyan",children:[i.size," ","selected"]}),n&&f(l,{dimColor:!0,children:["— filter:"," ",u(l,{color:"yellow",children:n})," ","(",s.length," ","results)"]})]}),f(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[u(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:u(h,{flexDirection:"column",marginTop:-r,children:s.map((d,p)=>{const g=p===e,m=i.has(d.id);return f(h,{flexShrink:0,height:1,children:[u(l,{children:g?">":" "}),f(l,{color:m?"white":"gray",children:[" ",m?"☑":"☐"," "]}),u(h,{flexGrow:1,children:f(l,{bold:g,inverse:g,wrap:"truncate",children:[d.name,f(l,{dimColor:!0,children:[" ","-",d.description]})]})})]},d.id)})})}),c&&u(h,{flexShrink:0,marginLeft:1,marginRight:1,children:u(An,{contentHeight:a,placement:"inset",scrollOffset:r,style:"block",viewportHeight:o})})]}),s.length===0&&u(h,{paddingX:1,children:u(l,{dimColor:!0,children:"No features match the search."})})]})},"FeaturesSection");var qk=Object.defineProperty,Jk=b((t,e)=>qk(t,"name",{value:e,configurable:!0}),"u$i");const ki=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],Yk={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},Ca={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},ho=["privileged","overrideCommand"],Kk={overrideCommand:"Override Command",privileged:"Privileged"},Xk=ki.length+ho.length,Qk=Jk(({config:t,fieldEditing:e,fieldIndex:r,onUpdate:n})=>f(h,{flexDirection:"column",paddingX:1,children:[u(h,{marginBottom:1,children:u(l,{bold:!0,color:"cyan",children:"General Configuration"})}),ki.map((o,i)=>{const s=i===r,a=t[o]??"";return f(h,{marginBottom:1,children:[u(h,{width:20,children:f(l,{bold:s,color:s?"cyan":"white",children:[s?"❯ ":" ",Yk[o],":"]})}),u(h,{flexGrow:1,children:s&&e?u(_i,{defaultValue:a,onChange:b(c=>{n({[o]:c})},"onChange"),placeholder:Ca[o]}):u(l,{color:a?"white":"gray",children:a||Ca[o]})})]},o)}),ho.map((o,i)=>{const s=ki.length+i===r,a=t[o]??!1;return f(h,{marginBottom:i<ho.length-1?1:0,children:[u(h,{width:20,children:f(l,{bold:s,color:s?"cyan":"white",children:[s?"❯ ":" ",Kk[o],":"]})}),u(h,{flexGrow:1,children:f(l,{color:a?"green":"gray",children:[a?"yes":"no",s&&u(l,{dimColor:!0,children:" (Space to toggle)"})]})})]},o)}),u(h,{marginTop:1,children:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",u(l,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",u(l,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",u(l,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),"GeneralSection"),ud=Xk,ii=ho;var Zk=Object.defineProperty,eb=b((t,e)=>Zk(t,"name",{value:e,configurable:!0}),"s$g");const pd=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],tb={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},rb={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},nb=eb(({config:t,fieldEditing:e,fieldIndex:r,onSetCommand:n})=>f(h,{flexDirection:"column",paddingX:1,children:[u(h,{marginBottom:1,children:u(l,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),pd.map((o,i)=>{const s=i===r,a=t[o],c=Array.isArray(a)?a.join(" && "):a??"";return f(h,{flexDirection:"column",marginBottom:1,children:[u(h,{children:f(l,{bold:s,color:s?"cyan":"white",children:[s?"❯ ":" ",tb[o]]})}),u(h,{paddingLeft:4,children:u(l,{dimColor:!0,children:rb[o]})}),u(h,{paddingLeft:4,children:s&&e?u(_i,{defaultValue:c,onChange:b(d=>{n(o,d)},"onChange"),placeholder:"e.g. npm install"}):u(l,{color:c?"green":"gray",children:c||"(not set)"})})]},o)}),u(h,{marginTop:1,children:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",u(l,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",u(l,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),"LifecycleSection"),ob=pd.length;var ib=Object.defineProperty,fd=b((t,e)=>ib(t,"name",{value:e,configurable:!0}),"s$f");const ja=fd(t=>typeof t=="string"?t:`[${t.type}] ${t.source} → ${t.target}`,"formatMount"),sb=fd(({addingMount:t,config:e,detectedPm:r,fieldIndex:n,mountPhase:o,mountSource:i,mountTarget:s,mountType:a,suggestedMounts:c})=>{const d=e.mounts??[];return f(h,{flexDirection:"column",paddingX:1,children:[f(h,{flexShrink:0,gap:1,paddingX:1,children:[f(l,{bold:!0,color:"cyan",children:[d.length," ","mounts"]}),r&&f(l,{dimColor:!0,children:["— detected:"," ",u(l,{color:"white",children:r})]})]}),c.length>0&&!t&&f(h,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[f(h,{flexShrink:0,children:[u(l,{bold:!0,color:"yellow",children:"Suggested mounts"}),f(l,{dimColor:!0,children:[" ","— press"," ",u(l,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),c.map((p,g)=>u(h,{flexShrink:0,children:f(l,{dimColor:!0,wrap:"truncate",children:[" + ",ja(p)]})},`suggestion-${String(g)}`))]}),d.length>0&&u(h,{flexDirection:"column",marginBottom:1,children:d.map((p,g)=>{const m=g===n;return f(h,{flexShrink:0,height:1,children:[u(l,{children:m?">":" "}),u(h,{flexGrow:1,children:f(l,{bold:m,inverse:m,wrap:"truncate",children:[" ",ja(p)]})})]},`mount-${String(g)}`)})}),!t&&u(h,{flexShrink:0,children:f(l,{color:n===d.length?"cyan":"gray",inverse:n===d.length,children:[" ","+ Add mount..."]})}),t&&f(h,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[u(h,{flexShrink:0,marginBottom:1,children:u(l,{bold:!0,color:"cyan",children:"New Mount"})}),f(h,{flexShrink:0,children:[u(h,{width:12,children:f(l,{bold:o==="source",color:o==="source"?"cyan":"white",children:[o==="source"?"❯ ":" ","Source:"]})}),u(l,{color:i?"yellow":"gray",children:i||(o==="source"?"_":"(type source, Enter to continue)")})]}),f(h,{flexShrink:0,children:[u(h,{width:12,children:f(l,{bold:o==="target",color:o==="target"?"cyan":"white",children:[o==="target"?"❯ ":" ","Target:"]})}),u(l,{color:s?"yellow":"gray",children:s||(o==="target"?"_":"/container/path")})]}),f(h,{flexShrink:0,children:[u(h,{width:12,children:f(l,{bold:o==="type",color:o==="type"?"cyan":"white",children:[o==="type"?"❯ ":" ","Type:"]})}),o==="type"?f(l,{children:[u(l,{bold:a==="volume",color:a==="volume"?"cyan":"gray",children:"[1] volume"})," ",u(l,{bold:a==="bind",color:a==="bind"?"cyan":"gray",children:"[2] bind"})," ",u(l,{bold:a==="tmpfs",color:a==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):u(l,{color:"gray",children:a})]}),u(h,{flexShrink:0,marginTop:1,children:u(l,{dimColor:!0,wrap:"truncate",children:o==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),d.length===0&&!t&&c.length===0&&u(h,{marginTop:1,children:u(l,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},"MountsSection");var ab=Object.defineProperty,cb=b((t,e)=>ab(t,"name",{value:e,configurable:!0}),"m$f");const lb=cb(({addingPort:t,addPortValue:e,config:r,fieldIndex:n})=>{const o=r.forwardPorts??[],i=n===o.length;return f(h,{flexDirection:"column",paddingX:1,children:[f(h,{marginBottom:1,children:[u(l,{bold:!0,color:"cyan",children:"Forwarded Ports"}),f(l,{dimColor:!0,children:[" ","(",o.length," ","ports)"]})]}),o.map((s,a)=>{const c=a===n;return u(h,{children:f(l,{color:c?"cyan":void 0,inverse:c,children:[" ",String(s)]})},`port-${String(s)}`)}),u(h,{marginTop:o.length>0?1:0,children:f(l,{color:i?"cyan":"gray",inverse:i,children:[" ",i&&t?f(l,{children:["Enter port:"," ",u(l,{color:"yellow",children:e||"_"})]}):"+ Add port..."]})}),u(h,{marginTop:1,children:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"Enter"})," ",i?"type port number, Enter to confirm":"select"," ",u(l,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",u(l,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},"PortsSection");var db=Object.defineProperty,ub=b((t,e)=>db(t,"name",{value:e,configurable:!0}),"a$f");const pb=ub(({focused:t,hadComments:e,jsonPreview:r,mode:n,scrollRef:o})=>f(h,{borderColor:t?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(h,{flexShrink:0,paddingX:1,children:[u(l,{bold:!0,color:t?"cyan":"white",children:"Preview"}),f(l,{dimColor:!0,children:[" ","(",n==="create"?"new":"edit",")"]})]}),e&&n==="edit"&&u(h,{flexShrink:0,paddingX:1,children:u(l,{color:"yellow",children:"Comments will not be preserved."})}),u(qr,{flexGrow:1,ref:o,scrollbar:!0,scrollbarColor:"gray",children:r.split(`
|
|
321
|
+
`).map((i,s)=>u(l,{color:"green",children:i},`line-${String(s)}`))})]}),"PreviewPanel");var fb=Object.defineProperty,gb=b((t,e)=>fb(t,"name",{value:e,configurable:!0}),"r$c");const hb=gb(t=>{const e=[],r=[],n=[];if(!t.image&&!t.build&&!t.dockerComposeFile&&e.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),t.build&&(t.image&&r.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),t.build.dockerfile||e.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),t.dockerComposeFile&&!t.service&&e.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),t.features!==void 0&&(typeof t.features!="object"||Array.isArray(t.features))&&e.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),t.forwardPorts)if(Array.isArray(t.forwardPorts))for(const[o,i]of t.forwardPorts.entries())typeof i=="number"&&(i<1||i>65535)&&e.push({field:"forwardPorts",message:`Invalid port ${String(i)} at index ${String(o)}`});else e.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return t.customizations?.vscode?.extensions&&!Array.isArray(t.customizations.vscode.extensions)&&e.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),t.customizations?.vscode?.settings&&typeof t.customizations.vscode.settings!="object"&&e.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),t.name||n.push({field:"name",message:"Consider adding a name for better identification"}),(!t.features||Object.keys(t.features).length===0)&&n.push({field:"features",message:"Consider adding features for common tools"}),(!t.customizations?.vscode?.extensions||t.customizations.vscode.extensions.length===0)&&n.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),t.privileged&&r.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:e,suggestions:n,valid:e.length===0,warnings:r}},"validateConfig");var mb=Object.defineProperty,gd=b((t,e)=>mb(t,"name",{value:e,configurable:!0}),"$$b");const Ta=80,Ea=15,yb=120,Ra=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],vb=gd((t,e,r,n)=>{switch(t){case"compose":return Bk;case"environment":return Vk(e);case"extensions":return fs(n).length;case"features":return ps(r).length;case"general":return ud;case"lifecycle":return ob;case"mounts":return(e.mounts?.length??0)+1;case"ports":return(e.forwardPorts?.length??0)+1;default:return 0}},"getFieldCount"),wb=gd(({onSave:t,store:e})=>{const{exit:r}=Hr(),{columns:n,rows:o}=zr(),i=On(e.subscribe,e.getSnapshot),[s,a]=ve(!1),[c,d]=ve(!1),[p,g]=ve(!1),[m,y]=ve(null),[v,k]=ve("editor"),[$,x]=ve(0),[E,A]=ve(!1),[L,I]=ve(""),[M,F]=ve(null),[_,N]=ve(""),[C,j]=ve(""),[R,V]=ve("key"),[P,B]=ve(!1),[q,J]=ve(""),[ce,le]=ve(""),[ke,D]=ve("volume"),[O,z]=ve("source"),me=Ve(null),Te=Ve(null),Ie=Ve(null),xt=Ve(!0);Rt(()=>(xt.current=!0,()=>{xt.current=!1,Ie.current&&clearTimeout(Ie.current)}),[]);const K=vb(i.section,i.config,i.featureSearch,i.extensionSearch),te=Math.max(1,o-9);Rt(()=>{i.section!=="features"&&i.section!=="extensions"||x(W=>i.fieldIndex>=W+te?i.fieldIndex-te+1:i.fieldIndex<W?i.fieldIndex:W)},[i.fieldIndex,i.section,te]),Rt(()=>{x(0)},[i.section,i.featureSearch,i.extensionSearch]);const fe=It(()=>{const W=e.cleanConfig(),H=hb(W);if(!H.valid){const ne=H.errors[0];y(ne?`Error: ${ne.message}`:"Validation failed"),Ie.current&&clearTimeout(Ie.current),Ie.current=setTimeout(()=>{xt.current&&y(null)},3e3);return}t(W),e.markClean();const G=H.warnings.length;y(G>0?`Saved! (${String(G)} warning${G>1?"s":""})`:"Saved!"),Ie.current&&clearTimeout(Ie.current),Ie.current=setTimeout(()=>{xt.current&&y(null)},2e3)},[t,e]);mt((W,H)=>{if(H.downArrow||W==="j")e.setTemplateIndex(i.templateIndex+1);else if(H.upArrow||W==="k")e.setTemplateIndex(i.templateIndex-1);else if(H.return){const G=Gr[i.templateIndex];G&&e.applyTemplate(G.id)}else H.escape&&e.dismissTemplateSelector()},{isActive:i.showTemplateSelector}),mt((W,H)=>{if(H.escape){A(!1),I("");return}if(H.return){const G=Number.parseInt(L,10);!Number.isNaN(G)&&G>0&&G<=65535&&e.addPort(G),A(!1),I("");return}if(H.backspace){I(G=>G.slice(0,-1));return}W&&/^\d$/u.test(W)&&I(G=>G+W)},{isActive:E}),mt((W,H)=>{if(H.escape){F(null),N(""),j(""),V("key");return}if(H.return){if(R==="key"&&_){V("value");return}if(R==="value"&&_){e.addEnvVar(M,_,C),F(null),N(""),j(""),V("key");return}}if(H.backspace){R==="key"?N(G=>G.slice(0,-1)):j(G=>G.slice(0,-1));return}W&&!H.ctrl&&!H.meta&&(R==="key"?N(G=>G+W):j(G=>G+W))},{isActive:M!==null}),mt((W,H)=>{if(H.escape){B(!1),J(""),le(""),z("source");return}if(H.return){if(O==="source"&&q){z("target");return}if(O==="target"&&ce){z("type");return}if(O==="type"){e.addMount({source:q,target:ce,type:ke}),B(!1),J(""),le(""),z("source");return}}if(O==="type"){switch(W){case"1":{D("volume");break}case"2":{D("bind");break}case"3":{D("tmpfs");break}}return}if(H.backspace){O==="source"?J(G=>G.slice(0,-1)):O==="target"&&le(G=>G.slice(0,-1));return}W&&!H.ctrl&&!H.meta&&(O==="source"?J(G=>G+W):O==="target"&&le(G=>G+W))},{isActive:P}),mt((W,H)=>{if(W==="c"&&H.ctrl){r();return}if(!c){if(s){H.escape||W==="?"?a(!1):H.downArrow||W==="j"?me.current?.scrollBy(1):H.upArrow||W==="k"?me.current?.scrollBy(-1):W==="q"&&(a(!1),d(!0));return}if(p){if(H.escape){g(!1),i.section==="features"?e.setFeatureSearch(""):e.setExtensionSearch("");return}if(H.return){g(!1);return}if(H.backspace){i.section==="features"?e.setFeatureSearch(i.featureSearch.slice(0,-1)):e.setExtensionSearch(i.extensionSearch.slice(0,-1));return}if(W&&!H.ctrl&&!H.meta){i.section==="features"?e.setFeatureSearch(i.featureSearch+W):e.setExtensionSearch(i.extensionSearch+W);return}return}if(i.fieldEditing){if(H.escape){e.setFieldEditing(!1);return}if(H.return){e.setFieldEditing(!1);return}return}if(W==="?"){a(!0);return}if(W==="q"){i.isDirty?d(!0):r();return}if(W==="s"){fe();return}if(H.tab){k(G=>G==="editor"?"preview":"editor");return}if(v==="preview"){if(H.downArrow||W==="j"){Te.current?.scrollBy(1);return}if(H.upArrow||W==="k"){Te.current?.scrollBy(-1);return}if(H.pageDown){Te.current?.scrollBy(10);return}if(H.pageUp){Te.current?.scrollBy(-10);return}if(H.home){Te.current?.scrollToTop();return}if(H.end){Te.current?.scrollToBottom();return}H.escape&&k("editor");return}if(H.downArrow||W==="j"){K>0&&e.setFieldIndex(Math.min(i.fieldIndex+1,K-1));return}if(H.upArrow||W==="k"){e.setFieldIndex(Math.max(i.fieldIndex-1,0));return}if(H.return){switch(i.section){case"compose":case"general":case"lifecycle":{e.setFieldEditing(!0);break}case"environment":{const G=Object.keys(i.config.containerEnv??{}).length,ne=G,he=G+1+Object.keys(i.config.remoteEnv??{}).length;i.fieldIndex===ne?(F("container"),N(""),j(""),V("key")):i.fieldIndex===he&&(F("remote"),N(""),j(""),V("key"));break}case"mounts":{const G=i.config.mounts??[];i.fieldIndex===G.length&&(B(!0),J(""),le(""),D("volume"),z("source"));break}case"ports":{const G=i.config.forwardPorts??[];i.fieldIndex===G.length&&(A(!0),I(""));break}}return}if(W===" "){switch(i.section){case"extensions":{const G=fs(i.extensionSearch)[i.fieldIndex];G&&e.toggleExtension(G.id);break}case"features":{const G=ps(i.featureSearch)[i.fieldIndex];G&&e.toggleFeature(G.id);break}case"general":{const G=ud-ii.length,ne=i.fieldIndex-G;if(ne>=0&&ne<ii.length){const he=ii[ne];e.updateConfig({[he]:!i.config[he]})}break}}return}if(W==="/"){(i.section==="features"||i.section==="extensions")&&g(!0);return}if(W==="A"&&i.section==="mounts"){e.applySuggestedMounts();return}if(W==="a"){if(i.section==="environment"){const G=Object.keys(i.config.containerEnv??{}).length,ne=i.fieldIndex<=G?"container":"remote";F(ne),N(""),j(""),V("key")}else i.section==="mounts"&&(B(!0),J(""),le(""),D("volume"),z("source"));return}if(W==="d")switch(i.section){case"environment":{const G=Object.keys(i.config.containerEnv??{}),ne=Object.keys(i.config.remoteEnv??{});if(i.fieldIndex<G.length)e.removeEnvVar("container",G[i.fieldIndex]),G.length===1||i.fieldIndex>=G.length-1&&e.setFieldIndex(G.length-2);else{const he=i.fieldIndex-G.length-1;he>=0&&he<ne.length&&(e.removeEnvVar("remote",ne[he]),ne.length===1||he>=ne.length-1&&e.setFieldIndex(i.fieldIndex-1))}break}case"mounts":{const G=i.config.mounts??[];if(i.fieldIndex<G.length){e.removeMount(i.fieldIndex);const ne=G.length-1;i.fieldIndex>=ne&&ne>0&&e.setFieldIndex(ne-1)}break}case"ports":{const G=i.config.forwardPorts??[];if(i.fieldIndex<G.length){e.removePort(i.fieldIndex);const ne=G.length-1;i.fieldIndex>=ne&&ne>0&&e.setFieldIndex(ne-1)}break}}}},{isActive:!i.showTemplateSelector&&!E&&M===null&&!P});const Bt=At(()=>e.getJsonPreview(),[i.config]);if(n<Ta||o<Ea)return u(h,{alignItems:"center",height:o,justifyContent:"center",width:n,children:f(l,{color:"yellow",children:["Terminal too small (",n,"x",o,"), need"," ",Ta,"x",Ea]})});if(i.showTemplateSelector)return u(h,{alignItems:"center",flexDirection:"column",height:o,justifyContent:"center",width:n,children:f(h,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[u(h,{justifyContent:"center",marginBottom:1,children:u(l,{bold:!0,color:"cyan",children:"Select a Template"})}),Gr.map((W,H)=>{const G=H===i.templateIndex;return u(h,{children:f(l,{color:G?"cyan":void 0,inverse:G,children:[G?" ❯ ":" ",u(l,{bold:G,children:W.name}),f(l,{dimColor:!0,children:[" ","-",W.description]})]})},W.id)}),u(h,{justifyContent:"center",marginTop:1,children:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",u(l,{bold:!0,color:"white",children:"Enter"})," ","select"," ",u(l,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let Y;switch(i.section){case"compose":{Y=u(Dk,{config:i.config,fieldEditing:i.fieldEditing,fieldIndex:i.fieldIndex,onUpdate:b(W=>{e.updateConfig(W)},"onUpdate")});break}case"environment":{Y=f(h,{flexDirection:"column",children:[u(Lk,{config:i.config,fieldIndex:i.fieldIndex}),M!==null&&u(h,{marginTop:1,paddingX:1,children:f(l,{color:"cyan",children:["Add"," ",M," ","env:"," ",R==="key"?f(l,{children:["key=",u(l,{color:"yellow",children:_||"_"})," ","(Enter to set value)"]}):f(l,{children:[_,"=",u(l,{color:"yellow",children:C||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{Y=u(Gk,{config:i.config,fieldIndex:i.fieldIndex,scrollOffset:$,searchText:i.extensionSearch,viewportHeight:te});break}case"features":{Y=u(Hk,{config:i.config,fieldIndex:i.fieldIndex,scrollOffset:$,searchText:i.featureSearch,viewportHeight:te});break}case"general":{Y=u(Qk,{config:i.config,fieldEditing:i.fieldEditing,fieldIndex:i.fieldIndex,onUpdate:b(W=>{e.updateConfig(W)},"onUpdate")});break}case"lifecycle":{Y=u(nb,{config:i.config,fieldEditing:i.fieldEditing,fieldIndex:i.fieldIndex,onSetCommand:b((W,H)=>{e.setLifecycleCommand(W,H)},"onSetCommand")});break}case"mounts":{Y=u(sb,{addingMount:P,config:i.config,detectedPm:i.detectedPm,fieldIndex:i.fieldIndex,mountPhase:O,mountSource:q,mountTarget:ce,mountType:ke,suggestedMounts:i.suggestedMounts});break}case"ports":{Y=u(lb,{addingPort:E,addPortValue:L,config:i.config,fieldIndex:i.fieldIndex});break}default:Y=u(l,{children:"Unknown section"})}const de=f(h,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[f(h,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"q"}),u(l,{dimColor:!0,children:"QUIT"})]}),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"?"}),u(l,{dimColor:!0,children:"HELP"})]}),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"↑↓"}),u(l,{dimColor:!0,children:"NAV"})]}),(i.section==="features"||i.section==="extensions")&&f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"Space"}),u(l,{dimColor:!0,children:"CHECK"})]}),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"←→"}),u(l,{dimColor:!0,children:"TABS"})]}),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"Tab"}),u(l,{dimColor:!0,children:"PANEL"})]}),(i.section==="features"||i.section==="extensions")&&f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"/"}),u(l,{dimColor:!0,children:"FILTER"})]}),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"s"}),u(l,{dimColor:!0,children:"SAVE"})]})]}),f(h,{paddingX:1,children:[m&&f(l,{color:m.startsWith("Error")?"red":"green",children:[m," "]}),i.isDirty&&u(l,{color:"yellow",children:"[modified]"}),!i.isDirty&&!m&&u(l,{dimColor:!0,children:"[saved]"})]})]}),pe=f(wr,{footer:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",u(l,{bold:!0,color:"white",children:"?"}),"/",u(l,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:me,title:"KEYBOARD SHORTCUTS",visible:s,width:56,children:[f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"NAVIGATION"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"←→"}),u(l,{dimColor:!0,children:" Switch tabs"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"↑↓"}),"/",u(l,{bold:!0,color:"white",children:"j/k"}),u(l,{dimColor:!0,children:" Navigate within section"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"Tab"}),u(l,{dimColor:!0,children:" Switch editor/preview panel"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"Enter"}),u(l,{dimColor:!0,children:" Edit selected field"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"Esc"}),u(l,{dimColor:!0,children:" Stop editing / cancel"})]})]}),f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"Space"}),u(l,{dimColor:!0,children:" Toggle selection"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"/"}),u(l,{dimColor:!0,children:" Search / filter"})]})]}),f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"a"}),u(l,{dimColor:!0,children:" Add new entry"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"d"}),u(l,{dimColor:!0,children:" Delete selected entry"})]})]}),f(h,{flexDirection:"column",children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"ACTIONS"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"s"}),u(l,{dimColor:!0,children:" Save configuration"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"q"}),u(l,{dimColor:!0,children:" Quit"})]}),f(l,{children:[" ",u(l,{bold:!0,color:"white",children:"?"}),u(l,{dimColor:!0,children:" Toggle help"})]})]})]}),Me=u(pb,{focused:v==="preview",hadComments:i.hadComments,jsonPreview:Bt,mode:i.mode,scrollRef:Te}),Ae=n>=yb,gt=Ae?Math.floor(n*.38):0;return f(h,{flexDirection:"column",height:o,width:n,children:[f(h,{flexShrink:0,gap:1,paddingX:1,children:[u(l,{bold:!0,inverse:!0,children:" VIS "}),f(l,{wrap:"truncate",children:[i.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),u(h,{flexShrink:0,paddingX:1,paddingY:1,children:u(Bc,{defaultValue:i.section,keyMap:{useNumbers:!1,useTab:!1},onChange:b(W=>{e.setSection(W),k("editor")},"onChange"),showIndex:!1,children:Ra.map(({id:W,label:H})=>u(Fc,{name:W,children:H},W))})}),u(h,{flexShrink:0,paddingRight:2,children:u(l,{dimColor:!0,wrap:"truncate",children:Ra.find(W=>W.id===i.section)?.description??""})}),f(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[u(h,{borderColor:v==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:Y}),Ae&&u(h,{flexShrink:0,width:gt,children:Me})]}),de,u(xr,{autoExitSeconds:3,onCancel:b(()=>{d(!1)},"onCancel"),visible:c}),pe]})},"VisDevcontainerApp");var kb=Object.defineProperty,Ia=b((t,e)=>kb(t,"name",{value:e,configurable:!0}),"c$n");const bb={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"]],execute:Ia(async({logger:t,options:e,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const n=r,o=e.template,i=e.output,s=!!process.stdout.isTTY&&!lt;let a=null;try{a=Ne(n).name}catch{}const c=Sk(n);let d=c?.config??null;const p=c?.hadComments??!1;if(o&&!c){const v=Gr.find(k=>k.id===o);if(!v){const k=Gr.map($=>$.id).join(", ");throw new Error(`Unknown template "${o}". Valid templates: ${k}`)}d=v.config}if(!s){d?t.info(JSON.stringify(d,null,2)):(t.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const g=setInterval(()=>{},1e3),m=new Ik(d,p,a);o&&!c&&m.dismissTemplateSelector();let y=null;if(await Ut(X.createElement(wb,{onSave:Ia(v=>{xk(n,v,i),y=v},"onSave"),store:m}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(g),y){const v=i??".devcontainer/devcontainer.json";t.info(`DevContainer config saved to ${v}`)}},"execute"),group:"Scaffold & Config",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}]};var $b=Object.defineProperty,Sb=b((t,e)=>$b(t,"name",{value:e,configurable:!0}),"o$e");const xb={argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"]],execute:Sb(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const o=t;if(!o||o.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[i,...s]=o,a=n??process.cwd(),c=Ne(a),d=r.package?Array.isArray(r.package)?r.package:[r.package]:[],p=Ji(c,{additionalPackages:d,args:s,package:i,shellMode:r.shellMode||!1,silent:r.silent||!1},a,e);p!==0&&(process.exitCode=p)},"execute"),group:"Run & Execute",name:"dlx",options:[{alias:"p",description:"Additional packages to install (repeatable)",multiple:!0,name:"package",type:String},{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output except command results",name:"silent",type:Boolean}]};var Cb=Object.defineProperty,Ir=b((t,e)=>Cb(t,"name",{value:e,configurable:!0}),"f$g");const jb=Ir((t,e)=>{const r=new Set,n=[t],o=new Set([t]);for(;n.length>0;){const i=n.shift(),s=e.dependencies[i]??[];for(const a of s)o.has(a.target)||(o.add(a.target),r.add(a.target),n.push(a.target))}return r},"collectTransitiveProjectDeps"),io="vis-docker-manifest.json",Tb=["package.json","project.json"],Eb=["package.json","pnpm-workspace.yaml","pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock","bun.lockb",".npmrc","vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],hd=Ir((t,e)=>{const r=new Set(t);for(const n of t){const o=jb(n,e);for(const i of o)r.add(i)}return r},"resolveFocusProjects"),jn=Ir(t=>{je(t)},"ensureDir"),Aa=Ir((t,e)=>{try{return jn(Nt(e)),Li(t,e),!0}catch(r){if(r.code==="ENOENT")return!1;throw r}},"copyFileIfExists"),md=Ir((t,e)=>{let r;try{r=Pc(t)}catch{return}if(!r.isSymbolicLink()){if(r.isFile()){jn(Nt(e)),Li(t,e);return}jn(e);for(const n of Ge(t,{withFileTypes:!0}))n.name==="node_modules"||n.name===".git"||n.isSymbolicLink()||md(w(t,n.name),w(e,n.name))}},"copyTreeExcludingNodeModules"),Rb=Ir(t=>{const{focus:e,includeSources:r=!1,outDir:n,projectGraph:o,workspace:i,workspaceRoot:s}=t,a=e.filter(g=>i.projects[g]===void 0);if(a.length>0)throw new Error(`Unknown focus project(s): ${a.join(", ")}. Check project names in your workspace.`);const c=hd(e,o),d=w(n,"workspace"),p=w(n,"sources");ot(d,{force:!0,recursive:!0}),ot(p,{force:!0,recursive:!0}),jn(d);for(const g of Eb)Aa(w(s,g),w(d,g));for(const g of c){const m=i.projects[g];if(m?.root)for(const y of Tb)Aa(w(s,m.root,y),w(d,m.root,y))}if(r){jn(p);for(const g of e){const m=i.projects[g];m?.root&&md(w(s,m.root),w(p,m.root))}}return Q(w(n,io),`${JSON.stringify({focus:e,projects:[...c].sort()},null,2)}
|
|
322
|
+
`),{projects:[...c]}},"scaffoldDockerContext"),Ib=Ir(t=>{const{contextRoot:e,workspace:r,workspaceRoot:n}=t,o=w(e,io);if(!T(o))throw new Error(`No ${io} at ${e}. Run \`vis docker scaffold\` first.`);const i=ue(o);if(!Array.isArray(i.projects))throw new TypeError(`Invalid ${io}: "projects" must be an array.`);const s=new Set(i.projects),a=[];for(const[c,d]of Object.entries(r.projects)){if(s.has(c)||!d.root)continue;const p=w(n,d.root),g=_e(n,p);g===""||g==="."||g.startsWith("..")||(ot(p,{force:!0,recursive:!0}),a.push(g))}return{removed:a}},"pruneDockerContext");var Ab=Object.defineProperty,Ob=b((t,e)=>Ab(t,"name",{value:e,configurable:!0}),"p$r");const Pb={argument:{description:"Docker subcommand: scaffold | prune",name:"subcommand",type:String},description:"Docker integration — scaffold a minimal context or prune unfocused 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"],["vis docker prune --context=.vis/docker","Strip unfocused projects inside a build stage"]],execute:Ob(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{const i=t[0];if(!i)throw new Error("Missing subcommand. Usage: vis docker <scaffold|prune>");if(!o)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:s,workspace:a}=ut(o,n);if(i==="scaffold"){const c=qt(o,a,s),d=r.focus;if(!d)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const p=d.split(",").map(y=>y.trim()).filter(Boolean);if(p.length===0)throw new Error("--focus resolved to an empty list. Provide at least one project name.");const g=w(o,r.out??".vis/docker"),{projects:m}=Rb({focus:p,includeSources:!!r.includeSources,outDir:g,projectGraph:c,workspace:a,workspaceRoot:o});e.info(`Scaffolded ${m.length} project(s) into ${g}`),e.info(`Focus closure: ${m.sort().join(", ")}`);return}if(i==="prune"){const c=w(o,r.context??".vis/docker"),{removed:d}=Ib({contextRoot:c,workspace:a,workspaceRoot:o});e.info(`Pruned ${d.length} unfocused project(s)`),d.length>0&&e.debug?.(d.join(`
|
|
323
|
+
`));return}throw new Error(`Unknown subcommand: "${i}". Expected scaffold or prune.`)},"execute"),group:"Workspace",name:"docker",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},{description:"Scaffold root for `vis docker prune` (default: .vis/docker)",name:"context",type:String}]};var Nb=Object.defineProperty,$t=b((t,e)=>Nb(t,"name",{value:e,configurable:!0}),"c$m");const Mb=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Db=["overrides","pnpm","resolutions"],Bb=["engines","files"],Fb=$t(t=>{const e=In(t)?.major;return e!==void 0&&e>=10},"isPnpmV10Plus"),Lb=$t(t=>{const e=w(t,"pnpm-workspace.yaml");if(!T(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Jr(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},"readPnpmWorkspaceOverrides"),Vb=$t((t,e)=>{let r={};return e==="pnpm"?r=t.pnpm?.overrides??{}:e==="yarn"||e==="bun"?r=t.resolutions??{}:r=t.overrides??{},{overrides:r,source:"package.json"}},"readPkgJsonOverrides"),Ub=$t((t,e,r)=>r.name==="pnpm"&&Fb(r.version)?Lb(t):Vb(e,r.name),"readOverrides"),Oa=$t((t,e)=>{const r=e;for(const o of Db){const i=t.indexOf(o);if(i!==-1&&o!==r)return r==="overrides"?i:i+1}let n=-1;for(const o of Mb){const i=t.indexOf(o);i>n&&(n=i)}if(n!==-1)return n+1;for(const o of Bb){const i=t.indexOf(o);if(i!==-1)return i}return t.length},"findInsertIndex"),_b=$t(t=>/\n(\s+)/.exec(t)?.[1]??" ","detectIndent"),Gb=$t((t,e)=>{const r=w(t,"pnpm-workspace.yaml");if(!T(r))throw new Error(`pnpm-workspace.yaml not found at ${r}. Cannot write overrides for pnpm v10+.`);let n=ee(r);const o=`overrides:
|
|
324
|
+
${Object.entries(e).map(([i,s])=>` '${i}': '${s}'`).join(`
|
|
293
325
|
`)}
|
|
294
|
-
`;n=/^overrides:\s*$/m.test(n)||/^overrides:\s*\n/m.test(n)?n.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,
|
|
295
|
-
|
|
296
|
-
${
|
|
297
|
-
`);else{const
|
|
298
|
-
`)}}else{const s=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[s])e[s]=r,
|
|
299
|
-
`);else{const
|
|
300
|
-
`)}}},"writePkgJsonOverrides"),Ys=We((t,e,r,n)=>{const i=K(e,"utf8"),o=JSON.parse(i),{overrides:s,source:l}=hh(t,o,n),d=[],f=[],p=new Set;if(n.name==="npm")for(const m of["dependencies","devDependencies"]){const y=o[m];if(y)for(const b of Object.keys(y))p.add(b)}for(const m of r){const y=s[m.original];if(typeof y=="object")continue;let b=m.spec;n.name==="npm"&&p.has(m.original)&&(b=`$${m.original}`),y!==b&&(y?f.push(m.original):d.push(m.original),s[m.original]=b)}if(d.length===0&&f.length===0)return{added:d,updated:f};const h=Object.fromEntries(Object.entries(s).sort(([m],[y])=>m.localeCompare(y)));return l==="pnpm-workspace.yaml"?yh(t,h):vh(e,o,h,n.name),{added:d,updated:f}},"applyOverrides"),Xs=We((t,e)=>{const r={bun:["bun.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const n of r[e]??[]){const i=T(t,n);try{return K(i,"utf8")}catch{continue}}return""},"readLockfileText"),wh=We((t,e,r)=>{if(!t)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(r){case"bun":return t.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(t);case"npm":return t.includes(`"${e}":`)||t.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${n}(@|['"]?:)`,"m").test(t);case"yarn":return new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(t);default:return!1}},"lockfileContainsPackage");var kh=Object.defineProperty,Qt=$((t,e)=>kh(t,"name",{value:e,configurable:!0}),"s$9");const bh=Qt((t,e,r)=>{let n=t;if(e!=="all"&&(n=n.filter(i=>i.category===e)),r){const i=r.toLowerCase();n=n.filter(o=>o.packageName.toLowerCase().includes(i))}return n},"filterEntries");let $h=class{static{$(this,"c")}static{Qt(this,"OptimizeStore")}#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=Qt(()=>this.#e,"getSnapshot");subscribe=Qt(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries=Qt(()=>bh(this.#e.entries,this.#e.filterType,this.#e.filterText),"getFilteredEntries");#n(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const r=this.getFilteredEntries();this.#e.selectedIndex=r.length===0?-1:Math.max(0,Math.min(e,r.length-1)),this.#n()}toggleCheck(e){const r=new Set(this.#e.checkedEntries);r.has(e)?r.delete(e):r.add(e),this.#e.checkedEntries=r,this.#n()}toggleAll(){const e=this.getFilteredEntries(),r=new Set(this.#e.checkedEntries);if(e.every(n=>r.has(n.packageName)))for(const n of e)r.delete(n.packageName);else for(const n of e)r.add(n.packageName);this.#e.checkedEntries=r,this.#n()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#n()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#n()}setFilterActive(e){this.#e.filterActive=e,this.#n()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#n()}setPhase(e){this.#e.phase=e,this.#n()}setProgress(e,r){this.#e.applyProgress={current:e,total:r},this.#n()}setError(e){this.#e.error=e,this.#e.phase="error",this.#n()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}};const Ks={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},xh={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},Sh={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."};var Ch=Object.defineProperty,Eh=$((t,e)=>Ch(t,"name",{value:e,configurable:!0}),"a$5");const jh=Eh(({entry:t,focused:e,scrollRef:r})=>{const n=e?"white":"gray";if(!t)return c(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:c(a,{dimColor:!0,children:"No entry selected"})});const i=Ks[t.category]??"gray";return u(g,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c(g,{flexShrink:0,paddingTop:1,paddingX:2,children:c(a,{bold:!0,color:"white",children:t.packageName})}),u(zt,{flexGrow:1,flexShrink:1,paddingX:2,ref:r,scrollbar:!0,scrollbarColor:"gray",children:[c(a,{}),u(g,{children:[c(g,{width:14,children:c(a,{dimColor:!0,children:"Category:"})}),c(a,{bold:!0,color:i,children:t.category})]}),u(g,{children:[c(g,{width:14,children:c(a,{dimColor:!0,children:"Replace with:"})}),c(a,{children:t.replacement})]}),t.overrideSpec&&u(g,{children:[c(g,{width:14,children:c(a,{dimColor:!0,children:"Override:"})}),c(a,{color:"cyan",children:t.overrideSpec})]}),u(g,{children:[c(g,{width:14,children:c(a,{dimColor:!0,children:"Codemod:"})}),c(a,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available ⚙":"not available"})]}),u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"DESCRIPTION"}),c(g,{marginTop:1,paddingLeft:2,children:c(a,{children:Sh[t.category]??""})})]}),t.category==="native"&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"green",children:"ACTION"}),c(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:t.hasCodemod?u(Zt,{children:[u(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),c(a,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):u(Zt,{children:[u(a,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),c(a,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),t.category==="socket"&&u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"cyan",children:"ACTION"}),u(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[u(a,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),c(a,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),u(g,{flexDirection:"column",marginTop:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"LINKS"}),c(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:u(a,{color:"cyan",underline:!0,children:["https://npmx.dev/",t.packageName]})})]})]})]})},"OptimizeDetailPanel");var Th=Object.defineProperty,Qs=$((t,e)=>Th(t,"name",{value:e,configurable:!0}),"b$8");const Ah=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],Ih=Qs(({checked:t,entry:e,isSelected:r})=>{const n=Ks[e.category]??"white",i=xh[e.category]??e.category,o=t?"☑":"☐",s=e.hasCodemod?"⚙":" ";return u(g,{flexShrink:0,height:1,children:[c(a,{children:r?">":" "}),u(a,{color:t?"white":"gray",children:[" ",o," "]}),c(a,{bold:!0,color:n,children:`[${i}]`.padEnd(9)}),u(a,{children:[" ",s," "]}),c(g,{flexGrow:1,children:c(a,{bold:r,inverse:r,wrap:"truncate",children:e.packageName})}),c(a,{dimColor:!0,children:" → "}),c(a,{wrap:"truncate",children:e.replacement})]})},"EntryRow"),Rh=Qs(({checkedEntries:t,entries:e,filterActive:r,filterText:n,filterType:i,focused:o,isDryRun:s,scrollOffset:l,selectedIndex:d,totalEntries:f,viewportHeight:p})=>{const h=o?"white":"gray";let m=0,y=0,b=0,x=0;for(const R of e)switch(R.category){case"micro-utility":{b++;break}case"native":{m++;break}case"preferred":{y++;break}case"socket":{x++;break}}const S=[];m>0&&S.push(`${m} native`),y>0&&S.push(`${y} preferred`),b>0&&S.push(`${b} micro`),x>0&&S.push(`${x} socket`);const C=S.length>0?` (${S.join(", ")})`:"",D=t.size,P=[];for(const[R,A]of e.entries())P.push(c(Ih,{checked:t.has(A.packageName),entry:A,isSelected:R===d},A.packageName));const M=e.length,E=M>p&&p>0;return u(g,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),u(a,{wrap:"truncate",children:[f," ","optimizations",C]}),!s&&D>0&&u(a,{dimColor:!0,children:[" ","—",D," ","selected"]})]}),c(g,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Ah.map(R=>{const A=i===R.key;return u(g,{children:[c(a,{dimColor:!A,children:"["}),c(a,{bold:A,color:A?"cyan":"gray",children:R.shortcut}),c(a,{dimColor:!A,children:"]"}),u(a,{color:A?"white":"gray",children:[" ",R.label]})]},R.key)})}),r&&u(g,{flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:"white",children:"/ "}),c(a,{children:n}),c(a,{inverse:!0,children:" "})]}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-l,children:P})}),E&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:M,placement:"inset",scrollOffset:l,style:"block",viewportHeight:p})})]})]})},"OptimizeListPanel");var Oh=Object.defineProperty,Ph=$((t,e)=>Oh(t,"name",{value:e,configurable:!0}),"z$2");const Nh=100,ri=10,ni={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},Dh=Ph(({isDryRun:t,store:e})=>{const{exit:r}=Gt(),{columns:n,rows:i}=Ut(),o=pr(e.subscribe,e.getSnapshot),s=be(null),[l,d]=ce(0),[f,p]=ce(!1),h=e.getFilteredEntries(),m=h[o.selectedIndex]??null,y=n>=Nh,b=Math.max(0,i-5),x=Ye(S=>{r(S)},[r]);return De((S,C)=>{if(f){S==="y"||S==="Y"?x():p(!1);return}if(o.filterActive){C.escape?(e.setFilterActive(!1),e.setFilterText("")):C.return?e.setFilterActive(!1):C.backspace||C.delete?e.setFilterText(o.filterText.slice(0,-1)):S&&!C.ctrl&&!C.meta&&e.setFilterText(o.filterText+S);return}if(S==="q"){!t&&o.checkedEntries.size>0?p(!0):x();return}if(S==="/"){e.setFilterActive(!0);return}if(ni[S]){e.setFilter(ni[S]);return}if(C.tab){e.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(o.focusedPanel==="list")if(C.upArrow||S==="k"){const D=Math.max(0,o.selectedIndex-1);e.select(D),D<l&&d(D)}else if(C.downArrow||S==="j"){const D=Math.min(h.length-1,o.selectedIndex+1);e.select(D),D>=l+b&&d(D-b+1)}else S===" "?m&&e.toggleCheck(m.packageName):S==="a"?e.toggleAll():C.return&&!t&&o.checkedEntries.size>0&&x(e.getCheckedEntries());else o.focusedPanel==="detail"&&(C.upArrow||S==="k"?s.current?.scrollBy(-1):(C.downArrow||S==="j")&&s.current?.scrollBy(1))},{isActive:o.phase==="browsing"}),i<ri?c(g,{alignItems:"center",justifyContent:"center",children:u(a,{color:"yellow",children:["Terminal too small. Resize to at least",ri," ","rows."]})}):u(g,{flexDirection:"column",height:i,width:n,children:[u(g,{flexDirection:y?"row":"column",flexGrow:1,children:[c(g,{flexBasis:y?"50%":void 0,flexGrow:1,children:c(Rh,{checkedEntries:o.checkedEntries,entries:h,filterActive:o.filterActive,filterText:o.filterText,filterType:o.filterType,focused:o.focusedPanel==="list",isDryRun:t,scrollOffset:l,selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:b})}),c(g,{flexBasis:y?"50%":void 0,flexGrow:1,children:c(jh,{entry:m,focused:o.focusedPanel==="detail",scrollRef:s})})]}),c(g,{flexShrink:0,paddingX:1,children:u(a,{dimColor:!0,children:[t?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),f&&c(jt,{message:`${o.checkedEntries.size} optimization${o.checkedEntries.size===1?"":"s"} selected but not applied. Quit?`})]})},"VisOptimizeApp");var Mh=Object.defineProperty,Ve=$((t,e)=>Mh(t,"name",{value:e,configurable:!0}),"g$8");const Ur=Ve((t,e)=>{const r=new Set;try{const n=JSON.parse(K(t,"utf8")),i=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const o of i)if(o)for(const s of Object.keys(o))r.add(s)}catch{}return r},"collectDepsFromPkgJson"),po=Ve(t=>{const e=tn(t);if(e)return Ct(t,e);const r=T(t,"package.json");if(!F(r))return[];try{const n=JSON.parse(K(r,"utf8")),i=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return i?Ct(t,i):[]}catch{return[]}},"discoverWorkspacePackages"),Zs=Ve(t=>{const e=[],r=Ve((n,i)=>{for(const[,o]of Object.entries(n.mappings)){if(!t.has(o.moduleName))continue;const s=[];for(const l of o.replacements){const d=n.replacements[l];d&&s.push(d.description??d.id)}e.push({category:i,hasCodemod:!1,overrideSpec:void 0,packageName:o.moduleName,replacement:s.join(", ")||o.replacements.join(", ")})}},"scanManifest");return r($c,"native"),r(xc,"preferred"),r(bc,"micro-utility"),e},"buildE18eEntries"),ea=Ve((t,e,r,n)=>{const i=kc("npm")??[],o=[];for(const[,s]of i){if(s.deprecated)continue;const l=t.has(s.package),d=e?wh(e,s.package,r.name):!1;if(!l&&!d)continue;const f=qr(s.version)?.major;if(f===void 0)continue;const p=n?`npm:${s.name}@${s.version}`:`npm:${s.name}@^${String(f)}`;o.push({category:"socket",hasCodemod:!1,overrideSpec:p,packageName:s.package,replacement:s.name})}return o},"buildSocketEntries");let Ir;const ta=Ve(async()=>{if(Ir)return Ir;try{return Ir=(await import("module-replacements-codemods")).codemods,Ir}catch{return{}}},"loadCodemods"),ra=Ve(async t=>{try{const e=await ta();for(const r of t)r.category!=="socket"&&e[r.packageName]&&(r.hasCodemod=!0)}catch{}},"markCodemodAvailability"),na=Ve(async(t,e)=>{let r=0;try{const n=(await ta())[e];if(!n)return{filesChanged:0,packageName:e};const i=n({}),o=Bh(t);for(const s of o){const l=K(s,"utf8");if(l.includes(e))try{const d=await i.transform({file:{filename:s,source:l}});d!==l&&(H(s,d,"utf8"),r++)}catch(d){process.stderr.write(`warn: codemod transform failed for ${s}: ${d instanceof Error?d.message:String(d)}
|
|
301
|
-
`)}}}catch{}return{filesChanged:r,packageName:e}},"runCodemod"),
|
|
302
|
-
`);const p=
|
|
303
|
-
Running ${String(
|
|
304
|
-
`);for(const
|
|
305
|
-
${String(
|
|
306
|
-
Added ${String(
|
|
307
|
-
Running ${n.name} install to update lockfile...`);const
|
|
308
|
-
`);return}const
|
|
309
|
-
Preferred alternatives (${String(
|
|
310
|
-
Micro-utilities (${String(
|
|
311
|
-
Socket.dev overrides (${String(
|
|
312
|
-
Total: ${String(
|
|
313
|
-
${
|
|
314
|
-
`),
|
|
315
|
-
Scanning...`);const
|
|
316
|
-
`),e.exitCode&&(
|
|
317
|
-
`);const
|
|
318
|
-
Running ${i.name} install to update lockfile...`),Zr(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,t)),k(""),Q("Fixes applied.")}else Gh(s);e.exitCode&&(e.strict?s.vulnCount>0||s.socketIssues.alerts>0||s.outdated.length>0||s.duplicates.length>0:s.vulnCount>0||s.socketIssues.alerts>0)&&(process.exitCode=1)},"execute"),name:"doctor",options:[{description:"Output format: table or json (default: table)",name:"format",type:String},{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)",name:"fix",type:Boolean},{defaultValue:!1,description:"With --exit-code: also fail on outdated and duplicate deps",name:"strict",type:Boolean}]};var Wh=Object.defineProperty,_h=$((t,e)=>Wh(t,"name",{value:e,configurable:!0}),"s$8");const Hh={group:"Run & Execute",argument:{description:"Command to execute followed by arguments",name:"command",type:String},description:"Execute a local node_modules/.bin command (no remote fallback)",examples:[["vis exec eslint .","Run local eslint"],["vis exec tsc --noEmit","Run local TypeScript check"],["vis exec -r -- eslint .","Run in all workspace packages"],["vis exec -c 'echo $PATH'","Shell mode"]],execute:_h(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const i=t;if(!i||i.length===0)throw new Error("No command specified. Usage: vis exec <command> [args...]");const[o,...s]=i,l=n??process.cwd(),d=me(l),f=qc(d,{args:s,command:o,filter:gr(r.filter),parallel:r.parallel||!1,recursive:r.recursive||!1,reverse:r.reverse||!1,shellMode:r.shellMode||!1,workspaceRoot:r.workspaceRoot||!1},l,e);f!==0&&(process.exitCode=f)},"execute"),name:"exec",options:[{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"r",defaultValue:!1,description:"Run in every workspace package",name:"recursive",type:Boolean},{alias:"w",defaultValue:!1,description:"Run on workspace root only",name:"workspace-root",type:Boolean},{alias:"F",description:"Filter packages by name pattern",multiple:!0,name:"filter",type:String},{defaultValue:!1,description:"Run concurrently without topological ordering",name:"parallel",type:Boolean},{defaultValue:!1,description:"Reverse topological execution order",name:"reverse",type:Boolean}]};var Jh=Object.defineProperty,rr=$((t,e)=>Jh(t,"name",{value:e,configurable:!0}),"n$4");const qh=rr(t=>{const e=new Map;for(const[r,n]of Object.entries(t.dependencies))for(const i of n){const o=e.get(i.target)??[];o.push(r),e.set(i.target,o)}return Object.values(t.nodes).map(r=>({deps:t.dependencies[r.name]??[],name:r.name,reverseDeps:e.get(r.name)??[],type:r.type})).sort((r,n)=>r.type!==n.type?r.type==="application"?-1:1:r.name.localeCompare(n.name))},"buildNodes"),Yh=rr((t,e,r)=>{let n=t;if(e==="app"?n=n.filter(i=>i.type==="application"):e==="lib"&&(n=n.filter(i=>i.type!=="application")),r){const i=r.toLowerCase();n=n.filter(o=>o.name.toLowerCase().includes(i))}return n},"filterNodes");class Xh{static{$(this,"GraphStore")}static{rr(this,"GraphStore")}#e;#t=new Set;#n;constructor(e){this.#n=e;const r=qh(e);this.#e={allNodes:r,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=rr(()=>this.#e,"getSnapshot");subscribe=rr(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredNodes(){return Yh(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const e=this.#e.allNodes.filter(i=>i.type==="application").length,r=this.#e.allNodes.length,n=Object.values(this.#n.dependencies).reduce((i,o)=>i+o.length,0);return{apps:e,deps:n,libs:r-e,total:r}}setSelectedIndex(e){const r=this.getFilteredNodes(),n=r.length===0?-1:Math.max(0,Math.min(e,r.length-1));n!==this.#e.selectedIndex&&this.#o({...this.#e,selectedIndex:n})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#o({...this.#e,focusedPanel:e})}setFilterType(e){e!==this.#e.filterType&&this.#o({...this.#e,filterType:e,selectedIndex:0})}setFilter(e){this.#o({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#o({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:e?this.#e.selectedIndex:0})}#o(e){this.#e=e;for(const r of this.#t)try{r()}catch{}}}var Kh=Object.defineProperty,Qh=$((t,e)=>Kh(t,"name",{value:e,configurable:!0}),"p$9");const Zh=Qh(({focused:t,node:e,scrollRef:r})=>{const n=t?"white":"gray";if(!e)return c(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:c(a,{dimColor:!0,children:"No project selected"})});const i=e.type==="application",o=i?"yellow":"cyan",s=i?"Application":"Library";return c(g,{borderColor:n,borderStyle:"single",borderTopRightTitle:` ${s} `,borderTopTitle:` ${e.name} `,flexDirection:"column",flexGrow:1,children:u(zt,{flexGrow:1,flexShrink:1,paddingX:2,ref:r,scrollbar:!0,scrollbarColor:"gray",children:[u(g,{flexDirection:"column",marginTop:1,children:[u(g,{children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"DEPENDS ON"}),u(a,{dimColor:!0,children:[" ","(",e.deps.length,")"]})]}),e.deps.length===0?c(g,{marginTop:1,paddingLeft:2,children:c(a,{dimColor:!0,children:"No dependencies"})}):c(g,{flexDirection:"column",marginTop:1,children:e.deps.map(l=>u(g,{gap:1,paddingLeft:2,children:[c(a,{color:"cyan",children:"→"}),c(a,{children:l.target}),l.type!=="static"&&u(a,{dimColor:!0,children:["(",l.type,")"]})]},l.target))})]}),u(g,{flexDirection:"column",marginTop:1,children:[u(g,{children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"REQUIRED BY"}),u(a,{dimColor:!0,children:[" ","(",e.reverseDeps.length,")"]})]}),e.reverseDeps.length===0?c(g,{marginTop:1,paddingLeft:2,children:c(a,{dimColor:!0,children:"No reverse dependencies"})}):c(g,{flexDirection:"column",marginTop:1,children:e.reverseDeps.map(l=>u(g,{gap:1,paddingLeft:2,children:[c(a,{color:"magenta",children:"←"}),c(a,{children:l})]},l))})]}),u(g,{flexDirection:"column",marginTop:1,children:[u(g,{children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"INFO"})]}),u(g,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[u(g,{children:[c(g,{width:16,children:c(a,{dimColor:!0,children:"Type:"})}),c(a,{color:o,children:s})]}),u(g,{children:[c(g,{width:16,children:c(a,{dimColor:!0,children:"Dependencies:"})}),c(a,{children:String(e.deps.length)})]}),u(g,{children:[c(g,{width:16,children:c(a,{dimColor:!0,children:"Required by:"})}),c(a,{children:String(e.reverseDeps.length)})]}),u(g,{children:[c(g,{width:16,children:c(a,{dimColor:!0,children:"Connectivity:"})}),c(a,{children:String(e.deps.length+e.reverseDeps.length)})]})]})]})]})})},"ProjectDetailPanel");var em=Object.defineProperty,fo=$((t,e)=>em(t,"name",{value:e,configurable:!0}),"g$6");const tm=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],oi=fo(({isSelected:t,node:e})=>{const r=e.type==="application",n=r?"yellow":"cyan",i=r?"app":"lib";return u(g,{flexShrink:0,height:1,children:[u(a,{children:[t?"▶":" "," "]}),c(g,{flexGrow:1,children:c(a,{bold:t,inverse:t,wrap:"truncate",children:e.name})}),u(a,{color:n,children:[" ",i]}),u(a,{dimColor:!0,children:[" ","→",e.deps.length," ","←",e.reverseDeps.length]})]})},"ProjectRow"),ii=fo(({count:t,label:e})=>u(g,{flexShrink:0,height:1,marginTop:1,children:[u(a,{dimColor:!0,children:["▼"," "]}),c(a,{bold:!0,color:"white",children:e.toUpperCase()}),u(a,{dimColor:!0,children:[" ","(",t,")"]})]}),"TypeHeader"),rm=fo(({filterActive:t,filterText:e,filterType:r,focused:n,nodes:i,scrollOffset:o,selectedIndex:s,stats:l,viewportHeight:d})=>{const f=n?"white":"gray",p=i.filter(S=>S.type==="application"),h=i.filter(S=>S.type!=="application"),m=[];let y=0;if(p.length>0){m.push(c(ii,{count:p.length,label:"Applications"},"hdr-apps"));for(const S of p){const C=y;m.push(c(oi,{isSelected:C===s,node:S},S.name)),y++}}if(h.length>0){m.push(c(ii,{count:h.length,label:"Libraries"},"hdr-libs"));for(const S of h){const C=y;m.push(c(oi,{isSelected:C===s,node:S},S.name)),y++}}let b=0;p.length>0&&(b+=2+p.length),h.length>0&&(b+=2+h.length);const x=b>d&&d>0;return u(g,{borderColor:f,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),u(a,{wrap:"truncate",children:[l.total," ","packages"]}),u(a,{dimColor:!0,children:["(",l.apps," ","apps,"," ",l.libs," ","libs,"," ",l.deps," ","deps)"]})]}),c(g,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:tm.map(S=>{const C=r===S.key;return u(g,{children:[c(a,{dimColor:!C,children:"["}),c(a,{bold:C,color:C?"cyan":"gray",children:S.shortcut}),c(a,{dimColor:!C,children:"]"}),u(a,{color:C?"white":"gray",children:[" ",S.label]})]},S.key)})}),t&&u(g,{flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:"white",children:"/ "}),c(a,{children:e}),c(a,{inverse:!0,children:" "})]}),u(g,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[c(g,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:c(g,{flexDirection:"column",marginTop:-o,children:m})}),x&&c(g,{flexShrink:0,marginLeft:1,marginRight:1,children:c(ur,{contentHeight:b,placement:"inset",scrollOffset:o,style:"block",viewportHeight:d})})]})]})},"ProjectListPanel");var nm=Object.defineProperty,om=$((t,e)=>nm(t,"name",{value:e,configurable:!0}),"M$6");const im=100,sm=40,am=10,si={1:"all",2:"app",3:"lib"},cm=om(({autoExitSeconds:t=0,store:e})=>{const{exit:r}=Gt(),{columns:n,rows:i}=Ut(),o=pr(e.subscribe,e.getSnapshot),[s,l]=ce(!1),d=be(null),f=be(null),[p,h]=ce(0),[m,y]=ce(!1),b=Ke(()=>e.getFilteredNodes(),[o.allNodes,o.filterType,o.filterText]),x=Ke(()=>e.getStats(),[o.allNodes]),S=b[o.selectedIndex]??null,C=Ye(w=>{const v=b.filter(Z=>Z.type==="application"),j=b.filter(Z=>Z.type!=="application");let U=0,z=0;if(v.length>0){U+=2;for(let Z=0;Z<v.length;Z++){if(z===w)return U;U+=1,z++}}if(j.length>0){U+=2;for(let Z=0;Z<j.length;Z++){if(z===w)return U;U+=1,z++}}return U},[b]),D=Math.max(1,i-8-(o.filterActive?1:0)),P=Ye(w=>{const v=C(w);h(j=>v>j+D-2?Math.max(0,v-D+2):v<j+1?Math.max(0,v-1):j)},[C,D]);if(qe(()=>{f.current?.scrollToTop()},[S?.name]),De((w,v)=>{if(w==="c"&&v.ctrl){r();return}if(!m){if(s){v.escape||w==="?"?l(!1):w==="q"?(l(!1),y(!0)):v.downArrow||w==="j"?d.current?.scrollBy(1):(v.upArrow||w==="k")&&d.current?.scrollBy(-1);return}if(w==="?"){l(!0);return}if(w==="q"){y(!0);return}if(v.tab){e.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(si[w]){e.setFilterType(si[w]);return}if(o.filterActive){if(v.escape){e.setFilterActive(!1);return}if(v.return){e.setFilterActive(!1);return}if(v.backspace){e.setFilter(o.filterText.slice(0,-1));return}if(w&&!v.ctrl&&!v.meta){e.setFilter(o.filterText+w);return}return}if(o.focusedPanel==="list"){if(b.length===0){w==="/"&&e.setFilterActive(!0);return}if(v.downArrow||w==="j"){const j=Math.min(o.selectedIndex+1,b.length-1);e.setSelectedIndex(j),P(j);return}if(v.upArrow||w==="k"){const j=Math.max(o.selectedIndex-1,0);e.setSelectedIndex(j),P(j);return}if(v.pageDown){const j=Math.min(o.selectedIndex+10,b.length-1);e.setSelectedIndex(j),P(j);return}if(v.pageUp){const j=Math.max(o.selectedIndex-10,0);e.setSelectedIndex(j),P(j);return}if(v.home){e.setSelectedIndex(0),h(0);return}if(v.end){const j=b.length-1;e.setSelectedIndex(j),P(j);return}if(w==="/"){e.setFilterActive(!0);return}if(v.rightArrow){e.setFocusedPanel("detail");return}return}if(o.focusedPanel==="detail"){if(v.escape||v.leftArrow){e.setFocusedPanel("list");return}if(v.downArrow||w==="j"){f.current?.scrollBy(1);return}if(v.upArrow||w==="k"){f.current?.scrollBy(-1);return}if(v.pageDown){f.current?.scrollBy(10);return}if(v.pageUp){f.current?.scrollBy(-10);return}if(v.home){f.current?.scrollToTop();return}v.end&&f.current?.scrollToBottom()}}},{isActive:!0}),n<sm||i<am)return c(g,{alignItems:"center",height:i,justifyContent:"center",width:n,children:u(a,{color:"yellow",children:["Terminal too small (",n,"x",i,")"]})});const M=n>=im,E=c(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:u(g,{flexWrap:"wrap",gap:2,paddingX:1,children:[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"1-3 /"}),c(a,{dimColor:!0,children:"FILTER"})]},"f"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"t")]})}),R=u(xt,{footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"?"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:d,title:"KEYBOARD SHORTCUTS",visible:s,width:52,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Move up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Move down"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Tab"]}),c(a,{dimColor:!0,children:" Switch panel"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","→","/","←"]}),c(a,{dimColor:!0,children:" Focus detail/list"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),c(a,{dimColor:!0,children:" Jump 10 items"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Home/End"]}),c(a,{dimColor:!0,children:" Jump to start/end"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"FILTERS"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","1"]}),c(a,{dimColor:!0,children:" All"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","2"]}),c(a,{dimColor:!0,children:" Apps only"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","3"]}),c(a,{dimColor:!0,children:" Libraries only"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","/"]}),c(a,{dimColor:!0,children:" Text filter"})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"ACTIONS"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","q"]}),c(a,{dimColor:!0,children:" Quit"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","?"]}),c(a,{dimColor:!0,children:" Toggle help"})]})]})]}),A=c(rm,{filterActive:o.filterActive,filterText:o.filterText,filterType:o.filterType,focused:o.focusedPanel==="list",nodes:b,scrollOffset:p,selectedIndex:o.selectedIndex,stats:x,viewportHeight:D}),G=c(Zh,{focused:o.focusedPanel==="detail",node:S,scrollRef:f});if(M){const w=Math.floor(n*.35);return u(g,{flexDirection:"column",height:i,width:n,children:[u(g,{flexDirection:"row",flexGrow:1,children:[c(g,{flexGrow:1,children:A}),c(g,{width:w,children:G})]}),E,c(jt,{autoExitSeconds:t??3,onCancel:$(()=>{y(!1)},"onCancel"),visible:m}),R]})}const B=Math.floor(i*.55);return u(g,{flexDirection:"column",height:i,width:n,children:[c(g,{height:B,children:A}),c(g,{flexGrow:1,children:G}),E,c(jt,{autoExitSeconds:t??3,onCancel:$(()=>{y(!1)},"onCancel"),visible:m}),R]})},"VisGraphApp");var ai=Object.freeze,oa=Object.defineProperty,Ht=$((t,e)=>oa(t,"name",{value:e,configurable:!0}),"y$6"),lm=$((t,e)=>ai(oa(t,"raw",{value:ai(e||t.slice())})),"k$7");const ia=Ht((t,e,r,n,i,o,s,l)=>{const d=re(r?"└── ":"├── "),f=i.has(t),p=f?re(" (*)"):"",h=n.get(t),m=h?.type==="application"?pe(t):t;if(o.push(`${e}${d}${m}${p}`),f)return;i.add(t);const y=h?.deps??[],b=r?`${e} `:`${e}${re("│")} `;if(l>=s&&y.length>0){o.push(`${b}${re(`... ${y.length} more`)}`);return}for(let x=0;x<y.length;x++){const S=y[x];S&&ia(S.target,b,x===y.length-1,n,i,o,s,l+1)}},"printDepsTree"),ci=Ht((t,e,r,n,i,o)=>{const s=e.get(t),l=s?.type==="application"?pe(t):t;n.push(`${o}${l}`),r.add(t);const d=s?.deps??[];if(d.length===0){n.push(`${o} ${re("(no dependencies)")}`);return}if(i<=0){n.push(`${o} ${re(`... ${d.length} dependencies`)}`);return}for(let f=0;f<d.length;f++){const p=d[f];p&&ia(p.target,o,f===d.length-1,e,r,n,i,1)}},"printRootProject"),li=Ht((t,e)=>{const r=new Map;for(const[h,m]of Object.entries(t.nodes))r.set(h,{deps:(t.dependencies[h]??[]).map(y=>({target:y.target,type:y.type})),name:h,type:m.type});const n=[],i=[];for(const[h,m]of r)m.type==="application"?n.push(h):i.push(h);n.sort(),i.sort();const o=n.length+i.length,s=Object.values(t.dependencies).reduce((h,m)=>h+m.length,0),l=[];if(l.push(pe("Project Dependency Graph"),""),n.length>0){l.push(` ${pe(Pe(`Applications (${n.length})`))}`,"");for(const h of n)ci(h,r,new Set,l,e," "),l.push("")}if(i.length>0){l.push(` ${pe(Pe(`Libraries (${i.length})`))}`,"");for(const h of i)ci(h,r,new Set,l,e," "),l.push("")}const d=process.stdout.columns||80;l.push(re("─".repeat(Math.min(d,60)))),l.push(`${pe(String(o))} packages ${re("·")} ${pe(String(s))} dependencies ${re("·")} ${pe(String(n.length))} apps${re(",")} ${pe(String(i.length))} libraries`);const f=new Set;let p=!1;for(const h of[...n,...i]){const m=r.get(h)?.deps??[];for(const y of m)f.has(y.target)&&(p=!0),f.add(y.target);f.add(h)}return p&&l.push(re("(*) = already shown above")),l.join(`
|
|
319
|
-
`)
|
|
326
|
+
`;n=/^overrides:\s*$/m.test(n)||/^overrides:\s*\n/m.test(n)?n.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,o):`${n.trimEnd()}
|
|
327
|
+
|
|
328
|
+
${o}`,Q(r,n)},"writePnpmWorkspaceOverrides"),Wb=$t((t,e,r,n)=>{const o=ee(t),i=_b(o);if(n==="pnpm"){const s=e.pnpm??{};if(s.overrides=r,e.pnpm)e.pnpm=s,Q(t,`${JSON.stringify(e,null,i)}
|
|
329
|
+
`);else{const a=Object.keys(e),c=Oa(a,"pnpm"),d=Object.entries(e);d.splice(c,0,["pnpm",s]),Q(t,`${JSON.stringify(Object.fromEntries(d),null,i)}
|
|
330
|
+
`)}}else{const s=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[s])e[s]=r,Q(t,`${JSON.stringify(e,null,i)}
|
|
331
|
+
`);else{const a=Object.keys(e),c=Oa(a,s),d=Object.entries(e);d.splice(c,0,[s,r]),Q(t,`${JSON.stringify(Object.fromEntries(d),null,i)}
|
|
332
|
+
`)}}},"writePkgJsonOverrides"),yd=$t((t,e,r,n)=>{const o=ee(e),i=JSON.parse(o),{overrides:s,source:a}=Ub(t,i,n),c=[],d=[],p=new Set;if(n.name==="npm")for(const m of["dependencies","devDependencies"]){const y=i[m];if(y)for(const v of Object.keys(y))p.add(v)}for(const m of r){const y=s[m.original];if(typeof y=="object")continue;let v=m.spec;n.name==="npm"&&p.has(m.original)&&(v=`$${m.original}`),y!==v&&(y?d.push(m.original):c.push(m.original),s[m.original]=v)}if(c.length===0&&d.length===0)return{added:c,updated:d};const g=Object.fromEntries(Object.entries(s).sort(([m],[y])=>m.localeCompare(y)));return a==="pnpm-workspace.yaml"?Gb(t,g):Wb(e,i,g,n.name),{added:c,updated:d}},"applyOverrides"),vd=$t((t,e)=>{const r={bun:["bun.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const n of r[e]??[]){const o=w(t,n);try{return ee(o)}catch{continue}}return""},"readLockfileText"),zb=$t((t,e,r)=>{if(!t)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(r){case"bun":return t.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(t);case"npm":return t.includes(`"${e}":`)||t.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${n}(@|['"]?:)`,"m").test(t);case"yarn":return new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(t);default:return!1}},"lockfileContainsPackage");var Hb=Object.defineProperty,Lo=b((t,e)=>Hb(t,"name",{value:e,configurable:!0}),"p$q");const qb=Lo(t=>{for(const e of[".nvmrc",".node-version"]){const r=w(t,e);if(T(r))try{return ee(r).trim().replace(/^v/,"")}catch{}}},"readNodeVersionFile"),Zn=Lo((t,e)=>{const r=t.split(/[.\-+]/).map(i=>Number.parseInt(i,10)||0),n=e.split(/[.\-+]/).map(i=>Number.parseInt(i,10)||0),o=Math.max(r.length,n.length);for(let i=0;i<o;i++){const s=r[i]??0,a=n[i]??0;if(s!==a)return s-a}return 0},"compareVersions"),Jb=Lo((t,e)=>{const r=e.trim();if(r===""||r==="*")return!0;const n=r.split(/\s+/).filter(Boolean);for(const o of n)if(o.startsWith(">=")){if(Zn(t,o.slice(2).trim())<0)return!1}else if(o.startsWith("<=")){if(Zn(t,o.slice(2).trim())>0)return!1}else if(o.startsWith(">")){if(Zn(t,o.slice(1).trim())<=0)return!1}else if(o.startsWith("<")){if(Zn(t,o.slice(1).trim())>=0)return!1}else if(/^\d/.test(o)){const i=t.split("."),s=o.split(".");for(const[a,c]of s.entries())if(c!==i[a])return!1}return!0},"satisfiesRange"),wd=Lo(t=>{const e=[],r=w(t,"package.json");let n={};try{n=ue(r)}catch{return e}const o=process.versions.node;if(n.engines?.node){const s=n.engines.node;Jb(o,s)||e.push({actual:o,expected:s,kind:"node",message:`package.json engines.node requires ${s}, but the current Node.js is ${o}.`,severity:"error"})}const i=qb(t);if(i){const[s,a]=i.split("."),[c,d]=o.split(".");(s!==c||a!==void 0&&a!==d)&&e.push({actual:o,expected:i,kind:"node",message:`.nvmrc pins Node ${i} but the current Node.js is ${o}. Run \`nvm use\` or switch runtimes.`,severity:"warning"})}if(n.packageManager){const[s,a]=n.packageManager.split("@"),c=(process.env.npm_config_user_agent??"").split(" ")[0]??"",[d,p]=c.split("/");d&&s&&d!==s?e.push({actual:d,expected:s,kind:"packageManager",message:`package.json packageManager pins ${n.packageManager} but the current invocation is ${c}. Install the correct package manager.`,severity:"error"}):p&&a&&p!==a&&e.push({actual:p,expected:a,kind:"packageManager",message:`package.json packageManager pins ${s}@${a} but the current invocation uses ${s}@${p}.`,severity:"warning"})}return e},"checkRuntimeVersions");var Yb=Object.defineProperty,pn=b((t,e)=>Yb(t,"name",{value:e,configurable:!0}),"s$d");const Kb=pn((t,e,r)=>{let n=t;if(e!=="all"&&(n=n.filter(o=>o.category===e)),r){const o=r.toLowerCase();n=n.filter(i=>i.packageName.toLowerCase().includes(o))}return n},"filterEntries");let Xb=class{static{b(this,"c")}static{pn(this,"OptimizeStore")}#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=pn(()=>this.#e,"getSnapshot");subscribe=pn(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries=pn(()=>Kb(this.#e.entries,this.#e.filterType,this.#e.filterText),"getFilteredEntries");#n(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const r=this.getFilteredEntries();this.#e.selectedIndex=r.length===0?-1:Math.max(0,Math.min(e,r.length-1)),this.#n()}toggleCheck(e){const r=new Set(this.#e.checkedEntries);r.has(e)?r.delete(e):r.add(e),this.#e.checkedEntries=r,this.#n()}toggleAll(){const e=this.getFilteredEntries(),r=new Set(this.#e.checkedEntries);if(e.every(n=>r.has(n.packageName)))for(const n of e)r.delete(n.packageName);else for(const n of e)r.add(n.packageName);this.#e.checkedEntries=r,this.#n()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#n()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#n()}setFilterActive(e){this.#e.filterActive=e,this.#n()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#n()}setPhase(e){this.#e.phase=e,this.#n()}setProgress(e,r){this.#e.applyProgress={current:e,total:r},this.#n()}setError(e){this.#e.error=e,this.#e.phase="error",this.#n()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}};const kd={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},Qb={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},Zb={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."};var e$=Object.defineProperty,t$=b((t,e)=>e$(t,"name",{value:e,configurable:!0}),"a$e");const r$=t$(({entry:t,focused:e,scrollRef:r})=>{const n=e?"white":"gray";if(!t)return u(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:u(l,{dimColor:!0,children:"No entry selected"})});const o=kd[t.category]??"gray";return f(h,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(h,{flexShrink:0,paddingTop:1,paddingX:2,children:u(l,{bold:!0,color:"white",children:t.packageName})}),f(qr,{flexGrow:1,flexShrink:1,paddingX:2,ref:r,scrollbar:!0,scrollbarColor:"gray",children:[u(l,{}),f(h,{children:[u(h,{width:14,children:u(l,{dimColor:!0,children:"Category:"})}),u(l,{bold:!0,color:o,children:t.category})]}),f(h,{children:[u(h,{width:14,children:u(l,{dimColor:!0,children:"Replace with:"})}),u(l,{children:t.replacement})]}),t.overrideSpec&&f(h,{children:[u(h,{width:14,children:u(l,{dimColor:!0,children:"Override:"})}),u(l,{color:"cyan",children:t.overrideSpec})]}),f(h,{children:[u(h,{width:14,children:u(l,{dimColor:!0,children:"Codemod:"})}),u(l,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available ⚙":"not available"})]}),f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"DESCRIPTION"}),u(h,{marginTop:1,paddingLeft:2,children:u(l,{children:Zb[t.category]??""})})]}),t.category==="native"&&f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"green",children:"ACTION"}),u(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:t.hasCodemod?f(gn,{children:[f(l,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),u(l,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):f(gn,{children:[f(l,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),u(l,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),t.category==="socket"&&f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"cyan",children:"ACTION"}),f(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[f(l,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),u(l,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),f(h,{flexDirection:"column",marginTop:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"LINKS"}),u(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:f(l,{color:"cyan",underline:!0,children:["https://npmx.dev/",t.packageName]})})]})]})]})},"OptimizeDetailPanel");var n$=Object.defineProperty,bd=b((t,e)=>n$(t,"name",{value:e,configurable:!0}),"b$c");const o$=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],i$=bd(({checked:t,entry:e,isSelected:r})=>{const n=kd[e.category]??"white",o=Qb[e.category]??e.category,i=t?"☑":"☐",s=e.hasCodemod?"⚙":" ";return f(h,{flexShrink:0,height:1,children:[u(l,{children:r?">":" "}),f(l,{color:t?"white":"gray",children:[" ",i," "]}),u(l,{bold:!0,color:n,children:`[${o}]`.padEnd(9)}),f(l,{children:[" ",s," "]}),u(h,{flexGrow:1,children:u(l,{bold:r,inverse:r,wrap:"truncate",children:e.packageName})}),u(l,{dimColor:!0,children:" → "}),u(l,{wrap:"truncate",children:e.replacement})]})},"EntryRow"),s$=bd(({checkedEntries:t,entries:e,filterActive:r,filterText:n,filterType:o,focused:i,isDryRun:s,scrollOffset:a,selectedIndex:c,totalEntries:d,viewportHeight:p})=>{const g=i?"white":"gray";let m=0,y=0,v=0,k=0;for(const M of e)switch(M.category){case"micro-utility":{v++;break}case"native":{m++;break}case"preferred":{y++;break}case"socket":{k++;break}}const $=[];m>0&&$.push(`${m} native`),y>0&&$.push(`${y} preferred`),v>0&&$.push(`${v} micro`),k>0&&$.push(`${k} socket`);const x=$.length>0?` (${$.join(", ")})`:"",E=t.size,A=[];for(const[M,F]of e.entries())A.push(u(i$,{checked:t.has(F.packageName),entry:F,isSelected:M===c},F.packageName));const L=e.length,I=L>p&&p>0;return f(h,{borderColor:g,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(h,{flexShrink:0,gap:1,paddingX:1,children:[u(l,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),f(l,{wrap:"truncate",children:[d," ","optimizations",x]}),!s&&E>0&&f(l,{dimColor:!0,children:[" ","—",E," ","selected"]})]}),u(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:o$.map(M=>{const F=o===M.key;return f(h,{children:[u(l,{dimColor:!F,children:"["}),u(l,{bold:F,color:F?"cyan":"gray",children:M.shortcut}),u(l,{dimColor:!F,children:"]"}),f(l,{color:F?"white":"gray",children:[" ",M.label]})]},M.key)})}),r&&f(h,{flexShrink:0,paddingX:1,children:[u(l,{bold:!0,color:"white",children:"/ "}),u(l,{children:n}),u(l,{inverse:!0,children:" "})]}),f(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[u(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:u(h,{flexDirection:"column",marginTop:-a,children:A})}),I&&u(h,{flexShrink:0,marginLeft:1,marginRight:1,children:u(An,{contentHeight:L,placement:"inset",scrollOffset:a,style:"block",viewportHeight:p})})]})]})},"OptimizeListPanel");var a$=Object.defineProperty,c$=b((t,e)=>a$(t,"name",{value:e,configurable:!0}),"S$b");const l$=100,Pa=10,Na={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},d$=c$(({isDryRun:t,store:e})=>{const{exit:r}=Hr(),{columns:n,rows:o}=zr(),i=On(e.subscribe,e.getSnapshot),s=Ve(null),[a,c]=ve(0),[d,p]=ve(!1),g=e.getFilteredEntries(),m=g[i.selectedIndex]??null,y=n>=l$,v=Math.max(0,o-5),k=It($=>{r($)},[r]);return mt(($,x)=>{if(d){$==="y"||$==="Y"?k():p(!1);return}if(i.filterActive){x.escape?(e.setFilterActive(!1),e.setFilterText("")):x.return?e.setFilterActive(!1):x.backspace||x.delete?e.setFilterText(i.filterText.slice(0,-1)):$&&!x.ctrl&&!x.meta&&e.setFilterText(i.filterText+$);return}if($==="q"){!t&&i.checkedEntries.size>0?p(!0):k();return}if($==="/"){e.setFilterActive(!0);return}if(Na[$]){e.setFilter(Na[$]);return}if(x.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(x.upArrow||$==="k"){const E=Math.max(0,i.selectedIndex-1);e.select(E),E<a&&c(E)}else if(x.downArrow||$==="j"){const E=Math.min(g.length-1,i.selectedIndex+1);e.select(E),E>=a+v&&c(E-v+1)}else $===" "?m&&e.toggleCheck(m.packageName):$==="a"?e.toggleAll():x.return&&!t&&i.checkedEntries.size>0&&k(e.getCheckedEntries());else i.focusedPanel==="detail"&&(x.upArrow||$==="k"?s.current?.scrollBy(-1):(x.downArrow||$==="j")&&s.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),o<Pa?u(h,{alignItems:"center",justifyContent:"center",children:f(l,{color:"yellow",children:["Terminal too small. Resize to at least",Pa," ","rows."]})}):f(h,{flexDirection:"column",height:o,width:n,children:[f(h,{flexDirection:y?"row":"column",flexGrow:1,children:[u(h,{flexBasis:y?"50%":void 0,flexGrow:1,children:u(s$,{checkedEntries:i.checkedEntries,entries:g,filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",isDryRun:t,scrollOffset:a,selectedIndex:i.selectedIndex,totalEntries:i.entries.length,viewportHeight:v})}),u(h,{flexBasis:y?"50%":void 0,flexGrow:1,children:u(r$,{entry:m,focused:i.focusedPanel==="detail",scrollRef:s})})]}),u(h,{flexShrink:0,paddingX:1,children:f(l,{dimColor:!0,children:[t?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),u(xr,{autoExitSeconds:3,onCancel:b(()=>{p(!1)},"onCancel"),visible:d})]})},"VisOptimizeApp");var u$=Object.defineProperty,Ot=b((t,e)=>u$(t,"name",{value:e,configurable:!0}),"f$e");const mo=Ot((t,e)=>{const r=new Set;try{const n=ue(t),o=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const i of o)if(i)for(const s of Object.keys(i))r.add(s)}catch{}return r},"collectDepsFromPkgJson"),gs=Ot(t=>{const e=Io(t);if(e)return $r(t,e);const r=w(t,"package.json");if(!T(r))return[];try{const n=ue(r),o=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return o?$r(t,o):[]}catch{return[]}},"discoverWorkspacePackages"),$d=Ot(t=>{const e=[],r=Ot((n,o)=>{for(const[,i]of Object.entries(n.mappings)){if(!t.has(i.moduleName))continue;const s=[];for(const a of i.replacements){const c=n.replacements[a];c&&s.push(c.description??c.id)}e.push({category:o,hasCodemod:!1,overrideSpec:void 0,packageName:i.moduleName,replacement:s.join(", ")||i.replacements.join(", ")})}},"scanManifest");return r(Sp,"native"),r(xp,"preferred"),r($p,"micro-utility"),e},"buildE18eEntries"),Sd=Ot((t,e,r,n)=>{const o=bp("npm")??[],i=[];for(const[,s]of o){if(s.deprecated)continue;const a=t.has(s.package),c=e?zb(e,s.package,r.name):!1;if(!a&&!c)continue;const d=In(s.version)?.major;if(d===void 0)continue;const p=n?`npm:${s.name}@${s.version}`:`npm:${s.name}@^${String(d)}`;i.push({category:"socket",hasCodemod:!1,overrideSpec:p,packageName:s.package,replacement:s.name})}return i},"buildSocketEntries");let eo;const xd=Ot(async()=>{if(eo)return eo;try{return eo=(await import("module-replacements-codemods")).codemods,eo}catch{return{}}},"loadCodemods"),Cd=Ot(async t=>{try{const e=await xd();for(const r of t)r.category!=="socket"&&e[r.packageName]&&(r.hasCodemod=!0)}catch{}},"markCodemodAvailability"),jd=Ot(async(t,e)=>{let r=0;try{const n=(await xd())[e];if(!n)return{filesChanged:0,packageName:e};const o=n({}),i=await p$(t);for(const s of i){const a=ee(s);if(a.includes(e))try{const c=await o.transform({file:{filename:s,source:a}});c!==a&&(Se(s,c,"utf8"),r++)}catch(c){process.stderr.write(`warn: codemod transform failed for ${s}: ${c instanceof Error?c.message:String(c)}
|
|
333
|
+
`)}}}catch{}return{filesChanged:r,packageName:e}},"runCodemod"),p$=Ot(async t=>Vu("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:t,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),"collectSourceFiles"),f$={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"]],execute:Ot(async({logger:t,options:e,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=Ne(r),o=!!e.dryRun,i=!!e.prod,s=!!e.pin;S(`Detected ${n.name} v${n.version}.`);const a=mo(w(r,"package.json"),i),c=gs(r),d=new Set(a);for(const I of c){const M=mo(w($e(r,I),"package.json"),i);for(const F of M)d.add(F)}c.length>0&&S(`Scanned ${String(c.length)} workspace package${c.length===1?"":"s"}.`),S(`Scanning dependencies...
|
|
334
|
+
`);const p=vd(r,n.name),g=$d(d),m=Sd(d,p,n,s),y=new Set(g.map(I=>I.packageName)),v=m.filter(I=>!y.has(I.packageName)),k=[...g,...v];if(await Cd(k),k.length===0){S("No optimizations found for your dependencies.");return}const $=!!process.stdout.isTTY&&!lt,x=e.format==="json"||!!e.json;if($&&!o&&!x){const I=new Xb(k),M=await Ut(X.createElement(d$,{isDryRun:!1,store:I}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),F=Array.isArray(M)?M:[];if(F.length===0){S("No optimizations selected.");return}const _=F.filter(j=>j.category!=="socket"&&j.hasCodemod),N=F.filter(j=>j.category!=="socket"&&!j.hasCodemod),C=F.filter(j=>j.category==="socket");if(_.length>0){S(`
|
|
335
|
+
Running ${String(_.length)} codemod${_.length===1?"":"s"}...
|
|
336
|
+
`);for(const j of _){const R=await jd(r,j.packageName);R.filesChanged>0?Z(` ${j.packageName}: ${String(R.filesChanged)} file${R.filesChanged===1?"":"s"} updated`):S(` ${j.packageName}: no files changed`)}}if(N.length>0){se(`
|
|
337
|
+
${String(N.length)} selected replacement${N.length===1?"":"s"} require manual migration (no codemod available):`);for(const j of N)S(` ${j.packageName} → ${j.replacement}`);ie(" Replace usage in your source code, then remove from dependencies.")}if(C.length>0){const j=C.filter(V=>V.overrideSpec).map(V=>({original:V.packageName,spec:V.overrideSpec})),R=yd(r,w(r,"package.json"),j,n);R.added.length>0&&Z(`
|
|
338
|
+
Added ${String(R.added.length)} override${R.added.length===1?"":"s"}.`),R.updated.length>0&&Z(`Updated ${String(R.updated.length)} override${R.updated.length===1?"":"s"}.`)}if(C.length>0&&!e.noInstall){S(`
|
|
339
|
+
Running ${n.name} install to update lockfile...`);const j=Oo(n,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},r,t);j!==0&&se(`${n.name} install exited with code ${String(j)}. Run it manually.`)}S(""),Z("Optimization complete.");return}if(x){process.stdout.write(`${JSON.stringify({e18e:g.map(I=>({category:I.category,hasCodemod:I.hasCodemod,packageName:I.packageName,replacement:I.replacement})),packageManager:n.name,socket:v.map(I=>({overrideSpec:I.overrideSpec,packageName:I.packageName,replacement:I.replacement})),total:k.length,workspaces:c.length},void 0,2)}
|
|
340
|
+
`);return}const E=g.filter(I=>I.category==="native"),A=g.filter(I=>I.category==="preferred"),L=g.filter(I=>I.category==="micro-utility");if(E.length>0){S(`Native replacements (${String(E.length)}):`);for(const I of E)S(` ${I.hasCodemod?"⚙":" "} ${I.packageName} → ${I.replacement}`)}if(A.length>0){S(`
|
|
341
|
+
Preferred alternatives (${String(A.length)}):`);for(const I of A)S(` ${I.hasCodemod?"⚙":" "} ${I.packageName} → ${I.replacement}`)}if(L.length>0){S(`
|
|
342
|
+
Micro-utilities (${String(L.length)}):`);for(const I of L)S(` ${I.hasCodemod?"⚙":" "} ${I.packageName} → ${I.replacement}`)}if(v.length>0){S(`
|
|
343
|
+
Socket.dev overrides (${String(v.length)}):`);for(const I of v)S(` ${I.packageName} → ${I.overrideSpec}`)}S(`
|
|
344
|
+
Total: ${String(k.length)} optimizations available (⚙ = codemod available).`),o&&ie("Run without --dry-run for interactive selection.")},"execute"),group:"Workspace",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}]};var g$=Object.defineProperty,Un=b((t,e)=>g$(t,"name",{value:e,configurable:!0}),"b$a");const h$=Un(async(t,e,r=!1)=>{const n=Ne(t),{packageManager:o}=$o(t),i=mo(w(t,"package.json"),!1),s=gs(t),a=new Set(i);for(const N of s){const C=mo(w($e(t,N),"package.json"),!1);for(const j of C)a.add(j)}const c=is(t),d=Mo(t,o),p=Er(e?.security?.socket),g=e?.security?.socket?.acceptedRisks,m=vd(t,n.name),y={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},v=Zl(t,n.name),[k,$,x,E]=await Promise.all([d.size>0?ss(d,y,c,void 0,t,p,g):Promise.resolve({failed:[],ignored:[],outdated:[]}),Promise.resolve(Ql(t)),Promise.resolve($d(a)),Promise.resolve(Sd(a,m,n,!1))]),A=new Set(x.map(N=>N.packageName)),L=E.filter(N=>!A.has(N.packageName)),I=[...x,...L];r&&await Cd(I);let M=0,F=0;if(p&&$.length>0){const N=await Xr($.map(C=>({name:C.name,version:C.version})),p);for(const C of N.values())C.alerts.length>0&&(M+=C.alerts.length),C.score.overall<Qt&&F++}let _=0;for(const N of k.outdated)N.vulnerabilities&&N.vulnerabilities.length>0&&(_+=N.vulnerabilities.length);if($.length>0){const N=await Do($.map(C=>({name:C.name,version:C.version})));for(const C of N.values())_+=C.length}return{duplicates:v,installedCount:$.length,optimizations:I,outdated:k.outdated,socketIssues:{alerts:M,lowScore:F},vulnCount:_,workspaceCount:s.length}},"runAllScans"),ht=Un(t=>t?Et("✓"):Ue("✗"),"icon"),Xt=Re("⚠"),m$=Un(t=>{const{duplicates:e,installedCount:r,optimizations:n,outdated:o,socketIssues:i,vulnCount:s}=t;if(S(""),S(be("── Dependencies ────────────────────────")),S(` ${ht(!0)} ${String(r)} packages installed`),o.length>0){const y=o.filter(x=>x.updateType==="major").length,v=o.filter(x=>x.updateType==="minor").length,k=o.filter(x=>x.updateType==="patch").length,$=[];y>0&&$.push(`${String(y)} major`),v>0&&$.push(`${String(v)} minor`),k>0&&$.push(`${String(k)} patch`),S(` ${Xt} ${String(o.length)} outdated (${$.join(", ")})`)}else S(` ${ht(!0)} All dependencies up to date`);e.length>0?S(` ${Xt} ${String(e.length)} packages with duplicate versions`):S(` ${ht(!0)} No duplicate dependencies`),S(""),S(be("── Security ────────────────────────────")),s>0?S(` ${ht(!1)} ${String(s)} vulnerabilit${s===1?"y":"ies"} found`):S(` ${ht(!0)} No known vulnerabilities`),i.alerts>0&&S(` ${Xt} ${String(i.alerts)} Socket.dev security alert${i.alerts===1?"":"s"}`),i.lowScore>0&&S(` ${Xt} ${String(i.lowScore)} package${i.lowScore===1?"":"s"} with low security score`),i.alerts===0&&i.lowScore===0&&s===0&&S(` ${ht(!0)} No security issues detected`),S(""),S(be("── Optimization ────────────────────────"));let a=0,c=0,d=0,p=0;for(const y of n)switch(y.category){case"micro-utility":{d++;break}case"native":{a++;break}case"preferred":{c++;break}case"socket":{p++;break}}n.length>0?(a>0&&S(` ${Xt} ${String(a)} replaceable with native APIs`),c>0&&S(` ${Xt} ${String(c)} with lighter alternatives`),d>0&&S(` ${Xt} ${String(d)} trivial micro-utilities`),p>0&&S(` ${Xt} ${String(p)} @socketregistry overrides available`)):S(` ${ht(!0)} No optimizations available`),S(""),S(be("── Summary ─────────────────────────────"));const g=s,m=o.length+e.length+n.length;g===0&&m===0?Z(" Everything looks good!"):(g>0&&er(` ${String(g)} security issue${g===1?"":"s"}`),m>0&&S(` ${String(m)} improvement${m===1?"":"s"} available`))},"displayResults"),y$=Un(t=>{const e=[];if(t.outdated.length>0&&e.push("vis update — update outdated dependencies"),(t.vulnCount>0||t.socketIssues.alerts>0)&&e.push("vis audit — detailed security analysis"),t.optimizations.length>0&&e.push("vis optimize — apply optimizations interactively"),t.duplicates.length>0&&e.push("vis dedupe — reduce duplicate versions"),e.length>0){S(""),ie(" Next steps:");for(const r of e)ie(` ${r}`)}S("")},"displayActions"),v$={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 --exit-code","Exit with code 1 if security issues found"],["vis doctor --exit-code --strict","Fail on any issue (outdated, duplicates, security)"]],execute:Un(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const o=Ne(n);S(`
|
|
345
|
+
${be("VIS DOCTOR")} — project health check
|
|
346
|
+
`),S(` ${ht(!0)} Detected ${o.name} v${o.version}`);const i=gs(n);i.length>0&&S(` ${ht(!0)} ${String(i.length)} workspace package${i.length===1?"":"s"}`);const s=wd(n);if(s.length===0)S(` ${ht(!0)} Runtime: Node.js ${process.versions.node} ${Et("✓")}`);else for(const m of s){const y=m.severity==="error"?Ue:Re;S(` ${ht(!1)} Runtime: ${y(m.message)}`)}S(`
|
|
347
|
+
Scanning...`);const a=await h$(n,r,!!e.fix);let c=0,d=0,p=0,g=0;for(const m of a.optimizations)switch(m.category){case"micro-utility":{p++;break}case"native":{c++;break}case"preferred":{d++;break}case"socket":{g++;break}}if(e.format==="json"||e.json){process.stdout.write(`${JSON.stringify({dependencies:{duplicates:a.duplicates.length,installed:a.installedCount,outdated:a.outdated.length},optimizations:{microUtilities:p,native:c,preferred:d,socket:g,total:a.optimizations.length},packageManager:o.name,security:{alerts:a.socketIssues.alerts,lowScorePackages:a.socketIssues.lowScore,vulnerabilities:a.vulnCount},workspaces:a.workspaceCount},void 0,2)}
|
|
348
|
+
`),e.exitCode&&(a.vulnCount>0||a.socketIssues.alerts>0)&&(process.exitCode=1);return}if(m$(a),e.fix&&a.optimizations.length>0){S(""),S(`Applying fixes...
|
|
349
|
+
`);const m=a.optimizations.filter(v=>v.category==="socket"&&v.overrideSpec).map(v=>({original:v.packageName,spec:v.overrideSpec}));if(m.length>0){const v=yd(n,w(n,"package.json"),m,o);v.added.length>0&&Z(` Added ${String(v.added.length)} security override${v.added.length===1?"":"s"}.`),v.updated.length>0&&Z(` Updated ${String(v.updated.length)} override${v.updated.length===1?"":"s"}.`)}const y=a.optimizations.filter(v=>v.category!=="socket"&&v.hasCodemod);for(const v of y){const k=await jd(n,v.packageName);k.filesChanged>0&&Z(` ${v.packageName}: ${String(k.filesChanged)} file${k.filesChanged===1?"":"s"} updated`)}m.length>0&&(S(`
|
|
350
|
+
Running ${o.name} install to update lockfile...`),Oo(o,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,t)),S(""),Z("Fixes applied.")}else y$(a);e.exitCode&&(e.strict?a.vulnCount>0||a.socketIssues.alerts>0||a.outdated.length>0||a.duplicates.length>0:a.vulnCount>0||a.socketIssues.alerts>0)&&(process.exitCode=1)},"execute"),group:"Security & Health",name:"doctor",options:[{description:"Output format: table or json (default: table)",name:"format",type:String},{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)",name:"fix",type:Boolean},{defaultValue:!1,description:"With --exit-code: also fail on outdated and duplicate deps",name:"strict",type:Boolean}]};var w$=Object.defineProperty,k$=b((t,e)=>w$(t,"name",{value:e,configurable:!0}),"s$c");const b$={argument:{description:"Command to execute followed by arguments",name:"command",type:String},description:"Execute a local node_modules/.bin command (no remote fallback)",examples:[["vis exec eslint .","Run local eslint"],["vis exec tsc --noEmit","Run local TypeScript check"],["vis exec -r -- eslint .","Run in all workspace packages"],["vis exec -c 'echo $PATH'","Shell mode"]],execute:k$(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const o=t;if(!o||o.length===0)throw new Error("No command specified. Usage: vis exec <command> [args...]");const[i,...s]=o,a=n??process.cwd(),c=Ne(a),d=oh(c,{args:s,command:i,filter:Dn(r.filter),parallel:r.parallel||!1,recursive:r.recursive||!1,reverse:r.reverse||!1,shellMode:r.shellMode||!1,workspaceRoot:r.workspaceRoot||!1},a,e);d!==0&&(process.exitCode=d)},"execute"),group:"Run & Execute",name:"exec",options:[{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"r",defaultValue:!1,description:"Run in every workspace package",name:"recursive",type:Boolean},{alias:"w",defaultValue:!1,description:"Run on workspace root only",name:"workspace-root",type:Boolean},{alias:"F",description:"Filter packages by name pattern",multiple:!0,name:"filter",type:String},{defaultValue:!1,description:"Run concurrently without topological ordering",name:"parallel",type:Boolean},{defaultValue:!1,description:"Reverse topological execution order",name:"reverse",type:Boolean}]};var $$=Object.defineProperty,Wt=b((t,e)=>$$(t,"name",{value:e,configurable:!0}),"i$a");const Td=[".ts",".mts",".cts",".js",".mjs",".cjs"],S$="template.yml",x$=[".d",".test",".spec",".config",".bench",".stories"],C$=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],Ed=Wt(t=>{for(const e of Td)if(t.endsWith(e))return t.slice(0,-e.length);return t},"stripExtension"),j$=Wt(t=>{if(C$.some(r=>t.endsWith(r))||!Td.some(r=>t.endsWith(r)))return!1;const e=Ed(t);return!x$.some(r=>e.endsWith(r))},"isNativeFile"),Ma=Wt((t,e)=>{const r=[];if(!T(t))return r;for(const n of Rn(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!j$(n.name))continue;const o=Ed(n.name);r.push({load:Wt(()=>T$(n.path),"load"),name:o,path:n.path,source:e})}return r},"scanNativeDirectory"),si=Wt((t,e)=>{const r=[];if(!T(t))return r;for(const n of Rn(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(n.path===t)continue;const o=w(n.path,S$);T(o)&&r.push({load:Wt(()=>E$(n.path,n.name),"load"),name:n.name,path:n.path,source:e})}return r},"scanMoonDirectory"),ai=Wt(t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:n}=t,o=[];o.push(...Ma(w(n,".vis","templates"),"native")),o.push(...si(w(n,".vis","templates"),"moon")),o.push(...si(w(n,".moon","templates"),"moon"));for(const s of e)o.push(...si(s,"config")),o.push(...Ma(s,"config"));const i=new Map;for(const s of o){const a=i.get(s.name);if(!a){i.set(s.name,s);continue}r&&r(`Template "${s.name}" exists in multiple sources — using ${a.source} (${a.path}), ignoring ${s.source} (${s.path}).`)}return[...i.values()].sort((s,a)=>s.name.localeCompare(a.name))},"discoverTemplates"),T$=Wt(async t=>{const{loadNativeTemplate:e}=await import("./packem_chunks/loader.js");return e(t)},"loadNativeFromPath"),E$=Wt(async(t,e)=>{const{loadMoonTemplate:r}=await import("./packem_chunks/index.js");return r(t,e)},"loadMoonFromPath");var R$=Object.defineProperty,Mt=b((t,e)=>R$(t,"name",{value:e,configurable:!0}),"c$k");const Vo=Mt((t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),"ask"),I$=Mt(async(t,e,r)=>{const n=await Vo(t,` ${e} ${re(r?"[Y/n]":"[y/N]")} `);return n===""?r:n.toLowerCase()==="y"||n.toLowerCase()==="yes"},"confirm"),A$=Mt(async(t,e,r,n)=>{process.stderr.write(` ${e}
|
|
351
|
+
`);for(const[o,i]of r.entries()){const s=ye(Be(` ${String(o+1)}.`)),a=i===n?re(" (default)"):"";process.stderr.write(`${s} ${i}${a}
|
|
352
|
+
`)}for(;;){const o=await Vo(t,`
|
|
353
|
+
${re(`Enter choice (1-${String(r.length)}):`)} `);if(o===""&&n!==void 0)return n;const i=Number.parseInt(o,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const s=r.find(a=>a===o);if(s)return s;process.stderr.write(` ${re("Invalid choice. Try again.")}
|
|
354
|
+
`)}},"selectOne"),O$=Mt(async(t,e,r,n)=>{process.stderr.write(` ${e} ${re("(comma-separated numbers)")}
|
|
355
|
+
`);for(const[o,i]of r.entries()){const s=ye(Be(` ${String(o+1)}.`)),a=n.includes(i)?re(" (default)"):"";process.stderr.write(`${s} ${i}${a}
|
|
356
|
+
`)}for(;;){const o=await Vo(t,`
|
|
357
|
+
${re("Enter choices:")} `);if(o===""&&n.length>0)return n;const i=o.split(",").map(s=>Number.parseInt(s.trim(),10)).filter(s=>Number.isInteger(s)&&s>=1&&s<=r.length);if(i.length>0)return i.map(s=>r[s-1]);process.stderr.write(` ${re("Invalid choice. Try again.")}
|
|
358
|
+
`)}},"selectMany"),P$=Mt(t=>` ${re(`${t}:`)} `,"promptText"),N$=Mt((t,e)=>e.prompt??t,"variableLabel"),M$=Mt(t=>Object.entries(t).sort(([e,r],[n,o])=>{const i=r.order??0,s=o.order??0;return i!==s?i-s:e.localeCompare(n)}),"sortVariables"),Da=Mt((t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},"parseValue"),ci=Mt((t,e,r)=>{if(e.type==="enum"){const n=Array.isArray(r)?r:[r];for(const o of n)if(typeof o!="string"||!e.values.includes(o))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(o)}")`)}},"validateValue"),D$=Mt(async t=>{const{defaults:e,interactive:r,overrides:n,variables:o}=t,i={},s=r?dt({input:process.stdin,output:process.stderr}):null;try{for(const[a,c]of M$(o)){if(Object.hasOwn(n,a)){const g=Da(c,n[a]??"");ci(a,c,g),i[a]=g;continue}if(e||!r||c.internal){if(c.default!==void 0){ci(a,c,c.default),i[a]=c.default;continue}if(c.required)throw new Error(`Required variable "${a}" not provided. Pass --${a}=<value> or remove --defaults.`);continue}const d=N$(a,c);let p;if(c.type==="boolean")p=await I$(s,d,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const g=Array.isArray(c.default)?c.default:[];p=await O$(s,d,c.values,g)}else{const g=typeof c.default=="string"?c.default:void 0;p=await A$(s,d,c.values,g)}else{const g=c.default===void 0?"":` (${String(c.default)})`,m=await Vo(s,P$(`${d}${g}`));if(m===""&&c.default!==void 0)p=c.default;else if(m===""){if(c.required)throw new Error(`Variable "${a}" is required`);continue}else p=Da(c,m)}ci(a,c,p),i[a]=p}return i}finally{s?.close()}},"collectOptions");var B$=Object.defineProperty,bi=b((t,e)=>B$(t,"name",{value:e,configurable:!0}),"o$c");const F$=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],L$=bi(t=>F$.some(e=>t.startsWith(e)),"isRemoteSource"),V$=bi(async(t,e={})=>{const r=e.targetDirectory===void 0,n=e.targetDirectory??ap(w(Qu(),"vis-generate-")),o=bi(()=>{if(r)try{ot(n,{force:!0,recursive:!0})}catch{}},"cleanup");S(`Downloading ${t}…`);try{const i=await Wc(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:n,force:!0,preferOffline:e.preferOffline});return{cleanup:o,directory:i.dir}}catch(i){o();const s=i instanceof Error?i.message:String(i);throw se(`Failed to download template: ${s}`),i}},"fetchRemoteTemplate");var U$=Object.defineProperty,Ar=b((t,e)=>U$(t,"name",{value:e,configurable:!0}),"a$c");const Rd=Ar((t,e="")=>{const r=[];for(const[n,o]of Object.entries(t)){const i=e?`${e}/${n}`:n;typeof o=="string"||Buffer.isBuffer(o)?r.push({content:o,path:i}):o&&typeof o=="object"&&r.push(...Rd(o,i))}return r},"flattenTree"),_$=Ar(t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,"formatSize"),G$=Ar((t,e)=>{if(nt(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=w(t,e),n=_e(t,r);if(n===".."||n.startsWith(`..${Cc}`)||nt(n))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},"safeJoinDestination"),W$=Ar((t,e)=>{je(Nt(t)),Q(t,e)},"writeOne"),z$=Ar((t,e,r=!1)=>{const n=typeof t=="string"?[t]:t.commands,o=typeof t=="string"?r:t.silent??r;for(const i of n){o||S(`$ ${i}`);const s=ct(i,{cwd:e,shell:!0,stdio:o?"ignore":"inherit"});if(s.status!==0)return se(`Script failed (exit ${String(s.status)}): ${i}`),!1}return!0},"runScript"),H$=Ar(t=>{const e=new Map;for(const r of t){const n=typeof r=="string"?0:r.phase??0,o=e.get(n);o?o.push(r):e.set(n,[r])}return[...e.entries()].sort(([r],[n])=>r-n)},"groupByPhase"),q$=Ar(async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:_e(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},n=await t.produce(r),o=n.files?Rd(n.files):[],i=n.filesMeta??{},s=[];for(const a of o){const c=G$(e.destination,a.path);s.push({file:a,meta:i[a.path]??{},target:c})}if(e.dryRun){S(`${ye(Be("Plan"))} ${re("(dry-run, no files written)")}`);for(const a of s){const c=Buffer.isBuffer(a.file.content)?a.file.content.length:Buffer.byteLength(a.file.content,"utf8");process.stderr.write(` ${re("write")} ${a.file.path} ${re(`(${_$(c)})`)}
|
|
359
|
+
`)}}else{je(e.destination);let a=0,c=0;for(const d of s){const{file:p,meta:g,target:m}=d,y=T(m),v=e.force||g.force===!0;if(y&&!v){se(`Skipped existing file: ${p.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}W$(m,p.content),a+=1}Z(`Wrote ${String(a)} file${a===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&n.scripts&&n.scripts.length>0){const a=H$(n.scripts);S(`Running ${String(n.scripts.length)} script${n.scripts.length===1?"":"s"} across ${String(a.length)} phase${a.length===1?"":"s"}…`);for(const[,c]of a)if((await Promise.all(c.map(d=>Promise.resolve(z$(d,e.destination))))).includes(!1))throw new Error("Script failed — aborting.")}if(n.suggestions&&n.suggestions.length>0){process.stderr.write(`
|
|
360
|
+
`),ie("Next steps:");for(const a of n.suggestions)process.stderr.write(` ${re("•")} ${a}
|
|
361
|
+
`)}},"runTemplate");var J$=Object.defineProperty,Uo=b((t,e)=>J$(t,"name",{value:e,configurable:!0}),"u$e");const Y$=Uo(t=>{if(t.length===0){S("No templates found."),ie("Create one at .vis/templates/<name>.ts (programmatic) or .vis/templates/<name>/ (moon-format with template.yml).");return}S("Available templates:");for(const e of t){const r=re(`(${e.source})`);process.stderr.write(` ${ye(Be(e.name))} ${r}
|
|
362
|
+
`)}},"printList"),K$=Uo(t=>{const e={},r=[];for(const n of t){if(!n.startsWith("--")){r.push(n);continue}const o=n.indexOf("=");if(o===-1){const a=n.slice(2);a.startsWith("no-")?e[a.slice(3)]="false":e[a]="true";continue}const i=n.slice(2,o),s=n.slice(o+1);e[i]=s}return{overrides:e,remaining:r}},"parsePassthroughOverrides"),X$={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"]],execute:Uo(async({argument:t,options:e,rawUnknown:r,visConfig:n,workspaceRoot:o})=>{const i=e.cwd||o||process.cwd(),s=o??i,a=n?.generator,c=Array.isArray(t)?t:t?[t]:[];if(e.list){const R=ai({extraDirectories:a?.templates??[],onWarning:se,workspaceRoot:s});Y$(R);return}let d=[...r??[]];if(d.length===0){const R=process.argv.slice(2),V=R.indexOf("--");V!==-1&&(d=R.slice(V+1))}const p=c.indexOf("--"),g=p===-1?[]:c.slice(p+1),m=p===-1?c:c.slice(0,p),{overrides:y}=K$([...g,...d]);let v,k,$;const x=m[0];let E;if(x&&L$(x)){const R=await V$(x,{auth:a?.auth,preferOffline:!!e.preferOffline||a?.preferOffline});E=R.cleanup;try{const V=ai({extraDirectories:[R.directory],workspaceRoot:s}).find(P=>P.path.startsWith(R.directory));if(!V)throw new Error(`Downloaded template at ${R.directory} contains no template.yml or *.ts entrypoint.`);v=await V.load(),k=V.name,$=v.destination}catch(V){throw E(),E=void 0,V}}else{const R=ai({extraDirectories:a?.templates??[],onWarning:se,workspaceRoot:s});if(R.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let V;if(x)V=x;else{if(e.noInteractive||!process.stdin.isTTY)throw new Error("No template specified. Pass a template name (see `vis generate --list`) or run interactively in a terminal.");V=await Q$(R)}const P=R.find(B=>B.name===V);if(!P)throw new Error(`Template "${V}" not found. Run 'vis generate --list' to see available templates.`);v=await P.load(),k=P.name,$=v.destination}const A=e.to,L=!!e.dryRun,I=!!e.force,M=!!e.defaults,F=!!e.skipScripts,_=!e.noInteractive&&!!process.stdin.isTTY&&!M;let N;A?N=A:$?N=$:N=".";const C=nt(N)?N:$e(i,N);S(`Template: ${ye(Be(k))}`),S(`Target: ${re(C)}`),process.stderr.write(`
|
|
363
|
+
`);const j=await D$({defaults:M,interactive:_,overrides:y,variables:v.options??{}});try{await q$(v,{cwd:i,destination:C,dryRun:L,force:I,options:j,skipScripts:F,workspaceRoot:s}),L||(process.stderr.write(`
|
|
364
|
+
`),Z(`Template '${k}' applied.`))}finally{E?.()}},"execute"),group:"Scaffold & Config",name:"generate",options:[{defaultValue:!1,description:"List discovered templates",name:"list",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}]},Q$=Uo(async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${ye(Be("vis generate"))} ${re("— pick a template")}
|
|
365
|
+
|
|
366
|
+
`);for(const[n,o]of t.entries()){const i=ye(Be(` ${String(n+1)}.`));process.stderr.write(`${i} ${o.name} ${re(`(${o.source})`)}
|
|
367
|
+
`)}return new Promise((n,o)=>{r.question(`
|
|
368
|
+
${re(`Enter choice (1-${String(t.length)}):`)} `,i=>{const s=Number.parseInt(i.trim(),10);Number.isInteger(s)&&s>=1&&s<=t.length?n(t[s-1].name):o(new Error("Invalid choice."))})})}finally{r.close()}},"pickInteractive");var Z$=Object.defineProperty,vn=b((t,e)=>Z$(t,"name",{value:e,configurable:!0}),"n$7");const eS=vn(t=>{const e=new Map;for(const[r,n]of Object.entries(t.dependencies))for(const o of n){const i=e.get(o.target)??[];i.push(r),e.set(o.target,i)}return Object.values(t.nodes).map(r=>({deps:t.dependencies[r.name]??[],name:r.name,reverseDeps:e.get(r.name)??[],type:r.type})).sort((r,n)=>r.type!==n.type?r.type==="application"?-1:1:r.name.localeCompare(n.name))},"buildNodes"),tS=vn((t,e,r)=>{let n=t;if(e==="app"?n=n.filter(o=>o.type==="application"):e==="lib"&&(n=n.filter(o=>o.type!=="application")),r){const o=r.toLowerCase();n=n.filter(i=>i.name.toLowerCase().includes(o))}return n},"filterNodes");class rS{static{b(this,"GraphStore")}static{vn(this,"GraphStore")}#e;#t=new Set;#n;constructor(e){this.#n=e;const r=eS(e);this.#e={allNodes:r,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=vn(()=>this.#e,"getSnapshot");subscribe=vn(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredNodes(){return tS(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const e=this.#e.allNodes.filter(o=>o.type==="application").length,r=this.#e.allNodes.length,n=Object.values(this.#n.dependencies).reduce((o,i)=>o+i.length,0);return{apps:e,deps:n,libs:r-e,total:r}}setSelectedIndex(e){const r=this.getFilteredNodes(),n=r.length===0?-1:Math.max(0,Math.min(e,r.length-1));n!==this.#e.selectedIndex&&this.#o({...this.#e,selectedIndex:n})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#o({...this.#e,focusedPanel:e})}setFilterType(e){e!==this.#e.filterType&&this.#o({...this.#e,filterType:e,selectedIndex:0})}setFilter(e){this.#o({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#o({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:e?this.#e.selectedIndex:0})}#o(e){this.#e=e;for(const r of this.#t)try{r()}catch{}}}var nS=Object.defineProperty,oS=b((t,e)=>nS(t,"name",{value:e,configurable:!0}),"p$l");const iS=oS(({focused:t,node:e,scrollRef:r})=>{const n=t?"white":"gray";if(!e)return u(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:u(l,{dimColor:!0,children:"No project selected"})});const o=e.type==="application",i=o?"yellow":"cyan",s=o?"Application":"Library";return u(h,{borderColor:n,borderStyle:"single",borderTopRightTitle:` ${s} `,borderTopTitle:` ${e.name} `,flexDirection:"column",flexGrow:1,children:f(qr,{flexGrow:1,flexShrink:1,paddingX:2,ref:r,scrollbar:!0,scrollbarColor:"gray",children:[f(h,{flexDirection:"column",marginTop:1,children:[f(h,{children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"DEPENDS ON"}),f(l,{dimColor:!0,children:[" ","(",e.deps.length,")"]})]}),e.deps.length===0?u(h,{marginTop:1,paddingLeft:2,children:u(l,{dimColor:!0,children:"No dependencies"})}):u(h,{flexDirection:"column",marginTop:1,children:e.deps.map(a=>f(h,{gap:1,paddingLeft:2,children:[u(l,{color:"cyan",children:"→"}),u(l,{children:a.target}),a.type!=="static"&&f(l,{dimColor:!0,children:["(",a.type,")"]})]},a.target))})]}),f(h,{flexDirection:"column",marginTop:1,children:[f(h,{children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"REQUIRED BY"}),f(l,{dimColor:!0,children:[" ","(",e.reverseDeps.length,")"]})]}),e.reverseDeps.length===0?u(h,{marginTop:1,paddingLeft:2,children:u(l,{dimColor:!0,children:"No reverse dependencies"})}):u(h,{flexDirection:"column",marginTop:1,children:e.reverseDeps.map(a=>f(h,{gap:1,paddingLeft:2,children:[u(l,{color:"magenta",children:"←"}),u(l,{children:a})]},a))})]}),f(h,{flexDirection:"column",marginTop:1,children:[f(h,{children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"INFO"})]}),f(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[f(h,{children:[u(h,{width:16,children:u(l,{dimColor:!0,children:"Type:"})}),u(l,{color:i,children:s})]}),f(h,{children:[u(h,{width:16,children:u(l,{dimColor:!0,children:"Dependencies:"})}),u(l,{children:String(e.deps.length)})]}),f(h,{children:[u(h,{width:16,children:u(l,{dimColor:!0,children:"Required by:"})}),u(l,{children:String(e.reverseDeps.length)})]}),f(h,{children:[u(h,{width:16,children:u(l,{dimColor:!0,children:"Connectivity:"})}),u(l,{children:String(e.deps.length+e.reverseDeps.length)})]})]})]})]})})},"ProjectDetailPanel");var sS=Object.defineProperty,hs=b((t,e)=>sS(t,"name",{value:e,configurable:!0}),"g$f");const aS=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],Ba=hs(({isSelected:t,node:e})=>{const r=e.type==="application",n=r?"yellow":"cyan",o=r?"app":"lib";return f(h,{flexShrink:0,height:1,children:[f(l,{children:[t?"▶":" "," "]}),u(h,{flexGrow:1,children:u(l,{bold:t,inverse:t,wrap:"truncate",children:e.name})}),f(l,{color:n,children:[" ",o]}),f(l,{dimColor:!0,children:[" ","→",e.deps.length," ","←",e.reverseDeps.length]})]})},"ProjectRow"),Fa=hs(({count:t,label:e})=>f(h,{flexShrink:0,height:1,marginTop:1,children:[f(l,{dimColor:!0,children:["▼"," "]}),u(l,{bold:!0,color:"white",children:e.toUpperCase()}),f(l,{dimColor:!0,children:[" ","(",t,")"]})]}),"TypeHeader"),cS=hs(({filterActive:t,filterText:e,filterType:r,focused:n,nodes:o,scrollOffset:i,selectedIndex:s,stats:a,viewportHeight:c})=>{const d=n?"white":"gray",p=o.filter($=>$.type==="application"),g=o.filter($=>$.type!=="application"),m=[];let y=0;if(p.length>0){m.push(u(Fa,{count:p.length,label:"Applications"},"hdr-apps"));for(const $ of p){const x=y;m.push(u(Ba,{isSelected:x===s,node:$},$.name)),y++}}if(g.length>0){m.push(u(Fa,{count:g.length,label:"Libraries"},"hdr-libs"));for(const $ of g){const x=y;m.push(u(Ba,{isSelected:x===s,node:$},$.name)),y++}}let v=0;p.length>0&&(v+=2+p.length),g.length>0&&(v+=2+g.length);const k=v>c&&c>0;return f(h,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(h,{flexShrink:0,gap:1,paddingX:1,children:[u(l,{bold:!0,inverse:!0,children:" VIS "}),f(l,{wrap:"truncate",children:[a.total," ","packages"]}),f(l,{dimColor:!0,children:["(",a.apps," ","apps,"," ",a.libs," ","libs,"," ",a.deps," ","deps)"]})]}),u(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:aS.map($=>{const x=r===$.key;return f(h,{children:[u(l,{dimColor:!x,children:"["}),u(l,{bold:x,color:x?"cyan":"gray",children:$.shortcut}),u(l,{dimColor:!x,children:"]"}),f(l,{color:x?"white":"gray",children:[" ",$.label]})]},$.key)})}),t&&f(h,{flexShrink:0,paddingX:1,children:[u(l,{bold:!0,color:"white",children:"/ "}),u(l,{children:e}),u(l,{inverse:!0,children:" "})]}),f(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[u(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:u(h,{flexDirection:"column",marginTop:-i,children:m})}),k&&u(h,{flexShrink:0,marginLeft:1,marginRight:1,children:u(An,{contentHeight:v,placement:"inset",scrollOffset:i,style:"block",viewportHeight:c})})]})]})},"ProjectListPanel");var lS=Object.defineProperty,dS=b((t,e)=>lS(t,"name",{value:e,configurable:!0}),"M$a");const uS=100,pS=40,fS=10,La={1:"all",2:"app",3:"lib"},gS=dS(({autoExitSeconds:t=0,store:e})=>{const{exit:r}=Hr(),{columns:n,rows:o}=zr(),i=On(e.subscribe,e.getSnapshot),[s,a]=ve(!1),c=Ve(null),d=Ve(null),[p,g]=ve(0),[m,y]=ve(!1),v=At(()=>e.getFilteredNodes(),[i.allNodes,i.filterType,i.filterText]),k=At(()=>e.getStats(),[i.allNodes]),$=v[i.selectedIndex]??null,x=It(C=>{const j=v.filter(B=>B.type==="application"),R=v.filter(B=>B.type!=="application");let V=0,P=0;if(j.length>0){V+=2;for(let B=0;B<j.length;B++){if(P===C)return V;V+=1,P++}}if(R.length>0){V+=2;for(let B=0;B<R.length;B++){if(P===C)return V;V+=1,P++}}return V},[v]),E=Math.max(1,o-8-(i.filterActive?1:0)),A=It(C=>{const j=x(C);g(R=>j>R+E-2?Math.max(0,j-E+2):j<R+1?Math.max(0,j-1):R)},[x,E]);if(Rt(()=>{d.current?.scrollToTop()},[$?.name]),mt((C,j)=>{if(C==="c"&&j.ctrl){r();return}if(!m){if(s){j.escape||C==="?"?a(!1):C==="q"?(a(!1),y(!0)):j.downArrow||C==="j"?c.current?.scrollBy(1):(j.upArrow||C==="k")&&c.current?.scrollBy(-1);return}if(C==="?"){a(!0);return}if(C==="q"){y(!0);return}if(j.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(La[C]){e.setFilterType(La[C]);return}if(i.filterActive){if(j.escape){e.setFilterActive(!1);return}if(j.return){e.setFilterActive(!1);return}if(j.backspace){e.setFilter(i.filterText.slice(0,-1));return}if(C&&!j.ctrl&&!j.meta){e.setFilter(i.filterText+C);return}return}if(i.focusedPanel==="list"){if(v.length===0){C==="/"&&e.setFilterActive(!0);return}if(j.downArrow||C==="j"){const R=Math.min(i.selectedIndex+1,v.length-1);e.setSelectedIndex(R),A(R);return}if(j.upArrow||C==="k"){const R=Math.max(i.selectedIndex-1,0);e.setSelectedIndex(R),A(R);return}if(j.pageDown){const R=Math.min(i.selectedIndex+10,v.length-1);e.setSelectedIndex(R),A(R);return}if(j.pageUp){const R=Math.max(i.selectedIndex-10,0);e.setSelectedIndex(R),A(R);return}if(j.home){e.setSelectedIndex(0),g(0);return}if(j.end){const R=v.length-1;e.setSelectedIndex(R),A(R);return}if(C==="/"){e.setFilterActive(!0);return}if(j.rightArrow){e.setFocusedPanel("detail");return}return}if(i.focusedPanel==="detail"){if(j.escape||j.leftArrow){e.setFocusedPanel("list");return}if(j.downArrow||C==="j"){d.current?.scrollBy(1);return}if(j.upArrow||C==="k"){d.current?.scrollBy(-1);return}if(j.pageDown){d.current?.scrollBy(10);return}if(j.pageUp){d.current?.scrollBy(-10);return}if(j.home){d.current?.scrollToTop();return}j.end&&d.current?.scrollToBottom()}}},{isActive:!0}),n<pS||o<fS)return u(h,{alignItems:"center",height:o,justifyContent:"center",width:n,children:f(l,{color:"yellow",children:["Terminal too small (",n,"x",o,")"]})});const L=n>=uS,I=u(h,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:f(h,{flexWrap:"wrap",gap:2,paddingX:1,children:[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"q"}),u(l,{dimColor:!0,children:"QUIT"})]},"q"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"?"}),u(l,{dimColor:!0,children:"HELP"})]},"?"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"↑↓"}),u(l,{dimColor:!0,children:"NAV"})]},"nav"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"1-3 /"}),u(l,{dimColor:!0,children:"FILTER"})]},"f"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"Tab"}),u(l,{dimColor:!0,children:"PANEL"})]},"t")]})}),M=f(wr,{footer:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",u(l,{bold:!0,color:"white",children:"?"}),"/",u(l,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:c,title:"KEYBOARD SHORTCUTS",visible:s,width:52,children:[f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"NAVIGATION"})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),u(l,{dimColor:!0,children:" Move up"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),u(l,{dimColor:!0,children:" Move down"})]})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Tab"]}),u(l,{dimColor:!0,children:" Switch panel"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","→","/","←"]}),u(l,{dimColor:!0,children:" Focus detail/list"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),u(l,{dimColor:!0,children:" Jump 10 items"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Home/End"]}),u(l,{dimColor:!0,children:" Jump to start/end"})]})]}),f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"FILTERS"})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","1"]}),u(l,{dimColor:!0,children:" All"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","2"]}),u(l,{dimColor:!0,children:" Apps only"})]})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","3"]}),u(l,{dimColor:!0,children:" Libraries only"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","/"]}),u(l,{dimColor:!0,children:" Text filter"})]})]}),f(h,{flexDirection:"column",children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"ACTIONS"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","q"]}),u(l,{dimColor:!0,children:" Quit"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","?"]}),u(l,{dimColor:!0,children:" Toggle help"})]})]})]}),F=u(cS,{filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",nodes:v,scrollOffset:p,selectedIndex:i.selectedIndex,stats:k,viewportHeight:E}),_=u(iS,{focused:i.focusedPanel==="detail",node:$,scrollRef:d});if(L){const C=Math.floor(n*.35);return f(h,{flexDirection:"column",height:o,width:n,children:[f(h,{flexDirection:"row",flexGrow:1,children:[u(h,{flexGrow:1,children:F}),u(h,{width:C,children:_})]}),I,u(xr,{autoExitSeconds:t??3,onCancel:b(()=>{y(!1)},"onCancel"),visible:m}),M]})}const N=Math.floor(o*.55);return f(h,{flexDirection:"column",height:o,width:n,children:[u(h,{height:N,children:F}),u(h,{flexGrow:1,children:_}),I,u(xr,{autoExitSeconds:t??3,onCancel:b(()=>{y(!1)},"onCancel"),visible:m}),M]})},"VisGraphApp");var Va=Object.freeze,Id=Object.defineProperty,Zr=b((t,e)=>Id(t,"name",{value:e,configurable:!0}),"y$7"),hS=b((t,e)=>Va(Id(t,"raw",{value:Va(e||t.slice())})),"k$d");const Ad=Zr((t,e,r,n,o,i,s,a)=>{const c=re(r?"└── ":"├── "),d=o.has(t),p=d?re(" (*)"):"",g=n.get(t),m=g?.type==="application"?ye(t):t;if(i.push(`${e}${c}${m}${p}`),d)return;o.add(t);const y=g?.deps??[],v=r?`${e} `:`${e}${re("│")} `;if(a>=s&&y.length>0){i.push(`${v}${re(`... ${y.length} more`)}`);return}for(let k=0;k<y.length;k++){const $=y[k];$&&Ad($.target,v,k===y.length-1,n,o,i,s,a+1)}},"printDepsTree"),Ua=Zr((t,e,r,n,o,i)=>{const s=e.get(t),a=s?.type==="application"?ye(t):t;n.push(`${i}${a}`),r.add(t);const c=s?.deps??[];if(c.length===0){n.push(`${i} ${re("(no dependencies)")}`);return}if(o<=0){n.push(`${i} ${re(`... ${c.length} dependencies`)}`);return}for(let d=0;d<c.length;d++){const p=c[d];p&&Ad(p.target,i,d===c.length-1,e,r,n,o,1)}},"printRootProject"),_a=Zr((t,e)=>{const r=new Map;for(const[g,m]of Object.entries(t.nodes))r.set(g,{deps:(t.dependencies[g]??[]).map(y=>({target:y.target,type:y.type})),name:g,type:m.type});const n=[],o=[];for(const[g,m]of r)m.type==="application"?n.push(g):o.push(g);n.sort(),o.sort();const i=n.length+o.length,s=Object.values(t.dependencies).reduce((g,m)=>g+m.length,0),a=[];if(a.push(ye("Project Dependency Graph"),""),n.length>0){a.push(` ${ye(Be(`Applications (${n.length})`))}`,"");for(const g of n)Ua(g,r,new Set,a,e," "),a.push("")}if(o.length>0){a.push(` ${ye(Be(`Libraries (${o.length})`))}`,"");for(const g of o)Ua(g,r,new Set,a,e," "),a.push("")}const c=process.stdout.columns||80;a.push(re("─".repeat(Math.min(c,60)))),a.push(`${ye(String(i))} packages ${re("·")} ${ye(String(s))} dependencies ${re("·")} ${ye(String(n.length))} apps${re(",")} ${ye(String(o.length))} libraries`);const d=new Set;let p=!1;for(const g of[...n,...o]){const m=r.get(g)?.deps??[];for(const y of m)d.has(y.target)&&(p=!0),d.add(y.target);d.add(g)}return p&&a.push(re("(*) = already shown above")),a.join(`
|
|
369
|
+
`)},"projectGraphToAscii"),mS=Zr(t=>{const e=Object.values(t.nodes).map(r=>({name:r.name,type:r.type}));return{edges:Object.values(t.dependencies).flat(),nodes:e}},"projectGraphToJson");var Ga;const yS=Zr(t=>{const e=Object.values(t.nodes).map(s=>({name:s.name,type:s.type})),r=[];for(const s of Object.values(t.dependencies))for(const a of s)r.push({source:a.source,target:a.target,type:a.type});const n=e.filter(s=>s.type==="application"),o=e.filter(s=>s.type!=="application"),i={apps:n.length,edges:r,libs:o.length,nodes:e};return String.raw(Ga||(Ga=hS([`<!DOCTYPE html>
|
|
320
370
|
<html lang="en">
|
|
321
371
|
<head>
|
|
322
372
|
<meta charset="UTF-8">
|
|
@@ -445,8 +495,12 @@ edges.forEach(e => {
|
|
|
445
495
|
const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
|
|
446
496
|
line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
|
|
447
497
|
line.setAttribute('stroke-width', '1.5');
|
|
448
|
-
if (e.type === 'implicit' || e.type === 'peerDependency')
|
|
449
|
-
|
|
498
|
+
if (e.type === 'implicit' || e.type === 'peerDependency') {
|
|
499
|
+
line.setAttribute('stroke-dasharray', '6,4');
|
|
500
|
+
}
|
|
501
|
+
if (e.type === 'devDependency') {
|
|
502
|
+
line.setAttribute('stroke-dasharray', '3,3');
|
|
503
|
+
}
|
|
450
504
|
svg.appendChild(line);
|
|
451
505
|
});
|
|
452
506
|
|
|
@@ -654,8 +708,12 @@ edges.forEach(e => {
|
|
|
654
708
|
const edgeColors = { implicit: '#475569', devDependency: '#888888', peerDependency: '#CC8800' };
|
|
655
709
|
line.setAttribute('stroke', edgeColors[e.type] || '#64748b');
|
|
656
710
|
line.setAttribute('stroke-width', '1.5');
|
|
657
|
-
if (e.type === 'implicit' || e.type === 'peerDependency')
|
|
658
|
-
|
|
711
|
+
if (e.type === 'implicit' || e.type === 'peerDependency') {
|
|
712
|
+
line.setAttribute('stroke-dasharray', '6,4');
|
|
713
|
+
}
|
|
714
|
+
if (e.type === 'devDependency') {
|
|
715
|
+
line.setAttribute('stroke-dasharray', '3,3');
|
|
716
|
+
}
|
|
659
717
|
svg.appendChild(line);
|
|
660
718
|
});
|
|
661
719
|
|
|
@@ -734,7 +792,7 @@ nodes.forEach(n => {
|
|
|
734
792
|
});
|
|
735
793
|
<\/script>
|
|
736
794
|
</body>
|
|
737
|
-
</html>`])),
|
|
795
|
+
</html>`])),i.apps,i.libs,i.edges.length,JSON.stringify(i).replaceAll("</",String.raw`<\/`))},"projectGraphToHtml"),vS={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"]],execute:Zr(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=n,{packageJsons:i,workspace:s}=ut(o,r),a=qt(o,s,i),c=!!process.stdout.isTTY&&!lt,d=e.format??(c?"tui":"ascii"),p=e.output,g=e.depth??1/0;let m;switch(d){case"dot":{m=zu(a);break}case"html":{m=yS(a);break}case"json":{m=JSON.stringify(mS(a),void 0,2);break}case"tui":{if(!c){m=_a(a,g);break}const y=r?.tui?.autoExit===!0?3:typeof r?.tui?.autoExit=="number"?r.tui.autoExit:0;process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const v=setInterval(()=>{},1e3),k=new rS(a);await Ut(X.createElement(gS,{autoExitSeconds:y,store:k}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(v);return}default:m=_a(a,g)}p?(Se(p,m,"utf8"),t.info(`Graph written to ${p}`)):t.info(m)},"execute"),group:"Workspace",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}]},Od=["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"],yo=".vis-hooks";var wS=Object.defineProperty,vo=b((t,e)=>wS(t,"name",{value:e,configurable:!0}),"o$a");const kS=/\/$/,bS=vo(t=>{let e='"$0"';for(let r=0;r<t;r+=1)e=`"$(dirname ${e})"`;return e},"nestedDirname"),$S=vo(t=>{const e=t.split("/").filter(r=>r!==""&&r!==".").length+2;return`#!/usr/bin/env sh
|
|
738
796
|
{ [ "$VIS_GIT_HOOKS" = "2" ]; } && set -x
|
|
739
797
|
n=$(basename "$0")
|
|
740
798
|
s=$(dirname "$(dirname "$0")")/$n
|
|
@@ -743,26 +801,36 @@ s=$(dirname "$(dirname "$0")")/$n
|
|
|
743
801
|
|
|
744
802
|
{ [ "\${VIS_GIT_HOOKS-}" = "0" ]; } && exit 0
|
|
745
803
|
|
|
746
|
-
d=${
|
|
804
|
+
d=${bS(e)}
|
|
747
805
|
export PATH="$d/node_modules/.bin:$PATH"
|
|
748
806
|
sh -e "$s" "$@"
|
|
749
807
|
c=$?
|
|
750
808
|
|
|
751
809
|
[ $c != 0 ] && echo "vis - $n script failed (code $c)"
|
|
752
810
|
[ $c = 127 ] && echo "vis - command not found in PATH=$PATH"
|
|
753
|
-
exit $c`},"hookScript"),
|
|
754
|
-
. "$(dirname "$0")/h"`,{mode:493});return{isError:!1,message:""}},"installHooks");var
|
|
755
|
-
`,"utf8"),{modified:
|
|
756
|
-
`,{mode:493}),e.info("Git hooks installed successfully.")},"executeInstall"),
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
811
|
+
exit $c`},"hookScript"),Pd=vo((t=yo)=>{if(process.env.VIS_GIT_HOOKS==="0")return{isError:!1,message:"skip install (git hooks disabled via VIS_GIT_HOOKS=0)"};if(t.includes(".."))return{isError:!0,message:'".." is not allowed in hooks directory path'};const e=ct("git",["rev-parse","--show-prefix"]);if(e.status===void 0||e.status===null)return{isError:!0,message:"git command not found"};if(e.status!==0)return{isError:!1,message:".git directory not found (not a git repository)"};const r=vo((d="")=>w(t,"_",d),"internal"),n=e.stdout.toString().trim().replace(kS,""),o=n?`${n}/${t}/_`:`${t}/_`,i=ct("git",["config","--local","core.hooksPath"]),s=i.status===0?i.stdout?.toString().trim():"";if(s&&s!==o)return{isError:!1,message:`core.hooksPath is already set to "${s}", skipping`};const{status:a,stderr:c}=ct("git",["config","core.hooksPath",o]);if(a==null)return{isError:!0,message:"git command not found"};if(a)return{isError:!0,message:String(c)};je(r()),Se(r(".gitignore"),"*"),Se(r("h"),$S(t),{mode:493});for(const d of Od)Se(r(d),`#!/usr/bin/env sh
|
|
812
|
+
. "$(dirname "$0")/h"`,{mode:493});return{isError:!1,message:""}},"installHooks");var SS=Object.defineProperty,xS=b((t,e)=>SS(t,"name",{value:e,configurable:!0}),"t$c");const Nd=[".lintstagedrc.json",".lintstagedrc"],Md=[".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"],ms=[...Nd,...Md],CS=[/^((?:[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/],Dd=[".nano-staged.json",".nanostagedrc"],Bd=[".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"],ys=[...Dd,...Bd],jS=[/^((?:[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/],TS=["husky","lint-staged","nano-staged"],ES=/\(is-ci \|\| husky \|\| exit 0\)\s*&&\s*/g,RS=/\bhusky(?:\s+install)?\s*&&\s*/g,IS=/\s*&&\s*husky(?:\s+install)?/g,AS=/\s*\|\|\s*husky(?:\s+install)?/g,OS=[ES,RS,IS,AS],Fd=xS(t=>{if(t==="husky"||t==="husky install")return;let e=t;for(const r of OS)e=e.replace(r,"");return e=e.trim(),e===t?t:e||void 0},"cleanHuskyFromScript");var PS=Object.defineProperty,cr=b((t,e)=>PS(t,"name",{value:e,configurable:!0}),"a$9");const NS=[".husky",".config/husky"],MS=/^\. "\$\(dirname "\$0"\)\/common\.sh"\s*/m,Ld=cr(t=>{for(const e of NS)if(T(w(t,e))&&br(w(t,e)).isDirectory())return e},"detectHuskyDirectory"),DS=cr((t,e)=>{const r=new Map,n=w(t,e),o=new Set(Od);for(const i of Ge(n)){if(i==="_"||i===".gitignore"||i.startsWith("."))continue;const s=w(n,i);br(s).isFile()&&(!o.has(i)&&i!=="common.sh"||r.set(i,ee(s)))}return r},"readHuskyHooks"),BS=cr(t=>t.replace(MS,""),"transformHookScript"),Vd=cr(t=>T(w(t,"pnpm-lock.yaml"))||T(w(t,"pnpm-workspace.yaml"))?"pnpm":T(w(t,"yarn.lock"))?"yarn":T(w(t,"bun.lockb"))||T(w(t,"bun.lock"))?"bun":"npm","detectPackageManager"),FS=cr((t,e)=>{const r=Vd(t),n={bun:["bun","remove","husky"],npm:["npm","uninstall","husky"],pnpm:["pnpm","remove","husky"],yarn:["yarn","remove","husky"]},[o,...i]=n[r];e.info(`Removing husky package via ${r}...`);const s=ct(o,i,{cwd:t,encoding:"utf8",stdio:"pipe"});return s.status!==0?(e.info(`Warning: failed to remove husky via ${r} (${s.stderr?.trim()??"unknown error"})`),!1):!0},"uninstallHuskyPackage"),LS=cr((t,e,r)=>{const n=Fd(r);if(n!==r)return n?(t[e]=n,`updated "${e}" script`):(delete t[e],`removed "${e}" script (was: "${r}")`)},"processScript"),VS=cr(t=>{const e=w(t,"package.json");if(!T(e))return{modified:!1,removedScriptReferences:[]};const r=ee(e),n=JSON.parse(r),o=[],i=n.scripts;if(i)for(const[s,a]of Object.entries(i)){if(typeof a!="string")continue;const c=LS(i,s,a);c&&o.push(c)}return o.length>0&&Se(e,`${JSON.stringify(n,void 0,4)}
|
|
813
|
+
`,"utf8"),{modified:o.length>0,removedScriptReferences:o}},"cleanPackageJsonScripts"),Ud=cr((t,e,r)=>{const n=Ld(t);if(!n)return{isError:!0,message:"No husky installation found (.husky/ or .config/husky/)"};r.info(`Found husky at ${n}/`);const o=DS(t,n);o.size===0&&r.info("No user-defined hooks found in husky directory.");const i=ct("git",["config","--local","core.hooksPath"]),s=i.status===0?i.stdout?.toString().trim():"";s&&(s===".husky/_"||s.startsWith(".husky"))&&ct("git",["config","--local","--unset","core.hooksPath"]);const a=Pd(e);if(a.isError)return a;a.message&&r.info(a.message);const c=w(t,e);je(c);let d=0;for(const[m,y]of o){if(m==="common.sh"){Se(w(c,m),y,{mode:493}),r.info(" Copied common.sh");continue}const v=BS(y);Se(w(c,m),v,{mode:493}),d+=1,r.info(` Migrated ${m}`)}FS(t,r);const p=VS(t);if(p.modified){r.info("Updated package.json scripts:");for(const m of p.removedScriptReferences)r.info(` ${m}`)}const g=w(t,n);return ot(g,{force:!0,recursive:!0}),r.info(`Removed ${n}/`),{isError:!1,message:`Migration complete: ${d} hook${d===1?"":"s"} migrated from ${n}/ to ${e}/`}},"migrateFromHusky");var US=Object.defineProperty,_S=b((t,e)=>US(t,"name",{value:e,configurable:!0}),"e$2");const GS=_S((t=yo)=>{if(ct("git",["config","--local","core.hooksPath"]).status!==0)return{isError:!1,message:"No custom hooks path configured"};const{status:e,stderr:r}=ct("git",["config","--local","--unset","core.hooksPath"]);if(e==null)return{isError:!0,message:"git command not found"};if(e&&e!==5)return{isError:!0,message:String(r)};const n=w(t,"_");return T(n)&&ot(n,{force:!0,recursive:!0}),{isError:!1,message:""}},"uninstallHooks");var WS=Object.defineProperty,en=b((t,e)=>WS(t,"name",{value:e,configurable:!0}),"n$6");const zS=en(t=>new Promise(e=>{const r=dt({input:process.stdin,output:process.stdout});r.question(`${t} (y/N) `,n=>{r.close();const o=n.trim().toLowerCase();e(o==="y"||o==="yes")})}),"confirmPrompt"),HS=en(async(t,e)=>{const r=Fi(),n=Ld(r);if(n){if(e.info(`Existing husky installation found at ${n}/`),await zS("Would you like to migrate your husky hooks to vis?")){const i=Ud(r,t,e);if(i.isError)throw new Error(i.message);i.message&&e.info(i.message);return}e.info("Aborting install. Remove husky first or run 'vis hook migrate' to migrate.");return}e.info(`Installing git hooks in ${t}/...`);const o=Pd(t);if(o.message){if(o.isError)throw new Error(o.message);e.info(o.message);return}T(w(r,t,"pre-commit"))||Se(w(r,t,"pre-commit"),`#!/usr/bin/env sh
|
|
814
|
+
`,{mode:493}),e.info("Git hooks installed successfully.")},"executeInstall"),qS=en((t,e)=>{const r=Fi(),n=Ud(r,t,e);if(n.isError)throw new Error(n.message);n.message&&e.info(n.message)},"executeMigrate"),$i="# vis:secrets-hook",JS=`#!/usr/bin/env sh
|
|
815
|
+
${$i}
|
|
816
|
+
# Scan staged files for secrets before each commit. Remove this block or the whole file to disable.
|
|
817
|
+
pnpm exec vis secrets --staged --quiet || exit 1
|
|
818
|
+
`,YS=en((t,e,r)=>{if(t!=="secrets")throw new Error(`Unknown hook add target "${String(t)}". Currently supported: "secrets".`);const n=Fi(),o=w(n,e,"pre-commit");if(!T(w(n,e)))throw new Error(`Hooks directory ${e}/ does not exist. Run \`vis hook install\` first.`);if(T(o)){const i=ee(o);if(i.includes($i)){r.info(`Secrets hook already present in ${o}.`);return}if(/\bvis secrets\b/.test(i)){r.warn(`Found a \`vis secrets\` invocation in ${o} without the managed marker — leaving it untouched.`);return}const s=`${i.trimEnd()}
|
|
819
|
+
|
|
820
|
+
${$i}
|
|
821
|
+
pnpm exec vis secrets --staged --quiet || exit 1
|
|
822
|
+
`;Se(o,s),Nc(o,493),r.info(`Appended secrets scan to ${o}.`);return}Se(o,JS,{mode:493}),r.info(`Created ${o} with a secrets-scan pre-commit check.`)},"executeAdd"),KS=en((t,e)=>{e.info("Removing git hooks...");const r=GS(t);if(r.message){if(r.isError)throw new Error(r.message);e.info(r.message);return}e.info("Git hooks removed successfully.")},"executeUninstall"),XS={argument:{description:"Action to perform: install, uninstall, migrate, or add <target>",name:"action",type:String},description:"Manage git hooks for the workspace",env:[{defaultValue:void 0,description:"Set to 0 to disable git hooks, set to 2 for debug output",name:"VIS_GIT_HOOKS",type:String}],examples:[["vis hook install","Install git hooks in .vis-hooks/"],["vis hook uninstall","Remove git hooks and reset core.hooksPath"],["vis hook migrate","Migrate from husky to vis hooks"],["vis hook add secrets","Add a pre-commit hook that runs `vis secrets --staged`"],["vis hook install --hooks-dir=.githooks","Install hooks in a custom directory"]],execute:en(async({argument:t,logger:e,options:r})=>{const n=t[0]??"install",o=r.hooksDir??yo;switch(n){case"add":{YS(t[1],o,e);break}case"install":{await HS(o,e);break}case"migrate":{qS(o,e);break}case"uninstall":{KS(o,e);break}default:throw new Error(`Unknown action "${n}". Use "install", "uninstall", "migrate", or "add <target>".`)}},"execute"),group:"Scaffold & Config",name:"hook",options:[{defaultValue:yo,description:"Custom hooks directory",name:"hooks-dir",type:String}]};var QS=Object.defineProperty,St=b((t,e)=>QS(t,"name",{value:e,configurable:!0}),"t$b");const _d=Cp(yp),ZS=["[skip ci]","[ci skip]","[no ci]","[vis skip]","[nx skip]"],e0=["[vis deploy]","[nx deploy]"],t0=["vis","nx"],r0=["CACHED_COMMIT_REF","VERCEL_GIT_PREVIOUS_SHA","GITHUB_BASE_REF","CI_COMMIT_BEFORE_SHA"],n0=/^[\w./~^@{}][\w.\-/~^@{}]*$/,o0=St((t=process.env)=>{for(const e of r0){const r=t[e];if(r&&r.trim().length>0)return r.trim()}},"resolveCiBaseSha"),Wa=St(t=>{if(!n0.test(t))throw new Error(`Invalid git ref: "${t}". Refs must start with an alphanumeric character or one of _ . / ~ ^ @ { } and may only contain letters, digits, dots, dashes, underscores, slashes, tildes, carets, @, and braces.`)},"validateGitRef"),i0=St(async(t,e)=>{try{return await _d("git",["rev-parse","--verify",`${e}^{commit}`],{cwd:t}),!0}catch{return!1}},"isRefReachable"),s0=St(async t=>{try{const{stdout:e}=await _d("git",["log","-1","--pretty=%B"],{cwd:t});return e}catch{return""}},"readLastCommitMessage"),Gd=St((t,e,r)=>t0.some(n=>t.includes(`[${n} ${e} ${r}]`)),"matchesPerProjectToken"),a0=St((t,e)=>ZS.some(r=>t.includes(r))||Gd(t,"skip",e),"commitHasSkipMessage"),c0=St((t,e)=>e0.some(r=>t.includes(r))||Gd(t,"deploy",e),"commitHasForceDeployMessage"),hr=St((t,e,r,n)=>({action:"build",message:r,project:t,reason:e,...n}),"decideBuild"),li=St((t,e,r,n)=>({action:"skip",message:r,project:t,reason:e,...n}),"decideSkip"),l0=St(t=>`${t.action==="skip"?"🛑":"✅"} ${t.message}`,"formatDecisionLine"),d0=St((t,e)=>t.action==="skip"||e?0:1,"exitCodeFor");var u0=Object.defineProperty,di=b((t,e)=>u0(t,"name",{value:e,configurable:!0}),"u$b");const za=new Set(["deep","direct","none"]),p0={argument:{description:"Project name to check (required)",name:"project",type:String},description:'Exit with inverted codes for CI "Ignored Build Step" gating (Vercel/Netlify)',examples:[["vis ignore my-app","Check if my-app is affected and decide whether to build"],["vis ignore my-app --base $VERCEL_GIT_PREVIOUS_SHA","Explicit base ref"],["vis ignore my-app --json","Emit the decision as JSON instead of text"],["vis ignore my-app --verbose","Print debug info about the decision path"],["vis ignore my-app --exit-zero-on-build","Normal exit semantics (0=build, 0=skip)"]],execute:di(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{const i=t[0]??"",s=!!r.json,a=!!r.verbose,c=!!r["exit-zero-on-build"],d=di(k=>{a&&!s&&e.info(`❱ ${k}`)},"debug"),p=di(k=>{s?process.stdout.write(`${JSON.stringify(k)}
|
|
823
|
+
`):e.info(l0(k)),process.exit(d0(k,c))},"emit");if(!i)return p(hr("","missing-project-argument","Missing project argument. Usage: vis ignore <project>"));if(!o)return p(hr(i,"workspace-error","Could not determine workspace root — building defensively"));const g=await s0(o),m=g.trim().split(`
|
|
824
|
+
`)[0]??"";if(d(`commit: ${m}`),g&&c0(g,i))return p(hr(i,"commit-force-deploy",`Force-deploy keyword in commit: "${m}"`));if(g&&a0(g,i))return p(li(i,"commit-skip",`Skip keyword in commit: "${m}"`));let y,v;try{({packageJsons:v,workspace:y}=ut(o,n))}catch(k){const $=k instanceof Error?k.message:String(k);return p(hr(i,"workspace-error",`Workspace discovery failed (${$}) — building defensively`))}if(!Object.hasOwn(y.projects,i))return p(hr(i,"project-unknown",`Project "${i}" not found in workspace — building defensively`));try{const k=r.base?.trim(),$=o0();let x=k||$||"HEAD~1";const E=r.head?.trim()||"HEAD";Wa(x),Wa(E),d(`resolved base ref: ${x} (source: ${k?"flag":$?"ci-env":"default"})`);const A=i0(o,x),L=qt(o,y,v);await A||(d(`base ref ${x} not reachable — falling back to HEAD~1`),x="HEAD~1"),d(`comparing ${x}...${E}`);const I=r.downstream??"deep",M=r.upstream??"none";if(!za.has(I))throw new Error(`Invalid --downstream value: "${I}". Must be "none", "direct", or "deep".`);if(!za.has(M))throw new Error(`Invalid --upstream value: "${M}". Must be "none", "direct", or "deep".`);const F={base:x,downstream:I,head:E,projectGraph:L,projects:y.projects,upstream:M,workspaceRoot:o},_=await jc(F);d(`changed files: ${_.changedFiles.length}`),d(`affected projects: ${_.affectedProjects.join(", ")||"(none)"}`);const N={base:x,head:E};return _.changedFiles.length===0?p(li(i,"no-changes",`No files changed between ${x}...${E}`,{...N,affectedProjects:[]})):_.affectedProjects.includes(i)?p(hr(i,"project-affected",`Build ${i}: affected by ${_.changedFiles.length} changed file(s)`,{...N,affectedProjects:_.affectedProjects})):p(li(i,"project-not-affected",`Skip ${i}: not affected by changes between ${x}...${E}`,{...N,affectedProjects:_.affectedProjects}))}catch(k){const $=k instanceof Error?k.message:String(k);return e.error(`Affected detection failed: ${$}`),p(hr(i,"workspace-error",`Affected detection failed (${$}) — building defensively`))}},"execute"),group:"Run & Execute",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}]};var f0=Object.defineProperty,Wd=b((t,e)=>f0(t,"name",{value:e,configurable:!0}),"f$b");const cn=w(Xe(),".vis"),zd=[w(Xe(),".zshrc"),w(Xe(),".zshenv"),w(Xe(),".bashrc"),w(Xe(),".bash_profile"),w(Xe(),".profile"),w(Xe(),".config","fish","config.fish")],g0=Wd(t=>{const e=[];for(const r of zd)if(T(r))try{const n=ee(r).split(`
|
|
825
|
+
`),o=n.filter(i=>!i.includes(".vis/bin")&&!i.includes("VIS_HOME")&&!i.includes("# vis "));o.length!==n.length&&(Q(r,o.join(`
|
|
826
|
+
`)),e.push(r))}catch{t.warn(`warning: could not clean ${r}`)}return e},"cleanShellProfiles"),h0={description:"Remove vis from the system (self-uninstall)",examples:[["vis implode","Interactive uninstall"],["vis implode --yes","Non-interactive uninstall (CI)"]],execute:Wd(async({logger:t,options:e})=>{if(!T(cn)){t.info("vis is not installed (no ~/.vis directory found).");return}t.info("This will remove:"),t.info(` ${cn}/`);const r=zd.filter(o=>T(o)&&ee(o).includes(".vis"));for(const o of r)t.info(` Lines in ${o}`);if(!e.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const o=dt({input:process.stdin,output:process.stdout}),i=await new Promise(s=>{o.question(`
|
|
827
|
+
Type "uninstall" to confirm: `,s)});if(o.close(),i.trim()!=="uninstall"){t.info("Aborted.");return}}const n=g0(t);for(const o of n)t.info(`Cleaned ${o}`);try{ot(cn,{force:!0,recursive:!0}),t.info(`
|
|
828
|
+
✓ Removed ${cn}`)}catch(o){throw new Error(`Failed to remove ${cn}: ${o instanceof Error?o.message:String(o)}`)}t.info("✓ vis has been uninstalled.")},"execute"),group:"System",name:"implode",options:[{alias:"y",defaultValue:!1,description:"Skip confirmation prompt",name:"yes",type:Boolean}]};var m0=Object.defineProperty,y0=b((t,e)=>m0(t,"name",{value:e,configurable:!0}),"n$5");const v0={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"]],execute:y0(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{if(!t||t.length===0)throw new Error("No package specified. Usage: vis info <package> [field...]");const[o,...i]=t,s=n??process.cwd(),a=Ne(s),c=th(a,{fields:i,json:r.json||!1,package:o},s,e);c!==0&&c!==1&&(process.exitCode=c)},"execute"),group:"Dependencies",name:"info",options:[{defaultValue:!1,description:"Output as JSON",name:"json",type:Boolean}]};var w0=Object.defineProperty,Or=b((t,e)=>w0(t,"name",{value:e,configurable:!0}),"l$c");const k0=Or(t=>{const e=[];return T(w(t,"turbo.json"))&&e.push("turborepo"),T(w(t,"nx.json"))&&e.push("nx"),T(w(t,".moon"))&&e.push("moon"),e},"detectExistingTools"),b0=Or((t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),"ask"),Pr=Or(async(t,e,r=!0)=>{const n=await b0(t,`${e} ${r?"[Y/n]":"[y/N]"} `);return n===""?r:n.toLowerCase()==="y"||n.toLowerCase()==="yes"},"confirm"),Si=Or((t,e)=>{const r=[],n=Object.entries(e.allowBuilds).filter(([,i])=>i).map(([i])=>` "${i}": true,`).join(`
|
|
829
|
+
`);let o=` allowBuilds: ${n?`{
|
|
762
830
|
${n}
|
|
763
|
-
}`:"{}"},`;return e.enableSocket&&(
|
|
831
|
+
}`:"{}"},`;return e.enableSocket&&(o+=`
|
|
764
832
|
socket: { enabled: true },`),r.push(` security: {
|
|
765
|
-
${
|
|
833
|
+
${o}
|
|
766
834
|
},`),e.staged&&r.push(` staged: {
|
|
767
835
|
"*.{ts,tsx}": "eslint --fix",
|
|
768
836
|
"*.{ts,tsx,js,jsx,json,md}": "prettier --write",
|
|
@@ -773,89 +841,152 @@ ${r.join(`
|
|
|
773
841
|
|
|
774
842
|
`)}
|
|
775
843
|
});
|
|
776
|
-
`},"generateConfigContent")
|
|
844
|
+
`},"generateConfigContent"),$0=Or(async(t,e,r)=>{const n=dt({input:process.stdin,output:process.stdout});S(`
|
|
777
845
|
vis init — interactive setup
|
|
778
|
-
`);const
|
|
779
|
-
`);for(const
|
|
780
|
-
`,"utf8"),!0},"editJsonFile");var
|
|
781
|
-
`),{entries:
|
|
782
|
-
`),"utf8")},"updatePnpmWorkspaceCatalog"),
|
|
783
|
-
${
|
|
846
|
+
`);const o=await Pr(n," Enable Socket.dev security scanning?");o&&(Z(" Socket.dev enabled — scores, alerts, and supply chain data active."),process.env.VIS_SOCKET_TOKEN||ie(" Set VIS_SOCKET_TOKEN for a custom API token (optional).")),S("");const i=await Pr(n," Scan for packages with build scripts?"),s={};if(i){S(" Scanning node_modules...");const g=Jl(t,{});if(g.length>0){S(` Found ${String(g.length)} package${g.length===1?"":"s"} with build scripts:
|
|
847
|
+
`);for(const m of g){const y=await Pr(n,` Allow ${m}?`,!1),v=m.split(" (")[0]??m;s[v]=y,y&&Z(` ✓ ${v} approved`)}}else S(" No packages with build scripts found.")}S("");const a=await Pr(n," Set up pre-commit hooks (lint-staged)?",!1);let c=!1;(e.name==="pnpm"||e.name==="yarn"||e.name==="npm"||e.name==="bun")&&(S(""),c=await Pr(n,` Sync security settings to ${e.name} config?`));const d=k0(t);if(d.length>0&&(S(""),S(` Detected existing tools: ${d.join(", ")}`),await Pr(n,` Run \`vis migrate\` for ${d.join(", ")}?`,!1))){n.close();const g=e.name==="pnpm"?"pnpm exec":e.name==="yarn"?"yarn exec":e.name==="bun"?"bunx":"npx";for(const m of d){S(` Migrating from ${m}...`);try{Pn(`${g} vis migrate ${m}`,{cwd:t,stdio:"inherit"})}catch{se(` Migration from ${m} had issues — run \`vis migrate ${m}\` manually.`)}}if(T(r))Z(`Migrated config written to ${r}`);else{const m=Si(e.name,{allowBuilds:s,enableSocket:o,staged:a});Q(r,m),Z(`Created ${r}`)}ie(" Run 'vis doctor' to see your project's full health status.");return}n.close(),S("");const p=Si(e.name,{allowBuilds:s,enableSocket:o,staged:a});if(Q(r,p),Z(`Created ${r}`),c){const g=Object.fromEntries(Object.entries(s).filter(([,y])=>y)),m=cs(e.name,t,g);for(const y of m)Z(` ${y}`)}S(""),S(" Setup complete. Your config:"),S(` Security: ${o?"Socket.dev enabled":"defaults only"}`),S(` Build scripts: ${Object.values(s).filter(Boolean).length} approved`),S(` Git hooks: ${a?"lint-staged configured":"not configured"}`),S(` PM sync: ${c?"done":"skipped"}`),S(""),ie(" Run 'vis doctor' to see your project's full health status."),S("")},"runInteractiveInit"),S0=Or((t,e,r,n)=>{const o=Si(e.name,{allowBuilds:{},enableSocket:!1,staged:!1});if(Q(n,o),Z(`Created ${n}`),S(" Secure defaults applied automatically by defineConfig()."),r.syncNative){const i=cs(e.name,t,{});for(const s of i)Z(` ${s}`)}S(""),ie("Run 'vis doctor' for a full health check, or 'vis init' in a terminal for guided setup.")},"runStaticInit"),x0={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"]],execute:Or(async({options:t,workspaceRoot:e})=>{const r=e??process.cwd(),n=Ne(r),o=Yr(r);if(o&&!t.force){se(`Config already exists: ${o}`),ie("Use --force to overwrite, or edit the existing file.");return}const i=o??w(r,"vis.config.ts");process.stdin.isTTY&&t.interactive!==!1&&!t.noInteractive?await $0(r,n,i):S0(r,n,t,i)},"execute"),group:"Scaffold & Config",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}]};var C0=Object.defineProperty,j0=b((t,e)=>C0(t,"name",{value:e,configurable:!0}),"i$7");const T0={alias:"i",description:"Install dependencies using the detected package manager",examples:[["vis install","Install all dependencies"],["vis i --frozen-lockfile","Install with frozen lockfile (CI mode)"],["vis install --ci","Clean install: wipe node_modules + frozen lockfile (mirrors npm ci / pnpm ci)"],["vis install --prod","Install production dependencies only"],["vis install --filter app","Install for specific workspace package"],["vis install --ignore-scripts","Install without running lifecycle scripts"],["vis install --no-typosquat-check","Skip typosquat name check"]],execute:j0(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{const o=n??process.cwd();if(!e.noTyposquatCheck&&!await vl(o,r?.security?.typosquatAllowlist)){process.exitCode=1;return}const i=Ne(o),s=Dn(e.filter),a=e.ci||!1;if(a){S("Clean install: removing node_modules...");try{ot(w(o,"node_modules"),{force:!0,recursive:!0})}catch(d){er(`Failed to remove node_modules: ${d instanceof Error?d.message:String(d)}`),process.exitCode=1;return}}const c=Oo(i,{dev:e.dev||!1,filter:s,force:e.force||!1,frozenLockfile:a||e.frozenLockfile||!1,ignoreScripts:e.ignoreScripts||!1,lockfileOnly:e.lockfileOnly||!1,noOptional:e.noOptional||!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},o,t);c!==0&&(process.exitCode=c)},"execute"),group:"Dependencies",name:"install",options:[{alias:"P",defaultValue:!1,description:"Skip devDependencies",name:"prod",type:Boolean},{alias:"D",defaultValue:!1,description:"Install devDependencies only",name:"dev",type:Boolean},{defaultValue:!1,description:"Use frozen lockfile (CI mode, maps to npm ci)",name:"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:"Skip lifecycle scripts",name:"ignore-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},{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}]};var E0=Object.defineProperty,R0=b((t,e)=>E0(t,"name",{value:e,configurable:!0}),"o$8");const I0={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)"]],execute:R0(async({argument:t,logger:e,workspaceRoot:r})=>{const n=t?.[0]??null,o=r??process.cwd(),i=Ne(o),s=rh(i,n,o,e);s!==0&&(process.exitCode=s)},"execute"),group:"Dependencies",name:"link"};var A0=Object.defineProperty,Ha=b((t,e)=>A0(t,"name",{value:e,configurable:!0}),"m$9");const O0={description:"List all workspace projects with metadata",examples:[["vis list","Show all projects"],["vis list --json","Machine-readable output"],['vis list --query "tag=frontend"',"Filter by query"]],execute:Ha(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const{projectOptions:o,workspace:i}=ut(n,r);let s=Object.keys(i.projects).sort();if(e.query&&(s=xo(s,i,e.query)),s.length===0){t.info("No projects found.");return}if(e.json){const g=s.map(m=>{const y=i.projects[m],v=o.get(m)??{},k=Object.entries(y.targets??{}).map(([$])=>{const x=v[$];return{aliases:x?.aliases??[],command:x?.command,description:x?.description,name:$,type:x?.type}});return{language:y.language,layer:y.layer,name:m,root:y.root,stack:y.stack,tags:y.tags??[],targets:k,type:y.projectType??"library"}});t.info(JSON.stringify(g,null,2));return}const a=["Project","Type","Layer","Tags","Targets"],c=s.map(g=>{const m=i.projects[g],y=Object.keys(m.targets??{});return[g,m.projectType??"library",m.layer??"—",(m.tags??[]).join(", ")||"—",y.length>4?`${y.slice(0,4).join(", ")}… (${String(y.length)})`:y.join(", ")||"—"]}),d=a.map((g,m)=>{const y=c.reduce((v,k)=>Math.max(v,(k[m]??"").length),0);return Math.max(g.length,y)}),p=Ha((g,m)=>g.padEnd(m),"pad");t.info(a.map((g,m)=>p(g,d[m])).join(" ")),t.info(d.map(g=>"─".repeat(g)).join("──"));for(const g of c)t.info(g.map((m,y)=>p(m,d[y])).join(" "));t.info(""),t.info(`${String(s.length)} project(s)`)},"execute"),group:"Workspace",name:"list",options:[{defaultValue:!1,description:"Emit JSON instead of a table",name:"json",type:Boolean},{description:"Filter projects by query",name:"query",type:String}]};var P0=Object.defineProperty,N0=b((t,e)=>P0(t,"name",{value:e,configurable:!0}),"t$a");const Pe=N0((t,e)=>{if(!T(t))return;const r=`${t}.bak`;T(r)||(e?.backupsCreated.includes(r)??!1)||(cp(t,r),e&&e.backupsCreated.push(r))},"backupFile");var M0=Object.defineProperty,_o=b((t,e)=>M0(t,"name",{value:e,configurable:!0}),"e$1");const ft=_o(t=>{try{const e=ee(t);return JSON.parse(e)}catch{return}},"readJsonFile"),Go=_o(t=>{if(!T(t))return!1;try{return JSON.parse(ee(t)),!0}catch{return!1}},"isJsonFile"),D0=/\n([ \t]+)"/,vs=_o(t=>D0.exec(t)?.[1]?.length??4,"detectJsonIndent"),B0=_o((t,e,r)=>{if(!T(t))return!1;const n=ee(t);let o;try{o=JSON.parse(n)}catch{return!1}const i=e(o);if(i===void 0)return!1;const s=vs(n);return r&&Pe(t,r),Se(t,`${JSON.stringify(i,void 0,s)}
|
|
848
|
+
`,"utf8"),!0},"editJsonFile");var F0=Object.defineProperty,lr=b((t,e)=>F0(t,"name",{value:e,configurable:!0}),"f$8");const L0=/\blint-staged\b/g,V0=lr((t,e)=>{let r=!1;const n={...t};for(const[o,i]of Object.entries(n)){if(typeof i!="string")continue;let s=Fd(i);s&&(s=s.replaceAll(L0,"vis staged").trim()||void 0),s!==i&&(s?n[o]=s:delete n[o],r=!0,e.rewrittenScriptCount+=1)}return{modified:r,scripts:n}},"rewriteScripts"),Hd=lr((t,e,r,n)=>{const o=w(t,"package.json");T(o)&&B0(o,i=>{let s=!1;for(const c of TS){const d=i.dependencies,p=i.devDependencies;d?.[c]&&(delete d[c],s=!0,n.removedPackageCount+=1),p?.[c]&&(delete p[c],s=!0,n.removedPackageCount+=1)}if(Object.keys(r).length>0)switch(e){case"bun":{const c=i.workspaces,d=c&&!Array.isArray(c)?c:void 0,p={...d?.catalog??i.catalog};for(const[m,y]of Object.entries(r))p[m]=y;d?.catalog==null?i.catalog=p:d.catalog=p;const g=i.overrides??{};for(const m of Object.keys(r))g[m]="catalog:";i.overrides=g,s=!0;break}case"npm":{const c=i.overrides??{};i.overrides={...c,...r},s=!0;break}case"pnpm":{const c=i.pnpm??{},d=c.overrides??{};c.overrides={...d,...r},i.pnpm=c,s=!0;break}case"yarn":{const c=i.resolutions??{};i.resolutions={...c,...r},s=!0;break}}const a=i.scripts;if(a){const c=V0(a,n);c.modified&&(i.scripts=c.scripts,s=!0)}return s?i:void 0})},"rewritePackageJson"),U0=lr((t,e,r,n)=>{try{const{workspace:o}=ut(t);for(const i of Object.values(o.projects)){const s=w(t,i.root);Hd(s,e,r,n)}}catch{}},"migrateMonorepoPackages"),_0=lr(t=>t.startsWith("- ")||t!==""&&!t.includes(":")&&!t.startsWith("#"),"isCatalogSectionEnd"),G0=lr(t=>{let e=!1,r="";const n=new Set;for(const o of t){const i=o.trim();if(i==="catalog:"){e=!0;continue}if(!e)continue;if(_0(i))break;const s=i.includes(":")?i.split(":")[0]?.trim():void 0;s&&(n.add(s),r=r||o.slice(0,o.indexOf(i)))}return{entries:n,indent:r||" "}},"parseCatalogEntries"),W0=lr((t,e,r)=>{const n=[];let o=!1,i=!1;for(let s=0;s<t.length;s+=1){const a=t[s],c=a.trim();if(n.push(a),c==="catalog:"){i=!0;continue}if(i&&!o){const d=t[s+1]?.trim()??"";(!d.includes(":")||d.startsWith("- ")||!d||d==="catalog:")&&(n.push(...e),o=!0,i=!1)}}return o||(r.includes("catalog:")||n.push("catalog:"),n.push(...e)),n},"insertCatalogEntries"),z0=lr((t,e)=>{const r=w(t,"pnpm-workspace.yaml");if(!T(r)||Object.keys(e).length===0)return;const n=ee(r),o=n.split(`
|
|
849
|
+
`),{entries:i,indent:s}=G0(o),a=[];for(const[d,p]of Object.entries(e))i.has(d)||a.push(`${s}${d}: "${p}"`);if(a.length===0)return;const c=W0(o,a,n);Pe(r),Se(r,c.join(`
|
|
850
|
+
`),"utf8")},"updatePnpmWorkspaceCatalog"),H0=lr((t,e,r,n,o,i)=>{const s=r.overrides??{};if(n.dryRun){o.info("[dry-run] Would rewrite package.json files (remove husky/lint-staged, rewrite scripts)"),Object.keys(s).length>0&&o.info(`[dry-run] Would add overrides: ${JSON.stringify(s)}`);return}Hd(t,e,s,i),o.info("Rewritten root package.json"),U0(t,e,s,i),e==="pnpm"&&z0(t,s)},"migrateDeps");var q0=Object.defineProperty,Wo=b((t,e)=>q0(t,"name",{value:e,configurable:!0}),"t$9");const J0=Wo(()=>({backupsCreated:[],gitHooksConfigured:!1,inlinedLintStagedConfigCount:0,manualSteps:[],mergedStagedConfigCount:0,perMigration:{},removedConfigCount:0,removedPackageCount:0,rewrittenScriptCount:0,warnings:[]}),"createMigrationReport"),He=Wo((t,e)=>{!t||t.warnings.includes(e)||t.warnings.push(e)},"addMigrationWarning"),Ze=Wo((t,e)=>{!t||t.manualSteps.includes(e)||t.manualSteps.push(e)},"addManualStep"),Pt=Wo((t,e,r,n=1)=>{const o=t.perMigration[e]??{removedConfigCount:0,removedPackageCount:0,rewrittenScriptCount:0};o[r]+=n,t.perMigration[e]=o,t[r]+=n},"bumpPerMigration");var Y0=Object.defineProperty,Dt=b((t,e)=>Y0(t,"name",{value:e,configurable:!0}),"d$d");const K0=["gitleaks.toml",".gitleaks.toml"],X0=["gitleaks-report.json",".gitleaks-report.json","baseline.json"],ws=Dt(t=>K0.find(e=>T(w(t,e))),"detectGitleaksConfig"),qd=Dt(t=>{const e=w(t,".gitleaksignore");return T(e)?e:void 0},"detectGitleaksIgnore"),Jd=Dt(t=>{for(const e of X0){const r=w(t,e);if(T(r))try{const n=JSON.parse(ee(r));if(Array.isArray(n)&&n.length>0&&typeof n[0]=="object"&&n[0]!==null&&"RuleID"in n[0])return r}catch{}}},"detectGitleaksBaseline"),Q0=Dt(t=>t.map(e=>({description:e.Description??"",endColumn:e.EndColumn??0,endLine:e.EndLine??e.StartLine??0,entropy:e.Entropy??0,file:e.File??"",match:e.Match??"",ruleId:e.RuleID??"",secret:e.Secret??"",startColumn:e.StartColumn??0,startLine:e.StartLine??0,tags:e.Tags??[]})),"convertBaseline"),Z0=Dt((t,e,r,n)=>{const o=Jd(t);if(!o)return;const i=w(t,".secrets-baseline.json");if(T(i)&&o!==i){He(n,`.secrets-baseline.json already exists — leaving ${o} in place`);return}const s=ft(o);if(!Array.isArray(s)){He(n,`Could not parse ${o} as a gitleaks baseline`);return}const a=Q0(s);if(e){r.info(`[dry-run] Would convert ${o} -> ${i} (${String(a.length)} findings)`);return}Pe(o,n),Q(i,`${JSON.stringify(a,null,4)}
|
|
851
|
+
`),r.info(`Converted ${o} -> ${i} (${String(a.length)} findings)`),Pt(n,"gitleaks","rewrittenScriptCount")},"migrateBaseline"),ex=Dt((t,e,r,n)=>{const o=w(t,"package.json");if(!T(o))return;const i=ft(o);if(!i)return;const s=ws(t),a=s?`vis secrets --config ${s}`:"vis secrets";let c=!1;if(i.scripts){for(const[d,p]of Object.entries(i.scripts))if(typeof p=="string"&&/\bgitleaks\b/.test(p)){const g=p.replaceAll(/\bgitleaks(?:\s+(?:detect|protect))?\b[^\n&|;]*/g,a).trim();g!==p&&(i.scripts[d]=g,c=!0,r.info(` scripts.${d}: "${p}" -> "${g}"`),Pt(n,"gitleaks","rewrittenScriptCount"))}}if(i.devDependencies){const d=i.devDependencies;for(const p of["gitleaks","@gitleaks/cli"])p in d&&(delete d[p],c=!0,Pt(n,"gitleaks","removedPackageCount"),r.info(` removed devDependency: ${p}`))}if(c){if(e){r.info(`[dry-run] Would update ${o}`);return}Pe(o,n),Q(o,`${JSON.stringify(i,null,4)}
|
|
852
|
+
`)}},"rewriteScripts"),tx=Dt((t,e,r,n)=>{const o=[".husky/pre-commit",".vis-hooks/pre-commit",".git/hooks/pre-commit"],i=ws(t),s=i?`vis secrets --staged --config ${i}`:"vis secrets --staged";for(const a of o){const c=w(t,a);if(!T(c))continue;const d=ee(c);if(!/\bgitleaks\b/.test(d))continue;const p=d.replaceAll(/\bgitleaks(?:\s+(?:detect|protect))?\b[^\n&|;]*/g,s);if(e){r.info(`[dry-run] Would rewrite ${c}`);continue}Pe(c,n),Q(c,p),n.gitHooksConfigured=!0,r.info(`Rewrote gitleaks invocation in ${a}`)}},"rewriteHooks"),rx=/^([^:#][^:]*):([^:]+):(\d+)$/,nx=Dt(t=>{const e=rx.exec(t.trim());if(!e)return;const[,r,n,o]=e,i=Number.parseInt(o??"0",10);return{description:"",endColumn:0,endLine:i,entropy:0,file:r??"",match:"",ruleId:n??"",secret:"",startColumn:0,startLine:i,tags:[]}},"fingerprintToBaselineEntry"),ox=Dt((t,e,r,n)=>{const o=qd(t);if(!o)return;const i=ee(o).split(/\r?\n/).map(p=>p.trim()).filter(p=>p.length>0&&!p.startsWith("#")).map(p=>nx(p)).filter(p=>p!==void 0);i.length===0&&He(n,`${o} contained no recognisable fingerprint lines — deleting it.`);const s=w(t,".secrets-baseline.json"),a=T(s)?ft(s)??[]:[],c=new Set(a.map(p=>`${p.file}:${p.ruleId}:${String(p.startLine)}`)),d=[...a];for(const p of i){const g=`${p.file}:${p.ruleId}:${String(p.startLine)}`;c.has(g)||(c.add(g),d.push(p))}if(e){r.info(`[dry-run] Would merge ${String(i.length)} .gitleaksignore fingerprint(s) into ${s}, then delete ${o}.`);return}Pe(o,n),T(s)&&Pe(s,n),Q(s,`${JSON.stringify(d,null,4)}
|
|
853
|
+
`),Wr(o),r.info(`Merged ${String(i.length)} fingerprint(s) from ${o} into ${s}; removed .gitleaksignore.`),Pt(n,"gitleaks","rewrittenScriptCount",i.length)},"migrateIgnoreFile"),ix=Dt((t,e,r,n)=>{const o=ws(t),i=qd(t);return o??i??Jd(t)?(o&&(r.info(`Keeping ${o} as-is (compatible with vis secrets --config).`),Ze(n,`Run \`vis secrets --config ${o}\` or rename to .gitleaksignore-compatible defaults.`)),i&&ox(t,e.dryRun,r,n),Z0(t,e.dryRun,r,n),ex(t,e.dryRun,r,n),tx(t,e.dryRun,r,n),Ze(n,"Review CI workflows (.github/workflows/*.yml) for gitleaks-action calls — replace with `vis secrets`."),!0):(e.silent||r.info("No gitleaks artifacts found — nothing to migrate."),!1)},"migrateGitleaks");var sx=Object.defineProperty,Yt=b((t,e)=>sx(t,"name",{value:e,configurable:!0}),"g$8");const ax=["kingfisher-baseline.yaml",".kingfisher-baseline.yaml","kingfisher-baseline.yml",".kingfisher-baseline.yml"],cx=["kingfisher-rules.yml","kingfisher-rules.yaml",".kingfisher-rules.yml",".kingfisher-rules.yaml"],Yd=Yt(t=>ax.find(e=>T(w(t,e))),"detectKingfisherBaseline"),ks=Yt(t=>cx.find(e=>T(w(t,e))),"detectKingfisherRules"),lx=Yt(t=>{const e=[];let r={};for(const n of t.split(/\r?\n/)){const o=n.replace(/#.*$/,"");(/^\s*-\s*filepath\s*:/.test(o)||/^\s*-\s*$/.test(o))&&(r.filepath&&typeof r.linenum=="number"&&r.fingerprint&&e.push(r),r={});const i=/filepath\s*:\s*(.+?)\s*$/.exec(o);if(i?.[1]){r.filepath=i[1].replaceAll(/^["']|["']$/g,"");continue}const s=/fingerprint\s*:\s*(.+?)\s*$/.exec(o);if(s?.[1]){r.fingerprint=s[1].replaceAll(/^["']|["']$/g,"");continue}const a=/linenum\s*:\s*(\d+)/.exec(o);a?.[1]&&(r.linenum=Number.parseInt(a[1],10))}return r.filepath&&typeof r.linenum=="number"&&r.fingerprint&&e.push(r),e},"parseKingfisherBaseline"),dx=Yt(t=>({_kingfisherMigration:{legacyFingerprint:t.fingerprint,note:"Kingfisher xxhash — regenerate by running `vis secrets --update-baseline`."},description:"",endColumn:0,endLine:t.linenum,entropy:0,file:t.filepath,match:"",ruleId:"",secret:"",startColumn:0,startLine:t.linenum,tags:[]}),"toPlaceholderEntry"),ux=Yt((t,e,r,n)=>{const o=Yd(t);if(!o)return;const i=w(t,o);let s;try{s=lx(ee(i))}catch(d){const p=d instanceof Error?d.message:String(d);He(n,`Could not parse ${o} as a Kingfisher baseline: ${p}`);return}if(s.length===0){He(n,`${o} contained no recognisable records — leaving it in place for manual review.`);return}const a=w(t,".secrets-baseline.json");if(T(a)){He(n,`.secrets-baseline.json already exists — leaving Kingfisher baseline at ${o} for manual merge.`);return}const c=s.map(d=>dx(d));if(e){r.info(`[dry-run] Would convert ${o} -> .secrets-baseline.json (${String(c.length)} placeholder finding(s))`),Ze(n,"Run `vis secrets --update-baseline` after migration — Kingfisher xxhash fingerprints aren't interchangeable with our content-hash.");return}Pe(i,n),Q(a,`${JSON.stringify(c,null,4)}
|
|
854
|
+
`),r.info(`Converted ${o} -> .secrets-baseline.json (${String(c.length)} placeholder finding(s))`),Ze(n,"Run `vis secrets --update-baseline` — the converted entries are placeholders until the scanner computes real fingerprints."),Pt(n,"kingfisher","rewrittenScriptCount")},"migrateBaseline"),Kd=/\bkingfisher(?:\s+(?:scan|validate|rules|update|manage-baseline|report|github|gitlab|bitbucket))?\b[^\n&|;]*/g,px=Yt((t,e,r,n)=>{const o=w(t,"package.json");if(!T(o))return;const i=ft(o);if(!i)return;const s=ks(t),a=s?`vis secrets --config ${s}`:"vis secrets";let c=!1;if(i.scripts)for(const[d,p]of Object.entries(i.scripts)){if(typeof p!="string"||!/\bkingfisher\b/.test(p))continue;const g=p.replaceAll(Kd,m=>m.includes("validate")?`${a} --validate`:a).trim();g!==p&&(i.scripts[d]=g,c=!0,r.info(` scripts.${d}: "${p}" -> "${g}"`),Pt(n,"kingfisher","rewrittenScriptCount"))}if(i.devDependencies){const d=i.devDependencies;for(const p of["kingfisher","@mongodb/kingfisher","kingfisher-scanner"])p in d&&(delete d[p],c=!0,Pt(n,"kingfisher","removedPackageCount"),r.info(` removed devDependency: ${p}`))}if(c){if(e){r.info(`[dry-run] Would update ${o}`);return}Pe(o,n),Q(o,`${JSON.stringify(i,null,4)}
|
|
855
|
+
`)}},"rewriteScripts"),fx=Yt((t,e,r,n)=>{const o=ks(t),i=o?`vis secrets --staged --config ${o}`:"vis secrets --staged";for(const s of Xd){const a=w(t,s);if(!T(a))continue;const c=ee(a);if(!/\bkingfisher\b/.test(c))continue;const d=c.replaceAll(Kd,i);if(e){r.info(`[dry-run] Would rewrite ${a}`);continue}Pe(a,n),Q(a,d),n.gitHooksConfigured=!0,r.info(`Rewrote kingfisher invocation in ${s}`)}},"rewriteHooks"),Xd=[".husky/pre-commit",".vis-hooks/pre-commit",".git/hooks/pre-commit"],qa=Yt(t=>{if(!T(t))return!1;try{return/\bkingfisher\b/.test(ee(t))}catch{return!1}},"hasKingfisherRef"),gx=Yt((t,e,r,n)=>{const o=Yd(t),i=ks(t),s=qa(w(t,"package.json")),a=Xd.some(c=>qa(w(t,c)));return(o??i)||s||a?(i&&(r.info(`Found custom Kingfisher ruleset at ${i} — keeping it for now.`),Ze(n,`Convert ${i} to gitleaks-shaped JSON using \`packages/tooling/secret-scanner/scripts/kingfisher-converter.mjs\`, then point \`vis secrets --config\` at the result.`)),o&&ux(t,e.dryRun,r,n),px(t,e.dryRun,r,n),fx(t,e.dryRun,r,n),Ze(n,"Replace `# kingfisher:ignore` markers with `# secret-scanner:allow` (or keep `# gitleaks:allow` — the scanner accepts both)."),Ze(n,"Review CI workflows (.github/workflows/*.yml) for Kingfisher action/docker invocations — replace with `vis secrets`."),!0):(e.silent||r.info("No Kingfisher artifacts found — nothing to migrate."),!1)},"migrateKingfisher");var hx=Object.defineProperty,Je=b((t,e)=>hx(t,"name",{value:e,configurable:!0}),"r$8");const mx=/\bstaged\s*:/,Ja=/(defineConfig\(\{)/,Ya=/(export\s+default\s+\{)/;Je(t=>ms.some(e=>T(w(t,e))),"hasStandaloneLintStagedConfig");const yx=Je(t=>{for(const r of Md)if(T(w(t,r)))return!0;const e=w(t,".lintstagedrc");return T(e)&&!Go(e)},"hasUnsupportedLintStagedConfig"),vx=Je(t=>{const e=Yr(t);if(!e)return!1;const r=ee(e);return mx.test(r)},"hasStagedConfigInVisConfig"),wx=Je(t=>{const e=w(t,"package.json");if(T(e)&&ft(e)?.["lint-staged"])return"package.json";for(const r of ms)if(T(w(t,r)))return r},"detectLintStagedConfig"),kx=Je(t=>ft(w(t,"package.json"))?.["lint-staged"],"extractLintStagedFromPackageJson"),bx=Je(t=>ft(t),"parseLintStagedJsonFile"),xi=Je(t=>` staged: {
|
|
856
|
+
${Object.entries(t).map(([e,r])=>{const n=Array.isArray(r)?`[${r.map(o=>JSON.stringify(o)).join(", ")}]`:JSON.stringify(r);return` ${JSON.stringify(e)}: ${n}`}).join(`,
|
|
857
|
+
`)},
|
|
858
|
+
}`,"generateStagedConfigSnippet"),$x=Je((t,e,r)=>{const n=Yr(t);if(n){const s=ee(n),a=xi(e);let c;return Ja.test(s)?c=s.replace(Ja,`$1
|
|
859
|
+
${a},`):Ya.test(s)&&(c=s.replace(Ya,`$1
|
|
860
|
+
${a},`)),c?(Pe(n),Se(n,c,"utf8"),r.info(`Merged staged config into ${n}`),!0):(r.warn(`Could not auto-insert staged config into ${n} — please add manually`),!1)}const o=w(t,"vis.config.ts"),i=`import { defineConfig } from "@visulima/vis/config";
|
|
861
|
+
|
|
862
|
+
export default defineConfig({
|
|
863
|
+
${xi(e)},
|
|
864
|
+
});
|
|
865
|
+
`;return Se(o,i,"utf8"),r.info(`Created ${o} with staged config`),!0},"insertStagedIntoVisConfig"),Sx=Je(t=>{const e=w(t,"package.json"),r={configRemoved:!1,dependencyRemoved:!1};if(!T(e))return r;const n=ee(e),o=JSON.parse(n);let i=!1;o["lint-staged"]&&(delete o["lint-staged"],i=!0,r.configRemoved=!0);const s=o.devDependencies,a=o.dependencies;if(s?.["lint-staged"]&&(delete s["lint-staged"],i=!0,r.dependencyRemoved=!0),a?.["lint-staged"]&&(delete a["lint-staged"],i=!0,r.dependencyRemoved=!0),i){const c=vs(n);Pe(e),Se(e,`${JSON.stringify(o,void 0,c)}
|
|
866
|
+
`,"utf8")}return r},"removeLintStagedFromPackageJson"),xx=Je((t,e)=>{for(const r of ms){const n=w(t,r);T(n)&&(Pe(n,e),Wr(n),e.removedConfigCount+=1)}},"removeLintStagedConfigFiles"),Cx=Je((t,e)=>{const r=w(t,e,"pre-commit");if(!T(r))return!1;const n=ee(r);if(n.includes("vis staged"))return!1;const o=n.split(`
|
|
867
|
+
`);let i=!1;const s=[];for(const a of o){const c=a.trim();if(!i){let d=!1;for(const p of CS){const g=p.exec(c);if(g){const m=a.slice(0,a.length-a.trimStart().length),y=g[1]?.trim()??"",v=c.slice(g[0].length).trim(),k=[y,"vis staged",v].filter(Boolean);s.push(`${m}${k.join(" ")}`),i=!0,d=!0;break}}if(d)continue}s.push(a)}return i?(Pe(r),Se(r,s.join(`
|
|
868
|
+
`)),!0):!1},"rewritePreCommitHook"),jx=Je((t,e,r)=>{if(e==="package.json")return kx(t);const n=w(t,e);if(!Nd.includes(e)){He(r,`${e} cannot be auto-migrated — please add "staged" config to vis.config.ts manually`),Ze(r,`Manually convert ${e} to staged config in vis.config.ts`);return}if(e===".lintstagedrc"&&!Go(n)){He(r,".lintstagedrc is not JSON format — please migrate manually");return}return bx(n)},"extractConfig"),Qd=Je((t,e)=>{const{configRemoved:r,dependencyRemoved:n}=Sx(t);r&&(e.inlinedLintStagedConfigCount+=1),n&&(e.removedPackageCount+=1),xx(t,e)},"cleanupLintStagedArtifacts"),Tx=Je((t,e,r,n)=>{const o=[".vis-hooks",".husky"];for(const i of o)T(w(t,i))&&Cx(t,i)&&(n.gitHooksConfigured=!0,e.silent||r.info(`Rewrote pre-commit hook in ${i}/ to use "vis staged"`))},"rewriteHooks"),Ex=Je((t,e,r,n,o)=>{$x(t,e,n)&&(o.mergedStagedConfigCount+=1),Qd(t,o),Tx(t,r,n,o)},"applyMigration"),Rx=Je((t,e,r,n)=>{const o=wx(t);if(!o)return e.silent||r.info("No lint-staged configuration found — nothing to migrate."),!1;if(yx(t)&&(He(n,'Non-JSON lint-staged config found — please migrate to "staged" in vis.config.ts manually'),Ze(n,"Convert your lint-staged config file to JSON format or add staged config to vis.config.ts manually")),vx(t))return He(n,'vis.config.ts already has a "staged" config — skipping lint-staged merge'),e.silent||r.warn('vis.config.ts already has a "staged" config — skipping'),e.dryRun||Qd(t,n),!0;const i=jx(t,o,n);return!i||Object.keys(i).length===0?(e.silent||r.warn("lint-staged config is empty — skipping"),!1):e.dryRun?(e.silent||(r.info("[dry-run] Would insert staged config into vis.config.ts:"),r.info(xi(i))),!0):(Ex(t,i,e,r,n),!0)},"migrateLintStaged");var Ix=Object.defineProperty,bs=b((t,e)=>Ix(t,"name",{value:e,configurable:!0}),"t$8");const $s=bs(t=>JSON.stringify(t,null,4).replaceAll(/"(\w+)":/g,"$1:"),"serializeConfigObject"),Ss=bs((t,e,r,n,o)=>{const i=w(t,"vis.config.ts");return T(i)&&!r.dryRun?(n.warn("vis.config.ts already exists — refusing to overwrite. Remove it first or run with --dry-run."),o.warnings.push("vis.config.ts already exists; migration skipped writing the file."),!1):(r.dryRun?(n.info("── vis.config.ts (preview) ──"),n.info(e),n.info("── end preview ──")):(Q(i,e),n.info(`Wrote ${i}`)),!0)},"writeVisConfig"),Zd=bs((t,e)=>{const r=w(t,e);if(T(r))try{return JSON.parse(ee(r))}catch(n){throw new Error(`Failed to parse ${r}: ${n.message}`)}},"readJsonConfig");var Ax=Object.defineProperty,tn=b((t,e)=>Ax(t,"name",{value:e,configurable:!0}),"l$b");const Ox=tn(t=>{const e={};return t.command&&(e.command=Array.isArray(t.args)?`${t.command} ${t.args.join(" ")}`:t.args?`${t.command} ${t.args}`:t.command),t.deps&&t.deps.length>0&&(e.dependsOn=t.deps),t.inputs&&t.inputs.length>0&&(e.inputs=t.inputs),t.outputs&&t.outputs.length>0&&(e.outputs=t.outputs),t.type&&(e.type=t.type),t.preset&&(e.preset=t.preset),t.options&&(e.options=t.options),e},"taskToVisTarget"),Px=tn(t=>{const e={};t.fileGroups&&(e.fileGroups=t.fileGroups);const r={};for(const[n,o]of Object.entries(t.tasks??{}))r[n]=Ox(o);return Object.keys(r).length>0&&(e.targetDefaults=r),t.implicitInputs&&t.implicitInputs.length>0&&(e.namedInputs={default:t.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(${$s(e)});`,""].join(`
|
|
869
|
+
`)},"renderVisConfig"),Nx=tn(t=>{const e=w(t,".moon");if(!T(e))return;for(const n of["tasks.yml","tasks.yaml"]){const o=w(e,n);if(T(o))return o}const r=w(e,"tasks");if(T(r)){const n=Ge(r).filter(o=>o.endsWith(".yml")||o.endsWith(".yaml")).sort();if(n.length>0)return w(r,n[0])}},"findMoonTasksFile"),Mx=tn(t=>{const e=w(t,".moon","templates");if(!T(e))return[];const r=[];try{for(const n of Ge(e,{withFileTypes:!0}))n.isDirectory()&&T(w(e,n.name,"template.yml"))&&r.push(n.name)}catch{}return r.sort()},"findMoonTemplates"),Dx=tn((t,e,r,n,o)=>{const i=w(t,".moon","templates"),s=w(t,".vis","templates");r||lp(s,{recursive:!0});for(const a of e){const c=w(i,a),d=w(s,a);if(T(d)){o.warnings.push(`Template "${a}" already exists at .vis/templates/${a} — left untouched. Remove or rename either copy to resolve.`);continue}if(r){n.info(`Would copy .moon/templates/${a} → .vis/templates/${a}`);continue}try{Li(c,d,{recursive:!0}),n.info(`Copied .moon/templates/${a} → .vis/templates/${a}`)}catch(p){const g=p instanceof Error?p.message:String(p);o.warnings.push(`Failed to copy template "${a}": ${g}`)}}!r&&e.length>0&&o.manualSteps.push(`Copied ${String(e.length)} template${e.length===1?"":"s"} from .moon/templates/ to .vis/templates/. Remove the .moon/templates/ directory when ready.`)},"copyMoonTemplatesToVis"),Bx=tn((t,e,r,n)=>{const o=Nx(t);if(!o){r.warn("No .moon/tasks.yml (or .moon/tasks/<scope>.yml) found — nothing to migrate."),n.warnings.push("No moon tasks file at workspace root.");return}let i;try{i=Jr(o)}catch(d){throw new Error(`Failed to parse ${o}: ${d.message}`)}for(const[d,p]of Object.entries(i.tasks??{}))p.env&&Object.keys(p.env).length>0&&n.warnings.push(`Task "${d}" has an \`env\` block which vis does not support — set environment variables in the command or a wrapper script.`),p.platform&&n.warnings.push(`Task "${d}" has a \`platform\` field ("${p.platform}") which vis does not support — review and remove.`),p.toolchain&&n.warnings.push(`Task "${d}" has a \`toolchain\` field ("${p.toolchain}") which vis does not support — review and remove.`),Array.isArray(p.args)&&p.args.some(g=>g.includes(" "))&&n.warnings.push(`Task "${d}" has \`args\` entries containing spaces — vis flattens args into the command string so quoting may need manual adjustment.`);i.extends&&i.extends.length>0&&n.warnings.push("`extends` was found in the moon config but has no direct vis equivalent — inline the referenced files or use vis's `taskDefaults` blocks."),i.implicitDeps&&i.implicitDeps.length>0&&n.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&&n.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 s=Px(i);if(!Ss(t,s,e,r,n))return;n.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."),n.manualSteps.push("Scoped `.moon/tasks/<scope>.yml` files map to vis's `taskDefaults` with a `scope` block. Only the first scope file was parsed — review the generated file.");const a=Mx(t);if(a.length===0)return;const c=a.map(d=>`"${d}"`).join(", ");e.copyTemplates?Dx(t,a,!!e.dryRun,r,n):n.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/.`)},"migrateMoon");var Fx=Object.defineProperty,Ye=b((t,e)=>Fx(t,"name",{value:e,configurable:!0}),"r$7");const Lx=/\bstaged\s*:/,Ka=/(defineConfig\(\{)/,Xa=/(export\s+default\s+\{)/;Ye(t=>ys.some(e=>T(w(t,e))),"hasStandaloneNanoStagedConfig");const Vx=Ye(t=>{for(const r of Bd)if(T(w(t,r)))return!0;const e=w(t,".nanostagedrc");return T(e)&&!Go(e)},"hasUnsupportedNanoStagedConfig"),Ux=Ye(t=>{const e=Yr(t);return e?Lx.test(ee(e)):!1},"hasStagedConfigInVisConfig"),_x=Ye(t=>{const e=w(t,"package.json");if(T(e)&&ft(e)?.["nano-staged"])return"package.json";for(const r of ys)if(T(w(t,r)))return r},"detectNanoStagedConfig"),Gx=Ye(t=>ft(w(t,"package.json"))?.["nano-staged"],"extractNanoStagedFromPackageJson"),Wx=Ye(t=>ft(t),"parseNanoStagedJsonFile"),Ci=Ye(t=>` staged: {
|
|
870
|
+
${Object.entries(t).map(([e,r])=>{const n=Array.isArray(r)?`[${r.map(o=>JSON.stringify(o)).join(", ")}]`:JSON.stringify(r);return` ${JSON.stringify(e)}: ${n}`}).join(`,
|
|
784
871
|
`)},
|
|
785
|
-
}`,"generateStagedConfigSnippet"),
|
|
786
|
-
${
|
|
787
|
-
${
|
|
872
|
+
}`,"generateStagedConfigSnippet"),zx=Ye((t,e,r)=>{const n=Yr(t);if(n){const s=ee(n),a=Ci(e);let c;return Ka.test(s)?c=s.replace(Ka,`$1
|
|
873
|
+
${a},`):Xa.test(s)&&(c=s.replace(Xa,`$1
|
|
874
|
+
${a},`)),c?(Pe(n),Se(n,c,"utf8"),r.info(`Merged staged config into ${n}`),!0):(r.warn(`Could not auto-insert staged config into ${n} — please add manually`),!1)}const o=w(t,"vis.config.ts"),i=`import { defineConfig } from "@visulima/vis/config";
|
|
788
875
|
|
|
789
876
|
export default defineConfig({
|
|
790
|
-
${
|
|
877
|
+
${Ci(e)},
|
|
791
878
|
});
|
|
792
|
-
`;return
|
|
793
|
-
`,"utf8")}return r},"
|
|
794
|
-
`);let
|
|
795
|
-
`)),!0):!1},"rewritePreCommitHook"),
|
|
796
|
-
`),(o==="all"||o==="deps")&&(e.info("── Migrating dependencies and scripts ──"),gy(l,f,d,{dryRun:s},e,p),e.info("")),(o==="all"||o==="lint-staged")&&(e.info("── Migrating lint-staged ──"),Ry(l,{dryRun:s},e,p),e.info("")),Py(p,e)},"execute"),name:"migrate",options:[{defaultValue:!1,description:"Preview changes without applying",name:"dry-run",type:Boolean}]};var Dy=Object.defineProperty,My=$((t,e)=>Dy(t,"name",{value:e,configurable:!0}),"a$1");const By={group:"System",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"]],execute:My(async({argument:t,logger:e,workspaceRoot:r})=>{const n=t;if(!n||n.length===0)throw new Error("No subcommand specified. Available: cache, publish, audit, list, view, config, whoami, login, logout, pack, owner, dist-tag, search, fund, ping, token, deprecate, rebuild, prune");const[i,...o]=n,s=r??process.cwd(),l=me(s),d=Yc(l,i,o,s,e);d!==0&&(process.exitCode=d)},"execute"),name:"pm"};var Ly=Object.defineProperty,Fy=$((t,e)=>Ly(t,"name",{value:e,configurable:!0}),"t$5");const Vy={group:"Dependencies",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"]],execute:Fy(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const i=t;if(!i||i.length===0)throw new Error("No packages specified. Usage: vis remove <packages...>");const o=process.cwd(),s=me(n??o),l=zc(s,{filter:gr(r.filter),global:r.global||!1,packages:i,recursive:r.recursive||!1,saveDev:r.saveDev||!1,workspaceRoot:r.workspaceRoot||!1},o,e);l!==0&&(process.exitCode=l)},"execute"),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}]};var Uy=Object.defineProperty,yo=$((t,e)=>Uy(t,"name",{value:e,configurable:!0}),"i$1");const Gy=yo(t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),"formatValue"),zy=yo((t,e,r)=>e==="_"?`${t}${Array.isArray(r)?r.join(" "):String(r)}`:`${t}--${e}=${Gy(r)}`,"formatFlags"),vo=yo((t,e,r)=>{const n=new Set(new Set(r.map(m=>m.target.target))),i=new Set(new Set(r.map(m=>m.target.project))),o=e.filter(m=>n.has(m)),s=t.filter(m=>i.has(m)),l=r.length-s.length*o.length,d=o.length===1?"target":"targets",f=o.join(", ");let p;p=s.length===1?`project ${s[0]}`:`${s.length} projects`;let h=`${d} ${f} for ${p}`;return l>0&&(h+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),h},"formatTargetsAndProjects");var Wy=Object.defineProperty,_y=$((t,e)=>Wy(t,"name",{value:e,configurable:!0}),"e");const Hy=_y(()=>process.platform==="win32"?!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color":process.env.TERM!=="linux","isUnicodeSupported"),dn=Hy(),xa=dn?"✓":"√",wo=dn?"✖":"×",Sa=dn?"…":"...",un=dn?"—":"-";var Jy=Object.defineProperty,qy=$((t,e)=>Jy(t,"name",{value:e,configurable:!0}),"c$4");const Yy={error:"red",info:"white",success:"green"},In=qy(({children:t,title:e,variant:r})=>{const n=Yy[r];return u(g,{flexDirection:"column",children:[u(g,{gap:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),c(a,{bold:!0,color:n,children:"•"}),c(a,{children:e})]}),t]})},"Header");var Xy=Object.defineProperty,Ky=$((t,e)=>Xy(t,"name",{value:e,configurable:!0}),"s$5");const Ca=Ky(({cached:t,failed:e,failedIds:r,projectNames:n,skippedIds:i,succeeded:o,targets:s,tasks:l,took:d})=>{const f=vo(n,s,l);if(e===0&&(!i||i.length===0)){const p=t>0?` (${t} read from cache)`:"";return c(xo,{children:$(()=>c(In,{title:`Successfully ran ${f}`,variant:"success",children:u(g,{flexDirection:"column",paddingLeft:2,children:[u(a,{children:[c(a,{color:"green",children:xa})," ",o+t," ","tasks completed",p?c(a,{dimColor:!0,children:p}):null]}),u(a,{dimColor:!0,children:[" ","Took",d]})]})}),"children")})}return c(xo,{children:$(()=>c(In,{title:`Ran ${f}`,variant:"error",children:u(g,{flexDirection:"column",paddingLeft:2,children:[i&&i.length>0&&u(g,{flexDirection:"column",children:[u(a,{dimColor:!0,children:[i.length," ","task",i.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),i.map(p=>u(a,{dimColor:!0,children:[" - ",p]},p)),c(a,{})]}),e>0&&u(g,{flexDirection:"column",children:[u(a,{children:[c(a,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),r.map(p=>u(a,{children:[" ",c(a,{color:"red",children:wo})," ",p]},p)),c(a,{})]}),u(a,{dimColor:!0,children:[" ","Took",d]})]})}),"children")})},"CommandSummary");var Qy=Object.defineProperty,$n=$((t,e)=>Qy(t,"name",{value:e,configurable:!0}),"u$6");class _r{static{$(this,"TaskStore")}static{$n(this,"TaskStore")}#e;#t=new Set;#n=new Map;constructor(e){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retryTaskId:null,rows:e.map(r=>({status:"pending",taskId:r.id})),selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,viewMode:"list"}}getSnapshot=$n(()=>this.#e,"getSnapshot");subscribe=$n(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");startTasks(e){const r=[...this.#e.rows];for(const n of e){const i=r.findIndex(o=>o.taskId===n.id);i!==-1&&(r[i]={...r[i],elapsed:0,status:"running"},this.#n.set(n.id,process.hrtime()))}this.#r({...this.#e,rows:r})}endTasks(e){const r=[...this.#e.rows];let{cached:n,completed:i,failed:o,succeeded:s}=this.#e;const l=new Map(this.#e.outputs);for(const f of e){const p=r.findIndex(h=>h.taskId===f.task.id);switch(p!==-1&&(r[p]={...r[p],duration:f.startTime&&f.endTime?f.endTime-f.startTime:void 0,status:f.status}),i++,f.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{n++;break}case"success":{s++;break}}f.terminalOutput&&!l.has(f.task.id)&&l.set(f.task.id,f.terminalOutput),this.#n.delete(f.task.id)}let{selectedIndex:d}=this.#e;if(o>this.#e.failed){const f=r.findIndex(p=>p.status==="failure");f!==-1&&(d=f)}this.#r({...this.#e,cached:n,completed:i,failed:o,outputs:l,rows:r,selectedIndex:d,succeeded:s})}static#o=256*1024;addOutput(e,r){if(!r.trim())return;let n=(this.#e.outputs.get(e)??"")+r;n.length>_r.#o&&(n=n.slice(-_r.#o)),this.#e.outputs.set(e,n),this.#r({...this.#e})}setOutput(e,r){this.#e.outputs.set(e,r),this.#r({...this.#e})}markDone(){this.#r({...this.#e,done:!0,endTime:Date.now()})}tick(){if(this.#n.size===0)return;let e=!1;const r=[...this.#e.rows];for(let n=0;n<r.length;n++){const i=r[n];if(i.status==="running"){const o=this.#n.get(i.taskId);if(o){const s=process.hrtime(o),l=s[0]*1e3+s[1]/1e6;r[n]={...i,elapsed:l},e=!0}}}e&&this.#r({...this.#e,rows:r})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:e})}setFilter(e){this.#r({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#r({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,r){const n=[...this.#e.pinnedTaskIds];n[e]=r,this.#r({...this.#e,pinnedTaskIds:n})}clearPins(){this.#r({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const r=[...this.#e.rows],n=r.findIndex(l=>l.taskId===e);let{completed:i,failed:o,succeeded:s}=this.#e;if(n!==-1){const l=r[n].status;l==="failure"?(o=Math.max(0,o-1),i=Math.max(0,i-1)):l==="success"&&(s=Math.max(0,s-1),i=Math.max(0,i-1)),r[n]={...r[n],elapsed:0,status:"running"},this.#n.set(e,process.hrtime())}this.#r({...this.#e,completed:i,done:!1,endTime:null,failed:o,interactiveMode:!1,retryTaskId:e,rows:r,succeeded:s})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#r({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#r({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#r({...this.#e,viewMode:e})}setStatusFilter(e){this.#r({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#n.clear(),this.#r({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,rows:this.#e.rows.map(e=>({status:"pending",taskId:e.taskId})),startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#r({...this.#e,rerunRequested:!1})}#r(e){this.#e=e;for(const r of this.#t)try{r()}catch{}}}var Zy=Object.defineProperty,_e=$((t,e)=>Zy(t,"name",{value:e,configurable:!0}),"t$3");const ev={d:_e(()=>" d","d"),future:"in %s",h:_e(()=>" h","h"),m:_e(()=>" m","m"),mo:_e(()=>" mo","mo"),ms:_e(()=>" ms","ms"),past:"%s ago",s:_e(()=>" s","s"),w:_e(()=>" w","w"),y:_e(()=>" y","y")},Ea={delimiter:" ",language:ev,largest:2,round:!0,spacer:"",units:["h","m","s","ms"]};_e(t=>{const e=t[0]*1e3+t[1]/1e6;return Ui(e,Ea)},"formatHrtime");const Tt=_e(t=>Ui(t,Ea),"formatMs");var tv=Object.defineProperty,br=$((t,e)=>tv(t,"name",{value:e,configurable:!0}),"n$2");const cr=br(t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache","isCacheStatus"),$r=br(t=>{switch(t){case"failure":return{color:"red",icon:wo};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:xa};case"skipped":return{color:"gray",icon:un};default:return{color:"gray",icon:"?"}}},"getStatusInfo"),ja=br(t=>{const{color:e,icon:r}=$r(t);return ge(_.createElement(a,{color:e},r),{columns:10}).trim()},"getStatusIcon"),rv=br(t=>{const{color:e,icon:r}=$r(t);switch(t){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return ge(_.createElement(a,null,_.createElement(a,{color:e},r)," ",_.createElement(a,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return ge(_.createElement(a,null,_.createElement(a,{dimColor:!0},r)," ",_.createElement(a,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return ge(_.createElement(a,{color:e},r),{columns:10}).trim()}},"getStatusPrefix"),nv=br((t,e,r)=>{const n=r.trim();if(!n)return;const i=`
|
|
797
|
-
|
|
798
|
-
`).map(S=>S.replace(/\r$/,"")):[];return!n&&(d==="running"||d==="pending")?c(g,{borderBottomTitle:b,borderColor:h,borderStyle:p,borderTopRightTitle:y,borderTopTitle:m,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:c(g,{alignItems:"center",flexGrow:1,justifyContent:"center",children:c(a,{dimColor:!0,children:"Waiting for task output..."})})}):u(g,{borderBottomTitle:b,borderColor:r?"yellow":h,borderStyle:p,borderTopRightTitle:y,borderTopTitle:m,flexDirection:"column",flexGrow:1,children:[c(g,{flexGrow:1,flexShrink:1,paddingY:1,children:c(zt,{flexGrow:1,followOutput:!0,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:x.map((S,C)=>c(a,{children:S},String(C)))})}),r&&c(g,{flexShrink:0,justifyContent:"center",paddingX:1,children:c(a,{bold:!0,color:"yellow",children:"INTERACTIVE — keystrokes forwarded to task — Esc to exit"})})]})},"OutputPanel");var sv=Object.defineProperty,pn=$((t,e)=>sv(t,"name",{value:e,configurable:!0}),"x");const Aa=6,Ia=8,Ra=10,av=pn(t=>t==="running"||t==="pending"?Sa:t==="local-cache"||t==="local-cache-kept-existing"?"Local":t==="remote-cache"?"Remote":un,"getCacheLabel"),gi=pn((t,e)=>e[0]===t?"[1]":e[1]===t?"[2]":"","getPinLabel"),hi=pn(({compact:t,isSelected:e,pinLabel:r,row:n})=>{const{status:i,taskId:o}=n,s=e?">":" ";let l;if(i==="running")l=u(a,{bold:!0,color:"white",children:[" ",c(Bi,{type:"dots"})," "]});else if(i==="pending")l=c(a,{bold:!0,color:"gray",children:" · "});else{const{color:f,icon:p}=$r(i);l=u(a,{bold:!0,color:f,children:[" ",p," "]})}let d=Sa;return i!=="running"&&i!=="pending"?d=n.duration===void 0?un:Tt(n.duration):i==="running"&&n.elapsed!==void 0&&(d=Tt(n.elapsed)),u(g,{children:[c(a,{children:s}),c(g,{width:Aa,children:l}),u(g,{flexGrow:1,children:[c(a,{bold:e,inverse:e,children:o}),r?c(a,{dimColor:!0,children:` ${r}`}):null]}),!t&&c(g,{justifyContent:"flex-end",width:Ia,children:c(a,{dimColor:!cr(i),children:av(i)})}),!t&&c(g,{justifyContent:"flex-end",width:Ra,children:c(a,{dimColor:i==="pending",children:d})})]})},"TaskListRow"),mi=pn(({compact:t,filterActive:e,filterText:r,focused:n,headerStatus:i,parallelSlots:o=3,pinnedTaskIds:s,rows:l,scrollRef:d,selectedIndex:f,title:p})=>{const h=i==="error"?"red":i==="success"?"green":n?"white":"gray",m=l[f]?.taskId,y=l.filter(S=>S.status==="running"),b=y.length>0||l.some(S=>S.status==="pending"),x=[];if(b)for(let S=0;S<o;S++){const C=y[S];C?x.push(c(hi,{compact:t,isSelected:C.taskId===m,pinLabel:gi(C.taskId,s),row:C},`par-${C.taskId}`)):x.push(u(g,{children:[c(a,{children:" "}),c(g,{width:Aa,children:c(a,{bold:!0,color:"gray",children:" · "})}),c(a,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(S)}`))}return u(g,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,gap:1,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),c(a,{children:p}),!t&&u(g,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[c(g,{justifyContent:"flex-end",width:Ia,children:c(a,{dimColor:!0,children:"Cache"})}),c(g,{justifyContent:"flex-end",width:Ra,children:c(a,{dimColor:!0,children:"Duration"})})]})]}),c(zt,{flexGrow:1,flexShrink:1,paddingLeft:1,paddingY:1,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:l.map(S=>c(hi,{compact:t,isSelected:S.taskId===m,pinLabel:gi(S.taskId,s),row:S},S.taskId))}),b&&c(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingLeft:1,paddingY:1,children:x}),e&&u(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:"white",children:"/ "}),c(a,{children:r}),c(a,{inverse:!0,children:" "})]})]})},"TaskListPanel");var cv=Object.defineProperty,lv=$((t,e)=>cv(t,"name",{value:e,configurable:!0}),"y$1");const yi=40,vi=10,wi=100,dv=lv(({autoExitSeconds:t,parallelSlots:e,projectNames:r,stdinRegistry:n,store:i,targets:o,tasks:s})=>{const{exit:l}=Gt(),{columns:d,rows:f}=Ut(),p=pr(i.subscribe,i.getSnapshot),[h,m]=ce(!1),y=be(null),b=be(null),x=be(null),[S,C]=ce(!1),D=be({list:0,splitList:0,splitOutput:0}),P=Ye(()=>{p.viewMode==="list"?D.current.list=b.current?.getScrollOffset()??0:p.viewMode==="split"&&(D.current.splitList=b.current?.getScrollOffset()??0,D.current.splitOutput=x.current?.getScrollOffset()??0)},[p.viewMode]),M=Ye(O=>{setTimeout(()=>{if(O==="list"){const I=D.current.list;b.current?.scrollTo(I)}else if(O==="split"){const I=D.current.splitList;I>0?b.current?.scrollTo(I):b.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),x.current?.scrollTo(D.current.splitOutput)}},0)},[i]),E=be(!1);qe(()=>{p.done&&!E.current&&(E.current=!0,t>0&&C(!0)),!p.done&&E.current&&(E.current=!1,C(!1))},[p.done,t]);const R=Ke(()=>{let O=p.rows;if(p.statusFilter!=="all"&&(O=O.filter(I=>p.statusFilter==="failed"?I.status==="failure":p.statusFilter==="running"?I.status==="running"||I.status==="pending":p.statusFilter==="passed"?I.status==="success"||cr(I.status):!0)),p.filterText){const I=p.filterText.toLowerCase();O=O.filter(Y=>Y.taskId.toLowerCase().includes(I))}return O},[p.rows,p.filterText,p.statusFilter]),A=Ke(()=>p.rows.filter(O=>O.status==="running").length,[p.rows]),G=(R[p.selectedIndex]??null)?.taskId??null,B=p.pinnedTaskIds[0]??G,w=B?p.rows.find(O=>O.taskId===B):null,v=B?p.outputs.get(B)??"":"",j=vo(r,o,s),U=p.done?`Completed ${j} (${Tt((p.endTime??Date.now())-p.startTime)})`:`Running ${j}...`,z=p.done?p.failed>0?"error":"success":"running",Z=Ye(O=>{b.current?.scrollTo(Math.max(0,O-2))},[]);if(qe(()=>{p.interactiveMode&&w?.status!=="running"&&i.setInteractiveMode(!1)},[p.interactiveMode,w?.status,i]),qe(()=>{if(!B)return;let O=d;p.viewMode==="split"&&d>=wi?O=d-Math.floor(d*.4)-2:(p.viewMode==="split"||p.viewMode==="fullscreen")&&(O=d-2);const I=Math.max(1,f-4);n.get(B)?.resize?.(O,I)},[d,f,p.viewMode,B]),De((O,I)=>{if(I.escape){i.setInteractiveMode(!1);return}if(!B)return;const Y=n.get(B);if(!Y){i.setInteractiveMode(!1);return}if(I.return)Y.write("\r");else if(I.upArrow)Y.write("\x1B[A");else if(I.downArrow)Y.write("\x1B[B");else if(I.rightArrow)Y.write("\x1B[C");else if(I.leftArrow)Y.write("\x1B[D");else if(I.backspace)Y.write("");else if(I.delete)Y.write("\x1B[3~");else if(I.tab)Y.write(" ");else if(I.home)Y.write("\x1B[H");else if(I.end)Y.write("\x1B[F");else if(I.pageUp)Y.write("\x1B[5~");else if(I.pageDown)Y.write("\x1B[6~");else if(I.ctrl&&O){const ye=O.toUpperCase().codePointAt(0);ye!==void 0&&ye>=65&&ye<=90&&Y.write(String.fromCodePoint(ye-64))}else O&&Y.write(O)},{isActive:p.interactiveMode}),De((O,I)=>{if(O==="c"&&I.ctrl){l();return}if(!S){if(h){I.escape||O==="?"?m(!1):O==="q"?(m(!1),C(!0)):I.downArrow||O==="j"?y.current?.scrollBy(1):I.upArrow||O==="k"?y.current?.scrollBy(-1):I.pageDown?y.current?.scrollBy(5):I.pageUp?y.current?.scrollBy(-5):I.home?y.current?.scrollToTop():I.end&&y.current?.scrollToBottom();return}if(O==="?"){m(!0);return}if(O==="q"){C(!0);return}if(O==="r"&&p.done){i.requestRerun();return}if(O==="R"&&p.done){const Y=R[p.selectedIndex];Y?.status==="failure"&&i.requestRetry(Y.taskId);return}if(O==="F"&&!p.filterActive){const Y=["all","failed","running","passed"],ye=Y.indexOf(p.statusFilter);i.setStatusFilter(Y[(ye+1)%Y.length]);return}if(p.filterActive){if(I.escape){i.setFilterActive(!1);return}if(I.return){i.setFilterActive(!1);return}if(I.backspace){i.setFilter(p.filterText.slice(0,-1));return}if(O&&!I.ctrl&&!I.meta){i.setFilter(p.filterText+O);return}return}if(O==="i"&&w?.status==="running"&&(p.viewMode==="fullscreen"||p.viewMode==="split"&&p.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(p.viewMode==="fullscreen"){if(I.escape){i.setViewMode("split"),M("split");return}if(I.downArrow||O==="j"){x.current?.scrollBy(1);return}if(I.upArrow||O==="k"){x.current?.scrollBy(-1);return}if(I.pageDown||I.ctrl&&O==="d"){x.current?.scrollBy(12);return}if(I.pageUp||I.ctrl&&O==="u"){x.current?.scrollBy(-12);return}if(I.home){x.current?.scrollToTop();return}if(I.end){x.current?.scrollToBottom();return}return}if(p.viewMode==="split"){if(I.tab){const Y=p.focusedPanel==="tasks"?"output":"tasks";i.setFocusedPanel(Y);return}if(p.focusedPanel==="output"){if(I.escape){i.setFocusedPanel("tasks");return}if(I.return){P(),i.setViewMode("fullscreen");return}if(I.downArrow||O==="j"){x.current?.scrollBy(1);return}if(I.upArrow||O==="k"){x.current?.scrollBy(-1);return}if(I.pageDown||I.ctrl&&O==="d"){x.current?.scrollBy(12);return}if(I.pageUp||I.ctrl&&O==="u"){x.current?.scrollBy(-12);return}if(I.home){x.current?.scrollToTop();return}if(I.end){x.current?.scrollToBottom();return}return}if(I.escape){i.setViewMode("list"),M("list");return}if(I.return){i.setFocusedPanel("output");return}}if(p.viewMode==="list"||p.viewMode==="split"&&p.focusedPanel==="tasks"){if(I.downArrow||O==="j"){const Y=Math.min(p.selectedIndex+1,Math.max(0,R.length-1));i.setSelectedIndex(Y),Z(Y);return}if(I.upArrow||O==="k"){const Y=Math.max(p.selectedIndex-1,0);i.setSelectedIndex(Y),Z(Y);return}if(I.return&&p.viewMode==="list"){P(),D.current.splitList=0,D.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),M("split");return}if(O==="/"){i.setFilterActive(!0);return}if(O==="1"&&G){i.pinTask(0,G);return}if(O==="2"&&G){i.pinTask(1,G);return}if(O==="0"){i.clearPins();return}I.escape&&p.filterText&&i.setFilter("")}}},{isActive:!p.interactiveMode}),d<yi||f<vi)return c(g,{alignItems:"center",height:f,justifyContent:"center",width:d,children:u(a,{color:"yellow",children:["Terminal too small (",d,"x",f,"). Minimum:"," ",yi,"x",vi]})});const he=u(g,{gap:1,children:[p.succeeded>0&&u(a,{bold:!0,color:"green",children:["✓"," ",p.succeeded]}),p.failed>0&&u(a,{bold:!0,color:"red",children:["✗"," ",p.failed]}),A>0&&u(a,{color:"cyan",children:["◷"," ",A]}),u(a,{dimColor:!0,children:[p.rows.length," ","total"]}),p.statusFilter!=="all"&&u(a,{color:"yellow",children:["[",p.statusFilter,"]"]})]});let oe;if(p.viewMode==="fullscreen")oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Esc"}),c(a,{dimColor:!0,children:"BACK"})]},"esc"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"^u ^d"}),c(a,{dimColor:!0,children:"PAGE"})]},"page"),...w?.status==="running"?[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"i"}),c(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q")];else if(p.done){const O=R[p.selectedIndex]?.status==="failure";oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"r"}),c(a,{dimColor:!0,children:"RERUN"})]},"r"),...O?[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"R"}),c(a,{dimColor:!0,children:"RETRY"})]},"R")]:[],u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"F"}),c(a,{dimColor:!0,children:"FILTER"})]},"F"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"⏎"}),c(a,{dimColor:!0,children:p.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else p.viewMode==="split"&&p.focusedPanel==="output"?oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Esc"}),c(a,{dimColor:!0,children:"BACK"})]},"esc"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),...w?.status==="running"?[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"i"}),c(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"⏎"}),c(a,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"tab"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?")]:oe=[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"/"}),c(a,{dimColor:!0,children:"FILTER"})]},"/"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"F"}),c(a,{dimColor:!0,children:"STATUS"})]},"F"),u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"⏎"}),c(a,{dimColor:!0,children:p.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...p.viewMode==="split"?[u(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const Te=u(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:oe}),c(g,{flexShrink:0,paddingX:1,children:he})]}),ke=u(xt,{backgroundColor:"#1e1e1e",footer:u(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"?"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:y,title:"KEYBOARD SHORTCUTS",visible:h,width:52,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Move up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Move down"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Tab"]}),c(a,{dimColor:!0,children:" Switch panel (split)"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Esc"]}),c(a,{dimColor:!0,children:" Back / close"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Enter"]}),c(a,{dimColor:!0,children:" Show output / fullscreen"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"VIEWS"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Enter"]}),u(a,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Esc"]}),u(a,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"ACTIONS"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","/"]}),c(a,{dimColor:!0,children:" Filter by text"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","F"]}),c(a,{dimColor:!0,children:" Filter by status"})]})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","1"]}),c(a,{dimColor:!0,children:"/"}),c(a,{bold:!0,color:"white",children:"2"}),c(a,{dimColor:!0,children:" Pin to output pane"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","0"]}),c(a,{dimColor:!0,children:" Clear pins"})]})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","r"]}),c(a,{dimColor:!0,children:" Rerun all (done)"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","R"]}),c(a,{dimColor:!0,children:" Retry failed task"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","i"]}),c(a,{dimColor:!0,children:" Interactive input (running task)"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"SCROLLING"}),c(a,{dimColor:!0,children:" (output panel)"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Scroll up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Scroll down"})]})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","^u"]}),c(a,{dimColor:!0,children:" Page up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","^d"]}),c(a,{dimColor:!0,children:" Page down"})]})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Home"]}),c(a,{dimColor:!0,children:" Top"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","End"]}),c(a,{dimColor:!0,children:" Bottom"})]})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"GENERAL"})]}),u(g,{children:[c(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","q"]}),c(a,{dimColor:!0,children:" Quit"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","?"]}),c(a,{dimColor:!0,children:" Toggle help"})]})]})]})]}),Se=c(jt,{autoExitSeconds:t>0?t:3,onCancel:$(()=>{C(!1)},"onCancel"),visible:S});if(p.viewMode==="fullscreen")return u(g,{flexDirection:"column",height:f,width:d,children:[c(g,{flexGrow:1,children:c(fi,{duration:w?.duration??w?.elapsed,focused:!0,interactiveMode:p.interactiveMode,output:v,scrollRef:x,status:w?.status,taskId:B})}),Te,Se,ke]});if(p.viewMode==="split"){const O=d>=wi,I=c(mi,{compact:!0,filterActive:p.filterActive,filterText:p.filterText,focused:p.focusedPanel==="tasks",headerStatus:z,parallelSlots:e,pinnedTaskIds:p.pinnedTaskIds,rows:R,scrollRef:b,selectedIndex:p.selectedIndex,title:U}),Y=c(fi,{duration:w?.duration??w?.elapsed,focused:p.focusedPanel==="output",interactiveMode:p.interactiveMode,output:v,scrollRef:x,showFullscreenHint:!0,status:w?.status,taskId:B});if(O){const Ae=Math.floor(d*.4);return u(g,{flexDirection:"column",height:f,width:d,children:[u(g,{flexDirection:"row",flexGrow:1,children:[c(g,{width:Ae,children:I}),c(g,{flexGrow:1,children:Y})]}),Te,Se,ke]})}const ye=Math.floor(f*.45);return u(g,{flexDirection:"column",height:f,width:d,children:[c(g,{height:ye,children:I}),c(g,{flexGrow:1,children:Y}),Te,Se,ke]})}return u(g,{flexDirection:"column",height:f,width:d,children:[c(g,{flexGrow:1,children:c(mi,{filterActive:p.filterActive,filterText:p.filterText,focused:!0,headerStatus:z,parallelSlots:e,pinnedTaskIds:p.pinnedTaskIds,rows:R,scrollRef:b,selectedIndex:p.selectedIndex,title:U})}),Te,Se,ke]})},"VisTaskRunnerApp");var uv=Object.defineProperty,Pt=$((t,e)=>uv(t,"name",{value:e,configurable:!0}),"n$1");const pv=Pt(t=>{const{args:e,autoExit:r=!1,projectNames:n,stdinRegistry:i,tasks:o}=t,s=new _r(o),l=typeof e.parallel=="number"?e.parallel:3,d=r===!0?3:typeof r=="number"?r:0;let f,p;const h=new Promise(P=>{p=P});let m;const y=Pt(()=>{m&&(clearInterval(m),m=void 0)},"cleanup"),b=Pt(()=>{if(i){for(const P of i.values())P.kill?.();i.clear()}},"killAllPtyProcesses"),x=Pt(()=>{y(),D(),b(),process.stdout.write("\x1B[?1049l\x1B[?25h"),f?.cleanup(),process.exit(1)},"onSignal"),S=Pt(()=>{const P=s.getSnapshot(),M=Tt(Date.now()-P.startTime),E=P.rows.filter(G=>G.status==="failure").map(G=>G.taskId),R=process.stdout.columns||80;process.stdout.write(`
|
|
799
|
-
`);for(const
|
|
879
|
+
`;return Se(o,i,"utf8"),r.info(`Created ${o} with staged config`),!0},"insertStagedIntoVisConfig"),Hx=Ye(t=>{const e=w(t,"package.json"),r={configRemoved:!1,dependencyRemoved:!1};if(!T(e))return r;const n=ee(e),o=JSON.parse(n);let i=!1;o["nano-staged"]&&(delete o["nano-staged"],i=!0,r.configRemoved=!0);const s=o.devDependencies,a=o.dependencies;if(s?.["nano-staged"]&&(delete s["nano-staged"],i=!0,r.dependencyRemoved=!0),a?.["nano-staged"]&&(delete a["nano-staged"],i=!0,r.dependencyRemoved=!0),i){const c=vs(n);Pe(e),Se(e,`${JSON.stringify(o,void 0,c)}
|
|
880
|
+
`,"utf8")}return r},"removeNanoStagedFromPackageJson"),qx=Ye((t,e)=>{for(const r of ys){const n=w(t,r);T(n)&&(Pe(n,e),Wr(n),e.removedConfigCount+=1)}},"removeNanoStagedConfigFiles"),Jx=Ye((t,e)=>{const r=w(t,e,"pre-commit");if(!T(r))return!1;const n=ee(r);if(n.includes("vis staged"))return!1;const o=n.split(`
|
|
881
|
+
`);let i=!1;const s=[];for(const a of o){const c=a.trim();if(!i){let d=!1;for(const p of jS){const g=p.exec(c);if(g){const m=a.slice(0,a.length-a.trimStart().length),y=g[1]?.trim()??"",v=c.slice(g[0].length).trim(),k=[y,"vis staged",v].filter(Boolean);s.push(`${m}${k.join(" ")}`),i=!0,d=!0;break}}if(d)continue}s.push(a)}return i?(Pe(r),Se(r,s.join(`
|
|
882
|
+
`)),!0):!1},"rewritePreCommitHook"),Yx=Ye((t,e,r)=>{if(e==="package.json")return Gx(t);const n=w(t,e);if(!Dd.includes(e)){He(r,`${e} cannot be auto-migrated — please add "staged" config to vis.config.ts manually`),Ze(r,`Manually convert ${e} to staged config in vis.config.ts`);return}if(e===".nanostagedrc"&&!Go(n)){He(r,".nanostagedrc is not JSON format — please migrate manually");return}return Wx(n)},"extractConfig"),eu=Ye((t,e)=>{const{configRemoved:r,dependencyRemoved:n}=Hx(t);r&&(e.inlinedLintStagedConfigCount+=1),n&&(e.removedPackageCount+=1),qx(t,e)},"cleanupNanoStagedArtifacts"),Kx=Ye((t,e,r,n)=>{const o=[".vis-hooks",".husky"];for(const i of o)T(w(t,i))&&Jx(t,i)&&(n.gitHooksConfigured=!0,e.silent||r.info(`Rewrote pre-commit hook in ${i}/ to use "vis staged"`))},"rewriteHooks"),Xx=Ye((t,e,r,n,o)=>{zx(t,e,n)&&(o.mergedStagedConfigCount+=1),eu(t,o),Kx(t,r,n,o)},"applyMigration"),Qx=Ye((t,e,r,n)=>{const o=_x(t);if(!o)return e.silent||r.info("No nano-staged configuration found — nothing to migrate."),!1;if(Vx(t)&&(He(n,'Non-JSON nano-staged config found — please migrate to "staged" in vis.config.ts manually'),Ze(n,"Convert your nano-staged config file to JSON format or add staged config to vis.config.ts manually")),Ux(t))return He(n,'vis.config.ts already has a "staged" config — skipping nano-staged merge'),e.silent||r.warn('vis.config.ts already has a "staged" config — skipping'),e.dryRun||eu(t,n),!0;const i=Yx(t,o,n);return!i||Object.keys(i).length===0?(e.silent||r.warn("nano-staged config is empty — skipping"),!1):e.dryRun?(e.silent||(r.info("[dry-run] Would insert staged config into vis.config.ts:"),r.info(Ci(i))),!0):(Xx(t,i,e,r,n),!0)},"migrateNanoStaged");var Zx=Object.defineProperty,tu=b((t,e)=>Zx(t,"name",{value:e,configurable:!0}),"o$7");const eC=tu(t=>{const e={};return t.namedInputs&&Object.keys(t.namedInputs).length>0&&(e.namedInputs=t.namedInputs),t.targetDefaults&&Object.keys(t.targetDefaults).length>0&&(e.targetDefaults=t.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(${$s(e)});`,""].join(`
|
|
883
|
+
`)},"renderVisConfig"),tC=tu((t,e,r,n)=>{const o=Zd(t,"nx.json");if(!o){r.warn("No nx.json found in workspace root — nothing to migrate."),n.warnings.push("No nx.json at workspace root.");return}const i=eC(o);Ss(t,i,e,r,n)&&(n.manualSteps.push("Existing project.json files are vis-compatible and have been left untouched. Rename `sourceRoot` -> `sourceRoot` is identical; `tags`, `implicitDependencies`, and `targets` translate directly."),(o.affected?.defaultBase||o.defaultBase)&&n.manualSteps.push(`nx's default base branch (${o.affected?.defaultBase??o.defaultBase}) is honoured by vis via the --base flag; no vis config change needed.`))},"migrateNx");var rC=Object.defineProperty,nC=b((t,e)=>rC(t,"name",{value:e,configurable:!0}),"o$6");const oC=nC(async t=>{if(!Bs.isTTY)return!0;const e=jp({input:Bs,output:sp});try{const r=(await e.question(`${t} [Y/n] `)).trim().toLowerCase();return r===""||r==="y"||r==="yes"}finally{e.close()}},"confirm");var iC=Object.defineProperty,zt=b((t,e)=>iC(t,"name",{value:e,configurable:!0}),"a$6");const ru=[".secretlintrc",".secretlintrc.json",".secretlintrc.js",".secretlintrc.mjs",".secretlintrc.cjs",".secretlintrc.yml",".secretlintrc.yaml"],nu=[".secretlintignore"],sC=zt(t=>ru.find(e=>T(w(t,e))),"detectSecretlintConfig"),aC=zt(t=>nu.find(e=>T(w(t,e))),"detectSecretlintIgnore"),cC=zt((t,e,r)=>{if(e.endsWith(".js")||e.endsWith(".mjs")||e.endsWith(".cjs"))return He(r,`${e} is a JS config — cannot auto-extract rule IDs. Review manually to confirm coverage.`),[];if(e.endsWith(".yml")||e.endsWith(".yaml"))return He(r,`${e} is YAML — cannot auto-extract rule IDs without a YAML parser. Review manually.`),[];const n=ft(w(t,e));if(!n)return[];const o=new Set,i=zt(s=>{if(s)for(const a of s)a.id&&o.add(a.id),a.rules&&i(a.rules)},"walk");return i(n.rules),[...o]},"extractRuleIds"),lC=zt((t,e,r,n)=>{for(const o of[...ru,...nu]){const i=w(t,o);if(T(i)){if(e){r.info(`[dry-run] Would remove ${i}`);continue}Pe(i,n),Wr(i),Pt(n,"secretlint","removedConfigCount"),r.info(`Removed ${i}`)}}},"removeSecretlintConfigFiles"),dC=zt((t,e,r,n)=>{const o=w(t,".secretlintignore");if(!T(o))return;const i=ee(o).split(/\r?\n/).map(s=>s.trim()).filter(s=>s&&!s.startsWith("#"));i.length!==0&&(Ze(n,`.secretlintignore contained ${String(i.length)} path pattern(s). vis secrets uses .gitignore + --exclude / --exclude-from; add these globs to your .gitignore or pass --exclude: ${i.slice(0,5).join(", ")}${i.length>5?", ...":""}`),e&&r.info(`[dry-run] Would consume ${o} (${String(i.length)} patterns) and surface as manual step.`))},"convertIgnoreFile"),uC=zt((t,e,r,n)=>{const o=w(t,"package.json");if(!T(o))return;const i=ft(o);if(!i)return;let s=!1;if(i.scripts){for(const[a,c]of Object.entries(i.scripts))if(typeof c=="string"&&/\bsecretlint\b/.test(c)){const d=c.replaceAll(/\bsecretlint\b[^\n&|;]*/g,"vis secrets").trim();d!==c&&(i.scripts[a]=d,s=!0,Pt(n,"secretlint","rewrittenScriptCount"),r.info(` scripts.${a}: "${c}" -> "${d}"`))}}if(i.devDependencies){const a=i.devDependencies,c=[];for(const d of Object.keys(a))(d==="secretlint"||d.startsWith("@secretlint/"))&&(delete a[d],c.push(d),s=!0,Pt(n,"secretlint","removedPackageCount"));c.length>0&&r.info(` removed ${String(c.length)} secretlint devDependencies: ${c.join(", ")}`)}if(s){if(e){r.info(`[dry-run] Would update ${o}`);return}Pe(o,n),Q(o,`${JSON.stringify(i,null,4)}
|
|
884
|
+
`)}},"rewriteScripts"),pC=zt((t,e,r,n)=>{const o=[".husky/pre-commit",".vis-hooks/pre-commit",".git/hooks/pre-commit"];for(const i of o){const s=w(t,i);if(!T(s))continue;const a=ee(s);if(!/\bsecretlint\b/.test(a))continue;const c=a.replaceAll(/\bsecretlint\b[^\n&|;]*/g,"vis secrets --staged");if(e){r.info(`[dry-run] Would rewrite ${s}`);continue}Pe(s,n),Q(s,c),n.gitHooksConfigured=!0,r.info(`Rewrote secretlint invocation in ${i}`)}},"rewriteHooks"),fC=zt((t,e,r,n)=>{const o=sC(t),i=aC(t);if(!(o??i))return e.silent||r.info("No secretlint artifacts found — nothing to migrate."),!1;if(o){const s=cC(t,o,n);r.info(`Found ${o}`),s.length>0?(r.info(` active rules/presets: ${s.join(", ")}`),Ze(n,`secretlint used these rules: ${s.join(", ")}. vis secrets ships the gitleaks ruleset (177 rules covering AWS/GCP/Azure/GitHub/Slack/Stripe and more). Verify parity before removing secretlint.`)):Ze(n,`Rule IDs could not be auto-extracted from ${o}. Verify that the bundled gitleaks ruleset covers your secretlint rule set.`)}return dC(t,e.dryRun,r,n),uC(t,e.dryRun,r,n),pC(t,e.dryRun,r,n),lC(t,e.dryRun,r,n),!0},"migrateSecretlint");var gC=Object.defineProperty,xs=b((t,e)=>gC(t,"name",{value:e,configurable:!0}),"u$8");const hC=xs(t=>t.map(e=>{if(e.startsWith("^"))return{dependencies:!0,target:e.slice(1)};if(e.includes("#")){const[r,n]=e.split("#");return{projects:r,target:n}}return e}),"convertDependsOn"),mC=xs(t=>{const e=t.tasks??t.pipeline??{},r={};for(const[i,s]of Object.entries(e)){if(i.includes("#"))continue;const a={};s.persistent&&(a.persistent=!0),s.interactive&&(a.interactive=!0);const c={};s.cache===!1&&(c.cache=!1),s.dependsOn&&s.dependsOn.length>0&&(c.dependsOn=hC(s.dependsOn)),s.inputs&&s.inputs.length>0&&(c.inputs=s.inputs),s.outputs&&s.outputs.length>0&&(c.outputs=s.outputs),s.env&&s.env.length>0&&(c.env=s.env),s.passThroughEnv&&s.passThroughEnv.length>0&&(c.passThroughEnv=s.passThroughEnv),Object.keys(a).length>0&&(c.options=a),r[i]=c}const n={};Object.keys(r).length>0&&(n.targetDefaults=r);const o={};return t.globalDependencies&&t.globalDependencies.length>0&&(o.globalInputs=t.globalDependencies),t.globalEnv&&t.globalEnv.length>0&&(o.globalEnv=t.globalEnv),t.globalPassThroughEnv&&t.globalPassThroughEnv.length>0&&(o.globalPassThroughEnv=t.globalPassThroughEnv),Object.keys(o).length>0&&(n.taskRunnerOptions=o),["// Migrated from turbo.json by `vis migrate turborepo`.","// Review the generated targetDefaults and move project-specific tasks","// into each project's project.json.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${$s(n)});`,""].join(`
|
|
885
|
+
`)},"renderVisConfig"),yC=xs((t,e,r,n)=>{const o=Zd(t,"turbo.json");if(!o){r.warn("No turbo.json found in workspace root — nothing to migrate."),n.warnings.push("No turbo.json at workspace root.");return}const i=mC(o);if(!Ss(t,i,e,r,n))return;n.manualSteps.push("Review targetDefaults in vis.config.ts — project-specific tasks (turbo's project#task syntax) were skipped and should be moved into each project's project.json.");const s=o.tasks??o.pipeline??{};Object.values(s).some(a=>a.outputLogs!==void 0)&&n.warnings.push("`outputLogs` was found on one or more tasks but vis has no equivalent setting — review and remove."),o.remoteCache?.enabled&&n.manualSteps.push("turbo remote cache detected. vis speaks the same HTTP protocol — set taskRunnerOptions.remoteCache { url, token, teamId } in vis.config.ts.")},"migrateTurborepo");var vC=Object.defineProperty,zo=b((t,e)=>vC(t,"name",{value:e,configurable:!0}),"c$d");const wC=[".husky/pre-commit",".vis-hooks/pre-commit",".git/hooks/pre-commit"],kC=[".secretlintrc",".secretlintrc.json",".secretlintrc.js",".secretlintrc.mjs",".secretlintrc.cjs",".secretlintrc.yml",".secretlintrc.yaml"],bC=zo(t=>{const e=w(t,"package.json");if(!T(e))return[];let r;try{r=JSON.parse(ee(e))}catch{return[]}const n=[];if(r.scripts)for(const[o,i]of Object.entries(r.scripts))typeof i=="string"&&(/\bgitleaks\b/.test(i)&&n.push({detail:`Script "${o}" still invokes gitleaks: ${i}`,kind:"script",location:"package.json"}),/\bsecretlint\b/.test(i)&&n.push({detail:`Script "${o}" still invokes secretlint: ${i}`,kind:"script",location:"package.json"}));if(r.devDependencies)for(const o of Object.keys(r.devDependencies))(o==="gitleaks"||o==="@gitleaks/cli")&&n.push({detail:`devDependency \`${o}\` is still installed`,kind:"devDep",location:"package.json"}),(o==="secretlint"||o.startsWith("@secretlint/"))&&n.push({detail:`devDependency \`${o}\` is still installed`,kind:"devDep",location:"package.json"});return n},"scanPackageJson"),$C=zo(t=>{const e=[];for(const r of wC){const n=w(t,r);if(!T(n))continue;const o=ee(n);/\bgitleaks\b/.test(o)&&e.push({detail:"gitleaks invocation still present in hook",kind:"hook",location:r}),/\bsecretlint\b/.test(o)&&e.push({detail:"secretlint invocation still present in hook",kind:"hook",location:r})}return e},"scanHooks"),SC=zo(t=>{const e=[];for(const r of kC)T(w(t,r))&&e.push({detail:"secretlint config should be removed after migration",kind:"config",location:r});return e},"scanConfigs"),xC=zo((t,e)=>{const r=[...bC(t),...$C(t),...SC(t)];if(r.length===0)return e.info("✓ No unmigrated gitleaks/secretlint references found."),[];e.warn(`Found ${String(r.length)} unmigrated reference(s):`);for(const n of r)e.warn(` [${n.kind}] ${n.location} — ${n.detail}`);return r},"verifyMigration");var CC=Object.defineProperty,ou=b((t,e)=>CC(t,"name",{value:e,configurable:!0}),"m$7");const jC=ou((t,e)=>{e.info("── Migration Summary ──");const r=[["Staged configs merged into vis.config.ts",t.mergedStagedConfigCount],["Lint-staged configs inlined",t.inlinedLintStagedConfigCount],["Config files removed",t.removedConfigCount],["Packages removed",t.removedPackageCount],["Scripts rewritten",t.rewrittenScriptCount]];for(const[o,i]of r)i>0&&e.info(` ${o}: ${String(i)}`);t.gitHooksConfigured&&e.info(" Pre-commit hook updated to use vis staged");const n=Object.entries(t.perMigration);if(n.length>0){e.info(""),e.info("By migration:");for(const[o,i]of n){const s=[];i.removedConfigCount>0&&s.push(`${String(i.removedConfigCount)} config(s) removed`),i.removedPackageCount>0&&s.push(`${String(i.removedPackageCount)} package(s) removed`),i.rewrittenScriptCount>0&&s.push(`${String(i.rewrittenScriptCount)} script(s) rewritten`),e.info(` ${o}: ${s.join(", ")||"no changes"}`)}}if(t.backupsCreated.length>0&&(e.info(""),e.info(`Created ${String(t.backupsCreated.length)} .bak file(s) for rollback. Remove them once you're happy.`)),t.warnings.length>0){e.info(""),e.warn("Warnings:");for(const o of t.warnings)e.warn(` - ${o}`)}if(t.manualSteps.length>0){e.info(""),e.info("Manual steps required:");for(const o of t.manualSteps)e.info(` - ${o}`)}},"printSummary"),TC={argument:{description:"Migration type: all, deps, lint-staged, nano-staged, turborepo, nx, moon, gitleaks, kingfisher, secretlint, verify",name:"type",type:String},description:"Migrate from other tools to vis (or verify a prior migration with `verify`)",examples:[["vis migrate","Run all built-in migrations"],["vis migrate gitleaks","Migrate gitleaks config/baseline/hooks to `vis secrets`"],["vis migrate kingfisher","Migrate Kingfisher baseline/hooks/scripts to `vis secrets`"],["vis migrate secretlint","Replace secretlint with `vis secrets`"],["vis migrate verify","Audit the workspace for stray gitleaks/secretlint references (exit 1 on issues)"]],execute:ou(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{const i=t[0]??"all",s=!!r.dryRun,a=!!r.yes,c=o??process.cwd(),d=n??{},p=Vd(c),g=J0(),m=["all","deps","lint-staged","nano-staged","turborepo","nx","moon","gitleaks","kingfisher","secretlint","verify"];if(!m.includes(i))throw new Error(`Unknown migration type "${i}". Use one of: ${m.join(", ")}.`);if(i==="verify"){xC(c,e).length>0&&(process.exitCode=1);return}if(s)e.info(`Running in dry-run mode — no changes will be made.
|
|
886
|
+
`);else if(!a&&i!=="all"&&!await oC(`This will edit files, scripts, and hooks for "${i}". Backups (.bak) will be created. Continue?`)){e.info("Aborted.");return}(i==="all"||i==="deps")&&(e.info("── Migrating dependencies and scripts ──"),H0(c,p,d,{dryRun:s},e,g),e.info("")),(i==="all"||i==="lint-staged")&&(e.info("── Migrating lint-staged ──"),Rx(c,{dryRun:s},e,g),e.info("")),(i==="all"||i==="nano-staged")&&(e.info("── Migrating nano-staged ──"),Qx(c,{dryRun:s},e,g),e.info("")),i==="turborepo"&&(e.info("── Migrating turborepo ──"),yC(c,{dryRun:s},e,g),e.info("")),i==="nx"&&(e.info("── Migrating nx ──"),tC(c,{dryRun:s},e,g),e.info("")),i==="moon"&&(e.info("── Migrating moon ──"),Bx(c,{copyTemplates:!!r.copyTemplates,dryRun:s},e,g),e.info("")),i==="gitleaks"&&(e.info("── Migrating gitleaks ──"),ix(c,{dryRun:s},e,g),e.info("")),i==="kingfisher"&&(e.info("── Migrating Kingfisher ──"),gx(c,{dryRun:s},e,g),e.info("")),i==="secretlint"&&(e.info("── Migrating secretlint ──"),fC(c,{dryRun:s},e,g),e.info("")),jC(g,e)},"execute"),group:"Scaffold & Config",name:"migrate",options:[{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},{defaultValue:!1,description:"For `vis migrate moon`: copy .moon/templates/* into .vis/templates/* so vis generate works without .moon/",name:"copy-templates",type:Boolean}]};var EC=Object.defineProperty,RC=b((t,e)=>EC(t,"name",{value:e,configurable:!0}),"a$5");const IC={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"]],execute:RC(async({argument:t,logger:e,workspaceRoot:r})=>{const n=t;if(!n||n.length===0)throw new Error("No subcommand specified. Available: cache, publish, audit, list, view, config, whoami, login, logout, pack, owner, dist-tag, search, fund, ping, token, deprecate, rebuild, prune");const[o,...i]=n,s=r??process.cwd(),a=Ne(s),c=ih(a,o,i,s,e);c!==0&&(process.exitCode=c)},"execute"),group:"System",name:"pm"};var AC=Object.defineProperty,OC=b((t,e)=>AC(t,"name",{value:e,configurable:!0}),"t$7");const PC={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"]],execute:OC(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis remove <packages...>");const i=process.cwd(),s=Ne(n??i),a=Xg(s,{filter:Dn(r.filter),global:r.global||!1,packages:o,recursive:r.recursive||!1,saveDev:r.saveDev||!1,workspaceRoot:r.workspaceRoot||!1},i,e);a!==0&&(process.exitCode=a)},"execute"),group:"Dependencies",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}]};var NC=Object.defineProperty,Cs=b((t,e)=>NC(t,"name",{value:e,configurable:!0}),"i$6");const MC=Cs((t,e)=>{let r=0,n=0,o=0;for(const[,a]of t)switch(a.status){case"failure":{o+=1;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{n+=1;break}case"success":{r+=1;break}}const i=[];r>0&&i.push(`${String(r)} succeeded`),n>0&&i.push(`${String(n)} cached`),o>0&&i.push(`${String(o)} failed`);const s=(e/1e3).toFixed(1);return i.push(`${s}s`),i.join(" · ")},"formatTimingSummary"),js=Cs(t=>{const e=w(t,".task-runner","runs");if(!T(e))return[];const r=Ge(e).filter(o=>o.endsWith(".json")),n=[];for(const o of r)try{n.push(ue(w(e,o)))}catch{}return n},"loadRunSummaries"),DC=Cs((t,e,r)=>{const n=r??js(t);if(n.length<2)return;let o=0,i=0;for(const c of n)typeof c.duration=="number"&&c.duration>0&&(o+=c.duration,i+=1);if(i<2)return;const s=o/i-e,a=Math.abs(s/1e3).toFixed(1);return Math.abs(s)<500?"(about average)":s>0?`(${a}s faster than avg)`:`(${a}s slower than avg)`},"compareDuration");var BC=Object.defineProperty,ji=b((t,e)=>BC(t,"name",{value:e,configurable:!0}),"c$c");const iu=ji((t,e={},r)=>{const n=r??js(t);if(n.length===0)return[];const o=new Map;for(const a of n)if(!(e.since&&(a.startTime===void 0||a.startTime<e.since))&&Array.isArray(a.tasks))for(const c of a.tasks){if(c.cacheStatus==="HIT"||c.cacheStatus==="REMOTE_HIT"||c.cacheStatus==="SKIPPED")continue;const d=o.get(c.taskId)??{failures:0,project:c.target.project,successes:0,target:c.target.target,totalRuns:0};d.totalRuns+=1,c.exitCode!==void 0&&c.exitCode!==0?(d.failures+=1,d.lastFailure=c.startTime??a.startTime):d.successes+=1,o.set(c.taskId,d)}const i=e.minRuns??2,s=[];for(const[a,c]of o)c.totalRuns<i||c.failures!==0&&s.push({failures:c.failures,flakinessRate:c.failures/c.totalRuns,lastFailure:c.lastFailure,project:c.project,successes:c.successes,target:c.target,taskId:a,totalRuns:c.totalRuns});return s.sort((a,c)=>c.flakinessRate-a.flakinessRate),s},"analyzeFlakiness"),FC=ji(t=>{if(t.length===0)return["No flaky tasks detected."];const e=["Task","Runs","Failures","Rate","Last Failure"],r=t.map(a=>[a.taskId,String(a.totalRuns),String(a.failures),`${(a.flakinessRate*100).toFixed(1)}%`,a.lastFailure??"—"]),n=e.map((a,c)=>{const d=r.reduce((p,g)=>Math.max(p,(g[c]??"").length),0);return Math.max(a.length,d)}),o=ji((a,c)=>a.padEnd(c),"pad"),i=n.map(a=>"─".repeat(a)).join("──"),s=[];s.push(e.map((a,c)=>o(a,n[c])).join(" ")),s.push(i);for(const a of r)s.push(a.map((c,d)=>o(c,n[d])).join(" "));return s},"formatFlakinessTable");var LC=Object.defineProperty,Ho=b((t,e)=>LC(t,"name",{value:e,configurable:!0}),"t$6");const VC=Ho(()=>Tp(),"createVisHooks"),UC=Ho(async(t,e)=>{if(!(!e||e.length===0))for(const r of e){if(r.hooks)for(const[n,o]of Object.entries(r.hooks)){const i=Array.isArray(o)?o:[o];for(const s of i)t.hook(n,s)}r.setup&&await r.setup(t)}},"registerPlugins");class _C{static{b(this,"HookableLifeCycle")}static{Ho(this,"HookableLifeCycle")}#e;#t;#n=new Map;constructor(e,r){this.#e=e,this.#t=r}startTasks(e){for(const r of e)this.#n.set(r.id,r),this.#o("task:before",r)}endTasks(e){for(const r of e)this.#n.delete(r.task.id),this.#o("task:after",r.task,r),r.status==="failure"?this.#o("task:failure",r.task,r):GC(r.status)&&this.#o("task:cacheHit",r.task,r)}printCacheMiss(e,r){this.#o("task:cacheMiss",e,r)}onTaskStdout(e,r){this.#o("task:stdout",e,r)}onTaskStderr(e,r){this.#o("task:stderr",e,r)}#o(e,...r){Promise.resolve(this.#e.callHook(e,...r)).catch(n=>{if(this.#t)try{this.#t(e,n)}catch{}})}}const GC=Ho(t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache","isCacheStatus");var WC=Object.defineProperty,qo=b((t,e)=>WC(t,"name",{value:e,configurable:!0}),"o$5");const zC=qo(async t=>{if(process.env.VIS_NO_SHELL_HISTORY||Ic()==="win32")return;const e=process.env.SHELL;if(!e)return;const r=So(e);try{if(r==="zsh"){await HC(t);return}if(r==="bash"){await qC(t);return}r==="fish"&&await JC(t)}catch{}},"appendToShellHistory"),HC=qo(async t=>{const e=process.env.HISTFILE??w(process.env.ZDOTDIR??Xe(),".zsh_history"),r=`: ${Math.floor(Date.now()/1e3)}:0;${t}
|
|
887
|
+
`;await Gi(e,r)},"writeZshHistory"),qC=qo(async t=>{const e=process.env.HISTFILE??w(Xe(),".bash_history");await Gi(e,`${t}
|
|
888
|
+
`)},"writeBashHistory"),JC=qo(async t=>{const e=w(Xe(),".local","share","fish","fish_history"),r=`- cmd: ${t.replaceAll("\\","\\\\").replaceAll(`
|
|
889
|
+
`,String.raw`\n`)}
|
|
890
|
+
when: ${Math.floor(Date.now()/1e3)}
|
|
891
|
+
`;await Gi(e,r)},"writeFishHistory");var YC=Object.defineProperty,dr=b((t,e)=>YC(t,"name",{value:e,configurable:!0}),"i$5");const Qa=dr(t=>{const e=new Set;for(const r of Object.values(t.projects))for(const n of Object.keys(r.targets??{}))e.add(n);return[...e].sort()},"collectAvailableTargets"),KC=dr(t=>{const e=new Map;for(const r of t.values())for(const[n,o]of Object.entries(r))for(const i of o.aliases??[])e.has(i)||e.set(i,n);return e},"buildAliasMap"),XC=dr((t,e)=>e.get(t)??t,"resolveTargetAlias"),QC=dr((t,e)=>{if(t.length===0)return e.length;if(e.length===0)return t.length;const r=[];for(let n=0;n<=e.length;n++)r[n]=[n];for(let n=0;n<=t.length;n++)r[0][n]=n;for(let n=1;n<=e.length;n++)for(let o=1;o<=t.length;o++){const i=e[n-1]===t[o-1]?0:1;r[n][o]=Math.min(r[n-1][o]+1,r[n][o-1]+1,r[n-1][o-1]+i)}return r[e.length][t.length]},"levenshtein"),ZC=dr((t,e,r=3)=>su(t,e,1,r)[0],"suggestTarget"),su=dr((t,e,r=3,n=3)=>{const o=[];for(const i of e){const s=QC(t.toLowerCase(),i.toLowerCase());s<=n&&o.push({distance:s,name:i})}return o.sort((i,s)=>i.distance-s.distance||i.name.localeCompare(s.name)),o.slice(0,r).map(i=>i.name)},"suggestTargets"),e1=dr(t=>t.length===0?" (no targets found)":t.map(e=>` - ${e}`).join(`
|
|
892
|
+
`),"formatTargetList"),t1=dr(async t=>{if(t.length===0||!process.stdin.isTTY||!process.stdout.isTTY)return;const e=dt({input:process.stdin,output:process.stdout});try{process.stdout.write(`Available targets:
|
|
893
|
+
`);for(const[o,i]of t.entries())process.stdout.write(` ${String(o+1).padStart(2," ")}. ${i}
|
|
894
|
+
`);process.stdout.write(`
|
|
895
|
+
`);const r=(await new Promise(o=>{e.question("Select a target (number or name, blank to cancel): ",o)})).trim();if(r.length===0)return;const n=Number.parseInt(r,10);return Number.isFinite(n)&&n>=1&&n<=t.length?t[n-1]:t.includes(r)?r:ZC(r,t)}finally{e.close()}},"promptTargetInteractively");var r1=Object.defineProperty,Ts=b((t,e)=>r1(t,"name",{value:e,configurable:!0}),"i$4");const n1=Ts(t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),"formatValue"),o1=Ts((t,e,r)=>e==="_"?`${t}${Array.isArray(r)?r.join(" "):String(r)}`:`${t}--${e}=${n1(r)}`,"formatFlags"),Es=Ts((t,e,r)=>{const n=new Set(new Set(r.map(m=>m.target.target))),o=new Set(new Set(r.map(m=>m.target.project))),i=e.filter(m=>n.has(m)),s=t.filter(m=>o.has(m)),a=r.length-s.length*i.length,c=i.length===1?"target":"targets",d=i.join(", ");let p;p=s.length===1?`project ${s[0]}`:`${s.length} projects`;let g=`${c} ${d} for ${p}`;return a>0&&(g+=` and ${a} ${a===1?"task":"tasks"} ${a===1?"it depends":"they depend"} on`),g},"formatTargetsAndProjects");var i1=Object.defineProperty,s1=b((t,e)=>i1(t,"name",{value:e,configurable:!0}),"c$8");const a1={error:"red",info:"white",success:"green"},Ti=s1(({children:t,title:e,variant:r})=>{const n=a1[r];return f(h,{flexDirection:"column",children:[f(h,{gap:1,children:[u(l,{bold:!0,inverse:!0,children:" VIS "}),u(l,{bold:!0,color:n,children:"•"}),u(l,{children:e})]}),t]})},"Header");var c1=Object.defineProperty,l1=b((t,e)=>c1(t,"name",{value:e,configurable:!0}),"s$8");const au=l1(({cached:t,failed:e,failedIds:r,projectNames:n,skippedIds:o,succeeded:i,targets:s,tasks:a,took:c})=>{const d=Es(n,s,a);if(e===0&&(!o||o.length===0)){const p=t>0?` (${t} read from cache)`:"";return u(Fs,{children:b(()=>u(Ti,{title:`Successfully ran ${d}`,variant:"success",children:f(h,{flexDirection:"column",paddingLeft:2,children:[f(l,{children:[u(l,{color:"green",children:Eo})," ",i+t," ","tasks completed",p?u(l,{dimColor:!0,children:p}):null]}),f(l,{dimColor:!0,children:[" ","Took",c]})]})}),"children")})}return u(Fs,{children:b(()=>u(Ti,{title:`Ran ${d}`,variant:"error",children:f(h,{flexDirection:"column",paddingLeft:2,children:[o&&o.length>0&&f(h,{flexDirection:"column",children:[f(l,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(p=>f(l,{dimColor:!0,children:[" - ",p]},p)),u(l,{})]}),e>0&&f(h,{flexDirection:"column",children:[f(l,{children:[u(l,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),r.map(p=>f(l,{children:[" ",u(l,{color:"red",children:Nn})," ",p]},p)),u(l,{})]}),f(l,{dimColor:!0,children:[" ","Took",c]})]})}),"children")})},"CommandSummary");var d1=Object.defineProperty,ui=b((t,e)=>d1(t,"name",{value:e,configurable:!0}),"u$6");class wo{static{b(this,"TaskStore")}static{ui(this,"TaskStore")}#e;#t=new Set;#n=new Map;constructor(e){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retryTaskId:null,rows:e.map(r=>({status:"pending",taskId:r.id})),selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,viewMode:"list"}}getSnapshot=ui(()=>this.#e,"getSnapshot");subscribe=ui(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");startTasks(e){const r=[...this.#e.rows];for(const n of e){const o=r.findIndex(i=>i.taskId===n.id);o!==-1&&(r[o]={...r[o],elapsed:0,status:"running"},this.#n.set(n.id,process.hrtime()))}this.#r({...this.#e,rows:r})}endTasks(e){const r=[...this.#e.rows];let{cached:n,completed:o,failed:i,succeeded:s}=this.#e;const a=new Map(this.#e.outputs);for(const d of e){const p=r.findIndex(g=>g.taskId===d.task.id);switch(p!==-1&&(r[p]={...r[p],duration:d.startTime&&d.endTime?d.endTime-d.startTime:void 0,status:d.status}),o++,d.status){case"failure":{i++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{n++;break}case"success":{s++;break}}d.terminalOutput&&!a.has(d.task.id)&&a.set(d.task.id,d.terminalOutput),this.#n.delete(d.task.id)}let{selectedIndex:c}=this.#e;if(i>this.#e.failed){const d=r.findIndex(p=>p.status==="failure");d!==-1&&(c=d)}this.#r({...this.#e,cached:n,completed:o,failed:i,outputs:a,rows:r,selectedIndex:c,succeeded:s})}static#o=256*1024;addOutput(e,r){if(!r.trim())return;let n=(this.#e.outputs.get(e)??"")+r;n.length>wo.#o&&(n=n.slice(-wo.#o)),this.#e.outputs.set(e,n),this.#r({...this.#e})}setOutput(e,r){this.#e.outputs.set(e,r),this.#r({...this.#e})}markDone(){this.#r({...this.#e,done:!0,endTime:Date.now()})}tick(){if(this.#n.size===0)return;let e=!1;const r=[...this.#e.rows];for(let n=0;n<r.length;n++){const o=r[n];if(o.status==="running"){const i=this.#n.get(o.taskId);if(i){const s=process.hrtime(i),a=s[0]*1e3+s[1]/1e6;r[n]={...o,elapsed:a},e=!0}}}e&&this.#r({...this.#e,rows:r})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:e})}setFilter(e){this.#r({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#r({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,r){const n=[...this.#e.pinnedTaskIds];n[e]=r,this.#r({...this.#e,pinnedTaskIds:n})}clearPins(){this.#r({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const r=[...this.#e.rows],n=r.findIndex(a=>a.taskId===e);let{completed:o,failed:i,succeeded:s}=this.#e;if(n!==-1){const a=r[n].status;a==="failure"?(i=Math.max(0,i-1),o=Math.max(0,o-1)):a==="success"&&(s=Math.max(0,s-1),o=Math.max(0,o-1)),r[n]={...r[n],elapsed:0,status:"running"},this.#n.set(e,process.hrtime())}this.#r({...this.#e,completed:o,done:!1,endTime:null,failed:i,interactiveMode:!1,retryTaskId:e,rows:r,succeeded:s})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#r({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#r({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#r({...this.#e,viewMode:e})}setStatusFilter(e){this.#r({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#n.clear(),this.#r({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,rows:this.#e.rows.map(e=>({status:"pending",taskId:e.taskId})),startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#r({...this.#e,rerunRequested:!1})}#r(e){this.#e=e;for(const r of this.#t)try{r()}catch{}}}var u1=Object.defineProperty,Ct=b((t,e)=>u1(t,"name",{value:e,configurable:!0}),"t$5");const p1={d:Ct(()=>" d","d"),future:"in %s",h:Ct(()=>" h","h"),m:Ct(()=>" m","m"),mo:Ct(()=>" mo","mo"),ms:Ct(()=>" ms","ms"),past:"%s ago",s:Ct(()=>" s","s"),w:Ct(()=>" w","w"),y:Ct(()=>" y","y")},cu={delimiter:" ",language:p1,largest:2,round:!0,spacer:"",units:["h","m","s","ms"]};Ct(t=>{const e=t[0]*1e3+t[1]/1e6;return Gc(e,cu)},"formatHrtime");const Cr=Ct(t=>Gc(t,cu),"formatMs");var f1=Object.defineProperty,_n=b((t,e)=>f1(t,"name",{value:e,configurable:!0}),"n$3");const Tn=_n(t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache","isCacheStatus"),Gn=_n(t=>{switch(t){case"failure":return{color:"red",icon:Nn};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Eo};case"skipped":return{color:"gray",icon:Zt};default:return{color:"gray",icon:"?"}}},"getStatusInfo"),lu=_n(t=>{const{color:e,icon:r}=Gn(t);return Oe(X.createElement(l,{color:e},r),{columns:10}).trim()},"getStatusIcon"),g1=_n(t=>{const{color:e,icon:r}=Gn(t);switch(t){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return Oe(X.createElement(l,null,X.createElement(l,{color:e},r)," ",X.createElement(l,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return Oe(X.createElement(l,null,X.createElement(l,{dimColor:!0},r)," ",X.createElement(l,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return Oe(X.createElement(l,{color:e},r),{columns:10}).trim()}},"getStatusPrefix"),h1=_n((t,e,r)=>{const n=r.trim();if(!n)return;const o=`
|
|
896
|
+
`;if(process.env.GITHUB_ACTIONS==="true")process.stdout.write(`::group::${lu(e)} ${t}${o}`),process.stdout.write(n+o),process.stdout.write(`::endgroup::${o}`);else{const i=process.stdout.columns||80,s=Oe(X.createElement(l,{dimColor:!0},Zt.repeat(i)),{columns:i}).trim(),a=g1(e),c=Oe(X.createElement(l,{bold:!0},t),{columns:i}).trim();process.stdout.write(`${s}${o}`),process.stdout.write(`${a} ${c}${o}`),process.stdout.write(n+o),process.stdout.write(`${s}${o}`)}},"logCommandOutputCI");var m1=Object.defineProperty,du=b((t,e)=>m1(t,"name",{value:e,configurable:!0}),"c$7");const y1=du(t=>t==="running"?{color:"white",icon:"•"}:t==="pending"?{color:"gray",icon:"·"}:Gn(t),"getDisplayInfo"),Za=du(({duration:t,focused:e,interactiveMode:r,output:n,scrollRef:o,showFullscreenHint:i,status:s,taskId:a})=>{const c=s??"pending",{icon:d}=y1(c),p=e?"bold":"single",g=c==="failure"?"red":c==="success"||Tn(c)?e?"green":"gray":c==="running"?e?"white":"cyan":e?"white":"gray",m=a?`${d} ${a}`:void 0,y=t===void 0?void 0:Cr(t),v=a?r?"Esc cancel | Enter send":e&&c==="running"&&i?"⏎ FULLSCREEN i INPUT":e&&c==="running"?"i INPUT":e&&i?"<enter> full screen":e?void 0:"<tab> or <enter> to focus":void 0;if(!a)return f(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[u(l,{dimColor:!0,children:"Select a task to view output"}),u(l,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const k=n?n.split(`
|
|
897
|
+
`).map($=>$.replace(/\r$/,"")):[];return!n&&(c==="running"||c==="pending")?u(h,{borderBottomTitle:v,borderColor:g,borderStyle:p,borderTopRightTitle:y,borderTopTitle:m,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:u(h,{alignItems:"center",flexGrow:1,justifyContent:"center",children:u(l,{dimColor:!0,children:"Waiting for task output..."})})}):f(h,{borderBottomTitle:v,borderColor:r?"yellow":g,borderStyle:p,borderTopRightTitle:y,borderTopTitle:m,flexDirection:"column",flexGrow:1,children:[u(h,{flexGrow:1,flexShrink:1,paddingY:1,children:u(qr,{flexGrow:1,followOutput:!0,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:k.map(($,x)=>u(l,{children:$},String(x)))})}),r&&u(h,{flexShrink:0,justifyContent:"center",paddingX:1,children:u(l,{bold:!0,color:"yellow",children:"INTERACTIVE — keystrokes forwarded to task — Esc to exit"})})]})},"OutputPanel");var v1=Object.defineProperty,Jo=b((t,e)=>v1(t,"name",{value:e,configurable:!0}),"u$5");const uu=6,pu=8,fu=10,w1=Jo(t=>t==="running"||t==="pending"?tl:t==="local-cache"||t==="local-cache-kept-existing"?"Local":t==="remote-cache"?"Remote":Zt,"getCacheLabel"),ec=Jo((t,e)=>e[0]===t?"[1]":e[1]===t?"[2]":"","getPinLabel"),tc=Jo(({compact:t,isSelected:e,pinLabel:r,row:n})=>{const{status:o,taskId:i}=n,s=e?">":" ";let a;if(o==="running")a=f(l,{bold:!0,color:"white",children:[" ",u(Vi,{type:"dots"})," "]});else if(o==="pending")a=u(l,{bold:!0,color:"gray",children:" · "});else{const{color:d,icon:p}=Gn(o);a=f(l,{bold:!0,color:d,children:[" ",p," "]})}let c=tl;return o!=="running"&&o!=="pending"?c=n.duration===void 0?Zt:Cr(n.duration):o==="running"&&n.elapsed!==void 0&&(c=Cr(n.elapsed)),f(h,{children:[u(l,{children:s}),u(h,{width:uu,children:a}),f(h,{flexGrow:1,children:[u(l,{bold:e,inverse:e,children:i}),r?u(l,{dimColor:!0,children:` ${r}`}):null]}),!t&&u(h,{justifyContent:"flex-end",width:pu,children:u(l,{dimColor:!Tn(o),children:w1(o)})}),!t&&u(h,{justifyContent:"flex-end",width:fu,children:u(l,{dimColor:o==="pending",children:c})})]})},"TaskListRow"),rc=Jo(({compact:t,filterActive:e,filterText:r,focused:n,headerStatus:o,parallelSlots:i=3,pinnedTaskIds:s,rows:a,scrollRef:c,selectedIndex:d,title:p})=>{const g=o==="error"?"red":o==="success"?"green":n?"white":"gray",m=a[d]?.taskId,y=a.filter($=>$.status==="running"),v=y.length>0||a.some($=>$.status==="pending"),k=[];if(v)for(let $=0;$<i;$++){const x=y[$];x?k.push(u(tc,{compact:t,isSelected:x.taskId===m,pinLabel:ec(x.taskId,s),row:x},`par-${x.taskId}`)):k.push(f(h,{children:[u(l,{children:" "}),u(h,{width:uu,children:u(l,{bold:!0,color:"gray",children:" · "})}),u(l,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String($)}`))}return f(h,{borderColor:g,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(h,{flexShrink:0,gap:1,paddingX:1,children:[u(l,{bold:!0,inverse:!0,children:" VIS "}),u(l,{children:p}),!t&&f(h,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[u(h,{justifyContent:"flex-end",width:pu,children:u(l,{dimColor:!0,children:"Cache"})}),u(h,{justifyContent:"flex-end",width:fu,children:u(l,{dimColor:!0,children:"Duration"})})]})]}),u(qr,{flexGrow:1,flexShrink:1,paddingLeft:1,paddingY:1,ref:c,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:a.map($=>u(tc,{compact:t,isSelected:$.taskId===m,pinLabel:ec($.taskId,s),row:$},$.taskId))}),v&&u(h,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingLeft:1,paddingY:1,children:k}),e&&f(h,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[u(l,{bold:!0,color:"white",children:"/ "}),u(l,{children:r}),u(l,{inverse:!0,children:" "})]})]})},"TaskListPanel");var k1=Object.defineProperty,b1=b((t,e)=>k1(t,"name",{value:e,configurable:!0}),"y$1");const nc=40,oc=10,ic=100,$1=b1(({autoExitSeconds:t,parallelSlots:e,projectNames:r,stdinRegistry:n,store:o,targets:i,tasks:s})=>{const{exit:a}=Hr(),{columns:c,rows:d}=zr(),p=On(o.subscribe,o.getSnapshot),[g,m]=ve(!1),y=Ve(null),v=Ve(null),k=Ve(null),[$,x]=ve(!1),E=Ve({list:0,splitList:0,splitOutput:0}),A=It(()=>{p.viewMode==="list"?E.current.list=v.current?.getScrollOffset()??0:p.viewMode==="split"&&(E.current.splitList=v.current?.getScrollOffset()??0,E.current.splitOutput=k.current?.getScrollOffset()??0)},[p.viewMode]),L=It(D=>{setTimeout(()=>{if(D==="list"){const O=E.current.list;v.current?.scrollTo(O)}else if(D==="split"){const O=E.current.splitList;O>0?v.current?.scrollTo(O):v.current?.scrollTo(Math.max(0,o.getSnapshot().selectedIndex-2)),k.current?.scrollTo(E.current.splitOutput)}},0)},[o]),I=Ve(!1);Rt(()=>{p.done&&!I.current&&(I.current=!0,t>0&&x(!0)),!p.done&&I.current&&(I.current=!1,x(!1))},[p.done,t]);const M=At(()=>{let D=p.rows;if(p.statusFilter!=="all"&&(D=D.filter(O=>p.statusFilter==="failed"?O.status==="failure":p.statusFilter==="running"?O.status==="running"||O.status==="pending":p.statusFilter==="passed"?O.status==="success"||Tn(O.status):!0)),p.filterText){const O=p.filterText.toLowerCase();D=D.filter(z=>z.taskId.toLowerCase().includes(O))}return D},[p.rows,p.filterText,p.statusFilter]),F=At(()=>p.rows.filter(D=>D.status==="running").length,[p.rows]),_=(M[p.selectedIndex]??null)?.taskId??null,N=p.pinnedTaskIds[0]??_,C=N?p.rows.find(D=>D.taskId===N):null,j=N?p.outputs.get(N)??"":"",R=Es(r,i,s),V=p.done?`Completed ${R} (${Cr((p.endTime??Date.now())-p.startTime)})`:`Running ${R}...`,P=p.done?p.failed>0?"error":"success":"running",B=It(D=>{v.current?.scrollTo(Math.max(0,D-2))},[]);if(Rt(()=>{p.interactiveMode&&C?.status!=="running"&&o.setInteractiveMode(!1)},[p.interactiveMode,C?.status,o]),Rt(()=>{if(!N)return;let D=c;p.viewMode==="split"&&c>=ic?D=c-Math.floor(c*.4)-2:(p.viewMode==="split"||p.viewMode==="fullscreen")&&(D=c-2);const O=Math.max(1,d-4);n.get(N)?.resize?.(D,O)},[c,d,p.viewMode,N]),mt((D,O)=>{if(O.escape){o.setInteractiveMode(!1);return}if(!N)return;const z=n.get(N);if(!z){o.setInteractiveMode(!1);return}if(O.return)z.write("\r");else if(O.upArrow)z.write("\x1B[A");else if(O.downArrow)z.write("\x1B[B");else if(O.rightArrow)z.write("\x1B[C");else if(O.leftArrow)z.write("\x1B[D");else if(O.backspace)z.write("");else if(O.delete)z.write("\x1B[3~");else if(O.tab)z.write(" ");else if(O.home)z.write("\x1B[H");else if(O.end)z.write("\x1B[F");else if(O.pageUp)z.write("\x1B[5~");else if(O.pageDown)z.write("\x1B[6~");else if(O.ctrl&&D){const me=D.toUpperCase().codePointAt(0);me!==void 0&&me>=65&&me<=90&&z.write(String.fromCodePoint(me-64))}else D&&z.write(D)},{isActive:p.interactiveMode}),mt((D,O)=>{if(D==="c"&&O.ctrl){a();return}if(!$){if(g){O.escape||D==="?"?m(!1):D==="q"?(m(!1),x(!0)):O.downArrow||D==="j"?y.current?.scrollBy(1):O.upArrow||D==="k"?y.current?.scrollBy(-1):O.pageDown?y.current?.scrollBy(5):O.pageUp?y.current?.scrollBy(-5):O.home?y.current?.scrollToTop():O.end&&y.current?.scrollToBottom();return}if(D==="?"){m(!0);return}if(D==="q"){x(!0);return}if(D==="r"&&p.done){o.requestRerun();return}if(D==="R"&&p.done){const z=M[p.selectedIndex];z?.status==="failure"&&o.requestRetry(z.taskId);return}if(D==="F"&&!p.filterActive){const z=["all","failed","running","passed"],me=z.indexOf(p.statusFilter);o.setStatusFilter(z[(me+1)%z.length]);return}if(p.filterActive){if(O.escape){o.setFilterActive(!1);return}if(O.return){o.setFilterActive(!1);return}if(O.backspace){o.setFilter(p.filterText.slice(0,-1));return}if(D&&!O.ctrl&&!O.meta){o.setFilter(p.filterText+D);return}return}if(D==="i"&&C?.status==="running"&&(p.viewMode==="fullscreen"||p.viewMode==="split"&&p.focusedPanel==="output")){o.setInteractiveMode(!0);return}if(p.viewMode==="fullscreen"){if(O.escape){o.setViewMode("split"),L("split");return}if(O.downArrow||D==="j"){k.current?.scrollBy(1);return}if(O.upArrow||D==="k"){k.current?.scrollBy(-1);return}if(O.pageDown||O.ctrl&&D==="d"){k.current?.scrollBy(12);return}if(O.pageUp||O.ctrl&&D==="u"){k.current?.scrollBy(-12);return}if(O.home){k.current?.scrollToTop();return}if(O.end){k.current?.scrollToBottom();return}return}if(p.viewMode==="split"){if(O.tab){const z=p.focusedPanel==="tasks"?"output":"tasks";o.setFocusedPanel(z);return}if(p.focusedPanel==="output"){if(O.escape){o.setFocusedPanel("tasks");return}if(O.return){A(),o.setViewMode("fullscreen");return}if(O.downArrow||D==="j"){k.current?.scrollBy(1);return}if(O.upArrow||D==="k"){k.current?.scrollBy(-1);return}if(O.pageDown||O.ctrl&&D==="d"){k.current?.scrollBy(12);return}if(O.pageUp||O.ctrl&&D==="u"){k.current?.scrollBy(-12);return}if(O.home){k.current?.scrollToTop();return}if(O.end){k.current?.scrollToBottom();return}return}if(O.escape){o.setViewMode("list"),L("list");return}if(O.return){o.setFocusedPanel("output");return}}if(p.viewMode==="list"||p.viewMode==="split"&&p.focusedPanel==="tasks"){if(O.downArrow||D==="j"){const z=Math.min(p.selectedIndex+1,Math.max(0,M.length-1));o.setSelectedIndex(z),B(z);return}if(O.upArrow||D==="k"){const z=Math.max(p.selectedIndex-1,0);o.setSelectedIndex(z),B(z);return}if(O.return&&p.viewMode==="list"){A(),E.current.splitList=0,E.current.splitOutput=0,o.setViewMode("split"),o.setFocusedPanel("output"),L("split");return}if(D==="/"){o.setFilterActive(!0);return}if(D==="1"&&_){o.pinTask(0,_);return}if(D==="2"&&_){o.pinTask(1,_);return}if(D==="0"){o.clearPins();return}O.escape&&p.filterText&&o.setFilter("")}}},{isActive:!p.interactiveMode}),c<nc||d<oc)return u(h,{alignItems:"center",height:d,justifyContent:"center",width:c,children:f(l,{color:"yellow",children:["Terminal too small (",c,"x",d,"). Minimum:"," ",nc,"x",oc]})});const q=f(h,{gap:1,children:[p.succeeded>0&&f(l,{bold:!0,color:"green",children:["✓"," ",p.succeeded]}),p.failed>0&&f(l,{bold:!0,color:"red",children:["✗"," ",p.failed]}),F>0&&f(l,{color:"cyan",children:["◷"," ",F]}),f(l,{dimColor:!0,children:[p.rows.length," ","total"]}),p.statusFilter!=="all"&&f(l,{color:"yellow",children:["[",p.statusFilter,"]"]})]});let J;if(p.viewMode==="fullscreen")J=[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"Esc"}),u(l,{dimColor:!0,children:"BACK"})]},"esc"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"↑↓"}),u(l,{dimColor:!0,children:"SCROLL"})]},"scroll"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"^u ^d"}),u(l,{dimColor:!0,children:"PAGE"})]},"page"),...C?.status==="running"?[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"i"}),u(l,{dimColor:!0,children:"INPUT"})]},"i")]:[],f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"q"}),u(l,{dimColor:!0,children:"QUIT"})]},"q")];else if(p.done){const D=M[p.selectedIndex]?.status==="failure";J=[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"q"}),u(l,{dimColor:!0,children:"QUIT"})]},"q"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"r"}),u(l,{dimColor:!0,children:"RERUN"})]},"r"),...D?[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"R"}),u(l,{dimColor:!0,children:"RETRY"})]},"R")]:[],f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"?"}),u(l,{dimColor:!0,children:"HELP"})]},"?"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"↑↓"}),u(l,{dimColor:!0,children:"NAV"})]},"nav"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"F"}),u(l,{dimColor:!0,children:"FILTER"})]},"F"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"⏎"}),u(l,{dimColor:!0,children:p.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else p.viewMode==="split"&&p.focusedPanel==="output"?J=[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"q"}),u(l,{dimColor:!0,children:"QUIT"})]},"q"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"Esc"}),u(l,{dimColor:!0,children:"BACK"})]},"esc"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"↑↓"}),u(l,{dimColor:!0,children:"SCROLL"})]},"scroll"),...C?.status==="running"?[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"i"}),u(l,{dimColor:!0,children:"INPUT"})]},"i")]:[],f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"⏎"}),u(l,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"Tab"}),u(l,{dimColor:!0,children:"PANEL"})]},"tab"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"?"}),u(l,{dimColor:!0,children:"HELP"})]},"?")]:J=[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"q"}),u(l,{dimColor:!0,children:"QUIT"})]},"q"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"?"}),u(l,{dimColor:!0,children:"HELP"})]},"?"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"↑↓"}),u(l,{dimColor:!0,children:"NAV"})]},"nav"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"/"}),u(l,{dimColor:!0,children:"FILTER"})]},"/"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"F"}),u(l,{dimColor:!0,children:"STATUS"})]},"F"),f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"⏎"}),u(l,{dimColor:!0,children:p.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...p.viewMode==="split"?[f(h,{gap:1,children:[u(l,{bold:!0,color:"white",children:"Tab"}),u(l,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const ce=f(h,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[u(h,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:J}),u(h,{flexShrink:0,paddingX:1,children:q})]}),le=f(wr,{backgroundColor:"#1e1e1e",footer:f(l,{dimColor:!0,children:[u(l,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",u(l,{bold:!0,color:"white",children:"?"}),"/",u(l,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:y,title:"KEYBOARD SHORTCUTS",visible:g,width:52,children:[f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"NAVIGATION"})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),u(l,{dimColor:!0,children:" Move up"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),u(l,{dimColor:!0,children:" Move down"})]})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Tab"]}),u(l,{dimColor:!0,children:" Switch panel (split)"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Esc"]}),u(l,{dimColor:!0,children:" Back / close"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Enter"]}),u(l,{dimColor:!0,children:" Show output / fullscreen"})]})]}),f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"VIEWS"})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Enter"]}),f(l,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Esc"]}),f(l,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"ACTIONS"})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","/"]}),u(l,{dimColor:!0,children:" Filter by text"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","F"]}),u(l,{dimColor:!0,children:" Filter by status"})]})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","1"]}),u(l,{dimColor:!0,children:"/"}),u(l,{bold:!0,color:"white",children:"2"}),u(l,{dimColor:!0,children:" Pin to output pane"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","0"]}),u(l,{dimColor:!0,children:" Clear pins"})]})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","r"]}),u(l,{dimColor:!0,children:" Rerun all (done)"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","R"]}),u(l,{dimColor:!0,children:" Retry failed task"})]})]}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","i"]}),u(l,{dimColor:!0,children:" Interactive input (running task)"})]})]}),f(h,{flexDirection:"column",marginBottom:1,children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"SCROLLING"}),u(l,{dimColor:!0,children:" (output panel)"})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),u(l,{dimColor:!0,children:" Scroll up"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),u(l,{dimColor:!0,children:" Scroll down"})]})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","^u"]}),u(l,{dimColor:!0,children:" Page up"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","^d"]}),u(l,{dimColor:!0,children:" Page down"})]})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","Home"]}),u(l,{dimColor:!0,children:" Top"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","End"]}),u(l,{dimColor:!0,children:" Bottom"})]})]})]}),f(h,{flexDirection:"column",children:[f(h,{marginBottom:1,children:[u(l,{dimColor:!0,children:"── "}),u(l,{bold:!0,color:"white",children:"GENERAL"})]}),f(h,{children:[u(h,{width:24,children:f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","q"]}),u(l,{dimColor:!0,children:" Quit"})]})}),f(l,{children:[f(l,{bold:!0,color:"white",children:[" ","?"]}),u(l,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ke=u(xr,{autoExitSeconds:t>0?t:3,onCancel:b(()=>{x(!1)},"onCancel"),visible:$});if(p.viewMode==="fullscreen")return f(h,{flexDirection:"column",height:d,width:c,children:[u(h,{flexGrow:1,children:u(Za,{duration:C?.duration??C?.elapsed,focused:!0,interactiveMode:p.interactiveMode,output:j,scrollRef:k,status:C?.status,taskId:N})}),ce,ke,le]});if(p.viewMode==="split"){const D=c>=ic,O=u(rc,{compact:!0,filterActive:p.filterActive,filterText:p.filterText,focused:p.focusedPanel==="tasks",headerStatus:P,parallelSlots:e,pinnedTaskIds:p.pinnedTaskIds,rows:M,scrollRef:v,selectedIndex:p.selectedIndex,title:V}),z=u(Za,{duration:C?.duration??C?.elapsed,focused:p.focusedPanel==="output",interactiveMode:p.interactiveMode,output:j,scrollRef:k,showFullscreenHint:!0,status:C?.status,taskId:N});if(D){const Te=Math.floor(c*.4);return f(h,{flexDirection:"column",height:d,width:c,children:[f(h,{flexDirection:"row",flexGrow:1,children:[u(h,{width:Te,children:O}),u(h,{flexGrow:1,children:z})]}),ce,ke,le]})}const me=Math.floor(d*.45);return f(h,{flexDirection:"column",height:d,width:c,children:[u(h,{height:me,children:O}),u(h,{flexGrow:1,children:z}),ce,ke,le]})}return f(h,{flexDirection:"column",height:d,width:c,children:[u(h,{flexGrow:1,children:u(rc,{filterActive:p.filterActive,filterText:p.filterText,focused:!0,headerStatus:P,parallelSlots:e,pinnedTaskIds:p.pinnedTaskIds,rows:M,scrollRef:v,selectedIndex:p.selectedIndex,title:V})}),ce,ke,le]})},"VisTaskRunnerApp");var S1=Object.defineProperty,Nr=b((t,e)=>S1(t,"name",{value:e,configurable:!0}),"n$2");const x1=Nr(t=>{const{args:e,autoExit:r=!1,projectNames:n,stdinRegistry:o,tasks:i}=t,s=new wo(i),a=typeof e.parallel=="number"?e.parallel:3,c=r===!0?3:typeof r=="number"?r:0;let d,p;const g=new Promise(A=>{p=A});let m;const y=Nr(()=>{m&&(clearInterval(m),m=void 0)},"cleanup"),v=Nr(()=>{if(o){for(const A of o.values())A.kill?.();o.clear()}},"killAllPtyProcesses"),k=Nr(()=>{y(),E(),v(),process.stdout.write("\x1B[?1049l\x1B[?25h"),d?.cleanup(),process.exit(1)},"onSignal"),$=Nr(()=>{const A=s.getSnapshot(),L=Cr(Date.now()-A.startTime),I=A.rows.filter(_=>_.status==="failure").map(_=>_.taskId),M=process.stdout.columns||80;process.stdout.write(`
|
|
898
|
+
`);for(const _ of A.rows){const{status:N,taskId:C}=_,j=Gn(N);let R="";switch(N){case"local-cache":case"local-cache-kept-existing":{R=" [local cache]";break}case"remote-cache":{R=" [remote cache]";break}case"skipped":{R=" [skipped]";break}}const V=Oe(X.createElement(l,null," ",X.createElement(l,{color:j.color},j.icon),` vis run ${C}`,R?X.createElement(l,{dimColor:!0},` ${R}`):null),{columns:M});process.stdout.write(`${V}
|
|
800
899
|
`)}process.stdout.write(`
|
|
801
|
-
`);const
|
|
802
|
-
`),
|
|
803
|
-
`,
|
|
804
|
-
|
|
805
|
-
`);const
|
|
806
|
-
`).map(
|
|
807
|
-
`);process.stdout.write(`${
|
|
808
|
-
`)}}},"printExitSummary");let
|
|
900
|
+
`);const F=Oe(X.createElement(au,{cached:A.cached,failed:A.failed,failedIds:I,projectNames:n,succeeded:A.succeeded,targets:e.targets,tasks:i,took:L}),{columns:M});if(process.stdout.write(`${F}
|
|
901
|
+
`),I.length>0)for(const _ of I){const N=A.outputs.get(_);if(N?.trim()){const C=Oe(X.createElement(l,null,`
|
|
902
|
+
`,X.createElement(l,{bold:!0,color:"red"},` ${Nn} vis run ${_}`)),{columns:M});process.stdout.write(`${C}
|
|
903
|
+
|
|
904
|
+
`);const j=N.trim().split(`
|
|
905
|
+
`).map(R=>` ${R}`).join(`
|
|
906
|
+
`);process.stdout.write(`${j}
|
|
907
|
+
`)}}},"printExitSummary");let x;const E=Nr(()=>{x&&(clearInterval(x),x=void 0)},"clearKeepAlive");return{lifeCycle:{endCommand(){y(),s.markDone(),x||(x=setInterval(()=>{},1e3)),process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume())},endTasks(A){s.endTasks(A)},printTaskTerminalOutput(A,L,I){s.getSnapshot().outputs.has(A.id)||s.addOutput(A.id,I)},startCommand(){process.on("SIGINT",k),process.on("SIGTERM",k),x||(x=setInterval(()=>{},1e3)),process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume()),d=Ut(X.createElement($1,{autoExitSeconds:c,parallelSlots:a,projectNames:n,stdinRegistry:o??new Map,store:s,targets:e.targets,tasks:i}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),d.waitUntilExit().then(()=>{E(),v(),process.removeListener("SIGINT",k),process.removeListener("SIGTERM",k),$(),p()},()=>{E(),v(),process.removeListener("SIGINT",k),process.removeListener("SIGTERM",k),p()})},startTasks(A){s.startTasks(A),m||(m=setInterval(()=>{s.tick()},100))}},renderIsDone:g,store:s}},"createDynamicOutputRenderer");var C1=Object.defineProperty,j1=b((t,e)=>C1(t,"name",{value:e,configurable:!0}),"m$4");class T1{static{b(this,"StaticOutputLifeCycle")}static{j1(this,"StaticOutputLifeCycle")}#e;#t;#n;#o=[];#r=[];#i=new Map;#s;#a=0;constructor(e){this.#e=e.projectNames,this.#t=e.args.targets,this.#n=e.tasks,this.#s=e.logReporter}startCommand(){this.#a=Date.now();const e=process.stdout.columns||80,r=`Running ${Es(this.#e,this.#t,this.#n)}`,n=Oe(X.createElement(Ti,{title:r,variant:"info"}),{columns:e});process.stdout.write(n);const o=this.#n[0],i=o?.overrides?Object.entries(o.overrides).filter(([s])=>s!=="command"):[];if(i.length>0){process.stdout.write(`
|
|
809
908
|
With additional flags:
|
|
810
|
-
`);for(const[s,
|
|
909
|
+
`);for(const[s,a]of i)process.stdout.write(`${o1(" ",s,a)}
|
|
910
|
+
`)}process.stdout.write(`
|
|
911
|
+
`)}startTasks(e){const r=process.stdout.columns||80;for(const n of e){const o=Oe(X.createElement(l,null,X.createElement(l,{dimColor:!0},">"),` ${n.id}`),{columns:r});process.stdout.write(`${o}
|
|
912
|
+
`)}}endTasks(e){const r=process.stdout.columns||80;for(const n of e){this.#i.set(n.task.id,n),n.status==="failure"?this.#o.push(n):Tn(n.status)&&this.#r.push(n);const o=lu(n.status),i=n.startTime&&n.endTime?` (${Cr(n.endTime-n.startTime)})`:"",s=Tn(n.status)?" [cache]":"",a=Oe(X.createElement(l,null,o,` ${n.task.id}`,s?X.createElement(l,{color:"cyan"},s):null,i?X.createElement(l,{dimColor:!0},i):null),{columns:r});process.stdout.write(`${a}
|
|
913
|
+
`)}}printTaskTerminalOutput(e,r,n){if(this.#s){this.#s.printTaskTerminalOutput(e,r,n);return}h1(e.id,r,n)}endCommand(){const e=Cr(Date.now()-this.#a),r=this.#n.filter(i=>!this.#i.has(i.id)).map(i=>i.id);process.stdout.write(`
|
|
914
|
+
`);const n=process.stdout.columns||80,o=Oe(X.createElement(au,{cached:this.#r.length,failed:this.#o.length,failedIds:this.#o.map(i=>i.task.id),projectNames:this.#e,skippedIds:r.length>0?r:void 0,succeeded:this.#i.size-this.#o.length-this.#r.length,targets:this.#t,tasks:this.#n,took:e}),{columns:n});process.stdout.write(`${o}
|
|
915
|
+
`)}}var E1=Object.defineProperty,Lr=b((t,e)=>E1(t,"name",{value:e,configurable:!0}),"l$5");const R1=[/node_modules(?:\/|$)/,/\.git(?:\/|$)/,/\.vis(?:\/|$)/,/\.task-runner(?:\/|$)/],sc=Lr((t,e)=>{const r=new Set,n=new Set;for(const[,s]of t){const a=s.task.hashDetails?.nodes;if(a)for(const c of Object.keys(a))r.add(c),n.add(Nt($e(e,c)))}const o=[...n].sort(),i=[];for(const s of o)i.some(a=>s===a||s.startsWith(`${a}/`))||i.push(s);return{directories:i,files:r}},"collectTrackedWatchTargets"),I1=Lr((t,e,r)=>{const n=new Set;for(const o of t){const i=$e(e,o);for(const s of r)if(i===s||i.startsWith(`${s}/`)){const a=_e(s,i);a.length>0&&n.add(a)}}return o=>{const i=o.replaceAll("\\","/");return n.has(i)}},"createTrackedFileFilter"),A1=Lr(t=>{const e=t.replaceAll("\\","/");return R1.some(r=>r.test(e))},"shouldIgnore"),ac=Lr(t=>{const{debounceMs:e=150,filter:r,onChange:n,paths:o}=t,i=[];let s=new Set,a;const c=Lr(()=>{a=void 0;const d=[...s];s=new Set,d.length!==0&&Promise.resolve(n(d)).catch(p=>{console.error("[vis watch] onChange handler failed:",p)})},"flush");for(const d of o)try{const p=dp(d,{recursive:!0},(g,m)=>{m&&(A1(m)||r&&!r(m)||(s.add(m),a&&clearTimeout(a),a=setTimeout(c,e)))});i.push(p)}catch(p){console.warn(`[vis watch] unable to watch ${d}: ${p.message}`)}return{close:Lr(()=>{a&&clearTimeout(a);for(const d of i)try{d.close()}catch{}},"close")}},"startWatcher");var O1=Object.defineProperty,xe=b((t,e)=>O1(t,"name",{value:e,configurable:!0}),"c$6");const Rs="VIS_AFFECTED_FILES",gu=xe((t,e,r)=>r||!e?t:e.startsWith("/")?e:`${t}/${e}`,"resolveCwd"),cc=xe(async(t,e,r,n)=>{const o=t.map(i=>{const s=i.overrides.command;if(!s)return;const a=i.overrides.visOptions,c=gu(e,i.projectRoot,!!a?.runFromWorkspaceRoot),d=a?.envFile?Kc(c,a.envFile):{},p=r&&(a?.affectedFiles==="env"||a?.affectedFiles==="both")?{[Rs]:r.join(`
|
|
916
|
+
`)}:{};return{command:s,cwd:c,env:{INIT_CWD:n,...d,...p},name:i.id}}).filter(i=>i!==void 0);o.length!==0&&await Bi(o,{killOthers:["failure"]})},"runPersistentTasks"),Ei=256*1024;class P1{static{b(this,"ye")}static{xe(this,"OutputRingBuffer")}#e;#t="";#n=!1;constructor(e){this.#e=e}append(e){this.#t+=e,this.#t.length>this.#e&&(this.#t=this.#t.slice(-this.#e),this.#n=!0)}toString(){return this.#n?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
917
|
+
${this.#t}`:this.#t}}const hu=xe(t=>{const e=t.overrides.visOptions;if(e&&typeof e=="object")return e},"getTaskOptions"),Is=xe(t=>`'${t.replaceAll("'",String.raw`'\''`)}'`,"singleQuoteEscape"),N1=xe((t,e,r)=>{if(!e||e.length===0||r===!1||r===void 0)return t;if(r==="args"||r==="both"){const n=e.map(Is).join(" ");return`${t} ${n}`}return t},"buildAffectedFilesArgs"),mu="visForwardedArgs",M1=xe((t,e)=>{const r=e.overrides[mu];if(!Array.isArray(r)||r.length===0)return t;const n=r.map(Is).join(" ");return`${t} ${n}`},"appendForwardedArgs"),D1=xe(async(t,e,r)=>{if(!e)return r();const n=t.get(e)??Promise.resolve();let o;const i=new Promise(a=>{o=a}),s=n.then(()=>i);t.set(e,s),await n;try{return await r()}finally{o(),t.get(e)===s&&t.delete(e)}},"withMutex"),B1=xe(t=>{let e=Math.max(0,Math.floor(t));return{claim(r){const n=Math.max(0,Math.min(r,e));return e-=n,n},get remaining(){return e}}},"createRetryBudget"),F1=xe((t,e,r)=>{const n=`${e}\0${typeof r=="string"?r:String(r)}`,o=t.get(n);if(o)return o;const i=Kc(e,r);return t.set(n,i),i},"loadEnvFileCached"),lc=xe(t=>{const e=new Map;return async(r,n)=>{const{affectedFiles:o,currentOs:i,initCwd:s,lifeCycle:a,mutexPool:c,onOutput:d,onOutputReplace:p,retryBudget:g,stdinRegistry:m,workspaceRoot:y}=t,v=hu(r),k=gu(y,n.cwd??r.projectRoot,v?.runFromWorkspaceRoot===!0),$=r.overrides.command;if(!$)return{code:0,terminalOutput:`No command configured for ${r.target.project}:${r.target.target}`};const x=M1($,r),E=N1(x,o,v?.affectedFiles),A=Xp(v,i),L=A?`${A} -c ${Is(E)}`:E,I=v?.envFile?F1(e,k,v.envFile):void 0,M={};o&&o.length>0&&(v?.affectedFiles==="env"||v?.affectedFiles==="both")&&(M[Rs]=o.join(`
|
|
918
|
+
`));const F={INIT_CWD:s,...I,...n.env,...M},_=v?.pty===!0,N=!!m,C=N||_;C&&(r.cache=!1);const j=C?void 0:new P1(Ei),R=C?new Ec(Ei):void 0;let V;const P=xe(q=>{if(q.kind==="started"&&(V=q.kill,q.write&&m&&m.set(r.id,{kill:q.kill,resize:q.resize,write:q.write})),(q.kind==="stdout"||q.kind==="stderr")&&q.text!==void 0)if(q.kind==="stdout"?a?.onTaskStdout?.(r,q.text):a?.onTaskStderr?.(r,q.text),R)R.write(q.text),N&&p?.(r.id,R.toString());else{const J=`${q.text}
|
|
919
|
+
`;j.append(J),d?.(r.id,J)}q.kind==="close"&&m&&m.delete(r.id)},"onEvent"),B=xe(async()=>{const q=v?.retryCount??0,J=v?.retryDelay,ce=g?g.claim(q):q,le=typeof v?.timeout=="number"&&v.timeout>0?v.timeout:0;let ke=!1,D;le>0&&(D=setTimeout(()=>{ke=!0,V?.("SIGTERM")},le));let O;try{O=await Bi([{command:L,cwd:k,env:F,name:r.id,...C?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:P,...ce>0?{restart:{delay:J??"exponential",tries:ce}}:{}})}finally{D&&clearTimeout(D)}const z=O.closeEvents[0],me=R?R.toString():j.toString();return ke?{code:124,terminalOutput:`${me}
|
|
920
|
+
[timeout] Task "${r.id}" exceeded ${le}ms budget.
|
|
921
|
+
`}:{code:z?.exitCode??1,terminalOutput:me}},"runOnce");return c?D1(c,v?.mutex,B):B()}},"createConcurrentExecutor"),L1=xe(t=>{if(!t||t.trim().length===0)return;const e=Number.parseFloat(t);return!Number.isFinite(e)||e<=0?{invalid:t}:{value:Math.floor(e)}},"parseEnvConcurrency"),V1=xe(async(t,e)=>{const r=await Hu(t);if(!r){e.warn("No previous run recorded yet. Run a task at least once to populate .task-runner/last-summary.json.");return}const n=(r.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${r.startTime} (${n}s)`),e.info(""),e.info(` Total: ${String(r.stats.total)}`),e.info(` Succeeded: ${String(r.stats.succeeded)}`),e.info(` Cached: ${String(r.stats.cached)}`),e.info(` Failed: ${String(r.stats.failed)}`),e.info(` Skipped: ${String(r.stats.skipped)}`),e.info(""),r.stats.failed>0){const i=r.tasks.filter(s=>s.exitCode!==void 0&&s.exitCode!==0);e.info("Failed tasks:");for(const s of i){const a=s.duration??0;e.info(` × ${s.taskId} (exit ${String(s.exitCode??-1)}, ${a}ms)`)}e.info("")}const o=[...r.tasks].filter(i=>typeof i.duration=="number").sort((i,s)=>(s.duration??0)-(i.duration??0)).slice(0,5);if(o.length>0){e.info("Slowest tasks:");for(const i of o)e.info(` ${i.taskId.padEnd(40)} ${String(i.duration??0).padStart(6)}ms [${i.cacheStatus}]`);e.info("")}},"renderLastRunSummary"),U1={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 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"]],execute:xe(async({argument:t,logger:e,options:r,runtime:n,visConfig:o,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const s=i;if(r.lastDetails===!0){await V1(s,e);return}const a=process.cwd(),{config:c,packageJsons:d,projectOptions:p,workspace:g}=ut(s,o),m=qt(s,g,d);let y=t[0];if(!y){const Y=Qa(g);if(process.stdout.isTTY&&process.stdin.isTTY){const de=await t1(Y);if(!de){e.info("No target selected.");return}y=de,await zC(`vis run ${de}`)}else{e.info("Available targets:"),e.info(""),e.info(e1(Y)),e.info(""),e.info("Usage: vis run <target>");return}}if(c.constraints&&!r.skipConstraints){const Y=Rc(m,c.constraints);if(Y.length>0){for(const de of Y)e.error(`[${de.rule}] ${de.message}`);throw new Error(`${Y.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(r.affected){const Y=[y];r.parallel!==void 0&&Y.push(`--parallel=${String(r.parallel)}`),r.cache||Y.push("--no-cache"),r.query&&Y.push(`--query=${String(r.query)}`),await n.runCommand("affected",{argv:Y});return}const v=await Yc(y,g,process.cwd(),s),k=KC(p),$=XC(v.target,k);$!==v.target&&e.debug?.(`Resolved alias "${v.target}" → "${$}"`);let x=v.projects;const E=t.slice(1).map(String);if(r.projects){const Y=new Set(r.projects.split(",").map(de=>de.trim()));if(x=x.filter(de=>Y.has(de)),x.length===0)throw new Error(`No matching projects found for: ${String(r.projects)}`)}if(r.query&&(x=xo(x,g,r.query),x.length===0)){e.info(`Query "${String(r.query)}" matched no projects.`);return}const A=Wi(),L=process.env[Rs],I=L?L.split(`
|
|
922
|
+
`).filter(Boolean):void 0,M=[],F=new Map;for(const Y of x){const de=p.get(Y)?.[$];if(!de)continue;const pe=de.options;if(!pe?.internal){if(!qp(pe,A)){e.debug?.(`Skipping ${Y}:${$} — osType does not match ${A}`);continue}if(!Jp(pe,!!lt)){e.debug?.(`Skipping ${Y}:${$} — runInCI filter`);continue}if(!Gp(pe?.when)){e.debug?.(`Skipping ${Y}:${$} — \`when\` condition not satisfied`);continue}M.push(Y),F.set(Y,de)}}if(M.length===0){const Y=Qa(g),de=Object.entries(g.projects).filter(([,pe])=>pe.targets?.[$]!==void 0).map(([pe])=>pe);if(e.error(`No projects have the "${$}" target.`),de.length>0){e.info(""),e.info(`Target "${$}" exists in these projects but was filtered out:`);for(const pe of de.slice(0,5))e.info(` - ${pe}`);de.length>5&&e.info(` …and ${de.length-5} more`)}else{const pe=su($,Y,3);pe.length>0&&(e.info(""),e.info(pe.length===1?`Did you mean "${pe[0]}"?`:`Did you mean one of: ${pe.map(Me=>`"${Me}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const _=r.pty===!0;let N=M.map(Y=>{const de=g.projects[Y],pe=F.get(Y),Me={project:Y,target:$},Ae=`${Y}:${$}`,gt=_?{...pe.options,pty:pe.options?.pty??!0}:pe.options;return{cache:pe.cache,id:Ae,outputs:pe.outputs??[],overrides:{command:pe.command,...E.length>0?{[mu]:E}:{},...gt?{visOptions:gt}:{}},parallelism:pe.parallelism,projectRoot:de?.root,target:Me}});const C=[],j=[];for(const Y of N)hu(Y)?.persistent?(Y.cache=!1,C.push(Y)):j.push(Y);N=j;const R=qu(r.partition);if(R&&(N=Ju.partitionTasks(N,R),e.info(`Partition ${R.index}/${R.total}: running ${N.length} task(s)`),N.length===0)){e.info("No tasks assigned to this partition.");return}const V=Di(N,{projectGraph:m,targetDefaults:c.targetDefaults,workspace:g});if(r.dryRun){const Y=Object.keys(V.tasks).length,de=V.roots.length;e.info(`Execution plan (${String(Y)} task(s), ${String(de)} root(s)):`),e.info("");const pe=new Set,Me=xe((Ae,gt)=>{if(pe.has(Ae))return;pe.add(Ae);for(const G of V.dependencies[Ae]??[])Me(G,gt+1);const W=V.tasks[Ae],H=" ".repeat(gt+1);e.info(`${H}${Ae}${W?.cache===!1?" (no-cache)":""}`)},"walkPlan");for(const Ae of V.roots)Me(Ae,0);C.length>0&&(e.info(""),e.info(` + ${String(C.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const P=Date.now(),B=VC(),q=xe((Y,de)=>{const pe=de instanceof Error?de.message:String(de);e.warn(`Plugin error in ${Y}: ${pe}`)},"onHookError");await UC(B,c.plugins);const J=typeof r.profile=="string"?r.profile:void 0,ce=xe(async Y=>{if(!J)return;const de=Ps(Y,V,P),pe=J.startsWith("/")?J:`${s}/${J}`;await Yu(de,pe),e.info(`Profile written to ${J}`)},"maybeWriteProfile"),le=c.taskRunnerOptions??{},ke=ed(s,r.cacheDir,le.cacheDirectory),D=jv(ke,s,c.branchScopedCache),O=L1(process.env.VIS_RUN_CONCURRENCY_LIMIT);O&&"invalid"in O&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${O.invalid} is not a positive number; falling back to default concurrency.`);const z=O&&"value"in O?O.value:void 0,me=r.parallel??z??3,Te={dryRun:r.dryRun,parallel:me,skipNxCache:!r.cache,summarize:r.summarize,...le,cacheDirectory:D},Ie=process.stdout.isTTY&&!lt,xt=c.tui?.autoExit??!1,K={args:{parallel:Te.parallel,targets:[$]},autoExit:xt,projectNames:M,tasks:N},te=typeof r.retryBudget=="number"?r.retryBudget:void 0,fe=te===void 0?void 0:B1(te),Bt=new _C(B,q);if(await B.callHook("run:before",{tasks:N,workspaceRoot:s}),Ie){const Y=new Map,de=x1({...K,stdinRegistry:Y}),{lifeCycle:pe,store:Me}=de,Ae=new Ns([pe,Bt]),gt=lc({affectedFiles:I,currentOs:A,initCwd:a,lifeCycle:Ae,mutexPool:new Map,onOutput:xe((ne,he)=>{Me.addOutput(ne,he)},"onOutput"),onOutputReplace:xe((ne,he)=>{Me.setOutput(ne,he)},"onOutputReplace"),retryBudget:fe,stdinRegistry:Y,workspaceRoot:s});let W="rerun",H=null,G=new Map;for(;W!=="quit";){if(W==="rerun")G=await Ms(N,Te,{lifeCycle:Ae,projectGraph:m,taskExecutor:gt,taskGraph:V,workspaceRoot:s});else if(W==="retry"&&H){const ne=N.find(Ke=>Ke.id===H),he=ne?.overrides.command;if(ne&&he){const Ke=ne.projectRoot??s,pr=Ke.startsWith("/")?Ke:`${s}/${Ke}`;Ae.startTasks?.([ne]);const Ft=new Ec(Ei),Kt=(await Bi([{command:he,cwd:pr,name:ne.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:xe(We=>{We.kind==="started"&&We.write&&Y.set(ne.id,{kill:We.kill,resize:We.resize,write:We.write}),(We.kind==="stdout"||We.kind==="stderr")&&We.text&&(Ft.write(We.text),Me.setOutput(ne.id,Ft.toString())),We.kind==="close"&&Y.delete(ne.id)},"onEvent")})).closeEvents[0];Ae.endTasks?.([{code:Kt?.exitCode??1,status:Kt?.exitCode===0?"success":"failure",task:ne,terminalOutput:Me.getSnapshot().outputs.get(ne.id)}])}else ne&&Ae.endTasks?.([{code:1,status:"failure",task:ne,terminalOutput:`No command configured for ${ne.id}`}]);H=null,Me.markDone()}W=await new Promise(ne=>{const he=Me.subscribe(()=>{const Ke=Me.getSnapshot();Ke.rerunRequested&&(Me.acknowledgeRerun(),he(),ne("rerun")),Ke.retryTaskId&&(H=Me.acknowledgeRetry(),he(),ne("retry"))});de.renderIsDone.then(()=>{he(),ne("quit")},()=>{he(),ne("quit")})})}await de.renderIsDone,await B.callHook("run:after",G),await ce(G),C.length>0&&!r.failFast&&await cc(C,s,I,a)}else{const Y=new Map,de=typeof r.log=="string"?r.log.toLowerCase():"",pe=de==="labeled"||de==="grouped"||de==="interleaved"?de:void 0,Me=pe?Ku(pe):void 0,Ae=new Ns([new T1({...K,logReporter:Me}),Bt]),gt=lc({affectedFiles:I,currentOs:A,initCwd:a,lifeCycle:Ae,mutexPool:Y,retryBudget:fe,workspaceRoot:s}),W=xe(async()=>{const ne=Date.now(),he=await Ms(N,Te,{lifeCycle:Ae,projectGraph:m,taskExecutor:gt,taskGraph:V,workspaceRoot:s}),Ke=Date.now()-ne;if(r.summarize){const on=Ps(he,V,P);await Xu(on,s)}let pr=!1;for(const[,on]of he)on.status==="failure"&&(pr=!0);const Ft=MC(he,Ke),Kt=js(s),We=DC(s,Ke,Kt);return e.info(""),e.info(` ${Ft}${We?` ${We}`:""}`),{hasFailure:pr,results:he,runHistory:Kt}},"runOnce"),H=await W();await B.callHook("run:after",H.results),await ce(H.results);const{hasFailure:G}=H;if(r.watch){const ne=M.map(tt=>{const Lt=g.projects[tt]?.root;if(Lt)return Lt.startsWith("/")?Lt:`${s}/${Lt}`}).filter(tt=>tt!==void 0);let he=!1,Ke=H.results;const pr=xe(()=>{const tt=sc(Ke,s);if(tt.directories.length>0&&tt.files.size>0){const Lt=I1(tt.files,s,tt.directories);return{handle:ac({filter:Lt,onChange:Kt,paths:tt.directories}),mode:"tracked"}}return{handle:ac({onChange:Kt,paths:ne}),mode:"roots"}},"buildHandle");let Ft;const Kt=xe(async tt=>{if(!he){he=!0;try{e.info(`Change detected in ${tt.length} file(s), rerunning…`),Ke=(await W()).results,Ft?.close(),Ft=pr().handle}finally{he=!1}}},"onChangeHandler"),We=pr();Ft=We.handle;const on=We.mode==="tracked"?`Watching ${String(sc(Ke,s).files.size)} tracked file(s)`:`Watching ${String(ne.length)} project root(s)`;e.info(`${on} — edit a file to rerun, Ctrl+C to exit.`),await new Promise(tt=>{const Lt=xe(()=>{process.off("SIGINT",Lt),Ft?.close(),tt()},"onSigint");process.on("SIGINT",Lt)});return}if(G){if(r.flaky!==!1){const ne=iu(s,{minRuns:2},H.runHistory);if(ne.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const he of FC(ne))e.info(` ${he}`);e.info("")}}throw new Error("Some tasks failed.")}C.length>0&&!r.failFast&&await cc(C,s,I,a)}},"execute"),group:"Run & Execute",name:"run",options:[{alias:"p",description:"Comma-separated list of projects to run",name:"projects",type:String},{defaultValue:3,description:"Maximum number of parallel tasks (falls back to VIS_RUN_CONCURRENCY_LIMIT env var, then 3)",name:"parallel",type:Number},{defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean},{description:"Custom cache directory",name:"cache-dir",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},{defaultValue:!1,description:"Only run on projects affected by git changes (shorthand for vis affected)",name:"affected",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},{description:"Output mode: interleaved (pass-through), labeled (prefix each line with [pkg#task]), or grouped (vite-task-style block)",name:"log",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 .task-runner/last-summary.json) and exit without executing any tasks",name:"last-details",type:Boolean},{defaultValue:!0,description:"Show flaky task report on failure (use --no-flaky to suppress)",name:"flaky",type:Boolean}]};var _1=Object.defineProperty,rn=b((t,e)=>_1(t,"name",{value:e,configurable:!0}),"r$5");const Ri=rn(t=>{try{return ue(t)}catch{return}},"readJsonSafe"),G1=rn(t=>{if(t.length===0||t.includes("..")||t.startsWith(".")||t.includes("\0")||t.includes("\\"))return!1;if(t.startsWith("@")){const e=t.indexOf("/");return e>1&&!t.includes("/",e+1)}return!t.includes("/")},"isSafePackageName"),W1=rn(t=>t.length>0&&!t.includes("/")&&!t.includes("\\")&&!t.includes("..")&&!t.includes("\0"),"isSafeVersion"),z1=rn((t,e,r)=>{const n=`${e.replaceAll("/","+")}@${r}`,o=w(t,"node_modules",".pnpm"),i=Ri(w(o,n,"node_modules",e,"package.json"));if(i)return i;let s;try{s=Ge(o)}catch{return}const a=`${n}_`;for(const c of s){if(!c.startsWith(a))continue;const d=Ri(w(o,c,"node_modules",e,"package.json"));if(d)return d}},"readPnpmVirtualStore"),H1=rn((t,e,r)=>{const n=Ri(w(t,"node_modules",e,"package.json"));return n?.version===r?n:void 0},"readHoistedCopy"),q1=rn((t,e,r)=>{if(!(!G1(e)||!W1(r)))return z1(t,e,r)??H1(t,e,r)},"readInstalledPackageMetadata");var J1=Object.defineProperty,yu=b((t,e)=>J1(t,"name",{value:e,configurable:!0}),"i$3");const vu=new Set(["0BSD","AGPL-3.0","AGPL-3.0-only","AGPL-3.0-or-later","Apache-1.1","Apache-2.0","Artistic-2.0","BlueOak-1.0.0","BSD-2-Clause","BSD-3-Clause","BSL-1.0","CC0-1.0","CC-BY-3.0","CC-BY-4.0","CDDL-1.0","CDDL-1.1","EPL-1.0","EPL-2.0","GPL-2.0","GPL-2.0-only","GPL-2.0-or-later","GPL-3.0","GPL-3.0-only","GPL-3.0-or-later","ISC","LGPL-2.0","LGPL-2.1","LGPL-3.0","MIT","MIT-0","MPL-1.1","MPL-2.0","Python-2.0","Unlicense","WTFPL","Zlib"]),Y1={apache2:"Apache-2.0","apache 2.0":"Apache-2.0",bsd:"BSD-3-Clause","bsd-2":"BSD-2-Clause","bsd-3":"BSD-3-Clause",mit:"MIT",public:"Unlicense","public domain":"Unlicense"},K1=(()=>{const t=new Map;for(const e of vu)t.set(e.toLowerCase(),e);for(const[e,r]of Object.entries(Y1))t.set(e,r);return t})(),X1=yu(t=>{const e=t.trim();if(e.length!==0)return vu.has(e)?e:K1.get(e.toLowerCase())},"normalizeSpdxId"),Q1=yu(t=>{let e;if(typeof t.license=="string")e=t.license;else if(t.license&&typeof t.license=="object"&&typeof t.license.type=="string")e=t.license.type;else if(Array.isArray(t.licenses)&&t.licenses.length>0){const o=t.licenses[0];o&&typeof o.type=="string"&&(e=o.type)}if(!e)return;const r=e.trim();if(r.length===0)return;if(/[()]|\b(and|or|with)\b/i.test(r))return[{expression:r}];const n=X1(r);return n?[{license:{id:n}}]:[{license:{name:r}}]},"extractLicenseChoice");var Z1=Object.defineProperty,wu=b((t,e)=>Z1(t,"name",{value:e,configurable:!0}),"t$4");const ej={sha256:"SHA-256",sha384:"SHA-384",sha512:"SHA-512"},tj={sha256:64,sha384:96,sha512:128},rj=wu(t=>{const e={name:t.name,version:t.version},{integrity:r}=t;return r&&r.hex.length===tj[r.algorithm]&&(e.hash={alg:ej[r.algorithm],content:r.hex}),t.dependencies&&(e.dependencies=t.dependencies),t.peerDependencies&&(e.peerDependencies=t.peerDependencies),t.optionalDependencies&&(e.optionalDependencies=t.optionalDependencies),e},"toResolvedPackage"),nj=[{file:"pnpm-lock.yaml",type:"pnpm"},{file:"package-lock.json",type:"npm"},{file:"yarn.lock",type:"yarn"},{file:"bun.lock",type:"bun"}],oj=wu(t=>{for(const{file:e,type:r}of nj){let n;try{n=ee(w(t,e))}catch{continue}const o=new Map;for(const i of Sc(n,r))o.set(`${i.name}@${i.version}`,rj(i));return{packages:o,type:r}}},"readLockfilePackages");var ij=Object.defineProperty,ku=b((t,e)=>ij(t,"name",{value:e,configurable:!0}),"r$4");const ln=ku(t=>t.replaceAll(/[^\w.~-]/g,e=>`%${(e.codePointAt(0)??0).toString(16).toUpperCase().padStart(2,"0")}`),"encodeSegment"),mr=ku((t,e)=>{const r=t.toLowerCase();if(r.startsWith("@")){const n=r.indexOf("/");if(n>0){const o=r.slice(0,n),i=r.slice(n+1);return`pkg:npm/${ln(o)}/${ln(i)}@${ln(e)}`}}return`pkg:npm/${ln(r)}@${ln(e)}`},"toNpmPurl");var sj=Object.defineProperty,bu=b((t,e)=>sj(t,"name",{value:e,configurable:!0}),"s$6");const aj=bu(t=>{const e=t.indexOf(":");return e<=0?t:t.slice(0,e)==="npm"?t.slice(e+1):t},"stripProtocolPrefix"),pi=bu((t,e,r)=>{const n=r.get(t);if(!n||n.size===0)return;if(n.has(e))return e;const o=aj(e);if(o!==e&&n.has(o))return o;const i=[...n];return Zu.maxSatisfying(i,o,{includePrerelease:!0})||i[0]},"resolveSpecifier");var cj=Object.defineProperty,et=b((t,e)=>cj(t,"name",{value:e,configurable:!0}),"p$6");const lj="1.6",dj="CycloneDX",uj="http://cyclonedx.org/schema/bom-1.6.schema.json",pj="@visulima/vis",dc=et(t=>{try{return ue(t)}catch{return}},"readPackageJson"),fj=et(t=>{if(t){if(typeof t=="string")return t;if(typeof t=="object"&&t.name)return t.email?`${t.name} <${t.email}>`:t.name}},"toAuthorString"),gj=et(t=>{if(t)return typeof t=="string"?t:t.url},"toRepositoryUrl"),hj=et(t=>{if(t)return typeof t=="string"?t:t.url},"toBugsUrl"),mj=et(t=>{const e=[];t.homepage&&e.push({type:"website",url:t.homepage});const r=gj(t.repository);r&&e.push({type:"vcs",url:r});const n=hj(t.bugs);return n&&e.push({type:"issue-tracker",url:n}),e.length>0?e:void 0},"buildExternalReferences"),fi=et((t,e)=>{if(!e)return;e.description&&(t.description=e.description);const r=fj(e.author);r&&(t.author=r);const n=Q1(e);n&&(t.licenses=n);const o=mj(e);o&&(t.externalReferences=o)},"decoratePackageComponent"),yj=et(t=>{const{focus:e,generatorVersion:r,includeDev:n=!1,now:o=new Date,projectGraph:i,serialNumber:s,workspace:a,workspaceRoot:c}=t,d=e&&e.length>0?[...hd(e,i)].sort():Object.keys(a.projects).sort(),p=new Set(d),g=new Map;for(const P of d){const B=a.projects[P];B&&g.set(P,dc(w(c,B.root,"package.json")))}const m=[],y=new Map;for(const P of d){const B=a.projects[P];if(!B)continue;const q=g.get(P),J=q?.version??"0.0.0",ce=mr(P,J);y.set(P,ce);const le={"bom-ref":ce,name:P,purl:ce,type:B.projectType==="application"?"application":"library",version:J};fi(le,q),m.push(le)}const v=oj(c),k=new Map,$=new Map;if(v)for(const P of v.packages.values()){k.set(`${P.name}@${P.version}`,P);let B=$.get(P.name);B||(B=new Set,$.set(P.name,B)),B.add(P.version)}const x=[],E=[],A=new Map;for(const P of d){const B=g.get(P);if(!B)continue;const q=[B.dependencies,B.peerDependencies];n&&q.push(B.devDependencies);const J=new Set,ce=et((le,ke)=>{if(ke)for(const[D,O]of Object.entries(ke)){if(p.has(D)){const me=y.get(D);me&&J.add(me);continue}const z=pi(D,O,$);z&&(J.add(mr(D,z)),le.push(`${D}@${z}`))}},"seedRef");for(const le of q)ce(x,le);ce(E,B.optionalDependencies),A.set(P,J)}const L=new Map,I=new Map,M=et((P,B)=>{const q=[...P];for(;q.length>0;){const J=q.pop(),ce=L.get(J);if(ce==="required"||ce==="optional"&&B==="optional")continue;L.set(J,B);const le=k.get(J);if(!le)continue;const ke=I.get(J)??new Set,D=[le.dependencies,le.peerDependencies];for(const O of D)if(O)for(const[z,me]of Object.entries(O))for(const Te of me){const Ie=pi(z,Te,$);Ie&&(ke.add(mr(z,Ie)),q.push(`${z}@${Ie}`))}if(le.optionalDependencies)for(const[O,z]of Object.entries(le.optionalDependencies))for(const me of z){const Te=pi(O,me,$);Te&&(ke.add(mr(O,Te)),E.push(`${O}@${Te}`))}ke.size>0&&I.set(J,ke)}},"walk");M(x,"required"),M(E,"optional");const F=[],_=[...L.keys()].sort();for(const P of _){const B=k.get(P);if(!B)continue;const q=mr(B.name,B.version),J={"bom-ref":q,name:B.name,purl:q,scope:L.get(P)??"required",type:"library",version:B.version};B.hash&&(J.hashes=[B.hash]),fi(J,q1(c,B.name,B.version)),F.push(J)}const N=[];for(const[P,B]of A){const q=y.get(P);if(!q)continue;const J=[...B].sort();N.push(J.length>0?{dependsOn:J,ref:q}:{ref:q})}for(const P of _){const B=k.get(P);if(!B)continue;const q=mr(B.name,B.version),J=I.get(P),ce=J?[...J].sort():[];N.push(ce.length>0?{dependsOn:ce,ref:q}:{ref:q})}N.sort((P,B)=>P.ref.localeCompare(B.ref));const C=dc(w(c,"package.json")),j=(()=>{if(e?.length===1){const ce=m.find(le=>le.name===e[0]);if(ce)return{"bom-ref":ce["bom-ref"],name:ce.name,purl:ce.purl,type:ce.type,version:ce.version}}const P=C?.name??"workspace",B=C?.version??"0.0.0",q=mr(P,B),J={"bom-ref":q,name:P,purl:q,type:"application",version:B};return fi(J,C),J})(),R=j["bom-ref"],V=R?m.filter(P=>P["bom-ref"]!==R):m;return{$schema:uj,bomFormat:dj,components:[...V,...F],dependencies:N,metadata:{component:j,lifecycles:[{phase:"build"}],timestamp:o.toISOString(),tools:{components:[{name:pj,type:"application",...r?{version:r}:{}}]}},serialNumber:s??`urn:uuid:${Ep()}`,specVersion:lj,version:1}},"buildCycloneDxBom"),vj=et(t=>{const e={version:t.version??1,xmlns:"http://cyclonedx.org/schema/bom/1.6"};t.serialNumber&&(e.serialNumber=t.serialNumber);const r=[];return t.metadata&&r.push(wj(t.metadata)),t.components&&t.components.length>0&&r.push({_content:t.components.map(Ii),_name:"components"}),t.dependencies&&t.dependencies.length>0&&r.push({_content:t.dependencies.map(bj),_name:"dependencies"}),`${Rp({_attrs:e,_content:r,_name:"bom"},{header:!0,indent:" ",selfCloseTags:!0})}
|
|
923
|
+
`},"serializeBomToXml"),wj=et(t=>{const e=[];return t.timestamp&&e.push({timestamp:t.timestamp}),t.lifecycles&&t.lifecycles.length>0&&e.push({_content:t.lifecycles.map(r=>{const n=[];return r.phase&&n.push({phase:r.phase}),r.name&&n.push({name:r.name}),r.description&&n.push({description:r.description}),{_content:n,_name:"lifecycle"}}),_name:"lifecycles"}),t.tools?.components&&e.push({_content:[{_content:t.tools.components.map(Ii),_name:"components"}],_name:"tools"}),t.component&&e.push(Ii(t.component)),{_content:e,_name:"metadata"}},"metadataToXmlElement"),Ii=et(t=>{const e={type:t.type};t["bom-ref"]&&(e["bom-ref"]=t["bom-ref"]);const r=[];t.group&&r.push({group:t.group}),r.push({name:t.name}),t.version&&r.push({version:t.version}),t.description&&r.push({description:t.description}),t.author&&r.push({author:t.author}),t.hashes&&t.hashes.length>0&&r.push({_content:t.hashes.map(o=>({_attrs:{alg:o.alg},_content:o.content,_name:"hash"})),_name:"hashes"});const n=kj(t.licenses);return n&&r.push(n),t.purl&&r.push({purl:t.purl}),t.scope&&r.push({scope:t.scope}),t.externalReferences&&t.externalReferences.length>0&&r.push({_content:t.externalReferences.map(o=>({_attrs:{type:o.type},_content:[{url:o.url}],_name:"reference"})),_name:"externalReferences"}),{_attrs:e,_content:r,_name:"component"}},"componentToXmlElement"),kj=et(t=>{if(!t||t.length===0)return;const e=[];for(const r of t){if("expression"in r){e.push({expression:r.expression});continue}const n=[];"id"in r.license&&r.license.id?n.push({id:r.license.id}):"name"in r.license&&r.license.name&&n.push({name:r.license.name}),e.push({_content:n,_name:"license"})}return{_content:e,_name:"licenses"}},"licensesToXmlElement"),bj=et(t=>t.dependsOn&&t.dependsOn.length>0?{_attrs:{ref:t.ref},_content:t.dependsOn.map(e=>({_attrs:{ref:e},_name:"dependency"})),_name:"dependency"}:{_attrs:{ref:t.ref},_name:"dependency"},"dependencyToXmlElement");var $j=Object.defineProperty,$u=b((t,e)=>$j(t,"name",{value:e,configurable:!0}),"i$2");const Su=["json","xml"],Sj=$u(t=>Su.includes(t),"isSbomFormat"),xj={description:"Generate a CycloneDX 1.6 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"]],execute:$u(async({options:t,visConfig:e,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:n,workspace:o}=ut(r,e),i=qt(r,o,n),s=t.focus,a=s?s.split(",").map(k=>k.trim()).filter(Boolean):void 0,c=(t.format??"json").toLowerCase();if(!Sj(c))throw new Error(`Unknown --format: "${c}". Expected one of: ${Su.join(", ")}.`);const d=yj({focus:a,includeDev:!!t.includeDev,projectGraph:i,workspace:o,workspaceRoot:r}),p=c==="xml"?vj(d):`${JSON.stringify(d,void 0,2)}
|
|
924
|
+
`,g=t.output??(c==="xml"?"sbom.cdx.xml":"sbom.cdx.json");if(g==="-"){process.stdout.write(p);return}const m=$e(r,g);je(Nt(m)),Se(m,p,"utf8");const y=d.components?.length??0,v=d.dependencies?.length??0;Z(`SBOM written to ${m}`),ie(`${y} components, ${v} dependency edges`)},"execute"),group:"Security & Health",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}]};var Cj=Object.defineProperty,Wn=b((t,e)=>Cj(t,"name",{value:e,configurable:!0}),"s$5");const jj=Wn((t,e)=>{if(!nt(t))return t;const r=_e(e,t);return r===""||r.startsWith("..")?t:r},"toRelative"),En=Wn((t,e)=>{const r=jj(t.file,e);return r===t.file?t:{...t,file:r}},"toRelativeFinding"),xu=Wn(t=>{if(!T(t))return[];try{const e=ue(t);return Array.isArray(e)?e:[]}catch{return[]}},"readBaseline"),Tj=Wn((t,e,r)=>{const n=xu(e).map(a=>En(a,r)),o=new Set(n.map(a=>Br(a))),i=t.map(a=>En(a,r)),s=new Set(i.map(a=>Br(a)));return{fresh:i.filter(a=>!o.has(Br(a))),resolved:n.filter(a=>!s.has(Br(a))),surviving:i.filter(a=>o.has(Br(a)))}},"diffBaseline"),Cu=Wn((t,e,r,n={})=>{const o=t.map(s=>En(s,r));let i;if(n.replace)i=o;else{const s=xu(e).map(c=>En(c,r)),a=new Set;i=[];for(const c of[...s,...o]){const d=Br(c);a.has(d)||(a.add(d),i.push(c))}}return Q(e,`${JSON.stringify(i,null,4)}
|
|
925
|
+
`),i.length},"writeBaseline");var Ej=Object.defineProperty,at=b((t,e)=>Ej(t,"name",{value:e,configurable:!0}),"a$2");const uc=1,Rj=at(t=>{const e=new Map;for(const r of t){const n=e.get(r.file);n?n.push(r):e.set(r.file,[r])}return e},"groupByFile"),Ij=at(t=>{try{return ee(t).split(/\r?\n/)}catch{return}},"loadLines"),Aj=at((t,e,r)=>{const n=Math.max(1,e);return`${t.slice(0,n-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,r))}`},"caretFor"),Oj=at((t,e,r)=>{if(t.length===0)return r?be("No secrets detected."):"No secrets detected.";const n=r?{cyan:st,dim:be,green:Et,red:Ue,yellow:Re}:{cyan:at(s=>s,"cyan"),dim:at(s=>s,"dim"),green:at(s=>s,"green"),red:at(s=>s,"red"),yellow:at(s=>s,"yellow")},o=[],i=Rj(t);for(const[s,a]of i){const c=_e(e,s)||s;o.push(n.cyan(c));const d=Ij(s);for(const p of a){const g=[p.source,p.confidence].filter(Boolean).join(", "),m=g?` ${n.dim(`(${g})`)}`:"",y=p.alternateMatches&&p.alternateMatches.length>0?` ${n.dim(`also: ${p.alternateMatches.join(", ")}`)}`:"";let v="";switch(p.validation){case"error":{v=` ${n.yellow("! error")}`;break}case"rejected":{v=` ${n.red("✗ rejected")}`;break}case"skipped":{v=` ${n.dim("— unverifiable")}`;break}case"verified":{v=` ${n.green("✓ verified")}`;break}}if(o.push(` ${n.red("✖")} ${n.yellow(`[${p.ruleId}]`)}${m}${v} ${n.dim(`line ${String(p.startLine)}:${String(p.startColumn)}`)}${y}`),d){const k=Math.max(0,p.startLine-1-uc),$=Math.min(d.length,p.startLine+uc);for(let x=k;x<$;x+=1){const E=String(x+1).padStart(4," "),A=x+1===p.startLine,L=A?n.red("▶"):" ";if(o.push(` ${L} ${n.dim(E)} │ ${d[x]??""}`),A){const I=Math.max(1,(p.endColumn??p.startColumn+1)-p.startColumn),M=Aj(d[x]??"",p.startColumn,I);o.push(` ${n.dim(" │ ")}${n.red(M)}`)}}}o.push("")}}return o.join(`
|
|
926
|
+
`).trimEnd()},"formatText"),Pj=at((t,e)=>{if(!nt(t))return t.replaceAll("\\","/");try{return Mc(t).toString()}catch{return`file://${$e(e,t).replaceAll("\\","/")}`}},"toSarifUri"),Nj=at((t,e=100)=>t.length<=e?t:`${t.slice(0,e-1).trimEnd()}…`,"shortText"),Mj=at((t,e,r=process.cwd(),n=[])=>{const o=new Map(n.map(c=>[c.id,c])),i=new Set;for(const c of t)i.add(c.ruleId);const s=[...new Set([...o.keys(),...i])].sort((c,d)=>c.localeCompare(d)),a=new Map(s.map((c,d)=>[c,d]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:Mc(r).toString()}},results:t.map(c=>{const d={};return c.source&&(d.source=c.source),c.confidence&&(d.confidence=c.confidence),c.alternateMatches&&c.alternateMatches.length>0&&(d.alternateRules=c.alternateMatches),c.validation&&(d.validation=c.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:Pj(c.file,r),uriBaseId:nt(c.file)?void 0:"SRCROOT"},region:{endColumn:c.endColumn,endLine:c.endLine,snippet:{text:c.match},startColumn:c.startColumn,startLine:c.startLine}}}],message:{text:c.description||c.ruleId},properties:Object.keys(d).length>0?d:void 0,ruleId:c.ruleId,ruleIndex:a.get(c.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:s.map(c=>{const d=o.get(c),p=d?.description??`Detected by rule \`${c}\``,g={};return d?.tags&&d.tags.length>0&&(g.tags=d.tags),d?.source&&(g.source=d.source),d?.confidence&&(g.confidence=d.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:p},helpUri:"https://visulima.com/packages/secret-scanner",id:c,name:c,properties:Object.keys(g).length>0?g:void 0,shortDescription:{text:Nj(p)}}}),version:e}}}],version:"2.1.0"},void 0,2)},"formatSarif");var Dj=Object.defineProperty,zn=b((t,e)=>Dj(t,"name",{value:e,configurable:!0}),"n$1");const ko=zn((t,e)=>{try{return Vc("git",e,{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch{return""}},"runGit"),Ai=zn(t=>t.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),"splitFiles"),Bj=zn(t=>Ai(ko(t,["diff","--cached","--name-only","--diff-filter=ACMR"])).map(e=>nt(e)?e:w(t,e)),"stagedFiles"),pc=zn((t,e)=>{const r=ko(t,["diff","--name-only","--diff-filter=ACMR",`${e}...HEAD`]),n=Ai(r);if(n.length===0){const o=ko(t,["diff","--name-only","--diff-filter=ACMR",e]);return Ai(o).map(i=>nt(i)?i:w(t,i))}return n.map(o=>nt(o)?o:w(t,o))},"filesSince"),gi=zn(t=>ko(t,["rev-parse","--show-toplevel"]).length>0,"hasGit");var Fj=Object.defineProperty,Mr=b((t,e)=>Fj(t,"name",{value:e,configurable:!0}),"r$2");const fc=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],ju=Mr(t=>{if(!(typeof process.stderr.isTTY=="boolean"&&process.stderr.isTTY))return{stop:Mr(()=>{},"stop"),update:Mr(()=>{},"update")};let e=t,r=0;const n=Mr(()=>{process.stderr.write(`\r${fc[r%fc.length]} ${e}`),r+=1},"render");n();const o=setInterval(n,80);return o.unref?.(),{stop:Mr(i=>{clearInterval(o),process.stderr.write("\r\x1B[2K"),i&&process.stderr.write(`${i}
|
|
927
|
+
`)},"stop"),update:Mr(i=>{e=i},"update")}},"startSpinner");var Lj=Object.defineProperty,Qe=b((t,e)=>Lj(t,"name",{value:e,configurable:!0}),"o$2");const fn=".secrets-baseline.json",gc=Qe(t=>t?Array.isArray(t)?t:[t]:[],"toArray"),Vj=Qe(t=>{const e=new Set(["json","sarif","text"]);return t&&!e.has(t)&&(ze(`--format must be one of: ${[...e].join(", ")} (got "${t}")`),process.exit(2)),t??"text"},"validateFormat"),Uj=Qe(t=>{if(t===void 0)return;const e=new Set(["high","low","medium"]);return e.has(t)||(ze(`--min-confidence must be one of: ${[...e].join(", ")} (got "${t}")`),process.exit(2)),t},"validateConfidence"),_j=Qe(async(t,e)=>{const r=await zc(t);process.stdout.write(`${String(r.length)} rules loaded
|
|
928
|
+
|
|
929
|
+
`);for(const n of r){const o=e?Re(n.id):n.id,i=n.tags.length>0?` ${e?be(`[${n.tags.join(", ")}]`):`[${n.tags.join(", ")}]`}`:"";if(process.stdout.write(`${o}${i}
|
|
930
|
+
${n.description}
|
|
931
|
+
`),n.keywords.length>0){const s=`keywords: ${n.keywords.slice(0,6).join(", ")}${n.keywords.length>6?", ...":""}`;process.stdout.write(` ${e?be(s):s}
|
|
811
932
|
`)}process.stdout.write(`
|
|
812
|
-
`)}
|
|
813
|
-
|
|
814
|
-
`)}
|
|
815
|
-
|
|
816
|
-
`)
|
|
817
|
-
|
|
818
|
-
|
|
933
|
+
`)}},"printListRules"),Gj=Qe(async(t,e)=>{const r=await Ip(t);if(r.length===0){process.stdout.write(e?`${be("No non-HTTP validators required by the current ruleset.")}
|
|
934
|
+
`:`No non-HTTP validators required by the current ruleset.
|
|
935
|
+
`);return}process.stdout.write(`${String(r.length)} non-HTTP validator type(s) referenced by the current ruleset:
|
|
936
|
+
|
|
937
|
+
`);for(const n of r){const o=e?Re(n.displayName):n.displayName,i=`(${n.type}, ${String(n.ruleCount)} rule${n.ruleCount===1?"":"s"})`;process.stdout.write(`${o} ${e?be(i):i}
|
|
938
|
+
`),process.stdout.write(` ${n.summary}
|
|
939
|
+
`);const s=n.packageName?`install: npm add ${n.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${e?be(s):s}
|
|
940
|
+
|
|
941
|
+
`)}},"printListValidators"),Wj=Qe(async(t,e,r)=>{const n=w(t,fn);!r&&T(n)&&(se(`Detected existing ${fn} — refusing to overwrite. Delete it first to re-init.`),process.exit(1)),S(r?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const o=ju("scanning");let i;try{i=await Hc([t],e)}finally{o.stop()}if(r){S(`[dry-run] Would create ${fn} with ${String(i.length)} finding(s).`);return}const s=Cu(i,n,t,{replace:!0});Z(`Wrote ${fn} (${String(s)} findings).`),ie("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},"runInit"),zj=Qe((t,e,r)=>{const n=e??{},o=Qe(k=>k?$e(r,k):void 0,"resolvePath"),i=Qe((k,$)=>{const x=gc(k);return x.length>0?x:$},"pickList"),s=i(t.enableRule,n.rules?.enable),a=i(t.excludeRule,n.rules?.exclude),c=i(t.includeRule,n.rules?.include),d=i(t.exclude,n.walk?.excludePatterns),p=gc(t.excludeFrom).map(k=>$e(r,k)),g=p.length>0?p:n.walk?.excludeFromFiles?.map(k=>$e(r,k)),m=o(t.baseline)??o(n.baseline),y=o(t.config)??o(n.config?.path),v=Uj(t.minConfidence??n.config?.minConfidence);return{baseline:m,concurrency:t.concurrency,config:{extendBundled:t.noExtendBundled?!1:n.config?.extendBundled,inline:n.config?.inline,minConfidence:v,onlyVerified:t.onlyVerified??n.config?.onlyVerified??!1,path:y,validate:t.validate??n.config?.validate??!1},redact:t.redact??n.redact,rules:{enable:s,exclude:a,include:c},verbose:t.verbose??!1,walk:{excludeFromFiles:g,excludePatterns:d,gitignore:t.noGitignore?!1:n.walk?.gitignore??!0,includeHidden:t.includeHidden??n.walk?.includeHidden,maxFileSize:t.maxSize??n.walk?.maxFileSize}}},"resolveScanOptions"),Hj=Qe(t=>{process.stderr.write(`${be("baseline diff: ")}${Et(`+${String(t.fresh.length)} new`)} · ${Re(`${String(t.surviving.length)} unchanged`)} · ${be(`-${String(t.resolved.length)} resolved`)}
|
|
942
|
+
`)},"printDiff"),qj=Qe(async(t,e,r)=>{if(t.staged)return gi(r)||(ze("--staged requires a git working tree, and none was detected."),process.exit(2)),{files:Bj(r)};if(t.since)return gi(r)||(ze("--since requires a git working tree, and none was detected."),process.exit(2)),{files:pc(r,t.since)};if(t.affected){if(!gi(r))return se("--affected requires git; falling back to full scan"),{paths:e&&e.length>0?e.map(o=>$e(r,o)):[r]};const n=process.env.VIS_BASE??"HEAD~1";return{files:pc(r,n)}}return{paths:e&&e.length>0?e.map(n=>$e(r,n)):[r]}},"chooseScanPaths"),Jj=Qe((t,e,r,n,o,i)=>{switch(e){case"json":{const s=t.map(a=>En(a,r));process.stdout.write(`${JSON.stringify(s,null,2)}
|
|
943
|
+
`);break}case"sarif":{process.stdout.write(`${Mj(t,o,r,i)}
|
|
944
|
+
`);break}default:process.stdout.write(`${Oj(t,r,n)}
|
|
945
|
+
`)}},"emitFindings"),Yj={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 --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"]],execute:Qe(async({argument:t,options:e,visConfig:r,workspaceRoot:n})=>{const o=e,i=t,s=n??process.cwd(),a=!o.quiet&&process.stdout.isTTY,c=r?.secrets,d=zj(o,c,s),p="0.0.0-alpha";if(o.listRules){await _j(d,a);return}if(o.listValidators){await Gj(d,a);return}if(o.init){await Wj(s,d,o.dryRun??!1);return}const g=await qj(o,i??[],s);if(g.files?.length===0){o.quiet||Z("No files to scan.");return}const m=!o.quiet&&!["json","sarif"].includes(o.format??"text")?ju("scanning for secrets"):{stop:Qe(()=>{},"stop"),update:Qe(()=>{},"update")};let y;try{y=g.files===void 0?await Hc(g.paths??[s],d):await Ap(g.files,d)}catch(E){m.stop(),ze(`secret scan failed: ${E instanceof Error?E.message:String(E)}`),process.exit(2)}finally{m.stop()}if(o.verbose){const E=await Op(d);if(E.length>0){se(`${String(E.length)} rule(s) skipped due to invalid regex. First few:`);for(const A of E.slice(0,5))process.stderr.write(` - ${A.ruleId}: ${A.reason}
|
|
946
|
+
`)}}const v=d.baseline??w(s,fn),k=!o.quiet&&T(v);if(o.updateBaseline){const E=Cu(y,v,s,{replace:o.replaceBaseline});Z(`Baseline updated: ${_e(s,v)||v} now contains ${String(E)} entries.`);return}const $=Vj(o.format),x=$==="sarif"?await zc(d).catch(()=>[]):[];Jj(y,$,s,a,p,x),$==="text"&&k&&Hj(Tj(y,v,s)),y.length>0&&(o.quiet||(se(`${String(y.length)} potential secret(s) found`),ie("Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exit(1)),o.quiet||Z("No secrets detected.")},"execute"),group:"Security",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},{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}]};var Kj=Object.defineProperty,bo=b((t,e)=>Kj(t,"name",{value:e,configurable:!0}),"d$4");const Xj=bo(t=>{const e=new Set,r=[],n=bo(i=>{const s=$e(i);!e.has(s)&&T(s)&&(e.add(s),r.push(s))},"addFile");n(w(t,"package.json"));const o=Io(t);if(o){const i=$r(t,o);for(const s of i)n(w(t,s,"package.json"))}else{const i=w(t,"package.json");if(T(i)){const s=JSON.parse(ee(i)),a=Array.isArray(s.workspaces)?s.workspaces:s.workspaces?.packages;if(a){const c=$r(t,a);for(const d of c)n(w(t,d,"package.json"))}}}return r},"findPackageJsonFiles"),Qj=bo((t,e)=>{const r=Ao();if(!r)throw new Error("Native bindings unavailable: sort-package-json requires the native addon. Ensure the correct platform binary is installed.");return r.sortPackageJsonStringWithOptions(t,{pretty:!0,sort_scripts:e})},"sortContents"),Zj={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"]],execute:bo(async({options:t,visConfig:e,workspaceRoot:r})=>{const n=r??process.cwd(),o=e?.sortPackageJson,i=t.check||!1,s=t.sortScripts||o?.sortScripts||!1,a=Xj(n);if(a.length===0){S("No package.json files found.");return}let c=0,d=0,p=0;for(const g of a)try{const m=ee(g);let y;try{y=Qj(m,s)}catch($){ze(`${g}: ${mi($)}`),p++;continue}const v=m.endsWith(`
|
|
819
947
|
`)?m:`${m}
|
|
820
|
-
`,
|
|
948
|
+
`,k=y.endsWith(`
|
|
821
949
|
`)?y:`${y}
|
|
822
|
-
`;if(
|
|
950
|
+
`;if(v===k){d++;continue}c++,i?se(`${g} is not sorted`):(Se(g,k,"utf8"),Z(`Sorted ${g}`))}catch(m){ze(`${g}: ${mi(m)}`),p++}if(i)c>0?(S(`${c} file${c===1?"":"s"} not sorted, ${d} already sorted`),process.exitCode=1):S(`All ${d} package.json file${d===1?" is":"s are"} sorted`);else{const g=[];c>0&&g.push(`sorted ${c} file${c===1?"":"s"}`),d>0&&g.push(`${d} already sorted`),p>0&&g.push(`${p} error${p===1?"":"s"}`),S(g.join(", "))}p>0&&(process.exitCode=1)},"execute"),group:"Workspace",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}]};var eT=Object.defineProperty,tT=b((t,e)=>eT(t,"name",{value:e,configurable:!0}),"n");const rT="VIS_STAGED_CONCURRENT",hc=tT(t=>{const e=t.trim();if(e==="true"||e==="")return!0;if(e==="false")return!1;const r=Number(e);return Number.isNaN(r)?!0:r},"parseConcurrent");var nT=Object.defineProperty,so=b((t,e)=>nT(t,"name",{value:e,configurable:!0}),"s$3");const oT=so((t,e)=>{const r={};e!==void 0&&(r.config=e);const n=so(L=>t[L]===void 0?void 0:!!t[L],"readBool"),o=so(L=>{const I=t[L];return typeof I=="string"&&I.length>0?I:void 0},"readString"),i=n("allow-empty");i!==void 0&&(r.allowEmpty=i);const s=n("auto-stage");s!==void 0&&(r.autoStage=s);const a=n("continue-on-error");a!==void 0&&(r.continueOnError=a);const c=n("debug");c!==void 0&&(r.debug=c);const d=n("fail-on-changes");d!==void 0&&(r.failOnChanges=d);const p=n("hide-partially-staged");p!==void 0&&(r.hidePartiallyStaged=p);const g=n("hide-unstaged");g!==void 0&&(r.hideUnstaged=g);const m=n("quiet");m!==void 0&&(r.quiet=m);const y=n("relative");y!==void 0&&(r.relative=y);const v=n("revert");v!==void 0&&(r.revert=v);const k=n("stash");k!==void 0&&(r.stash=k);const $=n("verbose");$!==void 0&&(r.verbose=$);const x=o("cwd");x!==void 0&&(r.cwd=x);const E=o("diff");E!==void 0&&(r.diff=E);const A=o("diff-filter");if(A!==void 0&&(r.diffFilter=A),n("force-kill")===!0&&(r.killSignal="SIGKILL"),t.concurrent===void 0){const L=process.env[rT];L!==void 0&&(r.concurrent=hc(L.trim()))}else r.concurrent=hc(String(t.concurrent));return r},"buildRunOptions"),iT={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"]],execute:so(async({options:t,visConfig:e})=>{const r=(e??{}).staged;if(!r)throw new Error(`No "staged" config found in vis.config.ts. Add one:
|
|
823
951
|
|
|
824
952
|
// vis.config.ts
|
|
825
953
|
import { defineConfig } from "@visulima/vis/config";
|
|
826
954
|
|
|
827
955
|
export default defineConfig({
|
|
828
956
|
staged: { '*': 'vis check --fix' },
|
|
829
|
-
})
|
|
830
|
-
|
|
831
|
-
`):r==="
|
|
832
|
-
`):(
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
`)
|
|
836
|
-
|
|
837
|
-
${
|
|
838
|
-
|
|
839
|
-
`)
|
|
840
|
-
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);const n=await hg(oT(t,r));process.exit(n.success?0:1)},"execute"),group:"Run & Execute",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}]};var sT=Object.defineProperty,Tu=b((t,e)=>sT(t,"name",{value:e,configurable:!0}),"d$3");const dn=Tu(t=>t?Et("✓"):Ue("✗"),"icon"),aT={description:"Show a workspace health dashboard at a glance",examples:[["vis status","Full status overview"],["vis status --json","Machine-readable output"]],execute:Tu(async({logger:t,options:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const{config:o,packageJsons:i,workspace:s}=ut(n,r),a=qt(n,s,i),c=Object.keys(s.projects).length,d=new Set(Object.values(s.projects).flatMap(k=>Object.keys(k.targets??{}))).size,p=wd(n);let g=0;o.constraints&&(g=Rc(a,o.constraints).length);const m=iu(n,{minRuns:2});let y;const v=w(n,".task-runner","runs");if(T(v)){const k=Ge(v).filter(E=>E.endsWith(".json")).sort();let $=0,x=0;for(const E of k.slice(-20))try{const A=ue(w(v,E));A.stats&&($+=A.stats.total??0,x+=A.stats.cached??0)}catch{continue}$>0&&(y=`${(x/$*100).toFixed(0)}%`)}if(e.json){t.info(JSON.stringify({cacheHitRate:y??null,constraintViolations:g,flakyTasks:m.length,projects:c,runtimeIssues:p.length,targets:d},null,2));return}t.info(""),t.info(` ${be("VIS STATUS")}`),t.info(""),t.info(` ${dn(!0)} ${String(c)} projects · ${String(d)} unique targets`),t.info(` ${dn(p.length===0)} Runtime: ${p.length===0?Et("OK"):Re(`${String(p.length)} issue(s)`)}`),t.info(` ${dn(g===0)} Constraints: ${g===0?Et("OK"):Ue(`${String(g)} violation(s)`)}`),t.info(` ${dn(m.length===0)} Flaky tasks: ${m.length===0?Et("none"):Re(String(m.length))}`),y&&t.info(` ${dn(!0)} Cache hit rate: ${y} (last 20 runs)`),t.info("")},"execute"),group:"Workspace",name:"status",options:[{defaultValue:!1,description:"Emit JSON output",name:"json",type:Boolean}]};var cT=Object.defineProperty,As=b((t,e)=>cT(t,"name",{value:e,configurable:!0}),"i$1");const lT=As((t,e)=>{const r=e.replace(/^\.?\//,"");return r===""||r==="."?`/${t}/`:t===""||t==="."?`/${r}`:`/${t}/${r}`},"toWorkspacePath"),dT=As((t,e)=>{const r=[];for(const[n,o]of Object.entries(e?.globalPaths??{}))r.push({owners:o,path:n});for(const[n,o]of Object.entries(t.projects)){const i=o.owners??[];for(const s of i)r.push({channel:s.channel,owners:s.owners,path:lT(o.root??n,s.path),projectId:n})}return(e?.orderBy??"file-source")==="project-id"?r.sort((n,o)=>(n.projectId??"").localeCompare(o.projectId??"")||n.path.localeCompare(o.path)):r.sort((n,o)=>n.path.localeCompare(o.path)),r},"buildCodeownersLines"),uT=["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.","# Update each project's project.json `owners` field and re-run the command.",""],pT=As((t,e="github")=>{const r=[...uT];for(const n of t){const o=n.owners.join(" "),i=n.channel?` # notify: ${n.channel}`:"";r.push(`${n.path} ${o}${i}`)}return r.push(""),r.join(`
|
|
960
|
+
`)},"renderCodeowners");var fT=Object.defineProperty,gT=b((t,e)=>fT(t,"name",{value:e,configurable:!0}),"u$4");const hT={argument:{description:"What to sync: codeowners",name:"kind",type:String},description:"Synchronise derived workspace artefacts (codeowners, 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"]],execute:gT(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{const i=t[0];if(!i)throw new Error("Missing sync kind. Usage: vis sync <kind> (known kinds: codeowners)");if(!o)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(i!=="codeowners")throw new Error(`Unknown sync kind: "${i}". Known kinds: codeowners.`);const{workspace:s}=ut(o,n),a=dT(s,n?.codeowners);if(a.length===0){e.info("No `owners` entries found in any project. Nothing to sync.");return}const c=pT(a,n?.codeowners?.provider??"github"),d=r.out?w(o,String(r.out)):w(o,"CODEOWNERS");if(r.check){let p="";try{p=Oc(d,"utf8")}catch(g){if(g.code==="ENOENT")p="";else throw g}if(p.trim()!==c.trim()){e.error(`${d} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}e.info(`${d} is up to date.`);return}Q(d,c),e.info(`Wrote ${a.length} entries to ${d}`)},"execute"),group:"Workspace",name:"sync",options:[{description:"Output path for the generated file (default: <workspace>/CODEOWNERS)",name:"out",type:String},{defaultValue:!1,description:"Verify the existing file is up to date (exit non-zero if stale)",name:"check",type:Boolean}]};var mT=Object.defineProperty,Os=b((t,e)=>mT(t,"name",{value:e,configurable:!0}),"h$2");const yT=Os((t,e)=>{const r=new Map;for(const[i,s]of Object.entries(t.dependencies))for(const a of s){const c=r.get(a)??[];c.push(i),r.set(a,c)}if(!t.tasks[e])return;const n=new Set([e]),o=[{node:e,path:[e]}];for(;o.length>0;){const i=o.shift();if(t.roots.includes(i.node))return i.path;for(const s of r.get(i.node)??[])n.has(s)||(n.add(s),o.push({node:s,path:[s,...i.path]}))}return[e]},"findShortestPathToRoot"),vT=Os((t,e)=>{const r=[];for(const[n,o]of Object.entries(t.dependencies))o.includes(e)&&r.push(n);return r.sort()},"collectParents"),wT={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"]],execute:Os(async({argument:t,logger:e,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const o=t[0];if(!o)throw new Error("No task ID specified. Usage: vis task-why <project>:<target>");if(!o.includes(":"))throw new Error(`Invalid task ID "${o}" — expected format "project:target".`);const{packageJsons:i,workspace:s}=ut(n,r),a=qt(n,s,i),[c,d]=o.split(":",2),p=s.projects[c];if(!p)throw new Error(`Unknown project "${c}".`);if(!p.targets?.[d])throw new Error(`Project "${c}" has no target "${d}".`);const g=Object.entries(s.projects).flatMap(([$,x])=>Object.keys(x.targets??{}).map(E=>({id:`${$}:${E}`,outputs:[],overrides:{},target:{project:$,target:E}}))),m=Di(g,{projectGraph:a,workspace:s});if(!m.tasks[o])throw new Error(`Task "${o}" is not reachable in the graph.`);const y=yT(m,o),v=vT(m,o);if(e.info(""),e.info(`Why ${o}?`),e.info(""),y&&y.length>1){e.info("Shortest path from a root to this task:");for(const[$,x]of y.entries()){const E=$===0?" ":`${" ".repeat($+1)}└─ `;e.info(`${E}${x}`)}e.info("")}else e.info(" This task is itself a root — nothing upstream depends on it."),e.info("");if(v.length>0){e.info(`Directly depended on by ${v.length} task(s):`);for(const $ of v)e.info(` - ${$}`);e.info("")}const k=m.dependencies[o]??[];if(k.length>0){e.info(`This task depends on ${k.length} task(s):`);for(const $ of[...k].sort())e.info(` - ${$}`);e.info("")}},"execute"),group:"Workspace",name:"task-why"};var kT=Object.defineProperty,bT=b((t,e)=>kT(t,"name",{value:e,configurable:!0}),"c$2");const $T={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"]],execute:bT(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const o=t||[],i=n??process.cwd(),s=Ne(i),a=nh(s,o,r.recursive||!1,i,e);a!==0&&(process.exitCode=a)},"execute"),group:"Dependencies",name:"unlink",options:[{alias:"r",defaultValue:!1,description:"Unlink in all workspace packages",name:"recursive",type:Boolean}]};var ST=Object.defineProperty,nn=b((t,e)=>ST(t,"name",{value:e,configurable:!0}),"s$1");const xT=nn(t=>{const e=[];for(const r of t.filters)e.push("--filter",r);return t.workspaceRoot&&e.push("--filter","."),e.push("update"),t.latest&&e.push("--latest"),t.recursive&&e.push("--recursive"),t.interactive&&e.push("--interactive"),t.dev&&e.push("--dev"),t.prod&&e.push("--prod"),t.noOptional&&e.push("--no-optional"),t.noSave&&e.push("--no-save"),e.push(...t.packages),{args:e,bin:"pnpm"}},"resolvePnpm"),CT=nn(t=>{const e=[];return t.filters.length>0&&e.push("workspace",t.filters[0]),e.push("upgrade"),t.latest&&e.push("--latest"),e.push(...t.packages),{args:e,bin:"yarn"}},"resolveYarnV1"),jT=nn(t=>{const e=[];if(t.filters.length>0||t.recursive){e.push("workspaces","foreach","--all");for(const r of t.filters)e.push("--include",r)}return e.push("up"),t.interactive&&e.push("--interactive"),e.push(...t.packages),{args:e,bin:"yarn"}},"resolveYarnBerry"),TT=nn((t,e)=>{const r=["update"];t.latest&&e.push("npm does not support --latest flag. Packages will be updated within their semver range."),t.interactive&&e.push("npm does not support --interactive mode.");for(const n of t.filters)r.push("--workspace",n);return t.recursive&&r.push("--workspaces"),t.workspaceRoot&&r.push("--include-workspace-root"),t.dev&&r.push("--dev"),t.prod&&r.push("--production"),t.noOptional&&r.push("--no-optional"),t.noSave&&r.push("--no-save"),r.push(...t.packages),{args:r,bin:"npm"}},"resolveNpm"),ET=nn(t=>{const e=["update"];t.latest&&e.push("--latest");for(const r of t.filters)e.push("--filter",r);return e.push(...t.packages),{args:e,bin:"bun"}},"resolveBun"),RT=nn((t,e,r)=>{const n=[];if(r.global)return{command:{args:["update","--global",...r.packages],bin:"npm"},warnings:n};let o;switch(t){case"bun":{o=ET(r);break}case"npm":{o=TT(r,n);break}case"pnpm":{o=xT(r);break}case"yarn":{o=e.startsWith("1.")?CT(r):jT(r);break}default:{const i=t;throw new Error(`Unsupported package manager: ${String(i)}`)}}return{command:o,warnings:n}},"resolveUpdateCommand");var IT=Object.defineProperty,ur=b((t,e)=>IT(t,"name",{value:e,configurable:!0}),"w");const AT=ur((t,e)=>{try{if(e==="pnpm"){const r=w(t,"pnpm-workspace.yaml");if(T(r)){const n=Jr(r);if(typeof n?.minimumReleaseAge=="number")return n.minimumReleaseAge}}else if(e==="bun"){const r=w(t,"package.json");if(T(r)){const n=ue(r);if(typeof n.minimumReleaseAge=="number")return n.minimumReleaseAge}}}catch{}},"readPmNativeMinimumReleaseAge"),OT=ur((t,e,r)=>{const n=t.latest?"latest":t.target??e.target??"latest";if(!["latest","minor","patch"].includes(n))throw new Error(`Invalid target "${n}". Use: latest, minor, or patch.`);return{exclude:[...yt(t.exclude),...yt(e.exclude)],ignore:yt(e.ignore),include:[...yt(t.include),...yt(e.include),...r],includeLocked:t.includeLocked||e.includeLocked||!1,includePrerelease:t.prerelease||e.prerelease||!1,minimumReleaseAge:e.minimumReleaseAge,minimumReleaseAgeExclude:e.minimumReleaseAgeExclude,packageMode:e.packageMode,security:t.security||t.ai||e.security||!1,target:n}},"buildCatalogCheckOptions"),mc=ur((t,e)=>{if(t.length!==0){e.info(`
|
|
961
|
+
${Re("⚠")} ${String(t.length)} package${t.length===1?"":"s"} skipped by target constraint (use --target latest to include):`);for(const r of t)e.info(` ${r.packageName} ${r.currentRange} → ${r.newRange} (${r.updateType})`)}},"logFilteredByTarget"),yc=ur((t,e,r,n)=>{r==="json"?process.stdout.write(`${By({checkedCount:0,failed:e,filteredByTarget:[],ignored:[],outdated:t})}
|
|
962
|
+
`):r==="minimal"?process.stdout.write(`${Wl(t)}
|
|
963
|
+
`):(zl(t,n),n.info(fo(t)))},"writeFormattedOutput"),vc=ur(async(t,e,r,n,o)=>{const i=Hy(t,r,e),s=e==="pnpm"?"pnpm-workspace.yaml":"package.json";if(o.info(`
|
|
964
|
+
Updated ${s}`),i&&o.info(`Backup saved to ${i}`),n.changelog){o.info(`
|
|
965
|
+
Fetching changelogs...`);const a=await Hl(r);for(const c of a){const d=c.releaseUrl??c.repoUrl??c.npmUrl;o.info(` ${c.packageName}: ${d}`)}}if(n.install??!0){const a={bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}[e]??`${e} install`;o.info(`Running ${a}...
|
|
966
|
+
`);try{Pn(a,{cwd:t,env:process.env,stdio:"inherit"})}catch{o.warn(`${a} failed. You may need to run it manually.`)}}},"applyCatalogAndInstall"),PT=ur(async(t,e,r,n,o,i)=>{const s=r.update??{},a=[["global","--global is not supported in catalog mode"],["recursive","--recursive is not needed in catalog mode (catalogs are workspace-level)"],["filter","--filter is not supported in catalog mode (use --include/--exclude instead)"],["no-save","--no-save is not supported in catalog mode"],["workspace-root","--workspace-root is not needed in catalog mode"],["no-optional","--no-optional is not supported in catalog mode"]];for(const[P,B]of a)n[P]&&i.warn(`${Re("⚠")} ${B}, ignoring.`);const c=AT(t,e),d=s.minimumReleaseAge??c;if(s.minimumReleaseAge!==void 0&&c!==void 0&&s.minimumReleaseAge!==c){const P=e==="pnpm"?"pnpm-workspace.yaml":"package.json";i.warn(`${Re("⚠")} minimumReleaseAge mismatch: vis config = ${String(s.minimumReleaseAge)} min, ${P} = ${String(c)} min. Consider keeping them in sync.`)}const p=is(t),g=Mo(t,e,{depFields:s.depFields,dev:n.dev,prod:n.prod});if(g.size===0){i.info("No catalogs found.");return}const m={...s,minimumReleaseAge:d},y=OT(n,m,o);let v=0;for(const P of g.values())v+=P.size;const k=!!process.stdout.isTTY&&!lt;let $;const x=k?(P,B)=>{$?$.rerender(X.createElement(xn,{current:P,total:B})):$=Ut(X.createElement(xn,{current:P,total:B}),{interactive:!0,patchConsole:!1})}:(P,B)=>{i.info(`Checking ${String(P)}/${String(B)} dependencies...`)};k||i.info(`Checking ${String(v)} catalog dependencies...
|
|
967
|
+
`);const E=Er(r.security?.socket),{checkedCount:A,failed:L,filteredByTarget:I,ignored:M,outdated:F}=await ss(g,y,p,x,t,E,r.security?.socket?.acceptedRisks);$&&($.clear(),$.unmount());const _=A-F.length-L.length;if(L.length>0&&i.warn(`Failed to fetch: ${L.join(", ")}`),M.length>0&&i.info(`Skipped ${String(M.length)} ignored package${M.length===1?"":"s"}: ${M.join(", ")}`),!k&&A>F.length){const P=[...g.values()].reduce((q,J)=>q+J.size,0),B=P>A?` (${String(P)} catalog entries, ${String(P-A)} duplicates)`:"";i.info(`Checked ${String(A)} unique packages${B}: ${String(F.length)} outdated, ${String(_)} up-to-date${L.length>0?`, ${String(L.length)} failed`:""}${I.length>0?`, ${String(I.length)} skipped by target`:""}`)}if(F.length===0){I.length>0?i.info(`All catalog dependencies are up to date within the current target.
|
|
968
|
+
${String(I.length)} package${I.length===1?" has":"s have"} newer versions available with --target latest:
|
|
969
|
+
${I.map(P=>` ${P.packageName} ${P.currentRange} → ${P.newRange} (${P.updateType})`).join(`
|
|
970
|
+
`)}`):i.info("All catalog dependencies are up to date.");return}const N=n.format??s.format??"table";let C;if(n.ai){const P=ts(n.aiType??"impact");C=await rs(F,i,r.ai,P)}const j=!!n.dryRun;if(k&&N==="table"){const P=new rd(F,C??null);let B;if(n.changelog){i.info("Fetching changelogs...");const D=await Hl(F);B=new Map;for(const O of D){const z=O.releaseUrl??O.repoUrl??O.npmUrl;z&&B.set(O.packageName,z)}}const q=r.tui?.autoExit??!1,J=q===!0?3:typeof q=="number"?q:0,ce=await Ut(X.createElement(nd,{autoExitSeconds:J,changelogUrls:B,checkedCount:A,filteredOutEntries:I,isDryRun:j,store:P,totalCatalogEntries:v}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),le=process.stdout.columns||80;process.stdout.write(`
|
|
971
|
+
`);for(const D of F){const O=D.vulnerabilities?.length||D.socketReport&&D.socketReport.alerts.length>0,z=!!D.acceptedRisk,me=O?z?"✓":"⚠":"✓",Te=z?"gray":D.updateType==="major"?"red":D.updateType==="minor"?"yellow":"green",Ie=D.socketReport?.score.overall,xt=Ie===void 0?"":` [${String(Math.round(Ie*100))}%]`,K=Ie===void 0?void 0:Mn(Ie);process.stdout.write(`${Oe(X.createElement(l,null," ",X.createElement(l,{color:Te},me),` ${D.packageName} ${D.currentRange} → ${D.newRange}`,X.createElement(l,{dimColor:!0},` ${D.updateType}`),K?X.createElement(l,{color:K},xt):null),{columns:le})}
|
|
841
972
|
`)}if(process.stdout.write(`
|
|
842
|
-
`),
|
|
843
|
-
`);const
|
|
844
|
-
`);for(const
|
|
845
|
-
`)}const
|
|
846
|
-
Applying ${String(
|
|
847
|
-
`);const
|
|
848
|
-
`)}else
|
|
849
|
-
`)
|
|
850
|
-
`)
|
|
851
|
-
${
|
|
852
|
-
`),process.exitCode=
|
|
853
|
-
✓ Already up to date (${
|
|
854
|
-
✓ Updated @visulima/vis from ${
|
|
855
|
-
`)}t.visConfig={}}const
|
|
856
|
-
`);
|
|
857
|
-
`),t.visConfig=await
|
|
858
|
-
\x1B[2mtip: ${
|
|
859
|
-
`),r.lastGlobal=e,r.perTip[
|
|
860
|
-
${re("vis update available:")} ${
|
|
861
|
-
`),e.lastNoticeAt=r,
|
|
973
|
+
`),i.info(fo(F)),A>F.length){const D=[...g.values()].reduce((z,me)=>z+me.size,0),O=D>A?` (${String(D)} catalog entries, ${String(D-A)} duplicates)`:"";i.info(` Checked ${String(A)} unique packages${O}: ${String(_)} up-to-date${L.length>0?`, ${String(L.length)} failed`:""}`)}if(I.length>0){process.stdout.write(`
|
|
974
|
+
`);const D=`${String(I.length)} package${I.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${Oe(X.createElement(l,{color:"yellow"},` ${D}`),{columns:le})}
|
|
975
|
+
`);for(const O of I)process.stdout.write(`${Oe(X.createElement(l,null," ",X.createElement(l,{dimColor:!0},O.packageName),` ${O.currentRange} → ${O.newRange}`,X.createElement(l,{dimColor:!0},` ${O.updateType}`)),{columns:le})}
|
|
976
|
+
`)}const ke=Array.isArray(ce)?ce:[];if(ke.length>0&&!j){i.info(`
|
|
977
|
+
Applying ${String(ke.length)} updates...
|
|
978
|
+
`);const D={...n,install:n.install??s.install};await vc(t,e,ke,D,i)}return}if(j){if(N==="json"){const P={failed:L,filteredByTarget:I,ignored:M,outdated:F};C&&(P.aiAnalysis=C),process.stdout.write(`${JSON.stringify(P,void 0,2)}
|
|
979
|
+
`)}else i.info(`Would update ${String(F.length)} dependencies:
|
|
980
|
+
`),yc(F,L,N,i),C&&(i.info(""),i.info(po(C))),mc(I,i);return}C&&N!=="json"&&(i.info(po(C)),i.info(""));let R=F;if(n.interactive&&(R=await qy(F),R.length===0)){i.info("No updates selected.");return}i.info(`Updating ${String(R.length)} catalog dependencies...
|
|
981
|
+
`),yc(R,[],N,i),mc(I,i);const V={...n,install:n.install??s.install};await vc(t,e,R,V,i)},"executeCatalogUpdate"),NT=ur((t,e,r,n,o,i)=>{const s={dev:n.dev,filters:yt(n.filter),global:n.global,interactive:n.interactive,latest:n.latest||n.target==="latest",noOptional:n.noOptional,noSave:n.noSave,packages:o,prod:n.prod,recursive:n.recursive,workspaceRoot:n.workspaceRoot},{command:a,warnings:c}=RT(e,r,s);for(const p of c)i.warn(p);const d=`${a.bin} ${a.args.join(" ")}`.trim();if(n.dryRun){i.info(`Would run: ${d}`);return}i.info(`Running: ${d}`);try{Pn(d,{cwd:t,env:process.env,stdio:"inherit"})}catch(p){const g=p.status??1;i.error(`
|
|
982
|
+
${Ue("✖")} Update failed (exit code ${String(g)})`),i.error(` Command: ${d}`),i.error(` Directory: ${t}
|
|
983
|
+
`),process.exitCode=g}},"executePmWrapper"),MT={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"]],execute:ur(async({argument:t,logger:e,options:r,visConfig:n,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");let i=t;const s=o,{packageManager:a}=$o(s);if(!r.noTyposquatCheck){if(i.length>0){const c=i.map(g=>Qi(g)),d=n?.security?.typosquatAllowlist,p=await yl(c.map(g=>g.name),d);if(!p.ok){process.exitCode=1;return}i=c.map((g,m)=>{const y=p.packages[m];return y!==g.name?g.versionSpec?`${y}@${g.versionSpec}`:y??"":i[m]??""})}else if(!await vl(s,n?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(r.rollback){if(!Dy(s,a)){e.info("No backup found. Run 'vis update' first to create a backup.");return}if(My(s,a))e.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(!r.noCatalog&&my(s,a))await PT(s,a,n??{},r,i,e);else{const c=Uu(a);NT(s,a,c,r,i,e)}},"execute"),group:"Dependencies",name:"update",options:[{alias:"L",defaultValue:!1,description:"Update to latest version (ignore semver range)",name:"latest",type:Boolean},{alias:"t",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",name:"filter",type:String},{alias:"w",defaultValue:!1,description:"Include workspace root",name:"workspace-root",type:Boolean},{alias:"D",defaultValue:!1,description:"Update only devDependencies",name:"dev",type:Boolean},{alias:"P",defaultValue:!1,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},{alias:"l",defaultValue:!1,description:"Include packages with pinned/exact versions (no ^ or ~ prefix)",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},{defaultValue:!1,description:"Check for known security vulnerabilities (via OSV.dev)",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}]};var DT=Object.defineProperty,BT=b((t,e)=>DT(t,"name",{value:e,configurable:!0}),"o$1");const FT={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"]],execute:BT(async({argument:t,logger:e,options:r})=>{const n=t?.[0];e.info("info: checking for updates...");const o=kn.version;let i;try{const s=Pn("npm view @visulima/vis version",{encoding:"utf8"}).trim();i=n??s}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(o===i&&!r.force){e.info(`
|
|
984
|
+
✓ Already up to date (${o})`);return}if(r.check){o===i?e.info(`✓ Already up to date (${o})`):e.info(`info: found @visulima/vis@${i} (current: ${o})`);return}if(e.info(`info: found @visulima/vis@${i} (current: ${o})`),e.info("info: installing..."),ct("npm",["install","-g",`@visulima/vis@${i}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
|
|
985
|
+
✓ Updated @visulima/vis from ${o} → ${i}`)},"execute"),group:"System",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}]};var LT=Object.defineProperty,VT=b((t,e)=>LT(t,"name",{value:e,configurable:!0}),"t$2");const UT={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"]],execute:VT(async({argument:t,logger:e,options:r,workspaceRoot:n})=>{const o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis why <package...>");const i=n??process.cwd(),s=Ne(i),a=Zg(s,{depth:r.depth===void 0?void 0:Number(r.depth),dev:r.dev||!1,filter:Dn(r.filter),global:r.global||!1,json:r.json||!1,long:r.long||!1,noOptional:r.noOptional||!1,packages:o,parseable:r.parseable||!1,prod:r.prod||!1,recursive:r.recursive||!1},i,e);a!==0&&a!==1&&(process.exitCode=a)},"execute"),group:"Dependencies",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",defaultValue:!1,description:"Filter to dev dependencies (pnpm)",name:"dev",type:Boolean},{alias:"P",defaultValue:!1,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}]};var _T=Object.defineProperty,GT=b((t,e)=>_T(t,"name",{value:e,configurable:!0}),"l$2");const WT={beforeCommand:GT(async t=>{try{const e=t.options?.cwd;let r;if(e)r=Pp(process.cwd(),e);else{const i=process.env.VIS_MONOREPO_ROOT;r=i&&i.length>0?i:xc(process.cwd()).path}t.workspaceRoot=r;let n=Yr(r);try{t.visConfig=await Us(r);const i=t.visConfig?.versionConstraint;if(i&&!np(i)){t.logger.error(""),t.logger.error(Ue(fr("✖ Invalid versionConstraint"))),t.logger.error(` vis.config.ts has versionConstraint ${fr(JSON.stringify(i))}, which is not a valid semver range.`),t.logger.error(""),process.exitCode=1;return}if(i&&!op(kn.version,i)){t.logger.error(""),t.logger.error(Ue(fr("✖ vis version too old"))),t.logger.error(` vis.config.ts requires vis ${fr(i)}, but the current version is ${fr(kn.version)}.`),t.logger.error(` ${Re("→")} Upgrade: ${st("pnpm add -D @visulima/vis@latest")}`),t.logger.error(""),process.exitCode=1;return}}catch(i){const s=n;if(s){const a=i instanceof Error?i.message:String(i);if(t.logger.error(""),t.logger.error(Ue(fr(`✖ Failed to load ${s}`))),t.logger.error(` ${a}`),t.logger.error(""),a.includes("Cannot find module")){const c=/Cannot find module '([^']+)'/.exec(a)?.[1]??"unknown";t.logger.error(`${Re("→ Hint:")} The module ${fr(c)} could not be resolved.`),c.includes("@visulima/vis")?(t.logger.error(" This usually means the package isn't installed or the export path changed."),t.logger.error(` Try: ${st("pnpm add @visulima/vis")}`),t.logger.error(` Or regenerate: ${st("vis init --force")}`)):t.logger.error(` Try: ${st(`pnpm add ${c}`)}`)}else a.includes("SyntaxError")||a.includes("Unexpected token")?(t.logger.error(`${Re("→ Hint:")} The config file has a syntax error.`),t.logger.error(" Check your config for typos or invalid syntax."),t.logger.error(` Or regenerate: ${st("vis init --force")}`)):(t.logger.error(`${Re("→ Hint:")} Delete the broken config and recreate it:`),t.logger.error(` ${st(`rm ${s} && vis init`)}`));t.logger.error(""),t.logger.error(` Continuing with default settings.
|
|
986
|
+
`)}t.visConfig={}}const o=process.argv[2]??"";if(!new Set(["--help","--version","-h","-V","create","help","implode","init"]).has(o)&&!n&&!lt)if(process.stdin.isTTY){const i=dt({input:process.stdin,output:process.stderr}),s=await new Promise(a=>{i.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 ",a),i.on("SIGINT",()=>{i.close(),a("n")})});if(i.close(),!s.trim()||s.trim().toLowerCase()==="y"||s.trim().toLowerCase()==="yes"){const a=Np(r,"vis.config.ts"),c=['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(`
|
|
987
|
+
`);Se(a,c),t.logger.info(`✓ Created ${a}
|
|
988
|
+
`),t.visConfig=await Us(r),n=a}}else t.logger.warn("No vis.config.ts found. Run 'vis init' to create one with best-practice security defaults.")}catch(e){e instanceof Error&&!e.message.includes("monorepo root")&&t.logger.warn(`Failed to detect workspace: ${e.message}`),t.visConfig={}}},"beforeCommand"),name:"config-loader"};var zT=Object.defineProperty,ge=b((t,e)=>zT(t,"name",{value:e,configurable:!0}),"e");const wc=300*1e3,Oi=w(Xe(),".vis",".tip-state.json"),HT=ge(()=>{try{if(T(Oi))return ue(Oi)}catch{}return{lastGlobal:0,perTip:{}}},"readState"),qT=ge(t=>{try{je(w(Xe(),".vis")),Q(Oi,JSON.stringify(t))}catch{}},"writeState"),JT=[{cooldownMs:1800*1e3,id:"short-aliases",matches:ge(t=>["install","link","remove","uninstall","update"].includes(t.command),"matches"),message:ge(t=>{const e={install:"i",link:"ln",remove:"rm",uninstall:"rm",update:"up"}[t.command];return e?`You can use 'vis ${e}' as a shorthand for 'vis ${t.command}'`:""},"message"),probability:.5},{id:"use-exec",matches:ge(t=>t.command==="dlx"&&t.success,"matches"),message:ge(()=>"Use 'vis exec' to run locally installed binaries without downloading.","message")},{id:"security-check",matches:ge(t=>(t.command==="check"||t.command==="update")&&t.success&&!t.args.includes("--security"),"matches"),message:ge(()=>"Add --security to check for known vulnerabilities via OSV.dev","message"),probability:.3},{cooldownMs:3600*1e3,id:"ai-analysis",matches:ge(t=>(t.command==="check"||t.command==="update")&&t.success&&!t.args.includes("--ai"),"matches"),message:ge(()=>"Add --ai to run AI analysis on outdated packages before updating.","message"),probability:.2},{cooldownMs:1440*60*1e3,id:"socket-security",matches:ge(t=>(t.command==="install"||t.command==="update"||t.command==="check")&&t.success,"matches"),message:ge(()=>"Enable Socket.dev in vis.config.ts for security scores and supply chain alerts: security.socket.enabled = true","message"),probability:.15},{id:"dedupe-after-install",matches:ge(t=>t.command==="install"&&t.success,"matches"),message:ge(()=>"Run 'vis dedupe' periodically to remove duplicate dependencies.","message"),probability:.15},{cooldownMs:720*60*1e3,id:"doctor-checkup",matches:ge(t=>(t.command==="install"||t.command==="add"||t.command==="update")&&t.success,"matches"),message:ge(()=>"Run 'vis doctor' for a full project health check — outdated, security, duplicates, and optimizations in one view.","message"),probability:.25},{cooldownMs:10080*60*1e3,id:"init-config",matches:ge(t=>(t.command==="install"||t.command==="run")&&t.success&&!t.hasVisConfig,"matches"),message:ge(()=>"Run 'vis init' to create a vis.config.ts with secure defaults — supply chain protection enabled automatically.","message"),probability:.4},{id:"why-command",matches:ge(t=>t.command==="outdated"&&t.success,"matches"),message:ge(()=>"Use 'vis why <package>' to understand why a dependency is installed.","message"),probability:.3},{id:"graph-command",matches:ge(t=>t.command==="run"&&t.success,"matches"),message:ge(()=>"Use 'vis graph' to visualize your project dependency graph.","message"),probability:.1},{id:"affected-command",matches:ge(t=>t.command==="run"&&t.success&&!t.args.includes("--projects"),"matches"),message:ge(()=>"Use 'vis affected <target>' to run tasks only on changed projects.","message"),probability:.2},{id:"pm-cache",matches:ge(t=>t.command==="install"&&t.success,"matches"),message:ge(()=>"Use 'vis pm cache dir' to find your package manager's cache location.","message"),probability:.1},{id:"create-editor",matches:ge(t=>t.command==="create"&&t.success,"matches"),message:ge(()=>"Add --editor vscode to generate VS Code configuration during project creation.","message"),probability:.5},{id:"env-pin",matches:ge(t=>t.command==="env"&&t.args.includes("install")&&t.success,"matches"),message:ge(()=>"Use 'vis env pin <version>' to pin the Node.js version for your project.","message"),probability:.5},{id:"upgrade-check",matches:ge(t=>t.command!=="self-update"&&t.success,"matches"),message:ge(()=>"Run 'vis self-update --check' to see if a newer version of vis is available.","message"),probability:.05}],YT=ge(t=>{if(process.env.VIS_CLI_TEST||lt)return;const e=Date.now(),r=HT();if(e-r.lastGlobal<wc)return;const n=JT.filter(s=>{if(!s.matches(t))return!1;const a=r.perTip[s.id]??0,c=s.cooldownMs??wc;return e-a>=c});if(n.length===0)return;const o=n.find(s=>{const a=s.probability??1;return Math.random()<a});if(!o)return;const i=o.message(t);i&&(process.stderr.write(`
|
|
989
|
+
\x1B[2mtip: ${i}\x1B[0m
|
|
990
|
+
`),r.lastGlobal=e,r.perTip[o.id]=e,qT(r))},"showTip");var KT=Object.defineProperty,kc=b((t,e)=>KT(t,"name",{value:e,configurable:!0}),"o");const XT=kc(t=>({afterCommand:kc(async e=>{const r=process.argv.slice(2),n=r[0]??"";t&&t(),YT({args:r,command:n,hasVisConfig:e.visConfig!==void 0&&Object.keys(e.visConfig).length>0,success:process.exitCode===void 0||process.exitCode===0})},"afterCommand"),name:"post-command"}),"postCommandPlugin");var QT=Object.defineProperty,Pi=b((t,e)=>QT(t,"name",{value:e,configurable:!0}),"f$1");const bc=new Set(["add","install","update"]),ZT=new Set(["add","dedupe","install","remove","update"]),eE=/(\d+\.\d+\.\d+)/,tE=Pi(t=>{const e=w(t,"package.json");if(!T(e))return[];const r=[];try{const n=ue(e),o={...n.dependencies,...n.devDependencies};for(const[i,s]of Object.entries(o)){const a=w(t,"node_modules",i,"package.json");if(T(a))try{const d=ue(a);if(d.version){r.push({name:i,version:d.version});continue}}catch{}const c=eE.exec(s);c?.[1]&&r.push({name:i,version:c[1]})}}catch{}return r},"resolveInstalledPackages"),rE={afterCommand:Pi(async t=>{if(process.exitCode&&process.exitCode!==0)return;const e=t.scriptEnforcement;e?.postInstallPackages.length&&t.workspaceRoot&&iv(t.workspaceRoot,e.postInstallPackages);const r=process.argv[2]??"",n=Er(t.visConfig?.security?.socket);if(bc.has(r)&&n&&t.workspaceRoot)try{const o=tE(t.workspaceRoot);if(o.length>0){const i=await Xr(o,n);if(i.size>0){const s=hh(i);if(s){S(""),S(s);let a=0;for(const c of i.values())for(const d of c.alerts)(d.severity==="critical"||d.severity==="high")&&a++;a>0&&se(`${String(a)} critical/high severity alert${a===1?"":"s"} detected. Run 'vis check --security' for details.`)}}}}catch{}},"afterCommand"),beforeCommand:Pi(async t=>{const e=process.argv[2]??"";if(ZT.has(e)&&t.visConfig&&t.workspaceRoot){const r=Ne(t.workspaceRoot);if(ev(t.visConfig,r.name),bc.has(e)){const n=nv(r.name,t.workspaceRoot,t.visConfig);for(const o of n.warnings)t.logger.warn(`security: ${o}`);t.scriptEnforcement=n}}},"beforeCommand"),name:"security-enforcement"};var nE=Object.defineProperty,rr=b((t,e)=>nE(t,"name",{value:e,configurable:!0}),"s");const Eu=w(Xe(),".vis"),Ni=w(Eu,".upgrade-check.json"),oE=1440*60*1e3,iE=1440*60*1e3,sE=500,aE=new Set(["--help","--version","-h","-V","help","implode","self-update","upgrade"]),cE=rr(()=>{try{if(T(Ni))return ue(Ni)}catch{}},"readCache"),Ru=rr(t=>{try{je(Eu),Q(Ni,JSON.stringify(t))}catch{}},"writeCache"),lE=rr(async t=>{try{const e=new AbortController,r=setTimeout(()=>{e.abort()},sE),n=await fetch(`https://registry.npmjs.org/${t}/latest`,{headers:{accept:"application/json"},signal:e.signal});return clearTimeout(r),n.ok?(await n.json()).version:void 0}catch{return}},"fetchLatestVersion"),dE=rr((t,e)=>{const r=rr(i=>i.replace(/^v/,"").split("-")[0].split(".").map(Number),"parseSemver"),n=r(t),o=r(e);for(let i=0;i<3;i++){if((o[i]??0)>(n[i]??0))return!0;if((o[i]??0)<(n[i]??0))return!1}return!1},"isNewerVersion"),$c=rr((t,e)=>{if(!dE(t,e.latestVersion))return;const r=Date.now();r-e.lastNoticeAt<iE||(process.stderr.write(`
|
|
991
|
+
${re("vis update available:")} ${ll(t)} ${re(Hi.arrow)} ${cl(ye(e.latestVersion))}${re(", run")} ${Be("vis upgrade")}
|
|
992
|
+
`),e.lastNoticeAt=r,Ru(e))},"showUpgradeNotice"),uE=rr(t=>{if(lt||process.env.VIS_CLI_TEST||process.env.VIS_NO_UPDATE_CHECK==="1"||!process.stderr.isTTY||aE.has(t))return!1;const e=new Set(process.argv.slice(2));return!(e.has("--silent")||e.has("-s")||e.has("--json"))},"shouldCheck"),pE=rr((t,e)=>{if(!uE(e))return;const r=cE(),n=Date.now();if(r&&n-r.lastQueryAt<oE)return()=>{$c(t,r)};let o=r;return lE("@visulima/vis").then(i=>{i&&(o={lastNoticeAt:r?.lastNoticeAt??0,lastQueryAt:n,latestVersion:i},Ru(o))}).catch(()=>{}),()=>{o&&$c(t,o)}},"startUpgradeCheck");Du();_g();try{const t=xc(process.cwd()).path;process.env.VIS_MONOREPO_ROOT=t;const e=ue(w(t,"package.json"));e.name&&Gg(e.name)}catch{}const fE=pE(kn.version,process.argv[2]??"");Mu();const oe=Pu("vis",{packageName:"vis",packageVersion:kn.version}),gE=process.argv.includes("--debug")||!!process.env.DEBUG;oe.addPlugin(Bu({detailed:gE,exitOnError:!1}));oe.addGlobalOption({description:"Override workspace root directory",name:"cwd",type:String});oe.addPlugin(WT);oe.addPlugin(rE);oe.addCommand(U1);oe.addCommand(pw);oe.addCommand(vS);oe.addCommand(Og);oe.addCommand(Bh);oe.addCommand(wT);oe.addCommand(p0);oe.addCommand(XS);oe.addCommand(MT);oe.addCommand(lw);oe.addCommand(Vm);oe.addCommand(Qy);oe.addCommand(TC);oe.addCommand(Zj);oe.addCommand(iT);oe.addCommand(aT);oe.addCommand(hT);oe.addCommand(Pb);oe.addCommand(O0);oe.addCommand(Nu);oe.addCommand(T0);oe.addCommand(Nh);oe.addCommand(PC);oe.addCommand(bk);oe.addCommand(UT);oe.addCommand(v0);oe.addCommand(I0);oe.addCommand($T);oe.addCommand(xb);oe.addCommand(b$);oe.addCommand(IC);oe.addCommand(x0);oe.addCommand(yw);oe.addCommand(Mv);oe.addCommand(vk);oe.addCommand(X$);oe.addCommand(bb);oe.addCommand(FT);oe.addCommand(h0);oe.addCommand(cv);oe.addCommand(kv);oe.addCommand(v$);oe.addCommand(f$);oe.addCommand(xj);oe.addCommand(Yj);oe.addPlugin(XT(fE));try{await oe.run()}catch{process.exitCode=process.exitCode||1}
|