@visulima/vis 5.0.0 → 6.0.0

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 (162) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/LICENSE.md +151 -88
  3. package/README.md +2 -2
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +1 -1
  6. package/dist/config/index.d.ts +16 -18
  7. package/dist/packem_chunks/CONFIG_FILES.js +4 -4
  8. package/dist/packem_chunks/bloom-status.js +1 -1
  9. package/dist/packem_chunks/bloom-sync.js +1 -1
  10. package/dist/packem_chunks/catalog.js +61 -51
  11. package/dist/packem_chunks/cli-exec.js +1 -1
  12. package/dist/packem_chunks/cli-main.js +202 -176
  13. package/dist/packem_chunks/dart-plan.js +1 -1
  14. package/dist/packem_chunks/dart-projects.js +1 -1
  15. package/dist/packem_chunks/dispatch.js +1 -1
  16. package/dist/packem_chunks/doctor-probe.js +1 -1
  17. package/dist/packem_chunks/fix.js +1 -1
  18. package/dist/packem_chunks/handler.js +1 -1
  19. package/dist/packem_chunks/handler10.js +4 -4
  20. package/dist/packem_chunks/handler11.js +1 -1
  21. package/dist/packem_chunks/handler12.js +1 -1
  22. package/dist/packem_chunks/handler13.js +1 -1
  23. package/dist/packem_chunks/handler14.js +1 -1
  24. package/dist/packem_chunks/handler15.js +1 -1
  25. package/dist/packem_chunks/handler16.js +1 -1
  26. package/dist/packem_chunks/handler17.js +1 -1
  27. package/dist/packem_chunks/handler18.js +1 -1
  28. package/dist/packem_chunks/handler19.js +1 -1
  29. package/dist/packem_chunks/handler2.js +1 -1
  30. package/dist/packem_chunks/handler20.js +2 -2
  31. package/dist/packem_chunks/handler21.js +1 -1
  32. package/dist/packem_chunks/handler22.js +2 -2
  33. package/dist/packem_chunks/handler23.js +1 -1
  34. package/dist/packem_chunks/handler24.js +1 -1
  35. package/dist/packem_chunks/handler26.js +3 -3
  36. package/dist/packem_chunks/handler27.js +1 -1
  37. package/dist/packem_chunks/handler28.js +1 -1
  38. package/dist/packem_chunks/handler29.js +1 -1
  39. package/dist/packem_chunks/handler3.js +1 -1
  40. package/dist/packem_chunks/handler30.js +1 -1
  41. package/dist/packem_chunks/handler39.js +6 -6
  42. package/dist/packem_chunks/handler5.js +1 -1
  43. package/dist/packem_chunks/handler50.js +2 -2
  44. package/dist/packem_chunks/handler51.js +1 -1
  45. package/dist/packem_chunks/handler53.js +1 -1
  46. package/dist/packem_chunks/handler54.js +1 -1
  47. package/dist/packem_chunks/handler55.js +1 -1
  48. package/dist/packem_chunks/handler58.js +1 -1
  49. package/dist/packem_chunks/handler59.js +1 -1
  50. package/dist/packem_chunks/handler6.js +1 -1
  51. package/dist/packem_chunks/handler60.js +7 -7
  52. package/dist/packem_chunks/handler61.js +2 -2
  53. package/dist/packem_chunks/handler62.js +2 -2
  54. package/dist/packem_chunks/handler63.js +1 -1
  55. package/dist/packem_chunks/handler64.js +2 -2
  56. package/dist/packem_chunks/handler65.js +3 -3
  57. package/dist/packem_chunks/handler66.js +2 -2
  58. package/dist/packem_chunks/handler67.js +31 -20
  59. package/dist/packem_chunks/handler68.js +1 -1
  60. package/dist/packem_chunks/handler69.js +4 -4
  61. package/dist/packem_chunks/handler7.js +1 -1
  62. package/dist/packem_chunks/handler70.js +5 -5
  63. package/dist/packem_chunks/handler71.js +1 -1
  64. package/dist/packem_chunks/handler72.js +1 -1
  65. package/dist/packem_chunks/handler73.js +1 -1
  66. package/dist/packem_chunks/handler74.js +1 -1
  67. package/dist/packem_chunks/handler75.js +36 -36
  68. package/dist/packem_chunks/handler76.js +1 -1
  69. package/dist/packem_chunks/handler77.js +3 -3
  70. package/dist/packem_chunks/handler78.js +24 -24
  71. package/dist/packem_chunks/handler8.js +1 -1
  72. package/dist/packem_chunks/handler9.js +1 -1
  73. package/dist/packem_chunks/heal-accept.js +1 -1
  74. package/dist/packem_chunks/heal.js +1 -1
  75. package/dist/packem_chunks/help-command.js +40 -7
  76. package/dist/packem_chunks/index2.js +32 -32
  77. package/dist/packem_chunks/index6.js +1 -1
  78. package/dist/packem_chunks/keys-refresh.js +1 -1
  79. package/dist/packem_chunks/lean.js +3 -4
  80. package/dist/packem_chunks/list.js +1 -1
  81. package/dist/packem_chunks/loader.js +1 -1
  82. package/dist/packem_chunks/orchestrator.js +1 -1
  83. package/dist/packem_chunks/prompts.js +1 -1
  84. package/dist/packem_chunks/status.js +1 -1
  85. package/dist/packem_chunks/sync.js +1 -1
  86. package/dist/packem_chunks/sync2.js +1 -1
  87. package/dist/packem_chunks/tripwire.js +1 -1
  88. package/dist/packem_chunks/ts-loader.js +5 -5
  89. package/dist/packem_chunks/verify-lockfile.js +1 -1
  90. package/dist/packem_shared/{affected-selection-BJXJW_3Q.js → affected-selection-DDxwjwM4.js} +1 -1
  91. package/dist/packem_shared/{affected-shas-B_kfSKss.js → affected-shas-BuaWvmsG.js} +1 -1
  92. package/dist/packem_shared/{ai-fix-BC6aIRJT.js → ai-fix-C2BhFFhi.js} +5 -5
  93. package/dist/packem_shared/{augment-B9kSZuvW.js → augment-CxUPE8KX.js} +1 -1
  94. package/dist/packem_shared/{bin-Dx8mjl3g.js → bin-Be7_QhQK.js} +1 -1
  95. package/dist/packem_shared/{build-scripts-CEDx_nJp.js → build-scripts-DxyVSkgM.js} +1 -1
  96. package/dist/packem_shared/command-runtime-BXvH5EC0.js +1 -0
  97. package/dist/packem_shared/{dart-pubspec-BK_cK2EP.js → dart-pubspec-DvmyleIr.js} +2 -2
  98. package/dist/packem_shared/{dependency-scan-B8jroa1D.js → dependency-scan-DKK3ZEZI.js} +1 -1
  99. package/dist/packem_shared/{docker-DXqV-07f.js → docker-BTuwdXaC.js} +1 -1
  100. package/dist/packem_shared/{ecosystem-gate-CeV20GSB.js → ecosystem-gate-BpQNUJzN.js} +1 -1
  101. package/dist/packem_shared/{env-consistency-Dt_uDbSP.js → env-consistency-CUBJHENL.js} +1 -1
  102. package/dist/packem_shared/{failure-log-D2x5BT8S.js → failure-log-kp0n2rbD.js} +1 -1
  103. package/dist/packem_shared/{formatBytes-BHAzNIrn-CrusHOew.js → formatBytes-BHAzNIrn-DRcKvqnb.js} +1 -1
  104. package/dist/packem_shared/{index-BzhrR_iC.js → index-BdMIfGVZ.js} +15 -15
  105. package/dist/packem_shared/index-C9ENZqH9.js +39 -0
  106. package/dist/packem_shared/{index-nEyN71oX.js → index-DQfNpt2u.js} +1 -1
  107. package/dist/packem_shared/{index-C_ScJMpb.js → index-DsSWb5XH.js} +1 -1
  108. package/dist/packem_shared/{index.server-sXNQYpsl.js → index.server-D8BLnYZO.js} +2 -2
  109. package/dist/packem_shared/{isAccessibleSync-DYKTrrvc-C-_5cgwu.js → isAccessibleSync-DYKTrrvc-BwaMhQs0.js} +1 -1
  110. package/dist/packem_shared/{lifecycle-D6PMPor-.js → lifecycle-BAhkhE2L.js} +1 -1
  111. package/dist/packem_shared/{lockfile-CiUtEbnt.js → lockfile-DHmlPGk1.js} +1 -1
  112. package/dist/packem_shared/{manifests-Du4yKlf_.js → manifests-Dd4Hoztt.js} +1 -1
  113. package/dist/packem_shared/{min-release-age-JViyQuBM.js → min-release-age-BJnOQaoF.js} +1 -1
  114. package/dist/packem_shared/{missing-package-json-Cu5YVAot.js → missing-package-json-DfzrGwe1.js} +1 -1
  115. package/dist/packem_shared/{multi-eco-lockfiles-B2X3yhyo.js → multi-eco-lockfiles-BIa6xvJc.js} +1 -1
  116. package/dist/packem_shared/{native-config-sync-TdTWjVgI.js → native-config-sync-Dr9XvxOf.js} +1 -1
  117. package/dist/packem_shared/osv-bloom-t40ra5U5.js +2 -0
  118. package/dist/packem_shared/{package-version-CiRZecQu.js → package-version-CFuNUWDG.js} +2 -2
  119. package/dist/packem_shared/{packument-Df46y5MY.js → packument-C9nRiBJf.js} +1 -1
  120. package/dist/packem_shared/pm-runner-ImwtpnWY.js +1 -0
  121. package/dist/packem_shared/{project-name-filter-CH8Ih7Qr.js → project-name-filter-C2rkW-Vn.js} +1 -1
  122. package/dist/packem_shared/{provenance-DKeR0Ig1.js → provenance-DF-ypZj3.js} +1 -1
  123. package/dist/packem_shared/{readJsonSync-CbryXYxN-EWl7_7KX.js → readJsonSync-CbryXYxN-Bm5i10UW.js} +1 -1
  124. package/dist/packem_shared/{registry-keys-DwB3ZXS_.js → registry-keys-BLuHOyZu.js} +1 -1
  125. package/dist/packem_shared/{resolve-explicit-BmV8YBE-.js → resolve-explicit-BDaQRR6o.js} +1 -1
  126. package/dist/packem_shared/resolve-runtime-Cr19Pk6L.js +1 -0
  127. package/dist/packem_shared/{run-file-UBukWaha.js → run-file-XbRCF6Mp.js} +1 -1
  128. package/dist/packem_shared/{runtime-check-1U8HrQd9.js → runtime-check-Bh5q9IrT.js} +1 -1
  129. package/dist/packem_shared/{s1ngularity-DZhkIqL4.js → s1ngularity-UCZN7skW.js} +1 -1
  130. package/dist/packem_shared/{scan-progress-CkumcBG-.js → scan-progress-DcYI76zE.js} +1 -1
  131. package/dist/packem_shared/{selectors-edwcgNl3.js → selectors-DCiEU0iv.js} +2 -2
  132. package/dist/packem_shared/{signatures-BxTMck2l.js → signatures-CicxPHN4.js} +1 -1
  133. package/dist/packem_shared/target-merge-BClIXg2k.js +14 -0
  134. package/dist/packem_shared/{target-options-DsHFmRZH.js → target-options-PgWIuJnb.js} +1 -1
  135. package/dist/packem_shared/{task-env-DzR4RkOj.js → task-env-Dl08aklA.js} +1 -1
  136. package/dist/packem_shared/toolchain-DvUxlbDz.js +5 -0
  137. package/dist/packem_shared/{typosquats-8u0drCqQ.js → typosquats-DxPzyK7u.js} +1 -1
  138. package/dist/packem_shared/{verify-B_MblU_Q.js → verify-CadR9PUk.js} +1 -1
  139. package/dist/packem_shared/{vis-update-app-BCIccZfA.js → vis-update-app-DrFWQyPn.js} +1 -1
  140. package/dist/packem_shared/{vis-user-error-Dd7hwxlW.js → vis-user-error-k7CLTpA4.js} +15 -15
  141. package/dist/packem_shared/{watch-CcTketln.js → watch-Dr_6yz3o.js} +1 -1
  142. package/dist/packem_shared/watch-loop-BId9vT7Q.js +11 -0
  143. package/dist/packem_shared/{writeFileSync-DJoHk3Ks-BPRoepNw.js → writeFileSync-DJoHk3Ks-Dhem3Uof.js} +1 -1
  144. package/dist/release/core/version-actions/index.d.ts +1 -1
  145. package/dist/release/presets.d.ts +1 -55
  146. package/dist/release/presets.js +1 -1
  147. package/dist/release/types.d.ts +1 -18
  148. package/dist/runtime/preload.js +1 -1
  149. package/index.d.ts +204 -204
  150. package/index.js +26 -26
  151. package/package.json +10 -10
  152. package/schemas/vis-config.schema.json +6 -28
  153. package/schemas/vis-release-config.schema.json +1 -12
  154. package/dist/packem_shared/Table-BB8xHTU5-BLPS917D.js +0 -11
  155. package/dist/packem_shared/command-runtime-p4IXiIf6.js +0 -1
  156. package/dist/packem_shared/index-BisalDCf.js +0 -39
  157. package/dist/packem_shared/osv-bloom-BCAX5ARR.js +0 -2
  158. package/dist/packem_shared/pm-runner-3iiQayy-.js +0 -1
  159. package/dist/packem_shared/resolve-runtime-CNiHcVtx.js +0 -1
  160. package/dist/packem_shared/target-merge-DVJl-7Qz.js +0 -4
  161. package/dist/packem_shared/toolchain-BRdpaAC4.js +0 -5
  162. package/dist/packem_shared/watch-loop-BBkg02-Q.js +0 -11
@@ -1,10 +1,10 @@
1
- import{createRequire as wt}from"node:module";import{F as S,j as le,q as ve,X as ye,b as Ee,J as ge}from"../packem_shared/index.server-sXNQYpsl.js";import{e as W,z as yt,v as bt,U as Je}from"../packem_shared/index-BzhrR_iC.js";import{aa as jt,U as St,V as Ct,W as $t,T as Et,C as Rt,X as Tt,Y as Le,p as d,q as At,S as F}from"./cli-main.js";import{i as It}from"../packem_shared/index-BjdW45xX.js";import{F as i,X as u,o as r,x as L,d as Nt,C as Ot,a as Qe,i as Ze,R as Pt,m as Dt,n as Mt,h as Ft,j as _t}from"./catalog.js";import{g as Bt,s as Be,D as tt}from"../packem_shared/formatBytes-BHAzNIrn-CrusHOew.js";import{y as be}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as st}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{h as Vt}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{findVisConfigFile as Ht}from"./CONFIG_FILES.js";import{d as Ne,c as Ve,r as Ut,b as Wt,a as Yt,e as Gt,f as Kt,m as qt}from"./handler69.js";import{d as it,n as Xt}from"../packem_shared/pm-runner-3iiQayy-.js";import{c as Jt}from"../packem_shared/env-consistency-Dt_uDbSP.js";import{c as Qt}from"../packem_shared/runtime-check-1U8HrQd9.js";import{s as Zt}from"../packem_shared/scan-progress-CkumcBG-.js";import{l as es,r as ts,f as ss}from"../packem_shared/dependency-scan-B8jroa1D.js";import{l as nt}from"../packem_shared/spinner-ukDEdGvp.js";import{n as is,a as ns}from"../packem_shared/tabs--uxJGL8N.js";import{u as rs}from"../packem_shared/use-measured-height-DUZyyias.js";import{DEFAULT_UNTRACKED_ENV_PATTERNS as os,resolveChildEnvPolicy as ls,createEnvMatcher as Ae,detectFrameworks as as,extractReferencedEnvVars as cs,looksLikeInputUri as ds,parseInputUri as us,CLEAN_ENV_BASE_NAMES as hs,CLEAN_ENV_POSIX_NAMES as ps,CLEAN_ENV_WIN32_NAMES as fs}from"@visulima/task-runner";import{c as ms,V as gs,a as xs}from"../packem_shared/task-env-DzR4RkOj.js";import{L as ws}from"../packem_shared/index-BisalDCf.js";import{l as ks}from"./ts-loader.js";import{s as vs}from"../packem_shared/verify-B_MblU_Q.js";let kt;const vt=e=>(kt??=wt(import.meta.url))(e),we=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xe=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:Lt,statSync:zt,readFileSync:et}=Xe("node:fs"),{spawnSync:Re}=Xe("node:child_process"),Ie=()=>W(Bt(),"doctor"),ys=1800*1e3,He=e=>{if(!e)return"";try{return String(zt(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 jt(Buffer.from(t))},Ss=e=>{const t=W(Ie(),`${e}.json`);if(be(t))try{const s=st(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)=>{Vt(Ie());const l={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:s};Lt(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=et("/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)},Os=(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}},Ps=(e,t,s=Ns)=>{s(e,t)},Ds=(e,t)=>{if(process.platform==="win32"){Os(e,t);return}Ps(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
- `)){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=et(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:`${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."]})]}),Xs=({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)})]})},Js=({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(Js,{finding:e});break}case"vulnerability":{n=i.jsx(Xs,{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(St,{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(nt,{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:j,sectionStatus:y,selectedIndex:R,severityFilter:v,totalAll:m,viewportHeight:T})=>{const A=o?"white":"gray",{measuredHeight:P,ref:I}=rs(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 X=0;for(const[,b]of h)X+=2+b.length;const B=X>P&&P>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(is,{isFocused:o,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:()=>{},showIndex:!1,value:n,children:me.map(({id:b,label:$})=>i.jsx(ns,{name:b,children:i.jsx(ri,{count:g[b],label:$,status:y[b]})},b))})}),(()=>{const b=Object.keys(y).filter($=>y[$]==="running"&&j[$]).map($=>j[$]);return b.length===0?null:i.jsx(u,{flexShrink:0,paddingX:1,children:i.jsxs(r,{dimColor:!0,wrap:"truncate",children:[i.jsx(nt,{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(Ct,{contentHeight:X,placement:"inset",scrollOffset:p,style:"block",viewportHeight:P})})]},`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
- `);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}=$t(),{columns:c,rows:h}=Et(),a=L.useSyncExternalStore(n.subscribe,n.getSnapshot),[p,g]=L.useState(!1),[j,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,P=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),X=Math.max(1,G-6-ee-(a.filterActive?1:0)),[B,b]=L.useState(X),$=B>0?B:X,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]),J=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]),Rt((w,x)=>{if(w==="c"&&x.ctrl){o();return}if(!j){if(p){x.escape||w==="?"?g(!1):w==="q"?(g(!1),y(!0)):x.downArrow||w==="j"?P.current?.scrollBy(1):(x.upArrow||w==="k")&&P.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),J(k);return}if(x.upArrow||w==="k"){const k=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(k),J(k);return}if(x.pageDown){const k=Math.min(a.selectedIndex+10,a.entries.length-1);n.setSelectedIndex(k),J(k);return}if(x.pageUp){const k=Math.max(a.selectedIndex-10,0);n.setSelectedIndex(k),J(k);return}if(x.home){n.setSelectedIndex(0),v(0);return}if(x.end){const k=a.entries.length-1;n.setSelectedIndex(k),J(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",O=[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:O})}),K=i.jsxs(Tt,{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:P,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:j}),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:j}),K]})},fi=8,mi=Ae([...hs,...ps,...fs,...gs,...Object.keys(xs),"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(cs(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(ds(n)){let o;try{o=us(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 as(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}=Nt(t,e,await Ot(t,e)),c=[...s.envVars??[],...s.globalEnv??[]],h=[...os,...s.untrackedEnvVars??[]],a=e.namedInputs??{};for(const[p,g]of n){const j=o.projects[p];if(!j)continue;const y=s.frameworkInference?await ki(W(t,j.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=ls(s.env,v.options?.env),P=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)||P(C),visible:A.mode==="clean"?ms(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},Oi=e=>{const t={allowBuildsCount:0,blockExoticSubdeps:void 0,jailBuilds:void 0,minimumReleaseAge:void 0,minimumReleaseAgeStrict:void 0,paranoid:void 0,source:void 0,strictDepBuilds:void 0,trustPolicy:void 0};for(const s of Ii){const l=W(e,s);if(!be(l))continue;let n;try{n=ws(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},Pi=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=ks(n)?.patchedDependencies)}else if(t==="bun"){const n=W(e,"package.json");be(n)&&(s=st(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:Je(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=vs(t.workspaceRoot);if(a.length>0){const p=[...new Set(a.map(g=>g.tool))].sort((g,j)=>g.localeCompare(j)).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=Oi(t.workspaceRoot),p=Pi(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"),j=o.has("optimization"),y=o.has("runtime"),R=(f,D)=>ht(zi(f,D),t),v=it(a),m=v.name,T=Ve(W(a,"package.json"),!1),A=Ne(a),P=new Set(T);for(const f of A){const D=Ve(W(Je(a,f),"package.json"),!1);for(const M of D)P.add(M)}const I=Dt(a),C=Qe(a,m),_=Ze(h?.security,{minimumScore:h?.security?.policies?.score?.minimum}),Y=h?.security?.policies?.score?.minimum??tt,ee=h?.security?.acceptedRisks,te=Ut(a,v.name),G={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},X=p?ss(a,v.name):[],B=j?Wt(P):[],b=j?Yt(P,te,v,!1):[],$=new Set(B.map(f=>f.packageName)),V=b.filter(f=>!$.has(f.packageName)),N=[...B,...V],oe=y?[..._s(a),...Jt(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"),j&&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 J=(p||g)&&C.size>0?je(l,"outdated",()=>Mt(C,G,I,void 0,a,_,ee),(f,D)=>{const M=f.outdated.length;return{status:M>0?"warn":"ok",summary:M>0?`${String(M)} outdated · ${U(D)}`:`up to date · ${U(D)}`}}):Promise.resolve({checkedCount:0,failed:[],filteredByTarget:[],ignored:[],outdated:[]}),ae=g&&s.length>0?je(l,"vulnerabilities",()=>Ft(s.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let M=0;for(const se of f.values())M+=se.length;return{status:M>0?"error":"ok",summary:M>0?`${String(M)} found · ${U(D)}`:`none found · ${U(D)}`}}):Promise.resolve(new Map),O=g&&_.length>0&&s.length>0?je(l,"socket",()=>_t(_,s.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let M=0,se=0;for(const _e of f.values())M+=_e.alerts.length,_e.score.overall<Y&&(se+=1);const Fe=M+se;return{status:Fe>0?"warn":"ok",summary:Fe>0?`${String(M)} alert${M===1?"":"s"}, ${String(se)} low-score · ${U(D)}`:`clean · ${U(D)}`}}):Promise.resolve(new Map);let H,K,ce,de;const ue=J.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=O.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:X,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,xe=c&&g?Promise.all([ue,w,x]).then(([f])=>{const D=H??K??ce;if(D){c.failSection("security",D);return}c.completeSection("security",R("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,he=(async()=>{if(n&&j&&N.length>0&&await je(l,"codemods",async()=>(await qt(N),N),(f,D)=>{const M=f.filter(se=>se.hasCodemod||se.category==="socket").length;return{status:"ok",summary:`${String(M)} auto-fixable · ${U(D)}`}}).catch(f=>{de=f instanceof Error?f.message:String(f)}),c&&j){if(de){c.failSection("optimization",de);return}c.completeSection("optimization",R("optimization",{duplicates:[],optimizations:N,outdated:[],runtime:[]}))}})(),[Pe,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 Pe.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Te+=f.vulnerabilities.length);for(const f of gt.values())Te+=f.length}return{duplicates:X,installedCount:s.length,optimizations:j?N:[],outdated:p?Pe.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(F.failure);case"skip":return S(F.dash);case"warn":return Ee(F.warning);default:return ge(F.success)}},re=(e,t)=>{const s=process.stderr.columns??80,l=Math.max(20,Math.min(s-2,60)),n=F.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} ${S(F.dash.repeat(h))}`},Z=e=>` ${ge(F.success)} ${e}`,q=e=>` ${Ee(F.warning)} ${e}`,Oe=e=>` ${ye(F.failure)} ${e}`,mt=e=>` ${S(F.dash)} ${S(e)}`,Q=(e,t,s)=>{const l=`${le(String(e))} ${S(t)}`;return s?`${l} ${S(`(${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"));e.duplicates.length>0?d.log(q(Q(e.duplicates.length,"packages with duplicate versions"))):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(Oe(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"?Oe(t.label):q(t.label);d.log(s),t.detail&&d.log(` ${S(F.arrow)} ${S(t.detail)}`)}e.supplyChain.status!=="ok"&&d.log(` ${S(F.arrow)} ${S("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! ${S(`(${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(F.failure)} ${o.join(", ")} ${S(`(${U(e.elapsedMs)})`)}`)}return}d.log(""),d.log(re("Summary","ok")),s===0&&n===0?d.success(`Everything looks good! ${S(`(${U(e.elapsedMs)})`)}`):(s>0&&d.error(`${String(s)} security issue${s===1?"":"s"}`),n>0&&d.log(` ${ve(F.arrow)} ${le(String(n))} ${S(`improvement${n===1?"":"s"} available`)} ${S(`(${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(` ${S(F.arrow)} ${s}`)}d.log("")},Xi=(e,t)=>{t||(Vi(e),Hi(e),Ui(e),Gi(e),Wi(e),Yi(e)),Ki(e,t)},Ji=(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"))} ${S("— 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(Oe(`Runtime: ${s(t.message)}`))}d.log(` ${S(F.arrow)} Run ${ge("vis toolchain install")} to install pinned versions, or ${ge("vis toolchain status")} for the per-tool breakdown.`)}d.log("")},$n=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 j=Date.now(),y=it(o),R=Qt(o),v=!!process.stdout.isTTY,m=!c&&v&&!It&&!a&&!p;!c&&!m&&Qi({nodeVersion:process.versions.node,packageManagerName:y.name,packageManagerVersion:y.version,runtimeFindings:R});const T=Qe(o,y.name),A=es(o,y.name),P=A.length,I=Ze(l?.security).length>0,C=l?.security?.policies?.score?.minimum??tt,_=Ne(o);if(!c&&!a&&!m){const O=_.length>0?S(` · ${String(_.length)} workspace package${_.length===1?"":"s"}`):"";d.log(`${S("·")} ${S("Found")} ${le(String(P))} ${S(`installed package${P===1?"":"s"}`)}${O}`)}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=ts(o,y.name)?.file,te=ee?W(o,ee):void 0,G=Ht(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 O=b?new Ue({activeSections:h,findings:ht(at(b),g)}):new Ue({activeSections:h}),H=At(Pt.createElement(pi,{banner:Y,fromCache:$,startedAt:j,store:O}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{V=b??await qe({filterPatterns:g,installed:A,resolveCodemods:!!s.fix,sections:h,store:O,visConfig:l,workspaceRoot:o})}catch(K){throw H.unmount(),K}await H.waitUntilExit(),N=O.getSnapshot().pendingAction}else if(b)V=b;else{const O=Ji(h,T.size,I,P,!!s.fix),K=Zt(O,{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()-j,envCoverage:await Si(l??{},o).catch(O=>(d.warn(`Env coverage check failed: ${O instanceof Error?O.message:String(O)}`),{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
- `),s.exitCode&&Ge(z,!!s.strict)&&(process.exitCode=1);return}$&&!a&&d.log(`${S("·")} Cached results (use --no-cache to refresh)`),g.length>0&&!a&&d.log(`${S("·")} Filter active: ${ve(s.filter??"")}`),Xi(z,a);const J=z.runtime.some(O=>O.id===Se&&O.status==="warn"),ae=z.sections.has("optimization")&&z.optimizations.length>0;s.fix&&(ae||J)?await Zi({force:!!s.fixForce,fs:e,logger:t,pm:y,recoverOrphans:J,results:z,useEditorconfig:l?.editorconfig??!0,workspaceRoot:o}):a||qi(z),N&&(process.stdout.write(`
1
+ import{createRequire as wt}from"node:module";import{F as S,j as le,q as ve,X as ye,b as Ee,J as ge}from"../packem_shared/index.server-D8BLnYZO.js";import{e as W,a as yt,z as bt,U as Je}from"../packem_shared/index-BdMIfGVZ.js";import{a8 as jt,U as St,V as Ct,W as $t,T as Et,C as Rt,X as Tt,Y as ze,p as d,q as At,S as F}from"./cli-main.js";import{i as It}from"../packem_shared/index-BjdW45xX.js";import{F as i,X as u,o as r,x as z,d as Nt,C as Ot,a as Qe,i as Ze,R as Pt,m as Dt,n as Mt,h as Ft,j as _t}from"./catalog.js";import{g as Bt,s as Be,D as tt}from"../packem_shared/formatBytes-BHAzNIrn-DRcKvqnb.js";import{y as be}from"../packem_shared/isAccessibleSync-DYKTrrvc-BwaMhQs0.js";import{p as st}from"../packem_shared/readJsonSync-CbryXYxN-Bm5i10UW.js";import{h as Vt}from"../packem_shared/writeFileSync-DJoHk3Ks-Dhem3Uof.js";import{findVisConfigFile as Ht}from"./CONFIG_FILES.js";import{d as Ne,c as Ve,r as Ut,b as Wt,a as Yt,e as Gt,f as Kt,m as qt}from"./handler69.js";import{d as it,n as Xt}from"../packem_shared/pm-runner-ImwtpnWY.js";import{c as Jt}from"../packem_shared/env-consistency-CUBJHENL.js";import{c as Qt}from"../packem_shared/runtime-check-Bh5q9IrT.js";import{s as Zt}from"../packem_shared/scan-progress-DcYI76zE.js";import{l as es,r as ts,f as ss}from"../packem_shared/dependency-scan-DKK3ZEZI.js";import{l as nt}from"../packem_shared/spinner-ukDEdGvp.js";import{n as is,a as ns}from"../packem_shared/tabs--uxJGL8N.js";import{u as rs}from"../packem_shared/use-measured-height-DUZyyias.js";import{DEFAULT_UNTRACKED_ENV_PATTERNS as os,resolveChildEnvPolicy as ls,createEnvMatcher as Ae,detectFrameworks as as,extractReferencedEnvVars as cs,looksLikeInputUri as ds,parseInputUri as us,CLEAN_ENV_BASE_NAMES as hs,CLEAN_ENV_POSIX_NAMES as ps,CLEAN_ENV_WIN32_NAMES as fs}from"@visulima/task-runner";import{c as ms,V as gs,a as xs}from"../packem_shared/task-env-Dl08aklA.js";import{y as ws}from"../packem_shared/index-C9ENZqH9.js";import{l as ks}from"./ts-loader.js";import{s as vs}from"../packem_shared/verify-CadR9PUk.js";let kt;const vt=e=>(kt??=wt(import.meta.url))(e),we=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xe=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:Le,writeFileSync:zt,statSync:Lt,readFileSync:et}=Xe("node:fs"),{spawnSync:Re}=Xe("node:child_process"),Ie=()=>W(Bt(),"doctor"),ys=1800*1e3,He=e=>{if(!e)return"";try{return String(Lt(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 jt(Buffer.from(t))},Ss=e=>{const t=W(Ie(),`${e}.json`);if(be(t))try{const s=st(t);if(Date.now()-s.createdAt>s.ttlMs){Le(t,{force:!0});return}return{...s.results,sections:new Set(s.results.sections)}}catch{Le(t,{force:!0});return}},Cs=(e,t,s=ys)=>{Vt(Ie());const l={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:s};zt(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=et("/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)},Os=(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}},Ps=(e,t,s=Ns)=>{s(e,t)},Ds=(e,t)=>{if(process.platform==="win32"){Os(e,t);return}Ps(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
+ `)){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=et(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]},zs=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=zs(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},Ls=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:`${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=Ls(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."]})]}),Xs=({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)})]})},Js=({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(Js,{finding:e});break}case"vulnerability":{n=i.jsx(Xs,{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(St,{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(nt,{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:j,sectionStatus:y,selectedIndex:R,severityFilter:v,totalAll:m,viewportHeight:T})=>{const A=o?"white":"gray",{measuredHeight:P,ref:I}=rs(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 X=0;for(const[,b]of h)X+=2+b.length;const B=X>P&&P>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(is,{isFocused:o,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:()=>{},showIndex:!1,value:n,children:me.map(({id:b,label:$})=>i.jsx(ns,{name:b,children:i.jsx(ri,{count:g[b],label:$,status:y[b]})},b))})}),(()=>{const b=Object.keys(y).filter($=>y[$]==="running"&&j[$]).map($=>j[$]);return b.length===0?null:i.jsx(u,{flexShrink:0,paddingX:1,children:i.jsxs(r,{dimColor:!0,wrap:"truncate",children:[i.jsx(nt,{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(Ct,{contentHeight:X,placement:"inset",scrollOffset:p,style:"block",viewportHeight:P})})]},`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
+ `);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}=$t(),{columns:c,rows:h}=Et(),a=z.useSyncExternalStore(n.subscribe,n.getSnapshot),[p,g]=z.useState(!1),[j,y]=z.useState(!1),[R,v]=z.useState(0),[m,T]=z.useState(()=>Date.now());z.useEffect(()=>{const w=setInterval(()=>{T(Date.now())},1e3);return()=>{clearInterval(w)}},[]);const A=m-l,P=z.useRef(null),I=z.useRef(null),C=a.entries[a.selectedIndex]??null,_=z.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=z.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),X=Math.max(1,G-6-ee-(a.filterActive?1:0)),[B,b]=z.useState(X),$=B>0?B:X,V=z.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),L=z.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]),J=z.useCallback(w=>{const x=L(w);v(k=>x>k+$-2?Math.min(N,Math.max(0,x-$+2)):x<k+1?Math.max(0,x-1):k)},[L,$,N]);if(z.useEffect(()=>{I.current?.scrollToTop()},[C?.id]),Rt((w,x)=>{if(w==="c"&&x.ctrl){o();return}if(!j){if(p){x.escape||w==="?"?g(!1):w==="q"?(g(!1),y(!0)):x.downArrow||w==="j"?P.current?.scrollBy(1):(x.upArrow||w==="k")&&P.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),J(k);return}if(x.upArrow||w==="k"){const k=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(k),J(k);return}if(x.pageDown){const k=Math.min(a.selectedIndex+10,a.entries.length-1);n.setSelectedIndex(k),J(k);return}if(x.pageUp){const k=Math.max(a.selectedIndex-10,0);n.setSelectedIndex(k),J(k);return}if(x.home){n.setSelectedIndex(0),v(0);return}if(x.end){const k=a.entries.length-1;n.setSelectedIndex(k),J(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",O=[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:O})}),K=i.jsxs(Tt,{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:P,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(ze,{autoExitSeconds:e||3,onCancel:()=>{y(!1)},visible:j}),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(ze,{autoExitSeconds:e||3,onCancel:()=>{y(!1)},visible:j}),K]})},fi=8,mi=Ae([...hs,...ps,...fs,...gs,...Object.keys(xs),"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(cs(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(ds(n)){let o;try{o=us(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 as(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}=Nt(t,e,await Ot(t,e)),c=[...s.envVars??[],...s.globalEnv??[]],h=[...os,...s.untrackedEnvVars??[]],a=e.namedInputs??{};for(const[p,g]of n){const j=o.projects[p];if(!j)continue;const y=s.frameworkInference?await ki(W(t,j.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=ls(s.env,v.options?.env),P=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)||P(C),visible:A.mode==="clean"?ms(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},Oi=e=>{const t={allowBuildsCount:0,blockExoticSubdeps:void 0,jailBuilds:void 0,minimumReleaseAge:void 0,minimumReleaseAgeStrict:void 0,paranoid:void 0,source:void 0,strictDepBuilds:void 0,trustPolicy:void 0};for(const s of Ii){const l=W(e,s);if(!be(l))continue;let n;try{n=ws(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},Pi=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=ks(n)?.patchedDependencies)}else if(t==="bun"){const n=W(e,"package.json");be(n)&&(s=st(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:Je(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",zi=(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=vs(t.workspaceRoot);if(a.length>0){const p=[...new Set(a.map(g=>g.tool))].sort((g,j)=>g.localeCompare(j)).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=Oi(t.workspaceRoot),p=Pi(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}},Li=(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"),j=o.has("optimization"),y=o.has("runtime"),R=(f,D)=>ht(Li(f,D),t),v=it(a),m=v.name,T=Ve(W(a,"package.json"),!1),A=Ne(a),P=new Set(T);for(const f of A){const D=Ve(W(Je(a,f),"package.json"),!1);for(const M of D)P.add(M)}const I=Dt(a),C=Qe(a,m),_=Ze(h?.security,{minimumScore:h?.security?.policies?.score?.minimum}),Y=h?.security?.policies?.score?.minimum??tt,ee=h?.security?.acceptedRisks,te=Ut(a,v.name),G={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},X=p?ss(a,v.name):[],B=j?Wt(P):[],b=j?Yt(P,te,v,!1):[],$=new Set(B.map(f=>f.packageName)),V=b.filter(f=>!$.has(f.packageName)),N=[...B,...V],oe=y?[..._s(a),...Jt(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"),j&&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 J=(p||g)&&C.size>0?je(l,"outdated",()=>Mt(C,G,I,void 0,a,_,ee),(f,D)=>{const M=f.outdated.length;return{status:M>0?"warn":"ok",summary:M>0?`${String(M)} outdated · ${U(D)}`:`up to date · ${U(D)}`}}):Promise.resolve({checkedCount:0,failed:[],filteredByTarget:[],ignored:[],outdated:[]}),ae=g&&s.length>0?je(l,"vulnerabilities",()=>Ft(s.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let M=0;for(const se of f.values())M+=se.length;return{status:M>0?"error":"ok",summary:M>0?`${String(M)} found · ${U(D)}`:`none found · ${U(D)}`}}):Promise.resolve(new Map),O=g&&_.length>0&&s.length>0?je(l,"socket",()=>_t(_,s.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let M=0,se=0;for(const _e of f.values())M+=_e.alerts.length,_e.score.overall<Y&&(se+=1);const Fe=M+se;return{status:Fe>0?"warn":"ok",summary:Fe>0?`${String(M)} alert${M===1?"":"s"}, ${String(se)} low-score · ${U(D)}`:`clean · ${U(D)}`}}):Promise.resolve(new Map);let H,K,ce,de;const ue=J.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=O.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:X,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,xe=c&&g?Promise.all([ue,w,x]).then(([f])=>{const D=H??K??ce;if(D){c.failSection("security",D);return}c.completeSection("security",R("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,he=(async()=>{if(n&&j&&N.length>0&&await je(l,"codemods",async()=>(await qt(N),N),(f,D)=>{const M=f.filter(se=>se.hasCodemod||se.category==="socket").length;return{status:"ok",summary:`${String(M)} auto-fixable · ${U(D)}`}}).catch(f=>{de=f instanceof Error?f.message:String(f)}),c&&j){if(de){c.failSection("optimization",de);return}c.completeSection("optimization",R("optimization",{duplicates:[],optimizations:N,outdated:[],runtime:[]}))}})(),[Pe,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 Pe.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Te+=f.vulnerabilities.length);for(const f of gt.values())Te+=f.length}return{duplicates:X,installedCount:s.length,optimizations:j?N:[],outdated:p?Pe.outdated:[],runtime:oe,sections:o,socketIssues:{alerts:De,lowScore:Me},supplyChain:zi(h,{packageManager:m,workspaceRoot:a}),vulnCount:Te,workspaceCount:A.length}},Bi=e=>{switch(e){case"error":return ye(F.failure);case"skip":return S(F.dash);case"warn":return Ee(F.warning);default:return ge(F.success)}},re=(e,t)=>{const s=process.stderr.columns??80,l=Math.max(20,Math.min(s-2,60)),n=F.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} ${S(F.dash.repeat(h))}`},Z=e=>` ${ge(F.success)} ${e}`,q=e=>` ${Ee(F.warning)} ${e}`,Oe=e=>` ${ye(F.failure)} ${e}`,mt=e=>` ${S(F.dash)} ${S(e)}`,Q=(e,t,s)=>{const l=`${le(String(e))} ${S(t)}`;return s?`${l} ${S(`(${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"));e.duplicates.length>0?d.log(q(Q(e.duplicates.length,"packages with duplicate versions"))):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(Oe(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"?Oe(t.label):q(t.label);d.log(s),t.detail&&d.log(` ${S(F.arrow)} ${S(t.detail)}`)}e.supplyChain.status!=="ok"&&d.log(` ${S(F.arrow)} ${S("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! ${S(`(${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(F.failure)} ${o.join(", ")} ${S(`(${U(e.elapsedMs)})`)}`)}return}d.log(""),d.log(re("Summary","ok")),s===0&&n===0?d.success(`Everything looks good! ${S(`(${U(e.elapsedMs)})`)}`):(s>0&&d.error(`${String(s)} security issue${s===1?"":"s"}`),n>0&&d.log(` ${ve(F.arrow)} ${le(String(n))} ${S(`improvement${n===1?"":"s"} available`)} ${S(`(${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(` ${S(F.arrow)} ${s}`)}d.log("")},Xi=(e,t)=>{t||(Vi(e),Hi(e),Ui(e),Gi(e),Wi(e),Yi(e)),Ki(e,t)},Ji=(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"))} ${S("— 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(Oe(`Runtime: ${s(t.message)}`))}d.log(` ${S(F.arrow)} Run ${ge("vis toolchain install")} to install pinned versions, or ${ge("vis toolchain status")} for the per-tool breakdown.`)}d.log("")},$n=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 j=Date.now(),y=it(o),R=Qt(o),v=!!process.stdout.isTTY,m=!c&&v&&!It&&!a&&!p;!c&&!m&&Qi({nodeVersion:process.versions.node,packageManagerName:y.name,packageManagerVersion:y.version,runtimeFindings:R});const T=Qe(o,y.name),A=es(o,y.name),P=A.length,I=Ze(l?.security).length>0,C=l?.security?.policies?.score?.minimum??tt,_=Ne(o);if(!c&&!a&&!m){const O=_.length>0?S(` · ${String(_.length)} workspace package${_.length===1?"":"s"}`):"";d.log(`${S("·")} ${S("Found")} ${le(String(P))} ${S(`installed package${P===1?"":"s"}`)}${O}`)}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=ts(o,y.name)?.file,te=ee?W(o,ee):void 0,G=Ht(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 O=b?new Ue({activeSections:h,findings:ht(at(b),g)}):new Ue({activeSections:h}),H=At(Pt.createElement(pi,{banner:Y,fromCache:$,startedAt:j,store:O}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{V=b??await qe({filterPatterns:g,installed:A,resolveCodemods:!!s.fix,sections:h,store:O,visConfig:l,workspaceRoot:o})}catch(K){throw H.unmount(),K}await H.waitUntilExit(),N=O.getSnapshot().pendingAction}else if(b)V=b;else{const O=Ji(h,T.size,I,P,!!s.fix),K=Zt(O,{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()-j,envCoverage:await Si(l??{},o).catch(O=>(d.warn(`Env coverage check failed: ${O instanceof Error?O.message:String(O)}`),{status:"ok",targets:[]}))};if(B&&!$)try{Cs(B,oe)}catch{}const L=Ri(oe,g,C);if(c){process.stdout.write(`${JSON.stringify(Ai(L,y.name),void 0,2)}
4
+ `),s.exitCode&&Ge(L,!!s.strict)&&(process.exitCode=1);return}$&&!a&&d.log(`${S("·")} Cached results (use --no-cache to refresh)`),g.length>0&&!a&&d.log(`${S("·")} Filter active: ${ve(s.filter??"")}`),Xi(L,a);const J=L.runtime.some(O=>O.id===Se&&O.status==="warn"),ae=L.sections.has("optimization")&&L.optimizations.length>0;s.fix&&(ae||J)?await Zi({force:!!s.fixForce,fs:e,logger:t,pm:y,recoverOrphans:J,results:L,useEditorconfig:l?.editorconfig??!0,workspaceRoot:o}):a||qi(L),N&&(process.stdout.write(`
5
5
  `),process.stdout.write(`${le("→ ")}${N.description}
6
6
  `),N.configSnippet?(process.stdout.write(`
7
7
  `),process.stdout.write(`${S(N.configSnippet)}
8
8
  `)):process.stdout.write(` ${ve(N.command)}
9
9
  `),process.stdout.write(`
10
- `)),s.exitCode&&Ge(z,!!s.strict)&&(process.exitCode=1)},Zi=async e=>{const{force:t,fs:s,logger:l,pm:n,recoverOrphans:o,results:c,useEditorconfig:h,workspaceRoot:a}=e;d.log(""),d.log(re("Applying fixes","ok"));const p=c.optimizations.filter(m=>m.category==="socket"&&m.overrideSpec).map(m=>({original:m.packageName,spec:m.overrideSpec})),g=c.optimizations.filter(m=>m.category!=="socket"&&m.hasCodemod),j=c.optimizations.filter(m=>m.category!=="socket"&&!m.hasCodemod);let y=!1,R=0;const v=[];if(o){const m=As({force:t});if(m.killed.length>0&&(d.success(`Cleaned up ${String(m.killed.length)} orphaned process${m.killed.length===1?"":"es"} (PIDs: ${m.killed.join(", ")}).`),y=!0),m.failed.length>0){const T=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";d.warn(`Could not signal ${String(m.failed.length)} orphan${m.failed.length===1?"":"s"}: ${m.failed.map(A=>`${String(A.pid)} (${A.reason})`).join(", ")}.${T}`)}}if(p.length>0){const m=Gt(a,W(a,"package.json"),p,n,h);m.added.length>0&&(d.success(`Added ${String(m.added.length)} security override${m.added.length===1?"":"s"}.`),y=!0),m.updated.length>0&&(d.success(`Updated ${String(m.updated.length)} override${m.updated.length===1?"":"s"}.`),y=!0)}for(const m of g)try{const T=await Kt(s,a,m.packageName);T.filesChanged>0&&(d.success(`${m.packageName}: ${String(T.filesChanged)} file${T.filesChanged===1?"":"s"} updated`),R+=1,y=!0)}catch(T){const A=T instanceof Error?T.message:String(T);v.push({error:A,package:m.packageName}),d.warn(`${m.packageName}: codemod failed — ${A}`)}p.length>0&&(d.log(`${ve(F.arrow)} Running ${n.name} install to update lockfile…`),Xt(n,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},a,l),y=!0),d.log(""),y?d.success(`Fixes applied. ${R>0?`${String(R)} codemod${R===1?"":"s"} applied.`:""}`.trim()):d.log(mt("No auto-fixable items in the current run.")),v.length>0&&d.warn(`${String(v.length)} codemod${v.length===1?"":"s"} failed (run ${ge("vis optimize")} for the interactive picker).`),j.length>0&&d.notice(`${String(j.length)} optimization${j.length===1?"":"s"} need manual review (no codemod). Run ${ge("vis optimize")} to inspect them.`)};export{$n as default};
10
+ `)),s.exitCode&&Ge(L,!!s.strict)&&(process.exitCode=1)},Zi=async e=>{const{force:t,fs:s,logger:l,pm:n,recoverOrphans:o,results:c,useEditorconfig:h,workspaceRoot:a}=e;d.log(""),d.log(re("Applying fixes","ok"));const p=c.optimizations.filter(m=>m.category==="socket"&&m.overrideSpec).map(m=>({original:m.packageName,spec:m.overrideSpec})),g=c.optimizations.filter(m=>m.category!=="socket"&&m.hasCodemod),j=c.optimizations.filter(m=>m.category!=="socket"&&!m.hasCodemod);let y=!1,R=0;const v=[];if(o){const m=As({force:t});if(m.killed.length>0&&(d.success(`Cleaned up ${String(m.killed.length)} orphaned process${m.killed.length===1?"":"es"} (PIDs: ${m.killed.join(", ")}).`),y=!0),m.failed.length>0){const T=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";d.warn(`Could not signal ${String(m.failed.length)} orphan${m.failed.length===1?"":"s"}: ${m.failed.map(A=>`${String(A.pid)} (${A.reason})`).join(", ")}.${T}`)}}if(p.length>0){const m=Gt(a,W(a,"package.json"),p,n,h);m.added.length>0&&(d.success(`Added ${String(m.added.length)} security override${m.added.length===1?"":"s"}.`),y=!0),m.updated.length>0&&(d.success(`Updated ${String(m.updated.length)} override${m.updated.length===1?"":"s"}.`),y=!0)}for(const m of g)try{const T=await Kt(s,a,m.packageName);T.filesChanged>0&&(d.success(`${m.packageName}: ${String(T.filesChanged)} file${T.filesChanged===1?"":"s"} updated`),R+=1,y=!0)}catch(T){const A=T instanceof Error?T.message:String(T);v.push({error:A,package:m.packageName}),d.warn(`${m.packageName}: codemod failed — ${A}`)}p.length>0&&(d.log(`${ve(F.arrow)} Running ${n.name} install to update lockfile…`),Xt(n,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},a,l),y=!0),d.log(""),y?d.success(`Fixes applied. ${R>0?`${String(R)} codemod${R===1?"":"s"} applied.`:""}`.trim()):d.log(mt("No auto-fixable items in the current run.")),v.length>0&&d.warn(`${String(v.length)} codemod${v.length===1?"":"s"} failed (run ${ge("vis optimize")} for the interactive picker).`),j.length>0&&d.notice(`${String(j.length)} optimization${j.length===1?"":"s"} need manual review (no codemod). Run ${ge("vis optimize")} to inspect them.`)};export{$n as default};