@visulima/vis 4.3.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +55 -129
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/packem_chunks/bloom-sync.js +1 -1
  6. package/dist/packem_chunks/catalog.js +52 -49
  7. package/dist/packem_chunks/cli-exec.js +1 -1
  8. package/dist/packem_chunks/cli-main.js +164 -164
  9. package/dist/packem_chunks/fix.js +1 -1
  10. package/dist/packem_chunks/handler13.js +1 -1
  11. package/dist/packem_chunks/handler15.js +1 -1
  12. package/dist/packem_chunks/handler19.js +1 -1
  13. package/dist/packem_chunks/handler2.js +1 -1
  14. package/dist/packem_chunks/handler20.js +1 -1
  15. package/dist/packem_chunks/handler21.js +1 -1
  16. package/dist/packem_chunks/handler24.js +1 -1
  17. package/dist/packem_chunks/handler28.js +1 -1
  18. package/dist/packem_chunks/handler3.js +1 -1
  19. package/dist/packem_chunks/handler4.js +1 -1
  20. package/dist/packem_chunks/handler5.js +2 -2
  21. package/dist/packem_chunks/handler50.js +1 -1
  22. package/dist/packem_chunks/handler54.js +2 -2
  23. package/dist/packem_chunks/handler55.js +1 -1
  24. package/dist/packem_chunks/handler58.js +1 -1
  25. package/dist/packem_chunks/handler59.js +1 -1
  26. package/dist/packem_chunks/handler6.js +6 -6
  27. package/dist/packem_chunks/handler63.js +1 -1
  28. package/dist/packem_chunks/handler65.js +4 -4
  29. package/dist/packem_chunks/handler66.js +1 -1
  30. package/dist/packem_chunks/handler68.js +4 -4
  31. package/dist/packem_chunks/handler70.js +5 -5
  32. package/dist/packem_chunks/handler71.js +1 -1
  33. package/dist/packem_chunks/handler72.js +1 -1
  34. package/dist/packem_chunks/handler73.js +1 -1
  35. package/dist/packem_chunks/handler74.js +1 -1
  36. package/dist/packem_chunks/handler75.js +26 -26
  37. package/dist/packem_chunks/handler76.js +7 -7
  38. package/dist/packem_chunks/handler77.js +2 -2
  39. package/dist/packem_chunks/handler78.js +1 -1
  40. package/dist/packem_chunks/handler8.js +1 -1
  41. package/dist/packem_chunks/heal.js +1 -1
  42. package/dist/packem_chunks/help-command.js +7 -7
  43. package/dist/packem_chunks/list.js +1 -1
  44. package/dist/packem_chunks/run.js +1 -1
  45. package/dist/packem_chunks/sync.js +1 -1
  46. package/dist/packem_chunks/verify-lockfile.js +1 -1
  47. package/dist/packem_shared/{affected-selection-BzIbfpA1.js → affected-selection-D4giBK2X.js} +1 -1
  48. package/dist/packem_shared/{ai-analysis-Cfj24UAy.js → ai-analysis-pldoS_N4.js} +2 -2
  49. package/dist/packem_shared/{ai-fix-DeRUtT-s.js → ai-fix-BC6aIRJT.js} +4 -4
  50. package/dist/packem_shared/{bin-D9TsVhq2.js → bin-C1XKj-O-.js} +1 -1
  51. package/dist/packem_shared/{ecosystem-gate-1M3wnsTr.js → ecosystem-gate-ddru_hOg.js} +1 -1
  52. package/dist/packem_shared/{index-BO8qIogg.js → index-Chje3u9v.js} +1 -1
  53. package/dist/packem_shared/{index-CNYv9D8g.js → index-DQ2GJzmy.js} +1 -1
  54. package/dist/packem_shared/{missing-package-json-DnHMxRnG.js → missing-package-json-Cu5YVAot.js} +1 -1
  55. package/dist/packem_shared/{multi-eco-lockfiles-CUUxUjHK.js → multi-eco-lockfiles-B2X3yhyo.js} +1 -1
  56. package/dist/packem_shared/{package-version-DUcG-b7S.js → package-version-Dxirp-UO.js} +1 -1
  57. package/dist/packem_shared/{packument-CyGSNquL.js → packument-BQv4je9m.js} +1 -1
  58. package/dist/packem_shared/{project-name-filter--bq-FL2f.js → project-name-filter-D6tXD8gd.js} +1 -1
  59. package/dist/packem_shared/{provenance-DyF0b6KX.js → provenance-DNyVMxNv.js} +1 -1
  60. package/dist/packem_shared/{resolve-explicit-BjCEm0s-.js → resolve-explicit-BPsdmuty.js} +1 -1
  61. package/dist/packem_shared/{s1ngularity-YfmkD_AH.js → s1ngularity-QD2LD1sO.js} +1 -1
  62. package/dist/packem_shared/{scan-progress-C_zaZjyY.js → scan-progress-CkumcBG-.js} +2 -2
  63. package/dist/packem_shared/{signatures-CL3ckp_Y.js → signatures-t8LbOaqr.js} +1 -1
  64. package/dist/packem_shared/spinner-ukDEdGvp.js +1 -0
  65. package/dist/packem_shared/tabs--uxJGL8N.js +1 -0
  66. package/dist/packem_shared/use-measured-height-DUZyyias.js +1 -0
  67. package/dist/packem_shared/{vis-update-app-D73C__fx.js → vis-update-app-BCIccZfA.js} +1 -1
  68. package/dist/packem_shared/{vis-user-error-Cpg2FqA4.js → vis-user-error-75VtCwMv.js} +15 -15
  69. package/index.js +52 -52
  70. package/package.json +11 -11
  71. package/dist/packem_shared/spinner-DuB0K0Am.js +0 -1
  72. package/dist/packem_shared/tabs-RZd_e1M0.js +0 -1
  73. package/dist/packem_shared/use-measured-height-DWkDV9Dj.js +0 -1
@@ -1,2 +1,2 @@
1
- import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-BzhrR_iC.js";import{l as B,m as X,n as J,D as Q,o as Z,$ as ee,k as _}from"../packem_shared/formatBytes-BHAzNIrn-CrusHOew.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as se}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{h as re,U as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{g as ne,r as ce}from"../packem_shared/packument-CyGSNquL.js";import{q as ie,j as ae,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-sXNQYpsl.js";import{a as le,o as fe}from"../packem_shared/pm-runner-CMSml1Bj.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-p4IXiIf6.js";let V;const z=e=>(V??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return z(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(te(k)){const e=se(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{re(B());const t=`${k}.${String(process.pid)}.tmp`;oe(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await ne(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ce(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await J([{name:t,version:c}],{apiToken:a,minimumScore:Q});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??X(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>Z(G(e)),Re={critical:E,high:E,low:v,medium:S},D=e=>{if(!(e===void 0||e<0))return ee(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=D(r),a=D(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},j=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ie(i.label.padEnd(j)):" ".repeat(j);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ae(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},De=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),je=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!De(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},je)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
1
+ import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-BzhrR_iC.js";import{l as B,m as X,n as J,D as Q,o as Z,$ as ee,k as _}from"../packem_shared/formatBytes-BHAzNIrn-CrusHOew.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as se}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{h as re,U as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{g as ne,r as ce}from"../packem_shared/packument-BQv4je9m.js";import{q as ie,j as ae,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-sXNQYpsl.js";import{a as le,o as fe}from"../packem_shared/pm-runner-CMSml1Bj.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-p4IXiIf6.js";let V;const z=e=>(V??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return z(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(te(k)){const e=se(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{re(B());const t=`${k}.${String(process.pid)}.tmp`;oe(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await ne(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ce(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await J([{name:t,version:c}],{apiToken:a,minimumScore:Q});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??X(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>Z(G(e)),Re={critical:E,high:E,low:v,medium:S},D=e=>{if(!(e===void 0||e<0))return ee(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=D(r),a=D(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},j=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ie(i.label.padEnd(j)):" ".repeat(j);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ae(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},De=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),je=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!De(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},je)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
2
2
  `);if(c)return R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:!0};const g=await Y("? Ok to proceed? (y/N) ",e.readline);return g&&R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:g}},Je=async({argument:e,logger:t,options:s,process:r,visConfig:o,workspaceRoot:a})=>{const n=e;if(!n||n.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[u,...i]=n,c=a??r.cwd,l=s.package?Array.isArray(s.package)?s.package:[s.package]:[],f=s.shellMode?l:[u,...l];for(const h of f){const d=!s.info||_(r.env.VIS_DLX_NO_INFO),b=!d&&s.info;if(!(await Be({forceInfo:b,noInfo:d,offline:s.offline||!1,pkg:h,socketToken:o?.security?.socket?.apiToken??r.env.VIS_SOCKET_TOKEN,workspaceRoot:c,yes:s.yes||_(r.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const y=ue({logger:t,options:s,visConfig:o},c),p=le(c,{backend:pe(y),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),m=fe(p,{additionalPackages:l,args:i,package:u,shellMode:s.shellMode||!1,silent:s.silent||!1},c,t,{offline:s.offline||!1});m!==0&&(process.exitCode=m)};export{Je as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-sXNQYpsl.js";import{e as I,z as se,a as $}from"../packem_shared/index-BzhrR_iC.js";import U from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{$ as oe,_ as F,w as ne,a6 as ae,a7 as ie,a8 as re,a9 as ce}from"./cli-main.js";import{k as pe,l as z,F as W,p as L,O as K,a as fe}from"./catalog.js";import{p as S}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{U as le}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{T as j}from"../packem_shared/target-merge-DVJl-7Qz.js";import{l as ue}from"../packem_shared/missing-package-json-DnHMxRnG.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>U(s,a)),G=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&G(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&U(t,e.depName)&&G(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
1
+ import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-sXNQYpsl.js";import{e as I,z as se,a as $}from"../packem_shared/index-BzhrR_iC.js";import U from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{$ as oe,_ as F,v as ne,a6 as ae,a7 as ie,a8 as re,a9 as ce}from"./cli-main.js";import{k as pe,l as z,E as W,p as L,N as K,a as fe}from"./catalog.js";import{p as S}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{U as le}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{T as j}from"../packem_shared/target-merge-DVJl-7Qz.js";import{l as ue}from"../packem_shared/missing-package-json-Cu5YVAot.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>U(s,a)),G=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&G(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&U(t,e.depName)&&G(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
2
2
  `)?`\r
3
3
  `:`
4
4
  `,o=a.filter(d=>d.catalogName==="default").sort((d,u)=>d.depName.localeCompare(u.depName));if(o.length===0)return;const i=r.length>0?r.split(n):[],c=i.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(c===-1){const d=["catalog:"];for(const J of o)d.push(` ${J.depName}: "${J.specifier}"`);let u=0;for(;u<i.length&&(i[u]??"").trim().length===0;)u+=1;const k=[...i.slice(0,u),...d,"",...i.slice(u)].join(n);return H(s,k.endsWith(n)?k:`${k}${n}`),s}let p=i.length;const f=new Set;for(let d=c+1;d<i.length;d+=1){const u=i[d]??"",k=u.trimStart();if(u.length===0)continue;if(u.length-k.length===0&&k.length>0&&!k.startsWith("#")){p=d;break}const P=/^([\w./@-]+)\s*:/.exec(k);P?.[1]&&f.add(P[1])}const m=[];for(const d of o)f.has(d.depName)||m.push(` ${d.depName}: "${d.specifier}"`);if(m.length===0)return;const h=[...i.slice(0,p),...m,...i.slice(p)].join(n);return H(s,h.endsWith(n)?h:`${h}${n}`),s},be=(e,a)=>{if(a.length===0)return"";const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=[...a].sort((f,m)=>f.depName.localeCompare(m.depName)),o=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],i=r.includes(`\r
@@ -6,8 +6,8 @@ import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b
6
6
  `:`
7
7
  `;if((r.length>0?r.split(i):[]).findIndex(f=>/^catalog\s*:\s*$/.test(f))===-1){o.push("@@ +1 @@","+catalog:");for(const f of n)o.push(`+ ${f.depName}: "${f.specifier}"`)}else{o.push("@@ catalog: @@");for(const f of n)o.push(`+ ${f.depName}: "${f.specifier}"`)}return o.join(i)},Ne=e=>{const a=[],s=pe(e);if(s){const r=I(e,"pnpm-workspace.yaml");for(const n of s)n.startsWith("!")||z(e,[n]).length===0&&a.push({pattern:n,source:"pnpm-workspace.yaml",sourcePath:r})}const t=I(e,"package.json");if(_(t)){const n=S(t).workspaces,o=Array.isArray(n)?n:n?.packages;if(o)for(const i of o)typeof i!="string"||i.startsWith("!")||z(e,[i]).length===0&&a.push({pattern:i,source:"package.json",sourcePath:t})}return a},Te=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.sourcePath);o?o.push(n):t.set(n.sourcePath,[n])}const r=[];for(const[n,o]of t){const i=new Set(o.map(m=>m.pattern));if(n.endsWith(".yaml")||n.endsWith(".yml")){const h=se(n).split(`
8
8
  `).filter(d=>{const u=d.trim();if(!u.startsWith("- "))return!0;const k=u.slice(2).replaceAll(/^['"]|['"]$/g,"");return!i.has(k)}).join(`
9
- `);le(n,h,{overwrite:!0}),r.push(n);continue}const p=S(n),f=p.workspaces;Array.isArray(f)?p.workspaces=f.filter(m=>typeof m!="string"||!i.has(m)):f&&Array.isArray(f.packages)&&(f.packages=f.packages.filter(m=>typeof m!="string"||!i.has(m))),j(n,p,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},xe=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Je=(e,a={})=>{const s=new Set(a.ignoreBlocks),t=oe(e),r=[];for(const n of t){const o=I(e,n,"package.json"),i=F(o);if(!i)continue;const c=typeof i.name=="string"?i.name:void 0;for(const p of xe){if(s.has(p))continue;const f=i[p];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:p,packageDir:n,packageJsonPath:o,packageName:c})}}return r},Se=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&!Array.isArray(p)&&Object.keys(p).length===0&&Reflect.deleteProperty(i,c.depType)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Ie=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Me=(e,a={})=>{const s=new Set(a.depTypes??Ie),t=new Set(a.ignoreDeps),r=new Map;for(const o of e)o.packageDir!=="."||!s.has(o.depType)||r.set(o.depName,{depType:o.depType,specifier:o.specifier});if(r.size===0)return[];const n=[];for(const o of e){if(o.packageDir==="."||!s.has(o.depType)||t.has(o.depName))continue;const i=r.get(o.depName);i&&n.push({childSpecifier:o.specifier,depName:o.depName,depType:o.depType,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},We=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:s}]},je=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath),o=n.dependencies;if(typeof o!="object"||o===null)continue;const i=o;n.devDependencies??={};const c=n.devDependencies;for(const p of r.depNames){const f=i[p];typeof f=="string"&&(p in c||(c[p]=f),Reflect.deleteProperty(i,p))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ae=/^[a-z][\w-]*@\S+$/i,Ee=(e,a,s={})=>{if(!a)return[];const t=I(e,"package.json"),r=F(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&Ae.test(n)?[]:[{packageJsonPath:t,suggested:s.suggested}]},Re=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){if(!r.suggested)continue;const n=S(r.packageJsonPath);n.packageManager=r.suggested,j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ce=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);return t?t.private===!0?[]:[{packageJsonPath:s,rawValue:t.private}]:[]},Ve=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath);let o=n;if("private"in n)n.private=!0;else{const{name:i,version:c,...p}=n,f={};i!==void 0&&(f.name=i),c!==void 0&&(f.version=c),f.private=!0;for(const[m,h]of Object.entries(p))f[m]=h;o=f}j(r.packageJsonPath,o,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},_e=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],Fe=new Set(["dependencies","devDependencies","peerDependencies"]),Oe=(e,a)=>{for(const s of e)if(s.members?.includes(a)||s.prefixes?.some(t=>a.startsWith(t)))return s},Be=e=>e.startsWith("workspace:")||e.startsWith("catalog:"),He=(e,a={})=>{const s=new Set(a.ignoreFamilies),t=new Map;for(const i of _e)t.set(i.id,i);for(const i of a.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!Fe.has(i.depType)||Be(i.specifier))continue;const c=Oe(r,i.depName);if(!c||s.has(c.id))continue;const p=n.get(c.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};p?p.push(f):n.set(c.id,[f])}const o=[];for(const[i,c]of n){const p=[...new Set(c.map(m=>m.specifier))];if(p.length<2)continue;const f=t.get(i);f&&o.push({family:i,familyLabel:f.label??i,members:c,specifiers:p})}return o},ze=e=>e.startsWith("@types/"),Le=(e,a={})=>{const s=new Set(a.ignoreDeps),t=new Map,r=o=>{const i=t.get(o);if(i!==void 0)return i;try{const p=S(o).private===!0;return t.set(o,p),p}catch{return t.set(o,!1),!1}},n=[];for(const o of e)o.depType==="dependencies"&&ze(o.depName)&&(s.has(o.depName)||r(o.packageJsonPath)&&n.push({childSpecifier:o.specifier,depName:o.depName,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName}));return n},Ke=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n),c=i.dependencies;if(typeof c!="object"||c===null)continue;const p=c;i.devDependencies??={};const f=i.devDependencies;for(const m of o){const h=p[m.depName];typeof h=="string"&&(m.depName in f||(f[m.depName]=h),Reflect.deleteProperty(p,m.depName))}Object.keys(p).length===0&&Reflect.deleteProperty(i,"dependencies"),j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},qe=e=>e.startsWith("workspace:"),Ge=(e,a={})=>{const s=a.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(qe(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:s,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},Ue=(e,a,s,t)=>{const r=a.split(".");let n=e;for(let c=0;c<r.length-1;c+=1){const p=r[c],f=n[p];(typeof f!="object"||f===null)&&(n[p]={}),n=n[p]}const o=r.at(-1);let i=n[o];(typeof i!="object"||i===null)&&(i={},n[o]=i),i[s]=t},Ye=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o)if(c.depType.includes("."))Ue(i,c.depType,c.depName,c.fix);else{const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Xe=new Set(["dependencies","devDependencies","peerDependencies"]),Qe=e=>e.startsWith("catalog:"),Ze=e=>e.startsWith("workspace:"),et=e=>{if(!e.startsWith("catalog:"))return;const a=e.slice(8);return a===""?"default":a},tt=(e,a)=>{if(e.get("default")?.has(a))return"default";const s=[...e.keys()].filter(t=>t!=="default").sort();for(const t of s)if(e.get(t)?.has(a))return t},st=e=>e==="default"?"catalog:":`catalog:${e}`,ot=(e,a)=>{const s=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of s){const n=L(r.specifier);if(!n)continue;if(!t){t=r;continue}const o=L(t.specifier);if(!o){t=r;continue}const i=K(o,n),c=K(n,o);(a==="highest"&&i||a==="lowest"&&c)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},nt=(e,a={})=>{const s=a.resolve??"highest",t=new Set(a.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!Xe.has(i.depType)||Ze(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),o=new Map;for(const i of n){const c=o.get(i.depName);c?c.push(i):o.set(i.depName,[i])}for(const[i,c]of o){const p=a.pinned?.get(i);if(p!==void 0){for(const u of c)u.specifier!==p&&r.push({canonicalSource:"cli:--pin",depName:i,depType:u.depType,fix:p,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier});continue}if(s==="catalog"){const{catalogs:u}=a;if(!u)continue;const k=tt(u,i);if(!k)continue;const J=st(k);for(const P of c)et(P.specifier)!==k&&r.push({canonicalSource:`catalog:${k}`,depName:i,depType:P.depType,fix:J,packageDir:P.packageDir,packageJsonPath:P.packageJsonPath,packageName:P.packageName,specifier:P.specifier});continue}const f=c.filter(u=>!Qe(u.specifier));if(f.length<2||new Set(f.map(u=>u.specifier)).size<=1)continue;const h=ot(f,s);if(!h)continue;const d=h.canonical.specifier;for(const u of f)u.specifier!==d&&r.push({canonicalSource:h.canonicalSource,depName:i,depType:u.depType,fix:d,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier})}return r},at=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},it=e=>{if(_(I(e,"pnpm-workspace.yaml")))return!0;const a=I(e,"package.json");if(!_(a))return!1;try{return S(a).workspaces!==void 0}catch{return!1}},A=(e,a)=>{const s=new Map;for(const t of e){const r=a(t),n=s.get(r);n?n.push(t):s.set(r,[t])}return s},rt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-protocol: no violations"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i){const f=s?x("→"):b("→");t.info(` ${g(p.depType)} ${p.depName}: ${D(p.specifier)} ${f} ${v(p.fix)}`)}}s||t.info(g(" Run with --fix to rewrite specifiers in place."))},ct=(e,a,s)=>{if(e.length===0){s.info(v("✓ redefine-root: no violations"));return}s.info(b(w(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r)s.info(` ${g(o.depType)} ${o.depName}: ${D(o.childSpecifier)} ${g(`(root ${o.rootDepType}: ${o.rootSpecifier})`)}`)}s.info(g(" Remove these from child package.json files — root pin will resolve."))},pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-versions: no drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.depName)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)} ${g(f.depType)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align drifting specifiers."))},ft=(e,a,s)=>{if(e.length===0){s.info(v("✓ banned-deps: no violations"));return}s.info(D(w(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r){const i=o.replacement?` ${g("→")} ${v(o.replacement)}`:"";s.info(` ${g(o.depType)} ${D(o.depName)}${i}`),s.info(` ${g(o.reason)}`)}}},lt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ catalog-proposals: nothing worth promoting"));return}const r=s?"Added":"Would add",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const o of e)t.info(` ${w(o.depName)}: ${v(o.specifier)} ${g(`(${String(o.instanceCount)} packages agree)`)}`);if(!s){const o=be(a,e);if(o){t.info(""),t.info(g("Proposed pnpm-workspace.yaml changes:"));for(const i of o.split(`
10
- `))i.startsWith("+")?t.info(v(i)):i.startsWith("-")?t.info(D(i)):t.info(g(i))}t.info(g(" Run with --fix to write these entries to pnpm-workspace.yaml."))}},ut=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ custom-types: no engines / packageManager / volta drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} custom-type drift${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>`${c.customType} ${c.depName}`)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align engines/packageManager/volta versions."))},dt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ empty-deps: no empty dependency blocks"));return}const r=s?"Removed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} empty dependency block${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${g(p.depType)}: ${D("{}")}`)}s||t.info(g(" Run with --fix to drop empty blocks."))},gt=(e,a,s,t)=>{if(e.length===0){t.info(v('✓ root-private: root package.json is "private": true'));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);if(t.info(n(w(`${r} "private": true on root ${g(`(${i})`)}`))),!s){const c=o.rawValue===void 0?"absent":JSON.stringify(o.rawValue);t.info(` ${g("current:")} ${D(c)}`)}}s||t.info(g(' Run with --fix to set "private": true.'))},mt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-package-manager: packageManager field present"));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} packageManager on root ${g(`(${i})`)}`))),!s&&!o.suggested&&t.info(g(" no canonical specifier configured (set policy.rootPackageManager.suggested to enable --fix)"))}s||t.info(g(' e.g. "packageManager": "pnpm@10.32.1"'))},ht=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-deps: no runtime dependencies on private root"));return}const r=s?"Moved":"Found",n=s?x:b;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} ${String(o.depNames.length)} runtime dep${o.depNames.length===1?"":"s"} on private root ${g(`(${i})`)}`)));for(const c of o.depNames)t.info(` ${D(c)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},kt=(e,a)=>{if(e.length===0){a.info(v("✓ missing-package-json: every workspace dir has a package.json"));return}a.info(b(w(`Found ${String(e.length)} workspace dir${e.length===1?"":"s"} without a package.json`)));for(const s of e)a.info(` ${D(s.packageDir)}`);a.info(g(" Either delete the directory or scaffold a package.json (vis create)."))},yt=(e,a,s)=>{if(e.length===0){s.info(v("✓ dead-workspace-pattern: every workspace pattern matches at least one package"));return}const t=a?"Removed":"Found",r=a?x:b;s.info(r(w(`${t} ${String(e.length)} unmatched workspace pattern${e.length===1?"":"s"}`)));for(const[n,o]of A(e,i=>i.source)){s.info(` ${w(n)}`);for(const i of o)s.info(` ${D(i.pattern)}`)}a||s.info(g(" Run with --fix to drop dead patterns."))},Pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ types-in-deps: no @types/* in dependencies of private packages"));return}const r=s?"Moved":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} @types/* dep${e.length===1?"":"s"} in dependencies`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${D(p.depName)} ${g(p.childSpecifier)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},$t=(e,a,s)=>{if(e.length===0){s.info(v("✓ similar-deps: every related dep family is in sync"));return}s.info(b(w(`Found ${String(e.length)} family${e.length===1?"":" families"} with version drift`)));for(const t of e){s.info(` ${w(t.familyLabel)} ${g(`(${t.specifiers.join(", ")})`)}`);for(const r of t.members){const n=$(a,r.packageJsonPath),o=r.packageName??n;s.info(` ${o} ${g(`(${n})`)} ${g(r.depType)}: ${D(r.depName)}@${b(r.specifier)}`)}}s.info(g(" Pick a single specifier per family and align by hand — auto-fix is unsafe across name boundaries."))},wt=(e,a,s,t,r)=>{let n=!0;const o=i=>{n||r.info(""),n=!1,i()};t.workspaceProtocol&&o(()=>{rt(e.workspaceProtocol??[],a,s.workspaceProtocol,r)}),t.redefineRoot&&o(()=>{ct(e.redefineRoot??[],a,r)}),t.workspaceVersions&&o(()=>{pt(e.workspaceVersions??[],a,s.workspaceVersions,r)}),t.customTypes&&o(()=>{ut(e.customTypes??[],a,s.customTypes,r)}),e.catalogProposals!==void 0&&o(()=>{lt(e.catalogProposals??[],a,s.catalogProposals,r)}),t.bannedDeps&&o(()=>{ft(e.bannedDeps??[],a,r)}),t.emptyDeps&&o(()=>{dt(e.emptyDeps??[],a,s.emptyDeps,r)}),t.rootPrivate&&o(()=>{gt(e.rootPrivate??[],a,s.rootPrivate,r)}),t.rootPackageManager&&o(()=>{mt(e.rootPackageManager??[],a,s.rootPackageManager,r)}),t.rootDeps&&o(()=>{ht(e.rootDeps??[],a,s.rootDeps,r)}),t.missingPackageJson&&o(()=>{kt(e.missingPackageJson??[],r)}),t.deadWorkspacePatterns&&o(()=>{yt(e.deadWorkspacePatterns??[],s.deadWorkspacePatterns,r)}),t.typesInDeps&&o(()=>{Pt(e.typesInDeps??[],a,s.typesInDeps,r)}),t.similarDeps&&o(()=>{$t(e.similarDeps??[],a,r)})},vt=(e,a)=>{for(const s of e.workspaceProtocol??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`workspace-protocol ${t} ${s.depType} ${s.depName} ${s.specifier} → ${s.fix}
9
+ `);le(n,h,{overwrite:!0}),r.push(n);continue}const p=S(n),f=p.workspaces;Array.isArray(f)?p.workspaces=f.filter(m=>typeof m!="string"||!i.has(m)):f&&Array.isArray(f.packages)&&(f.packages=f.packages.filter(m=>typeof m!="string"||!i.has(m))),j(n,p,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},xe=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Je=(e,a={})=>{const s=new Set(a.ignoreBlocks),t=oe(e),r=[];for(const n of t){const o=I(e,n,"package.json"),i=F(o);if(!i)continue;const c=typeof i.name=="string"?i.name:void 0;for(const p of xe){if(s.has(p))continue;const f=i[p];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:p,packageDir:n,packageJsonPath:o,packageName:c})}}return r},Se=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&!Array.isArray(p)&&Object.keys(p).length===0&&Reflect.deleteProperty(i,c.depType)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Ie=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Me=(e,a={})=>{const s=new Set(a.depTypes??Ie),t=new Set(a.ignoreDeps),r=new Map;for(const o of e)o.packageDir!=="."||!s.has(o.depType)||r.set(o.depName,{depType:o.depType,specifier:o.specifier});if(r.size===0)return[];const n=[];for(const o of e){if(o.packageDir==="."||!s.has(o.depType)||t.has(o.depName))continue;const i=r.get(o.depName);i&&n.push({childSpecifier:o.specifier,depName:o.depName,depType:o.depType,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},We=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:s}]},je=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath),o=n.dependencies;if(typeof o!="object"||o===null)continue;const i=o;n.devDependencies??={};const c=n.devDependencies;for(const p of r.depNames){const f=i[p];typeof f=="string"&&(p in c||(c[p]=f),Reflect.deleteProperty(i,p))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ee=/^[a-z][\w-]*@\S+$/i,Ae=(e,a,s={})=>{if(!a)return[];const t=I(e,"package.json"),r=F(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&Ee.test(n)?[]:[{packageJsonPath:t,suggested:s.suggested}]},Re=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){if(!r.suggested)continue;const n=S(r.packageJsonPath);n.packageManager=r.suggested,j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ce=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);return t?t.private===!0?[]:[{packageJsonPath:s,rawValue:t.private}]:[]},Ve=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath);let o=n;if("private"in n)n.private=!0;else{const{name:i,version:c,...p}=n,f={};i!==void 0&&(f.name=i),c!==void 0&&(f.version=c),f.private=!0;for(const[m,h]of Object.entries(p))f[m]=h;o=f}j(r.packageJsonPath,o,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},_e=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],Fe=new Set(["dependencies","devDependencies","peerDependencies"]),Oe=(e,a)=>{for(const s of e)if(s.members?.includes(a)||s.prefixes?.some(t=>a.startsWith(t)))return s},Be=e=>e.startsWith("workspace:")||e.startsWith("catalog:"),He=(e,a={})=>{const s=new Set(a.ignoreFamilies),t=new Map;for(const i of _e)t.set(i.id,i);for(const i of a.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!Fe.has(i.depType)||Be(i.specifier))continue;const c=Oe(r,i.depName);if(!c||s.has(c.id))continue;const p=n.get(c.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};p?p.push(f):n.set(c.id,[f])}const o=[];for(const[i,c]of n){const p=[...new Set(c.map(m=>m.specifier))];if(p.length<2)continue;const f=t.get(i);f&&o.push({family:i,familyLabel:f.label??i,members:c,specifiers:p})}return o},ze=e=>e.startsWith("@types/"),Le=(e,a={})=>{const s=new Set(a.ignoreDeps),t=new Map,r=o=>{const i=t.get(o);if(i!==void 0)return i;try{const p=S(o).private===!0;return t.set(o,p),p}catch{return t.set(o,!1),!1}},n=[];for(const o of e)o.depType==="dependencies"&&ze(o.depName)&&(s.has(o.depName)||r(o.packageJsonPath)&&n.push({childSpecifier:o.specifier,depName:o.depName,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName}));return n},Ke=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n),c=i.dependencies;if(typeof c!="object"||c===null)continue;const p=c;i.devDependencies??={};const f=i.devDependencies;for(const m of o){const h=p[m.depName];typeof h=="string"&&(m.depName in f||(f[m.depName]=h),Reflect.deleteProperty(p,m.depName))}Object.keys(p).length===0&&Reflect.deleteProperty(i,"dependencies"),j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},qe=e=>e.startsWith("workspace:"),Ge=(e,a={})=>{const s=a.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(qe(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:s,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},Ue=(e,a,s,t)=>{const r=a.split(".");let n=e;for(let c=0;c<r.length-1;c+=1){const p=r[c],f=n[p];(typeof f!="object"||f===null)&&(n[p]={}),n=n[p]}const o=r.at(-1);let i=n[o];(typeof i!="object"||i===null)&&(i={},n[o]=i),i[s]=t},Ye=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o)if(c.depType.includes("."))Ue(i,c.depType,c.depName,c.fix);else{const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Xe=new Set(["dependencies","devDependencies","peerDependencies"]),Qe=e=>e.startsWith("catalog:"),Ze=e=>e.startsWith("workspace:"),et=e=>{if(!e.startsWith("catalog:"))return;const a=e.slice(8);return a===""?"default":a},tt=(e,a)=>{if(e.get("default")?.has(a))return"default";const s=[...e.keys()].filter(t=>t!=="default").sort();for(const t of s)if(e.get(t)?.has(a))return t},st=e=>e==="default"?"catalog:":`catalog:${e}`,ot=(e,a)=>{const s=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of s){const n=L(r.specifier);if(!n)continue;if(!t){t=r;continue}const o=L(t.specifier);if(!o){t=r;continue}const i=K(o,n),c=K(n,o);(a==="highest"&&i||a==="lowest"&&c)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},nt=(e,a={})=>{const s=a.resolve??"highest",t=new Set(a.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!Xe.has(i.depType)||Ze(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),o=new Map;for(const i of n){const c=o.get(i.depName);c?c.push(i):o.set(i.depName,[i])}for(const[i,c]of o){const p=a.pinned?.get(i);if(p!==void 0){for(const u of c)u.specifier!==p&&r.push({canonicalSource:"cli:--pin",depName:i,depType:u.depType,fix:p,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier});continue}if(s==="catalog"){const{catalogs:u}=a;if(!u)continue;const k=tt(u,i);if(!k)continue;const J=st(k);for(const P of c)et(P.specifier)!==k&&r.push({canonicalSource:`catalog:${k}`,depName:i,depType:P.depType,fix:J,packageDir:P.packageDir,packageJsonPath:P.packageJsonPath,packageName:P.packageName,specifier:P.specifier});continue}const f=c.filter(u=>!Qe(u.specifier));if(f.length<2||new Set(f.map(u=>u.specifier)).size<=1)continue;const h=ot(f,s);if(!h)continue;const d=h.canonical.specifier;for(const u of f)u.specifier!==d&&r.push({canonicalSource:h.canonicalSource,depName:i,depType:u.depType,fix:d,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier})}return r},at=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},it=e=>{if(_(I(e,"pnpm-workspace.yaml")))return!0;const a=I(e,"package.json");if(!_(a))return!1;try{return S(a).workspaces!==void 0}catch{return!1}},E=(e,a)=>{const s=new Map;for(const t of e){const r=a(t),n=s.get(r);n?n.push(t):s.set(r,[t])}return s},rt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-protocol: no violations"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[o,i]of E(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i){const f=s?x("→"):b("→");t.info(` ${g(p.depType)} ${p.depName}: ${D(p.specifier)} ${f} ${v(p.fix)}`)}}s||t.info(g(" Run with --fix to rewrite specifiers in place."))},ct=(e,a,s)=>{if(e.length===0){s.info(v("✓ redefine-root: no violations"));return}s.info(b(w(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of E(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r)s.info(` ${g(o.depType)} ${o.depName}: ${D(o.childSpecifier)} ${g(`(root ${o.rootDepType}: ${o.rootSpecifier})`)}`)}s.info(g(" Remove these from child package.json files — root pin will resolve."))},pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-versions: no drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[o,i]of E(e,c=>c.depName)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)} ${g(f.depType)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align drifting specifiers."))},ft=(e,a,s)=>{if(e.length===0){s.info(v("✓ banned-deps: no violations"));return}s.info(D(w(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of E(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r){const i=o.replacement?` ${g("→")} ${v(o.replacement)}`:"";s.info(` ${g(o.depType)} ${D(o.depName)}${i}`),s.info(` ${g(o.reason)}`)}}},lt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ catalog-proposals: nothing worth promoting"));return}const r=s?"Added":"Would add",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const o of e)t.info(` ${w(o.depName)}: ${v(o.specifier)} ${g(`(${String(o.instanceCount)} packages agree)`)}`);if(!s){const o=be(a,e);if(o){t.info(""),t.info(g("Proposed pnpm-workspace.yaml changes:"));for(const i of o.split(`
10
+ `))i.startsWith("+")?t.info(v(i)):i.startsWith("-")?t.info(D(i)):t.info(g(i))}t.info(g(" Run with --fix to write these entries to pnpm-workspace.yaml."))}},ut=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ custom-types: no engines / packageManager / volta drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} custom-type drift${e.length===1?"":"s"}`)));for(const[o,i]of E(e,c=>`${c.customType} ${c.depName}`)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align engines/packageManager/volta versions."))},dt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ empty-deps: no empty dependency blocks"));return}const r=s?"Removed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} empty dependency block${e.length===1?"":"s"}`)));for(const[o,i]of E(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${g(p.depType)}: ${D("{}")}`)}s||t.info(g(" Run with --fix to drop empty blocks."))},gt=(e,a,s,t)=>{if(e.length===0){t.info(v('✓ root-private: root package.json is "private": true'));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);if(t.info(n(w(`${r} "private": true on root ${g(`(${i})`)}`))),!s){const c=o.rawValue===void 0?"absent":JSON.stringify(o.rawValue);t.info(` ${g("current:")} ${D(c)}`)}}s||t.info(g(' Run with --fix to set "private": true.'))},mt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-package-manager: packageManager field present"));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} packageManager on root ${g(`(${i})`)}`))),!s&&!o.suggested&&t.info(g(" no canonical specifier configured (set policy.rootPackageManager.suggested to enable --fix)"))}s||t.info(g(' e.g. "packageManager": "pnpm@10.32.1"'))},ht=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-deps: no runtime dependencies on private root"));return}const r=s?"Moved":"Found",n=s?x:b;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} ${String(o.depNames.length)} runtime dep${o.depNames.length===1?"":"s"} on private root ${g(`(${i})`)}`)));for(const c of o.depNames)t.info(` ${D(c)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},kt=(e,a)=>{if(e.length===0){a.info(v("✓ missing-package-json: every workspace dir has a package.json"));return}a.info(b(w(`Found ${String(e.length)} workspace dir${e.length===1?"":"s"} without a package.json`)));for(const s of e)a.info(` ${D(s.packageDir)}`);a.info(g(" Either delete the directory or scaffold a package.json (vis create)."))},yt=(e,a,s)=>{if(e.length===0){s.info(v("✓ dead-workspace-pattern: every workspace pattern matches at least one package"));return}const t=a?"Removed":"Found",r=a?x:b;s.info(r(w(`${t} ${String(e.length)} unmatched workspace pattern${e.length===1?"":"s"}`)));for(const[n,o]of E(e,i=>i.source)){s.info(` ${w(n)}`);for(const i of o)s.info(` ${D(i.pattern)}`)}a||s.info(g(" Run with --fix to drop dead patterns."))},Pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ types-in-deps: no @types/* in dependencies of private packages"));return}const r=s?"Moved":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} @types/* dep${e.length===1?"":"s"} in dependencies`)));for(const[o,i]of E(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${D(p.depName)} ${g(p.childSpecifier)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},$t=(e,a,s)=>{if(e.length===0){s.info(v("✓ similar-deps: every related dep family is in sync"));return}s.info(b(w(`Found ${String(e.length)} family${e.length===1?"":" families"} with version drift`)));for(const t of e){s.info(` ${w(t.familyLabel)} ${g(`(${t.specifiers.join(", ")})`)}`);for(const r of t.members){const n=$(a,r.packageJsonPath),o=r.packageName??n;s.info(` ${o} ${g(`(${n})`)} ${g(r.depType)}: ${D(r.depName)}@${b(r.specifier)}`)}}s.info(g(" Pick a single specifier per family and align by hand — auto-fix is unsafe across name boundaries."))},wt=(e,a,s,t,r)=>{let n=!0;const o=i=>{n||r.info(""),n=!1,i()};t.workspaceProtocol&&o(()=>{rt(e.workspaceProtocol??[],a,s.workspaceProtocol,r)}),t.redefineRoot&&o(()=>{ct(e.redefineRoot??[],a,r)}),t.workspaceVersions&&o(()=>{pt(e.workspaceVersions??[],a,s.workspaceVersions,r)}),t.customTypes&&o(()=>{ut(e.customTypes??[],a,s.customTypes,r)}),e.catalogProposals!==void 0&&o(()=>{lt(e.catalogProposals??[],a,s.catalogProposals,r)}),t.bannedDeps&&o(()=>{ft(e.bannedDeps??[],a,r)}),t.emptyDeps&&o(()=>{dt(e.emptyDeps??[],a,s.emptyDeps,r)}),t.rootPrivate&&o(()=>{gt(e.rootPrivate??[],a,s.rootPrivate,r)}),t.rootPackageManager&&o(()=>{mt(e.rootPackageManager??[],a,s.rootPackageManager,r)}),t.rootDeps&&o(()=>{ht(e.rootDeps??[],a,s.rootDeps,r)}),t.missingPackageJson&&o(()=>{kt(e.missingPackageJson??[],r)}),t.deadWorkspacePatterns&&o(()=>{yt(e.deadWorkspacePatterns??[],s.deadWorkspacePatterns,r)}),t.typesInDeps&&o(()=>{Pt(e.typesInDeps??[],a,s.typesInDeps,r)}),t.similarDeps&&o(()=>{$t(e.similarDeps??[],a,r)})},vt=(e,a)=>{for(const s of e.workspaceProtocol??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`workspace-protocol ${t} ${s.depType} ${s.depName} ${s.specifier} → ${s.fix}
11
11
  `)}for(const s of e.redefineRoot??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`redefine-root ${t} ${s.depType} ${s.depName} ${s.childSpecifier}
12
12
  `)}for(const s of e.workspaceVersions??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`workspace-versions ${t} ${s.depType} ${s.depName} ${s.specifier} → ${s.fix}
13
13
  `)}for(const s of e.customTypes??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`custom-types ${t} ${s.customType} ${s.depName} ${s.specifier} → ${s.fix}
@@ -22,4 +22,4 @@ import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b
22
22
  `);for(const s of e.typesInDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`types-in-deps ${t} ${s.depName} ${s.childSpecifier}
23
23
  `)}for(const s of e.similarDeps??[])for(const t of s.members){const r=$(a,t.packageJsonPath);process.stdout.write(`similar-deps ${s.family} ${r} ${t.depType} ${t.depName} ${t.specifier}
24
24
  `)}},Dt=(e,a,s,t)=>{const r=o=>({...o,packageJsonPath:$(a,o.packageJsonPath)}),n={fixed:s};if(t.workspaceProtocol){const o=(e.workspaceProtocol??[]).map(i=>r(i));n.workspaceProtocol={issues:o,total:o.length}}if(t.redefineRoot){const o=(e.redefineRoot??[]).map(i=>r(i));n.redefineRoot={issues:o,total:o.length}}if(t.workspaceVersions){const o=(e.workspaceVersions??[]).map(i=>r(i));n.workspaceVersions={issues:o,total:o.length}}if(t.customTypes){const o=(e.customTypes??[]).map(i=>r(i));n.customTypes={issues:o,total:o.length}}if(t.bannedDeps){const o=(e.bannedDeps??[]).map(i=>r(i));n.bannedDeps={issues:o,total:o.length}}if(e.catalogProposals!==void 0){const o=e.catalogProposals;n.catalogProposals={proposals:o,total:o.length}}if(t.emptyDeps){const o=(e.emptyDeps??[]).map(i=>r(i));n.emptyDeps={issues:o,total:o.length}}if(t.rootPrivate){const o=(e.rootPrivate??[]).map(i=>r(i));n.rootPrivate={issues:o,total:o.length}}if(t.rootPackageManager){const o=(e.rootPackageManager??[]).map(i=>r(i));n.rootPackageManager={issues:o,total:o.length}}if(t.rootDeps){const o=(e.rootDeps??[]).map(i=>r(i));n.rootDeps={issues:o,total:o.length}}if(t.missingPackageJson){const o=e.missingPackageJson??[];n.missingPackageJson={issues:o,total:o.length}}if(t.deadWorkspacePatterns){const o=e.deadWorkspacePatterns??[];n.deadWorkspacePatterns={issues:o,total:o.length}}if(t.typesInDeps){const o=(e.typesInDeps??[]).map(i=>r(i));n.typesInDeps={issues:o,total:o.length}}if(t.similarDeps){const o=(e.similarDeps??[]).map(i=>({...i,members:i.members.map(c=>({...c,packageJsonPath:$(a,c.packageJsonPath)}))}));n.similarDeps={issues:o,total:o.length}}process.stdout.write(`${JSON.stringify(n,void 0,2)}
25
- `)},T=(e,a,s)=>{const t=e[a];return typeof t=="boolean"?t:e[s]===!0},bt=e=>{const a=e,s=(e.ban?.length??0)>0,t=(e.pin?.length??0)>0,r=T(a,"workspaceProtocol","workspace-protocol"),n=T(a,"redefineRoot","redefine-root"),o=T(a,"bannedDeps","banned-deps"),i=T(a,"workspaceVersions","workspace-versions"),c=T(a,"customTypes","custom-types"),p=T(a,"emptyDeps","empty-deps"),f=T(a,"rootPrivate","root-private"),m=T(a,"rootPackageManager","root-package-manager"),h=T(a,"rootDeps","root-deps"),d=T(a,"missingPackageJson","missing-package-json"),u=T(a,"deadWorkspacePatterns","dead-workspace-patterns"),k=T(a,"typesInDeps","types-in-deps"),J=T(a,"similarDeps","similar-deps");return r||n||o||i||c||p||f||m||h||d||u||k||J||s||t?{bannedDeps:o||s,customTypes:c,deadWorkspacePatterns:u,emptyDeps:p,missingPackageJson:d,redefineRoot:n,rootDeps:h,rootPackageManager:m,rootPrivate:f,similarDeps:J,typesInDeps:k,workspaceProtocol:r,workspaceVersions:i||t}:{bannedDeps:!0,customTypes:!0,deadWorkspacePatterns:!0,emptyDeps:!0,missingPackageJson:!0,redefineRoot:!0,rootDeps:!0,rootPackageManager:!0,rootPrivate:!0,similarDeps:!0,typesInDeps:!0,workspaceProtocol:!0,workspaceVersions:!0}},Nt=e=>{const a=new Map;for(const s of e??[]){const t=s.lastIndexOf("@");if(t<=0||t===s.length-1)throw new Error(`Invalid --pin "${s}". Use: name@<specifier> (e.g. react@^18.2.0).`);const r=s.slice(0,t),n=s.slice(t+1);a.set(r,n)}return a},Tt=new Set(["catalog","highest","lowest"]),xt=e=>{if(e===void 0)return"highest";if(!Tt.has(e))throw new Error(`Invalid --resolve "${e}". Use: highest, lowest, or catalog.`);return e},M=(e,a)=>e?a===void 0||a===!0:!1,Jt={"custom-types":"policy.customTypes.autofix","workspace-protocol":"policy.workspaceProtocol.autofix","workspace-versions":"policy.workspaceVersions.autofix"},B=(e,a,s,t)=>{const r=Jt[a],n=s==="prompt"?`${r} = "prompt" (interactive mode not yet implemented; report-only)`:`${r} = false`,o=`Set "${r}": true (or remove it) to enable rewrites.`;e.warn(`${a}: ${String(t)} issue${t===1?"":"s"} not rewritten — ${n}. ${o}`)},Ft=async({logger:e,options:a,visConfig:s,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const r=t,n=a.fix??!1,o=a.format??"human",i=a.quiet??!1;if(!["human","json","minimal"].includes(o))throw new Error(`Invalid --format "${o}". Use: human, json, or minimal.`);const c=bt(a),p=s?.policy??{},f=s?.editorconfig??!0,m=Nt(a.pin),h=a.ban??[];(a.dep!==void 0||a.resolve!==void 0)&&!c.workspaceVersions&&!i&&e.warn("--dep / --resolve only apply to --workspace-versions; ignored.");const d=ne(r),u={},k={catalogProposals:!1,customTypes:!1,deadWorkspacePatterns:!1,emptyDeps:!1,rootDeps:!1,rootPackageManager:!1,rootPrivate:!1,typesInDeps:!1,workspaceProtocol:!1,workspaceVersions:!1},J=it(r);let P=0;if(c.workspaceProtocol){const l=Ge(d,{fixSpecifier:a.fixSpecifier}),y=M(n,p.workspaceProtocol?.autofix);y&&l.length>0&&(Ye(l,{useEditorconfig:f}),k.workspaceProtocol=!0),u.workspaceProtocol=l,y||(P+=l.length),n&&!y&&l.length>0&&!i&&B(e,"workspace-protocol",p.workspaceProtocol?.autofix,l.length)}if(c.redefineRoot){const l=Me(d,{ignoreDeps:p.redefineRoot?.ignore});u.redefineRoot=l,P+=l.length}if(c.workspaceVersions){const l=xt(a.resolve??p.workspaceVersions?.resolve),y=l==="catalog"?fe(r):void 0;l==="catalog"&&(!y||y.size===0)&&!i&&e.warn("--resolve catalog: no catalog found in pnpm-workspace.yaml or root package.json — nothing to align.");const N=nt(d,{catalogs:y,dep:a.dep,ignoreDeps:p.workspaceVersions?.ignore,pinned:m.size>0?m:void 0,resolve:l}),R=M(n,p.workspaceVersions?.autofix);if(R&&N.length>0&&(at(N,{useEditorconfig:f}),k.workspaceVersions=!0),u.workspaceVersions=N,R||(P+=N.length),n&&!R&&N.length>0&&!i&&B(e,"workspace-versions",p.workspaceVersions?.autofix,N.length),a.proposeMin!==void 0){if(l!=="catalog"&&!i)e.warn("--propose-min only runs under --resolve catalog; ignored.");else if(l==="catalog"){const C=ve(d,{catalogs:y,ignoreDeps:p.workspaceVersions?.ignore,min:a.proposeMin});R&&C.length>0&&(De(r,C),k.catalogProposals=!0),u.catalogProposals=C}}}if(c.customTypes){const l=p.customTypes?.extraTypes,y=ae(l);if(y.length>0){for(const X of y)e.error(`policy.customTypes.${X}`);process.exitCode=1;return}const N=ie(r,l),C=(a.resolve??p.customTypes?.resolve)==="lowest"?"lowest":"highest",E=re(N,{dep:a.dep,ignoreDeps:p.customTypes?.ignore,resolve:C}),O=M(n,p.customTypes?.autofix);O&&E.length>0&&(ce(E,{useEditorconfig:f}),k.customTypes=!0),u.customTypes=E,O||(P+=E.length),n&&!O&&E.length>0&&!i&&B(e,"custom-types",p.customTypes?.autofix,E.length)}if(c.bannedDeps){const l={...p.bannedDeps};for(const N of h)l[N]={reason:"banned via --ban CLI flag"};Object.keys(l).length===0&&a.bannedDeps&&!i&&e.warn("--banned-deps: no policy.bannedDeps in vis config, nothing to check.");const y=ke(d,l);u.bannedDeps=y,P+=y.length}if(c.emptyDeps){const l=Je(r,{ignoreBlocks:p.emptyDeps?.ignoreBlocks}),y=M(n,p.emptyDeps?.autofix);y&&l.length>0&&(Se(l,{useEditorconfig:f}),k.emptyDeps=!0),u.emptyDeps=l,y||(P+=l.length)}if(c.rootPrivate){const l=Ce(r,J),y=M(n,p.rootPrivate?.autofix);y&&l.length>0&&(Ve(l,{useEditorconfig:f}),k.rootPrivate=!0),u.rootPrivate=l,y||(P+=l.length)}if(c.rootPackageManager){const l=Ee(r,J,{suggested:p.rootPackageManager?.suggested}),y=M(n,p.rootPackageManager?.autofix);y&&l.some(N=>N.suggested!==void 0)&&(Re(l,{useEditorconfig:f}),k.rootPackageManager=!0),u.rootPackageManager=l,(!y||!k.rootPackageManager)&&(P+=l.filter(N=>N.suggested===void 0||!k.rootPackageManager).length)}if(c.rootDeps){const l=We(r,J),y=M(n,p.rootDeps?.autofix);y&&l.length>0&&(je(l,{useEditorconfig:f}),k.rootDeps=!0),u.rootDeps=l,y||(P+=l.length)}if(c.missingPackageJson){const l=ue(r);u.missingPackageJson=l,P+=l.length}if(c.deadWorkspacePatterns){const l=Ne(r),y=M(n,p.deadWorkspacePatterns?.autofix);y&&l.length>0&&(Te(l,{useEditorconfig:f}),k.deadWorkspacePatterns=!0),u.deadWorkspacePatterns=l,y||(P+=l.length)}if(c.typesInDeps){const l=Le(d,{ignoreDeps:p.typesInDeps?.ignore}),y=M(n,p.typesInDeps?.autofix);y&&l.length>0&&(Ke(l,{useEditorconfig:f}),k.typesInDeps=!0),u.typesInDeps=l,y||(P+=l.length)}if(c.similarDeps){const l=He(d,{extraFamilies:p.similarDeps?.extraFamilies,ignoreFamilies:p.similarDeps?.ignoreFamilies});u.similarDeps=l,P+=l.length}i||(o==="json"?Dt(u,r,k,c):o==="minimal"?vt(u,r):wt(u,r,k,c,e)),P>0&&(process.exitCode=1)};export{Ft as default};
25
+ `)},T=(e,a,s)=>{const t=e[a];return typeof t=="boolean"?t:e[s]===!0},bt=e=>{const a=e,s=(e.ban?.length??0)>0,t=(e.pin?.length??0)>0,r=T(a,"workspaceProtocol","workspace-protocol"),n=T(a,"redefineRoot","redefine-root"),o=T(a,"bannedDeps","banned-deps"),i=T(a,"workspaceVersions","workspace-versions"),c=T(a,"customTypes","custom-types"),p=T(a,"emptyDeps","empty-deps"),f=T(a,"rootPrivate","root-private"),m=T(a,"rootPackageManager","root-package-manager"),h=T(a,"rootDeps","root-deps"),d=T(a,"missingPackageJson","missing-package-json"),u=T(a,"deadWorkspacePatterns","dead-workspace-patterns"),k=T(a,"typesInDeps","types-in-deps"),J=T(a,"similarDeps","similar-deps");return r||n||o||i||c||p||f||m||h||d||u||k||J||s||t?{bannedDeps:o||s,customTypes:c,deadWorkspacePatterns:u,emptyDeps:p,missingPackageJson:d,redefineRoot:n,rootDeps:h,rootPackageManager:m,rootPrivate:f,similarDeps:J,typesInDeps:k,workspaceProtocol:r,workspaceVersions:i||t}:{bannedDeps:!0,customTypes:!0,deadWorkspacePatterns:!0,emptyDeps:!0,missingPackageJson:!0,redefineRoot:!0,rootDeps:!0,rootPackageManager:!0,rootPrivate:!0,similarDeps:!0,typesInDeps:!0,workspaceProtocol:!0,workspaceVersions:!0}},Nt=e=>{const a=new Map;for(const s of e??[]){const t=s.lastIndexOf("@");if(t<=0||t===s.length-1)throw new Error(`Invalid --pin "${s}". Use: name@<specifier> (e.g. react@^18.2.0).`);const r=s.slice(0,t),n=s.slice(t+1);a.set(r,n)}return a},Tt=new Set(["catalog","highest","lowest"]),xt=e=>{if(e===void 0)return"highest";if(!Tt.has(e))throw new Error(`Invalid --resolve "${e}". Use: highest, lowest, or catalog.`);return e},M=(e,a)=>e?a===void 0||a===!0:!1,Jt={"custom-types":"policy.customTypes.autofix","workspace-protocol":"policy.workspaceProtocol.autofix","workspace-versions":"policy.workspaceVersions.autofix"},B=(e,a,s,t)=>{const r=Jt[a],n=s==="prompt"?`${r} = "prompt" (interactive mode not yet implemented; report-only)`:`${r} = false`,o=`Set "${r}": true (or remove it) to enable rewrites.`;e.warn(`${a}: ${String(t)} issue${t===1?"":"s"} not rewritten — ${n}. ${o}`)},Ft=async({logger:e,options:a,visConfig:s,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const r=t,n=a.fix??!1,o=a.format??"human",i=a.quiet??!1;if(!["human","json","minimal"].includes(o))throw new Error(`Invalid --format "${o}". Use: human, json, or minimal.`);const c=bt(a),p=s?.policy??{},f=s?.editorconfig??!0,m=Nt(a.pin),h=a.ban??[];(a.dep!==void 0||a.resolve!==void 0)&&!c.workspaceVersions&&!i&&e.warn("--dep / --resolve only apply to --workspace-versions; ignored.");const d=ne(r),u={},k={catalogProposals:!1,customTypes:!1,deadWorkspacePatterns:!1,emptyDeps:!1,rootDeps:!1,rootPackageManager:!1,rootPrivate:!1,typesInDeps:!1,workspaceProtocol:!1,workspaceVersions:!1},J=it(r);let P=0;if(c.workspaceProtocol){const l=Ge(d,{fixSpecifier:a.fixSpecifier}),y=M(n,p.workspaceProtocol?.autofix);y&&l.length>0&&(Ye(l,{useEditorconfig:f}),k.workspaceProtocol=!0),u.workspaceProtocol=l,y||(P+=l.length),n&&!y&&l.length>0&&!i&&B(e,"workspace-protocol",p.workspaceProtocol?.autofix,l.length)}if(c.redefineRoot){const l=Me(d,{ignoreDeps:p.redefineRoot?.ignore});u.redefineRoot=l,P+=l.length}if(c.workspaceVersions){const l=xt(a.resolve??p.workspaceVersions?.resolve),y=l==="catalog"?fe(r):void 0;l==="catalog"&&(!y||y.size===0)&&!i&&e.warn("--resolve catalog: no catalog found in pnpm-workspace.yaml or root package.json — nothing to align.");const N=nt(d,{catalogs:y,dep:a.dep,ignoreDeps:p.workspaceVersions?.ignore,pinned:m.size>0?m:void 0,resolve:l}),R=M(n,p.workspaceVersions?.autofix);if(R&&N.length>0&&(at(N,{useEditorconfig:f}),k.workspaceVersions=!0),u.workspaceVersions=N,R||(P+=N.length),n&&!R&&N.length>0&&!i&&B(e,"workspace-versions",p.workspaceVersions?.autofix,N.length),a.proposeMin!==void 0){if(l!=="catalog"&&!i)e.warn("--propose-min only runs under --resolve catalog; ignored.");else if(l==="catalog"){const C=ve(d,{catalogs:y,ignoreDeps:p.workspaceVersions?.ignore,min:a.proposeMin});R&&C.length>0&&(De(r,C),k.catalogProposals=!0),u.catalogProposals=C}}}if(c.customTypes){const l=p.customTypes?.extraTypes,y=ae(l);if(y.length>0){for(const X of y)e.error(`policy.customTypes.${X}`);process.exitCode=1;return}const N=ie(r,l),C=(a.resolve??p.customTypes?.resolve)==="lowest"?"lowest":"highest",A=re(N,{dep:a.dep,ignoreDeps:p.customTypes?.ignore,resolve:C}),O=M(n,p.customTypes?.autofix);O&&A.length>0&&(ce(A,{useEditorconfig:f}),k.customTypes=!0),u.customTypes=A,O||(P+=A.length),n&&!O&&A.length>0&&!i&&B(e,"custom-types",p.customTypes?.autofix,A.length)}if(c.bannedDeps){const l={...p.bannedDeps};for(const N of h)l[N]={reason:"banned via --ban CLI flag"};Object.keys(l).length===0&&a.bannedDeps&&!i&&e.warn("--banned-deps: no policy.bannedDeps in vis config, nothing to check.");const y=ke(d,l);u.bannedDeps=y,P+=y.length}if(c.emptyDeps){const l=Je(r,{ignoreBlocks:p.emptyDeps?.ignoreBlocks}),y=M(n,p.emptyDeps?.autofix);y&&l.length>0&&(Se(l,{useEditorconfig:f}),k.emptyDeps=!0),u.emptyDeps=l,y||(P+=l.length)}if(c.rootPrivate){const l=Ce(r,J),y=M(n,p.rootPrivate?.autofix);y&&l.length>0&&(Ve(l,{useEditorconfig:f}),k.rootPrivate=!0),u.rootPrivate=l,y||(P+=l.length)}if(c.rootPackageManager){const l=Ae(r,J,{suggested:p.rootPackageManager?.suggested}),y=M(n,p.rootPackageManager?.autofix);y&&l.some(N=>N.suggested!==void 0)&&(Re(l,{useEditorconfig:f}),k.rootPackageManager=!0),u.rootPackageManager=l,(!y||!k.rootPackageManager)&&(P+=l.filter(N=>N.suggested===void 0||!k.rootPackageManager).length)}if(c.rootDeps){const l=We(r,J),y=M(n,p.rootDeps?.autofix);y&&l.length>0&&(je(l,{useEditorconfig:f}),k.rootDeps=!0),u.rootDeps=l,y||(P+=l.length)}if(c.missingPackageJson){const l=ue(r);u.missingPackageJson=l,P+=l.length}if(c.deadWorkspacePatterns){const l=Ne(r),y=M(n,p.deadWorkspacePatterns?.autofix);y&&l.length>0&&(Te(l,{useEditorconfig:f}),k.deadWorkspacePatterns=!0),u.deadWorkspacePatterns=l,y||(P+=l.length)}if(c.typesInDeps){const l=Le(d,{ignoreDeps:p.typesInDeps?.ignore}),y=M(n,p.typesInDeps?.autofix);y&&l.length>0&&(Ke(l,{useEditorconfig:f}),k.typesInDeps=!0),u.typesInDeps=l,y||(P+=l.length)}if(c.similarDeps){const l=He(d,{extraFamilies:p.similarDeps?.extraFamilies,ignoreFamilies:p.similarDeps?.ignoreFamilies});u.similarDeps=l,P+=l.length}i||(o==="json"?Dt(u,r,k,c):o==="minimal"?vt(u,r):wt(u,r,k,c,e)),P>0&&(process.exitCode=1)};export{Ft as default};
@@ -1,10 +1,10 @@
1
- import{createRequire as xt}from"node:module";import{F as j,j as oe,q as ye,X as be,b as Re,J as ge}from"../packem_shared/index.server-sXNQYpsl.js";import{aa as yt,U as bt,V as jt,W as vt,T as St,v as $t,X as Ct,Y as Fe,p as d,O as Xe,d as Rt,S as D}from"./cli-main.js";import{e as K,z as Tt,v as Et,U as qe}from"../packem_shared/index-BzhrR_iC.js";import{i as At}from"../packem_shared/index-BjdW45xX.js";import{G as i,X as u,o as r,x as z,a as Je,i as Qe,R as It,m as Dt,n as Ot,h as Pt,j as Nt}from"./catalog.js";import{g as zt,s as Le,D as et}from"../packem_shared/formatBytes-BHAzNIrn-CrusHOew.js";import{y as je}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as tt}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{h as Lt}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{findVisConfigFile as Bt}from"./CONFIG_FILES.js";import{d as st,c as Be,r as _t,b as Vt,a as Ht,e as Yt,f as Ut,m as Gt}from"./handler71.js";import{d as it,n as Wt}from"../packem_shared/pm-runner-CMSml1Bj.js";import{c as Kt}from"../packem_shared/runtime-check-1U8HrQd9.js";import{s as Xt}from"../packem_shared/scan-progress-C_zaZjyY.js";import{l as qt,r as Jt,f as Qt}from"../packem_shared/dependency-scan-B8jroa1D.js";import{l as rt}from"../packem_shared/spinner-DuB0K0Am.js";import{n as Zt,a as es}from"../packem_shared/tabs-RZd_e1M0.js";import{u as ts}from"../packem_shared/use-measured-height-DWkDV9Dj.js";import{L as ss}from"../packem_shared/index-BisalDCf.js";import{l as is}from"./ts-loader.js";import{s as rs}from"../packem_shared/verify-B_MblU_Q.js";let wt;const kt=e=>(wt??=xt(import.meta.url))(e),we=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ke=e=>{if(typeof we<"u"&&we.versions&&we.versions.node){const[t,s]=we.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return we.getBuiltinModule(e)}return kt(e)},{rmSync:ze,writeFileSync:Mt,statSync:Ft,readFileSync:Ze}=Ke("node:fs"),{spawnSync:Te}=Ke("node:child_process"),Ae=()=>K(zt(),"doctor"),ns=1800*1e3,_e=e=>{if(!e)return"";try{return String(Ft(e).mtimeMs)}catch{return""}},os=2,ls=e=>{const t=JSON.stringify({configMtime:_e(e.configPath),lockfileMtime:_e(e.lockfilePath),schema:os,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return yt(Buffer.from(t))},cs=e=>{const t=K(Ae(),`${e}.json`);if(je(t))try{const s=tt(t);if(Date.now()-s.createdAt>s.ttlMs){ze(t,{force:!0});return}return{...s.results,sections:new Set(s.results.sections)}}catch{ze(t,{force:!0});return}},as=(e,t,s=ns)=>{Lt(Ae());const l={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:s};Mt(K(Ae(),`${e}.json`),JSON.stringify(l,void 0,2),"utf8")},Se="orphans",ds=()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=Ze("/proc/sys/fs/inotify/max_user_watches","utf8").trim(),s=Number.parseInt(t,10);Number.isFinite(s)&&s>0&&(e=s)}catch{return{id:"inotify",message:"Could not read /proc/sys/fs/inotify/max_user_watches.",status:"warn"}}return e===void 0?{id:"inotify",message:"inotify max_user_watches reported a non-numeric value.",status:"warn"}:e<65536?{detail:{maxWatches:e},id:"inotify",message:`inotify watcher limit is ${String(e)} — large monorepos can exhaust this. Bump now with \`sudo sysctl fs.inotify.max_user_watches=524288\` and persist via \`/etc/sysctl.d/99-vis.conf\` so it survives reboot.`,status:"warn"}:{detail:{maxWatches:e},id:"inotify",message:`inotify capacity OK (${String(e)} watches).`,status:"ok"}},us=()=>{const e=!!process.stdin.isTTY,t=!!process.stdout.isTTY;return e&&t?{id:"tty",message:"Interactive TTY available — watch keybinds enabled.",status:"ok"}:!e&&!t?{id:"tty",message:"No TTY on stdin/stdout — running in CI / piped mode (keybinds disabled).",status:"skip"}:{detail:{stdin:String(e),stdout:String(t)},id:"tty",message:e?"stdin is a TTY but stdout is not — output is being captured; keybinds still work.":"stdout is a TTY but stdin is not — keybinds disabled (input is piped).",status:"skip"}},hs=()=>{const e=process.pid;try{return process.platform==="win32"?lt(e):ot(e)}catch{return[]}},ps=()=>{const e=process.pid;let t;try{t=process.platform==="win32"?lt(e):ot(e)}catch{return{id:Se,message:"Could not enumerate processes (ps/tasklist failed).",status:"warn"}}if(t.length===0)return{id:Se,message:"No orphaned vis/task-runner processes detected.",status:"ok"};if(t.length<=2)return{detail:{count:t.length,pids:t.join(",")},id:Se,message:`${String(t.length)} possibly orphaned process(es) detected (PIDs: ${t.join(", ")}). Likely benign.`,status:"skip"};const s=process.platform==="win32"?t.map(l=>`taskkill /F /PID ${String(l)}`).join(" & "):`kill ${t.join(" ")}`;return{detail:{count:t.length,pids:t.join(",")},id:"orphans",message:`${String(t.length)} possibly orphaned vis/task-runner processes — run \`vis doctor --fix\` to clean them up, or kill them manually: ${s}`,status:"warn"}},fs=(e={})=>{const t=e.enumerate??hs,l=e.force===!0?"SIGKILL":"SIGTERM",n=e.kill??ks,o=t(),a=[],h=[];for(const c of o)try{n(c,l),a.push(c)}catch(p){const x=p.code??p.message;if(x==="ESRCH"){a.push(c);continue}h.push({pid:c,reason:x})}return{failed:h,killed:a}},ms=e=>Te("taskkill",e,{encoding:"utf8",timeout:1e4}),gs=(e,t)=>{process.kill(e,t)},xs=(e,t,s=ms)=>{const l=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],n=s(l);if(n.error)throw n.error;if(typeof n.status=="number"&&n.status!==0){const o=n.status===128?"ESRCH":`taskkill exited with code ${String(n.status)}`,a=new Error(o);throw a.code=o,a}},ws=(e,t,s=gs)=>{s(e,t)},ks=(e,t)=>{if(process.platform==="win32"){xs(e,t);return}ws(e,t)},nt=(e,t)=>{const s=Te(e,t,{encoding:"utf8",timeout:1e4});if(s.error)throw s.error;if(typeof s.status=="number"&&s.status!==0)throw new Error(`${e} exited with code ${String(s.status)}`);return typeof s.stdout=="string"?s.stdout:""},ot=e=>{const t=nt("ps",["-Ao","pid=,command="]),s=[];for(const l of t.split(`
2
- `)){if(l.length===0)continue;const n=/^\s*(\d+)\s+(.+)$/.exec(l);if(!n)continue;const o=Number.parseInt(n[1]??"",10),a=(n[2]??"").toLowerCase();!Number.isFinite(o)||o===e||(/(?:^|[ /])vis-native(?:\s|$|[-.])/.test(a)||/(?:^|[ /])vis\s+run\b/.test(a)||/(?:^|[ /])task-runner(?:\s|$|[-.])/.test(a))&&s.push(o)}return s},lt=e=>{const t=nt("tasklist",["/FO","CSV","/NH"]),s=[];for(const l of t.split(/\r?\n/)){if(l.length===0)continue;const n=l.split(/","/).map(h=>h.replaceAll(/^"|"$/g,"")),o=(n[0]??"").toLowerCase(),a=Number.parseInt(n[1]??"",10);!Number.isFinite(a)||a===e||(o==="vis.exe"||o.startsWith("vis-native")||o.includes("task-runner"))&&s.push(a)}return s},ys=()=>{let e;try{const t=Te("watchman",["--version"],{encoding:"utf8",timeout:2e3});if(t.error||typeof t.status=="number"&&t.status!==0)throw t.error??new Error("watchman exited non-zero");e=typeof t.stdout=="string"?t.stdout.trim():void 0}catch{return{id:"watchman",message:"Watchman not found — `vis` uses native fs.watch (fine for small repos). Install Watchman + `fb-watchman` to scale watch mode on large monorepos.",status:"skip"}}return{detail:e?{version:e}:void 0,id:"watchman",message:e?`Watchman available (${e}) — scalable watch backend in use.`:"Watchman available — scalable watch backend in use.",status:"ok"}},bs=(e=process.cwd())=>{let t="";try{t=Ze(K(e,".gitattributes"),"utf8")}catch(s){if(s.code!=="ENOENT")return{id:"git-lfs",message:"Could not read .gitattributes.",status:"warn"}}if(!t.includes("filter=lfs"))return{id:"git-lfs",message:"No Git LFS tracking declared in .gitattributes.",status:"skip"};try{const s=Te("git",["lfs","version"],{encoding:"utf8",timeout:2e3});if(s.error||typeof s.status=="number"&&s.status!==0)throw s.error??new Error("git-lfs not available")}catch{return{id:"git-lfs",message:"Repo tracks files via Git LFS but `git-lfs` is not installed — checked-out LFS files are pointer stubs, not real content. Install git-lfs and run `git lfs pull`.",status:"warn"}}return{id:"git-lfs",message:"Git LFS tracking declared and `git-lfs` is installed.",status:"ok"}},js=e=>[ds(),us(),ys(),bs(e),ps()],me=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],Ce=["dependencies","security","optimization","runtime"],pe=e=>{const t=new Map;for(const s of Ce)t.set(s,[]);for(const s of e)t.get(s.section).push(s);for(const[s,l]of t)l.length===0&&t.delete(s);return t},fe=(e,t,s,l)=>{let n=e.filter(o=>o.section===t);if(l&&(n=n.filter(o=>o.severity===l)),s){const o=s.toLowerCase();n=n.filter(a=>a.title.toLowerCase().includes(o))}return[...n]},vs=e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const s of Ce)e.has(s)&&(t[s]="idle");return t};class Ve{#e;#s=new Set;constructor(t=[]){const s=Array.isArray(t)?{findings:t}:t,l=s.findings??[],n=s.activeSections??new Set(Ce),o=Ce.find(c=>n.has(c))??"dependencies",a=fe(l,o,"",void 0),h=vs(n);if(l.length>0)for(const c of l)h[c.section]="done";this.#e={all:l,entries:a,filterActive:!1,filterText:"",filterType:o,focusedPanel:"list",grouped:pe(a),pendingAction:void 0,sectionError:{},sectionMessage:{},sectionStatus:h,selectedIndex:0,severityFilter:void 0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#s.add(t),()=>{this.#s.delete(t)});setSelectedIndex(t){const s=Math.max(0,Math.min(t,this.#e.entries.length-1));s!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:s})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:t})}setFilterType(t){if(t===this.#e.filterType)return;const s=fe(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:s,filterType:t,grouped:pe(s),selectedIndex:0})}setFilter(t){const s=fe(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:s,filterText:t,grouped:pe(s),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const s=fe(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:s,filterActive:!1,filterText:"",grouped:pe(s),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const s=fe(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:s,grouped:pe(s),selectedIndex:0,severityFilter:t})}startSection(t,s){this.#t({...this.#e,sectionMessage:{...this.#e.sectionMessage,[t]:s},sectionStatus:{...this.#e.sectionStatus,[t]:"running"}})}completeSection(t,s){const l=[...this.#e.all,...s],n=fe(l,this.#e.filterType,this.#e.filterText,this.#e.severityFilter),o={...this.#e.sectionMessage};delete o[t],this.#t({...this.#e,all:l,entries:n,grouped:pe(n),sectionMessage:o,sectionStatus:{...this.#e.sectionStatus,[t]:"done"}})}failSection(t,s){this.#t({...this.#e,sectionError:{...this.#e.sectionError,[t]:s},sectionStatus:{...this.#e.sectionStatus,[t]:"error"}})}#t(t){this.#e=t;for(const s of this.#s)try{s()}catch{}}}const He={error:0,warn:1},Ss=e=>!!e.acceptedRisk,ct=e=>{const t=[];if(e.sections.has("dependencies")){for(const s of e.outdated)t.push({entry:s,id:`outdated:${s.packageName}`,kind:"outdated",section:"dependencies",severity:"warn",subtitle:`${s.currentRange} → ${s.newRange} (${s.updateType})`,title:s.packageName});for(const s of e.duplicates)t.push({id:`duplicate:${s.name}`,kind:"duplicate",pkg:s,section:"dependencies",severity:"warn",subtitle:`${String(s.versions.length)} versions installed`,title:s.name})}if(e.sections.has("security"))for(const s of e.outdated){if(s.vulnerabilities&&s.vulnerabilities.length>0){const l=s.vulnerabilities[0],n=Ss(s)?"warn":"error",o=s.vulnerabilities.length;t.push({entry:s,id:`vuln:${s.packageName}`,kind:"vulnerability",packageName:s.packageName,section:"security",severity:n,subtitle:o===1?`${l.severity} · ${l.id}`:`${String(o)} advisories · top: ${l.severity} ${l.id}`,title:s.packageName})}if(s.socketReport&&s.socketReport.alerts.length>0){const l=Math.round(s.socketReport.score.overall*100);t.push({entry:s,id:`socket:${s.packageName}`,kind:"socket",packageName:s.packageName,section:"security",severity:"warn",subtitle:`${String(s.socketReport.alerts.length)} alert${s.socketReport.alerts.length===1?"":"s"} · score ${String(l)}%`,title:s.packageName})}}if(e.sections.has("optimization"))for(const s of e.optimizations)t.push({entry:s,id:`opt:${s.packageName}`,kind:"optimization",section:"optimization",severity:"warn",subtitle:`${s.category} → ${s.replacement}`,title:s.packageName});if(e.sections.has("runtime"))for(const s of e.runtime)s.status==="warn"&&t.push({diagnostic:s,id:`runtime:${s.id}`,kind:"runtime",section:"runtime",severity:"warn",title:s.message});return t.sort((s,l)=>{if(s.section!==l.section){const n=["dependencies","security","optimization","runtime"];return n.indexOf(s.section)-n.indexOf(l.section)}return He[s.severity]-He[l.severity]}),t},at={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"},$s={error:"red",warn:"yellow"},Cs={error:"✖",warn:"⚠"},Rs={error:" ERROR ",warn:" WARN "},Ts=({children:e,hint:t,message:s,severity:l,title:n})=>{const o=$s[l];return i.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[i.jsxs(u,{gap:1,children:[i.jsx(r,{backgroundColor:o,bold:!0,color:"black",children:Rs[l]}),i.jsx(r,{bold:!0,color:o,children:Cs[l]}),i.jsx(r,{bold:!0,wrap:"truncate-end",children:n})]}),i.jsx(r,{wrap:"truncate-end",children:s}),t?i.jsx(r,{dimColor:!0,wrap:"truncate-end",children:t}):null,e]})},Es={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},As={critical:"red",high:"red",low:"gray",medium:"yellow"},Is={major:"red",minor:"yellow",patch:"green"},C=({children:e,label:t,width:s=14})=>i.jsxs(u,{children:[i.jsx(u,{width:s,children:i.jsxs(r,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?i.jsx(r,{children:e}):e]}),re=({children:e})=>i.jsx(u,{marginTop:1,children:i.jsx(r,{bold:!0,color:"white",children:e})}),Ds=({finding:e})=>{const{entry:t}=e,s=Is[t.updateType]??"white";return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Current",children:t.currentRange}),i.jsxs(C,{label:"Target",children:[i.jsx(r,{children:t.newRange}),i.jsxs(r,{bold:!0,color:s,children:[" (",t.updateType,")"]})]}),i.jsx(C,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?i.jsx(C,{label:"Risk ack",children:i.jsx(r,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,i.jsx(re,{children:"Action"}),i.jsxs(r,{dimColor:!0,children:["Run"," ",i.jsx(r,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},Os=({finding:e})=>i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Versions",children:i.jsx(r,{children:String(e.pkg.versions.length)})}),i.jsx(re,{children:"Installed versions"}),e.pkg.versions.map(t=>i.jsxs(r,{children:[" · ",t]},t)),i.jsx(re,{children:"Action"}),i.jsxs(r,{dimColor:!0,children:["Run"," ",i.jsx(r,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),Ps=({finding:e})=>{const t=e.entry.vulnerabilities??[];return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Package",children:e.packageName}),i.jsx(C,{label:"Current",children:e.entry.currentRange}),i.jsx(C,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?i.jsx(C,{label:"Risk ack",children:i.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(s=>{const l=Es[s.severity]??"gray";return i.jsxs(u,{flexDirection:"column",marginTop:1,children:[i.jsxs(u,{children:[i.jsx(r,{bold:!0,color:l,children:s.severity}),i.jsx(r,{children:" "}),i.jsx(r,{children:s.id}),typeof s.cvssScore=="number"?i.jsxs(r,{dimColor:!0,children:[" · CVSS ",s.cvssScore.toFixed(1)]}):null]}),i.jsx(r,{wrap:"wrap",children:s.summary}),s.fixedVersions.length>0?i.jsxs(r,{dimColor:!0,children:["Fixed in: ",s.fixedVersions.join(", ")]}):null,s.aliases&&s.aliases.length>0?i.jsxs(r,{dimColor:!0,children:["Aliases: ",s.aliases.join(", ")]}):null]},s.id)})]})},Ns=({finding:e})=>{const t=e.entry.socketReport;if(!t)return i.jsx(r,{dimColor:!0,children:"No Socket report attached."});const s=Math.round(t.score.overall*100),l=Le(t.score.overall);return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Package",children:e.packageName}),i.jsx(C,{label:"Overall",children:i.jsxs(r,{color:l,children:[String(s),"%"]})}),i.jsx(C,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?i.jsx(C,{label:"Risk ack",children:i.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,i.jsx(re,{children:"Score breakdown"}),Object.entries(t.score).map(([n,o])=>{if(n==="overall")return null;const a=typeof o=="number"?o:0,h=Math.round(a*100),c=Le(a);return i.jsxs(u,{children:[i.jsx(u,{width:14,children:i.jsxs(r,{dimColor:!0,children:[n,":"]})}),i.jsxs(r,{color:c,children:[String(h),"%"]})]},n)}),i.jsx(re,{children:"Alerts"}),t.alerts.map((n,o)=>{const a=As[n.severity]??"gray";return i.jsxs(u,{flexDirection:"column",marginBottom:1,children:[i.jsxs(u,{children:[i.jsx(r,{bold:!0,color:a,children:n.severity}),i.jsx(r,{children:" "}),i.jsx(r,{children:n.type})]}),n.props?i.jsx(r,{dimColor:!0,wrap:"wrap",children:JSON.stringify(n.props)}):null]},`${n.type}-${String(o)}`)})]})},Ms=({finding:e})=>{const{entry:t}=e;return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Package",children:t.packageName}),i.jsx(C,{label:"Category",children:t.category}),i.jsx(C,{label:"Replacement",children:t.replacement}),t.overrideSpec?i.jsx(C,{label:"Override",children:t.overrideSpec}):null,i.jsx(C,{label:"Codemod",children:i.jsx(r,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?i.jsx(C,{label:"Guide",children:i.jsx(r,{color:"cyan",underline:!0,children:t.docUrl})}):null,i.jsx(re,{children:"Action"}),t.hasCodemod?i.jsxs(r,{dimColor:!0,children:["Run"," ",i.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?i.jsxs(r,{dimColor:!0,children:["Run"," ",i.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to install the package override."]}):t.docUrl?i.jsx(r,{dimColor:!0,children:"No automated codemod. Open the migration guide above for the recommended alternative and steps."}):i.jsx(r,{dimColor:!0,children:"No automated codemod. Consult the package's docs or the e18e module-replacements guide for an alternative."})]})},Fs=({finding:e})=>{const{diagnostic:t}=e,s=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Check",children:t.id}),i.jsx(C,{label:"Status",children:i.jsx(r,{color:s,children:t.status})}),i.jsx(re,{children:"Message"}),i.jsx(r,{wrap:"wrap",children:t.message}),t.detail&&Object.keys(t.detail).length>0?i.jsxs(i.Fragment,{children:[i.jsx(re,{children:"Details"}),Object.entries(t.detail).map(([l,n])=>i.jsxs(u,{children:[i.jsx(u,{width:20,children:i.jsxs(r,{dimColor:!0,children:[l,":"]})}),i.jsx(r,{children:String(n)})]},l))]}):null]})},zs=({finding:e,focused:t,scrollRef:s})=>{const l=t?"white":"gray";if(!e)return i.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:i.jsx(r,{dimColor:!0,children:"No finding selected"})});let n;switch(e.kind){case"duplicate":{n=i.jsx(Os,{finding:e});break}case"optimization":{n=i.jsx(Ms,{finding:e});break}case"outdated":{n=i.jsx(Ds,{finding:e});break}case"runtime":{n=i.jsx(Fs,{finding:e});break}case"socket":{n=i.jsx(Ns,{finding:e});break}case"vulnerability":{n=i.jsx(Ps,{finding:e});break}default:{n=i.jsx(r,{dimColor:!0,children:"Unknown finding kind."});break}}return i.jsxs(u,{borderColor:l,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[i.jsxs(u,{flexShrink:0,paddingTop:1,paddingX:2,children:[i.jsx(r,{bold:!0,color:"white",children:e.title}),i.jsxs(r,{dimColor:!0,children:[" ",at[e.section]]})]}),i.jsxs(bt,{flexGrow:1,flexShrink:1,paddingX:2,ref:s,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[i.jsx(r,{}),n]})]})},dt={error:"red",warn:"yellow"},Ls={error:"✖",warn:"⚠"},Bs=e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,_s=({finding:e,isSelected:t})=>{const s=dt[e.severity],l=Bs(e);return i.jsxs(u,{flexShrink:0,height:1,children:[i.jsx(r,{children:t?">":" "}),i.jsxs(r,{color:s,children:[" ",Ls[e.severity]," "]}),i.jsx(u,{flexGrow:1,children:i.jsx(r,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),l?i.jsx(r,{color:"cyan",children:" ack"}):null,e.subtitle?i.jsxs(r,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},Vs=({count:e,section:t})=>i.jsxs(u,{flexShrink:0,height:1,marginTop:1,children:[i.jsx(r,{dimColor:!0,children:"▼ "}),i.jsx(r,{bold:!0,color:"white",children:at[t].toUpperCase()}),i.jsxs(r,{dimColor:!0,children:[" (",e,")"]})]}),Hs=({count:e,label:t,status:s})=>{const l=s==="running";return i.jsxs(r,{children:[t,l?i.jsxs(r,{children:[" ",i.jsx(rt,{type:"dots"})]}):null,s==="error"?i.jsx(r,{bold:!0,color:"red",children:" ✖"}):i.jsxs(r,{dimColor:!0,children:[" (",String(e),")"]})]})},Ys=({elapsedMs:e,entries:t,filterActive:s,filterText:l,filterType:n,focused:o,fromCache:a=!1,grouped:h,onViewportHeightChange:c,scrollOffset:p,sectionCounts:x,sectionMessage:v,sectionStatus:y,selectedIndex:N,severityFilter:S,totalAll:m,viewportHeight:E})=>{const O=o?"white":"gray",{measuredHeight:M,ref:P}=ts(E,c);let R=0,F=0;for(const b of t)b.severity==="error"?R+=1:b.severity==="warn"&&(F+=1);const U=[];R>0&&U.push(`${String(R)} error${R===1?"":"s"}`),F>0&&U.push(`${String(F)} warn${F===1?"":"s"}`);const ee=U.length>0?` (${U.join(", ")})`:"",te=(e/1e3).toFixed(1),G=[];for(const[b,$]of h){G.push(i.jsx(Vs,{count:$.length,section:b},`hdr-${b}`));for(const V of $){const T=t.indexOf(V);G.push(i.jsx(_s,{finding:V,isSelected:T===N},V.id))}}let X=0;for(const[,b]of h)X+=2+b.length;const _=X>M&&M>0;return i.jsxs(u,{borderColor:O,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[i.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[i.jsx(r,{bold:!0,inverse:!0,children:" DOCTOR "}),i.jsxs(r,{wrap:"truncate",children:[t.length,t.length===m?"":`/${String(m)}`," finding",t.length===1?"":"s",ee]}),S?i.jsx(r,{bold:!0,color:dt[S],inverse:!0,children:` ${S.toUpperCase()} ONLY `}):null,a?i.jsx(r,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,i.jsxs(r,{dimColor:!0,children:[" · ",te,"s"]})]}),i.jsx(u,{flexShrink:0,paddingX:1,paddingY:1,children:i.jsx(Zt,{isFocused:o,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:()=>{},showIndex:!1,value:n,children:me.map(({id:b,label:$})=>i.jsx(es,{name:b,children:i.jsx(Hs,{count:x[b],label:$,status:y[b]})},b))})}),(()=>{const b=Object.keys(y).filter($=>y[$]==="running"&&v[$]).map($=>v[$]);return b.length===0?null:i.jsx(u,{flexShrink:0,paddingX:1,children:i.jsxs(r,{dimColor:!0,wrap:"truncate",children:[i.jsx(rt,{type:"dots"})," ",b.join(" · ")]})})})(),s&&i.jsxs(u,{flexShrink:0,paddingX:1,children:[i.jsx(r,{bold:!0,color:"white",children:"/ "}),i.jsx(r,{children:l}),i.jsx(r,{inverse:!0,children:" "})]}),i.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:P,children:[i.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:i.jsx(u,{flexDirection:"column",marginTop:-p,children:G.length>0?G:i.jsx(u,{marginTop:1,children:i.jsx(r,{dimColor:!0,children:"No findings match the current filter."})})})}),_&&i.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:i.jsx(jt,{contentHeight:X,placement:"inset",scrollOffset:p,style:"block",viewportHeight:M})})]},`list-${n}-${l}`)]})},Us=e=>{if(e.kind==="outdated")return{command:`vis update ${e.entry.packageName}`,description:`Update ${e.entry.packageName} to ${e.entry.newRange}`};if(e.kind==="duplicate")return{command:`vis dedupe ${e.pkg.name}`,description:`Dedupe ${e.pkg.name} (${String(e.pkg.versions.length)} versions)`}},Gs=e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},Ws=e=>{if(e.kind!=="outdated"&&e.kind!=="vulnerability"&&e.kind!=="socket")return;const t=e.kind==="outdated"?e.entry.packageName:e.packageName,s=["// Add to vis.config.ts:","security: {"," acceptedRisks: {",` "${t}": {`,' reason: "explain why this risk is acceptable",',' expiresAt: "YYYY-MM-DD",'," },"," },","},"].join(`
3
- `);return{command:s,configSnippet:s,description:`Acknowledge risk for ${t}`}},Ks=100,Xs=40,qs=10,Js=({autoExitSeconds:e=0,banner:t,fromCache:s=!1,startedAt:l,store:n})=>{const{exit:o}=vt(),{columns:a,rows:h}=St(),c=z.useSyncExternalStore(n.subscribe,n.getSnapshot),[p,x]=z.useState(!1),[v,y]=z.useState(!1),[N,S]=z.useState(0),[m,E]=z.useState(()=>Date.now());z.useEffect(()=>{const w=setInterval(()=>{E(Date.now())},1e3);return()=>{clearInterval(w)}},[]);const O=m-l,M=z.useRef(null),P=z.useRef(null),R=c.entries[c.selectedIndex]??null,F=z.useMemo(()=>{const w={dependencies:0,optimization:0,runtime:0,security:0};for(const g of c.all)w[g.section]+=1;return w},[c.all]),U=t?t.hint?5:4:0,ee=z.useMemo(()=>{for(const w of Object.keys(c.sectionStatus))if(c.sectionStatus[w]==="running"&&c.sectionMessage[w])return 1;return 0},[c.sectionStatus,c.sectionMessage]),te=a>=Ks,G=te?Math.max(1,h-U-2):Math.floor(h*.55),X=Math.max(1,G-6-ee-(c.filterActive?1:0)),[_,b]=z.useState(X),$=_>0?_:X,V=z.useMemo(()=>{let w=0;for(const[,g]of c.grouped)w+=2+g.length;return w},[c.grouped]),T=Math.max(0,V-$),ne=Math.min(N,T),B=z.useCallback(w=>{let g=0,k=0;for(const[,xe]of c.grouped){g+=2;for(let he=0;he<xe.length;he++){if(k===w)return g;g+=1,k+=1}}return g},[c.grouped]),q=z.useCallback(w=>{const g=B(w);S(k=>g>k+$-2?Math.min(T,Math.max(0,g-$+2)):g<k+1?Math.max(0,g-1):k)},[B,$,T]);if(z.useEffect(()=>{P.current?.scrollToTop()},[R?.id]),$t((w,g)=>{if(w==="c"&&g.ctrl){o();return}if(!v){if(p){g.escape||w==="?"?x(!1):w==="q"?(x(!1),y(!0)):g.downArrow||w==="j"?M.current?.scrollBy(1):(g.upArrow||w==="k")&&M.current?.scrollBy(-1);return}if(w==="?"){x(!0);return}if(w==="q"){y(!0);return}if(g.tab){n.setFocusedPanel(c.focusedPanel==="list"?"detail":"list");return}if(c.filterActive){if(g.escape||g.return){n.setFilterActive(!1);return}if(g.backspace){S(0),n.setFilter(c.filterText.slice(0,-1));return}w&&!g.ctrl&&!g.meta&&(S(0),n.setFilter(c.filterText+w));return}if(c.focusedPanel==="list"&&(g.leftArrow||g.rightArrow)){const k=me.findIndex(he=>he.id===c.filterType),xe=g.rightArrow?(k+1)%me.length:(k-1+me.length)%me.length;S(0),P.current?.scrollToTop(),n.setFilterType(me[xe].id);return}if(c.focusedPanel==="list"){if(g.downArrow||w==="j"){const k=Math.min(c.selectedIndex+1,c.entries.length-1);n.setSelectedIndex(k),q(k);return}if(g.upArrow||w==="k"){const k=Math.max(c.selectedIndex-1,0);n.setSelectedIndex(k),q(k);return}if(g.pageDown){const k=Math.min(c.selectedIndex+10,c.entries.length-1);n.setSelectedIndex(k),q(k);return}if(g.pageUp){const k=Math.max(c.selectedIndex-10,0);n.setSelectedIndex(k),q(k);return}if(g.home){n.setSelectedIndex(0),S(0);return}if(g.end){const k=c.entries.length-1;n.setSelectedIndex(k),q(k);return}if(w==="/"){n.setFilterActive(!0);return}if(w==="e"){n.setSeverityFilter(c.severityFilter==="error"?void 0:"error"),S(0);return}if(w==="w"){n.setSeverityFilter(c.severityFilter==="warn"?void 0:"warn"),S(0);return}if(w==="u"&&R){const k=Us(R);k&&(n.setPendingAction(k),o());return}if(w==="o"&&R){const k=Gs(R);k&&(n.setPendingAction(k),o());return}if(w==="a"&&R){const k=Ws(R);k&&(n.setPendingAction(k),o());return}if(w==="d"){n.setFocusedPanel("detail");return}return}if(g.escape||g.leftArrow){n.setFocusedPanel("list");return}if(g.downArrow||w==="j"){P.current?.scrollBy(1);return}if(g.upArrow||w==="k"){P.current?.scrollBy(-1);return}if(g.pageDown){P.current?.scrollBy(10);return}if(g.pageUp){P.current?.scrollBy(-10);return}if(g.home){P.current?.scrollToTop();return}g.end&&P.current?.scrollToBottom()}},{isActive:!0}),a<Xs||h<qs)return i.jsx(u,{alignItems:"center",height:h,justifyContent:"center",width:a,children:i.jsxs(r,{color:"yellow",children:["Terminal too small (",a,"x",h,")"]})});const ce=c.focusedPanel==="detail",L=[i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"q"}),i.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"?"}),i.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"↑↓"}),i.jsx(r,{dimColor:!0,children:ce?"SCROLL":"NAV"})]},"nav"),ce?i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"←/Esc"}),i.jsx(r,{dimColor:!0,children:"LIST"})]},"lr"):i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"←→"}),i.jsx(r,{dimColor:!0,children:"SECTION"})]},"lr"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"/"}),i.jsx(r,{dimColor:!0,children:"SEARCH"})]},"search"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"e/w"}),i.jsx(r,{dimColor:!0,children:"SEVERITY"})]},"sev"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"u/o/a"}),i.jsx(r,{dimColor:!0,children:"ACTION"})]},"actions"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"Tab"}),i.jsx(r,{dimColor:!0,children:"PANEL"})]},"tab")],H=i.jsx(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:i.jsx(u,{gap:2,overflow:"hidden",paddingX:1,children:L})}),W=i.jsxs(Ct,{footer:i.jsxs(r,{dimColor:!0,children:[i.jsx(r,{bold:!0,color:"white",children:"↑↓"})," scroll ",i.jsx(r,{bold:!0,color:"white",children:"?"}),"/",i.jsx(r,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:M,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:p,width:56,children:[i.jsxs(u,{flexDirection:"column",marginBottom:1,children:[i.jsxs(u,{marginBottom:1,children:[i.jsx(r,{dimColor:!0,children:"── "}),i.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),i.jsxs(u,{children:[i.jsx(u,{width:26,children:i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" ↑/k "}),i.jsx(r,{dimColor:!0,children:"Move up"})]})}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" ↓/j "}),i.jsx(r,{dimColor:!0,children:"Move down"})]})]}),i.jsxs(u,{children:[i.jsx(u,{width:26,children:i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" PgUp"}),i.jsx(r,{dimColor:!0,children:" Jump up 10"})]})}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" PgDn"}),i.jsx(r,{dimColor:!0,children:" Jump down 10"})]})]}),i.jsxs(u,{children:[i.jsx(u,{width:26,children:i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" Home"}),i.jsx(r,{dimColor:!0,children:" Jump to top"})]})}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" End"}),i.jsx(r,{dimColor:!0,children:" Jump to bottom"})]})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" Tab"}),i.jsx(r,{dimColor:!0,children:" Switch panel"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" →/←"}),i.jsx(r,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),i.jsxs(u,{flexDirection:"column",marginBottom:1,children:[i.jsxs(u,{marginBottom:1,children:[i.jsx(r,{dimColor:!0,children:"── "}),i.jsx(r,{bold:!0,color:"white",children:"FILTER"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" /"}),i.jsx(r,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" e"}),i.jsx(r,{dimColor:!0,children:" Toggle errors-only filter"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" w"}),i.jsx(r,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),i.jsxs(u,{flexDirection:"column",marginBottom:1,children:[i.jsxs(u,{marginBottom:1,children:[i.jsx(r,{dimColor:!0,children:"── "}),i.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" u"}),i.jsx(r,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" o"}),i.jsx(r,{dimColor:!0,children:" Exit + suggest optimize command"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" a"}),i.jsx(r,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" d"}),i.jsx(r,{dimColor:!0,children:" Focus detail panel"})]})]}),i.jsxs(u,{flexDirection:"column",children:[i.jsxs(u,{marginBottom:1,children:[i.jsx(r,{dimColor:!0,children:"── "}),i.jsx(r,{bold:!0,color:"white",children:"EXIT"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" q"}),i.jsx(r,{dimColor:!0,children:" Quit (with countdown)"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" Ctrl+C"}),i.jsx(r,{dimColor:!0,children:" Quit immediately"})]})]})]}),ae=i.jsx(Ys,{elapsedMs:O,entries:c.entries,filterActive:c.filterActive,filterText:c.filterText,filterType:c.filterType,focused:c.focusedPanel==="list",fromCache:s,grouped:c.grouped,onViewportHeightChange:b,scrollOffset:ne,sectionCounts:F,sectionMessage:c.sectionMessage,sectionStatus:c.sectionStatus,selectedIndex:c.selectedIndex,severityFilter:c.severityFilter,totalAll:c.all.length,viewportHeight:$}),de=t?i.jsx(Ts,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,ue=i.jsx(zs,{finding:R,focused:c.focusedPanel==="detail",scrollRef:P});if(te){const w=Math.floor(a*.4);return i.jsxs(u,{flexDirection:"column",height:h,width:a,children:[de,i.jsxs(u,{flexDirection:"row",flexGrow:1,children:[i.jsx(u,{flexGrow:1,children:ae}),i.jsx(u,{width:w,children:ue})]}),H,i.jsx(Fe,{autoExitSeconds:e||3,onCancel:()=>{y(!1)},visible:v}),W]})}return i.jsxs(u,{flexDirection:"column",height:h,width:a,children:[de,i.jsx(u,{height:G,children:ae}),i.jsx(u,{flexGrow:1,children:ue}),H,i.jsx(Fe,{autoExitSeconds:e||3,onCancel:()=>{y(!1)},visible:v}),W]})},Qs=e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),Zs=e=>{const t=e.split("*").map(s=>Qs(s));return new RegExp(`^${t.join(".*")}$`,"i")},ei=e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>Zs(t)):[],$e=(e,t)=>{for(const s of t)if(s.test(e))return!0;return!1},ti=(e,t,s)=>{if(t.length===0)return e;const l=e.outdated.filter(p=>$e(p.packageName,t)),n=e.duplicates.filter(p=>$e(p.name,t)),o=e.optimizations.filter(p=>$e(p.packageName,t));let a=0,h=0,c=0;for(const p of l)p.vulnerabilities&&(a+=p.vulnerabilities.length),p.socketReport&&(h+=p.socketReport.alerts.length,p.socketReport.score.overall<s&&(c+=1));return{...e,duplicates:n,optimizations:o,outdated:l,socketIssues:{alerts:h,lowScore:c},vulnCount:a}},ut=(e,t)=>t.length===0?[...e]:e.filter(s=>{if(s.kind==="runtime")return!0;const l=s.kind==="duplicate"?s.pkg.name:s.kind==="outdated"||s.kind==="optimization"?s.entry.packageName:s.packageName;return $e(l,t)}),ht=["dependencies","security","optimization","runtime"],Ye=e=>{const t=new Set;if(!e)return t;for(const s of e.split(",")){const l=s.trim().toLowerCase();ht.includes(l)&&t.add(l)}return t},si=(e,t)=>{if(e!==void 0&&e!=="")return Ye(e);const s=Ye(t);return new Set(ht.filter(l=>!s.has(l)))},pt=e=>{const t={micro:0,native:0,preferred:0,socket:0,total:e.length};for(const s of e)switch(s.category){case"micro-utility":{t.micro+=1;break}case"native":{t.native+=1;break}case"preferred":{t.preferred+=1;break}case"socket":{t.socket+=1;break}}return t},ie=(e,t)=>{if(!e.sections.has(t))return"skip";switch(t){case"dependencies":return e.outdated.length>0||e.duplicates.length>0?"warn":"ok";case"optimization":return e.optimizations.length>0?"warn":"ok";case"runtime":return e.runtime.some(s=>s.status==="warn")?"warn":"ok";case"security":return e.vulnCount>0||e.socketIssues.alerts>0?"error":e.socketIssues.lowScore>0?"warn":"ok";default:return"ok"}},ii=(e,t)=>{const s=pt(e.optimizations),l={dependencies:ie(e,"dependencies"),optimization:ie(e,"optimization"),runtime:ie(e,"runtime"),security:ie(e,"security")},n=new Set([...Object.values(l),e.supplyChain.status]),o=n.has("error")?"error":n.has("warn")?"warn":"ok";return{dependencies:{duplicates:e.duplicates.length,installed:e.installedCount,outdated:e.outdated.length,status:l.dependencies},elapsedMs:e.elapsedMs,optimizations:{microUtilities:s.micro,native:s.native,preferred:s.preferred,socket:s.socket,status:l.optimization,total:s.total},packageManager:t,runtime:e.runtime.map(a=>({detail:a.detail,id:a.id,message:a.message,status:a.status})),runtimeStatus:l.runtime,security:{alerts:e.socketIssues.alerts,lowScorePackages:e.socketIssues.lowScore,status:l.security,vulnerabilities:e.vulnCount},status:o,supplyChain:{findings:e.supplyChain.findings.map(a=>({detail:a.detail,label:a.label,severity:a.severity})),status:e.supplyChain.status},workspaces:e.workspaceCount}},Ue=(e,t)=>{const s=e.runtime.some(n=>n.status==="warn"),l=e.vulnCount>0||e.socketIssues.alerts>0;return t?l||e.outdated.length>0||e.duplicates.length>0||s:l},ri=["aube-workspace.yaml","pnpm-workspace.yaml"],ke=e=>typeof e=="boolean"?e:void 0,ni=e=>{if(e==="no-downgrade"||e==="off")return e},oi=e=>{const t={allowBuildsCount:0,blockExoticSubdeps:void 0,jailBuilds:void 0,minimumReleaseAge:void 0,minimumReleaseAgeStrict:void 0,paranoid:void 0,source:void 0,strictDepBuilds:void 0,trustPolicy:void 0};for(const s of ri){const l=K(e,s);if(!je(l))continue;let n;try{n=ss(Tt(l))}catch{continue}if(typeof n!="object"||n===null)continue;const o=n;return t.source=s,t.paranoid=ke(o.paranoid),t.trustPolicy=ni(o.trustPolicy),t.blockExoticSubdeps=ke(o.blockExoticSubdeps),t.jailBuilds=ke(o.jailBuilds),t.strictDepBuilds=ke(o.strictDepBuilds),t.minimumReleaseAgeStrict=ke(o.minimumReleaseAgeStrict),typeof o.minimumReleaseAge=="number"&&Number.isFinite(o.minimumReleaseAge)&&(t.minimumReleaseAge=o.minimumReleaseAge),o.allowBuilds&&typeof o.allowBuilds=="object"&&!Array.isArray(o.allowBuilds)&&(t.allowBuildsCount=Object.keys(o.allowBuilds).length),t}return t},li=e=>e.paranoid?{...e,jailBuilds:!0,minimumReleaseAgeStrict:!0,strictDepBuilds:!0,trustPolicy:"no-downgrade"}:e,ci=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,ai=e=>{const t=ci.exec(e);if(t)return{name:t[1],version:t[2]}},di=(e,t)=>{let s;try{if(t==="pnpm"){const n=K(e,"pnpm-workspace.yaml");je(n)&&(s=is(n)?.patchedDependencies)}else if(t==="bun"){const n=K(e,"package.json");je(n)&&(s=tt(n)?.patchedDependencies)}}catch{return[]}if(!s||typeof s!="object")return[];const l=[];for(const[n,o]of Object.entries(s)){if(typeof o!="string"||o.length===0)continue;const a=ai(n);a&&l.push({name:a.name,patchFile:o,resolvedPatchFile:Et(o)?o:qe(e,o),version:a.version})}return l},ui=e=>{const t=[];for(const s of e)je(s.resolvedPatchFile)||t.push({entry:s,kind:"missing-file"});return t},Ge=e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok",hi=(e,t={})=>{const s=[],l=e?.security;if(!l)return s.push({detail:"Use defineConfig() from '@visulima/vis/config' to apply secure defaults.",label:"No security config — running with the PM's native defaults",severity:"warn"}),{findings:s,status:Ge(s)};const n=l.policies?.firstSeen?.minutes,o=l.policies?.publisherChange,a=l.policies?.installScripts;n===void 0?s.push({detail:"Set security.policies.firstSeen.minutes to block packages published in the last N minutes (mitigates supply-chain attacks).",label:"policies.firstSeen.minutes is not set",severity:"warn"}):n===0?s.push({detail:"New packages can be installed immediately after publishing. Consider setting a non-zero cooldown.",label:"policies.firstSeen.minutes is explicitly 0",severity:"warn"}):s.push({label:`policies.firstSeen.minutes: ${String(n)} minutes`,severity:"ok"}),o?.mode===void 0||o.mode==="off"?s.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`policies.publisherChange.mode: ${o?.mode??"not set"}`,severity:"warn"}):s.push({label:`policies.publisherChange.mode: ${o.mode}`,severity:"ok"}),l.blockExoticSubdeps===void 0||!l.blockExoticSubdeps?s.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(l.blockExoticSubdeps??!1)}`,severity:"warn"}):s.push({label:"blockExoticSubdeps: true",severity:"ok"});const h=a?.allow?Object.keys(a.allow).length:0;if(h===0?s.push({detail:"Lifecycle scripts are blocked by default. List trusted packages here to opt them back in (e.g. esbuild, @prisma/client).",label:"policies.installScripts.allow: not configured",severity:"warn"}):s.push({label:`policies.installScripts.allow: ${String(h)} ${h===1?"entry":"entries"}`,severity:"ok"}),a?.strict&&h===0&&s.push({detail:"All dependencies with build scripts will be blocked. Run 'vis approve-builds' to populate the allow list.",label:"policies.installScripts.strict is on but allow is empty",severity:"error"}),t.workspaceRoot){const c=rs(t.workspaceRoot);if(c.length>0){const p=[...new Set(c.map(x=>x.tool))].sort((x,v)=>x.localeCompare(v)).join(", ");s.push({detail:"Run `vis migrate verify` for the full list, then re-run `vis migrate <tool>` to clean up.",label:`${String(c.length)} leftover ${c.length===1?"reference":"references"} to ${p}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager==="aube"){const c=oi(t.workspaceRoot),p=li(c),x=p.source?` (from ${p.source})`:"";p.paranoid===!0&&s.push({detail:"Forces jailBuilds, trustPolicy=no-downgrade, minimumReleaseAgeStrict, strictStoreIntegrity, and strictDepBuilds on.",label:`aube paranoid: true${x}`,severity:"ok"}),p.trustPolicy==="off"&&s.push({detail:"Trust downgrades between releases will not be blocked. Set trustPolicy: no-downgrade in aube-workspace.yaml.",label:`aube trustPolicy: off${x}`,severity:"warn"}),p.blockExoticSubdeps===!1&&s.push({detail:"Transitive deps from git+, file:, and tarball URLs will not be blocked. Re-enable with blockExoticSubdeps: true.",label:`aube blockExoticSubdeps: false${x}`,severity:"warn"}),p.minimumReleaseAge===0&&s.push({detail:"Newly published versions are not held in a cooling window. Restore with minimumReleaseAge: 1440 (24h) or higher.",label:`aube minimumReleaseAge: 0${x}`,severity:"warn"}),p.jailBuilds===!0&&s.push({label:`aube jailBuilds: true${x}`,severity:"ok"}),p.strictDepBuilds===!0&&s.push({label:`aube strictDepBuilds: true${x}`,severity:"ok"}),p.allowBuildsCount>0&&s.push({label:`aube allowBuilds: ${String(p.allowBuildsCount)} ${p.allowBuildsCount===1?"entry":"entries"}${x}`,severity:"ok"})}if(t.workspaceRoot&&t.packageManager){const c=di(t.workspaceRoot,t.packageManager);if(c.length>0){const p=ui(c);if(p.length===0)s.push({label:`patchedDependencies: ${String(c.length)} ${c.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const x of p)s.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${x.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${x.entry.name}@${x.entry.version}`,severity:"error"})}}return{findings:s,status:Ge(s)}},Y=e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,ve=async(e,t,s,l)=>{if(!e)return s();e.start(t);const n=Date.now();try{const o=await s(),a=Date.now()-n,{status:h,summary:c}=l(o,a);return e.finish(t,h,c),o}catch(o){const a=Date.now()-n,h=o instanceof Error?o.message:String(o);throw e.finish(t,"error",`${h} (${Y(a)})`),o}},pi=(e,t)=>{const s={duplicates:t.duplicates,optimizations:t.optimizations,outdated:t.outdated,runtime:t.runtime,sections:new Set([e])};return ct(s)},We=async e=>{const{filterPatterns:t,installed:s,progress:l,resolveCodemods:n,sections:o,store:a,visConfig:h,workspaceRoot:c}=e,p=o.has("dependencies"),x=o.has("security"),v=o.has("optimization"),y=o.has("runtime"),N=(f,A)=>ut(pi(f,A),t),S=it(c),{packageManager:m}=Xe(c),E=Be(K(c,"package.json"),!1),O=st(c),M=new Set(E);for(const f of O){const A=Be(K(qe(c,f),"package.json"),!1);for(const I of A)M.add(I)}const P=Dt(c),R=Je(c,m),F=Qe(h?.security,{minimumScore:h?.security?.policies?.score?.minimum}),U=h?.security?.policies?.score?.minimum??et,ee=h?.security?.acceptedRisks,te=_t(c,S.name),G={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},X=p?Qt(c,S.name):[],_=v?Vt(M):[],b=v?Ht(M,te,S,!1):[],$=new Set(_.map(f=>f.packageName)),V=b.filter(f=>!$.has(f.packageName)),T=[..._,...V],ne=y?js(c):[];a&&(p&&a.startSection("dependencies",R.size>0?"checking outdated catalog dependencies":"scanning duplicates"),x&&a.startSection("security",s.length>0?`scanning ${String(s.length)} packages for advisories`:"no installed packages to scan"),v&&a.startSection("optimization","matching e18e + socket overrides"),y&&a.startSection("runtime","running runtime diagnostics")),a&&y&&a.completeSection("runtime",N("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:ne}));const q=(p||x)&&R.size>0?ve(l,"outdated",()=>Ot(R,G,P,void 0,c,F,ee),(f,A)=>{const I=f.outdated.length;return{status:I>0?"warn":"ok",summary:I>0?`${String(I)} outdated · ${Y(A)}`:`up to date · ${Y(A)}`}}):Promise.resolve({checkedCount:0,failed:[],filteredByTarget:[],ignored:[],outdated:[]}),ce=x&&s.length>0?ve(l,"vulnerabilities",()=>Pt(s.map(f=>({name:f.name,version:f.version}))),(f,A)=>{let I=0;for(const se of f.values())I+=se.length;return{status:I>0?"error":"ok",summary:I>0?`${String(I)} found · ${Y(A)}`:`none found · ${Y(A)}`}}):Promise.resolve(new Map),L=x&&F.length>0&&s.length>0?ve(l,"socket",()=>Nt(F,s.map(f=>({name:f.name,version:f.version}))),(f,A)=>{let I=0,se=0;for(const Me of f.values())I+=Me.alerts.length,Me.score.overall<U&&(se+=1);const Ne=I+se;return{status:Ne>0?"warn":"ok",summary:Ne>0?`${String(I)} alert${I===1?"":"s"}, ${String(se)} low-score · ${Y(A)}`:`clean · ${Y(A)}`}}):Promise.resolve(new Map);let H,W,ae,de;const ue=q.catch(f=>(H=f instanceof Error?f.message:String(f),a||d.warn(`Outdated scan failed: ${H}`),{failed:[],ignored:[],outdated:[]})),w=ce.catch(f=>(W=f instanceof Error?f.message:String(f),a||d.warn(`Vulnerability scan failed: ${W}`),new Map)),g=L.catch(f=>(ae=f instanceof Error?f.message:String(f),a||d.warn(`Socket scan failed: ${ae}`),new Map)),k=a&&p?ue.then(f=>{if(H){a.failSection("dependencies",H);return}a.completeSection("dependencies",N("dependencies",{duplicates:X,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,xe=a&&x?Promise.all([ue,w,g]).then(([f])=>{const A=H??W??ae;if(A){a.failSection("security",A);return}a.completeSection("security",N("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,he=(async()=>{if(n&&v&&T.length>0&&await ve(l,"codemods",async()=>(await Gt(T),T),(f,A)=>{const I=f.filter(se=>se.hasCodemod||se.category==="socket").length;return{status:"ok",summary:`${String(I)} auto-fixable · ${Y(A)}`}}).catch(f=>{de=f instanceof Error?f.message:String(f)}),a&&v){if(de){a.failSection("optimization",de);return}a.completeSection("optimization",N("optimization",{duplicates:[],optimizations:T,outdated:[],runtime:[]}))}})(),[De,mt,gt]=await Promise.all([ue,w,g]);await Promise.all([k,xe,he]);let Oe=0,Pe=0;if(x&&F.length>0)for(const f of gt.values())Oe+=f.alerts.length,f.score.overall<U&&(Pe+=1);let Ee=0;if(x){for(const f of De.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Ee+=f.vulnerabilities.length);for(const f of mt.values())Ee+=f.length}return{duplicates:X,installedCount:s.length,optimizations:v?T:[],outdated:p?De.outdated:[],runtime:ne,sections:o,socketIssues:{alerts:Oe,lowScore:Pe},supplyChain:hi(h,{packageManager:m,workspaceRoot:c}),vulnCount:Ee,workspaceCount:O.length}},fi=e=>{switch(e){case"error":return be(D.failure);case"skip":return j(D.dash);case"warn":return Re(D.warning);default:return ge(D.success)}},le=(e,t)=>{const s=process.stderr.columns??80,l=Math.max(20,Math.min(s-2,60)),n=D.dash.repeat(2),o=`${fi(t)} ${oe(e)}`,a=o.replaceAll(/\[[0-9;]*m/g,"").length,h=Math.max(0,l-a-n.length-2);return`${n} ${o} ${j(D.dash.repeat(h))}`},Z=e=>` ${ge(D.success)} ${e}`,J=e=>` ${Re(D.warning)} ${e}`,Ie=e=>` ${be(D.failure)} ${e}`,ft=e=>` ${j(D.dash)} ${j(e)}`,Q=(e,t,s)=>{const l=`${oe(String(e))} ${j(t)}`;return s?`${l} ${j(`(${s})`)}`:l},mi=e=>{if(e.sections.has("dependencies")){if(d.log(""),d.log(le("Dependencies",ie(e,"dependencies"))),d.log(Z(Q(e.installedCount,"packages installed"))),e.outdated.length>0){const t=e.outdated.filter(o=>o.updateType==="major").length,s=e.outdated.filter(o=>o.updateType==="minor").length,l=e.outdated.filter(o=>o.updateType==="patch").length,n=[];t>0&&n.push(`${String(t)} major`),s>0&&n.push(`${String(s)} minor`),l>0&&n.push(`${String(l)} patch`),d.log(J(Q(e.outdated.length,"outdated",n.join(", "))))}else d.log(Z("All dependencies up to date"));e.duplicates.length>0?d.log(J(Q(e.duplicates.length,"packages with duplicate versions"))):d.log(Z("No duplicate dependencies"))}},gi=e=>{e.sections.has("security")&&(d.log(""),d.log(le("Security",ie(e,"security"))),e.vulnCount>0?d.log(Ie(Q(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):d.log(Z("No known vulnerabilities")),e.socketIssues.alerts>0&&d.log(J(Q(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&d.log(J(Q(e.socketIssues.lowScore,`package${e.socketIssues.lowScore===1?"":"s"} with low security score`))),e.socketIssues.alerts===0&&e.socketIssues.lowScore===0&&e.vulnCount===0&&d.log(Z("No security issues detected")))},xi=e=>{if(!e.sections.has("optimization"))return;d.log(""),d.log(le("Optimization",ie(e,"optimization")));const t=pt(e.optimizations);if(t.total===0){d.log(Z("No optimizations available"));return}t.native>0&&d.log(J(Q(t.native,"replaceable with native APIs"))),t.preferred>0&&d.log(J(Q(t.preferred,"with lighter alternatives"))),t.micro>0&&d.log(J(Q(t.micro,"trivial micro-utilities"))),t.socket>0&&d.log(J(Q(t.socket,"@socketregistry overrides available")))},wi=e=>{d.log(""),d.log(le("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const s=t.severity==="ok"?Z(t.label):t.severity==="error"?Ie(t.label):J(t.label);d.log(s),t.detail&&d.log(` ${j(D.arrow)} ${j(t.detail)}`)}e.supplyChain.status!=="ok"&&d.log(` ${j(D.arrow)} ${j("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},ki=e=>{if(e.sections.has("runtime")){d.log(""),d.log(le("Runtime",ie(e,"runtime")));for(const t of e.runtime)t.status==="ok"?d.log(Z(t.message)):t.status==="skip"?d.log(ft(t.message)):d.log(J(t.message))}},yi=(e,t)=>{const s=e.vulnCount,l=e.runtime.filter(o=>o.status==="warn").length,n=e.outdated.length+e.duplicates.length+e.optimizations.length+l;if(t){if(s===0&&n===0)d.success(`Everything looks good! ${j(`(${Y(e.elapsedMs)})`)}`);else{const o=[];s>0&&o.push(be(`${String(s)} security`)),n>0&&o.push(Re(`${String(n)} improvement${n===1?"":"s"}`)),d.log(`${be(D.failure)} ${o.join(", ")} ${j(`(${Y(e.elapsedMs)})`)}`)}return}d.log(""),d.log(le("Summary","ok")),s===0&&n===0?d.success(`Everything looks good! ${j(`(${Y(e.elapsedMs)})`)}`):(s>0&&d.error(`${String(s)} security issue${s===1?"":"s"}`),n>0&&d.log(` ${ye(D.arrow)} ${oe(String(n))} ${j(`improvement${n===1?"":"s"} available`)} ${j(`(${Y(e.elapsedMs)})`)}`))},bi=e=>{const t=[];if(e.outdated.length>0&&t.push("vis update — update outdated dependencies"),(e.vulnCount>0||e.socketIssues.alerts>0)&&t.push("vis audit — detailed security analysis"),e.optimizations.length>0&&t.push("vis optimize — apply optimizations interactively"),e.duplicates.length>0&&t.push("vis dedupe — reduce duplicate versions"),t.length>0){d.log(""),d.log(oe("Next steps:"));for(const s of t)d.log(` ${j(D.arrow)} ${s}`)}d.log("")},ji=(e,t)=>{t||(mi(e),gi(e),xi(e),ki(e),wi(e)),yi(e,t)},vi=(e,t,s,l,n)=>{const o=[],a=e.has("dependencies"),h=e.has("security"),c=e.has("optimization");return(a||h)&&t>0&&o.push({id:"outdated",label:"Outdated catalog dependencies"}),h&&l>0&&o.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),h&&s&&l>0&&o.push({id:"socket",label:"Socket.dev supply-chain reports"}),c&&n&&o.push({id:"codemods",label:"Codemod availability"}),o},Si=e=>{if(d.log(""),d.log(`${oe(ye("vis doctor"))} ${j("— project health check")}`),d.log(Z(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.runtimeFindings.length===0)d.log(Z(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const s=t.severity==="error"?be:Re;d.log(Ie(`Runtime: ${s(t.message)}`))}d.log(` ${j(D.arrow)} Run ${ge("vis toolchain install")} to install pinned versions, or ${ge("vis toolchain status")} for the per-tool breakdown.`)}d.log("")},Ki=async({fs:e,logger:t,options:s,visConfig:l,visConfigError:n,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root.");const a=s.format==="json"||s.json,h=si(s.only,s.skip),c=!!s.quiet,p=s.progress===!1,x=ei(s.filter);if(h.size===0){d.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const v=Date.now(),y=it(o),N=Kt(o),S=!!process.stdout.isTTY,m=!a&&S&&!At&&!c&&!p;!a&&!m&&Si({nodeVersion:process.versions.node,packageManagerName:y.name,packageManagerVersion:y.version,runtimeFindings:N});const E=Je(o,Xe(o).packageManager),O=qt(o,y.name),M=O.length,P=Qe(l?.security).length>0,R=l?.security?.policies?.score?.minimum??et,F=st(o);if(!a&&!c&&!m){const L=F.length>0?j(` · ${String(F.length)} workspace package${F.length===1?"":"s"}`):"";d.log(`${j("·")} ${j("Found")} ${oe(String(M))} ${j(`installed package${M===1?"":"s"}`)}${L}`)}const U=n?{hint:n.file?`Continuing with default settings — fix or regenerate ${n.file} (vis init --force).`:"Continuing with default settings.",message:n.message,severity:"error",title:n.file?`Failed to load ${n.file}`:"Failed to load vis.config"}:void 0,ee=Jt(o,y.name)?.file,te=ee?K(o,ee):void 0,G=Bt(o),_=s.cache!==!1&&!s.fix?ls({configPath:G,lockfilePath:te,sections:h,socketEnabled:P,workspaceRoot:o}):void 0,b=_?cs(_):void 0,$=b!==void 0;let V,T;if(m){const L=b?new Ve({activeSections:h,findings:ut(ct(b),x)}):new Ve({activeSections:h}),H=Rt(It.createElement(Js,{banner:U,fromCache:$,startedAt:v,store:L}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{V=b??await We({filterPatterns:x,installed:O,resolveCodemods:!!s.fix,sections:h,store:L,visConfig:l,workspaceRoot:o})}catch(W){throw H.unmount(),W}await H.waitUntilExit(),T=L.getSnapshot().pendingAction}else if(b)V=b;else{const L=vi(h,E.size,P,M,!!s.fix),W=Xt(L,{live:!a&&!c&&!p});try{V=await We({filterPatterns:x,installed:O,progress:W,resolveCodemods:!!s.fix,sections:h,visConfig:l,workspaceRoot:o})}finally{W.stop()}}const ne={...V,elapsedMs:Date.now()-v};if(_&&!$)try{as(_,ne)}catch{}const B=ti(ne,x,R);if(a){process.stdout.write(`${JSON.stringify(ii(B,y.name),void 0,2)}
4
- `),s.exitCode&&Ue(B,!!s.strict)&&(process.exitCode=1);return}$&&!c&&d.log(`${j("·")} Cached results (use --no-cache to refresh)`),x.length>0&&!c&&d.log(`${j("·")} Filter active: ${ye(s.filter??"")}`),ji(B,c);const q=B.runtime.some(L=>L.id===Se&&L.status==="warn"),ce=B.sections.has("optimization")&&B.optimizations.length>0;s.fix&&(ce||q)?await $i({force:!!s.fixForce,fs:e,logger:t,pm:y,recoverOrphans:q,results:B,useEditorconfig:l?.editorconfig??!0,workspaceRoot:o}):c||bi(B),T&&(process.stdout.write(`
1
+ import{createRequire as xt}from"node:module";import{F as j,j as oe,q as ye,X as be,b as Re,J as ge}from"../packem_shared/index.server-sXNQYpsl.js";import{aa as yt,U as bt,V as jt,W as vt,T as St,C as $t,X as Ct,Y as Fe,p as d,O as qe,q as Rt,S as O}from"./cli-main.js";import{e as K,z as Tt,v as Et,U as Xe}from"../packem_shared/index-BzhrR_iC.js";import{i as At}from"../packem_shared/index-BjdW45xX.js";import{F as i,X as u,o as r,x as z,a as Je,i as Qe,R as It,m as Ot,n as Dt,h as Pt,j as Nt}from"./catalog.js";import{g as zt,s as Le,D as et}from"../packem_shared/formatBytes-BHAzNIrn-CrusHOew.js";import{y as je}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as tt}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{h as Lt}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{findVisConfigFile as Bt}from"./CONFIG_FILES.js";import{d as st,c as Be,r as _t,b as Vt,a as Ht,e as Yt,f as Ut,m as Gt}from"./handler71.js";import{d as it,n as Wt}from"../packem_shared/pm-runner-CMSml1Bj.js";import{c as Kt}from"../packem_shared/runtime-check-1U8HrQd9.js";import{s as qt}from"../packem_shared/scan-progress-CkumcBG-.js";import{l as Xt,r as Jt,f as Qt}from"../packem_shared/dependency-scan-B8jroa1D.js";import{l as rt}from"../packem_shared/spinner-ukDEdGvp.js";import{n as Zt,a as es}from"../packem_shared/tabs--uxJGL8N.js";import{u as ts}from"../packem_shared/use-measured-height-DUZyyias.js";import{L as ss}from"../packem_shared/index-BisalDCf.js";import{l as is}from"./ts-loader.js";import{s as rs}from"../packem_shared/verify-B_MblU_Q.js";let wt;const kt=e=>(wt??=xt(import.meta.url))(e),we=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ke=e=>{if(typeof we<"u"&&we.versions&&we.versions.node){const[t,s]=we.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return we.getBuiltinModule(e)}return kt(e)},{rmSync:ze,writeFileSync:Mt,statSync:Ft,readFileSync:Ze}=Ke("node:fs"),{spawnSync:Te}=Ke("node:child_process"),Ae=()=>K(zt(),"doctor"),ns=1800*1e3,_e=e=>{if(!e)return"";try{return String(Ft(e).mtimeMs)}catch{return""}},os=2,ls=e=>{const t=JSON.stringify({configMtime:_e(e.configPath),lockfileMtime:_e(e.lockfilePath),schema:os,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return yt(Buffer.from(t))},cs=e=>{const t=K(Ae(),`${e}.json`);if(je(t))try{const s=tt(t);if(Date.now()-s.createdAt>s.ttlMs){ze(t,{force:!0});return}return{...s.results,sections:new Set(s.results.sections)}}catch{ze(t,{force:!0});return}},as=(e,t,s=ns)=>{Lt(Ae());const l={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:s};Mt(K(Ae(),`${e}.json`),JSON.stringify(l,void 0,2),"utf8")},Se="orphans",ds=()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=Ze("/proc/sys/fs/inotify/max_user_watches","utf8").trim(),s=Number.parseInt(t,10);Number.isFinite(s)&&s>0&&(e=s)}catch{return{id:"inotify",message:"Could not read /proc/sys/fs/inotify/max_user_watches.",status:"warn"}}return e===void 0?{id:"inotify",message:"inotify max_user_watches reported a non-numeric value.",status:"warn"}:e<65536?{detail:{maxWatches:e},id:"inotify",message:`inotify watcher limit is ${String(e)} — large monorepos can exhaust this. Bump now with \`sudo sysctl fs.inotify.max_user_watches=524288\` and persist via \`/etc/sysctl.d/99-vis.conf\` so it survives reboot.`,status:"warn"}:{detail:{maxWatches:e},id:"inotify",message:`inotify capacity OK (${String(e)} watches).`,status:"ok"}},us=()=>{const e=!!process.stdin.isTTY,t=!!process.stdout.isTTY;return e&&t?{id:"tty",message:"Interactive TTY available — watch keybinds enabled.",status:"ok"}:!e&&!t?{id:"tty",message:"No TTY on stdin/stdout — running in CI / piped mode (keybinds disabled).",status:"skip"}:{detail:{stdin:String(e),stdout:String(t)},id:"tty",message:e?"stdin is a TTY but stdout is not — output is being captured; keybinds still work.":"stdout is a TTY but stdin is not — keybinds disabled (input is piped).",status:"skip"}},hs=()=>{const e=process.pid;try{return process.platform==="win32"?lt(e):ot(e)}catch{return[]}},ps=()=>{const e=process.pid;let t;try{t=process.platform==="win32"?lt(e):ot(e)}catch{return{id:Se,message:"Could not enumerate processes (ps/tasklist failed).",status:"warn"}}if(t.length===0)return{id:Se,message:"No orphaned vis/task-runner processes detected.",status:"ok"};if(t.length<=2)return{detail:{count:t.length,pids:t.join(",")},id:Se,message:`${String(t.length)} possibly orphaned process(es) detected (PIDs: ${t.join(", ")}). Likely benign.`,status:"skip"};const s=process.platform==="win32"?t.map(l=>`taskkill /F /PID ${String(l)}`).join(" & "):`kill ${t.join(" ")}`;return{detail:{count:t.length,pids:t.join(",")},id:"orphans",message:`${String(t.length)} possibly orphaned vis/task-runner processes — run \`vis doctor --fix\` to clean them up, or kill them manually: ${s}`,status:"warn"}},fs=(e={})=>{const t=e.enumerate??hs,l=e.force===!0?"SIGKILL":"SIGTERM",n=e.kill??ks,o=t(),a=[],h=[];for(const c of o)try{n(c,l),a.push(c)}catch(p){const x=p.code??p.message;if(x==="ESRCH"){a.push(c);continue}h.push({pid:c,reason:x})}return{failed:h,killed:a}},ms=e=>Te("taskkill",e,{encoding:"utf8",timeout:1e4}),gs=(e,t)=>{process.kill(e,t)},xs=(e,t,s=ms)=>{const l=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],n=s(l);if(n.error)throw n.error;if(typeof n.status=="number"&&n.status!==0){const o=n.status===128?"ESRCH":`taskkill exited with code ${String(n.status)}`,a=new Error(o);throw a.code=o,a}},ws=(e,t,s=gs)=>{s(e,t)},ks=(e,t)=>{if(process.platform==="win32"){xs(e,t);return}ws(e,t)},nt=(e,t)=>{const s=Te(e,t,{encoding:"utf8",timeout:1e4});if(s.error)throw s.error;if(typeof s.status=="number"&&s.status!==0)throw new Error(`${e} exited with code ${String(s.status)}`);return typeof s.stdout=="string"?s.stdout:""},ot=e=>{const t=nt("ps",["-Ao","pid=,command="]),s=[];for(const l of t.split(`
2
+ `)){if(l.length===0)continue;const n=/^\s*(\d+)\s+(.+)$/.exec(l);if(!n)continue;const o=Number.parseInt(n[1]??"",10),a=(n[2]??"").toLowerCase();!Number.isFinite(o)||o===e||(/(?:^|[ /])vis-native(?:\s|$|[-.])/.test(a)||/(?:^|[ /])vis\s+run\b/.test(a)||/(?:^|[ /])task-runner(?:\s|$|[-.])/.test(a))&&s.push(o)}return s},lt=e=>{const t=nt("tasklist",["/FO","CSV","/NH"]),s=[];for(const l of t.split(/\r?\n/)){if(l.length===0)continue;const n=l.split(/","/).map(h=>h.replaceAll(/^"|"$/g,"")),o=(n[0]??"").toLowerCase(),a=Number.parseInt(n[1]??"",10);!Number.isFinite(a)||a===e||(o==="vis.exe"||o.startsWith("vis-native")||o.includes("task-runner"))&&s.push(a)}return s},ys=()=>{let e;try{const t=Te("watchman",["--version"],{encoding:"utf8",timeout:2e3});if(t.error||typeof t.status=="number"&&t.status!==0)throw t.error??new Error("watchman exited non-zero");e=typeof t.stdout=="string"?t.stdout.trim():void 0}catch{return{id:"watchman",message:"Watchman not found — `vis` uses native fs.watch (fine for small repos). Install Watchman + `fb-watchman` to scale watch mode on large monorepos.",status:"skip"}}return{detail:e?{version:e}:void 0,id:"watchman",message:e?`Watchman available (${e}) — scalable watch backend in use.`:"Watchman available — scalable watch backend in use.",status:"ok"}},bs=(e=process.cwd())=>{let t="";try{t=Ze(K(e,".gitattributes"),"utf8")}catch(s){if(s.code!=="ENOENT")return{id:"git-lfs",message:"Could not read .gitattributes.",status:"warn"}}if(!t.includes("filter=lfs"))return{id:"git-lfs",message:"No Git LFS tracking declared in .gitattributes.",status:"skip"};try{const s=Te("git",["lfs","version"],{encoding:"utf8",timeout:2e3});if(s.error||typeof s.status=="number"&&s.status!==0)throw s.error??new Error("git-lfs not available")}catch{return{id:"git-lfs",message:"Repo tracks files via Git LFS but `git-lfs` is not installed — checked-out LFS files are pointer stubs, not real content. Install git-lfs and run `git lfs pull`.",status:"warn"}}return{id:"git-lfs",message:"Git LFS tracking declared and `git-lfs` is installed.",status:"ok"}},js=e=>[ds(),us(),ys(),bs(e),ps()],me=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],Ce=["dependencies","security","optimization","runtime"],pe=e=>{const t=new Map;for(const s of Ce)t.set(s,[]);for(const s of e)t.get(s.section).push(s);for(const[s,l]of t)l.length===0&&t.delete(s);return t},fe=(e,t,s,l)=>{let n=e.filter(o=>o.section===t);if(l&&(n=n.filter(o=>o.severity===l)),s){const o=s.toLowerCase();n=n.filter(a=>a.title.toLowerCase().includes(o))}return[...n]},vs=e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const s of Ce)e.has(s)&&(t[s]="idle");return t};class Ve{#e;#s=new Set;constructor(t=[]){const s=Array.isArray(t)?{findings:t}:t,l=s.findings??[],n=s.activeSections??new Set(Ce),o=Ce.find(c=>n.has(c))??"dependencies",a=fe(l,o,"",void 0),h=vs(n);if(l.length>0)for(const c of l)h[c.section]="done";this.#e={all:l,entries:a,filterActive:!1,filterText:"",filterType:o,focusedPanel:"list",grouped:pe(a),pendingAction:void 0,sectionError:{},sectionMessage:{},sectionStatus:h,selectedIndex:0,severityFilter:void 0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#s.add(t),()=>{this.#s.delete(t)});setSelectedIndex(t){const s=Math.max(0,Math.min(t,this.#e.entries.length-1));s!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:s})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:t})}setFilterType(t){if(t===this.#e.filterType)return;const s=fe(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:s,filterType:t,grouped:pe(s),selectedIndex:0})}setFilter(t){const s=fe(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:s,filterText:t,grouped:pe(s),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const s=fe(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:s,filterActive:!1,filterText:"",grouped:pe(s),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const s=fe(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:s,grouped:pe(s),selectedIndex:0,severityFilter:t})}startSection(t,s){this.#t({...this.#e,sectionMessage:{...this.#e.sectionMessage,[t]:s},sectionStatus:{...this.#e.sectionStatus,[t]:"running"}})}completeSection(t,s){const l=[...this.#e.all,...s],n=fe(l,this.#e.filterType,this.#e.filterText,this.#e.severityFilter),o={...this.#e.sectionMessage};delete o[t],this.#t({...this.#e,all:l,entries:n,grouped:pe(n),sectionMessage:o,sectionStatus:{...this.#e.sectionStatus,[t]:"done"}})}failSection(t,s){this.#t({...this.#e,sectionError:{...this.#e.sectionError,[t]:s},sectionStatus:{...this.#e.sectionStatus,[t]:"error"}})}#t(t){this.#e=t;for(const s of this.#s)try{s()}catch{}}}const He={error:0,warn:1},Ss=e=>!!e.acceptedRisk,ct=e=>{const t=[];if(e.sections.has("dependencies")){for(const s of e.outdated)t.push({entry:s,id:`outdated:${s.packageName}`,kind:"outdated",section:"dependencies",severity:"warn",subtitle:`${s.currentRange} → ${s.newRange} (${s.updateType})`,title:s.packageName});for(const s of e.duplicates)t.push({id:`duplicate:${s.name}`,kind:"duplicate",pkg:s,section:"dependencies",severity:"warn",subtitle:`${String(s.versions.length)} versions installed`,title:s.name})}if(e.sections.has("security"))for(const s of e.outdated){if(s.vulnerabilities&&s.vulnerabilities.length>0){const l=s.vulnerabilities[0],n=Ss(s)?"warn":"error",o=s.vulnerabilities.length;t.push({entry:s,id:`vuln:${s.packageName}`,kind:"vulnerability",packageName:s.packageName,section:"security",severity:n,subtitle:o===1?`${l.severity} · ${l.id}`:`${String(o)} advisories · top: ${l.severity} ${l.id}`,title:s.packageName})}if(s.socketReport&&s.socketReport.alerts.length>0){const l=Math.round(s.socketReport.score.overall*100);t.push({entry:s,id:`socket:${s.packageName}`,kind:"socket",packageName:s.packageName,section:"security",severity:"warn",subtitle:`${String(s.socketReport.alerts.length)} alert${s.socketReport.alerts.length===1?"":"s"} · score ${String(l)}%`,title:s.packageName})}}if(e.sections.has("optimization"))for(const s of e.optimizations)t.push({entry:s,id:`opt:${s.packageName}`,kind:"optimization",section:"optimization",severity:"warn",subtitle:`${s.category} → ${s.replacement}`,title:s.packageName});if(e.sections.has("runtime"))for(const s of e.runtime)s.status==="warn"&&t.push({diagnostic:s,id:`runtime:${s.id}`,kind:"runtime",section:"runtime",severity:"warn",title:s.message});return t.sort((s,l)=>{if(s.section!==l.section){const n=["dependencies","security","optimization","runtime"];return n.indexOf(s.section)-n.indexOf(l.section)}return He[s.severity]-He[l.severity]}),t},at={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"},$s={error:"red",warn:"yellow"},Cs={error:"✖",warn:"⚠"},Rs={error:" ERROR ",warn:" WARN "},Ts=({children:e,hint:t,message:s,severity:l,title:n})=>{const o=$s[l];return i.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[i.jsxs(u,{gap:1,children:[i.jsx(r,{backgroundColor:o,bold:!0,color:"black",children:Rs[l]}),i.jsx(r,{bold:!0,color:o,children:Cs[l]}),i.jsx(r,{bold:!0,wrap:"truncate-end",children:n})]}),i.jsx(r,{wrap:"truncate-end",children:s}),t?i.jsx(r,{dimColor:!0,wrap:"truncate-end",children:t}):null,e]})},Es={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},As={critical:"red",high:"red",low:"gray",medium:"yellow"},Is={major:"red",minor:"yellow",patch:"green"},C=({children:e,label:t,width:s=14})=>i.jsxs(u,{children:[i.jsx(u,{width:s,children:i.jsxs(r,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?i.jsx(r,{children:e}):e]}),re=({children:e})=>i.jsx(u,{marginTop:1,children:i.jsx(r,{bold:!0,color:"white",children:e})}),Os=({finding:e})=>{const{entry:t}=e,s=Is[t.updateType]??"white";return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Current",children:t.currentRange}),i.jsxs(C,{label:"Target",children:[i.jsx(r,{children:t.newRange}),i.jsxs(r,{bold:!0,color:s,children:[" (",t.updateType,")"]})]}),i.jsx(C,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?i.jsx(C,{label:"Risk ack",children:i.jsx(r,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,i.jsx(re,{children:"Action"}),i.jsxs(r,{dimColor:!0,children:["Run"," ",i.jsx(r,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},Ds=({finding:e})=>i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Versions",children:i.jsx(r,{children:String(e.pkg.versions.length)})}),i.jsx(re,{children:"Installed versions"}),e.pkg.versions.map(t=>i.jsxs(r,{children:[" · ",t]},t)),i.jsx(re,{children:"Action"}),i.jsxs(r,{dimColor:!0,children:["Run"," ",i.jsx(r,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),Ps=({finding:e})=>{const t=e.entry.vulnerabilities??[];return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Package",children:e.packageName}),i.jsx(C,{label:"Current",children:e.entry.currentRange}),i.jsx(C,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?i.jsx(C,{label:"Risk ack",children:i.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(s=>{const l=Es[s.severity]??"gray";return i.jsxs(u,{flexDirection:"column",marginTop:1,children:[i.jsxs(u,{children:[i.jsx(r,{bold:!0,color:l,children:s.severity}),i.jsx(r,{children:" "}),i.jsx(r,{children:s.id}),typeof s.cvssScore=="number"?i.jsxs(r,{dimColor:!0,children:[" · CVSS ",s.cvssScore.toFixed(1)]}):null]}),i.jsx(r,{wrap:"wrap",children:s.summary}),s.fixedVersions.length>0?i.jsxs(r,{dimColor:!0,children:["Fixed in: ",s.fixedVersions.join(", ")]}):null,s.aliases&&s.aliases.length>0?i.jsxs(r,{dimColor:!0,children:["Aliases: ",s.aliases.join(", ")]}):null]},s.id)})]})},Ns=({finding:e})=>{const t=e.entry.socketReport;if(!t)return i.jsx(r,{dimColor:!0,children:"No Socket report attached."});const s=Math.round(t.score.overall*100),l=Le(t.score.overall);return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Package",children:e.packageName}),i.jsx(C,{label:"Overall",children:i.jsxs(r,{color:l,children:[String(s),"%"]})}),i.jsx(C,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?i.jsx(C,{label:"Risk ack",children:i.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,i.jsx(re,{children:"Score breakdown"}),Object.entries(t.score).map(([n,o])=>{if(n==="overall")return null;const a=typeof o=="number"?o:0,h=Math.round(a*100),c=Le(a);return i.jsxs(u,{children:[i.jsx(u,{width:14,children:i.jsxs(r,{dimColor:!0,children:[n,":"]})}),i.jsxs(r,{color:c,children:[String(h),"%"]})]},n)}),i.jsx(re,{children:"Alerts"}),t.alerts.map((n,o)=>{const a=As[n.severity]??"gray";return i.jsxs(u,{flexDirection:"column",marginBottom:1,children:[i.jsxs(u,{children:[i.jsx(r,{bold:!0,color:a,children:n.severity}),i.jsx(r,{children:" "}),i.jsx(r,{children:n.type})]}),n.props?i.jsx(r,{dimColor:!0,wrap:"wrap",children:JSON.stringify(n.props)}):null]},`${n.type}-${String(o)}`)})]})},Ms=({finding:e})=>{const{entry:t}=e;return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Package",children:t.packageName}),i.jsx(C,{label:"Category",children:t.category}),i.jsx(C,{label:"Replacement",children:t.replacement}),t.overrideSpec?i.jsx(C,{label:"Override",children:t.overrideSpec}):null,i.jsx(C,{label:"Codemod",children:i.jsx(r,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?i.jsx(C,{label:"Guide",children:i.jsx(r,{color:"cyan",underline:!0,children:t.docUrl})}):null,i.jsx(re,{children:"Action"}),t.hasCodemod?i.jsxs(r,{dimColor:!0,children:["Run"," ",i.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?i.jsxs(r,{dimColor:!0,children:["Run"," ",i.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to install the package override."]}):t.docUrl?i.jsx(r,{dimColor:!0,children:"No automated codemod. Open the migration guide above for the recommended alternative and steps."}):i.jsx(r,{dimColor:!0,children:"No automated codemod. Consult the package's docs or the e18e module-replacements guide for an alternative."})]})},Fs=({finding:e})=>{const{diagnostic:t}=e,s=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return i.jsxs(u,{flexDirection:"column",children:[i.jsx(C,{label:"Check",children:t.id}),i.jsx(C,{label:"Status",children:i.jsx(r,{color:s,children:t.status})}),i.jsx(re,{children:"Message"}),i.jsx(r,{wrap:"wrap",children:t.message}),t.detail&&Object.keys(t.detail).length>0?i.jsxs(i.Fragment,{children:[i.jsx(re,{children:"Details"}),Object.entries(t.detail).map(([l,n])=>i.jsxs(u,{children:[i.jsx(u,{width:20,children:i.jsxs(r,{dimColor:!0,children:[l,":"]})}),i.jsx(r,{children:String(n)})]},l))]}):null]})},zs=({finding:e,focused:t,scrollRef:s})=>{const l=t?"white":"gray";if(!e)return i.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:i.jsx(r,{dimColor:!0,children:"No finding selected"})});let n;switch(e.kind){case"duplicate":{n=i.jsx(Ds,{finding:e});break}case"optimization":{n=i.jsx(Ms,{finding:e});break}case"outdated":{n=i.jsx(Os,{finding:e});break}case"runtime":{n=i.jsx(Fs,{finding:e});break}case"socket":{n=i.jsx(Ns,{finding:e});break}case"vulnerability":{n=i.jsx(Ps,{finding:e});break}default:{n=i.jsx(r,{dimColor:!0,children:"Unknown finding kind."});break}}return i.jsxs(u,{borderColor:l,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[i.jsxs(u,{flexShrink:0,paddingTop:1,paddingX:2,children:[i.jsx(r,{bold:!0,color:"white",children:e.title}),i.jsxs(r,{dimColor:!0,children:[" ",at[e.section]]})]}),i.jsxs(bt,{flexGrow:1,flexShrink:1,paddingX:2,ref:s,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[i.jsx(r,{}),n]})]})},dt={error:"red",warn:"yellow"},Ls={error:"✖",warn:"⚠"},Bs=e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,_s=({finding:e,isSelected:t})=>{const s=dt[e.severity],l=Bs(e);return i.jsxs(u,{flexShrink:0,height:1,children:[i.jsx(r,{children:t?">":" "}),i.jsxs(r,{color:s,children:[" ",Ls[e.severity]," "]}),i.jsx(u,{flexGrow:1,children:i.jsx(r,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),l?i.jsx(r,{color:"cyan",children:" ack"}):null,e.subtitle?i.jsxs(r,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},Vs=({count:e,section:t})=>i.jsxs(u,{flexShrink:0,height:1,marginTop:1,children:[i.jsx(r,{dimColor:!0,children:"▼ "}),i.jsx(r,{bold:!0,color:"white",children:at[t].toUpperCase()}),i.jsxs(r,{dimColor:!0,children:[" (",e,")"]})]}),Hs=({count:e,label:t,status:s})=>{const l=s==="running";return i.jsxs(r,{children:[t,l?i.jsxs(r,{children:[" ",i.jsx(rt,{type:"dots"})]}):null,s==="error"?i.jsx(r,{bold:!0,color:"red",children:" ✖"}):i.jsxs(r,{dimColor:!0,children:[" (",String(e),")"]})]})},Ys=({elapsedMs:e,entries:t,filterActive:s,filterText:l,filterType:n,focused:o,fromCache:a=!1,grouped:h,onViewportHeightChange:c,scrollOffset:p,sectionCounts:x,sectionMessage:v,sectionStatus:y,selectedIndex:N,severityFilter:S,totalAll:m,viewportHeight:E})=>{const D=o?"white":"gray",{measuredHeight:M,ref:P}=ts(E,c);let R=0,F=0;for(const b of t)b.severity==="error"?R+=1:b.severity==="warn"&&(F+=1);const U=[];R>0&&U.push(`${String(R)} error${R===1?"":"s"}`),F>0&&U.push(`${String(F)} warn${F===1?"":"s"}`);const ee=U.length>0?` (${U.join(", ")})`:"",te=(e/1e3).toFixed(1),G=[];for(const[b,$]of h){G.push(i.jsx(Vs,{count:$.length,section:b},`hdr-${b}`));for(const V of $){const T=t.indexOf(V);G.push(i.jsx(_s,{finding:V,isSelected:T===N},V.id))}}let q=0;for(const[,b]of h)q+=2+b.length;const _=q>M&&M>0;return i.jsxs(u,{borderColor:D,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[i.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[i.jsx(r,{bold:!0,inverse:!0,children:" DOCTOR "}),i.jsxs(r,{wrap:"truncate",children:[t.length,t.length===m?"":`/${String(m)}`," finding",t.length===1?"":"s",ee]}),S?i.jsx(r,{bold:!0,color:dt[S],inverse:!0,children:` ${S.toUpperCase()} ONLY `}):null,a?i.jsx(r,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,i.jsxs(r,{dimColor:!0,children:[" · ",te,"s"]})]}),i.jsx(u,{flexShrink:0,paddingX:1,paddingY:1,children:i.jsx(Zt,{isFocused:o,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:()=>{},showIndex:!1,value:n,children:me.map(({id:b,label:$})=>i.jsx(es,{name:b,children:i.jsx(Hs,{count:x[b],label:$,status:y[b]})},b))})}),(()=>{const b=Object.keys(y).filter($=>y[$]==="running"&&v[$]).map($=>v[$]);return b.length===0?null:i.jsx(u,{flexShrink:0,paddingX:1,children:i.jsxs(r,{dimColor:!0,wrap:"truncate",children:[i.jsx(rt,{type:"dots"})," ",b.join(" · ")]})})})(),s&&i.jsxs(u,{flexShrink:0,paddingX:1,children:[i.jsx(r,{bold:!0,color:"white",children:"/ "}),i.jsx(r,{children:l}),i.jsx(r,{inverse:!0,children:" "})]}),i.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:P,children:[i.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:i.jsx(u,{flexDirection:"column",marginTop:-p,children:G.length>0?G:i.jsx(u,{marginTop:1,children:i.jsx(r,{dimColor:!0,children:"No findings match the current filter."})})})}),_&&i.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:i.jsx(jt,{contentHeight:q,placement:"inset",scrollOffset:p,style:"block",viewportHeight:M})})]},`list-${n}-${l}`)]})},Us=e=>{if(e.kind==="outdated")return{command:`vis update ${e.entry.packageName}`,description:`Update ${e.entry.packageName} to ${e.entry.newRange}`};if(e.kind==="duplicate")return{command:`vis dedupe ${e.pkg.name}`,description:`Dedupe ${e.pkg.name} (${String(e.pkg.versions.length)} versions)`}},Gs=e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},Ws=e=>{if(e.kind!=="outdated"&&e.kind!=="vulnerability"&&e.kind!=="socket")return;const t=e.kind==="outdated"?e.entry.packageName:e.packageName,s=["// Add to vis.config.ts:","security: {"," acceptedRisks: {",` "${t}": {`,' reason: "explain why this risk is acceptable",',' expiresAt: "YYYY-MM-DD",'," },"," },","},"].join(`
3
+ `);return{command:s,configSnippet:s,description:`Acknowledge risk for ${t}`}},Ks=100,qs=40,Xs=10,Js=({autoExitSeconds:e=0,banner:t,fromCache:s=!1,startedAt:l,store:n})=>{const{exit:o}=vt(),{columns:a,rows:h}=St(),c=z.useSyncExternalStore(n.subscribe,n.getSnapshot),[p,x]=z.useState(!1),[v,y]=z.useState(!1),[N,S]=z.useState(0),[m,E]=z.useState(()=>Date.now());z.useEffect(()=>{const w=setInterval(()=>{E(Date.now())},1e3);return()=>{clearInterval(w)}},[]);const D=m-l,M=z.useRef(null),P=z.useRef(null),R=c.entries[c.selectedIndex]??null,F=z.useMemo(()=>{const w={dependencies:0,optimization:0,runtime:0,security:0};for(const g of c.all)w[g.section]+=1;return w},[c.all]),U=t?t.hint?5:4:0,ee=z.useMemo(()=>{for(const w of Object.keys(c.sectionStatus))if(c.sectionStatus[w]==="running"&&c.sectionMessage[w])return 1;return 0},[c.sectionStatus,c.sectionMessage]),te=a>=Ks,G=te?Math.max(1,h-U-2):Math.floor(h*.55),q=Math.max(1,G-6-ee-(c.filterActive?1:0)),[_,b]=z.useState(q),$=_>0?_:q,V=z.useMemo(()=>{let w=0;for(const[,g]of c.grouped)w+=2+g.length;return w},[c.grouped]),T=Math.max(0,V-$),ne=Math.min(N,T),B=z.useCallback(w=>{let g=0,k=0;for(const[,xe]of c.grouped){g+=2;for(let he=0;he<xe.length;he++){if(k===w)return g;g+=1,k+=1}}return g},[c.grouped]),X=z.useCallback(w=>{const g=B(w);S(k=>g>k+$-2?Math.min(T,Math.max(0,g-$+2)):g<k+1?Math.max(0,g-1):k)},[B,$,T]);if(z.useEffect(()=>{P.current?.scrollToTop()},[R?.id]),$t((w,g)=>{if(w==="c"&&g.ctrl){o();return}if(!v){if(p){g.escape||w==="?"?x(!1):w==="q"?(x(!1),y(!0)):g.downArrow||w==="j"?M.current?.scrollBy(1):(g.upArrow||w==="k")&&M.current?.scrollBy(-1);return}if(w==="?"){x(!0);return}if(w==="q"){y(!0);return}if(g.tab){n.setFocusedPanel(c.focusedPanel==="list"?"detail":"list");return}if(c.filterActive){if(g.escape||g.return){n.setFilterActive(!1);return}if(g.backspace){S(0),n.setFilter(c.filterText.slice(0,-1));return}w&&!g.ctrl&&!g.meta&&(S(0),n.setFilter(c.filterText+w));return}if(c.focusedPanel==="list"&&(g.leftArrow||g.rightArrow)){const k=me.findIndex(he=>he.id===c.filterType),xe=g.rightArrow?(k+1)%me.length:(k-1+me.length)%me.length;S(0),P.current?.scrollToTop(),n.setFilterType(me[xe].id);return}if(c.focusedPanel==="list"){if(g.downArrow||w==="j"){const k=Math.min(c.selectedIndex+1,c.entries.length-1);n.setSelectedIndex(k),X(k);return}if(g.upArrow||w==="k"){const k=Math.max(c.selectedIndex-1,0);n.setSelectedIndex(k),X(k);return}if(g.pageDown){const k=Math.min(c.selectedIndex+10,c.entries.length-1);n.setSelectedIndex(k),X(k);return}if(g.pageUp){const k=Math.max(c.selectedIndex-10,0);n.setSelectedIndex(k),X(k);return}if(g.home){n.setSelectedIndex(0),S(0);return}if(g.end){const k=c.entries.length-1;n.setSelectedIndex(k),X(k);return}if(w==="/"){n.setFilterActive(!0);return}if(w==="e"){n.setSeverityFilter(c.severityFilter==="error"?void 0:"error"),S(0);return}if(w==="w"){n.setSeverityFilter(c.severityFilter==="warn"?void 0:"warn"),S(0);return}if(w==="u"&&R){const k=Us(R);k&&(n.setPendingAction(k),o());return}if(w==="o"&&R){const k=Gs(R);k&&(n.setPendingAction(k),o());return}if(w==="a"&&R){const k=Ws(R);k&&(n.setPendingAction(k),o());return}if(w==="d"){n.setFocusedPanel("detail");return}return}if(g.escape||g.leftArrow){n.setFocusedPanel("list");return}if(g.downArrow||w==="j"){P.current?.scrollBy(1);return}if(g.upArrow||w==="k"){P.current?.scrollBy(-1);return}if(g.pageDown){P.current?.scrollBy(10);return}if(g.pageUp){P.current?.scrollBy(-10);return}if(g.home){P.current?.scrollToTop();return}g.end&&P.current?.scrollToBottom()}},{isActive:!0}),a<qs||h<Xs)return i.jsx(u,{alignItems:"center",height:h,justifyContent:"center",width:a,children:i.jsxs(r,{color:"yellow",children:["Terminal too small (",a,"x",h,")"]})});const ce=c.focusedPanel==="detail",L=[i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"q"}),i.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"?"}),i.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"↑↓"}),i.jsx(r,{dimColor:!0,children:ce?"SCROLL":"NAV"})]},"nav"),ce?i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"←/Esc"}),i.jsx(r,{dimColor:!0,children:"LIST"})]},"lr"):i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"←→"}),i.jsx(r,{dimColor:!0,children:"SECTION"})]},"lr"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"/"}),i.jsx(r,{dimColor:!0,children:"SEARCH"})]},"search"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"e/w"}),i.jsx(r,{dimColor:!0,children:"SEVERITY"})]},"sev"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"u/o/a"}),i.jsx(r,{dimColor:!0,children:"ACTION"})]},"actions"),i.jsxs(u,{gap:1,children:[i.jsx(r,{bold:!0,color:"white",children:"Tab"}),i.jsx(r,{dimColor:!0,children:"PANEL"})]},"tab")],H=i.jsx(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:i.jsx(u,{gap:2,overflow:"hidden",paddingX:1,children:L})}),W=i.jsxs(Ct,{footer:i.jsxs(r,{dimColor:!0,children:[i.jsx(r,{bold:!0,color:"white",children:"↑↓"})," scroll ",i.jsx(r,{bold:!0,color:"white",children:"?"}),"/",i.jsx(r,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:M,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:p,width:56,children:[i.jsxs(u,{flexDirection:"column",marginBottom:1,children:[i.jsxs(u,{marginBottom:1,children:[i.jsx(r,{dimColor:!0,children:"── "}),i.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),i.jsxs(u,{children:[i.jsx(u,{width:26,children:i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" ↑/k "}),i.jsx(r,{dimColor:!0,children:"Move up"})]})}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" ↓/j "}),i.jsx(r,{dimColor:!0,children:"Move down"})]})]}),i.jsxs(u,{children:[i.jsx(u,{width:26,children:i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" PgUp"}),i.jsx(r,{dimColor:!0,children:" Jump up 10"})]})}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" PgDn"}),i.jsx(r,{dimColor:!0,children:" Jump down 10"})]})]}),i.jsxs(u,{children:[i.jsx(u,{width:26,children:i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" Home"}),i.jsx(r,{dimColor:!0,children:" Jump to top"})]})}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" End"}),i.jsx(r,{dimColor:!0,children:" Jump to bottom"})]})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" Tab"}),i.jsx(r,{dimColor:!0,children:" Switch panel"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" →/←"}),i.jsx(r,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),i.jsxs(u,{flexDirection:"column",marginBottom:1,children:[i.jsxs(u,{marginBottom:1,children:[i.jsx(r,{dimColor:!0,children:"── "}),i.jsx(r,{bold:!0,color:"white",children:"FILTER"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" /"}),i.jsx(r,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" e"}),i.jsx(r,{dimColor:!0,children:" Toggle errors-only filter"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" w"}),i.jsx(r,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),i.jsxs(u,{flexDirection:"column",marginBottom:1,children:[i.jsxs(u,{marginBottom:1,children:[i.jsx(r,{dimColor:!0,children:"── "}),i.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" u"}),i.jsx(r,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" o"}),i.jsx(r,{dimColor:!0,children:" Exit + suggest optimize command"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" a"}),i.jsx(r,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" d"}),i.jsx(r,{dimColor:!0,children:" Focus detail panel"})]})]}),i.jsxs(u,{flexDirection:"column",children:[i.jsxs(u,{marginBottom:1,children:[i.jsx(r,{dimColor:!0,children:"── "}),i.jsx(r,{bold:!0,color:"white",children:"EXIT"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" q"}),i.jsx(r,{dimColor:!0,children:" Quit (with countdown)"})]}),i.jsxs(r,{children:[i.jsx(r,{bold:!0,color:"white",children:" Ctrl+C"}),i.jsx(r,{dimColor:!0,children:" Quit immediately"})]})]})]}),ae=i.jsx(Ys,{elapsedMs:D,entries:c.entries,filterActive:c.filterActive,filterText:c.filterText,filterType:c.filterType,focused:c.focusedPanel==="list",fromCache:s,grouped:c.grouped,onViewportHeightChange:b,scrollOffset:ne,sectionCounts:F,sectionMessage:c.sectionMessage,sectionStatus:c.sectionStatus,selectedIndex:c.selectedIndex,severityFilter:c.severityFilter,totalAll:c.all.length,viewportHeight:$}),de=t?i.jsx(Ts,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,ue=i.jsx(zs,{finding:R,focused:c.focusedPanel==="detail",scrollRef:P});if(te){const w=Math.floor(a*.4);return i.jsxs(u,{flexDirection:"column",height:h,width:a,children:[de,i.jsxs(u,{flexDirection:"row",flexGrow:1,children:[i.jsx(u,{flexGrow:1,children:ae}),i.jsx(u,{width:w,children:ue})]}),H,i.jsx(Fe,{autoExitSeconds:e||3,onCancel:()=>{y(!1)},visible:v}),W]})}return i.jsxs(u,{flexDirection:"column",height:h,width:a,children:[de,i.jsx(u,{height:G,children:ae}),i.jsx(u,{flexGrow:1,children:ue}),H,i.jsx(Fe,{autoExitSeconds:e||3,onCancel:()=>{y(!1)},visible:v}),W]})},Qs=e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),Zs=e=>{const t=e.split("*").map(s=>Qs(s));return new RegExp(`^${t.join(".*")}$`,"i")},ei=e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>Zs(t)):[],$e=(e,t)=>{for(const s of t)if(s.test(e))return!0;return!1},ti=(e,t,s)=>{if(t.length===0)return e;const l=e.outdated.filter(p=>$e(p.packageName,t)),n=e.duplicates.filter(p=>$e(p.name,t)),o=e.optimizations.filter(p=>$e(p.packageName,t));let a=0,h=0,c=0;for(const p of l)p.vulnerabilities&&(a+=p.vulnerabilities.length),p.socketReport&&(h+=p.socketReport.alerts.length,p.socketReport.score.overall<s&&(c+=1));return{...e,duplicates:n,optimizations:o,outdated:l,socketIssues:{alerts:h,lowScore:c},vulnCount:a}},ut=(e,t)=>t.length===0?[...e]:e.filter(s=>{if(s.kind==="runtime")return!0;const l=s.kind==="duplicate"?s.pkg.name:s.kind==="outdated"||s.kind==="optimization"?s.entry.packageName:s.packageName;return $e(l,t)}),ht=["dependencies","security","optimization","runtime"],Ye=e=>{const t=new Set;if(!e)return t;for(const s of e.split(",")){const l=s.trim().toLowerCase();ht.includes(l)&&t.add(l)}return t},si=(e,t)=>{if(e!==void 0&&e!=="")return Ye(e);const s=Ye(t);return new Set(ht.filter(l=>!s.has(l)))},pt=e=>{const t={micro:0,native:0,preferred:0,socket:0,total:e.length};for(const s of e)switch(s.category){case"micro-utility":{t.micro+=1;break}case"native":{t.native+=1;break}case"preferred":{t.preferred+=1;break}case"socket":{t.socket+=1;break}}return t},ie=(e,t)=>{if(!e.sections.has(t))return"skip";switch(t){case"dependencies":return e.outdated.length>0||e.duplicates.length>0?"warn":"ok";case"optimization":return e.optimizations.length>0?"warn":"ok";case"runtime":return e.runtime.some(s=>s.status==="warn")?"warn":"ok";case"security":return e.vulnCount>0||e.socketIssues.alerts>0?"error":e.socketIssues.lowScore>0?"warn":"ok";default:return"ok"}},ii=(e,t)=>{const s=pt(e.optimizations),l={dependencies:ie(e,"dependencies"),optimization:ie(e,"optimization"),runtime:ie(e,"runtime"),security:ie(e,"security")},n=new Set([...Object.values(l),e.supplyChain.status]),o=n.has("error")?"error":n.has("warn")?"warn":"ok";return{dependencies:{duplicates:e.duplicates.length,installed:e.installedCount,outdated:e.outdated.length,status:l.dependencies},elapsedMs:e.elapsedMs,optimizations:{microUtilities:s.micro,native:s.native,preferred:s.preferred,socket:s.socket,status:l.optimization,total:s.total},packageManager:t,runtime:e.runtime.map(a=>({detail:a.detail,id:a.id,message:a.message,status:a.status})),runtimeStatus:l.runtime,security:{alerts:e.socketIssues.alerts,lowScorePackages:e.socketIssues.lowScore,status:l.security,vulnerabilities:e.vulnCount},status:o,supplyChain:{findings:e.supplyChain.findings.map(a=>({detail:a.detail,label:a.label,severity:a.severity})),status:e.supplyChain.status},workspaces:e.workspaceCount}},Ue=(e,t)=>{const s=e.runtime.some(n=>n.status==="warn"),l=e.vulnCount>0||e.socketIssues.alerts>0;return t?l||e.outdated.length>0||e.duplicates.length>0||s:l},ri=["aube-workspace.yaml","pnpm-workspace.yaml"],ke=e=>typeof e=="boolean"?e:void 0,ni=e=>{if(e==="no-downgrade"||e==="off")return e},oi=e=>{const t={allowBuildsCount:0,blockExoticSubdeps:void 0,jailBuilds:void 0,minimumReleaseAge:void 0,minimumReleaseAgeStrict:void 0,paranoid:void 0,source:void 0,strictDepBuilds:void 0,trustPolicy:void 0};for(const s of ri){const l=K(e,s);if(!je(l))continue;let n;try{n=ss(Tt(l))}catch{continue}if(typeof n!="object"||n===null)continue;const o=n;return t.source=s,t.paranoid=ke(o.paranoid),t.trustPolicy=ni(o.trustPolicy),t.blockExoticSubdeps=ke(o.blockExoticSubdeps),t.jailBuilds=ke(o.jailBuilds),t.strictDepBuilds=ke(o.strictDepBuilds),t.minimumReleaseAgeStrict=ke(o.minimumReleaseAgeStrict),typeof o.minimumReleaseAge=="number"&&Number.isFinite(o.minimumReleaseAge)&&(t.minimumReleaseAge=o.minimumReleaseAge),o.allowBuilds&&typeof o.allowBuilds=="object"&&!Array.isArray(o.allowBuilds)&&(t.allowBuildsCount=Object.keys(o.allowBuilds).length),t}return t},li=e=>e.paranoid?{...e,jailBuilds:!0,minimumReleaseAgeStrict:!0,strictDepBuilds:!0,trustPolicy:"no-downgrade"}:e,ci=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,ai=e=>{const t=ci.exec(e);if(t)return{name:t[1],version:t[2]}},di=(e,t)=>{let s;try{if(t==="pnpm"){const n=K(e,"pnpm-workspace.yaml");je(n)&&(s=is(n)?.patchedDependencies)}else if(t==="bun"){const n=K(e,"package.json");je(n)&&(s=tt(n)?.patchedDependencies)}}catch{return[]}if(!s||typeof s!="object")return[];const l=[];for(const[n,o]of Object.entries(s)){if(typeof o!="string"||o.length===0)continue;const a=ai(n);a&&l.push({name:a.name,patchFile:o,resolvedPatchFile:Et(o)?o:Xe(e,o),version:a.version})}return l},ui=e=>{const t=[];for(const s of e)je(s.resolvedPatchFile)||t.push({entry:s,kind:"missing-file"});return t},Ge=e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok",hi=(e,t={})=>{const s=[],l=e?.security;if(!l)return s.push({detail:"Use defineConfig() from '@visulima/vis/config' to apply secure defaults.",label:"No security config — running with the PM's native defaults",severity:"warn"}),{findings:s,status:Ge(s)};const n=l.policies?.firstSeen?.minutes,o=l.policies?.publisherChange,a=l.policies?.installScripts;n===void 0?s.push({detail:"Set security.policies.firstSeen.minutes to block packages published in the last N minutes (mitigates supply-chain attacks).",label:"policies.firstSeen.minutes is not set",severity:"warn"}):n===0?s.push({detail:"New packages can be installed immediately after publishing. Consider setting a non-zero cooldown.",label:"policies.firstSeen.minutes is explicitly 0",severity:"warn"}):s.push({label:`policies.firstSeen.minutes: ${String(n)} minutes`,severity:"ok"}),o?.mode===void 0||o.mode==="off"?s.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`policies.publisherChange.mode: ${o?.mode??"not set"}`,severity:"warn"}):s.push({label:`policies.publisherChange.mode: ${o.mode}`,severity:"ok"}),l.blockExoticSubdeps===void 0||!l.blockExoticSubdeps?s.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(l.blockExoticSubdeps??!1)}`,severity:"warn"}):s.push({label:"blockExoticSubdeps: true",severity:"ok"});const h=a?.allow?Object.keys(a.allow).length:0;if(h===0?s.push({detail:"Lifecycle scripts are blocked by default. List trusted packages here to opt them back in (e.g. esbuild, @prisma/client).",label:"policies.installScripts.allow: not configured",severity:"warn"}):s.push({label:`policies.installScripts.allow: ${String(h)} ${h===1?"entry":"entries"}`,severity:"ok"}),a?.strict&&h===0&&s.push({detail:"All dependencies with build scripts will be blocked. Run 'vis approve-builds' to populate the allow list.",label:"policies.installScripts.strict is on but allow is empty",severity:"error"}),t.workspaceRoot){const c=rs(t.workspaceRoot);if(c.length>0){const p=[...new Set(c.map(x=>x.tool))].sort((x,v)=>x.localeCompare(v)).join(", ");s.push({detail:"Run `vis migrate verify` for the full list, then re-run `vis migrate <tool>` to clean up.",label:`${String(c.length)} leftover ${c.length===1?"reference":"references"} to ${p}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager==="aube"){const c=oi(t.workspaceRoot),p=li(c),x=p.source?` (from ${p.source})`:"";p.paranoid===!0&&s.push({detail:"Forces jailBuilds, trustPolicy=no-downgrade, minimumReleaseAgeStrict, strictStoreIntegrity, and strictDepBuilds on.",label:`aube paranoid: true${x}`,severity:"ok"}),p.trustPolicy==="off"&&s.push({detail:"Trust downgrades between releases will not be blocked. Set trustPolicy: no-downgrade in aube-workspace.yaml.",label:`aube trustPolicy: off${x}`,severity:"warn"}),p.blockExoticSubdeps===!1&&s.push({detail:"Transitive deps from git+, file:, and tarball URLs will not be blocked. Re-enable with blockExoticSubdeps: true.",label:`aube blockExoticSubdeps: false${x}`,severity:"warn"}),p.minimumReleaseAge===0&&s.push({detail:"Newly published versions are not held in a cooling window. Restore with minimumReleaseAge: 1440 (24h) or higher.",label:`aube minimumReleaseAge: 0${x}`,severity:"warn"}),p.jailBuilds===!0&&s.push({label:`aube jailBuilds: true${x}`,severity:"ok"}),p.strictDepBuilds===!0&&s.push({label:`aube strictDepBuilds: true${x}`,severity:"ok"}),p.allowBuildsCount>0&&s.push({label:`aube allowBuilds: ${String(p.allowBuildsCount)} ${p.allowBuildsCount===1?"entry":"entries"}${x}`,severity:"ok"})}if(t.workspaceRoot&&t.packageManager){const c=di(t.workspaceRoot,t.packageManager);if(c.length>0){const p=ui(c);if(p.length===0)s.push({label:`patchedDependencies: ${String(c.length)} ${c.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const x of p)s.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${x.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${x.entry.name}@${x.entry.version}`,severity:"error"})}}return{findings:s,status:Ge(s)}},Y=e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,ve=async(e,t,s,l)=>{if(!e)return s();e.start(t);const n=Date.now();try{const o=await s(),a=Date.now()-n,{status:h,summary:c}=l(o,a);return e.finish(t,h,c),o}catch(o){const a=Date.now()-n,h=o instanceof Error?o.message:String(o);throw e.finish(t,"error",`${h} (${Y(a)})`),o}},pi=(e,t)=>{const s={duplicates:t.duplicates,optimizations:t.optimizations,outdated:t.outdated,runtime:t.runtime,sections:new Set([e])};return ct(s)},We=async e=>{const{filterPatterns:t,installed:s,progress:l,resolveCodemods:n,sections:o,store:a,visConfig:h,workspaceRoot:c}=e,p=o.has("dependencies"),x=o.has("security"),v=o.has("optimization"),y=o.has("runtime"),N=(f,A)=>ut(pi(f,A),t),S=it(c),{packageManager:m}=qe(c),E=Be(K(c,"package.json"),!1),D=st(c),M=new Set(E);for(const f of D){const A=Be(K(Xe(c,f),"package.json"),!1);for(const I of A)M.add(I)}const P=Ot(c),R=Je(c,m),F=Qe(h?.security,{minimumScore:h?.security?.policies?.score?.minimum}),U=h?.security?.policies?.score?.minimum??et,ee=h?.security?.acceptedRisks,te=_t(c,S.name),G={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},q=p?Qt(c,S.name):[],_=v?Vt(M):[],b=v?Ht(M,te,S,!1):[],$=new Set(_.map(f=>f.packageName)),V=b.filter(f=>!$.has(f.packageName)),T=[..._,...V],ne=y?js(c):[];a&&(p&&a.startSection("dependencies",R.size>0?"checking outdated catalog dependencies":"scanning duplicates"),x&&a.startSection("security",s.length>0?`scanning ${String(s.length)} packages for advisories`:"no installed packages to scan"),v&&a.startSection("optimization","matching e18e + socket overrides"),y&&a.startSection("runtime","running runtime diagnostics")),a&&y&&a.completeSection("runtime",N("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:ne}));const X=(p||x)&&R.size>0?ve(l,"outdated",()=>Dt(R,G,P,void 0,c,F,ee),(f,A)=>{const I=f.outdated.length;return{status:I>0?"warn":"ok",summary:I>0?`${String(I)} outdated · ${Y(A)}`:`up to date · ${Y(A)}`}}):Promise.resolve({checkedCount:0,failed:[],filteredByTarget:[],ignored:[],outdated:[]}),ce=x&&s.length>0?ve(l,"vulnerabilities",()=>Pt(s.map(f=>({name:f.name,version:f.version}))),(f,A)=>{let I=0;for(const se of f.values())I+=se.length;return{status:I>0?"error":"ok",summary:I>0?`${String(I)} found · ${Y(A)}`:`none found · ${Y(A)}`}}):Promise.resolve(new Map),L=x&&F.length>0&&s.length>0?ve(l,"socket",()=>Nt(F,s.map(f=>({name:f.name,version:f.version}))),(f,A)=>{let I=0,se=0;for(const Me of f.values())I+=Me.alerts.length,Me.score.overall<U&&(se+=1);const Ne=I+se;return{status:Ne>0?"warn":"ok",summary:Ne>0?`${String(I)} alert${I===1?"":"s"}, ${String(se)} low-score · ${Y(A)}`:`clean · ${Y(A)}`}}):Promise.resolve(new Map);let H,W,ae,de;const ue=X.catch(f=>(H=f instanceof Error?f.message:String(f),a||d.warn(`Outdated scan failed: ${H}`),{failed:[],ignored:[],outdated:[]})),w=ce.catch(f=>(W=f instanceof Error?f.message:String(f),a||d.warn(`Vulnerability scan failed: ${W}`),new Map)),g=L.catch(f=>(ae=f instanceof Error?f.message:String(f),a||d.warn(`Socket scan failed: ${ae}`),new Map)),k=a&&p?ue.then(f=>{if(H){a.failSection("dependencies",H);return}a.completeSection("dependencies",N("dependencies",{duplicates:q,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,xe=a&&x?Promise.all([ue,w,g]).then(([f])=>{const A=H??W??ae;if(A){a.failSection("security",A);return}a.completeSection("security",N("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,he=(async()=>{if(n&&v&&T.length>0&&await ve(l,"codemods",async()=>(await Gt(T),T),(f,A)=>{const I=f.filter(se=>se.hasCodemod||se.category==="socket").length;return{status:"ok",summary:`${String(I)} auto-fixable · ${Y(A)}`}}).catch(f=>{de=f instanceof Error?f.message:String(f)}),a&&v){if(de){a.failSection("optimization",de);return}a.completeSection("optimization",N("optimization",{duplicates:[],optimizations:T,outdated:[],runtime:[]}))}})(),[Oe,mt,gt]=await Promise.all([ue,w,g]);await Promise.all([k,xe,he]);let De=0,Pe=0;if(x&&F.length>0)for(const f of gt.values())De+=f.alerts.length,f.score.overall<U&&(Pe+=1);let Ee=0;if(x){for(const f of Oe.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Ee+=f.vulnerabilities.length);for(const f of mt.values())Ee+=f.length}return{duplicates:q,installedCount:s.length,optimizations:v?T:[],outdated:p?Oe.outdated:[],runtime:ne,sections:o,socketIssues:{alerts:De,lowScore:Pe},supplyChain:hi(h,{packageManager:m,workspaceRoot:c}),vulnCount:Ee,workspaceCount:D.length}},fi=e=>{switch(e){case"error":return be(O.failure);case"skip":return j(O.dash);case"warn":return Re(O.warning);default:return ge(O.success)}},le=(e,t)=>{const s=process.stderr.columns??80,l=Math.max(20,Math.min(s-2,60)),n=O.dash.repeat(2),o=`${fi(t)} ${oe(e)}`,a=o.replaceAll(/\[[0-9;]*m/g,"").length,h=Math.max(0,l-a-n.length-2);return`${n} ${o} ${j(O.dash.repeat(h))}`},Z=e=>` ${ge(O.success)} ${e}`,J=e=>` ${Re(O.warning)} ${e}`,Ie=e=>` ${be(O.failure)} ${e}`,ft=e=>` ${j(O.dash)} ${j(e)}`,Q=(e,t,s)=>{const l=`${oe(String(e))} ${j(t)}`;return s?`${l} ${j(`(${s})`)}`:l},mi=e=>{if(e.sections.has("dependencies")){if(d.log(""),d.log(le("Dependencies",ie(e,"dependencies"))),d.log(Z(Q(e.installedCount,"packages installed"))),e.outdated.length>0){const t=e.outdated.filter(o=>o.updateType==="major").length,s=e.outdated.filter(o=>o.updateType==="minor").length,l=e.outdated.filter(o=>o.updateType==="patch").length,n=[];t>0&&n.push(`${String(t)} major`),s>0&&n.push(`${String(s)} minor`),l>0&&n.push(`${String(l)} patch`),d.log(J(Q(e.outdated.length,"outdated",n.join(", "))))}else d.log(Z("All dependencies up to date"));e.duplicates.length>0?d.log(J(Q(e.duplicates.length,"packages with duplicate versions"))):d.log(Z("No duplicate dependencies"))}},gi=e=>{e.sections.has("security")&&(d.log(""),d.log(le("Security",ie(e,"security"))),e.vulnCount>0?d.log(Ie(Q(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):d.log(Z("No known vulnerabilities")),e.socketIssues.alerts>0&&d.log(J(Q(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&d.log(J(Q(e.socketIssues.lowScore,`package${e.socketIssues.lowScore===1?"":"s"} with low security score`))),e.socketIssues.alerts===0&&e.socketIssues.lowScore===0&&e.vulnCount===0&&d.log(Z("No security issues detected")))},xi=e=>{if(!e.sections.has("optimization"))return;d.log(""),d.log(le("Optimization",ie(e,"optimization")));const t=pt(e.optimizations);if(t.total===0){d.log(Z("No optimizations available"));return}t.native>0&&d.log(J(Q(t.native,"replaceable with native APIs"))),t.preferred>0&&d.log(J(Q(t.preferred,"with lighter alternatives"))),t.micro>0&&d.log(J(Q(t.micro,"trivial micro-utilities"))),t.socket>0&&d.log(J(Q(t.socket,"@socketregistry overrides available")))},wi=e=>{d.log(""),d.log(le("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const s=t.severity==="ok"?Z(t.label):t.severity==="error"?Ie(t.label):J(t.label);d.log(s),t.detail&&d.log(` ${j(O.arrow)} ${j(t.detail)}`)}e.supplyChain.status!=="ok"&&d.log(` ${j(O.arrow)} ${j("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},ki=e=>{if(e.sections.has("runtime")){d.log(""),d.log(le("Runtime",ie(e,"runtime")));for(const t of e.runtime)t.status==="ok"?d.log(Z(t.message)):t.status==="skip"?d.log(ft(t.message)):d.log(J(t.message))}},yi=(e,t)=>{const s=e.vulnCount,l=e.runtime.filter(o=>o.status==="warn").length,n=e.outdated.length+e.duplicates.length+e.optimizations.length+l;if(t){if(s===0&&n===0)d.success(`Everything looks good! ${j(`(${Y(e.elapsedMs)})`)}`);else{const o=[];s>0&&o.push(be(`${String(s)} security`)),n>0&&o.push(Re(`${String(n)} improvement${n===1?"":"s"}`)),d.log(`${be(O.failure)} ${o.join(", ")} ${j(`(${Y(e.elapsedMs)})`)}`)}return}d.log(""),d.log(le("Summary","ok")),s===0&&n===0?d.success(`Everything looks good! ${j(`(${Y(e.elapsedMs)})`)}`):(s>0&&d.error(`${String(s)} security issue${s===1?"":"s"}`),n>0&&d.log(` ${ye(O.arrow)} ${oe(String(n))} ${j(`improvement${n===1?"":"s"} available`)} ${j(`(${Y(e.elapsedMs)})`)}`))},bi=e=>{const t=[];if(e.outdated.length>0&&t.push("vis update — update outdated dependencies"),(e.vulnCount>0||e.socketIssues.alerts>0)&&t.push("vis audit — detailed security analysis"),e.optimizations.length>0&&t.push("vis optimize — apply optimizations interactively"),e.duplicates.length>0&&t.push("vis dedupe — reduce duplicate versions"),t.length>0){d.log(""),d.log(oe("Next steps:"));for(const s of t)d.log(` ${j(O.arrow)} ${s}`)}d.log("")},ji=(e,t)=>{t||(mi(e),gi(e),xi(e),ki(e),wi(e)),yi(e,t)},vi=(e,t,s,l,n)=>{const o=[],a=e.has("dependencies"),h=e.has("security"),c=e.has("optimization");return(a||h)&&t>0&&o.push({id:"outdated",label:"Outdated catalog dependencies"}),h&&l>0&&o.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),h&&s&&l>0&&o.push({id:"socket",label:"Socket.dev supply-chain reports"}),c&&n&&o.push({id:"codemods",label:"Codemod availability"}),o},Si=e=>{if(d.log(""),d.log(`${oe(ye("vis doctor"))} ${j("— project health check")}`),d.log(Z(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.runtimeFindings.length===0)d.log(Z(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const s=t.severity==="error"?be:Re;d.log(Ie(`Runtime: ${s(t.message)}`))}d.log(` ${j(O.arrow)} Run ${ge("vis toolchain install")} to install pinned versions, or ${ge("vis toolchain status")} for the per-tool breakdown.`)}d.log("")},Ki=async({fs:e,logger:t,options:s,visConfig:l,visConfigError:n,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root.");const a=s.format==="json"||s.json,h=si(s.only,s.skip),c=!!s.quiet,p=s.progress===!1,x=ei(s.filter);if(h.size===0){d.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const v=Date.now(),y=it(o),N=Kt(o),S=!!process.stdout.isTTY,m=!a&&S&&!At&&!c&&!p;!a&&!m&&Si({nodeVersion:process.versions.node,packageManagerName:y.name,packageManagerVersion:y.version,runtimeFindings:N});const E=Je(o,qe(o).packageManager),D=Xt(o,y.name),M=D.length,P=Qe(l?.security).length>0,R=l?.security?.policies?.score?.minimum??et,F=st(o);if(!a&&!c&&!m){const L=F.length>0?j(` · ${String(F.length)} workspace package${F.length===1?"":"s"}`):"";d.log(`${j("·")} ${j("Found")} ${oe(String(M))} ${j(`installed package${M===1?"":"s"}`)}${L}`)}const U=n?{hint:n.file?`Continuing with default settings — fix or regenerate ${n.file} (vis init --force).`:"Continuing with default settings.",message:n.message,severity:"error",title:n.file?`Failed to load ${n.file}`:"Failed to load vis.config"}:void 0,ee=Jt(o,y.name)?.file,te=ee?K(o,ee):void 0,G=Bt(o),_=s.cache!==!1&&!s.fix?ls({configPath:G,lockfilePath:te,sections:h,socketEnabled:P,workspaceRoot:o}):void 0,b=_?cs(_):void 0,$=b!==void 0;let V,T;if(m){const L=b?new Ve({activeSections:h,findings:ut(ct(b),x)}):new Ve({activeSections:h}),H=Rt(It.createElement(Js,{banner:U,fromCache:$,startedAt:v,store:L}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{V=b??await We({filterPatterns:x,installed:D,resolveCodemods:!!s.fix,sections:h,store:L,visConfig:l,workspaceRoot:o})}catch(W){throw H.unmount(),W}await H.waitUntilExit(),T=L.getSnapshot().pendingAction}else if(b)V=b;else{const L=vi(h,E.size,P,M,!!s.fix),W=qt(L,{live:!a&&!c&&!p});try{V=await We({filterPatterns:x,installed:D,progress:W,resolveCodemods:!!s.fix,sections:h,visConfig:l,workspaceRoot:o})}finally{W.stop()}}const ne={...V,elapsedMs:Date.now()-v};if(_&&!$)try{as(_,ne)}catch{}const B=ti(ne,x,R);if(a){process.stdout.write(`${JSON.stringify(ii(B,y.name),void 0,2)}
4
+ `),s.exitCode&&Ue(B,!!s.strict)&&(process.exitCode=1);return}$&&!c&&d.log(`${j("·")} Cached results (use --no-cache to refresh)`),x.length>0&&!c&&d.log(`${j("·")} Filter active: ${ye(s.filter??"")}`),ji(B,c);const X=B.runtime.some(L=>L.id===Se&&L.status==="warn"),ce=B.sections.has("optimization")&&B.optimizations.length>0;s.fix&&(ce||X)?await $i({force:!!s.fixForce,fs:e,logger:t,pm:y,recoverOrphans:X,results:B,useEditorconfig:l?.editorconfig??!0,workspaceRoot:o}):c||bi(B),T&&(process.stdout.write(`
5
5
  `),process.stdout.write(`${oe("→ ")}${T.description}
6
6
  `),T.configSnippet?(process.stdout.write(`
7
7
  `),process.stdout.write(`${j(T.configSnippet)}
8
8
  `)):process.stdout.write(` ${ye(T.command)}
9
9
  `),process.stdout.write(`
10
- `)),s.exitCode&&Ue(B,!!s.strict)&&(process.exitCode=1)},$i=async e=>{const{force:t,fs:s,logger:l,pm:n,recoverOrphans:o,results:a,useEditorconfig:h,workspaceRoot:c}=e;d.log(""),d.log(le("Applying fixes","ok"));const p=a.optimizations.filter(m=>m.category==="socket"&&m.overrideSpec).map(m=>({original:m.packageName,spec:m.overrideSpec})),x=a.optimizations.filter(m=>m.category!=="socket"&&m.hasCodemod),v=a.optimizations.filter(m=>m.category!=="socket"&&!m.hasCodemod);let y=!1,N=0;const S=[];if(o){const m=fs({force:t});if(m.killed.length>0&&(d.success(`Cleaned up ${String(m.killed.length)} orphaned process${m.killed.length===1?"":"es"} (PIDs: ${m.killed.join(", ")}).`),y=!0),m.failed.length>0){const E=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";d.warn(`Could not signal ${String(m.failed.length)} orphan${m.failed.length===1?"":"s"}: ${m.failed.map(O=>`${String(O.pid)} (${O.reason})`).join(", ")}.${E}`)}}if(p.length>0){const m=Yt(c,K(c,"package.json"),p,n,h);m.added.length>0&&(d.success(`Added ${String(m.added.length)} security override${m.added.length===1?"":"s"}.`),y=!0),m.updated.length>0&&(d.success(`Updated ${String(m.updated.length)} override${m.updated.length===1?"":"s"}.`),y=!0)}for(const m of x)try{const E=await Ut(s,c,m.packageName);E.filesChanged>0&&(d.success(`${m.packageName}: ${String(E.filesChanged)} file${E.filesChanged===1?"":"s"} updated`),N+=1,y=!0)}catch(E){const O=E instanceof Error?E.message:String(E);S.push({error:O,package:m.packageName}),d.warn(`${m.packageName}: codemod failed — ${O}`)}p.length>0&&(d.log(`${ye(D.arrow)} Running ${n.name} install to update lockfile…`),Wt(n,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},c,l),y=!0),d.log(""),y?d.success(`Fixes applied. ${N>0?`${String(N)} codemod${N===1?"":"s"} applied.`:""}`.trim()):d.log(ft("No auto-fixable items in the current run.")),S.length>0&&d.warn(`${String(S.length)} codemod${S.length===1?"":"s"} failed (run ${ge("vis optimize")} for the interactive picker).`),v.length>0&&d.notice(`${String(v.length)} optimization${v.length===1?"":"s"} need manual review (no codemod). Run ${ge("vis optimize")} to inspect them.`)};export{Ki as default};
10
+ `)),s.exitCode&&Ue(B,!!s.strict)&&(process.exitCode=1)},$i=async e=>{const{force:t,fs:s,logger:l,pm:n,recoverOrphans:o,results:a,useEditorconfig:h,workspaceRoot:c}=e;d.log(""),d.log(le("Applying fixes","ok"));const p=a.optimizations.filter(m=>m.category==="socket"&&m.overrideSpec).map(m=>({original:m.packageName,spec:m.overrideSpec})),x=a.optimizations.filter(m=>m.category!=="socket"&&m.hasCodemod),v=a.optimizations.filter(m=>m.category!=="socket"&&!m.hasCodemod);let y=!1,N=0;const S=[];if(o){const m=fs({force:t});if(m.killed.length>0&&(d.success(`Cleaned up ${String(m.killed.length)} orphaned process${m.killed.length===1?"":"es"} (PIDs: ${m.killed.join(", ")}).`),y=!0),m.failed.length>0){const E=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";d.warn(`Could not signal ${String(m.failed.length)} orphan${m.failed.length===1?"":"s"}: ${m.failed.map(D=>`${String(D.pid)} (${D.reason})`).join(", ")}.${E}`)}}if(p.length>0){const m=Yt(c,K(c,"package.json"),p,n,h);m.added.length>0&&(d.success(`Added ${String(m.added.length)} security override${m.added.length===1?"":"s"}.`),y=!0),m.updated.length>0&&(d.success(`Updated ${String(m.updated.length)} override${m.updated.length===1?"":"s"}.`),y=!0)}for(const m of x)try{const E=await Ut(s,c,m.packageName);E.filesChanged>0&&(d.success(`${m.packageName}: ${String(E.filesChanged)} file${E.filesChanged===1?"":"s"} updated`),N+=1,y=!0)}catch(E){const D=E instanceof Error?E.message:String(E);S.push({error:D,package:m.packageName}),d.warn(`${m.packageName}: codemod failed — ${D}`)}p.length>0&&(d.log(`${ye(O.arrow)} Running ${n.name} install to update lockfile…`),Wt(n,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},c,l),y=!0),d.log(""),y?d.success(`Fixes applied. ${N>0?`${String(N)} codemod${N===1?"":"s"} applied.`:""}`.trim()):d.log(ft("No auto-fixable items in the current run.")),S.length>0&&d.warn(`${String(S.length)} codemod${S.length===1?"":"s"} failed (run ${ge("vis optimize")} for the interactive picker).`),v.length>0&&d.notice(`${String(v.length)} optimization${v.length===1?"":"s"} need manual review (no codemod). Run ${ge("vis optimize")} to inspect them.`)};export{Ki as default};
@@ -1,4 +1,4 @@
1
- import{e as C,z as P,U as pe}from"../packem_shared/index-BzhrR_iC.js";import{U as ge,V as le,W as de,T as me,v as ye,Y as ke,p as m,d as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{P as be,G as t,X as g,o as c,x as O,R as xe,k as Te,l as Y}from"./catalog.js";import{s as ee}from"../packem_shared/index-B4AjSxHU.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as D}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{d as we,n as Me}from"../packem_shared/pm-runner-CMSml1Bj.js";import{p as re}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],$e=["overrides","pnpm","resolutions"],Ee=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="deno"?{overrides:{},source:"package.json"}:(e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"})},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),H=(r,e)=>{const s=e;for(const o of $e){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of Ee){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
1
+ import{e as C,z as P,U as pe}from"../packem_shared/index-BzhrR_iC.js";import{U as ge,V as le,W as de,T as me,C as ye,Y as ke,p as m,q as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{P as be,F as t,X as g,o as c,x as O,R as xe,k as Te,l as Y}from"./catalog.js";import{s as ee}from"../packem_shared/index-B4AjSxHU.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as D}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{d as we,n as Me}from"../packem_shared/pm-runner-CMSml1Bj.js";import{p as re}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],$e=["overrides","pnpm","resolutions"],Ee=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="deno"?{overrides:{},source:"package.json"}:(e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"})},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),H=(r,e)=>{const s=e;for(const o of $e){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of Ee){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
2
2
  ${Object.entries(e).map(([p,d])=>` '${p}': '${d}'`).join(`
3
3
  `)}
4
4
  `;i=/^overrides:\s*$/m.test(i)||/^overrides:\s*\n/m.test(i)?i.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,n):`${i.trimEnd()}