@visulima/vis 1.0.0-alpha.26 → 1.0.0-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/LICENSE.md +3213 -95
- package/README.md +24 -22
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +176 -16
- package/dist/packem_chunks/bin.js +468 -364
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/config.js +15 -15
- package/dist/packem_chunks/devtools.js +82 -0
- package/dist/packem_chunks/doctor-probe.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +8 -9
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +3 -3
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler23.js +2 -2
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +6 -6
- package/dist/packem_chunks/handler31.js +1 -1
- package/dist/packem_chunks/handler33.js +1 -1
- package/dist/packem_chunks/handler34.js +4 -4
- package/dist/packem_chunks/handler35.js +3 -22
- package/dist/packem_chunks/handler36.js +21 -60
- package/dist/packem_chunks/handler37.js +61 -6
- package/dist/packem_chunks/handler38.js +3 -24
- package/dist/packem_chunks/handler39.js +6 -153
- package/dist/packem_chunks/handler4.js +5 -5
- package/dist/packem_chunks/handler40.js +24 -10
- package/dist/packem_chunks/handler41.js +153 -25
- package/dist/packem_chunks/handler42.js +25 -708
- package/dist/packem_chunks/handler43.js +10 -24
- package/dist/packem_chunks/handler44.js +659 -273
- package/dist/packem_chunks/handler45.js +24 -46
- package/dist/packem_chunks/handler46.js +322 -3
- package/dist/packem_chunks/handler47.js +48 -27
- package/dist/packem_chunks/handler48.js +3 -187
- package/dist/packem_chunks/handler49.js +23 -30
- package/dist/packem_chunks/handler5.js +7 -7
- package/dist/packem_chunks/handler50.js +195 -0
- package/dist/packem_chunks/handler51.js +34 -0
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +7 -17
- package/dist/packem_chunks/index.js +3 -3
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/list.js +2 -2
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/Table-CwC2kW07-EjFLNV0q.js +12 -0
- package/dist/packem_shared/_commonjsHelpers-CLblCigl.js +1 -0
- package/dist/packem_shared/{advisories-DS8JEB_g.js → advisories-BxXiKFbL.js} +1 -1
- package/dist/packem_shared/{ai-analysis-Csn82p17.js → ai-analysis-BnmDFqc8.js} +5 -5
- package/dist/packem_shared/{ai-fix-BlYyz5bI.js → ai-fix-BGbnrWCz.js} +7 -7
- package/dist/packem_shared/{cyclonedx-ja1cbU69.js → cyclonedx-C2k2HmvI.js} +1 -1
- package/dist/packem_shared/{dependency-scan-s2MD0vi-.js → dependency-scan-Bki15Yi-.js} +1 -1
- package/dist/packem_shared/{docker-Bw9gKo69.js → docker-k-Sl8b-w.js} +1 -1
- package/dist/packem_shared/{failure-log-B0Uh-65U.js → failure-log-C3bG1bCA.js} +1 -1
- package/dist/packem_shared/index-2r730kXY.js +29 -0
- package/dist/packem_shared/{index-88UK-tt_.js → index-DBq4TVu5.js} +1 -1
- package/dist/packem_shared/{lifecycle-ChCFTm5Q.js → lifecycle-B91p_ra8.js} +2 -2
- package/dist/packem_shared/{lockfile-BG1HvBzH.js → lockfile-DmDfgKaT.js} +1 -1
- package/dist/packem_shared/{min-release-age-heJgeP7o.js → min-release-age-B1Jm1_JY.js} +1 -1
- package/dist/packem_shared/{native-config-sync-BOeuyrBj.js → native-config-sync-Cnpj2xcn.js} +6 -6
- package/dist/packem_shared/{osv-bloom-QSAn2Dcw.js → osv-bloom-ep8GlDGT.js} +2 -2
- package/dist/packem_shared/pm-runner-COoPLGKi.js +1 -0
- package/dist/packem_shared/{provenance-BsBn1f5S.js → provenance-DbkJRDqt.js} +1 -1
- package/dist/packem_shared/{registry-keys-pemEkRM9.js → registry-keys-SylX07bs.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-CBPr617N.js → resolve-explicit-CJ_5wYSu.js} +1 -1
- package/dist/packem_shared/s1ngularity-DlS-4a6K.js +1 -0
- package/dist/packem_shared/scan-progress-CU4ttEHQ.js +2 -0
- package/dist/packem_shared/{signatures-CaXzNuEn.js → signatures-B-1u4t-c.js} +1 -1
- package/dist/packem_shared/spinner-B9ZPv1iT.js +1 -0
- package/dist/packem_shared/spinners-f91Rbo99-Bjf3NcO0.js +1 -0
- package/dist/packem_shared/tabs-C-qFIoUv.js +1 -0
- package/dist/packem_shared/typosquats-BxCOUvTJ.js +1 -0
- package/dist/packem_shared/use-measured-height-kIDCuc76.js +1 -0
- package/dist/packem_shared/vis-update-app-COYmjGKv.js +1 -0
- package/dist/packem_shared/watch-BSVsZ_1I.js +1 -0
- package/dist/packem_shared/watch-loop-CP318TfG.js +11 -0
- package/index.js +751 -567
- package/package.json +11 -11
- package/schemas/project.schema.json +86 -1
- package/schemas/vis-config.schema.json +255 -7
- package/dist/packem_shared/index-CS6a2wFB.js +0 -29
- package/dist/packem_shared/index.server-B7ETiT4C.js +0 -2
- package/dist/packem_shared/pm-runner-BzGZmzYs.js +0 -1
- package/dist/packem_shared/s1ngularity-j_ArCZAs.js +0 -1
- package/dist/packem_shared/scan-progress-EbvmIh4i.js +0 -2
- package/dist/packem_shared/typosquats-C1e6RNjF.js +0 -1
- package/dist/packem_shared/use-measured-height-DjYgUOKk.js +0 -1
- package/dist/packem_shared/vis-update-app-qhQPV97i.js +0 -1
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);let r;for(const s of t){if(s.startsWith("#!")||s.startsWith("# Generated by")||s.startsWith("# NOTE:")||s==="set -e"||s==="")continue;const n=ze.exec(s);if(n){r&&o.push(r),r={command:"",id:n[1]??"",...n[2]?{name:n[2]}:{}};continue}r?r.command=r.command.length>0?`${r.command}
|
|
3
|
-
${s}`:s:r={command:s,id:"(custom)"}}return r&&o.push(r),o},"parseStageScript"),Ye=q((e,o)=>{const t=g(e,o),r=[],s=new Set(pe);if(S(t))for(const n of de(t)){if(n.startsWith(".")||n==="_"||!s.has(n))continue;const i=g(t,n);if(!z(i).isFile())continue;const a=N(i),c=Qe(a);r.push({blocks:c,rawLineCount:a.split(`
|
|
4
|
-
`)
|
|
5
|
-
`)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
`)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
${No}
|
|
12
|
-
exec vis hook run ${e} "$@"
|
|
13
|
-
`,"stageScriptBody"),oe=v(e=>{for(const o of Me)if(S(g(e,o)))return o},"detectPrekConfig"),Ho=v(e=>Ne[e]??e,"mapPrekStage"),Do=v(e=>Mo.exec(e)?.[1]??e,"normalizeRepoKey"),Lo=v(e=>{if(Io.test(e))return;if(e.startsWith("@")){const r=e.indexOf("@",1);if(r===-1)return{name:e,version:"latest"};const s=e.slice(r+1).trim();return{name:e.slice(0,r),version:s||"latest"}}const o=e.indexOf("@");if(o===-1)return{name:e,version:"latest"};const t=e.slice(o+1).trim();return{name:e.slice(0,o),version:t||"latest"}},"parseAdditionalDep"),Wo=v(e=>{const o=[];for(const t of[e.types,e.types_or,e.exclude_types])for(const r of t??[])to(r)||o.push(r);return o},"unknownTypes"),Vo=v((e,o)=>(e.stages&&e.stages.length>0?e.stages:o??["pre-commit"]).map(t=>Ho(t)),"resolveStages"),qo=v((e,o,t)=>{const r=e.id??"<unknown>",s=Z.has(o),n={id:r};return e.name&&(n.name=e.name),e.language==="fail"?(n.fail=e.entry??e.name??r,n):(t?n.builtin=t:e.entry&&(n.entry=e.entry),Array.isArray(e.args)&&e.args.length>0&&(n.args=[...e.args]),s||(e.files&&(n.files=e.files),e.exclude&&(n.exclude=e.exclude),e.types&&e.types.length>0&&(n.types=[...e.types]),e.types_or&&e.types_or.length>0&&(n.typesOr=[...e.types_or]),e.exclude_types&&e.exclude_types.length>0&&(n.excludeTypes=[...e.exclude_types])),(e.pass_filenames===!1||s)&&(n.passFilenames=!1),(e.always_run||s)&&(n.alwaysRun=!0),e.verbose&&(n.verbose=!0),n)},"buildHookEntry"),Go=v((e,o,t,r)=>{if(Array.isArray(e.additional_dependencies))for(const s of e.additional_dependencies){const n=Lo(s);if(!n){r.push(`"${o}": additional_dependency "${s}" uses a pip-style pin and cannot be added to package.json — install manually.`);continue}t.push({hookId:o,name:n.name,raw:s,version:n.version})}},"collectAdditionalDeps"),Jo=v(e=>{const o={},t=[],r=[],s=[],n=[];(e.files||e.exclude)&&r.push("top-level files/exclude filter dropped — apply it per hook if needed");for(const a of e.repos??[]){const c=a.repo??"<unknown>",l=c==="local",d=l?void 0:Do(c);for(const u of a.hooks??[]){const m=u.id??"<unknown>";let k;if(l){const f=u.language??"system";if(!Be.has(f)){t.push({hookId:m,reason:`language "${f}" needs an isolated toolchain — run via prek or reimplement as a system command`,repo:c});continue}if(f!=="fail"&&!u.entry){t.push({hookId:m,reason:"missing `entry`",repo:c});continue}}else if(d&&(k=Co.get(`${d}#${m}`)),!k){t.push({hookId:m,reason:`remote repo "${c}"@${a.rev??"?"} has no bundled equivalent — run via prek or replace with a system command`,repo:c});continue}Go(u,m,n,s);const w=Wo(u);w.length>0&&r.push(`hook "${m}": unsupported types ${w.join(", ")} — those entries are ignored by the dispatcher`);const h=Vo(u,e.default_stages);for(const f of h){if(f==="manual")continue;if(!He.has(f)){t.push({hookId:m,reason:`unsupported stage "${f}"`,repo:c});continue}const p=qo(u,f,k),b=o[f];b?b.push(p):o[f]=[p]}}}const i={stages:o,version:L};return e.fail_fast&&(i.failFast=!0),{additionalDeps:n,config:i,droppedFilters:r,manualSteps:s,skippedHooks:t}},"convertPrekConfig"),Ko=v(e=>{const o=De(e);if(o&&typeof o=="object")return o},"parsePrekConfig"),Uo=v(e=>{if(e.endsWith(".toml")){const t=Le(e);return t&&typeof t=="object"?t:void 0}const o=N(e);return Ko(o)},"loadPrekConfig"),zo=v((e,o,t)=>{const r=g(e,"package.json"),s=[],n=[];if(!S(r)||o.length===0)return{added:s,skipped:n};const i=N(r),a=JSON.parse(i),c=a.devDependencies??{},l=a.dependencies??{};for(const u of o){if(u.name in c||u.name in l){n.push(u.name);continue}c[u.name]=u.version,s.push(u.name)}if(s.length===0)return{added:s,skipped:n};a.devDependencies=c;const d=We(r,i,{defaultIndent:" ",useEditorconfig:t});return x(r,`${JSON.stringify(a,void 0,d)}
|
|
14
|
-
`,"utf8"),{added:s,skipped:n}},"mergeAdditionalDependencies"),Qo=v((e,o)=>{const t=g(e,o);ye(t),x(g(t,"README.md"),["# Vis hook config","","`config.json` is the single source of truth for what each stage","script runs. Auto-generated by `vis hook migrate`. Edit by hand","or re-run the migrator after updating your prek config.","",`Bundled builtins: ${Eo.join(", ")}`,""].join(`
|
|
15
|
-
`),"utf8")},"writeConfigReadme"),Yo=v((e,o)=>{R("prek",["--version"],{cwd:e,encoding:"utf8"}).status===0?R("prek",["uninstall"],{cwd:e,encoding:"utf8"}).status===0?o.info("Detached prek via `prek uninstall`."):o.info("`prek uninstall` did not exit cleanly — continuing. You may need to run it manually."):o.info("prek binary not found on PATH — skipping `prek uninstall`. Run it manually if prek is installed elsewhere.")},"detachPrek"),je=v((e,o,t,r={})=>{const s=oe(e),n=r.dryRun===!0;if(!s)return{isError:!0,message:"No prek configuration found (.pre-commit-config.yaml, .pre-commit-config.yml, or prek.toml)"};t.info(`Found prek config at ${s}`);const i=g(e,s),a=N(i),c=Uo(i);if(!c)return{isError:!0,message:`Could not parse ${s}`};const{additionalDeps:l,config:d,droppedFilters:u,manualSteps:m,skippedHooks:k}=Jo(c),w=Object.keys(d.stages);if(w.length===0&&k.length===0)return{isError:!0,message:`${s} has no hooks to migrate`};if(!n){const y=R("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(y.status===0){const J=y.stdout?.toString().trim();J&&(J.includes(".prek")||J.includes("prek-hooks"))&&R("git",["config","--local","--unset","core.hooksPath"],{cwd:e})}const T=he(o);if(T.isError)return T;T.message&&t.info(T.message)}const h=g(e,o);n||ye(h),n?t.info(` (would write) ${o}/${F}`):(_o(e,o,d),Qo(e,o),t.info(` Wrote ${o}/${F}`));let f=0;for(const y of w){const T=Bo(y);n?t.info(` (would write) ${o}/${y}`):(x(g(h,y),T,{mode:493}),t.info(` Wrote ${o}/${y}`)),f+=1}const{added:p,skipped:b}=n?{added:l.map(y=>y.name),skipped:[]}:zo(e,l,r.useEditorconfig);if(p.length>0){const y=n?"would add":"Added";t.info(`${y} ${p.length} package${p.length===1?"":"s"} to devDependencies: ${p.join(", ")}`),n||t.info("Run your package manager's install (e.g. `pnpm install`) to pick up the new devDependencies.")}b.length>0&&t.info(`Skipped ${b.length} already-declared package${b.length===1?"":"s"}: ${b.join(", ")}`),n||Yo(e,t);const se=`${i}.bak`;if(n?t.info(` (would remove) ${s} and back it up to ${s}.bak`):(S(se)||x(se,a,"utf8"),_e(i),t.info(`Removed ${s} (backup at ${s}.bak)`)),k.length>0){t.warn(`Skipped ${k.length} hook${k.length===1?"":"s"} that cannot run without prek:`);for(const y of k)t.warn(` - ${y.repo}::${y.hookId} — ${y.reason}`)}if(u.length>0){t.warn("Partial filter translations:");for(const y of u)t.warn(` - ${y}`)}if(m.length>0){t.warn("Manual follow-up required:");for(const y of m)t.warn(` - ${y}`)}return{isError:!1,message:`${n?"would migrate":"Migration complete:"} ${f} stage script${f===1?"":"s"} ${n?"into":"written to"} ${o}/`}},"migrateFromPrek");var Xo=Object.defineProperty,te=$((e,o)=>Xo(e,"name",{value:o,configurable:!0}),"i$2");const Zo=te(e=>{const o=[];let t=0;for(let r=0;r<e.length;r+=1)e[r]===0&&(r>t&&o.push(e.subarray(t,r).toString("utf8")),t=r+1);return t<e.length&&o.push(e.subarray(t).toString("utf8")),o},"splitNulBuffer"),U=te((e,o,t)=>{const r=R("git",[...e],{cwd:t,encoding:"buffer"});if(r.status!==0){const s=r.stderr?r.stderr.toString():"";throw new Error(`git ${o} failed${s?`: ${s.trim()}`:""}`)}return r.stdout.length===0?[]:Zo(r.stdout)},"gitListFiles"),et=te((e,o)=>{switch(e.kind){case"all":return U(["ls-files","-z"],"ls-files",o);case"range":return U(["diff","--name-only","--diff-filter=ACM","-z",e.fromRef,e.toRef],"diff --from-ref/--to-ref",o);case"staged":return U(["diff","--cached","--name-only","--diff-filter=ACM","-z"],"diff --cached",o);default:{const t=e;throw new Error(`unknown discover mode: ${JSON.stringify(t)}`)}}},"discoverFiles");var ot=Object.defineProperty,re=$((e,o)=>ot(e,"name",{value:o,configurable:!0}),"i$1");const le=re((e,o)=>{try{return new RegExp(e)}catch(t){const r=t instanceof Error?t.message:String(t);throw new Error(`invalid ${o} regex ${JSON.stringify(e)}: ${r}`,{cause:t})}},"compileRegex"),tt=re(e=>e.types&&e.types.length>0||e.typesOr&&e.typesOr.length>0||e.excludeTypes&&e.excludeTypes.length>0||!1,"hasTagFilters"),rt=re((e,o)=>{let t=e;if(o.files){const n=le(o.files,"files");t=t.filter(i=>n.test(i))}if(o.exclude){const n=le(o.exclude,"exclude");t=t.filter(i=>!n.test(i))}if(!tt(o))return[...t];const r=oo(t),s={excludeTypes:o.excludeTypes,types:o.types,typesOr:o.typesOr};return t.filter(n=>{const i=r.get(n);return i?ro(i,s):!1})},"applyHookFilter");var nt=Object.defineProperty,A=$((e,o)=>nt(e,"name",{value:o,configurable:!0}),"u$2");const st=32*1024,it=A((e,o)=>{const t=[],r=Math.max(1024,st-o);let s=[],n=0;for(const i of e){const a=Buffer.byteLength(i,"utf8")+8;n+a>r&&s.length>0&&(t.push(s),s=[],n=0),s.push(i),n+=a}return s.length>0&&t.push(s),t},"chunkFiles"),at=A(e=>({error:A(o=>{e.error(o)},"error"),info:A(o=>{e.info(o)},"info")}),"builtinLoggerFor"),ue=A((e,o,t)=>t?t.message:o?`terminated by signal ${o}`:`exited with status ${String(e)}`,"describeSpawnFailure"),ct=A((e,o,t,r,s)=>{const n=r?s.extraArgs:[];if(!t||o.length===0){const c=R("sh",["-c",e,"sh",...n],{cwd:s.root,stdio:"inherit"});return c.status===null?(s.logger.error(`hook command failed: ${ue(c.status,c.signal,c.error)}`),1):c.status}const i=Buffer.byteLength(e,"utf8")+Buffer.byteLength("sh","utf8")+Buffer.byteLength("-c","utf8")+n.reduce((c,l)=>c+Buffer.byteLength(l,"utf8")+8,0)+64;let a=0;for(const c of it(o,i)){const l=R("sh",["-c",`${e} "$@"`,"sh",...n,...c],{cwd:s.root,stdio:"inherit"});l.status===null?(s.logger.error(`hook command failed: ${ue(l.status,l.signal,l.error)}`),a|=1):a|=l.status}return a},"runShellCommand"),ft=A((e,o,t)=>{if(e.fail!==void 0)return t.logger.info(e.fail),1;const r=Z.has(t.stage);let s;try{s=rt(o,e)}catch(c){const l=c instanceof Error?c.message:String(c);return t.logger.error(`hook "${e.id}": ${l}`),2}if(s.length===0&&e.alwaysRun!==!0&&!r)return 0;const n=e.passFilenames!==!1;if(e.verbose){const c=e.name??e.id;t.logger.info(`+ ${c}`)}if(e.builtin){const c=So(e.builtin);if(!c)return t.logger.error(`unknown builtin "${e.builtin}" referenced by hook "${e.id}"`),2;const l={logger:at(t.logger),root:t.root};try{return c(s,e.args??[],l)}catch(d){const u=d instanceof Error?d.message:String(d);return t.logger.error(`builtin "${e.builtin}" crashed: ${u}`),1}}if(e.entry===void 0)return t.logger.error(`hook "${e.id}" has no \`entry\`, \`builtin\`, or \`fail\` to run`),2;const i=(e.args??[]).map(c=>`'${c.replaceAll("'",String.raw`'\''`)}'`).join(" "),a=i?`${e.entry} ${i}`:e.entry;return ct(a,s,n,r,t)},"runHookEntry"),lt=A((e,o,t,r)=>{const s=e.stages[o];if(!s||s.length===0)return 0;let n=0;for(const i of s){const a=ft(i,t,r);if(a!==0&&(n|=a,e.failFast))return n}return n},"runStage");var ut=Object.defineProperty,ne=$((e,o)=>ut(e,"name",{value:o,configurable:!0}),"s");const gt="pre-commit",dt=ne(e=>{if(e.lastCommit&&(e.fromRef||e.toRef))throw new Error("--last-commit cannot be combined with --from-ref or --to-ref");const o=e.lastCommit?"HEAD~1":e.fromRef,t=e.lastCommit?"HEAD":e.toRef;if(o&&!t||t&&!o)throw new Error("--from-ref and --to-ref must be specified together");return o&&t?{fromRef:o,kind:"range",toRef:t}:e.allFiles?{kind:"all"}:{kind:"staged"}},"resolveDiscoverMode"),pt=ne((e,o,t,r)=>{const s=t.stage??gt,n=Oe(e,o);if(!n)throw new Error(`No hook config found at ${o}/config.json. Install or migrate hooks first.`);const i=n.stages[s];if(!i||i.length===0)return r.info(`No hooks configured for stage "${s}".`),0;const a=Z.has(s)?void 0:dt(t),c=a?.kind==="all"?" (--all-files)":a?.kind==="range"?` (${a.fromRef}..${a.toRef})`:"";r.info(`Running ${s}${c}`);const l=a?et(a,e):[],d={extraArgs:t.extraArgs??[],logger:r,root:e,stage:s};return lt(n,s,l,d)},"runHookStage"),ht=ne((e,o,t)=>{const r=pt(M(),e,o,t);if(r!==0)throw new Error(`Hook stage exited with code ${r}`)},"runRun");var mt=Object.defineProperty,kt=$((e,o)=>mt(e,"name",{value:o,configurable:!0}),"e");const yt=kt((e=X)=>{if(R("git",["config","--local","core.hooksPath"]).status!==0)return{isError:!1,message:"No custom hooks path configured"};const{status:o,stderr:t}=R("git",["config","--local","--unset","core.hooksPath"]);if(o===null)return{isError:!0,message:"git command not found"};if(o&&o!==5)return{isError:!0,message:String(t)};const r=g(e,"_");return S(r)&&Te(r,{force:!0,recursive:!0}),{isError:!1,message:""}},"uninstallHooks");var $t=Object.defineProperty,G=$((e,o)=>$t(e,"name",{value:o,configurable:!0}),"u");const vt=new Set(pe),wt=G(e=>{const o=R("sh",["-n",e],{encoding:"utf8"});if(o.status===null)return`failed to run "sh -n" (${o.error?.message??"unknown error"})`;if(o.status!==0)return o.stderr.trim()||`sh -n exited with ${o.status}`},"runSyntaxCheck"),bt=G((e,o)=>{const t=[],r=g(e,o),s=R("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(s.status===0){const i=s.stdout.trim(),a=`${o}/_`;i&&i!==a&&t.push({kind:"warning",message:`core.hooksPath is "${i}" — expected "${a}". Re-run \`vis hook install\` to fix.`})}else t.push({kind:"warning",message:"core.hooksPath is not set — run `vis hook install`."});if(S(g(r,"_"))||t.push({kind:"error",message:`Dispatcher directory ${o}/_ is missing. Run \`vis hook install\`.`}),!S(r))return t.push({kind:"error",message:`Hooks directory ${o}/ is missing.`}),{issues:t,ok:!1};let n=!1;for(const i of de(r)){if(i.startsWith(".")||i==="_"||i===F||i==="README.md")continue;if(!vt.has(i)){t.push({kind:"warning",message:`Unknown hook "${i}" — not a standard git hook.`,path:g(o,i)});continue}const a=g(r,i);if(!z(a).isFile())continue;n=!0;const c=z(a).mode&511;(c&64)===0&&t.push({kind:"warning",message:`Script is not owner-executable (mode ${c.toString(8)}).`,path:g(o,i)});const l=wt(a);l&&t.push({kind:"error",message:`Shell syntax error: ${l}`,path:g(o,i)})}if(n){const i=g(r,F);if(S(i))try{Oe(e,o)}catch(a){t.push({kind:"error",message:`${F} is malformed: ${a instanceof Error?a.message:String(a)}`,path:g(o,F)})}else t.push({kind:"error",message:`Stage scripts are present but ${o}/${F} is missing. Re-run \`vis hook migrate\`.`})}return{issues:t,ok:!t.some(i=>i.kind==="error")}},"validateHooks"),xt=G((e,o)=>{if(e.issues.length===0)return[`Hook directory ${o}/ looks good.`];const t=[];for(const r of e.issues){const s=r.kind==="error"?"ERROR":"WARN ",n=r.path?` (${r.path})`:"";t.push(`${s} ${r.message}${n}`)}return t.push("",e.ok?"No errors — warnings only.":`${e.issues.filter(r=>r.kind==="error").length} error(s).`),t},"formatValidationResult"),Et=G((e,o)=>{const t=bt(M(),e),r=xt(t,e);for(const s of r)s.startsWith("ERROR")||s.startsWith("WARN")?o.warn(s):o.info(s);if(!t.ok)throw new Error("Hook validation failed")},"runValidate");var St=Object.defineProperty,E=$((e,o)=>St(e,"name",{value:o,configurable:!0}),"i");const _=E(e=>e.hooksDir??X,"resolveHooksDirectory"),ge=E(e=>new Promise(o=>{const t=Ie({input:process.stdin,output:process.stdout});t.question(`${e} (y/N) `,r=>{t.close();const s=r.trim().toLowerCase();o(s==="y"||s==="yes")})}),"confirmPrompt"),Rt=E(async(e,o,t)=>{const r=M(),s=me(r),n=oe(r);if(s&&n)throw new Error(`Found both husky (${s}/) and prek (${n}). Remove or migrate one before running \`vis hook install\`.`);if(s){if(o.info(`Existing husky installation found at ${s}/`),await ge("Would you like to migrate your husky hooks to vis?")){const a=ke(r,e,o,{useEditorconfig:t});if(a.isError)throw new Error(a.message);a.message&&o.info(a.message);return}o.info("Aborting install. Remove husky first or run 'vis hook migrate' to migrate.");return}if(n){if(o.info(`Existing prek configuration found at ${n}`),await ge("Would you like to migrate your prek hooks to vis?")){const a=je(r,e,o,{useEditorconfig:t});if(a.isError)throw new Error(a.message);a.message&&o.info(a.message);return}o.info("Aborting install. Remove the prek config first or run 'vis hook migrate' to migrate.");return}o.info(`Installing git hooks in ${e}/...`);const i=he(e);if(i.message){if(i.isError)throw new Error(i.message);o.info(i.message);return}S(g(r,e,"pre-commit"))||x(g(r,e,"pre-commit"),`#!/usr/bin/env sh
|
|
16
|
-
`,{mode:493}),o.info("Git hooks installed successfully.")},"executeInstall"),Ot=E((e,o,t,r)=>{const s=M(),n=me(s),i=oe(s);if(n&&i)throw new Error(`Found both husky (${n}/) and prek (${i}). Migrate one at a time — rename or remove one before retrying.`);if(!n&&!i)throw new Error("No husky (.husky/) or prek (.pre-commit-config.yaml / prek.toml) configuration found to migrate.");o&&t.info("(dry-run) no files will be written");const a=n?ke(s,e,t,{dryRun:o,useEditorconfig:r}):je(s,e,t,{dryRun:o,useEditorconfig:r});if(a.isError)throw new Error(a.message);a.message&&t.info(a.message)},"executeMigrate"),Y="# vis:secrets-hook",jt=`#!/usr/bin/env sh
|
|
17
|
-
${Y}
|
|
18
|
-
# Scan staged files for secrets before each commit. Remove this block or the whole file to disable.
|
|
19
|
-
pnpm exec vis secrets --staged --quiet || exit 1
|
|
20
|
-
`,Ft=E((e,o,t)=>{if(e!=="secrets")throw new Error(`Unknown hook add target "${String(e)}". Currently supported: "secrets".`);const r=M(),s=g(r,o,"pre-commit");if(!S(g(r,o)))throw new Error(`Hooks directory ${o}/ does not exist. Run \`vis hook install\` first.`);if(S(s)){const n=N(s);if(n.includes(Y)){t.info(`Secrets hook already present in ${s}.`);return}if(/\bvis secrets\b/.test(n)){t.warn(`Found a \`vis secrets\` invocation in ${s} without the managed marker — leaving it untouched.`);return}const i=`${n.trimEnd()}
|
|
21
|
-
|
|
22
|
-
${Y}
|
|
23
|
-
pnpm exec vis secrets --staged --quiet || exit 1
|
|
24
|
-
`;x(s,i),Ce(s,493),t.info(`Appended secrets scan to ${s}.`);return}x(s,jt,{mode:493}),t.info(`Created ${s} with a secrets-scan pre-commit check.`)},"executeAdd"),At=E((e,o)=>{o.info("Removing git hooks...");const t=yt(e);if(t.message){if(t.isError)throw new Error(t.message);o.info(t.message);return}o.info("Git hooks removed successfully.")},"executeUninstall"),Pt=E(async({logger:e,options:o,visConfig:t})=>{await Rt(_(o),e,t?.editorconfig??!0)},"hookInstallImpl"),_t=E(({logger:e,options:o})=>{At(_(o),e)},"hookUninstallImpl"),Tt=E(({logger:e,options:o,visConfig:t})=>{Ot(_(o),!!o.dryRun,e,t?.editorconfig??!0)},"hookMigrateImpl"),Ct=E(({logger:e,options:o})=>{Ze(_(o),e)},"hookListImpl"),It=E(({logger:e,options:o})=>{Et(_(o),e)},"hookValidateImpl"),Mt=E(({argument:e,logger:o,options:t})=>{ht(_(t),{allFiles:!!t.allFiles,extraArgs:e.slice(1),fromRef:t.fromRef,lastCommit:!!t.lastCommit,stage:e[0],toRef:t.toRef},o)},"hookRunImpl"),Nt=E(({argument:e,logger:o,options:t})=>{Ft(e[0],_(t),o)},"hookAddImpl"),qt=Pt,Gt=_t,Jt=Tt,Kt=Ct,Ut=It,zt=Mt,Qt=Nt;export{Qt as hookAddExecute,qt as hookInstallExecute,Kt as hookListExecute,Jt as hookMigrateExecute,zt as hookRunExecute,Gt as hookUninstallExecute,Ut as hookValidateExecute};
|
|
1
|
+
var Pt=Object.defineProperty;var T=(e,t)=>Pt(e,"name",{value:t,configurable:!0});import{createRequire as It}from"node:module";import{I as we,e as Me,E as v,T as Re,j as ce,q as Te}from"../packem_shared/Table-CwC2kW07-EjFLNV0q.js";import{h as Ot,a$ as Nt,a5 as s,a6 as u,n as r,K as We,aG as Ft,aH as Mt,aI as Et,aF as zt,r as L,af as Bt,aJ as Lt,aK as Je,b0 as Vt,o as Ut,U as ot,O as Gt,R as lt,b as at,V as _t,T as Ht,f as Kt,p as d,a7 as N,v as Yt,d as Wt,a4 as ct,s as Jt}from"./bin.js";import{M as J,i as Ae,$ as qt,a as Xt,C as dt}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{n as ht,d as ei,j as ti}from"./config.js";import{x as Xe,A as pt,L as ii,F as si,T as ri,U as ni,a as oi,I as li}from"./handler40.js";import{A as gt,y as ai}from"../packem_shared/pm-runner-COoPLGKi.js";import{c as ci}from"../packem_shared/runtime-check-DgXsKCsv.js";import{s as di}from"../packem_shared/scan-progress-CU4ttEHQ.js";import{f as ui,l as hi,r as pi}from"../packem_shared/dependency-scan-Bki15Yi-.js";import{n as ft}from"../packem_shared/spinner-B9ZPv1iT.js";import{g as gi,r as fi}from"../packem_shared/tabs-C-qFIoUv.js";import{u as mi}from"../packem_shared/use-measured-height-kIDCuc76.js";import{s as xi}from"../packem_shared/verify-C8EAHql6.js";const Dt=It(import.meta.url),Se=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,nt=T(e=>{if(typeof Se<"u"&&Se.versions&&Se.versions.node){const[t,i]=Se.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return Se.getBuiltinModule(e)}return Dt(e)},"__cjs_getBuiltinModule"),{statSync:Qt,rmSync:qe,writeFileSync:Zt,readFileSync:ut}=nt("node:fs"),{spawnSync:Ee}=nt("node:child_process");var yi=Object.defineProperty,Pe=T((e,t)=>yi(e,"name",{value:t,configurable:!0}),"r$2");const Ve=Pe(()=>J(Ot(),"doctor"),"getCacheDirectory"),ki=1800*1e3,Qe=Pe(e=>{if(!e)return"";try{return String(Qt(e).mtimeMs)}catch{return""}},"safeMtime"),wi=2,vi=Pe(e=>{const t=JSON.stringify({configMtime:Qe(e.configPath),lockfileMtime:Qe(e.lockfilePath),schema:wi,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return Nt(Buffer.from(t))},"buildDoctorCacheKey"),bi=Pe(e=>{const t=J(Ve(),`${e}.json`);if(Ae(t))try{const i=ht(t);if(Date.now()-i.createdAt>i.ttlMs){qe(t,{force:!0});return}return{...i.results,sections:new Set(i.results.sections)}}catch{qe(t,{force:!0});return}},"readDoctorCache"),ji=Pe((e,t,i=ki)=>{ei(Ve());const o={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:i};Zt(J(Ve(),`${e}.json`),JSON.stringify(o,void 0,2),"utf8")},"writeDoctorCache");var $i=Object.defineProperty,M=T((e,t)=>$i(e,"name",{value:t,configurable:!0}),"n$1");const Oe="orphans",Si=M(()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=ut("/proc/sys/fs/inotify/max_user_watches","utf8").trim(),i=Number.parseInt(t,10);Number.isFinite(i)&&i>0&&(e=i)}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"}},"checkInotifyCapacity"),Ci=M(()=>{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"}},"checkTtyAvailability"),Ri=M(()=>{const e=process.pid;try{return process.platform==="win32"?yt(e):xt(e)}catch{return[]}},"listOrphanPids"),Ti=M(()=>{const e=process.pid;let t;try{t=process.platform==="win32"?yt(e):xt(e)}catch{return{id:Oe,message:"Could not enumerate processes (ps/tasklist failed).",status:"warn"}}if(t.length===0)return{id:Oe,message:"No orphaned vis/task-runner processes detected.",status:"ok"};if(t.length<=2)return{detail:{count:t.length,pids:t.join(",")},id:Oe,message:`${String(t.length)} possibly orphaned process(es) detected (PIDs: ${t.join(", ")}). Likely benign.`,status:"skip"};const i=process.platform==="win32"?t.map(o=>`taskkill /F /PID ${String(o)}`).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: ${i}`,status:"warn"}},"checkOrphanedRunners"),Ai=M((e={})=>{const t=e.enumerate??Ri,i=e.force===!0?"SIGKILL":"SIGTERM",o=e.kill??Ni,n=t(),l=[],c=[];for(const h of n)try{o(h,i),l.push(h)}catch(a){const g=a.code??a.message;if(g==="ESRCH"){l.push(h);continue}c.push({pid:h,reason:g})}return{failed:c,killed:l}},"killOrphanedRunners"),Pi=M(e=>Ee("taskkill",e,{encoding:"utf8"}),"defaultTaskkillRunner"),Ii=M((e,t)=>{process.kill(e,t)},"defaultProcessKill"),Di=M((e,t,i=Pi)=>{const o=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],n=i(o);if(n.error)throw n.error;if(typeof n.status=="number"&&n.status!==0){const l=n.status===128?"ESRCH":`taskkill exited with code ${String(n.status)}`,c=new Error(l);throw c.code=l,c}},"killViaTaskkill"),Oi=M((e,t,i=Ii)=>{i(e,t)},"killViaSignal"),Ni=M((e,t)=>{if(process.platform==="win32"){Di(e,t);return}Oi(e,t)},"defaultKill"),mt=M((e,t)=>{const i=Ee(e,t,{encoding:"utf8"});if(i.error)throw i.error;if(typeof i.status=="number"&&i.status!==0)throw new Error(`${e} exited with code ${String(i.status)}`);return typeof i.stdout=="string"?i.stdout:""},"runProcessListing"),xt=M(e=>{const t=mt("ps",["-Ao","pid=,command="]),i=[];for(const o of t.split(`
|
|
2
|
+
`)){if(o.length===0)continue;const n=/^\s*(\d+)\s+(.+)$/.exec(o);if(!n)continue;const l=Number.parseInt(n[1]??"",10),c=(n[2]??"").toLowerCase();!Number.isFinite(l)||l===e||(/(?:^|[ /])vis-native(?:\s|$|[-.])/.test(c)||/(?:^|[ /])vis\s+run\b/.test(c)||/(?:^|[ /])task-runner(?:\s|$|[-.])/.test(c))&&i.push(l)}return i},"listOrphansUnix"),yt=M(e=>{const t=mt("tasklist",["/FO","CSV","/NH"]),i=[];for(const o of t.split(/\r?\n/)){if(o.length===0)continue;const n=o.split(/","/).map(h=>h.replaceAll(/^"|"$/g,"")),l=(n[0]??"").toLowerCase(),c=Number.parseInt(n[1]??"",10);!Number.isFinite(c)||c===e||(l==="vis.exe"||l.startsWith("vis-native")||l.includes("task-runner"))&&i.push(c)}return i},"listOrphansWindows"),Fi=M(()=>{let e;try{const t=Ee("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"}},"checkWatchmanAvailability"),Mi=M((e=process.cwd())=>{let t="";try{t=ut(J(e,".gitattributes"),"utf8")}catch(i){if(i.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 i=Ee("git",["lfs","version"],{encoding:"utf8",timeout:2e3});if(i.error||typeof i.status=="number"&&i.status!==0)throw i.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"}},"checkGitLfsTracking"),Ei=M(e=>[Si(),Ci(),Fi(),Mi(e),Ti()],"runRuntimeDiagnostics");var zi=Object.defineProperty,ke=T((e,t)=>zi(e,"name",{value:t,configurable:!0}),"s$2");const ye=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],Fe=["dependencies","security","optimization","runtime"],me=ke(e=>{const t=new Map;for(const i of Fe)t.set(i,[]);for(const i of e)t.get(i.section).push(i);for(const[i,o]of t)o.length===0&&t.delete(i);return t},"groupBySection"),xe=ke((e,t,i,o)=>{let n=e.filter(l=>l.section===t);if(o&&(n=n.filter(l=>l.severity===o)),i){const l=i.toLowerCase();n=n.filter(c=>c.title.toLowerCase().includes(l))}return[...n]},"filterFindings"),Bi=ke(e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const i of Fe)e.has(i)&&(t[i]="idle");return t},"initialStatus");class Ze{static{T(this,"DoctorStore")}static{ke(this,"DoctorStore")}#e;#i=new Set;constructor(t=[]){const i=Array.isArray(t)?{findings:t}:t,o=i.findings??[],n=i.activeSections??new Set(Fe),l=Fe.find(a=>n.has(a))??"dependencies",c=xe(o,l,"",void 0),h=Bi(n);if(o.length>0)for(const a of o)h[a.section]="done";this.#e={all:o,entries:c,filterActive:!1,filterText:"",filterType:l,focusedPanel:"list",grouped:me(c),pendingAction:void 0,sectionError:{},sectionMessage:{},sectionStatus:h,selectedIndex:0,severityFilter:void 0}}getSnapshot=ke(()=>this.#e,"getSnapshot");subscribe=ke(t=>(this.#i.add(t),()=>{this.#i.delete(t)}),"subscribe");setSelectedIndex(t){const i=Math.max(0,Math.min(t,this.#e.entries.length-1));i!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:i})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:t})}setFilterType(t){if(t===this.#e.filterType)return;const i=xe(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterType:t,grouped:me(i),selectedIndex:0})}setFilter(t){const i=xe(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterText:t,grouped:me(i),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const i=xe(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:i,filterActive:!1,filterText:"",grouped:me(i),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const i=xe(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:i,grouped:me(i),selectedIndex:0,severityFilter:t})}startSection(t,i){this.#t({...this.#e,sectionMessage:{...this.#e.sectionMessage,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"running"}})}completeSection(t,i){const o=[...this.#e.all,...i],n=xe(o,this.#e.filterType,this.#e.filterText,this.#e.severityFilter),l={...this.#e.sectionMessage};delete l[t],this.#t({...this.#e,all:o,entries:n,grouped:me(n),sectionMessage:l,sectionStatus:{...this.#e.sectionStatus,[t]:"done"}})}failSection(t,i){this.#t({...this.#e,sectionError:{...this.#e.sectionError,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"error"}})}#t(t){this.#e=t;for(const i of this.#i)try{i()}catch{}}}var Li=Object.defineProperty,kt=T((e,t)=>Li(e,"name",{value:t,configurable:!0}),"r$1");const et={error:0,warn:1},Vi=kt(e=>!!e.acceptedRisk,"isAcknowledged"),wt=kt(e=>{const t=[];if(e.sections.has("dependencies")){for(const i of e.outdated)t.push({entry:i,id:`outdated:${i.packageName}`,kind:"outdated",section:"dependencies",severity:"warn",subtitle:`${i.currentRange} → ${i.newRange} (${i.updateType})`,title:i.packageName});for(const i of e.duplicates)t.push({id:`duplicate:${i.name}`,kind:"duplicate",pkg:i,section:"dependencies",severity:"warn",subtitle:`${String(i.versions.length)} versions installed`,title:i.name})}if(e.sections.has("security"))for(const i of e.outdated){if(i.vulnerabilities&&i.vulnerabilities.length>0){const o=i.vulnerabilities[0],n=Vi(i)?"warn":"error",l=i.vulnerabilities.length;t.push({entry:i,id:`vuln:${i.packageName}`,kind:"vulnerability",packageName:i.packageName,section:"security",severity:n,subtitle:l===1?`${o.severity} · ${o.id}`:`${String(l)} advisories · top: ${o.severity} ${o.id}`,title:i.packageName})}if(i.socketReport&&i.socketReport.alerts.length>0){const o=Math.round(i.socketReport.score.overall*100);t.push({entry:i,id:`socket:${i.packageName}`,kind:"socket",packageName:i.packageName,section:"security",severity:"warn",subtitle:`${String(i.socketReport.alerts.length)} alert${i.socketReport.alerts.length===1?"":"s"} · score ${String(o)}%`,title:i.packageName})}}if(e.sections.has("optimization"))for(const i of e.optimizations)t.push({entry:i,id:`opt:${i.packageName}`,kind:"optimization",section:"optimization",severity:"warn",subtitle:`${i.category} → ${i.replacement}`,title:i.packageName});if(e.sections.has("runtime"))for(const i of e.runtime)i.status==="warn"&&t.push({diagnostic:i,id:`runtime:${i.id}`,kind:"runtime",section:"runtime",severity:"warn",title:i.message});return t.sort((i,o)=>{if(i.section!==o.section){const n=["dependencies","security","optimization","runtime"];return n.indexOf(i.section)-n.indexOf(o.section)}return et[i.severity]-et[o.severity]}),t},"flattenFindings"),vt={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"};var Ui=Object.defineProperty,Gi=T((e,t)=>Ui(e,"name",{value:t,configurable:!0}),"a$2");const _i={error:"red",warn:"yellow"},Hi={error:"✖",warn:"⚠"},Ki={error:" ERROR ",warn:" WARN "},Yi=Gi(({children:e,hint:t,message:i,severity:o,title:n})=>{const l=_i[o];return s.jsxs(u,{borderColor:l,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[s.jsxs(u,{gap:1,children:[s.jsx(r,{backgroundColor:l,bold:!0,color:"black",children:Ki[o]}),s.jsx(r,{bold:!0,color:l,children:Hi[o]}),s.jsx(r,{bold:!0,wrap:"truncate-end",children:n})]}),s.jsx(r,{wrap:"truncate-end",children:i}),t?s.jsx(r,{dimColor:!0,wrap:"truncate-end",children:t}):null,e]})},"ConfigBanner");var Wi=Object.defineProperty,te=T((e,t)=>Wi(e,"name",{value:t,configurable:!0}),"d$2");const Ji={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},qi={critical:"red",high:"red",low:"gray",medium:"yellow"},Xi={major:"red",minor:"yellow",patch:"green"},R=te(({children:e,label:t,width:i=14})=>s.jsxs(u,{children:[s.jsx(u,{width:i,children:s.jsxs(r,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?s.jsx(r,{children:e}):e]}),"FieldRow"),ne=te(({children:e})=>s.jsx(u,{marginTop:1,children:s.jsx(r,{bold:!0,color:"white",children:e})}),"SectionTitle"),Qi=te(({finding:e})=>{const{entry:t}=e,i=Xi[t.updateType]??"white";return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Current",children:t.currentRange}),s.jsxs(R,{label:"Target",children:[s.jsx(r,{children:t.newRange}),s.jsxs(r,{bold:!0,color:i,children:[" (",t.updateType,")"]})]}),s.jsx(R,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?s.jsx(R,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,s.jsx(ne,{children:"Action"}),s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},"OutdatedDetail"),Zi=te(({finding:e})=>s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Versions",children:s.jsx(r,{children:String(e.pkg.versions.length)})}),s.jsx(ne,{children:"Installed versions"}),e.pkg.versions.map(t=>s.jsxs(r,{children:[" · ",t]},t)),s.jsx(ne,{children:"Action"}),s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),"DuplicateDetail"),es=te(({finding:e})=>{const t=e.entry.vulnerabilities??[];return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Package",children:e.packageName}),s.jsx(R,{label:"Current",children:e.entry.currentRange}),s.jsx(R,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?s.jsx(R,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(i=>{const o=Ji[i.severity]??"gray";return s.jsxs(u,{flexDirection:"column",marginTop:1,children:[s.jsxs(u,{children:[s.jsx(r,{bold:!0,color:o,children:i.severity}),s.jsx(r,{children:" "}),s.jsx(r,{children:i.id}),typeof i.cvssScore=="number"?s.jsxs(r,{dimColor:!0,children:[" · CVSS ",i.cvssScore.toFixed(1)]}):null]}),s.jsx(r,{wrap:"wrap",children:i.summary}),i.fixedVersions.length>0?s.jsxs(r,{dimColor:!0,children:["Fixed in: ",i.fixedVersions.join(", ")]}):null,i.aliases&&i.aliases.length>0?s.jsxs(r,{dimColor:!0,children:["Aliases: ",i.aliases.join(", ")]}):null]},i.id)})]})},"VulnerabilityDetail"),ts=te(({finding:e})=>{const t=e.entry.socketReport;if(!t)return s.jsx(r,{dimColor:!0,children:"No Socket report attached."});const i=Math.round(t.score.overall*100),o=We(t.score.overall);return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Package",children:e.packageName}),s.jsx(R,{label:"Overall",children:s.jsxs(r,{color:o,children:[String(i),"%"]})}),s.jsx(R,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?s.jsx(R,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,s.jsx(ne,{children:"Score breakdown"}),Object.entries(t.score).map(([n,l])=>{if(n==="overall")return null;const c=typeof l=="number"?l:0,h=Math.round(c*100),a=We(c);return s.jsxs(u,{children:[s.jsx(u,{width:14,children:s.jsxs(r,{dimColor:!0,children:[n,":"]})}),s.jsxs(r,{color:a,children:[String(h),"%"]})]},n)}),s.jsx(ne,{children:"Alerts"}),t.alerts.map((n,l)=>{const c=qi[n.severity]??"gray";return s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{children:[s.jsx(r,{bold:!0,color:c,children:n.severity}),s.jsx(r,{children:" "}),s.jsx(r,{children:n.type})]}),n.props?s.jsx(r,{dimColor:!0,wrap:"wrap",children:JSON.stringify(n.props)}):null]},`${n.type}-${String(l)}`)})]})},"SocketDetail"),is=te(({finding:e})=>{const{entry:t}=e;return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Package",children:t.packageName}),s.jsx(R,{label:"Category",children:t.category}),s.jsx(R,{label:"Replacement",children:t.replacement}),t.overrideSpec?s.jsx(R,{label:"Override",children:t.overrideSpec}):null,s.jsx(R,{label:"Codemod",children:s.jsx(r,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?s.jsx(R,{label:"Guide",children:s.jsx(r,{color:"cyan",underline:!0,children:t.docUrl})}):null,s.jsx(ne,{children:"Action"}),t.hasCodemod?s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to install the package override."]}):t.docUrl?s.jsx(r,{dimColor:!0,children:"No automated codemod. Open the migration guide above for the recommended alternative and steps."}):s.jsx(r,{dimColor:!0,children:"No automated codemod. Consult the package's docs or the e18e module-replacements guide for an alternative."})]})},"OptimizationDetail"),ss=te(({finding:e})=>{const{diagnostic:t}=e,i=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return s.jsxs(u,{flexDirection:"column",children:[s.jsx(R,{label:"Check",children:t.id}),s.jsx(R,{label:"Status",children:s.jsx(r,{color:i,children:t.status})}),s.jsx(ne,{children:"Message"}),s.jsx(r,{wrap:"wrap",children:t.message}),t.detail&&Object.keys(t.detail).length>0?s.jsxs(s.Fragment,{children:[s.jsx(ne,{children:"Details"}),Object.entries(t.detail).map(([o,n])=>s.jsxs(u,{children:[s.jsx(u,{width:20,children:s.jsxs(r,{dimColor:!0,children:[o,":"]})}),s.jsx(r,{children:String(n)})]},o))]}):null]})},"RuntimeDetail"),rs=te(({finding:e,focused:t,scrollRef:i})=>{const o=t?"white":"gray";if(!e)return s.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:s.jsx(r,{dimColor:!0,children:"No finding selected"})});let n;switch(e.kind){case"duplicate":{n=s.jsx(Zi,{finding:e});break}case"optimization":{n=s.jsx(is,{finding:e});break}case"outdated":{n=s.jsx(Qi,{finding:e});break}case"runtime":{n=s.jsx(ss,{finding:e});break}case"socket":{n=s.jsx(ts,{finding:e});break}case"vulnerability":{n=s.jsx(es,{finding:e});break}default:{n=s.jsx(r,{dimColor:!0,children:"Unknown finding kind."});break}}return s.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s.jsxs(u,{flexShrink:0,paddingTop:1,paddingX:2,children:[s.jsx(r,{bold:!0,color:"white",children:e.title}),s.jsxs(r,{dimColor:!0,children:[" ",vt[e.section]]})]}),s.jsxs(Ft,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[s.jsx(r,{}),n]})]})},"DoctorDetailPanel");var ns=Object.defineProperty,Ie=T((e,t)=>ns(e,"name",{value:t,configurable:!0}),"c$2");const bt={error:"red",warn:"yellow"},os={error:"✖",warn:"⚠"},ls=Ie(e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,"hasAcceptedRisk"),as=Ie(({finding:e,isSelected:t})=>{const i=bt[e.severity],o=ls(e);return s.jsxs(u,{flexShrink:0,height:1,children:[s.jsx(r,{children:t?">":" "}),s.jsxs(r,{color:i,children:[" ",os[e.severity]," "]}),s.jsx(u,{flexGrow:1,children:s.jsx(r,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),o?s.jsx(r,{color:"cyan",children:" ack"}):null,e.subtitle?s.jsxs(r,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},"FindingRow"),cs=Ie(({count:e,section:t})=>s.jsxs(u,{flexShrink:0,height:1,marginTop:1,children:[s.jsx(r,{dimColor:!0,children:"▼ "}),s.jsx(r,{bold:!0,color:"white",children:vt[t].toUpperCase()}),s.jsxs(r,{dimColor:!0,children:[" (",e,")"]})]}),"SectionHeader"),ds=Ie(({count:e,label:t,status:i})=>s.jsxs(r,{children:[t,i==="running"?s.jsxs(r,{children:[" ",s.jsx(ft,{type:"dots"})]}):null,i==="error"?s.jsx(r,{bold:!0,color:"red",children:" ✖"}):s.jsxs(r,{dimColor:!0,children:[" (",String(e),")"]})]}),"TabLabel"),us=Ie(({elapsedMs:e,entries:t,filterActive:i,filterText:o,filterType:n,focused:l,fromCache:c=!1,grouped:h,onViewportHeightChange:a,scrollOffset:g,sectionCounts:y,sectionMessage:w,sectionStatus:A,selectedIndex:E,severityFilter:p,totalAll:P,viewportHeight:z})=>{const q=l?"white":"gray",{measuredHeight:V,ref:B}=mi(z,a);let S=0,G=0;for(const b of t)b.severity==="error"?S+=1:b.severity==="warn"&&(G+=1);const _=[];S>0&&_.push(`${String(S)} error${S===1?"":"s"}`),G>0&&_.push(`${String(G)} warn${G===1?"":"s"}`);const oe=_.length>0?` (${_.join(", ")})`:"",ie=(e/1e3).toFixed(1),U=[];for(const[b,j]of h){U.push(s.jsx(cs,{count:j.length,section:b},`hdr-${b}`));for(const X of j){const C=t.indexOf(X);U.push(s.jsx(as,{finding:X,isSelected:C===E},X.id))}}let F=0;for(const[,b]of h)F+=2+b.length;const K=F>V&&V>0;return s.jsxs(u,{borderColor:q,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[s.jsx(r,{bold:!0,inverse:!0,children:" DOCTOR "}),s.jsxs(r,{wrap:"truncate",children:[t.length,t.length===P?"":`/${String(P)}`," finding",t.length===1?"":"s",oe]}),p?s.jsx(r,{bold:!0,color:bt[p],inverse:!0,children:` ${p.toUpperCase()} ONLY `}):null,c?s.jsx(r,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,s.jsxs(r,{dimColor:!0,children:[" · ",ie,"s"]})]}),s.jsx(u,{flexShrink:0,paddingX:1,paddingY:1,children:s.jsx(gi,{isFocused:l,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:T(()=>{},"onChange"),showIndex:!1,value:n,children:ye.map(({id:b,label:j})=>s.jsx(fi,{name:b,children:s.jsx(ds,{count:y[b],label:j,status:A[b]})},b))})}),(()=>{const b=Object.keys(A).filter(j=>A[j]==="running"&&w[j]).map(j=>w[j]);return b.length===0?null:s.jsx(u,{flexShrink:0,paddingX:1,children:s.jsxs(r,{dimColor:!0,wrap:"truncate",children:[s.jsx(ft,{type:"dots"})," ",b.join(" · ")]})})})(),i&&s.jsxs(u,{flexShrink:0,paddingX:1,children:[s.jsx(r,{bold:!0,color:"white",children:"/ "}),s.jsx(r,{children:o}),s.jsx(r,{inverse:!0,children:" "})]}),s.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:B,children:[s.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:s.jsx(u,{flexDirection:"column",marginTop:-g,children:U.length>0?U:s.jsx(u,{marginTop:1,children:s.jsx(r,{dimColor:!0,children:"No findings match the current filter."})})})}),K&&s.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:s.jsx(Mt,{contentHeight:F,placement:"inset",scrollOffset:g,style:"block",viewportHeight:V})})]},`list-${n}-${o}`)]})},"DoctorListPanel");var hs=Object.defineProperty,ze=T((e,t)=>hs(e,"name",{value:t,configurable:!0}),"g$1");const ps=ze(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)`}},"buildUpdateAction"),gs=ze(e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},"buildOptimizeAction"),fs=ze(e=>{if(e.kind!=="outdated"&&e.kind!=="vulnerability"&&e.kind!=="socket")return;const t=e.kind==="outdated"?e.entry.packageName:e.packageName,i=["// Add to vis.config.ts:","security: {"," acceptedRisks: {",` "${t}": {`,' reason: "explain why this risk is acceptable",',' expiresAt: "YYYY-MM-DD",'," },"," },","},"].join(`
|
|
3
|
+
`);return{command:i,configSnippet:i,description:`Acknowledge risk for ${t}`}},"buildAckAction"),ms=100,xs=40,ys=10,ks=ze(({autoExitSeconds:e=0,banner:t,fromCache:i=!1,startedAt:o,store:n})=>{const{exit:l}=Et(),{columns:c,rows:h}=zt(),a=L.useSyncExternalStore(n.subscribe,n.getSnapshot),[g,y]=L.useState(!1),[w,A]=L.useState(!1),[E,p]=L.useState(0),[P,z]=L.useState(()=>Date.now());L.useEffect(()=>{const x=setInterval(()=>{z(Date.now())},1e3);return()=>{clearInterval(x)}},[]);const q=P-o,V=L.useRef(null),B=L.useRef(null),S=a.entries[a.selectedIndex]??null,G=L.useMemo(()=>{const x={dependencies:0,optimization:0,runtime:0,security:0};for(const m of a.all)x[m.section]+=1;return x},[a.all]),_=t?t.hint?5:4:0,oe=L.useMemo(()=>{for(const x of Object.keys(a.sectionStatus))if(a.sectionStatus[x]==="running"&&a.sectionMessage[x])return 1;return 0},[a.sectionStatus,a.sectionMessage]),ie=c>=ms,U=ie?Math.max(1,h-_-2):Math.floor(h*.55),F=Math.max(1,U-6-oe-(a.filterActive?1:0)),[K,b]=L.useState(F),j=K>0?K:F,X=L.useMemo(()=>{let x=0;for(const[,m]of a.grouped)x+=2+m.length;return x},[a.grouped]),C=Math.max(0,X-j),le=Math.min(E,C),ue=L.useCallback(x=>{let m=0,k=0;for(const[,$e]of a.grouped){m+=2;for(let ae=0;ae<$e.length;ae++){if(k===x)return m;m+=1,k+=1}}return m},[a.grouped]),I=L.useCallback(x=>{const m=ue(x);p(k=>m>k+j-2?Math.min(C,Math.max(0,m-j+2)):m<k+1?Math.max(0,m-1):k)},[ue,j,C]);if(L.useEffect(()=>{B.current?.scrollToTop()},[S?.id]),Bt((x,m)=>{if(x==="c"&&m.ctrl){l();return}if(!w){if(g){m.escape||x==="?"?y(!1):x==="q"?(y(!1),A(!0)):m.downArrow||x==="j"?V.current?.scrollBy(1):(m.upArrow||x==="k")&&V.current?.scrollBy(-1);return}if(x==="?"){y(!0);return}if(x==="q"){A(!0);return}if(m.tab){n.setFocusedPanel(a.focusedPanel==="list"?"detail":"list");return}if(a.filterActive){if(m.escape||m.return){n.setFilterActive(!1);return}if(m.backspace){p(0),n.setFilter(a.filterText.slice(0,-1));return}x&&!m.ctrl&&!m.meta&&(p(0),n.setFilter(a.filterText+x));return}if(a.focusedPanel==="list"&&(m.leftArrow||m.rightArrow)){const k=ye.findIndex(ae=>ae.id===a.filterType),$e=m.rightArrow?(k+1)%ye.length:(k-1+ye.length)%ye.length;p(0),B.current?.scrollToTop(),n.setFilterType(ye[$e].id);return}if(a.focusedPanel==="list"){if(m.downArrow||x==="j"){const k=Math.min(a.selectedIndex+1,a.entries.length-1);n.setSelectedIndex(k),I(k);return}if(m.upArrow||x==="k"){const k=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(k),I(k);return}if(m.pageDown){const k=Math.min(a.selectedIndex+10,a.entries.length-1);n.setSelectedIndex(k),I(k);return}if(m.pageUp){const k=Math.max(a.selectedIndex-10,0);n.setSelectedIndex(k),I(k);return}if(m.home){n.setSelectedIndex(0),p(0);return}if(m.end){const k=a.entries.length-1;n.setSelectedIndex(k),I(k);return}if(x==="/"){n.setFilterActive(!0);return}if(x==="e"){n.setSeverityFilter(a.severityFilter==="error"?void 0:"error"),p(0);return}if(x==="w"){n.setSeverityFilter(a.severityFilter==="warn"?void 0:"warn"),p(0);return}if(x==="u"&&S){const k=ps(S);k&&(n.setPendingAction(k),l());return}if(x==="o"&&S){const k=gs(S);k&&(n.setPendingAction(k),l());return}if(x==="a"&&S){const k=fs(S);k&&(n.setPendingAction(k),l());return}if(x==="d"){n.setFocusedPanel("detail");return}return}if(m.escape||m.leftArrow){n.setFocusedPanel("list");return}if(m.downArrow||x==="j"){B.current?.scrollBy(1);return}if(m.upArrow||x==="k"){B.current?.scrollBy(-1);return}if(m.pageDown){B.current?.scrollBy(10);return}if(m.pageUp){B.current?.scrollBy(-10);return}if(m.home){B.current?.scrollToTop();return}m.end&&B.current?.scrollToBottom()}},{isActive:!0}),c<xs||h<ys)return s.jsx(u,{alignItems:"center",height:h,justifyContent:"center",width:c,children:s.jsxs(r,{color:"yellow",children:["Terminal too small (",c,"x",h,")"]})});const Q=a.focusedPanel==="detail",ee=[s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"q"}),s.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"?"}),s.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"↑↓"}),s.jsx(r,{dimColor:!0,children:Q?"SCROLL":"NAV"})]},"nav"),Q?s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"←/Esc"}),s.jsx(r,{dimColor:!0,children:"LIST"})]},"lr"):s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"←→"}),s.jsx(r,{dimColor:!0,children:"SECTION"})]},"lr"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"/"}),s.jsx(r,{dimColor:!0,children:"SEARCH"})]},"search"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"e/w"}),s.jsx(r,{dimColor:!0,children:"SEVERITY"})]},"sev"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"u/o/a"}),s.jsx(r,{dimColor:!0,children:"ACTION"})]},"actions"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"Tab"}),s.jsx(r,{dimColor:!0,children:"PANEL"})]},"tab")],he=s.jsx(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:s.jsx(u,{gap:2,overflow:"hidden",paddingX:1,children:ee})}),pe=s.jsxs(Lt,{footer:s.jsxs(r,{dimColor:!0,children:[s.jsx(r,{bold:!0,color:"white",children:"↑↓"})," scroll ",s.jsx(r,{bold:!0,color:"white",children:"?"}),"/",s.jsx(r,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:V,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:g,width:56,children:[s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" ↑/k "}),s.jsx(r,{dimColor:!0,children:"Move up"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" ↓/j "}),s.jsx(r,{dimColor:!0,children:"Move down"})]})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" PgUp"}),s.jsx(r,{dimColor:!0,children:" Jump up 10"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" PgDn"}),s.jsx(r,{dimColor:!0,children:" Jump down 10"})]})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Home"}),s.jsx(r,{dimColor:!0,children:" Jump to top"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" End"}),s.jsx(r,{dimColor:!0,children:" Jump to bottom"})]})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Tab"}),s.jsx(r,{dimColor:!0,children:" Switch panel"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" →/←"}),s.jsx(r,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"FILTER"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" /"}),s.jsx(r,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" e"}),s.jsx(r,{dimColor:!0,children:" Toggle errors-only filter"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" w"}),s.jsx(r,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" u"}),s.jsx(r,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" o"}),s.jsx(r,{dimColor:!0,children:" Exit + suggest optimize command"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" a"}),s.jsx(r,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" d"}),s.jsx(r,{dimColor:!0,children:" Focus detail panel"})]})]}),s.jsxs(u,{flexDirection:"column",children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"EXIT"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" q"}),s.jsx(r,{dimColor:!0,children:" Quit (with countdown)"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Ctrl+C"}),s.jsx(r,{dimColor:!0,children:" Quit immediately"})]})]})]}),ge=s.jsx(us,{elapsedMs:q,entries:a.entries,filterActive:a.filterActive,filterText:a.filterText,filterType:a.filterType,focused:a.focusedPanel==="list",fromCache:i,grouped:a.grouped,onViewportHeightChange:b,scrollOffset:le,sectionCounts:G,sectionMessage:a.sectionMessage,sectionStatus:a.sectionStatus,selectedIndex:a.selectedIndex,severityFilter:a.severityFilter,totalAll:a.all.length,viewportHeight:j}),fe=t?s.jsx(Yi,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,je=s.jsx(rs,{finding:S,focused:a.focusedPanel==="detail",scrollRef:B});if(ie){const x=Math.floor(c*.4);return s.jsxs(u,{flexDirection:"column",height:h,width:c,children:[fe,s.jsxs(u,{flexDirection:"row",flexGrow:1,children:[s.jsx(u,{flexGrow:1,children:ge}),s.jsx(u,{width:x,children:je})]}),he,s.jsx(Je,{autoExitSeconds:e||3,onCancel:T(()=>{A(!1)},"onCancel"),visible:w}),pe]})}return s.jsxs(u,{flexDirection:"column",height:h,width:c,children:[fe,s.jsx(u,{height:U,children:ge}),s.jsx(u,{flexGrow:1,children:je}),he,s.jsx(Je,{autoExitSeconds:e||3,onCancel:T(()=>{A(!1)},"onCancel"),visible:w}),pe]})},"VisDoctorApp");var ws=Object.defineProperty,ve=T((e,t)=>ws(e,"name",{value:t,configurable:!0}),"n");const vs=ve(e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),"escapeRegex"),bs=ve(e=>{const t=e.split("*").map(i=>vs(i));return new RegExp(`^${t.join(".*")}$`,"i")},"compilePattern"),js=ve(e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>bs(t)):[],"parseFilterPatterns"),Ne=ve((e,t)=>{for(const i of t)if(i.test(e))return!0;return!1},"matchesAny"),$s=ve((e,t,i)=>{if(t.length===0)return e;const o=e.outdated.filter(g=>Ne(g.packageName,t)),n=e.duplicates.filter(g=>Ne(g.name,t)),l=e.optimizations.filter(g=>Ne(g.packageName,t));let c=0,h=0,a=0;for(const g of o)g.vulnerabilities&&(c+=g.vulnerabilities.length),g.socketReport&&(h+=g.socketReport.alerts.length,g.socketReport.score.overall<i&&(a+=1));return{...e,duplicates:n,optimizations:l,outdated:o,socketIssues:{alerts:h,lowScore:a},vulnCount:c}},"applyFilter"),jt=ve((e,t)=>t.length===0?[...e]:e.filter(i=>{if(i.kind==="runtime")return!0;const o=i.kind==="duplicate"?i.pkg.name:i.kind==="outdated"||i.kind==="optimization"?i.entry.packageName:i.packageName;return Ne(o,t)}),"filterFindingsByPattern");var Ss=Object.defineProperty,be=T((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"r");const $t=["dependencies","security","optimization","runtime"],tt=be(e=>{const t=new Set;if(!e)return t;for(const i of e.split(",")){const o=i.trim().toLowerCase();$t.includes(o)&&t.add(o)}return t},"parseSectionList"),Cs=be((e,t)=>{if(e!==void 0&&e!=="")return tt(e);const i=tt(t);return new Set($t.filter(o=>!i.has(o)))},"resolveSections"),St=be(e=>{const t={micro:0,native:0,preferred:0,socket:0,total:e.length};for(const i of e)switch(i.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},"summarizeOptimizations"),re=be((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(i=>i.status==="warn")?"warn":"ok";case"security":return e.vulnCount>0||e.socketIssues.alerts>0?"error":e.socketIssues.lowScore>0?"warn":"ok";default:return"ok"}},"sectionStatus"),Rs=be((e,t)=>{const i=St(e.optimizations),o={dependencies:re(e,"dependencies"),optimization:re(e,"optimization"),runtime:re(e,"runtime"),security:re(e,"security")},n=new Set([...Object.values(o),e.supplyChain.status]),l=n.has("error")?"error":n.has("warn")?"warn":"ok";return{dependencies:{duplicates:e.duplicates.length,installed:e.installedCount,outdated:e.outdated.length,status:o.dependencies},elapsedMs:e.elapsedMs,optimizations:{microUtilities:i.micro,native:i.native,preferred:i.preferred,socket:i.socket,status:o.optimization,total:i.total},packageManager:t,runtime:e.runtime.map(c=>({detail:c.detail,id:c.id,message:c.message,status:c.status})),runtimeStatus:o.runtime,security:{alerts:e.socketIssues.alerts,lowScorePackages:e.socketIssues.lowScore,status:o.security,vulnerabilities:e.vulnCount},status:l,supplyChain:{findings:e.supplyChain.findings.map(c=>({detail:c.detail,label:c.label,severity:c.severity})),status:e.supplyChain.status},workspaces:e.workspaceCount}},"buildJsonPayload"),it=be((e,t)=>{const i=e.runtime.some(n=>n.status==="warn"),o=e.vulnCount>0||e.socketIssues.alerts>0;return t?o||e.outdated.length>0||e.duplicates.length>0||i:o},"shouldFail");var Ts=Object.defineProperty,Be=T((e,t)=>Ts(e,"name",{value:t,configurable:!0}),"u$1");const As=["aube-workspace.yaml","pnpm-workspace.yaml"],Ce=Be(e=>typeof e=="boolean"?e:void 0,"asBool"),Ps=Be(e=>{if(e==="no-downgrade"||e==="off")return e},"asTrustPolicy"),Is=Be(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 i of As){const o=J(e,i);if(!Ae(o))continue;let n;try{n=Vt(qt(o))}catch{continue}if(typeof n!="object"||n===null)continue;const l=n;return t.source=i,t.paranoid=Ce(l.paranoid),t.trustPolicy=Ps(l.trustPolicy),t.blockExoticSubdeps=Ce(l.blockExoticSubdeps),t.jailBuilds=Ce(l.jailBuilds),t.strictDepBuilds=Ce(l.strictDepBuilds),t.minimumReleaseAgeStrict=Ce(l.minimumReleaseAgeStrict),typeof l.minimumReleaseAge=="number"&&Number.isFinite(l.minimumReleaseAge)&&(t.minimumReleaseAge=l.minimumReleaseAge),l.allowBuilds&&typeof l.allowBuilds=="object"&&!Array.isArray(l.allowBuilds)&&(t.allowBuildsCount=Object.keys(l.allowBuilds).length),t}return t},"readAubeSecurityPosture"),Ds=Be(e=>e.paranoid?{...e,jailBuilds:!0,minimumReleaseAgeStrict:!0,strictDepBuilds:!0,trustPolicy:"no-downgrade"}:e,"applyAubeParanoidOverrides");var Os=Object.defineProperty,Ue=T((e,t)=>Os(e,"name",{value:t,configurable:!0}),"i");const Ns=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,Fs=Ue(e=>{const t=Ns.exec(e);if(t)return{name:t[1],version:t[2]}},"parsePatchKey"),Ms=Ue((e,t)=>{let i;try{if(t==="pnpm"){const n=J(e,"pnpm-workspace.yaml");Ae(n)&&(i=Ut(n)?.patchedDependencies)}else if(t==="bun"){const n=J(e,"package.json");Ae(n)&&(i=ht(n)?.patchedDependencies)}}catch{return[]}if(!i||typeof i!="object")return[];const o=[];for(const[n,l]of Object.entries(i)){if(typeof l!="string"||l.length===0)continue;const c=Fs(n);c&&o.push({name:c.name,patchFile:l,resolvedPatchFile:Xt(l)?l:dt(e,l),version:c.version})}return o},"readPatchedDependencies"),Es=Ue(e=>{const t=[];for(const i of e)Ae(i.resolvedPatchFile)||t.push({entry:i,kind:"missing-file"});return t},"findPatchIssues");var zs=Object.defineProperty,Ct=T((e,t)=>zs(e,"name",{value:t,configurable:!0}),"c");const st=Ct(e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok","rollUpStatus"),Bs=Ct((e,t={})=>{const i=[],o=e?.security;if(!o)return i.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:i,status:st(i)};const n=o.policies?.firstSeen?.minutes,l=o.policies?.publisherChange,c=o.policies?.installScripts;n===void 0?i.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?i.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"}):i.push({label:`policies.firstSeen.minutes: ${String(n)} minutes`,severity:"ok"}),l?.mode===void 0||l.mode==="off"?i.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`policies.publisherChange.mode: ${l?.mode??"not set"}`,severity:"warn"}):i.push({label:`policies.publisherChange.mode: ${l.mode}`,severity:"ok"}),o.blockExoticSubdeps===void 0||!o.blockExoticSubdeps?i.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(o.blockExoticSubdeps??!1)}`,severity:"warn"}):i.push({label:"blockExoticSubdeps: true",severity:"ok"});const h=c?.allow?Object.keys(c.allow).length:0;if(h===0?i.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"}):i.push({label:`policies.installScripts.allow: ${String(h)} ${h===1?"entry":"entries"}`,severity:"ok"}),c?.strict&&h===0&&i.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=xi(t.workspaceRoot);if(a.length>0){const g=[...new Set(a.map(y=>y.tool))].sort((y,w)=>y.localeCompare(w)).join(", ");i.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 ${g}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager==="aube"){const a=Is(t.workspaceRoot),g=Ds(a),y=g.source?` (from ${g.source})`:"";g.paranoid===!0&&i.push({detail:"Forces jailBuilds, trustPolicy=no-downgrade, minimumReleaseAgeStrict, strictStoreIntegrity, and strictDepBuilds on.",label:`aube paranoid: true${y}`,severity:"ok"}),g.trustPolicy==="off"&&i.push({detail:"Trust downgrades between releases will not be blocked. Set trustPolicy: no-downgrade in aube-workspace.yaml.",label:`aube trustPolicy: off${y}`,severity:"warn"}),g.blockExoticSubdeps===!1&&i.push({detail:"Transitive deps from git+, file:, and tarball URLs will not be blocked. Re-enable with blockExoticSubdeps: true.",label:`aube blockExoticSubdeps: false${y}`,severity:"warn"}),g.minimumReleaseAge===0&&i.push({detail:"Newly published versions are not held in a cooling window. Restore with minimumReleaseAge: 1440 (24h) or higher.",label:`aube minimumReleaseAge: 0${y}`,severity:"warn"}),g.jailBuilds===!0&&i.push({label:`aube jailBuilds: true${y}`,severity:"ok"}),g.strictDepBuilds===!0&&i.push({label:`aube strictDepBuilds: true${y}`,severity:"ok"}),g.allowBuildsCount>0&&i.push({label:`aube allowBuilds: ${String(g.allowBuildsCount)} ${g.allowBuildsCount===1?"entry":"entries"}${y}`,severity:"ok"})}if(t.workspaceRoot&&t.packageManager){const a=Ms(t.workspaceRoot,t.packageManager);if(a.length>0){const g=Es(a);if(g.length===0)i.push({label:`patchedDependencies: ${String(a.length)} ${a.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const y of g)i.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${y.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${y.entry.name}@${y.entry.version}`,severity:"error"})}}return{findings:i,status:st(i)}},"buildSupplyChainPosture");var Ls=Object.defineProperty,$=T((e,t)=>Ls(e,"name",{value:t,configurable:!0}),"u");const H=$(e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,"fmtDuration"),De=$(async(e,t,i,o)=>{if(!e)return i();e.start(t);const n=Date.now();try{const l=await i(),c=Date.now()-n,{status:h,summary:a}=o(l,c);return e.finish(t,h,a),l}catch(l){const c=Date.now()-n,h=l instanceof Error?l.message:String(l);throw e.finish(t,"error",`${h} (${H(c)})`),l}},"tracked"),Vs=$((e,t)=>{const i={duplicates:t.duplicates,elapsedMs:0,installedCount:0,optimizations:t.optimizations,outdated:t.outdated,runtime:t.runtime,sections:new Set([e]),socketIssues:{alerts:0,lowScore:0},supplyChain:{findings:[],status:"ok"},vulnCount:0,workspaceCount:0};return wt(i)},"buildSectionFindings"),rt=$(async e=>{const{filterPatterns:t,installed:i,progress:o,resolveCodemods:n,sections:l,store:c,visConfig:h,workspaceRoot:a}=e,g=l.has("dependencies"),y=l.has("security"),w=l.has("optimization"),A=l.has("runtime"),E=$((f,D)=>jt(Vs(f,D),t),"sectionFindings"),p=gt(a),{packageManager:P}=ot(a),z=Xe(J(a,"package.json"),!1),q=pt(a),V=new Set(z);for(const f of q){const D=Xe(J(dt(a,f),"package.json"),!1);for(const O of D)V.add(O)}const B=Gt(a),S=lt(a,P),G=at(h?.security,{minimumScore:h?.security?.policies?.score?.minimum}),_=h?.security?.policies?.score?.minimum??ct,oe=h?.security?.acceptedRisks,ie=ii(a,p.name),U={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},F=g?ui(a,p.name):[],K=w?si(V):[],b=w?ri(V,ie,p,!1):[],j=new Set(K.map(f=>f.packageName)),X=b.filter(f=>!j.has(f.packageName)),C=[...K,...X],le=A?Ei(a):[];c&&(g&&c.startSection("dependencies",S.size>0?"checking outdated catalog dependencies":"scanning duplicates"),y&&c.startSection("security",i.length>0?`scanning ${String(i.length)} packages for advisories`:"no installed packages to scan"),w&&c.startSection("optimization","matching e18e + socket overrides"),A&&c.startSection("runtime","running runtime diagnostics")),c&&A&&c.completeSection("runtime",E("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:le}));const ue=(g||y)&&S.size>0?De(o,"outdated",()=>_t(S,U,B,void 0,a,G,oe),(f,D)=>{const O=f.outdated.length;return{status:O>0?"warn":"ok",summary:O>0?`${String(O)} outdated · ${H(D)}`:`up to date · ${H(D)}`}}):Promise.resolve({failed:[],ignored:[],outdated:[]}),I=y&&i.length>0?De(o,"vulnerabilities",()=>Ht(i.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let O=0;for(const se of f.values())O+=se.length;return{status:O>0?"error":"ok",summary:O>0?`${String(O)} found · ${H(D)}`:`none found · ${H(D)}`}}):Promise.resolve(new Map),Q=y&&G.length>0&&i.length>0?De(o,"socket",()=>Kt(G,i.map(f=>({name:f.name,version:f.version}))),(f,D)=>{let O=0,se=0;for(const Ye of f.values())O+=Ye.alerts.length,Ye.score.overall<_&&(se+=1);const Ke=O+se;return{status:Ke>0?"warn":"ok",summary:Ke>0?`${String(O)} alert${O===1?"":"s"}, ${String(se)} low-score · ${H(D)}`:`clean · ${H(D)}`}}):Promise.resolve(new Map);let ee,he,pe,ge;const fe=ue.catch(f=>(ee=f instanceof Error?f.message:String(f),c||d.warn(`Outdated scan failed: ${ee}`),{failed:[],ignored:[],outdated:[]})),je=I.catch(f=>(he=f instanceof Error?f.message:String(f),c||d.warn(`Vulnerability scan failed: ${he}`),new Map)),x=Q.catch(f=>(pe=f instanceof Error?f.message:String(f),c||d.warn(`Socket scan failed: ${pe}`),new Map)),m=c&&g?fe.then(f=>{if(ee){c.failSection("dependencies",ee);return}c.completeSection("dependencies",E("dependencies",{duplicates:F,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,k=c&&y?Promise.all([fe,je,x]).then(([f])=>{const D=ee??he??pe;if(D){c.failSection("security",D);return}c.completeSection("security",E("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,$e=(async()=>{if(n&&w&&C.length>0&&await De(o,"codemods",async()=>(await ni(C),C),(f,D)=>{const O=f.filter(se=>se.hasCodemod||se.category==="socket").length;return{status:"ok",summary:`${String(O)} auto-fixable · ${H(D)}`}}).catch(f=>{ge=f instanceof Error?f.message:String(f)}),c&&w){if(ge){c.failSection("optimization",ge);return}c.completeSection("optimization",E("optimization",{duplicates:[],optimizations:C,outdated:[],runtime:[]}))}})(),[ae,Tt,At]=await Promise.all([fe,je,x]);await Promise.all([m,k,$e]);let _e=0,He=0;if(y&&G.length>0)for(const f of At.values())_e+=f.alerts.length,f.score.overall<_&&(He+=1);let Le=0;if(y){for(const f of ae.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Le+=f.vulnerabilities.length);for(const f of Tt.values())Le+=f.length}return{duplicates:F,installedCount:i.length,optimizations:w?C:[],outdated:g?ae.outdated:[],runtime:le,sections:l,socketIssues:{alerts:_e,lowScore:He},supplyChain:Bs(h,{packageManager:P,workspaceRoot:a}),vulnCount:Le,workspaceCount:q.length}},"streamScans"),Us=$(e=>{switch(e){case"error":return Re(N.failure);case"skip":return v(N.dash);case"warn":return Me(N.warning);default:return we(N.success)}},"sectionIcon"),de=$((e,t)=>{const i=process.stderr.columns??80,o=Math.max(20,Math.min(i-2,60)),n=N.dash.repeat(2),l=`${Us(t)} ${ce(e)}`,c=l.replaceAll(/\[[0-9;]*m/g,"").length,h=Math.max(0,o-c-n.length-2);return`${n} ${l} ${v(N.dash.repeat(h))}`},"heading"),W=$(e=>` ${we(N.success)} ${e}`,"itemOk"),Z=$(e=>` ${Me(N.warning)} ${e}`,"itemWarn"),Ge=$(e=>` ${Re(N.failure)} ${e}`,"itemError"),Rt=$(e=>` ${v(N.dash)} ${v(e)}`,"itemSkip"),Y=$((e,t,i)=>{const o=`${ce(String(e))} ${v(t)}`;return i?`${o} ${v(`(${i})`)}`:o},"countLine"),Gs=$(e=>{if(e.sections.has("dependencies")){if(d.log(""),d.log(de("Dependencies",re(e,"dependencies"))),d.log(W(Y(e.installedCount,"packages installed"))),e.outdated.length>0){const t=e.outdated.filter(l=>l.updateType==="major").length,i=e.outdated.filter(l=>l.updateType==="minor").length,o=e.outdated.filter(l=>l.updateType==="patch").length,n=[];t>0&&n.push(`${String(t)} major`),i>0&&n.push(`${String(i)} minor`),o>0&&n.push(`${String(o)} patch`),d.log(Z(Y(e.outdated.length,"outdated",n.join(", "))))}else d.log(W("All dependencies up to date"));e.duplicates.length>0?d.log(Z(Y(e.duplicates.length,"packages with duplicate versions"))):d.log(W("No duplicate dependencies"))}},"displayDependencies"),_s=$(e=>{e.sections.has("security")&&(d.log(""),d.log(de("Security",re(e,"security"))),e.vulnCount>0?d.log(Ge(Y(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):d.log(W("No known vulnerabilities")),e.socketIssues.alerts>0&&d.log(Z(Y(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&d.log(Z(Y(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(W("No security issues detected")))},"displaySecurity"),Hs=$(e=>{if(!e.sections.has("optimization"))return;d.log(""),d.log(de("Optimization",re(e,"optimization")));const t=St(e.optimizations);if(t.total===0){d.log(W("No optimizations available"));return}t.native>0&&d.log(Z(Y(t.native,"replaceable with native APIs"))),t.preferred>0&&d.log(Z(Y(t.preferred,"with lighter alternatives"))),t.micro>0&&d.log(Z(Y(t.micro,"trivial micro-utilities"))),t.socket>0&&d.log(Z(Y(t.socket,"@socketregistry overrides available")))},"displayOptimization"),Ks=$(e=>{d.log(""),d.log(de("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const i=t.severity==="ok"?W(t.label):t.severity==="error"?Ge(t.label):Z(t.label);d.log(i),t.detail&&d.log(` ${v(N.arrow)} ${v(t.detail)}`)}e.supplyChain.status!=="ok"&&d.log(` ${v(N.arrow)} ${v("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},"displaySupplyChain"),Ys=$(e=>{if(e.sections.has("runtime")){d.log(""),d.log(de("Runtime",re(e,"runtime")));for(const t of e.runtime)t.status==="ok"?d.log(W(t.message)):t.status==="skip"?d.log(Rt(t.message)):d.log(Z(t.message))}},"displayRuntime"),Ws=$((e,t)=>{const i=e.vulnCount,o=e.runtime.filter(l=>l.status==="warn").length,n=e.outdated.length+e.duplicates.length+e.optimizations.length+o;if(t){if(i===0&&n===0)d.success(`Everything looks good! ${v(`(${H(e.elapsedMs)})`)}`);else{const l=[];i>0&&l.push(Re(`${String(i)} security`)),n>0&&l.push(Me(`${String(n)} improvement${n===1?"":"s"}`)),d.log(`${Re(N.failure)} ${l.join(", ")} ${v(`(${H(e.elapsedMs)})`)}`)}return}d.log(""),d.log(de("Summary","ok")),i===0&&n===0?d.success(`Everything looks good! ${v(`(${H(e.elapsedMs)})`)}`):(i>0&&d.error(`${String(i)} security issue${i===1?"":"s"}`),n>0&&d.log(` ${Te(N.arrow)} ${ce(String(n))} ${v(`improvement${n===1?"":"s"} available`)} ${v(`(${H(e.elapsedMs)})`)}`))},"displaySummary"),Js=$(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(ce("Next steps:"));for(const i of t)d.log(` ${v(N.arrow)} ${i}`)}d.log("")},"displayActions"),qs=$((e,t)=>{t||(Gs(e),_s(e),Hs(e),Ys(e),Ks(e)),Ws(e,t)},"displayResults"),Xs=$((e,t,i,o,n)=>{const l=[],c=e.has("dependencies"),h=e.has("security"),a=e.has("optimization");return(c||h)&&t>0&&l.push({id:"outdated",label:"Outdated catalog dependencies"}),h&&o>0&&l.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),h&&i&&o>0&&l.push({id:"socket",label:"Socket.dev supply-chain reports"}),a&&n&&l.push({id:"codemods",label:"Codemod availability"}),l},"planScanTasks"),Qs=$(e=>{if(d.log(""),d.log(`${ce(Te("vis doctor"))} ${v("— project health check")}`),d.log(W(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.workspaceCount!==void 0&&e.workspaceCount>0&&d.log(W(Y(e.workspaceCount,`workspace package${e.workspaceCount===1?"":"s"}`))),e.runtimeFindings.length===0)d.log(W(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const i=t.severity==="error"?Re:Me;d.log(Ge(`Runtime: ${i(t.message)}`))}d.log(` ${v(N.arrow)} Run ${we("vis toolchain install")} to install pinned versions, or ${we("vis toolchain status")} for the per-tool breakdown.`)}d.log("")},"printBanner"),fr=$(async({logger:e,options:t,visConfig:i,visConfigError:o,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const l=t.format==="json"||t.json===!0,c=Cs(t.only,t.skip),h=!!t.quiet,a=t.progress===!1,g=js(t.filter);if(c.size===0){d.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const y=Date.now(),w=gt(n),A=ci(n),E=!!process.stdout.isTTY,p=!l&&E&&!Jt&&!h&&!a;!l&&!p&&Qs({nodeVersion:process.versions.node,packageManagerName:w.name,packageManagerVersion:w.version,runtimeFindings:A,workspaceCount:void 0});const P=lt(n,ot(n).packageManager),z=hi(n,w.name),q=z.length,V=at(i?.security).length>0,B=i?.security?.policies?.score?.minimum??ct,S=pt(n);if(!l&&!h&&!p){const I=S.length>0?v(` · ${String(S.length)} workspace package${S.length===1?"":"s"}`):"";d.log(`${v("·")} ${v("Found")} ${ce(String(q))} ${v(`installed package${q===1?"":"s"}`)}${I}`)}const G=o?{hint:o.file?`Continuing with default settings — fix or regenerate ${o.file} (vis init --force).`:"Continuing with default settings.",message:o.message,severity:"error",title:o.file?`Failed to load ${o.file}`:"Failed to load vis.config"}:void 0,_=pi(n,w.name)?.file,oe=_?J(n,_):void 0,ie=ti(n),U=t.cache!==!1&&!t.fix?vi({configPath:ie,lockfilePath:oe,sections:c,socketEnabled:V,workspaceRoot:n}):void 0,F=U?bi(U):void 0,K=F!==void 0;let b,j;if(p){const I=F?new Ze({activeSections:c,findings:jt(wt(F),g)}):new Ze({activeSections:c}),Q=Yt(Wt.createElement(ks,{banner:G,fromCache:K,startedAt:y,store:I}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{b=F??await rt({filterPatterns:g,installed:z,resolveCodemods:!!t.fix,sections:c,store:I,visConfig:i,workspaceRoot:n})}catch(ee){throw Q.unmount(),ee}await Q.waitUntilExit(),j=I.getSnapshot().pendingAction}else if(F)b=F;else{const I=Xs(c,P.size,V,q,!!t.fix),Q=di(I,{live:!l&&!h&&!a});try{b=await rt({filterPatterns:g,installed:z,progress:Q,resolveCodemods:!!t.fix,sections:c,visConfig:i,workspaceRoot:n})}finally{Q.stop()}}const X={...b,elapsedMs:Date.now()-y};if(U&&!K)try{ji(U,X)}catch{}const C=$s(X,g,B);if(l){process.stdout.write(`${JSON.stringify(Rs(C,w.name),void 0,2)}
|
|
4
|
+
`),t.exitCode&&it(C,!!t.strict)&&(process.exitCode=1);return}K&&!h&&d.log(`${v("·")} Cached results (use --no-cache to refresh)`),g.length>0&&!h&&d.log(`${v("·")} Filter active: ${Te(t.filter??"")}`),qs(C,h);const le=C.runtime.some(I=>I.id===Oe&&I.status==="warn"),ue=C.sections.has("optimization")&&C.optimizations.length>0;t.fix&&(ue||le)?await Zs({force:!!t.fixForce,logger:e,pm:w,recoverOrphans:le,results:C,useEditorconfig:i?.editorconfig??!0,workspaceRoot:n}):h||Js(C),j&&(process.stdout.write(`
|
|
5
|
+
`),process.stdout.write(`${ce("→ ")}${j.description}
|
|
6
|
+
`),j.configSnippet?(process.stdout.write(`
|
|
7
|
+
`),process.stdout.write(`${v(j.configSnippet)}
|
|
8
|
+
`)):process.stdout.write(` ${Te(j.command)}
|
|
9
|
+
`),process.stdout.write(`
|
|
10
|
+
`)),t.exitCode&&it(C,!!t.strict)&&(process.exitCode=1)},"execute"),Zs=$(async e=>{const{force:t,logger:i,pm:o,recoverOrphans:n,results:l,useEditorconfig:c,workspaceRoot:h}=e;d.log(""),d.log(de("Applying fixes","ok"));const a=l.optimizations.filter(p=>p.category==="socket"&&p.overrideSpec).map(p=>({original:p.packageName,spec:p.overrideSpec})),g=l.optimizations.filter(p=>p.category!=="socket"&&p.hasCodemod),y=l.optimizations.filter(p=>p.category!=="socket"&&!p.hasCodemod);let w=!1,A=0;const E=[];if(n){const p=Ai({force:t});if(p.killed.length>0&&(d.success(`Cleaned up ${String(p.killed.length)} orphaned process${p.killed.length===1?"":"es"} (PIDs: ${p.killed.join(", ")}).`),w=!0),p.failed.length>0){const P=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";d.warn(`Could not signal ${String(p.failed.length)} orphan${p.failed.length===1?"":"s"}: ${p.failed.map(z=>`${String(z.pid)} (${z.reason})`).join(", ")}.${P}`)}}if(a.length>0){const p=oi(h,J(h,"package.json"),a,o,c);p.added.length>0&&(d.success(`Added ${String(p.added.length)} security override${p.added.length===1?"":"s"}.`),w=!0),p.updated.length>0&&(d.success(`Updated ${String(p.updated.length)} override${p.updated.length===1?"":"s"}.`),w=!0)}for(const p of g)try{const P=await li(h,p.packageName);P.filesChanged>0&&(d.success(`${p.packageName}: ${String(P.filesChanged)} file${P.filesChanged===1?"":"s"} updated`),A+=1,w=!0)}catch(P){const z=P instanceof Error?P.message:String(P);E.push({error:z,package:p.packageName}),d.warn(`${p.packageName}: codemod failed — ${z}`)}a.length>0&&(d.log(`${Te(N.arrow)} Running ${o.name} install to update lockfile…`),ai(o,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},h,i),w=!0),d.log(""),w?d.success(`Fixes applied. ${A>0?`${String(A)} codemod${A===1?"":"s"} applied.`:""}`.trim()):d.log(Rt("No auto-fixable items in the current run.")),E.length>0&&d.warn(`${String(E.length)} codemod${E.length===1?"":"s"} failed (run ${we("vis optimize")} for the interactive picker).`),y.length>0&&d.notice(`${String(y.length)} optimization${y.length===1?"":"s"} need manual review (no codemod). Run ${we("vis optimize")} to inspect them.`)},"runFixes");export{fr as default};
|