@visulima/vis 6.6.0 → 6.6.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 (120) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/bin/vis.mjs +5 -1
  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 +1 -1
  7. package/dist/packem_chunks/cli-exec.js +1 -1
  8. package/dist/packem_chunks/cli-main.js +182 -151
  9. package/dist/packem_chunks/fix.js +1 -1
  10. package/dist/packem_chunks/handler10.js +1 -1
  11. package/dist/packem_chunks/handler12.js +1 -1
  12. package/dist/packem_chunks/handler13.js +1 -1
  13. package/dist/packem_chunks/handler14.js +1 -1
  14. package/dist/packem_chunks/handler15.js +1 -1
  15. package/dist/packem_chunks/handler19.js +1 -1
  16. package/dist/packem_chunks/handler2.js +1 -1
  17. package/dist/packem_chunks/handler20.js +1 -1
  18. package/dist/packem_chunks/handler21.js +1 -1
  19. package/dist/packem_chunks/handler22.js +2 -2
  20. package/dist/packem_chunks/handler23.js +1 -1
  21. package/dist/packem_chunks/handler24.js +1 -1
  22. package/dist/packem_chunks/handler25.js +1 -1
  23. package/dist/packem_chunks/handler26.js +1 -1
  24. package/dist/packem_chunks/handler28.js +1 -1
  25. package/dist/packem_chunks/handler3.js +1 -1
  26. package/dist/packem_chunks/handler4.js +1 -1
  27. package/dist/packem_chunks/handler5.js +1 -1
  28. package/dist/packem_chunks/handler50.js +2 -2
  29. package/dist/packem_chunks/handler51.js +1 -1
  30. package/dist/packem_chunks/handler52.js +1 -1
  31. package/dist/packem_chunks/handler54.js +1 -1
  32. package/dist/packem_chunks/handler55.js +1 -1
  33. package/dist/packem_chunks/handler58.js +3 -3
  34. package/dist/packem_chunks/handler59.js +1 -1
  35. package/dist/packem_chunks/handler6.js +1 -1
  36. package/dist/packem_chunks/handler60.js +1 -1
  37. package/dist/packem_chunks/handler61.js +2 -2
  38. package/dist/packem_chunks/handler62.js +1 -1
  39. package/dist/packem_chunks/handler63.js +1 -1
  40. package/dist/packem_chunks/handler64.js +5 -5
  41. package/dist/packem_chunks/handler65.js +3 -3
  42. package/dist/packem_chunks/handler66.js +3 -3
  43. package/dist/packem_chunks/handler67.js +1 -1
  44. package/dist/packem_chunks/handler68.js +1 -1
  45. package/dist/packem_chunks/handler69.js +1 -1
  46. package/dist/packem_chunks/handler7.js +1 -1
  47. package/dist/packem_chunks/handler70.js +1 -1
  48. package/dist/packem_chunks/handler71.js +1 -1
  49. package/dist/packem_chunks/handler72.js +1 -1
  50. package/dist/packem_chunks/handler73.js +1 -1
  51. package/dist/packem_chunks/handler74.js +1 -1
  52. package/dist/packem_chunks/handler75.js +15 -15
  53. package/dist/packem_chunks/handler76.js +1 -1
  54. package/dist/packem_chunks/handler77.js +1 -1
  55. package/dist/packem_chunks/handler78.js +2 -2
  56. package/dist/packem_chunks/handler79.js +1 -1
  57. package/dist/packem_chunks/handler8.js +1 -1
  58. package/dist/packem_chunks/heal.js +1 -1
  59. package/dist/packem_chunks/help-command.js +1 -1
  60. package/dist/packem_chunks/index7.js +1 -1
  61. package/dist/packem_chunks/keys-refresh.js +1 -1
  62. package/dist/packem_chunks/list.js +1 -1
  63. package/dist/packem_chunks/prune.js +1 -1
  64. package/dist/packem_chunks/status.js +1 -1
  65. package/dist/packem_chunks/sync.js +1 -1
  66. package/dist/packem_chunks/sync2.js +1 -1
  67. package/dist/packem_chunks/tripwire.js +1 -1
  68. package/dist/packem_chunks/verify-lockfile.js +1 -1
  69. package/dist/packem_shared/{advisories-BldM-U4F.js → advisories-C803XIyf.js} +1 -1
  70. package/dist/packem_shared/{affected-selection-DxKQo2N5.js → affected-selection-N_hH7E2F.js} +1 -1
  71. package/dist/packem_shared/{ai-analysis-D1Y5a_SZ.js → ai-analysis-Cl0z4yyY.js} +1 -1
  72. package/dist/packem_shared/{ai-cache-CSmj5gA2.js → ai-cache-62Q75Ohc.js} +1 -1
  73. package/dist/packem_shared/{ai-fix-DVcnNQ0X.js → ai-fix-B5o7o8D0.js} +1 -1
  74. package/dist/packem_shared/{bin-Bw91EYm6.js → bin-Dg4DTW2J.js} +1 -1
  75. package/dist/packem_shared/{build-scripts-ETlkUGzC.js → build-scripts-DXEaKPbM.js} +1 -1
  76. package/dist/packem_shared/{dependency-scan-Dv1kJ-Sn.js → dependency-scan-DRigy-Ce.js} +1 -1
  77. package/dist/packem_shared/{detect-Bch1mcQe.js → detect-Cy4J0ZzQ.js} +1 -1
  78. package/dist/packem_shared/{docker-DPxeLIQl.js → docker-eH4IgLNI.js} +1 -1
  79. package/dist/packem_shared/{ecosystem-gate-IugL9cei.js → ecosystem-gate-Bn-P4Yqx.js} +1 -1
  80. package/dist/packem_shared/{env-D3wteXlq.js → env-B_MqQz0I.js} +1 -1
  81. package/dist/packem_shared/{env-consistency-1rRSdrFI.js → env-consistency-C-gPg1z7.js} +1 -1
  82. package/dist/packem_shared/{failure-log-Dgp-P-SJ.js → failure-log-TINPmB_Y.js} +1 -1
  83. package/dist/packem_shared/glob-Cyk1H9ZL-BcU6BdWa.js +1 -0
  84. package/dist/packem_shared/{index-DojXARzs.js → index-DUGTZGN1.js} +1 -1
  85. package/dist/packem_shared/{index-BTwTRy_a.js → index-DV9plm6F.js} +1 -1
  86. package/dist/packem_shared/{lifecycle-C6o0cmOT.js → lifecycle-C2j-_yjz.js} +1 -1
  87. package/dist/packem_shared/{manifests-CgiKqpP8.js → manifests-Dxq09rdz.js} +1 -1
  88. package/dist/packem_shared/{min-release-age-RVDHqGu5.js → min-release-age-lSu9fMQU.js} +1 -1
  89. package/dist/packem_shared/{missing-package-json-Cf7PavlK.js → missing-package-json-DX1OyAgd.js} +1 -1
  90. package/dist/packem_shared/{multi-eco-lockfiles-B3591j5D.js → multi-eco-lockfiles-BBdBBERS.js} +1 -1
  91. package/dist/packem_shared/{native-config-sync-BGLC8n86.js → native-config-sync-CDV3izkE.js} +1 -1
  92. package/dist/packem_shared/{osv-CI9eaGmG.js → osv-zlqqFEue.js} +1 -1
  93. package/dist/packem_shared/{package-version-COyEFX59.js → package-version-ilIDuvbM.js} +1 -1
  94. package/dist/packem_shared/{packument-Dij7POVt.js → packument-DgfV5ebL.js} +1 -1
  95. package/dist/packem_shared/{project-name-filter-B7h62wuR.js → project-name-filter-Bav_usE5.js} +1 -1
  96. package/dist/packem_shared/{provenance-BVFxzkUv.js → provenance-iyO7oSbr.js} +1 -1
  97. package/dist/packem_shared/{registry-CyYhBUaF.js → registry-DiFjkq9L.js} +1 -1
  98. package/dist/packem_shared/{registry-keys-BwWnVZtb.js → registry-keys-PoCGGEQU.js} +1 -1
  99. package/dist/packem_shared/{renderToString-DR0zDUjh-CQT5Ebrc.js → renderToString-DR0zDUjh-DIy97Cvo.js} +1 -1
  100. package/dist/packem_shared/{resolve-explicit-BshyrPRh.js → resolve-explicit-BxXTTACy.js} +1 -1
  101. package/dist/packem_shared/{run-summary-utils-RzgHeC8f.js → run-summary-utils-CWtpwjB-.js} +1 -1
  102. package/dist/packem_shared/{runtime-check-CpBsIYcl.js → runtime-check-B2_65Qxg.js} +1 -1
  103. package/dist/packem_shared/{s1ngularity-Bb56bc8v.js → s1ngularity-2ULYV9dv.js} +1 -1
  104. package/dist/packem_shared/{scaffold-files-sbf-Y1nQ.js → scaffold-files-ljwdtNix.js} +1 -1
  105. package/dist/packem_shared/{scan-progress-Blrj96LZ.js → scan-progress-Bg2J2LtK.js} +1 -1
  106. package/dist/packem_shared/{selectors-DmRRUQsG.js → selectors-CZt_FK38.js} +1 -1
  107. package/dist/packem_shared/{signatures-DlGMQsHg.js → signatures-wQxWdScn.js} +1 -1
  108. package/dist/packem_shared/{spinner-B30I9gQR.js → spinner-DqhHeEEh.js} +1 -1
  109. package/dist/packem_shared/{table-ahQIE6tw.js → table-DWrn2wa0.js} +1 -1
  110. package/dist/packem_shared/{tabs-K9dH5Qdu.js → tabs-CPZha41U.js} +1 -1
  111. package/dist/packem_shared/{toolchain-B7PrWDAi.js → toolchain-B7MSc6S4.js} +1 -1
  112. package/dist/packem_shared/{typosquats-Dn2ahBS1.js → typosquats-CCM8oyg7.js} +1 -1
  113. package/dist/packem_shared/{use-measured-height-D5xfIDWl.js → use-measured-height-Zz5Edg6J.js} +1 -1
  114. package/dist/packem_shared/{vis-update-app-CPpJkbSs.js → vis-update-app-CouPhMGg.js} +1 -1
  115. package/dist/packem_shared/{vis-user-error-C3y9hGtw.js → vis-user-error-Ceb7hJQW.js} +1 -1
  116. package/dist/packem_shared/{watch-loop-DQ6KryuH.js → watch-loop-CY-QsO2E.js} +1 -1
  117. package/index.d.ts +213 -204
  118. package/index.js +231 -104
  119. package/package.json +9 -9
  120. package/dist/packem_shared/glob-Cyk1H9ZL-D0MQr5DW.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-0dnGN3GP.js";import{n as B,h as X,U as J,o as Q,p as Z,e as ee,q as te,m as _}from"../packem_shared/env-D3wteXlq.js";import{y as se}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as re}from"../packem_shared/package-version-COyEFX59.js";import{g as oe,r as ne}from"../packem_shared/packument-Dij7POVt.js";import{q as ce,j as ie,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-Ca_EEVfw.js";import{z as ae}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{a as le,o as fe}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-DG49t2MT.js";let z;const V=e=>(z??=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 V(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(se(k)){const e=re(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{X(B());const t=`${k}.${String(process.pid)}.tmp`;J(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 oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ne(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await Z([{name:t,version:c}],{apiToken:a,minimumScore:ee});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??Q(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=>te(G(e)),Re={critical:E,high:E,low:v,medium:S},j=e=>{if(!(e===void 0||e<0))return ae(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=j(r),a=j(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},D=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?ce(i.label.padEnd(D)):" ".repeat(D);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=`┌─${ie(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)}},je=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),De=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||!je(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)},De)}),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-0dnGN3GP.js";import{n as B,h as X,U as J,o as Q,p as Z,e as ee,q as te,m as _}from"../packem_shared/env-B_MqQz0I.js";import{y as se}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as re}from"../packem_shared/package-version-ilIDuvbM.js";import{g as oe,r as ne}from"../packem_shared/packument-DgfV5ebL.js";import{q as ce,j as ie,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-Ca_EEVfw.js";import{z as ae}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{a as le,o as fe}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-DG49t2MT.js";let z;const V=e=>(z??=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 V(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(se(k)){const e=re(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{X(B());const t=`${k}.${String(process.pid)}.tmp`;J(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 oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ne(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await Z([{name:t,version:c}],{apiToken:a,minimumScore:ee});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??Q(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=>te(G(e)),Re={critical:E,high:E,low:v,medium:S},j=e=>{if(!(e===void 0||e<0))return ae(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=j(r),a=j(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},D=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?ce(i.label.padEnd(D)):" ".repeat(D);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=`┌─${ie(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)}},je=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),De=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||!je(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)},De)}),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({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 ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-0dnGN3GP.js";import{f as ae,h as M}from"../packem_shared/ai-cache-CSmj5gA2.js";import{p as c,V,W as k,X as ne,R as P,Y as L,Z as oe,h as ie}from"./cli-main.js";import{B as ce,C as de,D as N,E as z}from"../packem_shared/registry-CyYhBUaF.js";import{r as he,d as x,a as U,t as I}from"../packem_shared/env-D3wteXlq.js";import{z as b}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{Cache as E,readLastRunSummary as q,getLastRunSummaryPath as T,parseCacheSize as me,digestFile as X,describeCacheMissReason as pe}from"@visulima/task-runner";import{y as R}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{r as G,f as F,a as ye,d as Se}from"../packem_shared/run-summary-utils-RzgHeC8f.js";let te;const se=e=>(te??=ee(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(e)}return se(e)},{realpath:_,rm:W,mkdtemp:fe,readdir:ue,stat:Y}=j("node:fs/promises"),{createInterface:le}=j("node:readline"),{tmpdir:$e}=j("node:os"),we=e=>new Promise(s=>{const t=le({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const n=r.trim().toLowerCase();s(n==="y"||n==="yes")})}),ve=()=>{try{const e=ae();e>0&&c.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},ke=()=>{try{const e=he();e>0&&c.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Ce=()=>{try{const e=ce();e>0&&c.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ge=()=>{try{const e=de();e>0&&c.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},De=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const a=(await Promise.all(V(e,!0).map(async i=>k(i)))).flat(),o=a.reduce((i,d)=>i+d.sizeBytes,0);c.info(`Would remove ${String(a.length)} cache entr${a.length===1?"y":"ies"} (${b(o,{decimals:1,space:!1})}) from ${e}`);return}const r=ne(e,s);try{const n=await _(e),a=await _(s);if(n===a){c.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(c.warn(`Cache directory is outside the workspace root: ${e}`),c.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){c.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await we(" Continue?")){c.info("Aborted.");return}}r?await new E({cacheDirectory:e,workspaceRoot:s}).clear():await W(e,{force:!0,recursive:!0}),c.success(`Cleared cache: ${e}`)},Z=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),m=(e,s)=>e==="all"||e===s,xe=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),w=(e,s,t)=>{const r=e??process.cwd(),n=t??{},a=n.taskRunner??{},o=xe(s.scope),i=s.cacheDir,d=P(r,i,a.cacheDirectory,!1),f=P(r,i,a.cacheDirectory,n.sharedWorktreeCache),h=L(d,r,n.branchScopedCache),u=L(f,r,n.branchScopedCache);let l;switch(o){case"all":{l=u===h?[{base:f,scoped:u}]:[{base:f,scoped:u},{base:d,scoped:h}];break}case"worktree":{l=[{base:d,scoped:h}];break}default:l=[{base:f,scoped:u}]}const S=n.branchScopedCache===!0;return{directoriesFor:O=>O==="read"?[...new Set(l.flatMap(p=>p.scoped!==p.base&&oe(p.base)?[p.scoped,p.base]:[p.scoped]))]:O==="wipe"?[...new Set(l.map(p=>p.base))]:[...new Set(l.flatMap(p=>V(p.base,S)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,K=e=>e.length>H?`${e.slice(0,H)}…`:e,v=(e,s,t)=>{const r=Object.entries(s??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([n],[a])=>n.localeCompare(a));for(const[n,a]of r)t.info(` ${n.padEnd(40)} ${K(a)}`)}},be=async(e,s,t)=>{if(e!==void 0)for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).get(e);if(n?.fingerprint)return n.fingerprint}},Ee=(e,s)=>{v("tracked files",e.fileHashes,s),v("tracked env",e.envHashes,s),v("missing files",Object.fromEntries(e.missingFiles.map(t=>[t,"absent"])),s)},Re=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await q(a,{dataDirectory:x(a)}):await G(a,n);if(!o){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null,taskId:e},void 0,2)}
1
+ import{createRequire as ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-0dnGN3GP.js";import{f as ae,h as M}from"../packem_shared/ai-cache-62Q75Ohc.js";import{p as c,W as V,X as k,Y as ne,T as P,Z as L,_ as oe,h as ie}from"./cli-main.js";import{B as ce,C as de,D as N,E as z}from"../packem_shared/registry-DiFjkq9L.js";import{r as he,d as x,a as U,t as I}from"../packem_shared/env-B_MqQz0I.js";import{z as b}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{Cache as E,readLastRunSummary as q,getLastRunSummaryPath as T,parseCacheSize as me,digestFile as X,describeCacheMissReason as pe}from"@visulima/task-runner";import{y as R}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{r as G,f as F,a as ye,d as Se}from"../packem_shared/run-summary-utils-CWtpwjB-.js";let te;const se=e=>(te??=ee(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(e)}return se(e)},{realpath:_,rm:W,mkdtemp:fe,readdir:ue,stat:Y}=j("node:fs/promises"),{createInterface:le}=j("node:readline"),{tmpdir:$e}=j("node:os"),we=e=>new Promise(s=>{const t=le({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const n=r.trim().toLowerCase();s(n==="y"||n==="yes")})}),ve=()=>{try{const e=ae();e>0&&c.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},ke=()=>{try{const e=he();e>0&&c.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Ce=()=>{try{const e=ce();e>0&&c.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ge=()=>{try{const e=de();e>0&&c.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},De=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const a=(await Promise.all(V(e,!0).map(async i=>k(i)))).flat(),o=a.reduce((i,d)=>i+d.sizeBytes,0);c.info(`Would remove ${String(a.length)} cache entr${a.length===1?"y":"ies"} (${b(o,{decimals:1,space:!1})}) from ${e}`);return}const r=ne(e,s);try{const n=await _(e),a=await _(s);if(n===a){c.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(c.warn(`Cache directory is outside the workspace root: ${e}`),c.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){c.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await we(" Continue?")){c.info("Aborted.");return}}r?await new E({cacheDirectory:e,workspaceRoot:s}).clear():await W(e,{force:!0,recursive:!0}),c.success(`Cleared cache: ${e}`)},Z=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),m=(e,s)=>e==="all"||e===s,xe=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),w=(e,s,t)=>{const r=e??process.cwd(),n=t??{},a=n.taskRunner??{},o=xe(s.scope),i=s.cacheDir,d=P(r,i,a.cacheDirectory,!1),f=P(r,i,a.cacheDirectory,n.sharedWorktreeCache),h=L(d,r,n.branchScopedCache),u=L(f,r,n.branchScopedCache);let l;switch(o){case"all":{l=u===h?[{base:f,scoped:u}]:[{base:f,scoped:u},{base:d,scoped:h}];break}case"worktree":{l=[{base:d,scoped:h}];break}default:l=[{base:f,scoped:u}]}const S=n.branchScopedCache===!0;return{directoriesFor:O=>O==="read"?[...new Set(l.flatMap(p=>p.scoped!==p.base&&oe(p.base)?[p.scoped,p.base]:[p.scoped]))]:O==="wipe"?[...new Set(l.map(p=>p.base))]:[...new Set(l.flatMap(p=>V(p.base,S)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,K=e=>e.length>H?`${e.slice(0,H)}…`:e,v=(e,s,t)=>{const r=Object.entries(s??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([n],[a])=>n.localeCompare(a));for(const[n,a]of r)t.info(` ${n.padEnd(40)} ${K(a)}`)}},be=async(e,s,t)=>{if(e!==void 0)for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).get(e);if(n?.fingerprint)return n.fingerprint}},Ee=(e,s)=>{v("tracked files",e.fileHashes,s),v("tracked env",e.envHashes,s),v("missing files",Object.fromEntries(e.missingFiles.map(t=>[t,"absent"])),s)},Re=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await q(a,{dataDirectory:x(a)}):await G(a,n);if(!o){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null,taskId:e},void 0,2)}
2
2
  `),process.exitCode=1;return}n===void 0?c.error(`No previous run summary found. Run a task first to populate \`${T(a,{dataDirectory:x(a)})}\`.`):c.error(`Run summary "${n}" not found in ${U(a)}/.`),process.exitCode=1;return}const i=F(o,e);if(!i){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
3
3
  `),process.exitCode=1;return}c.error(`Task "${e}" was not part of run ${o.id}.`),process.exitCode=1;return}const d=i.hashDetails===void 0?await be(i.hash,s.cacheDirectories??[],a):void 0;if(r==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:i.cacheStatus,hash:i.hash??null,hashDetails:i.hashDetails??null,hashSource:i.hashSource??null,runId:o.id,taskId:i.taskId,trackedFingerprint:d??null},void 0,2)}
4
4
  `);return}c.info(`Hash for ${e} (run ${o.id})`),t.info(""),t.info(` status: ${i.cacheStatus}`),t.info(` hash: ${i.hash??"(none)"}`),i.hashSource==="declared-fallback"&&t.info(" key: declared-fallback (no files were tracked; the entry is keyed on the declared inputs below)"),i.hashDetails?(t.info(""),t.info(` command: ${K(i.hashDetails.command)}`),v("nodes",i.hashDetails.nodes,t),v("runtime",i.hashDetails.runtime,t),v("implicitDeps",i.hashDetails.implicitDeps,t)):d?(t.info(""),Ee(d,t)):(t.info(""),c.info("No hash details recorded for this task."))},$=e=>{process.stdout.write(`${e}
@@ -1,4 +1,4 @@
1
- import{createRequire as ye}from"node:module";import{b as C,F as g,X as xe,J as ce,q as ke}from"../packem_shared/index.server-Ca_EEVfw.js";import{m as Ie,v as F,U as k,a as _,e as U,z as Re}from"../packem_shared/index-0dnGN3GP.js";import{wholeMatchFingerprint as Ce,fingerprint as V,baselineKeys as J,legacyFingerprint as Fe,GIT_CONFIG_OVERRIDES as Te,DIFF_HARDENING_FLAGS as je,gitleaksIgnoreFingerprint as q,toSarifUri as Ee,CONFIDENCE_LEVELS as Y,DEFAULT_MAX_FILE_SIZE as Ae,MAX_ARCHIVE_DEPTH as De,listRules as le,listRequiredValidators as Ne,scan as Me,scanGitHistoryDetailed as Le,scanDetailed as _e,scanGitStaged as Be,scanFilesDetailed as Ue,inspectRuleset as Oe}from"@visulima/secret-scanner";import{V as p}from"../packem_shared/vis-user-error-C3y9hGtw.js";import{_ as qe,$ as X,p as j}from"./cli-main.js";import{E as Pe,A as Ge}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{y as H}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Ye}from"../packem_shared/package-version-COyEFX59.js";import{e as B,c as Qe}from"../packem_shared/junit-audit-CuJShWCH.js";let be;const Se=e=>(be??=ye(import.meta.url))(e),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=e=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[t,s]=A.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return A.getBuiltinModule(e)}return Se(e)},{createRequire:Ve}=L("node:module"),{mkdirSync:He,writeFileSync:Z,openSync:ze,fchmodSync:Ke,closeSync:We,realpathSync:Je}=L("node:fs"),{execFileSync:Xe}=L("node:child_process"),{createHash:Ze}=L("node:crypto"),{pathToFileURL:de}=L("node:url");let et;const tt=e=>(et??=Ve(import.meta.url))(e),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,st=e=>{if(typeof D<"u"&&D.versions&&D.versions.node){const[t,s]=D.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return D.getBuiltinModule(e)}return tt(e)},{styleText:it}=st("node:util"),rt={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},nt=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},ot=/\u001B\[[\d;]*[a-z]/gi,at=e=>[...e.replaceAll(ot,"")].length,ct=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?s=>s:s=>it(t,s)};class lt{#n=0;#l;#e=!1;#r="";#o="";#g=0;#d=0;#t;#s;#u="";#a;#m;#i;#y;#h=0;#c;#b;constructor(t={},s){if(t.frames)this.#a=t.frames;else{const i=t.name??"dots",n=Ge(i);if(!n)throw new Error(`Unknown spinner "${i}". Pass a custom \`frames\` set or use one of: ${Pe().join(", ")}.`);this.#a=n}this.#m=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=s,this.#i=t.stream??process.stderr,this.#y=s?!0:this.#i.isTTY&&!nt(),this.#b={...rt,...t.icons},typeof t.style=="function"?this.#c=t.style:t.style&&(this.#c=ct(t.style))}get elapsedTime(){return this.#g===0?0:(this.#d||Date.now())-this.#g}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#s=t}tick(){this.#e&&(this.#n=(this.#n+1)%this.#a.frames.length)}start(t,s){return this.#e?this:this.#m?(this.#e=!0,this.#g=Date.now(),this.#d=0,this.#n=0,this.#u="",t&&(this.#o=t),s?.prefixText&&(this.#r=s.prefixText),this.#s?(this.#s.renderAll(),this):(this.#t?(this.#t.hook(),this.#S(),this.#$()):(this.#x(),this.#$()),this)):this}stop(){if(this.#e){if(this.#p(),this.#e=!1,this.#d=Date.now(),this.#u="",this.#s){this.#s.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#v()}}stopAndPersist(t){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#m))return;const s=t?.prefixText??this.#r,i=t?.text??this.#o;let n=t?.symbol??"";s&&(n=n?`${s} ${n}`:s),i&&(n=n?`${n} ${i}`:i),this.#k(n)}succeed(t){this.#f("success",t)}failed(t){this.#f("error",t)}warn(t){this.#f("warning",t)}info(t){this.#f("info",t)}pause(){this.#p()}resume(){this.#e&&(this.#p(),this.#s||this.#$())}getFrameOutput(){if(!this.#e&&this.#u)return this.#u;const t=this.#a.frames[this.#n];let s=this.#c?this.#c(t):t;return this.#r&&(s=`${this.#r} ${s}`),this.#o&&(s=`${s} ${this.#o}`),s}#$(){this.#y&&(this.#l=setInterval(()=>{this.#e&&(this.#n=(this.#n+1)%this.#a.frames.length,this.#w())},this.#a.interval),this.#l.unref())}#p(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#s?this.#s.renderAll():this.#t?this.#S():this.#x()}#S(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#x(){const t=this.getFrameOutput();if(this.#v(),this.#i.isTTY){this.#i.write(t);const s=this.#i.columns||80;this.#h=Math.max(1,Math.ceil(at(t)/s))}else this.#i.write(`${t}
1
+ import{createRequire as ye}from"node:module";import{b as C,F as g,X as xe,J as ce,q as ke}from"../packem_shared/index.server-Ca_EEVfw.js";import{m as Ie,v as F,U as k,a as _,e as U,z as Re}from"../packem_shared/index-0dnGN3GP.js";import{wholeMatchFingerprint as Ce,fingerprint as V,baselineKeys as J,legacyFingerprint as Fe,GIT_CONFIG_OVERRIDES as Te,DIFF_HARDENING_FLAGS as je,gitleaksIgnoreFingerprint as q,toSarifUri as Ee,CONFIDENCE_LEVELS as Y,DEFAULT_MAX_FILE_SIZE as Ae,MAX_ARCHIVE_DEPTH as De,listRules as le,listRequiredValidators as Ne,scan as Me,scanGitHistoryDetailed as Le,scanDetailed as _e,scanGitStaged as Be,scanFilesDetailed as Ue,inspectRuleset as Oe}from"@visulima/secret-scanner";import{V as p}from"../packem_shared/vis-user-error-Ceb7hJQW.js";import{$ as qe,a0 as X,p as j}from"./cli-main.js";import{E as Pe,A as Ge}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{y as H}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Ye}from"../packem_shared/package-version-ilIDuvbM.js";import{e as B,c as Qe}from"../packem_shared/junit-audit-CuJShWCH.js";let be;const Se=e=>(be??=ye(import.meta.url))(e),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=e=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[t,s]=A.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return A.getBuiltinModule(e)}return Se(e)},{createRequire:Ve}=L("node:module"),{mkdirSync:He,writeFileSync:Z,openSync:ze,fchmodSync:Ke,closeSync:We,realpathSync:Je}=L("node:fs"),{execFileSync:Xe}=L("node:child_process"),{createHash:Ze}=L("node:crypto"),{pathToFileURL:de}=L("node:url");let et;const tt=e=>(et??=Ve(import.meta.url))(e),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,st=e=>{if(typeof D<"u"&&D.versions&&D.versions.node){const[t,s]=D.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return D.getBuiltinModule(e)}return tt(e)},{styleText:it}=st("node:util"),rt={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},nt=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},ot=/\u001B\[[\d;]*[a-z]/gi,at=e=>[...e.replaceAll(ot,"")].length,ct=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?s=>s:s=>it(t,s)};class lt{#n=0;#l;#e=!1;#r="";#o="";#g=0;#d=0;#t;#s;#u="";#a;#m;#i;#y;#h=0;#c;#b;constructor(t={},s){if(t.frames)this.#a=t.frames;else{const i=t.name??"dots",n=Ge(i);if(!n)throw new Error(`Unknown spinner "${i}". Pass a custom \`frames\` set or use one of: ${Pe().join(", ")}.`);this.#a=n}this.#m=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=s,this.#i=t.stream??process.stderr,this.#y=s?!0:this.#i.isTTY&&!nt(),this.#b={...rt,...t.icons},typeof t.style=="function"?this.#c=t.style:t.style&&(this.#c=ct(t.style))}get elapsedTime(){return this.#g===0?0:(this.#d||Date.now())-this.#g}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#s=t}tick(){this.#e&&(this.#n=(this.#n+1)%this.#a.frames.length)}start(t,s){return this.#e?this:this.#m?(this.#e=!0,this.#g=Date.now(),this.#d=0,this.#n=0,this.#u="",t&&(this.#o=t),s?.prefixText&&(this.#r=s.prefixText),this.#s?(this.#s.renderAll(),this):(this.#t?(this.#t.hook(),this.#S(),this.#$()):(this.#x(),this.#$()),this)):this}stop(){if(this.#e){if(this.#p(),this.#e=!1,this.#d=Date.now(),this.#u="",this.#s){this.#s.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#v()}}stopAndPersist(t){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#m))return;const s=t?.prefixText??this.#r,i=t?.text??this.#o;let n=t?.symbol??"";s&&(n=n?`${s} ${n}`:s),i&&(n=n?`${n} ${i}`:i),this.#k(n)}succeed(t){this.#f("success",t)}failed(t){this.#f("error",t)}warn(t){this.#f("warning",t)}info(t){this.#f("info",t)}pause(){this.#p()}resume(){this.#e&&(this.#p(),this.#s||this.#$())}getFrameOutput(){if(!this.#e&&this.#u)return this.#u;const t=this.#a.frames[this.#n];let s=this.#c?this.#c(t):t;return this.#r&&(s=`${this.#r} ${s}`),this.#o&&(s=`${s} ${this.#o}`),s}#$(){this.#y&&(this.#l=setInterval(()=>{this.#e&&(this.#n=(this.#n+1)%this.#a.frames.length,this.#w())},this.#a.interval),this.#l.unref())}#p(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#s?this.#s.renderAll():this.#t?this.#S():this.#x()}#S(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#x(){const t=this.getFrameOutput();if(this.#v(),this.#i.isTTY){this.#i.write(t);const s=this.#i.columns||80;this.#h=Math.max(1,Math.ceil(at(t)/s))}else this.#i.write(`${t}
2
2
  `),this.#h=0}#v(){if(this.#h>0&&this.#i.isTTY){for(let t=1;t<this.#h;t+=1)this.#i.write("\x1B[1A\x1B[2K");this.#i.write("\r\x1B[K")}this.#h=0}#k(t){this.#u=t,this.#s?this.#s.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#v(),this.#i.write(`${t}
3
3
  `))}#f(t,s){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#m))return;let i="";const n=this.#b[t];n&&(i=this.#c?this.#c(n):n),this.#r&&(i=`${this.#r} ${i}`),s&&(i=`${i} ${s}`),this.#k(i)}}const ue=(e={})=>{const t=new qe(new X(process.stdout),new X(process.stderr));return new lt(e,t)},Q=384,he=(e,t,s)=>{if(He(Ie(e),{recursive:!0}),!s){Z(e,t);return}const i=ze(e,"w",Q);try{Ke(i,Q),Z(i,t)}finally{We(i)}},dt=(e,t)=>{if(!F(e))return e;const s=_(t,e);return s===""||s.startsWith("..")?e:s},P=e=>{try{return Je(e)}catch{return e}},pe=(e,t)=>{const s=_(e,t);return s===""||s.startsWith("..")||F(s)?t:s},E=(e,t)=>{const s=dt(e.file,t);return s===e.file?e:{...e,file:s}},z=e=>{if(!H(e))return[];try{const t=Ye(e);return Array.isArray(t)?t:[]}catch{return[]}},ee=(e,t,s)=>{const i=F(e.file)?e.file:k(t,e.file),n=pe(P(s),i);return n===e.file?e:{...e,file:n}},ut=(e,t,s)=>{const i=P(t),n=P(s);return z(e).flatMap(r=>{const a=pe(n,F(r.file)?r.file:k(i,r.file));return a===r.file?[r]:[r,{...r,file:a}]})},te=e=>[V({...e,secret:typeof e.secret=="string"?e.secret:""}),Fe(e)],ht=(e,t,s)=>{const i=z(t).map(o=>E(o,s)),n=new Set(i.flatMap(o=>te(o))),r=e.map(o=>E(o,s)),a=new Set(r.flatMap(o=>J(o))),l=o=>J(o).some(c=>n.has(c));return{fresh:r.filter(o=>!l(o)),resolved:i.filter(o=>!te(o).some(c=>a.has(c))),surviving:r.filter(o=>l(o))}},me=(e,t,s,i={})=>{const n=e.map(a=>E(a,s));let r;if(i.replace)r=n;else{const a=new Set(n.filter(c=>c.secret!==c.match).map(c=>Ce(c))),l=z(t).map(c=>E(c,s)).filter(c=>!a.has(V(c))),o=new Set;r=[];for(const c of[...l,...n]){const u=V(c);o.has(u)||(o.add(u),r.push(c))}}return he(t,`${JSON.stringify(r,null,4)}
4
4
  `,i.sensitive??!0),r.length},G=(e,t)=>{try{return Xe("git",[...Te,...t],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}catch{return""}},pt=e=>e.split("\0").filter(Boolean),se=(e,t)=>{if(t.startsWith("-"))throw new p(`--since "${t}" looks like a flag, not a git ref.`);const s=k(e,G(e,["rev-parse","--show-cdup"]).trim()),i=r=>pt(G(e,["diff","-z","--name-only","--diff-filter=ACMR",...je,r,"--"]));let n=i(`${t}...HEAD`);return n.length===0&&(n=i(t)),n.map(r=>F(r)?r:U(s,r))},ie=e=>G(e,["rev-parse","--show-toplevel"]).trim().length>0,mt=/^[\t\r+=@-]/,y=e=>{const t=mt.test(e)?`'${e}`:e;return/[\n\r",]/.test(t)?`"${t.replaceAll('"','""')}"`:t},ft=["RuleID","Commit","File","Secret","Match","StartLine","EndLine","StartColumn","EndColumn","Author","Message","Date","Email","Fingerprint","Tags"],gt=e=>{const t=e.map(s=>[y(s.ruleId),y(s.commit?.sha??""),y(s.file),y(s.secret),y(s.match),String(s.startLine),String(s.endLine),String(s.startColumn),String(s.endColumn),y(s.commit?.authorName??""),y(s.commit?.message??""),y(s.commit?.date??""),y(s.commit?.authorEmail??""),y(q(s)),y(s.tags.join(" "))].join(","));return`${[ft.join(","),...t].join(`\r
@@ -1 +1 @@
1
- import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-B7PrWDAi.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};
1
+ import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-B7MSc6S4.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ 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-Ca_EEVfw.js";import{e as I,z as se,a as $}from"../packem_shared/index-0dnGN3GP.js";import G from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as oe,T as F,l as ne,a0 as ae,a1 as ie,a2 as re,a3 as ce}from"./cli-main.js";import{h as pe,i as z,q as W,u as j,p as L,J as K}from"../packem_shared/registry-CyYhBUaF.js";import{p as S}from"../packem_shared/package-version-COyEFX59.js";import{U as fe}from"../packem_shared/env-D3wteXlq.js";import{l as le}from"../packem_shared/missing-package-json-Cf7PavlK.js";import{readCatalogs as ue}from"./catalog.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=>G(s,a)),U=(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&&U(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&G(t,e.depName)&&U(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-Ca_EEVfw.js";import{e as I,z as se,a as $}from"../packem_shared/index-0dnGN3GP.js";import G from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{V as oe,U as F,l as ne,a1 as ae,a2 as ie,a3 as re,a4 as ce}from"./cli-main.js";import{h as pe,i as z,q as W,u as j,p as L,J as K}from"../packem_shared/registry-DiFjkq9L.js";import{p as S}from"../packem_shared/package-version-ilIDuvbM.js";import{U as fe}from"../packem_shared/env-B_MqQz0I.js";import{l as le}from"../packem_shared/missing-package-json-DX1OyAgd.js";import{readCatalogs as ue}from"./catalog.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=>G(s,a)),U=(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&&U(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&G(t,e.depName)&&U(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
@@ -1,4 +1,4 @@
1
- import{e as C,z as P,U as pe}from"../packem_shared/index-0dnGN3GP.js";import{L as ge,M as le,N as de,K as me,C as ye,Q 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{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-CyYhBUaF.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as D}from"../packem_shared/env-D3wteXlq.js";import{d as we,n as Me}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{p as re}from"../packem_shared/package-version-COyEFX59.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-D0MQr5DW.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["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==="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),Y=(r,e)=>{const s=e;for(const o of Ee){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 $e){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-0dnGN3GP.js";import{M as ge,N as le,P as de,L as me,C as ye,R 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{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-DiFjkq9L.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as D}from"../packem_shared/env-B_MqQz0I.js";import{d as we,n as Me}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{p as re}from"../packem_shared/package-version-ilIDuvbM.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-BcU6BdWa.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["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==="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),Y=(r,e)=>{const s=e;for(const o of Ee){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 $e){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()}
@@ -1,4 +1,4 @@
1
- import{createRequire as Dt}from"node:module";import{X as xe,F as I,b as ke,q as ut,T as mt}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as V,z as $e,U as Ft}from"../packem_shared/index-0dnGN3GP.js";import{i as Me}from"../packem_shared/index-BjdW45xX.js";import{whichBin as zt}from"#native";import{b as Bt,a as Wt,e as Ht}from"../packem_shared/ai-analysis-D1Y5a_SZ.js";import{e as Gt,b as Kt,g as qt,s as Yt}from"../packem_shared/ai-cache-CSmj5gA2.js";import{l as Fe}from"./ts-loader.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as et,e as Jt,i as tt,f as Xt,k as Zt}from"../packem_shared/env-D3wteXlq.js";import{L as Qt,h as en,i as tn,K as nn,a as an,f as on,d as rn,b as sn}from"../packem_shared/registry-CyYhBUaF.js";import{p as f,c as nt}from"./cli-main.js";import{d as cn,c as ln}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{a as T}from"../packem_shared/index--eV4qIz5.js";import{c as ht,s as ye,g as dn,p as pn,e as fn}from"../packem_shared/index-BTwTRy_a.js";import{d as gn}from"../packem_shared/anolilab-text-CAM_E6uK.js";import{S as un,a as M,b as vt,d as be,s as mn,f as hn,g as vn,h as wn}from"../packem_shared/junit-audit-CuJShWCH.js";import{t as yn,b as bn,G as xn}from"../packem_shared/ecosystem-gate-IugL9cei.js";import{s as Sn}from"../packem_shared/scan-progress-Blrj96LZ.js";import{r as An,b as Nn,c as it,q as at,a as ot}from"../packem_shared/advisories-BldM-U4F.js";import{p as yt}from"../packem_shared/package-version-COyEFX59.js";import{r as Cn,l as En,f as jn,a as Pn}from"../packem_shared/dependency-scan-Dv1kJ-Sn.js";import{r as Rn}from"../packem_shared/manifests-CgiKqpP8.js";import{c as oe,h as On,i as In,l as Ln,m as Dn}from"../packem_shared/multi-eco-lockfiles-B3591j5D.js";import{l as Tn,p as Mn,O as _n}from"../packem_shared/osv-bloom-DU6avR2k.js";import{f as Bn}from"../packem_shared/osv-CI9eaGmG.js";let Tt;const Mt=e=>(Tt??=Dt(import.meta.url))(e),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=e=>{if(typeof te<"u"&&te.versions&&te.versions.node){const[t,n]=te.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return te.getBuiltinModule(e)}return Mt(e)},{spawnSync:_t}=Z("node:child_process"),{createInterface:Vt}=Z("node:readline"),{stripVTControlCharacters:Ut}=Z("node:util"),{createHash:kn}=Z("node:crypto"),{relative:wt,join:$n}=Z("node:path"),{readFileSync:Vn,writeFileSync:Fn,renameSync:zn,unlinkSync:Un}=Z("node:fs"),rt=(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const n=[];for(const i of Qt(e,t))n.push(i.path);return n},Se=e=>`${e.packageName}@${e.packageVersion}:${e.vulnerability.id}`,Wn=e=>e==null||e===!0||e===""||e==="true"||e.toString().toLowerCase()==="all",Hn=(e,t)=>{if(Wn(t))return e;const n=String(t).trim();if(/^\d+$/.test(n)){const a=Number.parseInt(n,10)-1,o=e[a];return o?[o]:[]}const i=n.toLowerCase();return e.filter(a=>{const{aliases:o,id:r}=a.vulnerability;return r.toLowerCase()===i||(o??[]).some(c=>c.toLowerCase()===i)})},Gn=e=>{const{packageName:t,packageVersion:n,vulnerability:i}=e,a=(i.aliases??[]).join(", ")||"none",o=(i.fixedVersions??[]).join(", ")||"no fixed version published";return`You are a security engineer. Explain this dependency vulnerability for a developer triaging it.
1
+ import{createRequire as Dt}from"node:module";import{X as xe,F as I,b as ke,q as ut,T as mt}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as V,z as $e,U as Ft}from"../packem_shared/index-0dnGN3GP.js";import{i as Me}from"../packem_shared/index-BjdW45xX.js";import{whichBin as zt}from"#native";import{b as Bt,a as Wt,e as Ht}from"../packem_shared/ai-analysis-Cl0z4yyY.js";import{e as Gt,b as Kt,g as qt,s as Yt}from"../packem_shared/ai-cache-62Q75Ohc.js";import{l as Fe}from"./ts-loader.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as et,e as Jt,i as tt,f as Xt,k as Zt}from"../packem_shared/env-B_MqQz0I.js";import{L as Qt,h as en,i as tn,K as nn,a as an,f as on,d as rn,b as sn}from"../packem_shared/registry-DiFjkq9L.js";import{p as f,c as nt}from"./cli-main.js";import{d as cn,c as ln}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{a as T}from"../packem_shared/index--eV4qIz5.js";import{c as ht,s as ye,g as dn,p as pn,e as fn}from"../packem_shared/index-DV9plm6F.js";import{d as gn}from"../packem_shared/anolilab-text-CAM_E6uK.js";import{S as un,a as M,b as vt,d as be,s as mn,f as hn,g as vn,h as wn}from"../packem_shared/junit-audit-CuJShWCH.js";import{t as yn,b as bn,G as xn}from"../packem_shared/ecosystem-gate-Bn-P4Yqx.js";import{s as Sn}from"../packem_shared/scan-progress-Bg2J2LtK.js";import{r as An,b as Nn,c as it,q as at,a as ot}from"../packem_shared/advisories-C803XIyf.js";import{p as yt}from"../packem_shared/package-version-ilIDuvbM.js";import{r as Cn,l as En,f as jn,a as Pn}from"../packem_shared/dependency-scan-DRigy-Ce.js";import{r as Rn}from"../packem_shared/manifests-Dxq09rdz.js";import{c as oe,h as On,i as In,l as Ln,m as Dn}from"../packem_shared/multi-eco-lockfiles-BBdBBERS.js";import{l as Tn,p as Mn,O as _n}from"../packem_shared/osv-bloom-DU6avR2k.js";import{f as Bn}from"../packem_shared/osv-zlqqFEue.js";let Tt;const Mt=e=>(Tt??=Dt(import.meta.url))(e),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=e=>{if(typeof te<"u"&&te.versions&&te.versions.node){const[t,n]=te.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return te.getBuiltinModule(e)}return Mt(e)},{spawnSync:_t}=Z("node:child_process"),{createInterface:Vt}=Z("node:readline"),{stripVTControlCharacters:Ut}=Z("node:util"),{createHash:kn}=Z("node:crypto"),{relative:wt,join:$n}=Z("node:path"),{readFileSync:Vn,writeFileSync:Fn,renameSync:zn,unlinkSync:Un}=Z("node:fs"),rt=(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const n=[];for(const i of Qt(e,t))n.push(i.path);return n},Se=e=>`${e.packageName}@${e.packageVersion}:${e.vulnerability.id}`,Wn=e=>e==null||e===!0||e===""||e==="true"||e.toString().toLowerCase()==="all",Hn=(e,t)=>{if(Wn(t))return e;const n=String(t).trim();if(/^\d+$/.test(n)){const a=Number.parseInt(n,10)-1,o=e[a];return o?[o]:[]}const i=n.toLowerCase();return e.filter(a=>{const{aliases:o,id:r}=a.vulnerability;return r.toLowerCase()===i||(o??[]).some(c=>c.toLowerCase()===i)})},Gn=e=>{const{packageName:t,packageVersion:n,vulnerability:i}=e,a=(i.aliases??[]).join(", ")||"none",o=(i.fixedVersions??[]).join(", ")||"no fixed version published";return`You are a security engineer. Explain this dependency vulnerability for a developer triaging it.
2
2
 
3
3
  Package: ${t}@${n}
4
4
  Advisory: ${i.id} (aliases: ${a})
@@ -1,4 +1,4 @@
1
- import{createRequire as wt}from"node:module";import{F as j,j as le,q as ve,X as ye,b as Ee,J as ge}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as W,z as yt,v as bt,U as Xe}from"../packem_shared/index-0dnGN3GP.js";import{L as jt,M as St,N as Ct,K as $t,C as Et,P as Rt,Q as Le,p as d,q as Tt,S as O}from"./cli-main.js";import{i as At}from"../packem_shared/index-BjdW45xX.js";import{j as i,X as u,O as r,r as L,d as It,o as Nt,a as Qe,R as Pt,f as Ot}from"../packem_shared/registry-CyYhBUaF.js";import{x as Ft}from"../packem_shared/xxh3-BLHlvhgT.js";import{h as _t,g as Lt,s as Be,e as et}from"../packem_shared/env-D3wteXlq.js";import{y as be}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as tt}from"../packem_shared/package-version-COyEFX59.js";import{findVisConfigFile as zt}from"./CONFIG_FILES.js";import{d as Ne,c as Ve,r as Bt,b as Vt,a as Ht,e as Ut,f as Wt,m as Yt}from"./handler71.js";import{d as st,n as Gt}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{c as Kt}from"../packem_shared/env-consistency-1rRSdrFI.js";import{c as qt}from"../packem_shared/runtime-check-CpBsIYcl.js";import{s as Jt}from"../packem_shared/scan-progress-Blrj96LZ.js";import{l as Xt,r as Qt,f as Zt}from"../packem_shared/dependency-scan-Dv1kJ-Sn.js";import{l as it}from"../packem_shared/spinner-B30I9gQR.js";import{n as es,a as ts}from"../packem_shared/tabs-K9dH5Qdu.js";import{u as ss}from"../packem_shared/use-measured-height-D5xfIDWl.js";import{readCatalogs as nt,checkOutdated as is}from"./catalog.js";import{DEFAULT_UNTRACKED_ENV_PATTERNS as ns,resolveChildEnvPolicy as rs,createEnvMatcher as Ae,detectFrameworks as os,extractReferencedEnvVars as ls,looksLikeInputUri as as,parseInputUri as cs,CLEAN_ENV_BASE_NAMES as ds,CLEAN_ENV_POSIX_NAMES as us,CLEAN_ENV_WIN32_NAMES as hs}from"@visulima/task-runner";import{c as ps,V as fs,a as ms}from"../packem_shared/task-env-Cl4jNMCR.js";import{L as gs}from"../packem_shared/index-BisalDCf.js";import{l as xs}from"./ts-loader.js";import{s as ws}from"../packem_shared/verify-3WE9U_Bv.js";import{l as ks}from"../packem_shared/npmrc-CIvOb61L.js";import{f as vs}from"../packem_shared/osv-CI9eaGmG.js";let kt;const vt=e=>(kt??=wt(import.meta.url))(e),we=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Je=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 vt(e)},{rmSync:ze,writeFileSync:Dt,statSync:Mt,readFileSync:Ze}=Je("node:fs"),{spawnSync:Re}=Je("node:child_process"),Ie=()=>W(Lt(),"doctor"),ys=1800*1e3,He=e=>{if(!e)return"";try{return String(Mt(e).mtimeMs)}catch{return""}},bs=3,js=e=>{const t=JSON.stringify({configMtime:He(e.configPath),lockfileMtime:He(e.lockfilePath),schema:bs,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return Ft(Buffer.from(t))},Ss=e=>{const t=W(Ie(),`${e}.json`);if(be(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}},Cs=(e,t,s=ys)=>{_t(Ie());const l={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:s};Dt(W(Ie(),`${e}.json`),JSON.stringify(l,void 0,2),"utf8")},Se="orphans",$s=()=>{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"}},Es=()=>{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"}},Rs=()=>{const e=process.pid;try{return process.platform==="win32"?lt(e):ot(e)}catch{return[]}},Ts=()=>{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"}},As=(e={})=>{const t=e.enumerate??Rs,l=e.force===!0?"SIGKILL":"SIGTERM",n=e.kill??Ds,o=t(),c=[],h=[];for(const a of o)try{n(a,l),c.push(a)}catch(p){const g=p.code??p.message;if(g==="ESRCH"){c.push(a);continue}h.push({pid:a,reason:g})}return{failed:h,killed:c}},Is=e=>Re("taskkill",e,{encoding:"utf8",timeout:1e4}),Ns=(e,t)=>{process.kill(e,t)},Ps=(e,t,s=Is)=>{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)}`,c=new Error(o);throw c.code=o,c}},Os=(e,t,s=Ns)=>{s(e,t)},Ds=(e,t)=>{if(process.platform==="win32"){Ps(e,t);return}Os(e,t)},rt=(e,t)=>{const s=Re(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=rt("ps",["-Ao","pid=,command="]),s=[];for(const l of t.split(`
1
+ import{createRequire as wt}from"node:module";import{F as j,j as le,q as ve,X as ye,b as Ee,J as ge}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as W,z as yt,v as bt,U as Xe}from"../packem_shared/index-0dnGN3GP.js";import{M as jt,N as St,P as Ct,L as $t,C as Et,Q as Rt,R as Le,p as d,q as Tt,S as O}from"./cli-main.js";import{i as At}from"../packem_shared/index-BjdW45xX.js";import{j as i,X as u,O as r,r as L,d as It,o as Nt,a as Qe,R as Pt,f as Ot}from"../packem_shared/registry-DiFjkq9L.js";import{x as Ft}from"../packem_shared/xxh3-BLHlvhgT.js";import{h as _t,g as Lt,s as Be,e as et}from"../packem_shared/env-B_MqQz0I.js";import{y as be}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as tt}from"../packem_shared/package-version-ilIDuvbM.js";import{findVisConfigFile as zt}from"./CONFIG_FILES.js";import{d as Ne,c as Ve,r as Bt,b as Vt,a as Ht,e as Ut,f as Wt,m as Yt}from"./handler71.js";import{d as st,n as Gt}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{c as Kt}from"../packem_shared/env-consistency-C-gPg1z7.js";import{c as qt}from"../packem_shared/runtime-check-B2_65Qxg.js";import{s as Jt}from"../packem_shared/scan-progress-Bg2J2LtK.js";import{l as Xt,r as Qt,f as Zt}from"../packem_shared/dependency-scan-DRigy-Ce.js";import{l as it}from"../packem_shared/spinner-DqhHeEEh.js";import{n as es,a as ts}from"../packem_shared/tabs-CPZha41U.js";import{u as ss}from"../packem_shared/use-measured-height-Zz5Edg6J.js";import{readCatalogs as nt,checkOutdated as is}from"./catalog.js";import{DEFAULT_UNTRACKED_ENV_PATTERNS as ns,resolveChildEnvPolicy as rs,createEnvMatcher as Ae,detectFrameworks as os,extractReferencedEnvVars as ls,looksLikeInputUri as as,parseInputUri as cs,CLEAN_ENV_BASE_NAMES as ds,CLEAN_ENV_POSIX_NAMES as us,CLEAN_ENV_WIN32_NAMES as hs}from"@visulima/task-runner";import{c as ps,V as fs,a as ms}from"../packem_shared/task-env-Cl4jNMCR.js";import{L as gs}from"../packem_shared/index-BisalDCf.js";import{l as xs}from"./ts-loader.js";import{s as ws}from"../packem_shared/verify-3WE9U_Bv.js";import{l as ks}from"../packem_shared/npmrc-CIvOb61L.js";import{f as vs}from"../packem_shared/osv-zlqqFEue.js";let kt;const vt=e=>(kt??=wt(import.meta.url))(e),we=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Je=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 vt(e)},{rmSync:ze,writeFileSync:Dt,statSync:Mt,readFileSync:Ze}=Je("node:fs"),{spawnSync:Re}=Je("node:child_process"),Ie=()=>W(Lt(),"doctor"),ys=1800*1e3,He=e=>{if(!e)return"";try{return String(Mt(e).mtimeMs)}catch{return""}},bs=3,js=e=>{const t=JSON.stringify({configMtime:He(e.configPath),lockfileMtime:He(e.lockfilePath),schema:bs,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return Ft(Buffer.from(t))},Ss=e=>{const t=W(Ie(),`${e}.json`);if(be(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}},Cs=(e,t,s=ys)=>{_t(Ie());const l={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:s};Dt(W(Ie(),`${e}.json`),JSON.stringify(l,void 0,2),"utf8")},Se="orphans",$s=()=>{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"}},Es=()=>{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"}},Rs=()=>{const e=process.pid;try{return process.platform==="win32"?lt(e):ot(e)}catch{return[]}},Ts=()=>{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"}},As=(e={})=>{const t=e.enumerate??Rs,l=e.force===!0?"SIGKILL":"SIGTERM",n=e.kill??Ds,o=t(),c=[],h=[];for(const a of o)try{n(a,l),c.push(a)}catch(p){const g=p.code??p.message;if(g==="ESRCH"){c.push(a);continue}h.push({pid:a,reason:g})}return{failed:h,killed:c}},Is=e=>Re("taskkill",e,{encoding:"utf8",timeout:1e4}),Ns=(e,t)=>{process.kill(e,t)},Ps=(e,t,s=Is)=>{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)}`,c=new Error(o);throw c.code=o,c}},Os=(e,t,s=Ns)=>{s(e,t)},Ds=(e,t)=>{if(process.platform==="win32"){Ps(e,t);return}Os(e,t)},rt=(e,t)=>{const s=Re(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=rt("ps",["-Ao","pid=,command="]),s=[];for(const l of t.split(`
2
2
  `)){if(l.length===0)continue;const n=/^\s*(\d+)\s+(.+)$/.exec(l);if(!n)continue;const o=Number.parseInt(n[1]??"",10),c=(n[2]??"").toLowerCase();!Number.isFinite(o)||o===e||(/(?:^|[ /])vis-native(?:\s|$|[-.])/.test(c)||/(?:^|[ /])vis\s+run\b/.test(c)||/(?:^|[ /])task-runner(?:\s|$|[-.])/.test(c))&&s.push(o)}return s},lt=e=>{const t=rt("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(),c=Number.parseInt(n[1]??"",10);!Number.isFinite(c)||c===e||(o==="vis.exe"||o.startsWith("vis-native")||o.includes("task-runner"))&&s.push(c)}return s},Ms=()=>{let e;try{const t=Re("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"}},Fs=(e=process.cwd())=>{let t="";try{t=Ze(W(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=Re("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"}},_s=e=>[$s(),Es(),Ms(),Fs(e),Ts()],me=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],$e=["dependencies","security","optimization","runtime"],pe=e=>{const t=new Map;for(const s of $e)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(c=>c.title.toLowerCase().includes(o))}return[...n]},Ls=e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const s of $e)e.has(s)&&(t[s]="idle");return t};class Ue{#e;#s=new Set;constructor(t=[]){const s=Array.isArray(t)?{findings:t}:t,l=s.findings??[],n=s.activeSections??new Set($e),o=$e.find(a=>n.has(a))??"dependencies",c=fe(l,o,"",void 0),h=Ls(n);if(l.length>0)for(const a of l)h[a.section]="done";this.#e={all:l,entries:c,filterActive:!1,filterText:"",filterType:o,focusedPanel:"list",grouped:pe(c),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 We={error:0,warn:1},zs=e=>!!e.acceptedRisk,at=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:s.hint?`${String(s.versions.length)} versions installed — ${s.hint}`:`${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=zs(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 We[s.severity]-We[l.severity]}),t},ct={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"},Bs={error:"red",warn:"yellow"},Vs={error:"✖",warn:"⚠"},Hs={error:" ERROR ",warn:" WARN "},Us=({children:e,hint:t,message:s,severity:l,title:n})=>{const o=Bs[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:Hs[l]}),i.jsx(r,{bold:!0,color:o,children:Vs[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]})},Ws={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},Ys={critical:"red",high:"red",low:"gray",medium:"yellow"},Gs={major:"red",minor:"yellow",patch:"green"},E=({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]}),ne=({children:e})=>i.jsx(u,{marginTop:1,children:i.jsx(r,{bold:!0,color:"white",children:e})}),Ks=({finding:e})=>{const{entry:t}=e,s=Gs[t.updateType]??"white";return i.jsxs(u,{flexDirection:"column",children:[i.jsx(E,{label:"Current",children:t.currentRange}),i.jsxs(E,{label:"Target",children:[i.jsx(r,{children:t.newRange}),i.jsxs(r,{bold:!0,color:s,children:[" (",t.updateType,")"]})]}),i.jsx(E,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?i.jsx(E,{label:"Risk ack",children:i.jsx(r,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,i.jsx(ne,{children:"Action"}),i.jsxs(r,{dimColor:!0,children:["Run"," ",i.jsx(r,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},qs=({finding:e})=>i.jsxs(u,{flexDirection:"column",children:[i.jsx(E,{label:"Versions",children:i.jsx(r,{children:String(e.pkg.versions.length)})}),i.jsx(ne,{children:"Installed versions"}),e.pkg.versions.map(t=>i.jsxs(r,{children:[" · ",t]},t)),i.jsx(ne,{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."]})]}),Js=({finding:e})=>{const t=e.entry.vulnerabilities??[];return i.jsxs(u,{flexDirection:"column",children:[i.jsx(E,{label:"Package",children:e.packageName}),i.jsx(E,{label:"Current",children:e.entry.currentRange}),i.jsx(E,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?i.jsx(E,{label:"Risk ack",children:i.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(s=>{const l=Ws[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)})]})},Xs=({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=Be(t.score.overall);return i.jsxs(u,{flexDirection:"column",children:[i.jsx(E,{label:"Package",children:e.packageName}),i.jsx(E,{label:"Overall",children:i.jsxs(r,{color:l,children:[String(s),"%"]})}),i.jsx(E,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?i.jsx(E,{label:"Risk ack",children:i.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,i.jsx(ne,{children:"Score breakdown"}),Object.entries(t.score).map(([n,o])=>{if(n==="overall")return null;const c=typeof o=="number"?o:0,h=Math.round(c*100),a=Be(c);return i.jsxs(u,{children:[i.jsx(u,{width:14,children:i.jsxs(r,{dimColor:!0,children:[n,":"]})}),i.jsxs(r,{color:a,children:[String(h),"%"]})]},n)}),i.jsx(ne,{children:"Alerts"}),t.alerts.map((n,o)=>{const c=Ys[n.severity]??"gray";return i.jsxs(u,{flexDirection:"column",marginBottom:1,children:[i.jsxs(u,{children:[i.jsx(r,{bold:!0,color:c,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)}`)})]})},Qs=({finding:e})=>{const{entry:t}=e;return i.jsxs(u,{flexDirection:"column",children:[i.jsx(E,{label:"Package",children:t.packageName}),i.jsx(E,{label:"Category",children:t.category}),i.jsx(E,{label:"Replacement",children:t.replacement}),t.overrideSpec?i.jsx(E,{label:"Override",children:t.overrideSpec}):null,i.jsx(E,{label:"Codemod",children:i.jsx(r,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?i.jsx(E,{label:"Guide",children:i.jsx(r,{color:"cyan",underline:!0,children:t.docUrl})}):null,i.jsx(ne,{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."})]})},Zs=({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(E,{label:"Check",children:t.id}),i.jsx(E,{label:"Status",children:i.jsx(r,{color:s,children:t.status})}),i.jsx(ne,{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(ne,{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]})},ei=({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(qs,{finding:e});break}case"optimization":{n=i.jsx(Qs,{finding:e});break}case"outdated":{n=i.jsx(Ks,{finding:e});break}case"runtime":{n=i.jsx(Zs,{finding:e});break}case"socket":{n=i.jsx(Xs,{finding:e});break}case"vulnerability":{n=i.jsx(Js,{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:[" ",ct[e.section]]})]}),i.jsxs(jt,{flexGrow:1,flexShrink:1,paddingX:2,ref:s,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[i.jsx(r,{}),n]})]})},dt={error:"red",warn:"yellow"},ti={error:"✖",warn:"⚠"},si=e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,ii=({finding:e,isSelected:t})=>{const s=dt[e.severity],l=si(e);return i.jsxs(u,{flexShrink:0,height:1,children:[i.jsx(r,{children:t?">":" "}),i.jsxs(r,{color:s,children:[" ",ti[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]})},ni=({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:ct[t].toUpperCase()}),i.jsxs(r,{dimColor:!0,children:[" (",e,")"]})]}),ri=({count:e,label:t,status:s})=>{const l=s==="running";return i.jsxs(r,{children:[t,l?i.jsxs(r,{children:[" ",i.jsx(it,{type:"dots"})]}):null,s==="error"?i.jsx(r,{bold:!0,color:"red",children:" ✖"}):i.jsxs(r,{dimColor:!0,children:[" (",String(e),")"]})]})},oi=({elapsedMs:e,entries:t,filterActive:s,filterText:l,filterType:n,focused:o,fromCache:c=!1,grouped:h,onViewportHeightChange:a,scrollOffset:p,sectionCounts:g,sectionMessage:S,sectionStatus:y,selectedIndex:R,severityFilter:v,totalAll:m,viewportHeight:T})=>{const A=o?"white":"gray",{measuredHeight:D,ref:I}=ss(T,a);let C=0,_=0;for(const b of t)b.severity==="error"?C+=1:b.severity==="warn"&&(_+=1);const Y=[];C>0&&Y.push(`${String(C)} error${C===1?"":"s"}`),_>0&&Y.push(`${String(_)} warn${_===1?"":"s"}`);const ee=Y.length>0?` (${Y.join(", ")})`:"",te=(e/1e3).toFixed(1),G=[];for(const[b,$]of h){G.push(i.jsx(ni,{count:$.length,section:b},`hdr-${b}`));for(const V of $){const N=t.indexOf(V);G.push(i.jsx(ii,{finding:V,isSelected:N===R},V.id))}}let J=0;for(const[,b]of h)J+=2+b.length;const B=J>D&&D>0;return i.jsxs(u,{borderColor:A,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]}),v?i.jsx(r,{bold:!0,color:dt[v],inverse:!0,children:` ${v.toUpperCase()} ONLY `}):null,c?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(es,{isFocused:o,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:()=>{},showIndex:!1,value:n,children:me.map(({id:b,label:$})=>i.jsx(ts,{name:b,children:i.jsx(ri,{count:g[b],label:$,status:y[b]})},b))})}),(()=>{const b=Object.keys(y).filter($=>y[$]==="running"&&S[$]).map($=>S[$]);return b.length===0?null:i.jsx(u,{flexShrink:0,paddingX:1,children:i.jsxs(r,{dimColor:!0,wrap:"truncate",children:[i.jsx(it,{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:I,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."})})})}),B&&i.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:i.jsx(St,{contentHeight:J,placement:"inset",scrollOffset:p,style:"block",viewportHeight:D})})]},`list-${n}-${l}`)]})},li=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)`}},ai=e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},ci=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
3
  `);return{command:s,configSnippet:s,description:`Acknowledge risk for ${t}`}},di=100,ui=40,hi=10,pi=({autoExitSeconds:e=0,banner:t,fromCache:s=!1,startedAt:l,store:n})=>{const{exit:o}=Ct(),{columns:c,rows:h}=$t(),a=L.useSyncExternalStore(n.subscribe,n.getSnapshot),[p,g]=L.useState(!1),[S,y]=L.useState(!1),[R,v]=L.useState(0),[m,T]=L.useState(()=>Date.now());L.useEffect(()=>{const w=setInterval(()=>{T(Date.now())},1e3);return()=>{clearInterval(w)}},[]);const A=m-l,D=L.useRef(null),I=L.useRef(null),C=a.entries[a.selectedIndex]??null,_=L.useMemo(()=>{const w={dependencies:0,optimization:0,runtime:0,security:0};for(const x of a.all)w[x.section]+=1;return w},[a.all]),Y=t?t.hint?5:4:0,ee=L.useMemo(()=>{for(const w of Object.keys(a.sectionStatus))if(a.sectionStatus[w]==="running"&&a.sectionMessage[w])return 1;return 0},[a.sectionStatus,a.sectionMessage]),te=c>=di,G=te?Math.max(1,h-Y-2):Math.floor(h*.55),J=Math.max(1,G-6-ee-(a.filterActive?1:0)),[B,b]=L.useState(J),$=B>0?B:J,V=L.useMemo(()=>{let w=0;for(const[,x]of a.grouped)w+=2+x.length;return w},[a.grouped]),N=Math.max(0,V-$),oe=Math.min(R,N),z=L.useCallback(w=>{let x=0,k=0;for(const[,xe]of a.grouped){x+=2;for(let he=0;he<xe.length;he++){if(k===w)return x;x+=1,k+=1}}return x},[a.grouped]),X=L.useCallback(w=>{const x=z(w);v(k=>x>k+$-2?Math.min(N,Math.max(0,x-$+2)):x<k+1?Math.max(0,x-1):k)},[z,$,N]);if(L.useEffect(()=>{I.current?.scrollToTop()},[C?.id]),Et((w,x)=>{if(w==="c"&&x.ctrl){o();return}if(!S){if(p){x.escape||w==="?"?g(!1):w==="q"?(g(!1),y(!0)):x.downArrow||w==="j"?D.current?.scrollBy(1):(x.upArrow||w==="k")&&D.current?.scrollBy(-1);return}if(w==="?"){g(!0);return}if(w==="q"){y(!0);return}if(x.tab){n.setFocusedPanel(a.focusedPanel==="list"?"detail":"list");return}if(a.filterActive){if(x.escape||x.return){n.setFilterActive(!1);return}if(x.backspace){v(0),n.setFilter(a.filterText.slice(0,-1));return}w&&!x.ctrl&&!x.meta&&(v(0),n.setFilter(a.filterText+w));return}if(a.focusedPanel==="list"&&(x.leftArrow||x.rightArrow)){const k=me.findIndex(he=>he.id===a.filterType),xe=x.rightArrow?(k+1)%me.length:(k-1+me.length)%me.length;v(0),I.current?.scrollToTop(),n.setFilterType(me[xe].id);return}if(a.focusedPanel==="list"){if(x.downArrow||w==="j"){const k=Math.min(a.selectedIndex+1,a.entries.length-1);n.setSelectedIndex(k),X(k);return}if(x.upArrow||w==="k"){const k=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(k),X(k);return}if(x.pageDown){const k=Math.min(a.selectedIndex+10,a.entries.length-1);n.setSelectedIndex(k),X(k);return}if(x.pageUp){const k=Math.max(a.selectedIndex-10,0);n.setSelectedIndex(k),X(k);return}if(x.home){n.setSelectedIndex(0),v(0);return}if(x.end){const k=a.entries.length-1;n.setSelectedIndex(k),X(k);return}if(w==="/"){n.setFilterActive(!0);return}if(w==="e"){n.setSeverityFilter(a.severityFilter==="error"?void 0:"error"),v(0);return}if(w==="w"){n.setSeverityFilter(a.severityFilter==="warn"?void 0:"warn"),v(0);return}if(w==="u"&&C){const k=li(C);k&&(n.setPendingAction(k),o());return}if(w==="o"&&C){const k=ai(C);k&&(n.setPendingAction(k),o());return}if(w==="a"&&C){const k=ci(C);k&&(n.setPendingAction(k),o());return}if(w==="d"){n.setFocusedPanel("detail");return}return}if(x.escape||x.leftArrow){n.setFocusedPanel("list");return}if(x.downArrow||w==="j"){I.current?.scrollBy(1);return}if(x.upArrow||w==="k"){I.current?.scrollBy(-1);return}if(x.pageDown){I.current?.scrollBy(10);return}if(x.pageUp){I.current?.scrollBy(-10);return}if(x.home){I.current?.scrollToTop();return}x.end&&I.current?.scrollToBottom()}},{isActive:!0}),c<ui||h<hi)return i.jsx(u,{alignItems:"center",height:h,justifyContent:"center",width:c,children:i.jsxs(r,{color:"yellow",children:["Terminal too small (",c,"x",h,")"]})});const ae=a.focusedPanel==="detail",P=[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:ae?"SCROLL":"NAV"})]},"nav"),ae?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:P})}),K=i.jsxs(Rt,{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:D,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"})]})]})]}),ce=i.jsx(oi,{elapsedMs:A,entries:a.entries,filterActive:a.filterActive,filterText:a.filterText,filterType:a.filterType,focused:a.focusedPanel==="list",fromCache:s,grouped:a.grouped,onViewportHeightChange:b,scrollOffset:oe,sectionCounts:_,sectionMessage:a.sectionMessage,sectionStatus:a.sectionStatus,selectedIndex:a.selectedIndex,severityFilter:a.severityFilter,totalAll:a.all.length,viewportHeight:$}),de=t?i.jsx(Us,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,ue=i.jsx(ei,{finding:C,focused:a.focusedPanel==="detail",scrollRef:I});if(te){const w=Math.floor(c*.4);return i.jsxs(u,{flexDirection:"column",height:h,width:c,children:[de,i.jsxs(u,{flexDirection:"row",flexGrow:1,children:[i.jsx(u,{flexGrow:1,children:ce}),i.jsx(u,{width:w,children:ue})]}),H,i.jsx(Le,{autoExitSeconds:e||3,onCancel:()=>{y(!1)},visible:S}),K]})}return i.jsxs(u,{flexDirection:"column",height:h,width:c,children:[de,i.jsx(u,{height:G,children:ce}),i.jsx(u,{flexGrow:1,children:ue}),H,i.jsx(Le,{autoExitSeconds:e||3,onCancel:()=>{y(!1)},visible:S}),K]})},fi=8,mi=Ae([...ds,...us,...hs,...fs,...Object.keys(ms),"VIS_*"]),gi=/(?<![\w%])%([A-Z_]\w+)%(?![\w%])/gi,xi=e=>[...new Set([...e.matchAll(gi)].map(t=>t[1]))],wi=(e,t)=>{const s=new Set(ls(e)),l=new Set(xi(e)),n=[];for(const o of new Set([...s,...l]))t.excluded(o)||!t.visible(o)||t.exact.has(o)||t.coveredByPattern(o)||(l.has(o)||s.has(o)&&!t.autoEnvVars)&&n.push({name:o,shellOnly:!l.has(o)});return n},ut=(e,t,s=new Set)=>{const l=[];for(const n of e)if(typeof n=="string")if(as(n)){let o;try{o=cs(n)}catch{continue}o&&"env"in o&&l.push(o.env)}else t[n]&&!s.has(n)&&(s.add(n),l.push(...ut(t[n],t,s)));else typeof n=="object"&&n!==null&&"env"in n&&typeof n.env=="string"&&l.push(n.env);return l},ki=async e=>(await os(e)).flatMap(s=>s.envPrefixes.map(l=>`${l}*`)),vi=e=>e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e.at(-1)}`,yi=e=>{const t=e.total-e.variables.length,s=t>0?` (+${String(t)} more)`:"";return`${e.target}: ${e.variables.join(", ")}${s}. fix: ${vi(e.hints)}`},bi=e=>e.targets.map(t=>yi(t)),ji=(e,t)=>{const s=["fingerprintEnv"];return t.some(l=>l.shellOnly)&&s.push("autoEnvVars"),s.push("untrackedEnv"),{hints:s,target:e,total:t.length,variables:t.map(l=>l.name).toSorted().slice(0,fi)}},Si=async(e,t)=>{const s=e.taskRunner??{},l=[];if(s.autoFingerprint===!0)return{status:"ok",targets:l};if(Ne(t).length===0)return{status:"ok",targets:l};const{projectOptions:n,workspace:o}=It(t,e,await Nt(t,e)),c=[...s.envVars??[],...s.globalEnv??[]],h=[...ns,...s.untrackedEnvVars??[]],a=e.namedInputs??{};for(const[p,g]of n){const S=o.projects[p];if(!S)continue;const y=s.frameworkInference?await ki(W(t,S.root,"package.json")):[];for(const[R,v]of Object.entries(g)){if(v.hashMode==="trace"||v.cache===!1||v.always===!0)continue;const m=v.command??s.targetDefaults?.[R]?.command;if(typeof m!="string"||m.length===0)continue;const T=v.inputs??s.targetDefaults?.[R]?.inputs??[],A=rs(s.env,v.options?.env),D=Ae([...h,...v.untrackedEnv??[]]),I=wi(m,{autoEnvVars:s.autoEnvVars===!0,coveredByPattern:Ae([...v.fingerprintEnv??[],...y]),exact:new Set([...c,...ut(T,a)]),excluded:C=>mi(C)||D(C),visible:A.mode==="clean"?ps(A.allow):()=>!0});I.length>0&&l.push(ji(`${p}:${R}`,I))}}return l.sort((p,g)=>p.target.localeCompare(g.target)),{status:l.length>0?"warn":"ok",targets:l}},Ci=e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),$i=e=>{const t=e.split("*").map(s=>Ci(s));return new RegExp(`^${t.join(".*")}$`,"i")},Ei=e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>$i(t)):[],Ce=(e,t)=>{for(const s of t)if(s.test(e))return!0;return!1},Ri=(e,t,s)=>{if(t.length===0)return e;const l=e.outdated.filter(p=>Ce(p.packageName,t)),n=e.duplicates.filter(p=>Ce(p.name,t)),o=e.optimizations.filter(p=>Ce(p.packageName,t));let c=0,h=0,a=0;for(const p of l)p.vulnerabilities&&(c+=p.vulnerabilities.length),p.socketReport&&(h+=p.socketReport.alerts.length,p.socketReport.score.overall<s&&(a+=1));return{...e,duplicates:n,optimizations:o,outdated:l,socketIssues:{alerts:h,lowScore:a},vulnCount:c}},ht=(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 Ce(l,t)}),pt=["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();pt.includes(l)&&t.add(l)}return t},Ti=(e,t)=>{if(e!==void 0&&e!=="")return Ye(e);const s=Ye(t);return new Set(pt.filter(l=>!s.has(l)))},ft=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"}},Ai=(e,t)=>{const s=ft(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.envCoverage.status,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,...e.envCoverage.targets.length>0?{envCoverage:{status:e.envCoverage.status,targets:e.envCoverage.targets.map(c=>({hints:c.hints,target:c.target,total:c.total,variables:c.variables}))}}:{},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(c=>({detail:c.detail,id:c.id,message:c.message,status:c.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(c=>({detail:c.detail,label:c.label,severity:c.severity})),status:e.supplyChain.status},workspaces:e.workspaceCount}},Ge=(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||e.envCoverage.targets.length>0:l},Ii=["aube-workspace.yaml","pnpm-workspace.yaml"],ke=e=>typeof e=="boolean"?e:void 0,Ni=e=>{if(e==="no-downgrade"||e==="off")return e},Pi=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 Ii){const l=W(e,s);if(!be(l))continue;let n;try{n=gs(yt(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},Oi=e=>e.paranoid?{...e,jailBuilds:!0,minimumReleaseAgeStrict:!0,strictDepBuilds:!0,trustPolicy:"no-downgrade"}:e,Di=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,Mi=e=>{const t=Di.exec(e);if(t)return{name:t[1],version:t[2]}},Fi=(e,t)=>{let s;try{if(t==="pnpm"){const n=W(e,"pnpm-workspace.yaml");be(n)&&(s=xs(n)?.patchedDependencies)}else if(t==="bun"){const n=W(e,"package.json");be(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 c=Mi(n);c&&l.push({name:c.name,patchFile:o,resolvedPatchFile:bt(o)?o:Xe(e,o),version:c.version})}return l},_i=e=>{const t=[];for(const s of e)be(s.resolvedPatchFile)||t.push({entry:s,kind:"missing-file"});return t},Ke=e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok",Li=(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:Ke(s)};const n=l.policies?.firstSeen?.minutes,o=l.policies?.publisherChange,c=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=c?.allow?Object.keys(c.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"}),c?.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 a=ws(t.workspaceRoot);if(a.length>0){const p=[...new Set(a.map(g=>g.tool))].sort((g,S)=>g.localeCompare(S)).join(", ");s.push({detail:"Run `vis migrate verify` for the full list, then re-run `vis migrate <tool>` to clean up.",label:`${String(a.length)} leftover ${a.length===1?"reference":"references"} to ${p}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager==="aube"){const a=Pi(t.workspaceRoot),p=Oi(a),g=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${g}`,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${g}`,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${g}`,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${g}`,severity:"warn"}),p.jailBuilds===!0&&s.push({label:`aube jailBuilds: true${g}`,severity:"ok"}),p.strictDepBuilds===!0&&s.push({label:`aube strictDepBuilds: true${g}`,severity:"ok"}),p.allowBuildsCount>0&&s.push({label:`aube allowBuilds: ${String(p.allowBuildsCount)} ${p.allowBuildsCount===1?"entry":"entries"}${g}`,severity:"ok"})}if(t.workspaceRoot&&t.packageManager){const a=Fi(t.workspaceRoot,t.packageManager);if(a.length>0){const p=_i(a);if(p.length===0)s.push({label:`patchedDependencies: ${String(a.length)} ${a.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const g of p)s.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${g.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${g.entry.name}@${g.entry.version}`,severity:"error"})}}return{findings:s,status:Ke(s)}},U=e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,je=async(e,t,s,l)=>{if(!e)return s();e.start(t);const n=Date.now();try{const o=await s(),c=Date.now()-n,{status:h,summary:a}=l(o,c);return e.finish(t,h,a),o}catch(o){const c=Date.now()-n,h=o instanceof Error?o.message:String(o);throw e.finish(t,"error",`${h} (${U(c)})`),o}},zi=(e,t)=>{const s={duplicates:t.duplicates,optimizations:t.optimizations,outdated:t.outdated,runtime:t.runtime,sections:new Set([e])};return at(s)},qe=async e=>{const{filterPatterns:t,installed:s,progress:l,resolveCodemods:n,sections:o,store:c,visConfig:h,workspaceRoot:a}=e,p=o.has("dependencies"),g=o.has("security"),S=o.has("optimization"),y=o.has("runtime"),R=(f,M)=>ht(zi(f,M),t),v=st(a),m=v.name,T=Ve(W(a,"package.json"),!1),A=Ne(a),D=new Set(T);for(const f of A){const M=Ve(W(Xe(a,f),"package.json"),!1);for(const F of M)D.add(F)}const I=ks(a),C=nt(a,m),_=Qe(h?.security,{minimumScore:h?.security?.policies?.score?.minimum}),Y=h?.security?.policies?.score?.minimum??et,ee=h?.security?.acceptedRisks,te=Bt(a,v.name),G={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},J=p?Zt(a,v.name):[],B=S?Vt(D):[],b=S?Ht(D,te,v,!1):[],$=new Set(B.map(f=>f.packageName)),V=b.filter(f=>!$.has(f.packageName)),N=[...B,...V],oe=y?[..._s(a),...Kt(a)]:[];c&&(p&&c.startSection("dependencies",C.size>0?"checking outdated catalog dependencies":"scanning duplicates"),g&&c.startSection("security",s.length>0?`scanning ${String(s.length)} packages for advisories`:"no installed packages to scan"),S&&c.startSection("optimization","matching e18e + socket overrides"),y&&c.startSection("runtime","running runtime diagnostics")),c&&y&&c.completeSection("runtime",R("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:oe}));const X=(p||g)&&C.size>0?je(l,"outdated",()=>is(C,G,I,void 0,a,_,ee),(f,M)=>{const F=f.outdated.length;return{status:F>0?"warn":"ok",summary:F>0?`${String(F)} outdated · ${U(M)}`:`up to date · ${U(M)}`}}):Promise.resolve({checkedCount:0,failed:[],filteredByTarget:[],ignored:[],outdated:[]}),ae=g&&s.length>0?je(l,"vulnerabilities",()=>vs(s.map(f=>({name:f.name,version:f.version}))),(f,M)=>{let F=0;for(const se of f.values())F+=se.length;return{status:F>0?"error":"ok",summary:F>0?`${String(F)} found · ${U(M)}`:`none found · ${U(M)}`}}):Promise.resolve(new Map),P=g&&_.length>0&&s.length>0?je(l,"socket",()=>Ot(_,s.map(f=>({name:f.name,version:f.version}))),(f,M)=>{let F=0,se=0;for(const _e of f.values())F+=_e.alerts.length,_e.score.overall<Y&&(se+=1);const Fe=F+se;return{status:Fe>0?"warn":"ok",summary:Fe>0?`${String(F)} alert${F===1?"":"s"}, ${String(se)} low-score · ${U(M)}`:`clean · ${U(M)}`}}):Promise.resolve(new Map);let H,K,ce,de;const ue=X.catch(f=>(H=f instanceof Error?f.message:String(f),c||d.warn(`Outdated scan failed: ${H}`),{failed:[],ignored:[],outdated:[]})),w=ae.catch(f=>(K=f instanceof Error?f.message:String(f),c||d.warn(`Vulnerability scan failed: ${K}`),new Map)),x=P.catch(f=>(ce=f instanceof Error?f.message:String(f),c||d.warn(`Socket scan failed: ${ce}`),new Map)),k=c&&p?ue.then(f=>{if(H){c.failSection("dependencies",H);return}c.completeSection("dependencies",R("dependencies",{duplicates:J,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,xe=c&&g?Promise.all([ue,w,x]).then(([f])=>{const M=H??K??ce;if(M){c.failSection("security",M);return}c.completeSection("security",R("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,he=(async()=>{if(n&&S&&N.length>0&&await je(l,"codemods",async()=>(await Yt(N),N),(f,M)=>{const F=f.filter(se=>se.hasCodemod||se.category==="socket").length;return{status:"ok",summary:`${String(F)} auto-fixable · ${U(M)}`}}).catch(f=>{de=f instanceof Error?f.message:String(f)}),c&&S){if(de){c.failSection("optimization",de);return}c.completeSection("optimization",R("optimization",{duplicates:[],optimizations:N,outdated:[],runtime:[]}))}})(),[Oe,gt,xt]=await Promise.all([ue,w,x]);await Promise.all([k,xe,he]);let De=0,Me=0;if(g&&_.length>0)for(const f of xt.values())De+=f.alerts.length,f.score.overall<Y&&(Me+=1);let Te=0;if(g){for(const f of Oe.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Te+=f.vulnerabilities.length);for(const f of gt.values())Te+=f.length}return{duplicates:J,installedCount:s.length,optimizations:S?N:[],outdated:p?Oe.outdated:[],runtime:oe,sections:o,socketIssues:{alerts:De,lowScore:Me},supplyChain:Li(h,{packageManager:m,workspaceRoot:a}),vulnCount:Te,workspaceCount:A.length}},Bi=e=>{switch(e){case"error":return ye(O.failure);case"skip":return j(O.dash);case"warn":return Ee(O.warning);default:return ge(O.success)}},re=(e,t)=>{const s=process.stderr.columns??80,l=Math.max(20,Math.min(s-2,60)),n=O.dash.repeat(2),o=`${Bi(t)} ${le(e)}`,c=o.replaceAll(/\[[0-9;]*m/g,"").length,h=Math.max(0,l-c-n.length-2);return`${n} ${o} ${j(O.dash.repeat(h))}`},Z=e=>` ${ge(O.success)} ${e}`,q=e=>` ${Ee(O.warning)} ${e}`,Pe=e=>` ${ye(O.failure)} ${e}`,mt=e=>` ${j(O.dash)} ${j(e)}`,Q=(e,t,s)=>{const l=`${le(String(e))} ${j(t)}`;return s?`${l} ${j(`(${s})`)}`:l},Vi=e=>{if(e.sections.has("dependencies")){if(d.log(""),d.log(re("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(q(Q(e.outdated.length,"outdated",n.join(", "))))}else d.log(Z("All dependencies up to date"));if(e.duplicates.length>0){d.log(q(Q(e.duplicates.length,"packages with duplicate versions")));for(const t of e.duplicates)t.hint&&d.log(` ${j(O.arrow)} ${t.hint}`)}else d.log(Z("No duplicate dependencies"))}},Hi=e=>{e.sections.has("security")&&(d.log(""),d.log(re("Security",ie(e,"security"))),e.vulnCount>0?d.log(Pe(Q(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):d.log(Z("No known vulnerabilities")),e.socketIssues.alerts>0&&d.log(q(Q(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&d.log(q(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")))},Ui=e=>{if(!e.sections.has("optimization"))return;d.log(""),d.log(re("Optimization",ie(e,"optimization")));const t=ft(e.optimizations);if(t.total===0){d.log(Z("No optimizations available"));return}t.native>0&&d.log(q(Q(t.native,"replaceable with native APIs"))),t.preferred>0&&d.log(q(Q(t.preferred,"with lighter alternatives"))),t.micro>0&&d.log(q(Q(t.micro,"trivial micro-utilities"))),t.socket>0&&d.log(q(Q(t.socket,"@socketregistry overrides available")))},Wi=e=>{d.log(""),d.log(re("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const s=t.severity==="ok"?Z(t.label):t.severity==="error"?Pe(t.label):q(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.")}`)},Yi=e=>{const t=bi(e.envCoverage);if(t.length!==0){d.log(""),d.log(re("Env Coverage","warn"));for(const s of t)d.log(q(s))}},Gi=e=>{if(e.sections.has("runtime")){d.log(""),d.log(re("Runtime",ie(e,"runtime")));for(const t of e.runtime)t.status==="ok"?d.log(Z(t.message)):t.status==="skip"?d.log(mt(t.message)):d.log(q(t.message))}},Ki=(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(`(${U(e.elapsedMs)})`)}`);else{const o=[];s>0&&o.push(ye(`${String(s)} security`)),n>0&&o.push(Ee(`${String(n)} improvement${n===1?"":"s"}`)),d.log(`${ye(O.failure)} ${o.join(", ")} ${j(`(${U(e.elapsedMs)})`)}`)}return}d.log(""),d.log(re("Summary","ok")),s===0&&n===0?d.success(`Everything looks good! ${j(`(${U(e.elapsedMs)})`)}`):(s>0&&d.error(`${String(s)} security issue${s===1?"":"s"}`),n>0&&d.log(` ${ve(O.arrow)} ${le(String(n))} ${j(`improvement${n===1?"":"s"} available`)} ${j(`(${U(e.elapsedMs)})`)}`))},qi=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(le("Next steps:"));for(const s of t)d.log(` ${j(O.arrow)} ${s}`)}d.log("")},Ji=(e,t)=>{t||(Vi(e),Hi(e),Ui(e),Gi(e),Wi(e),Yi(e)),Ki(e,t)},Xi=(e,t,s,l,n)=>{const o=[],c=e.has("dependencies"),h=e.has("security"),a=e.has("optimization");return(c||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"}),a&&n&&o.push({id:"codemods",label:"Codemod availability"}),o},Qi=e=>{if(d.log(""),d.log(`${le(ve("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"?ye:Ee;d.log(Pe(`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("")},Tn=async({fs:e,logger:t,options:s,visConfig:l,visConfigError:n,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root.");const c=s.format==="json"||s.json,h=Ti(s.only,s.skip),a=!!s.quiet,p=s.progress===!1,g=Ei(s.filter);if(h.size===0){d.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const S=Date.now(),y=st(o),R=qt(o),v=!!process.stdout.isTTY,m=!c&&v&&!At&&!a&&!p;!c&&!m&&Qi({nodeVersion:process.versions.node,packageManagerName:y.name,packageManagerVersion:y.version,runtimeFindings:R});const T=nt(o,y.name),A=Xt(o,y.name),D=A.length,I=Qe(l?.security).length>0,C=l?.security?.policies?.score?.minimum??et,_=Ne(o);if(!c&&!a&&!m){const P=_.length>0?j(` · ${String(_.length)} workspace package${_.length===1?"":"s"}`):"";d.log(`${j("·")} ${j("Found")} ${le(String(D))} ${j(`installed package${D===1?"":"s"}`)}${P}`)}const Y=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=Qt(o,y.name)?.file,te=ee?W(o,ee):void 0,G=zt(o),B=s.cache!==!1&&!s.fix?js({configPath:G,lockfilePath:te,sections:h,socketEnabled:I,workspaceRoot:o}):void 0,b=B?Ss(B):void 0,$=b!==void 0;let V,N;if(m){const P=b?new Ue({activeSections:h,findings:ht(at(b),g)}):new Ue({activeSections:h}),H=Tt(Pt.createElement(pi,{banner:Y,fromCache:$,startedAt:S,store:P}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{V=b??await qe({filterPatterns:g,installed:A,resolveCodemods:!!s.fix,sections:h,store:P,visConfig:l,workspaceRoot:o})}catch(K){throw H.unmount(),K}await H.waitUntilExit(),N=P.getSnapshot().pendingAction}else if(b)V=b;else{const P=Xi(h,T.size,I,D,!!s.fix),K=Jt(P,{live:!c&&!a&&!p});try{V=await qe({filterPatterns:g,installed:A,progress:K,resolveCodemods:!!s.fix,sections:h,visConfig:l,workspaceRoot:o})}finally{K.stop()}}const oe={...V,elapsedMs:Date.now()-S,envCoverage:await Si(l??{},o).catch(P=>(d.warn(`Env coverage check failed: ${P instanceof Error?P.message:String(P)}`),{status:"ok",targets:[]}))};if(B&&!$)try{Cs(B,oe)}catch{}const z=Ri(oe,g,C);if(c){process.stdout.write(`${JSON.stringify(Ai(z,y.name),void 0,2)}
4
4
  `),s.exitCode&&Ge(z,!!s.strict)&&(process.exitCode=1);return}$&&!a&&d.log(`${j("·")} Cached results (use --no-cache to refresh)`),g.length>0&&!a&&d.log(`${j("·")} Filter active: ${ve(s.filter??"")}`),Ji(z,a);const X=z.runtime.some(P=>P.id===Se&&P.status==="warn"),ae=z.sections.has("optimization")&&z.optimizations.length>0;s.fix&&(ae||X)?await Zi({force:!!s.fixForce,fs:e,logger:t,pm:y,recoverOrphans:X,results:z,useEditorconfig:l?.editorconfig??!0,workspaceRoot:o}):a||qi(z),N&&(process.stdout.write(`