@visulima/vis 1.0.0-alpha.14 → 1.0.0-alpha.15

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 (87) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE.md +936 -1
  3. package/dist/bin.js +1 -1
  4. package/dist/config/index.js +1 -1
  5. package/dist/packem_chunks/applyDefaults.js +2 -2
  6. package/dist/packem_chunks/bin.js +314 -311
  7. package/dist/packem_chunks/fix.js +1 -1
  8. package/dist/packem_chunks/handler.js +1 -1
  9. package/dist/packem_chunks/handler10.js +1 -1
  10. package/dist/packem_chunks/handler12.js +5 -5
  11. package/dist/packem_chunks/handler14.js +3 -3
  12. package/dist/packem_chunks/handler15.js +1 -1
  13. package/dist/packem_chunks/handler18.js +1 -1
  14. package/dist/packem_chunks/handler19.js +1 -1
  15. package/dist/packem_chunks/handler2.js +1 -1
  16. package/dist/packem_chunks/handler20.js +1 -1
  17. package/dist/packem_chunks/handler22.js +1 -1
  18. package/dist/packem_chunks/handler23.js +1 -1
  19. package/dist/packem_chunks/handler24.js +1 -1
  20. package/dist/packem_chunks/handler25.js +1 -1
  21. package/dist/packem_chunks/handler26.js +1 -1
  22. package/dist/packem_chunks/handler27.js +2 -2
  23. package/dist/packem_chunks/handler28.js +7 -7
  24. package/dist/packem_chunks/handler3.js +1 -1
  25. package/dist/packem_chunks/handler30.js +10 -10
  26. package/dist/packem_chunks/handler31.js +1 -1
  27. package/dist/packem_chunks/handler32.js +1 -1
  28. package/dist/packem_chunks/handler33.js +21 -21
  29. package/dist/packem_chunks/handler34.js +2 -2
  30. package/dist/packem_chunks/handler35.js +3 -3
  31. package/dist/packem_chunks/handler36.js +20 -20
  32. package/dist/packem_chunks/handler37.js +1 -1
  33. package/dist/packem_chunks/handler38.js +2 -2
  34. package/dist/packem_chunks/handler39.js +10 -10
  35. package/dist/packem_chunks/handler40.js +5 -5
  36. package/dist/packem_chunks/handler41.js +10 -24
  37. package/dist/packem_chunks/handler42.js +24 -10
  38. package/dist/packem_chunks/handler43.js +5 -5
  39. package/dist/packem_chunks/handler44.js +5 -5
  40. package/dist/packem_chunks/handler45.js +3 -3
  41. package/dist/packem_chunks/handler46.js +11 -11
  42. package/dist/packem_chunks/handler47.js +15 -15
  43. package/dist/packem_chunks/handler48.js +6 -6
  44. package/dist/packem_chunks/handler5.js +1 -1
  45. package/dist/packem_chunks/handler6.js +1 -1
  46. package/dist/packem_chunks/handler7.js +1 -1
  47. package/dist/packem_chunks/heal-accept.js +1 -1
  48. package/dist/packem_chunks/heal.js +1 -1
  49. package/dist/packem_chunks/help-command.js +1 -1
  50. package/dist/packem_chunks/index.js +2 -2
  51. package/dist/packem_chunks/loader.js +1 -1
  52. package/dist/packem_chunks/tar.js +1 -1
  53. package/dist/packem_shared/{ai-analysis-Dzs_nUwM.js → ai-analysis-CGVjqwdc.js} +1 -1
  54. package/dist/packem_shared/ai-cache-BdPgSfg2.js +1 -0
  55. package/dist/packem_shared/{ai-fix-BmLM72GS.js → ai-fix-iHtGLkJS.js} +1 -1
  56. package/dist/packem_shared/cache-directory-DTfMSzT9.js +1 -0
  57. package/dist/packem_shared/dependency-scan-SQeRzrpJ.js +2 -0
  58. package/dist/packem_shared/docker-D5p9mRPU.js +2 -0
  59. package/dist/packem_shared/failure-log-CElcbnb9.js +2 -0
  60. package/dist/packem_shared/flakiness-C4t4_NoA.js +1 -0
  61. package/dist/packem_shared/{giget-BX2ixMoa.js → giget-CcEy_Elm.js} +2 -2
  62. package/dist/packem_shared/lockfile-B7JJzxnL.js +1 -0
  63. package/dist/packem_shared/otel-CO8UEfTa.js +17 -0
  64. package/dist/packem_shared/otelPlugin-DTynZDWh.js +1 -0
  65. package/dist/packem_shared/readTomlSync-1fKo0R52-DAKNI1Me.js +109 -0
  66. package/dist/packem_shared/registry-D04iOQ5H.js +2 -0
  67. package/dist/packem_shared/run-summary-utils-BPraMTcm.js +1 -0
  68. package/dist/packem_shared/{runtime-check-BaKni2y1.js → runtime-check-l4qFpo08.js} +1 -1
  69. package/dist/packem_shared/{selectors-BvtUXWGY.js → selectors-Sem2CTYA.js} +1 -1
  70. package/dist/packem_shared/{toolchain-B7sIiJxK.js → toolchain-BhZNts--.js} +3 -3
  71. package/dist/packem_shared/typosquats-Dr7VIL2B.js +1 -0
  72. package/dist/packem_shared/verify-C6NNOhTA.js +1 -0
  73. package/dist/packem_shared/{vis-update-app-DR8c4OfG.js → vis-update-app-DGiMc5kb.js} +1 -1
  74. package/package.json +10 -12
  75. package/dist/packem_shared/ai-cache-Dtvmbsru.js +0 -1
  76. package/dist/packem_shared/cache-directory-xASJia6M.js +0 -1
  77. package/dist/packem_shared/dependency-scan-DmwPKwLy.js +0 -2
  78. package/dist/packem_shared/docker-CA-scYu0.js +0 -2
  79. package/dist/packem_shared/failure-log-fD4DiFb1.js +0 -2
  80. package/dist/packem_shared/flakiness-BIg1rwvp.js +0 -1
  81. package/dist/packem_shared/index-OlP7U_t5.js +0 -6
  82. package/dist/packem_shared/lockfile-BXylopgH.js +0 -1
  83. package/dist/packem_shared/otelPlugin-y5hoCw4b.js +0 -1
  84. package/dist/packem_shared/registry-BHqKXiLb.js +0 -2
  85. package/dist/packem_shared/run-summary-utils-D39XBHWW.js +0 -1
  86. package/dist/packem_shared/typosquats-XkC1CnOa.js +0 -1
  87. package/dist/packem_shared/verify-BVTcVfoW.js +0 -1
@@ -1,4 +1,4 @@
1
- var T=Object.defineProperty;var v=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createRequire as q}from"node:module";import{j as $,E as P,e as R,q as D,d as j,c as I,p}from"./bin.js";import{z as _}from"../packem_shared/index-OlP7U_t5.js";import{r as W,a as B,b as L,c as w}from"../packem_shared/ai-fix-BmLM72GS.js";import{l as N}from"../packem_shared/failure-log-fD4DiFb1.js";const A=q(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=v(e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,r]=m.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return m.getBuiltinModule(e)}return A(e)},"__cjs_getBuiltinModule"),{createInterface:z}=J("node:readline");var M=Object.defineProperty,l=v((e,t)=>M(e,"name",{value:t,configurable:!0}),"c");const U={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},S=l((e,t,r)=>{const o=W(e,t,r),s=_(e,o);return s===""||s.startsWith("..")?o:s},"formatDisplayPath"),E=l((e,t,r)=>{const o=[$(`Fix proposal (${e.provider}, confidence: ${e.confidence})`),"",e.explanation||P("<no explanation>")];if(e.cannotFix)return o.push(""),o.push(R(`Cannot fix automatically: ${e.cannotFix}`)),o.join(`
1
+ var T=Object.defineProperty;var v=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createRequire as q}from"node:module";import{j as $,E as P,e as R,q as D,d as j,c as I,p}from"./bin.js";import{z as _}from"../packem_shared/otel-CO8UEfTa.js";import{r as W,a as B,b as L,c as w}from"../packem_shared/ai-fix-iHtGLkJS.js";import{l as N}from"../packem_shared/failure-log-CElcbnb9.js";const A=q(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=v(e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,r]=m.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return m.getBuiltinModule(e)}return A(e)},"__cjs_getBuiltinModule"),{createInterface:z}=J("node:readline");var M=Object.defineProperty,l=v((e,t)=>M(e,"name",{value:t,configurable:!0}),"c");const U={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},S=l((e,t,r)=>{const o=W(e,t,r),s=_(e,o);return s===""||s.startsWith("..")?o:s},"formatDisplayPath"),E=l((e,t,r)=>{const o=[$(`Fix proposal (${e.provider}, confidence: ${e.confidence})`),"",e.explanation||P("<no explanation>")];if(e.cannotFix)return o.push(""),o.push(R(`Cannot fix automatically: ${e.cannotFix}`)),o.join(`
2
2
  `);if(e.patches.length===0)return o.push(""),o.push(R("No patches were proposed.")),o.join(`
3
3
  `);o.push(""),o.push($(`Patches (${String(e.patches.length)}):`));for(const[s,i]of e.patches.entries()){const a=S(t,r,i.file);o.push(""),o.push(D(`[${String(s+1)}] ${a}`)),i.reason&&o.push(P(` reason: ${i.reason}`));for(const u of i.oldString.split(`
4
4
  `))o.push(j(` - ${u}`));for(const u of i.newString.split(`
@@ -1 +1 @@
1
- var O=Object.defineProperty;var w=(o,e)=>O(o,"name",{value:e,configurable:!0});import{createTaskGraph as b}from"@visulima/task-runner";import{y as E,m as R}from"./bin.js";import{r as x,f as G}from"../packem_shared/selectors-BvtUXWGY.js";var J=Object.defineProperty,m=w((o,e)=>J(o,"name",{value:e,configurable:!0}),"u");const P=m((o,e,n)=>{const c=[],t=new Set,l=m((r,f)=>{if(t.has(r))return;t.add(r);const s=e[r]??[];for(const i of s)l(i,f+1);const d=n[r],u=" ".repeat(f);c.push(`${u}${r}${d?.cache===!1?" (no-cache)":""}`)},"walk");for(const r of o)l(r,0);return c},"renderPlan"),S=m((o,e,n)=>({roots:o,tasks:Object.fromEntries(Object.entries(n).map(([c,t])=>[c,{cache:t.cache,dependsOn:e[c]??[],outputs:t.outputs,parallelism:t.parallelism,projectRoot:t.projectRoot,target:t.target}]))}),"toJson"),T=m(async({argument:o,logger:e,options:n,visConfig:c,workspaceRoot:t})=>{const l=o[0];if(!l)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!t)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:r,packageJsons:f,workspace:s}=E(t,c),d=R(t,s,f),u=await x(l,s,process.cwd(),t),{target:i}=u;let h=u.projects;n.query&&(h=G(h,s,n.query));const j=h.filter(p=>s.projects[p]?.targets?.[i]!==void 0);if(j.length===0){e.info(`No projects have a "${i}" target.`);return}const y=j.map(p=>{const k=s.projects[p],g=k.targets?.[i],$={project:p,target:i};return{cache:g?.cache,id:`${p}:${i}`,outputs:g?.outputs??[],overrides:{command:g?.command},parallelism:g?.parallelism,projectRoot:k.root,target:$}}),a=b(y,{projectGraph:d,targetDefaults:r.targetDefaults,workspace:s});if(n.json){e.info(JSON.stringify(S(a.roots,a.dependencies,a.tasks),null,2));return}const v=P(a.roots,a.dependencies,a.tasks);e.info(`Execution plan (${Object.keys(a.tasks).length} task(s), ${a.roots.length} root(s)):`),e.info("");for(const p of v)e.info(p)},"execute");export{T as default};
1
+ var O=Object.defineProperty;var w=(o,e)=>O(o,"name",{value:e,configurable:!0});import{createTaskGraph as b}from"@visulima/task-runner";import{y as E,m as R}from"./bin.js";import{r as x,f as G}from"../packem_shared/selectors-Sem2CTYA.js";var J=Object.defineProperty,m=w((o,e)=>J(o,"name",{value:e,configurable:!0}),"u");const P=m((o,e,n)=>{const c=[],t=new Set,l=m((r,f)=>{if(t.has(r))return;t.add(r);const s=e[r]??[];for(const i of s)l(i,f+1);const d=n[r],u=" ".repeat(f);c.push(`${u}${r}${d?.cache===!1?" (no-cache)":""}`)},"walk");for(const r of o)l(r,0);return c},"renderPlan"),S=m((o,e,n)=>({roots:o,tasks:Object.fromEntries(Object.entries(n).map(([c,t])=>[c,{cache:t.cache,dependsOn:e[c]??[],outputs:t.outputs,parallelism:t.parallelism,projectRoot:t.projectRoot,target:t.target}]))}),"toJson"),T=m(async({argument:o,logger:e,options:n,visConfig:c,workspaceRoot:t})=>{const l=o[0];if(!l)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!t)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:r,packageJsons:f,workspace:s}=E(t,c),d=R(t,s,f),u=await x(l,s,process.cwd(),t),{target:i}=u;let h=u.projects;n.query&&(h=G(h,s,n.query));const j=h.filter(p=>s.projects[p]?.targets?.[i]!==void 0);if(j.length===0){e.info(`No projects have a "${i}" target.`);return}const y=j.map(p=>{const k=s.projects[p],g=k.targets?.[i],$={project:p,target:i};return{cache:g?.cache,id:`${p}:${i}`,outputs:g?.outputs??[],overrides:{command:g?.command},parallelism:g?.parallelism,projectRoot:k.root,target:$}}),a=b(y,{projectGraph:d,targetDefaults:r.targetDefaults,workspace:s});if(n.json){e.info(JSON.stringify(S(a.roots,a.dependencies,a.tasks),null,2));return}const v=P(a.roots,a.dependencies,a.tasks);e.info(`Execution plan (${Object.keys(a.tasks).length} task(s), ${a.roots.length} root(s)):`),e.info("");for(const p of v)e.info(p)},"execute");export{T as default};
@@ -1,2 +1,2 @@
1
- var g=Object.defineProperty;var p=(t,o)=>g(t,"name",{value:o,configurable:!0});import{M as d}from"../packem_shared/index-OlP7U_t5.js";import{y as k,m as v}from"./bin.js";import{s as h,p as j}from"../packem_shared/docker-CA-scYu0.js";var x=Object.defineProperty,E=p((t,o)=>x(t,"name",{value:o,configurable:!0}),"f");const C=E(async({argument:t,logger:o,options:s,visConfig:m,workspaceRoot:e})=>{const n=t[0];if(!n)throw new Error("Missing subcommand. Usage: vis docker <scaffold|prune>");if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:l,workspace:c}=k(e,m);if(n==="scaffold"){const a=v(e,c,l),r=s.focus;if(!r)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const i=r.split(",").map(w=>w.trim()).filter(Boolean);if(i.length===0)throw new Error("--focus resolved to an empty list. Provide at least one project name.");const f=d(e,s.out??".vis/docker"),{projects:u}=h({focus:i,includeSources:!!s.includeSources,outDir:f,projectGraph:a,workspace:c,workspaceRoot:e});o.info(`Scaffolded ${u.length} project(s) into ${f}`),o.info(`Focus closure: ${u.toSorted().join(", ")}`);return}if(n==="prune"){const a=d(e,s.context??".vis/docker"),{removed:r}=j({contextRoot:a,workspace:c,workspaceRoot:e});o.info(`Pruned ${r.length} unfocused project(s)`),r.length>0&&o.debug?.(r.join(`
1
+ var g=Object.defineProperty;var p=(t,o)=>g(t,"name",{value:o,configurable:!0});import{M as d}from"../packem_shared/otel-CO8UEfTa.js";import{y as k,m as v}from"./bin.js";import{s as h,p as j}from"../packem_shared/docker-D5p9mRPU.js";var x=Object.defineProperty,E=p((t,o)=>x(t,"name",{value:o,configurable:!0}),"f");const C=E(async({argument:t,logger:o,options:s,visConfig:m,workspaceRoot:e})=>{const n=t[0];if(!n)throw new Error("Missing subcommand. Usage: vis docker <scaffold|prune>");if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:l,workspace:c}=k(e,m);if(n==="scaffold"){const a=v(e,c,l),r=s.focus;if(!r)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const i=r.split(",").map(w=>w.trim()).filter(Boolean);if(i.length===0)throw new Error("--focus resolved to an empty list. Provide at least one project name.");const f=d(e,s.out??".vis/docker"),{projects:u}=h({focus:i,includeSources:!!s.includeSources,outDir:f,projectGraph:a,workspace:c,workspaceRoot:e});o.info(`Scaffolded ${u.length} project(s) into ${f}`),o.info(`Focus closure: ${u.toSorted().join(", ")}`);return}if(n==="prune"){const a=d(e,s.context??".vis/docker"),{removed:r}=j({contextRoot:a,workspace:c,workspaceRoot:e});o.info(`Pruned ${r.length} unfocused project(s)`),r.length>0&&o.debug?.(r.join(`
2
2
  `));return}throw new Error(`Unknown subcommand: "${n}". Expected scaffold or prune.`)},"execute");export{C as default};
@@ -1,5 +1,5 @@
1
- var g=Object.defineProperty;var a=(e,i)=>g(e,"name",{value:i,configurable:!0});import{createRequire as y}from"node:module";import{isAccessibleSync as u,readFileSync as p,writeFileSync as S}from"@visulima/fs";import{M as r}from"../packem_shared/index-OlP7U_t5.js";import{l as j}from"./bin.js";const _=y(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=a(e=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[i,s]=c.versions.node.split(".").map(Number);if(i>22||i===22&&s>=3||i===20&&s>=16)return c.getBuiltinModule(e)}return _(e)},"__cjs_getBuiltinModule"),{rmSync:b}=d("node:fs"),{homedir:n}=d("node:os"),{createInterface:w}=d("node:readline");var T=Object.defineProperty,m=a((e,i)=>T(e,"name",{value:i,configurable:!0}),"l");const f=j(),h=[r(n(),".zshrc"),r(n(),".zshenv"),r(n(),".bashrc"),r(n(),".bash_profile"),r(n(),".profile"),r(n(),".config","fish","config.fish")],$=m(e=>{const i=[];for(const s of h)if(u(s))try{const l=p(s).split(`
2
- `),o=l.filter(t=>!t.includes(".vis/bin")&&!t.includes("VIS_HOME")&&!t.includes("# vis "));o.length!==l.length&&(S(s,o.join(`
3
- `)),i.push(s))}catch{e.warn(`warning: could not clean ${s}`)}return i},"cleanShellProfiles"),R=m(async({logger:e,options:i})=>{if(!u(f)){e.info("vis is not installed (no ~/.vis directory found).");return}e.info("This will remove:"),e.info(` ${f}/`);const s=h.filter(o=>u(o)&&p(o).includes(".vis"));for(const o of s)e.info(` Lines in ${o}`);if(!i.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const o=w({input:process.stdin,output:process.stdout}),t=await new Promise(v=>{o.question(`
4
- Type "uninstall" to confirm: `,v)});if(o.close(),t.trim()!=="uninstall"){e.info("Aborted.");return}}const l=$(e);for(const o of l)e.info(`Cleaned ${o}`);try{b(f,{force:!0,recursive:!0}),e.info(`
5
- ✓ Removed ${f}`)}catch(o){throw new Error(`Failed to remove ${f}: ${o instanceof Error?o.message:String(o)}`,{cause:o})}e.info("✓ vis has been uninstalled.")},"execute");export{R as default};
1
+ var g=Object.defineProperty;var a=(e,i)=>g(e,"name",{value:i,configurable:!0});import{createRequire as _}from"node:module";import{M as r,i as u,$ as p,B as $}from"../packem_shared/otel-CO8UEfTa.js";import{l as j}from"./bin.js";const b=_(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=a(e=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[i,s]=c.versions.node.split(".").map(Number);if(i>22||i===22&&s>=3||i===20&&s>=16)return c.getBuiltinModule(e)}return b(e)},"__cjs_getBuiltinModule"),{rmSync:y}=d("node:fs"),{homedir:n}=d("node:os"),{createInterface:w}=d("node:readline");var T=Object.defineProperty,m=a((e,i)=>T(e,"name",{value:i,configurable:!0}),"l");const f=j(),h=[r(n(),".zshrc"),r(n(),".zshenv"),r(n(),".bashrc"),r(n(),".bash_profile"),r(n(),".profile"),r(n(),".config","fish","config.fish")],M=m(e=>{const i=[];for(const s of h)if(u(s))try{const l=p(s).split(`
2
+ `),o=l.filter(t=>!t.includes(".vis/bin")&&!t.includes("VIS_HOME")&&!t.includes("# vis "));o.length!==l.length&&($(s,o.join(`
3
+ `)),i.push(s))}catch{e.warn(`warning: could not clean ${s}`)}return i},"cleanShellProfiles"),B=m(async({logger:e,options:i})=>{if(!u(f)){e.info("vis is not installed (no ~/.vis directory found).");return}e.info("This will remove:"),e.info(` ${f}/`);const s=h.filter(o=>u(o)&&p(o).includes(".vis"));for(const o of s)e.info(` Lines in ${o}`);if(!i.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const o=w({input:process.stdin,output:process.stdout}),t=await new Promise(v=>{o.question(`
4
+ Type "uninstall" to confirm: `,v)});if(o.close(),t.trim()!=="uninstall"){e.info("Aborted.");return}}const l=M(e);for(const o of l)e.info(`Cleaned ${o}`);try{y(f,{force:!0,recursive:!0}),e.info(`
5
+ ✓ Removed ${f}`)}catch(o){throw new Error(`Failed to remove ${f}: ${o instanceof Error?o.message:String(o)}`,{cause:o})}e.info("✓ vis has been uninstalled.")},"execute");export{B as default};
@@ -1,4 +1,4 @@
1
- var _=Object.defineProperty;var b=(s,e)=>_(s,"name",{value:e,configurable:!0});import{createRequire as C}from"node:module";import{isAccessibleSync as g,writeFileSync as $}from"@visulima/fs";import{M as h}from"../packem_shared/index-OlP7U_t5.js";import{findVisConfigFile as B}from"./applyDefaults.js";import{p as t,I as E,b as x,A as M}from"./bin.js";const T=C(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=b(s=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,o]=p.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return p.getBuiltinModule(s)}return T(s)},"__cjs_getBuiltinModule"),{execFileSync:I}=j("node:child_process"),{createInterface:O}=j("node:readline");var R=Object.defineProperty,u=b((s,e)=>R(s,"name",{value:e,configurable:!0}),"f");const N=u(s=>{const e=[];return g(h(s,"turbo.json"))&&e.push("turborepo"),g(h(s,"nx.json"))&&e.push("nx"),g(h(s,".moon"))&&e.push("moon"),e},"detectExistingTools"),P=u((s,e)=>new Promise(o=>{s.question(e,n=>{o(n.trim())})}),"ask"),d=u(async(s,e,o=!0)=>{const n=await P(s,`${e} ${o?"[Y/n]":"[y/N]"} `);return n===""?o:n.toLowerCase()==="y"||n.toLowerCase()==="yes"},"confirm"),w=u((s,e)=>{const o=[],n=Object.entries(e.allowBuilds).filter(([,r])=>r).map(([r])=>` "${r}": true,`).join(`
1
+ var _=Object.defineProperty;var y=(s,e)=>_(s,"name",{value:e,configurable:!0});import{createRequire as C}from"node:module";import{i as g,M as h,B as b}from"../packem_shared/otel-CO8UEfTa.js";import{findVisConfigFile as O}from"./applyDefaults.js";import{p as t,I as E,b as x,A as M}from"./bin.js";const T=C(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=y(s=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,o]=p.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return p.getBuiltinModule(s)}return T(s)},"__cjs_getBuiltinModule"),{execFileSync:B}=j("node:child_process"),{createInterface:I}=j("node:readline");var R=Object.defineProperty,u=y((s,e)=>R(s,"name",{value:e,configurable:!0}),"f");const N=u(s=>{const e=[];return g(h(s,"turbo.json"))&&e.push("turborepo"),g(h(s,"nx.json"))&&e.push("nx"),g(h(s,".moon"))&&e.push("moon"),e},"detectExistingTools"),P=u((s,e)=>new Promise(o=>{s.question(e,n=>{o(n.trim())})}),"ask"),d=u(async(s,e,o=!0)=>{const n=await P(s,`${e} ${o?"[Y/n]":"[y/N]"} `);return n===""?o:n.toLowerCase()==="y"||n.toLowerCase()==="yes"},"confirm"),w=u((s,e)=>{const o=[],n=Object.entries(e.allowBuilds).filter(([,r])=>r).map(([r])=>` "${r}": true,`).join(`
2
2
  `);let i=` allowBuilds: ${n?`{
3
3
  ${n}
4
4
  }`:"{}"},`;return e.enableSocket&&(i+=`
@@ -14,7 +14,7 @@ ${o.join(`
14
14
 
15
15
  `)}
16
16
  });
17
- `},"generateConfigContent"),q=u(async(s,e,o)=>{const n=O({input:process.stdin,output:process.stdout});t.info(`
17
+ `},"generateConfigContent"),q=u(async(s,e,o)=>{const n=I({input:process.stdin,output:process.stdout});t.info(`
18
18
  vis init — interactive setup
19
19
  `);const i=await d(n," Enable Socket.dev security scanning?");i&&(t.success(" Socket.dev enabled — scores, alerts, and supply chain data active."),process.env.VIS_SOCKET_TOKEN||t.notice(" Set VIS_SOCKET_TOKEN for a custom API token (optional).")),t.info("");const r=await d(n," Scan for packages with build scripts?"),l={};if(r){t.info(" Scanning node_modules...");const c=E(s,{});if(c.length>0){t.info(` Found ${String(c.length)} package${c.length===1?"":"s"} with build scripts:
20
- `);for(const f of c){const a=await d(n,` Allow ${f}?`,!1),S=f.split(" (")[0]??f;l[S]=a,a&&t.success(` ✓ ${S} approved`)}}else t.info(" No packages with build scripts found.")}t.info("");const y=await d(n," Set up pre-commit hooks (lint-staged)?",!1);let v=!1;(e.name==="pnpm"||e.name==="yarn"||e.name==="npm"||e.name==="bun")&&(t.info(""),v=await d(n,` Sync security settings to ${e.name} config?`));const m=N(s);if(m.length>0&&(t.info(""),t.info(` Detected existing tools: ${m.join(", ")}`),await d(n,` Run \`vis migrate\` for ${m.join(", ")}?`,!1))){n.close();const[c,...f]=e.name==="pnpm"?["pnpm","exec"]:e.name==="yarn"?["yarn","exec"]:e.name==="bun"?["bunx"]:["npx"];for(const a of m){t.info(` Migrating from ${a}...`);try{I(c,[...f,"vis","migrate",a],{cwd:s,stdio:"inherit"})}catch{t.warn(` Migration from ${a} had issues — run \`vis migrate ${a}\` manually.`)}}if(g(o))t.success(`Migrated config written to ${o}`);else{const a=w(e.name,{allowBuilds:l,enableSocket:i,staged:y});$(o,a),t.success(`Created ${o}`)}t.notice(" Run 'vis doctor' to see your project's full health status.");return}n.close(),t.info("");const k=w(e.name,{allowBuilds:l,enableSocket:i,staged:y});if($(o,k),t.success(`Created ${o}`),v){const c=Object.fromEntries(Object.entries(l).filter(([,a])=>a)),f=x(e.name,s,c);for(const a of f)t.success(` ${a}`)}t.info(""),t.info(" Setup complete. Your config:"),t.info(` Security: ${i?"Socket.dev enabled":"defaults only"}`),t.info(` Build scripts: ${Object.values(l).filter(Boolean).length} approved`),t.info(` Git hooks: ${y?"lint-staged configured":"not configured"}`),t.info(` PM sync: ${v?"done":"skipped"}`),t.info(""),t.notice(" Run 'vis doctor' to see your project's full health status."),t.info("")},"runInteractiveInit"),A=u((s,e,o,n)=>{const i=w(e.name,{allowBuilds:{},enableSocket:!1,staged:!1});if($(n,i),t.success(`Created ${n}`),t.info(" Secure defaults applied automatically by defineConfig()."),o.syncNative){const r=x(e.name,s,{});for(const l of r)t.success(` ${l}`)}t.info(""),t.notice("Run 'vis doctor' for a full health check, or 'vis init' in a terminal for guided setup.")},"runStaticInit"),G=u(async({options:s,workspaceRoot:e})=>{const o=e??process.cwd(),n=M(o),i=B(o);if(i&&!s.force){t.warn(`Config already exists: ${i}`),t.notice("Use --force to overwrite, or edit the existing file.");return}const r=i??h(o,"vis.config.ts");process.stdin.isTTY&&s.interactive!==!1?await q(o,n,r):A(o,n,s,r)},"execute");export{G as default};
20
+ `);for(const f of c){const a=await d(n,` Allow ${f}?`,!1),S=f.split(" (")[0]??f;l[S]=a,a&&t.success(` ✓ ${S} approved`)}}else t.info(" No packages with build scripts found.")}t.info("");const v=await d(n," Set up pre-commit hooks (lint-staged)?",!1);let $=!1;(e.name==="pnpm"||e.name==="yarn"||e.name==="npm"||e.name==="bun")&&(t.info(""),$=await d(n,` Sync security settings to ${e.name} config?`));const m=N(s);if(m.length>0&&(t.info(""),t.info(` Detected existing tools: ${m.join(", ")}`),await d(n,` Run \`vis migrate\` for ${m.join(", ")}?`,!1))){n.close();const[c,...f]=e.name==="pnpm"?["pnpm","exec"]:e.name==="yarn"?["yarn","exec"]:e.name==="bun"?["bunx"]:["npx"];for(const a of m){t.info(` Migrating from ${a}...`);try{B(c,[...f,"vis","migrate",a],{cwd:s,stdio:"inherit"})}catch{t.warn(` Migration from ${a} had issues — run \`vis migrate ${a}\` manually.`)}}if(g(o))t.success(`Migrated config written to ${o}`);else{const a=w(e.name,{allowBuilds:l,enableSocket:i,staged:v});b(o,a),t.success(`Created ${o}`)}t.notice(" Run 'vis doctor' to see your project's full health status.");return}n.close(),t.info("");const k=w(e.name,{allowBuilds:l,enableSocket:i,staged:v});if(b(o,k),t.success(`Created ${o}`),$){const c=Object.fromEntries(Object.entries(l).filter(([,a])=>a)),f=x(e.name,s,c);for(const a of f)t.success(` ${a}`)}t.info(""),t.info(" Setup complete. Your config:"),t.info(` Security: ${i?"Socket.dev enabled":"defaults only"}`),t.info(` Build scripts: ${Object.values(l).filter(Boolean).length} approved`),t.info(` Git hooks: ${v?"lint-staged configured":"not configured"}`),t.info(` PM sync: ${$?"done":"skipped"}`),t.info(""),t.notice(" Run 'vis doctor' to see your project's full health status."),t.info("")},"runInteractiveInit"),K=u((s,e,o,n)=>{const i=w(e.name,{allowBuilds:{},enableSocket:!1,staged:!1});if(b(n,i),t.success(`Created ${n}`),t.info(" Secure defaults applied automatically by defineConfig()."),o.syncNative){const r=x(e.name,s,{});for(const l of r)t.success(` ${l}`)}t.info(""),t.notice("Run 'vis doctor' for a full health check, or 'vis init' in a terminal for guided setup.")},"runStaticInit"),D=u(async({options:s,workspaceRoot:e})=>{const o=e??process.cwd(),n=M(o),i=O(o);if(i&&!s.force){t.warn(`Config already exists: ${i}`),t.notice("Use --force to overwrite, or edit the existing file.");return}const r=i??h(o,"vis.config.ts");process.stdin.isTTY&&s.interactive!==!1?await q(o,n,r):K(o,n,s,r)},"execute");export{D as default};
@@ -1 +1 @@
1
- var j=Object.defineProperty;var f=(o,e)=>j(o,"name",{value:e,configurable:!0});import{createRequire as x}from"node:module";import{isAccessibleSync as z}from"@visulima/fs";import{M as y,K as R,c as L}from"../packem_shared/index-OlP7U_t5.js";import{p as t,A as M,h as T,o as $,r as A}from"./bin.js";import{s as B}from"../packem_shared/typosquats-XkC1CnOa.js";import{o as D}from"../packem_shared/utils-DrNg0XTR.js";const O=x(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=f(o=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[e,r]=i.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return i.getBuiltinModule(o)}return O(o)},"__cjs_getBuiltinModule"),{rmSync:q}=S("node:fs");var E=Object.defineProperty,b=f((o,e)=>E(o,"name",{value:e,configurable:!0}),"f");const F=["pnpm-lock.yaml","yarn.lock","package-lock.json","npm-shrinkwrap.json","bun.lock","bun.lockb"],P=b(o=>{let e=o;for(;;){for(const a of F)if(z(y(e,a)))return!0;const r=R(e);if(r===e||L(e).root===e)return!1;e=r}},"hasLockfile"),g=new Set(["aube","auto","bun","npm","pnpm","yarn"]),U=b(async({logger:o,options:e,visConfig:r,workspaceRoot:a})=>{const s=a??process.cwd();if(e.typosquatCheck!==!1&&!await B(s,r?.security?.typosquatAllowlist)){process.exitCode=1;return}const l=e.installer;if(l&&!g.has(l)){t.error(`Invalid --installer value: "${l}". Expected one of: ${[...g].join(", ")}.`),process.exitCode=1;return}const v=l,_=e.aube===!1;let c;try{c=_?M(s):T(s,{backend:v,configBackend:r?.install?.backend,configCorepack:r?.install?.corepack})}catch(n){t.error(n instanceof Error?n.message:String(n)),process.exitCode=1;return}const p=$(s,c);p&&t.warn(p);const w=D(e.filter),u=e.ci||!1,d=e.frozenLockfile||u,h=e.frozenLockfile===!1||e.force||e.lockfileOnly,C=P(s),m=d||!h&&C;if(!d&&m&&!e.silent&&t.info("Defaulting to frozen lockfile (pass --no-frozen-lockfile to allow lockfile updates)."),u){t.info("Clean install: removing node_modules...");try{q(y(s,"node_modules"),{force:!0,recursive:!0})}catch(n){t.error(`Failed to remove node_modules: ${n instanceof Error?n.message:String(n)}`),process.exitCode=1;return}}const k=A(c,{dev:e.dev||!1,filter:w,force:e.force||!1,frozenLockfile:m,ignoreScripts:!e.runScripts,lockfileOnly:e.lockfileOnly||!1,noOptional:e.optional===!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},s,o,{preferOffline:e.preferOffline||!1});k!==0&&(process.exitCode=k)},"execute");export{U as default};
1
+ var j=Object.defineProperty;var f=(o,e)=>j(o,"name",{value:e,configurable:!0});import{createRequire as x}from"node:module";import{i as z,M as y,a as R,d as L}from"../packem_shared/otel-CO8UEfTa.js";import{p as t,A as M,h as T,u as $,v as B}from"./bin.js";import{s as D}from"../packem_shared/typosquats-Dr7VIL2B.js";import{o as E}from"../packem_shared/utils-DrNg0XTR.js";const O=x(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=f(o=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[e,r]=i.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return i.getBuiltinModule(o)}return O(o)},"__cjs_getBuiltinModule"),{rmSync:S}=q("node:fs");var F=Object.defineProperty,v=f((o,e)=>F(o,"name",{value:e,configurable:!0}),"f");const A=["pnpm-lock.yaml","yarn.lock","package-lock.json","npm-shrinkwrap.json","bun.lock","bun.lockb"],P=v(o=>{let e=o;for(;;){for(const a of A)if(z(y(e,a)))return!0;const r=R(e);if(r===e||L(e).root===e)return!1;e=r}},"hasLockfile"),g=new Set(["aube","auto","bun","npm","pnpm","yarn"]),Q=v(async({logger:o,options:e,visConfig:r,workspaceRoot:a})=>{const s=a??process.cwd();if(e.typosquatCheck!==!1&&!await D(s,r?.security?.typosquatAllowlist)){process.exitCode=1;return}const l=e.installer;if(l&&!g.has(l)){t.error(`Invalid --installer value: "${l}". Expected one of: ${[...g].join(", ")}.`),process.exitCode=1;return}const b=l,_=e.aube===!1;let c;try{c=_?M(s):T(s,{backend:b,configBackend:r?.install?.backend,configCorepack:r?.install?.corepack})}catch(n){t.error(n instanceof Error?n.message:String(n)),process.exitCode=1;return}const p=$(s,c);p&&t.warn(p);const w=E(e.filter),u=e.ci||!1,d=e.frozenLockfile||u,h=e.frozenLockfile===!1||e.force||e.lockfileOnly,C=P(s),m=d||!h&&C;if(!d&&m&&!e.silent&&t.info("Defaulting to frozen lockfile (pass --no-frozen-lockfile to allow lockfile updates)."),u){t.info("Clean install: removing node_modules...");try{S(y(s,"node_modules"),{force:!0,recursive:!0})}catch(n){t.error(`Failed to remove node_modules: ${n instanceof Error?n.message:String(n)}`),process.exitCode=1;return}}const k=B(c,{dev:e.dev||!1,filter:w,force:e.force||!1,frozenLockfile:m,ignoreScripts:!e.runScripts,lockfileOnly:e.lockfileOnly||!1,noOptional:e.optional===!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},s,o,{preferOffline:e.preferOffline||!1});k!==0&&(process.exitCode=k)},"execute");export{Q as default};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var i=(e,o)=>f(e,"name",{value:o,configurable:!0});import{h as p,t as g}from"./bin.js";import{o as v}from"../packem_shared/utils-DrNg0XTR.js";var k=Object.defineProperty,m=i((e,o)=>k(e,"name",{value:o,configurable:!0}),"l");const b=m(async({argument:e,logger:o,options:a,visConfig:s,workspaceRoot:l})=>{const r=e;if(!r||r.length===0)throw new Error("No packages specified. Usage: vis remove <packages...>");const c=process.cwd(),n=p(l??c,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),t=g(n,{filter:v(a.filter),global:a.global||!1,packages:r,recursive:a.recursive||!1,saveDev:a.saveDev||!1,workspaceRoot:a.workspaceRoot||!1},c,o);t!==0&&(process.exitCode=t)},"execute");export{b as default};
1
+ var f=Object.defineProperty;var i=(e,o)=>f(e,"name",{value:o,configurable:!0});import{h as p,w as g}from"./bin.js";import{o as v}from"../packem_shared/utils-DrNg0XTR.js";var k=Object.defineProperty,m=i((e,o)=>k(e,"name",{value:o,configurable:!0}),"l");const b=m(async({argument:e,logger:o,options:a,visConfig:s,workspaceRoot:l})=>{const r=e;if(!r||r.length===0)throw new Error("No packages specified. Usage: vis remove <packages...>");const c=process.cwd(),n=p(l??c,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),t=g(n,{filter:v(a.filter),global:a.global||!1,packages:r,recursive:a.recursive||!1,saveDev:a.saveDev||!1,workspaceRoot:a.workspaceRoot||!1},c,o);t!==0&&(process.exitCode=t)},"execute");export{b as default};
@@ -1,4 +1,4 @@
1
- var k=Object.defineProperty;var p=(t,e)=>k(t,"name",{value:e,configurable:!0});import{readLastRunSummary as S}from"@visulima/task-runner";import{p as m}from"./bin.js";import{r as g,l as v}from"../packem_shared/run-summary-utils-D39XBHWW.js";var x=Object.defineProperty,o=p((t,e)=>x(t,"name",{value:e,configurable:!0}),"s");const I=new Set(["json","table"]),y=o(t=>t??process.cwd(),"resolveWorkspaceRoot"),c=o(t=>t===void 0?"-":t<1e3?`${String(t)}ms`:`${(t/1e3).toFixed(2)}s`,"formatDuration"),l=o(t=>t.exitCode===void 0?t.cacheStatus:t.exitCode===0?t.cacheStatus==="MISS"?"OK":t.cacheStatus:`FAIL(${String(t.exitCode)})`,"formatStatus"),n=o((t,e)=>t.length>=e?t:t+" ".repeat(e-t.length),"padCell"),w=o(t=>t.exitCode!==void 0&&t.exitCode!==0,"isFailedTask"),$=o((t,e)=>{e.info(`Run ${t.id}`),e.info(` start: ${t.startTime}`),e.info(` end: ${t.endTime}`),e.info(` duration: ${c(t.duration)}`),e.info(` totals: ${String(t.stats.total)} total · ${String(t.stats.succeeded)} ok · ${String(t.stats.cached)} cached · ${String(t.stats.skipped)} skipped · ${String(t.stats.failed)} failed`),e.info(` env: node ${t.environment.nodeVersion} · ${t.environment.platform}/${t.environment.arch}`),e.info("")},"renderRunHeader"),T=o((t,e)=>{if(t.length===0){e.info("(no tasks match the current filter)");return}const a=t.map(r=>({duration:c(r.duration),hash:r.hash?r.hash.slice(0,12):"-",status:l(r),taskId:r.taskId})),s={duration:Math.max(8,...a.map(r=>r.duration.length)),hash:Math.max(4,...a.map(r=>r.hash.length)),status:Math.max(6,...a.map(r=>r.status.length)),taskId:Math.max(4,...a.map(r=>r.taskId.length))};e.info(` ${n("task",s.taskId)} ${n("status",s.status)} ${n("duration",s.duration)} ${n("hash",s.hash)}`),e.info(` ${"-".repeat(s.taskId)} ${"-".repeat(s.status)} ${"-".repeat(s.duration)} ${"-".repeat(s.hash)}`);for(const r of a)e.info(` ${n(r.taskId,s.taskId)} ${n(r.status,s.status)} ${n(r.duration,s.duration)} ${n(r.hash,s.hash)}`)},"renderTaskTable"),C=o((t,e,a)=>{$(t,a),a.info(`Task ${e.taskId}`),a.info(` status: ${l(e)}`),a.info(` cache: ${e.cacheStatus}`),a.info(` duration: ${c(e.duration)}`),a.info(` exit: ${e.exitCode===void 0?"-":String(e.exitCode)}`),a.info(` hash: ${e.hash??"(none)"}`),a.info(` start: ${e.startTime??"-"}`),a.info(` end: ${e.endTime??"-"}`),e.dependencies.length>0&&a.info(` deps: ${e.dependencies.join(", ")}`),a.info(""),m.info(`Drill into hash inputs with: vis cache why ${e.taskId} --run ${t.id}`)},"renderTaskDetail"),R=o(t=>{process.stdout.write(`${JSON.stringify(t.map(e=>({id:e.id,mtime:new Date(e.mtimeMs).toISOString(),path:e.path})),void 0,2)}
1
+ var k=Object.defineProperty;var p=(t,e)=>k(t,"name",{value:e,configurable:!0});import{readLastRunSummary as S}from"@visulima/task-runner";import{p as m}from"./bin.js";import{r as g,l as v}from"../packem_shared/run-summary-utils-BPraMTcm.js";var x=Object.defineProperty,o=p((t,e)=>x(t,"name",{value:e,configurable:!0}),"s");const I=new Set(["json","table"]),y=o(t=>t??process.cwd(),"resolveWorkspaceRoot"),c=o(t=>t===void 0?"-":t<1e3?`${String(t)}ms`:`${(t/1e3).toFixed(2)}s`,"formatDuration"),l=o(t=>t.exitCode===void 0?t.cacheStatus:t.exitCode===0?t.cacheStatus==="MISS"?"OK":t.cacheStatus:`FAIL(${String(t.exitCode)})`,"formatStatus"),n=o((t,e)=>t.length>=e?t:t+" ".repeat(e-t.length),"padCell"),w=o(t=>t.exitCode!==void 0&&t.exitCode!==0,"isFailedTask"),$=o((t,e)=>{e.info(`Run ${t.id}`),e.info(` start: ${t.startTime}`),e.info(` end: ${t.endTime}`),e.info(` duration: ${c(t.duration)}`),e.info(` totals: ${String(t.stats.total)} total · ${String(t.stats.succeeded)} ok · ${String(t.stats.cached)} cached · ${String(t.stats.skipped)} skipped · ${String(t.stats.failed)} failed`),e.info(` env: node ${t.environment.nodeVersion} · ${t.environment.platform}/${t.environment.arch}`),e.info("")},"renderRunHeader"),T=o((t,e)=>{if(t.length===0){e.info("(no tasks match the current filter)");return}const a=t.map(r=>({duration:c(r.duration),hash:r.hash?r.hash.slice(0,12):"-",status:l(r),taskId:r.taskId})),s={duration:Math.max(8,...a.map(r=>r.duration.length)),hash:Math.max(4,...a.map(r=>r.hash.length)),status:Math.max(6,...a.map(r=>r.status.length)),taskId:Math.max(4,...a.map(r=>r.taskId.length))};e.info(` ${n("task",s.taskId)} ${n("status",s.status)} ${n("duration",s.duration)} ${n("hash",s.hash)}`),e.info(` ${"-".repeat(s.taskId)} ${"-".repeat(s.status)} ${"-".repeat(s.duration)} ${"-".repeat(s.hash)}`);for(const r of a)e.info(` ${n(r.taskId,s.taskId)} ${n(r.status,s.status)} ${n(r.duration,s.duration)} ${n(r.hash,s.hash)}`)},"renderTaskTable"),C=o((t,e,a)=>{$(t,a),a.info(`Task ${e.taskId}`),a.info(` status: ${l(e)}`),a.info(` cache: ${e.cacheStatus}`),a.info(` duration: ${c(e.duration)}`),a.info(` exit: ${e.exitCode===void 0?"-":String(e.exitCode)}`),a.info(` hash: ${e.hash??"(none)"}`),a.info(` start: ${e.startTime??"-"}`),a.info(` end: ${e.endTime??"-"}`),e.dependencies.length>0&&a.info(` deps: ${e.dependencies.join(", ")}`),a.info(""),m.info(`Drill into hash inputs with: vis cache why ${e.taskId} --run ${t.id}`)},"renderTaskDetail"),R=o(t=>{process.stdout.write(`${JSON.stringify(t.map(e=>({id:e.id,mtime:new Date(e.mtimeMs).toISOString(),path:e.path})),void 0,2)}
2
2
  `)},"renderListJson"),j=o((t,e)=>{if(t.length===0){m.info("No recorded runs found in .task-runner/runs/. Run with --summarize to record a run.");return}const a={id:Math.max(2,...t.map(s=>s.id.length)),mtime:24};e.info(` ${n("id",a.id)} ${n("mtime",a.mtime)}`),e.info(` ${"-".repeat(a.id)} ${"-".repeat(a.mtime)}`);for(const s of t)e.info(` ${n(s.id,a.id)} ${new Date(s.mtimeMs).toISOString()}`)},"renderListTable"),O=o((t,e)=>{let{tasks:a}=t;return e.task!==void 0&&(a=a.filter(s=>s.taskId===e.task)),e.failed&&(a=a.filter(s=>w(s))),a},"filterTasks"),b=o(async(t,e)=>{const{failed:a,format:s,runId:r,task:d,workspaceRoot:h}=t,i=r===void 0?await S(h):await g(h,r);if(!i){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:r??null},void 0,2)}
3
3
  `),process.exitCode=1;return}r===void 0?m.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):m.error(`Run summary "${r}" not found in .task-runner/runs/.`),process.exitCode=1;return}const f=O(i,{failed:a,task:d});if(d!==void 0&&f.length===0){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:i.id,taskId:d},void 0,2)}
4
4
  `),process.exitCode=1;return}m.error(`Task "${d}" was not part of run ${i.id}.`),process.exitCode=1;return}if(i.stats.failed>0&&(process.exitCode=1),s==="json"){process.stdout.write(`${JSON.stringify({duration:i.duration,endTime:i.endTime,environment:i.environment,runId:i.id,startTime:i.startTime,stats:i.stats,tasks:f.map(u=>({cacheStatus:u.cacheStatus,dependencies:u.dependencies,duration:u.duration,endTime:u.endTime,exitCode:u.exitCode,hash:u.hash??null,startTime:u.startTime,taskId:u.taskId}))},void 0,2)}
@@ -1,2 +1,2 @@
1
- var j=Object.defineProperty;var g=(n,r)=>j(n,"name",{value:r,configurable:!0});import{getAffectedProjects as v}from"@visulima/task-runner";import{y as E,m as F}from"./bin.js";import{f as b}from"../packem_shared/selectors-BvtUXWGY.js";var S=Object.defineProperty,$=g((n,r)=>S(n,"name",{value:r,configurable:!0}),"m");const T=$(async({argument:n,logger:r,options:e,runtime:l,visConfig:h,workspaceRoot:u})=>{const f=n[0];if(!f)throw new Error("Missing target. Usage: vis affected <target>");if(!u)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const s=u,{packageJsons:m,workspace:i}=E(s,h),w=F(s,i,m),d=new Set(["deep","direct","none"]),c=e.downstream??"deep",p=e.upstream??"none";if(!d.has(c))throw new Error(`Invalid --downstream value: "${c}". Must be "none", "direct", or "deep".`);if(!d.has(p))throw new Error(`Invalid --upstream value: "${p}". Must be "none", "direct", or "deep".`);const y={base:e.base,downstream:c,head:e.head,projectGraph:w,projects:i.projects,upstream:p,workspaceRoot:s},o=await v(y);if(o.changedFiles.length===0){r.info("No files changed. Nothing to run.");return}if(o.affectedProjects.length===0){r.info("No projects affected by the changes.");return}let{affectedProjects:a}=o;if(e.query&&(a=b(a,i,e.query),a.length===0)){r.info(`Query "${String(e.query)}" matched no affected projects.`);return}r.info(`Affected projects: ${a.join(", ")}`),o.changedFiles.length>0&&(process.env.VIS_AFFECTED_FILES=o.changedFiles.join(`
1
+ var j=Object.defineProperty;var g=(n,r)=>j(n,"name",{value:r,configurable:!0});import{getAffectedProjects as v}from"@visulima/task-runner";import{y as E,m as F}from"./bin.js";import{f as b}from"../packem_shared/selectors-Sem2CTYA.js";var S=Object.defineProperty,$=g((n,r)=>S(n,"name",{value:r,configurable:!0}),"m");const T=$(async({argument:n,logger:r,options:e,runtime:l,visConfig:h,workspaceRoot:u})=>{const f=n[0];if(!f)throw new Error("Missing target. Usage: vis affected <target>");if(!u)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const s=u,{packageJsons:m,workspace:i}=E(s,h),w=F(s,i,m),d=new Set(["deep","direct","none"]),c=e.downstream??"deep",p=e.upstream??"none";if(!d.has(c))throw new Error(`Invalid --downstream value: "${c}". Must be "none", "direct", or "deep".`);if(!d.has(p))throw new Error(`Invalid --upstream value: "${p}". Must be "none", "direct", or "deep".`);const y={base:e.base,downstream:c,head:e.head,projectGraph:w,projects:i.projects,upstream:p,workspaceRoot:s},o=await v(y);if(o.changedFiles.length===0){r.info("No files changed. Nothing to run.");return}if(o.affectedProjects.length===0){r.info("No projects affected by the changes.");return}let{affectedProjects:a}=o;if(e.query&&(a=b(a,i,e.query),a.length===0)){r.info(`Query "${String(e.query)}" matched no affected projects.`);return}r.info(`Affected projects: ${a.join(", ")}`),o.changedFiles.length>0&&(process.env.VIS_AFFECTED_FILES=o.changedFiles.join(`
2
2
  `));const t=[f,`--projects=${a.join(",")}`];e.parallel!==void 0&&t.push(`--parallel=${String(e.parallel)}`),e.cache||t.push("--no-cache"),e.dryRun&&t.push("--dry-run"),e.partition&&t.push(`--partition=${String(e.partition)}`),e.reverse&&t.push("--reverse"),typeof e.runnerTags=="string"&&e.runnerTags!==""&&t.push(`--runner-tags=${e.runnerTags}`);try{await l.runCommand("run",{argv:t})}finally{delete process.env.VIS_AFFECTED_FILES}},"execute");export{T as default};
@@ -1 +1 @@
1
- var w=Object.defineProperty;var y=(e,t)=>w(e,"name",{value:t,configurable:!0});import{createRequire as C}from"node:module";import{c as f,d as v,y as F,m as I,E as J,e as _}from"./bin.js";import{isAccessibleSync as P,readJsonSync as V}from"@visulima/fs";import{M as b}from"../packem_shared/index-OlP7U_t5.js";import{enforceProjectConstraints as z}from"@visulima/task-runner";import{a as A}from"../packem_shared/flakiness-BIg1rwvp.js";import{c as B}from"../packem_shared/runtime-check-BaKni2y1.js";const M=C(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=y(e=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[t,i]=n.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return n.getBuiltinModule(e)}return M(e)},"__cjs_getBuiltinModule"),{readdirSync:x}=q("node:fs");var E=Object.defineProperty,O=y((e,t)=>E(e,"name",{value:t,configurable:!0}),"h");const r=O(e=>e?f("✓"):v("✗"),"icon"),Q=O(async({logger:e,options:t,visConfig:i,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root.");const{config:$,packageJsons:T,workspace:u}=F(s,i),R=I(s,u,T),j=Object.keys(u.projects).length,k=new Set(Object.values(u.projects).flatMap(p=>Object.keys(p.targets??{}))).size,a=B(s);let o=0;$.constraints&&(o=z(R,$.constraints).length);const c=A(s,{minRuns:2});let l;const g=b(s,".task-runner","runs");if(P(g)){const p=x(g).filter(d=>d.endsWith(".json")).sort();let m=0,S=0;for(const d of p.slice(-20))try{const h=V(b(g,d));h.stats&&(m+=h.stats.total??0,S+=h.stats.cached??0)}catch{continue}m>0&&(l=`${(S/m*100).toFixed(0)}%`)}if(t.json){e.info(JSON.stringify({cacheHitRate:l??null,constraintViolations:o,flakyTasks:c.length,projects:j,runtimeIssues:a.length,targets:k},null,2));return}e.info(""),e.info(` ${J("VIS STATUS")}`),e.info(""),e.info(` ${r(!0)} ${String(j)} projects · ${String(k)} unique targets`),e.info(` ${r(a.length===0)} Runtime: ${a.length===0?f("OK"):_(`${String(a.length)} issue(s)`)}`),e.info(` ${r(o===0)} Constraints: ${o===0?f("OK"):v(`${String(o)} violation(s)`)}`),e.info(` ${r(c.length===0)} Flaky tasks: ${c.length===0?f("none"):_(String(c.length))}`),l&&e.info(` ${r(!0)} Cache hit rate: ${l} (last 20 runs)`),e.info("")},"execute");export{Q as default};
1
+ var w=Object.defineProperty;var j=(e,t)=>w(e,"name",{value:t,configurable:!0});import{createRequire as C}from"node:module";import{c as f,d as v,y as F,m as I,E as P,e as _}from"./bin.js";import{M as b,i as V,n as z}from"../packem_shared/otel-CO8UEfTa.js";import{enforceProjectConstraints as B}from"@visulima/task-runner";import{a as E}from"../packem_shared/flakiness-C4t4_NoA.js";import{c as J}from"../packem_shared/runtime-check-l4qFpo08.js";const M=C(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=j(e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,i]=o.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return o.getBuiltinModule(e)}return M(e)},"__cjs_getBuiltinModule"),{readdirSync:x}=q("node:fs");var K=Object.defineProperty,O=j((e,t)=>K(e,"name",{value:t,configurable:!0}),"h");const r=O(e=>e?f("✓"):v("✗"),"icon"),L=O(async({logger:e,options:t,visConfig:i,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root.");const{config:y,packageJsons:T,workspace:u}=F(s,i),R=I(s,u,T),k=Object.keys(u.projects).length,$=new Set(Object.values(u.projects).flatMap(p=>Object.keys(p.targets??{}))).size,a=J(s);let n=0;y.constraints&&(n=B(R,y.constraints).length);const c=E(s,{minRuns:2});let l;const g=b(s,".task-runner","runs");if(V(g)){const p=x(g).filter(h=>h.endsWith(".json")).sort();let m=0,S=0;for(const h of p.slice(-20))try{const d=z(b(g,h));d.stats&&(m+=d.stats.total??0,S+=d.stats.cached??0)}catch{continue}m>0&&(l=`${(S/m*100).toFixed(0)}%`)}if(t.json){e.info(JSON.stringify({cacheHitRate:l??null,constraintViolations:n,flakyTasks:c.length,projects:k,runtimeIssues:a.length,targets:$},null,2));return}e.info(""),e.info(` ${P("VIS STATUS")}`),e.info(""),e.info(` ${r(!0)} ${String(k)} projects · ${String($)} unique targets`),e.info(` ${r(a.length===0)} Runtime: ${a.length===0?f("OK"):_(`${String(a.length)} issue(s)`)}`),e.info(` ${r(n===0)} Constraints: ${n===0?f("OK"):v(`${String(n)} violation(s)`)}`),e.info(` ${r(c.length===0)} Flaky tasks: ${c.length===0?f("none"):_(String(c.length))}`),l&&e.info(` ${r(!0)} Cache hit rate: ${l} (last 20 runs)`),e.info("")},"execute");export{L as default};
@@ -1,4 +1,4 @@
1
- var P=Object.defineProperty;var v=(e,n)=>P(e,"name",{value:n,configurable:!0});import{createRequire as R}from"node:module";import{c as S,d as W,e as A,E as d,p as o}from"./bin.js";import{M as N}from"../packem_shared/index-OlP7U_t5.js";import{S as w,g as C,w as M,b as B,p as q,f as j,a as k,c as H,u as y,d as K,e as O,h as D}from"../packem_shared/toolchain-B7sIiJxK.js";const I=R(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=v(e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[n,i]=$.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return $.getBuiltinModule(e)}return I(e)},"__cjs_getBuiltinModule"),{spawnSync:U}=b("node:child_process"),{writeFileSync:F}=b("node:fs");var L=Object.defineProperty,f=v((e,n)=>L(e,"name",{value:n,configurable:!0}),"d");const x=["bun","deno","go","node","npm","pnpm","python","ruby","rust","yarn"],G=f(e=>x.includes(e),"isKnownTool"),p=f(e=>e?S("✓"):W("✗"),"icon"),T=A("⚠"),J=f(e=>{if(e.installed){const n=e.version?` v${e.version}`:"",i=e.configFiles.length>0?` (${e.configFiles.join(", ")})`:"";return`${p(!0)} ${e.name}${n}${i}`}return`${T} ${e.name} — referenced by ${e.configFiles.join(", ")} but not installed`},"renderManagerLine"),z=f(e=>{if(e.matches)return"";const{manager:n}=e;return n.name==="none"?d("→ (no manager)"):n.name==="self-activate"?"":n.installed?d(`→ ${n.name}`):d(`→ ${n.name} (missing)`)},"renderToolManager"),Q=f(e=>e.matches?p(!0):e.actual?T:p(!1),"toolIcon"),V=f(e=>{if(o.info(""),o.info(d("── Toolchain ───────────────────────")),e.detected.length===0)o.info(` ${p(!1)} No version manager detected`),o.notice(` Install one of: ${w.join(", ")}`);else for(const n of e.detected)o.info(` ${J(n)}`);if(o.info(""),e.tools.length===0){o.info(` ${d("No tool pins found — add engines.node, .nvmrc, or a manager config file.")}`);return}o.info(d("── Tools ───────────────────────────"));for(const n of e.tools){const i=`${n.expected.tool} ${n.expected.version}`,r=n.actual?`actual ${n.actual}`:"not installed",t=n.matches?"":d(` [${n.expected.source}]`),s=z(n),u=s===""?"":` ${s}`;o.info(` ${Q(n)} ${i} — ${r}${t}${u}`),n.manager.note&&o.notice(` ${n.manager.note}`)}},"printStatus"),X=f((e,n,i)=>{const r=C(e,n);if(i.json){process.stdout.write(`${JSON.stringify({detected:r.detected.map(s=>({binPath:s.binPath??null,configFiles:s.configFiles,installed:s.installed,name:s.name,version:s.version??null})),tools:r.tools.map(s=>({actual:s.actual??null,expected:s.expected.version,manager:s.manager.name,managerInstalled:s.manager.installed,matches:s.matches,note:s.manager.note??null,source:s.expected.source,tool:s.expected.tool}))},void 0,2)}
1
+ var P=Object.defineProperty;var v=(e,n)=>P(e,"name",{value:n,configurable:!0});import{createRequire as R}from"node:module";import{c as S,d as W,e as A,E as d,p as o}from"./bin.js";import{M as N}from"../packem_shared/otel-CO8UEfTa.js";import{S as w,g as C,w as M,b as B,p as q,f as j,a as k,c as H,u as y,d as K,e as O,h as D}from"../packem_shared/toolchain-BhZNts--.js";const I=R(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=v(e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[n,i]=$.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return $.getBuiltinModule(e)}return I(e)},"__cjs_getBuiltinModule"),{spawnSync:U}=b("node:child_process"),{writeFileSync:F}=b("node:fs");var L=Object.defineProperty,f=v((e,n)=>L(e,"name",{value:n,configurable:!0}),"d");const x=["bun","deno","go","node","npm","pnpm","python","ruby","rust","yarn"],G=f(e=>x.includes(e),"isKnownTool"),p=f(e=>e?S("✓"):W("✗"),"icon"),T=A("⚠"),J=f(e=>{if(e.installed){const n=e.version?` v${e.version}`:"",i=e.configFiles.length>0?` (${e.configFiles.join(", ")})`:"";return`${p(!0)} ${e.name}${n}${i}`}return`${T} ${e.name} — referenced by ${e.configFiles.join(", ")} but not installed`},"renderManagerLine"),z=f(e=>{if(e.matches)return"";const{manager:n}=e;return n.name==="none"?d("→ (no manager)"):n.name==="self-activate"?"":n.installed?d(`→ ${n.name}`):d(`→ ${n.name} (missing)`)},"renderToolManager"),Q=f(e=>e.matches?p(!0):e.actual?T:p(!1),"toolIcon"),V=f(e=>{if(o.info(""),o.info(d("── Toolchain ───────────────────────")),e.detected.length===0)o.info(` ${p(!1)} No version manager detected`),o.notice(` Install one of: ${w.join(", ")}`);else for(const n of e.detected)o.info(` ${J(n)}`);if(o.info(""),e.tools.length===0){o.info(` ${d("No tool pins found — add engines.node, .nvmrc, or a manager config file.")}`);return}o.info(d("── Tools ───────────────────────────"));for(const n of e.tools){const i=`${n.expected.tool} ${n.expected.version}`,r=n.actual?`actual ${n.actual}`:"not installed",t=n.matches?"":d(` [${n.expected.source}]`),s=z(n),u=s===""?"":` ${s}`;o.info(` ${Q(n)} ${i} — ${r}${t}${u}`),n.manager.note&&o.notice(` ${n.manager.note}`)}},"printStatus"),X=f((e,n,i)=>{const r=C(e,n);if(i.json){process.stdout.write(`${JSON.stringify({detected:r.detected.map(s=>({binPath:s.binPath??null,configFiles:s.configFiles,installed:s.installed,name:s.name,version:s.version??null})),tools:r.tools.map(s=>({actual:s.actual??null,expected:s.expected.version,manager:s.manager.name,managerInstalled:s.manager.installed,matches:s.matches,note:s.manager.note??null,source:s.expected.source,tool:s.expected.tool}))},void 0,2)}
2
2
  `);return}V(r);const t=r.tools.filter(s=>!s.matches);t.length>0&&(o.info(""),o.notice(" Run `vis toolchain install` to install pinned versions.")),i.exitCode&&t.length>0&&(process.exitCode=1)},"executeStatus"),Y=f(e=>{const n=new Map;for(const i of e){const r=n.get(i.manager.name);r?r.push(i):n.set(i.manager.name,[i])}return n},"groupByManager"),E=f((e,n,i)=>U(e,n,{cwd:i,stdio:"inherit"}).status??1,"runInvocation"),Z=f((e,n,i)=>{const r=C(e,n),t=r.tools.filter(c=>!c.matches);if(t.length===0){o.success("Everything already matches — nothing to install.");return}const s=t.some(c=>c.manager.name!=="self-activate"&&c.manager.name!=="none");if(r.detected.length===0&&s){o.error(`No version manager detected. Install one of: ${w.join(", ")}.`),process.exitCode=1;return}const u=Y(t);let l=!1,g=0;for(const[c,m]of u){if(c==="self-activate"){for(const{expected:a}of m){if(a.source==="packageManager")o.info(`${d("$")} (${a.tool} will self-activate from packageManager on next invocation)`);else if(o.info(`${d("$")} Writing packageManager=${a.tool}@${a.version}`),i.dryRun)l=!0;else try{M(e,a),l=!0}catch(h){o.error(h.message),g=1}o.notice(` ${a.tool} ${a.version} — no install needed`)}continue}if(c==="none"){for(const{expected:a}of m)o.warn(`Cannot install ${a.tool} ${a.version} — no manager can handle it.`);g=1;continue}if(!r.detected.find(a=>a.name===c)?.installed){o.error(`${c} is referenced but not on PATH — install it first, then rerun \`vis toolchain install\`.`),g=1;continue}const _=m.map(a=>B(c,a.expected)).filter(Boolean);for(const a of _){if(!a)continue;if(a.bin==="nvm"&&a.args.length===0){o.error("nvm is a shell function — run `nvm install` in your shell, then rerun `vis toolchain install`."),a.hint&&o.notice(` ${a.hint}`),g=1;continue}if(o.info(`${d("$")} ${a.bin} ${a.args.join(" ")}`),a.hint&&o.notice(` ${a.hint}`),i.dryRun){l=!0;continue}const h=E(a.bin,a.args,e);if(l=!0,h!==0){g=h;break}}}if(g!==0){process.exitCode=g;return}l&&o.success("Toolchain installed.")},"executeInstall"),ee=f((e,n,i,r)=>{if(!i)throw new Error("Usage: vis toolchain use <tool>@<version> (e.g. vis toolchain use node@22.13.0)");const t=q(i);if(!t)throw new Error(`Could not parse "${i}". Expected "<tool>@<version>" where <tool> is one of ${x.join(", ")}.`);const s=j(e),u=k(t,s,n);if(u.name==="none"){o.error(`No manager can pin ${t.tool}. Install one of: ${w.join(", ")}.`),process.exitCode=1;return}if(!u.installed){o.error(`The best manager for ${t.tool} (${u.name}) is not on PATH. ${u.note??""}`),process.exitCode=1;return}const l=H(u.name,t);if(!l){o.error(`${u.name} cannot pin ${t.tool}. Use a different manager, or set \`toolchain.tools.${t.tool}\` in vis.config.ts.`),process.exitCode=1;return}if(u.name==="self-activate"){if(o.info(`${d("→")} Writing packageManager field to package.json...`),r.dryRun){o.notice(` Would set packageManager: "${t.tool}@${t.version}"`);return}try{const c=M(e,t);if(!c){o.error(`Refusing to pin non-package-manager tool ${t.tool} via the packageManager field.`),process.exitCode=1;return}if(o.success(`Set packageManager: "${c}" — ${t.tool} will activate this version on next invocation.`),r.engines!==!1){const m=y(e,t);m&&o.success(`Updated package.json engines.${t.tool} → ${m}.`)}}catch(c){o.error(c.message),process.exitCode=1}return}if(l.args.length===0&&u.name==="nvm"&&t.tool==="node"){const c=N(e,".nvmrc");if(o.info(`${d("→")} Writing ${c}...`),r.dryRun){o.notice(` Would write ${t.version} to .nvmrc`);return}try{F(c,`${t.version}
3
3
  `)}catch(m){o.error(`Failed to write .nvmrc: ${m.message}`),process.exitCode=1;return}o.success(`Wrote ${t.version} to .nvmrc.`),o.notice(" nvm is a shell function — run `nvm use` to activate it in this shell.");return}if(l.args.length===0){o.error(`${u.name} cannot pin ${t.tool} from a subprocess. ${l.configChange?.hint??""}`),l.configChange&&o.notice(` Edit ${l.configChange.file} by hand and rerun \`vis toolchain status\` to verify.`),process.exitCode=1;return}if(o.info(`${d("$")} ${l.bin} ${l.args.join(" ")}`),l.configChange&&o.notice(` Will update ${l.configChange.file} — ${l.configChange.hint}`),r.dryRun)return;const g=E(l.bin,l.args,e);if(g!==0){process.exitCode=g;return}if(o.success(`Pinned ${t.tool} to ${t.version}.`),r.engines!==!1)try{const c=y(e,t);c&&o.success(`Updated package.json engines.${t.tool} → ${c}.`)}catch(c){o.warn(`Could not update engines.${t.tool}: ${c.message}`)}},"executeUse"),ne=f((e,n,i)=>{if(!i)throw new Error("Usage: vis toolchain which <tool> (e.g. vis toolchain which node)");const r=i.toLowerCase();if(!G(r))throw new Error(`Unknown tool "${i}". Known: ${x.join(", ")}.`);const t=j(e),s=k({source:"vis.config.ts",tool:r,version:"*"},t,n),u=s.installed&&s.name!=="self-activate"&&s.name!=="none"?t.find(g=>g.name===s.name):void 0,l=u?K(u,r):O(r);if(!l){o.error(`${i} not found in PATH${u?` or via ${u.name}`:""}.`),process.exitCode=1;return}process.stdout.write(`${l}
4
4
  `)},"executeWhich"),oe=f((e,n)=>{const i=D(e,n);process.stdout.write(`${i.name}
@@ -1 +1 @@
1
- var p=Object.defineProperty;var c=(e,o)=>p(e,"name",{value:o,configurable:!0});import{h as f,u}from"./bin.js";var g=Object.defineProperty,d=c((e,o)=>g(e,"name",{value:o,configurable:!0}),"t");const v=d(async({argument:e,logger:o,options:n,visConfig:a,workspaceRoot:t})=>{const i=e||[],r=t??process.cwd(),l=f(r,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),s=u(l,i,n.recursive||!1,r,o);s!==0&&(process.exitCode=s)},"execute");export{v as default};
1
+ var p=Object.defineProperty;var c=(e,o)=>p(e,"name",{value:o,configurable:!0});import{h as f,C as g}from"./bin.js";var u=Object.defineProperty,d=c((e,o)=>u(e,"name",{value:o,configurable:!0}),"t");const v=d(async({argument:e,logger:o,options:n,visConfig:a,workspaceRoot:t})=>{const i=e||[],r=t??process.cwd(),l=f(r,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),s=g(l,i,n.recursive||!1,r,o);s!==0&&(process.exitCode=s)},"execute");export{v as default};
@@ -1,3 +1,3 @@
1
- var a=Object.defineProperty;var s=(n,e)=>a(n,"name",{value:e,configurable:!0});import{createRequire as f}from"node:module";import{v}from"./bin.js";const d=f(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=s(n=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,r]=t.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return t.getBuiltinModule(n)}return d(n)},"__cjs_getBuiltinModule"),{execSync:p,spawnSync:m}=l("node:child_process");var g=Object.defineProperty,y=s((n,e)=>g(n,"name",{value:e,configurable:!0}),"r");const w=y(async({argument:n,logger:e,options:r})=>{const c=n?.[0];e.info("info: checking for updates...");const o=v.version;let i;try{const u=p("npm view @visulima/vis version",{encoding:"utf8"}).trim();i=c??u}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(o===i&&!r.force){e.info(`
1
+ var a=Object.defineProperty;var s=(n,e)=>a(n,"name",{value:e,configurable:!0});import{createRequire as f}from"node:module";import{K as v}from"./bin.js";const d=f(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=s(n=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,r]=t.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return t.getBuiltinModule(n)}return d(n)},"__cjs_getBuiltinModule"),{execSync:p,spawnSync:m}=l("node:child_process");var g=Object.defineProperty,y=s((n,e)=>g(n,"name",{value:e,configurable:!0}),"r");const w=y(async({argument:n,logger:e,options:r})=>{const c=n?.[0];e.info("info: checking for updates...");const o=v.version;let i;try{const u=p("npm view @visulima/vis version",{encoding:"utf8"}).trim();i=c??u}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(o===i&&!r.force){e.info(`
2
2
  ✓ Already up to date (${o})`);return}if(r.check){o===i?e.info(`✓ Already up to date (${o})`):e.info(`info: found @visulima/vis@${i} (current: ${o})`);return}if(e.info(`info: found @visulima/vis@${i} (current: ${o})`),e.info("info: installing..."),m("npm",["install","-g",`@visulima/vis@${i}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
3
3
  ✓ Updated @visulima/vis from ${o} → ${i}`)},"execute");export{w as default};
@@ -1 +1 @@
1
- var p=Object.defineProperty;var t=(a,o)=>p(a,"name",{value:o,configurable:!0});import{h as f,C as d}from"./bin.js";import{o as g}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,u=t((a,o)=>v(a,"name",{value:o,configurable:!0}),"n");const h=u(async({argument:a,logger:o,options:e,visConfig:l,workspaceRoot:c})=>{const s=a;if(!s||s.length===0)throw new Error("No packages specified. Usage: vis why <package...>");const n=c??process.cwd(),i=f(n,{configBackend:l?.install?.backend,configCorepack:l?.install?.corepack}),r=d(i,{depth:e.depth===void 0?void 0:Number(e.depth),dev:e.dev||!1,filter:g(e.filter),global:e.global||!1,json:e.json||!1,long:e.long||!1,noOptional:e.optional===!1,packages:s,parseable:e.parseable||!1,prod:e.prod||!1,recursive:e.recursive||!1},n,o);r!==0&&r!==1&&(process.exitCode=r)},"execute");export{h as default};
1
+ var p=Object.defineProperty;var t=(a,o)=>p(a,"name",{value:o,configurable:!0});import{h as f,L as d}from"./bin.js";import{o as g}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,u=t((a,o)=>v(a,"name",{value:o,configurable:!0}),"n");const h=u(async({argument:a,logger:o,options:e,visConfig:l,workspaceRoot:c})=>{const s=a;if(!s||s.length===0)throw new Error("No packages specified. Usage: vis why <package...>");const n=c??process.cwd(),i=f(n,{configBackend:l?.install?.backend,configCorepack:l?.install?.corepack}),r=d(i,{depth:e.depth===void 0?void 0:Number(e.depth),dev:e.dev||!1,filter:g(e.filter),global:e.global||!1,json:e.json||!1,long:e.long||!1,noOptional:e.optional===!1,packages:s,parseable:e.parseable||!1,prod:e.prod||!1,recursive:e.recursive||!1},n,o);r!==0&&r!==1&&(process.exitCode=r)},"execute");export{h as default};
@@ -1 +1 @@
1
- var q=Object.defineProperty;var $=(t,r)=>q(t,"name",{value:r,configurable:!0});import{createRequire as A}from"node:module";import{B as I,w as b,K as N,p as g,L as R,E as M,d as U,e as B,c as E,Q as J,X as z,Y as Q,a as Y,y as Z,U as K,R as V,Z as W,r as X,J as G,$ as H,h as ee,a0 as oe}from"./bin.js";import{readJsonSync as te,writeJsonSync as se}from"@visulima/fs";import{M as ne}from"../packem_shared/index-OlP7U_t5.js";import{r as re}from"../packem_shared/typosquats-XkC1CnOa.js";import{d as C,o as j}from"../packem_shared/utils-DrNg0XTR.js";const L=A(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=$(t=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[r,e]=k.versions.node.split(".").map(Number);if(r>22||r===22&&e>=3||r===20&&e>=16)return k.getBuiltinModule(t)}return L(t)},"__cjs_getBuiltinModule"),{createInterface:F}=O("node:readline");var ae=Object.defineProperty,h=$((t,r)=>ae(t,"name",{value:r,configurable:!0}),"c");const P=h(t=>t==="default"?"catalog:":`catalog:${t}`,"buildCatalogRef"),S=h(t=>t==="default"?"default catalog":`catalog "${t}"`,"labelForCatalog"),ie=h((t,r)=>{const e=[];for(const[o,n]of r)o.includes(":")||n.has(t)&&e.push(o);if(e.length===0)return;if(e.length===1){const[o]=e;return{source:S(o),spec:P(o)}}const a=e.find(o=>o==="default")??e[0],i=e.filter(o=>o!==a);return{candidates:[...e],conflict:!0,source:`${S(a)} (also in: ${i.map(o=>S(o)).join(", ")})`,spec:P(a)}},"resolveFromCatalogs"),ce=h((t,r)=>{const e=new Map;for(const[l,p]of r){if(!l.includes(":"))continue;const f=p.get(t);f!==void 0&&e.set(f,(e.get(f)??0)+1)}if(e.size===0)return;const a=[...e.entries()],i=a.reduce((l,[,p])=>l+p,0);if(a.length===1){const[[l]]=a;return{source:`siblings (${String(i)} pkg${i===1?"":"s"} on ${l})`,spec:l}}const o=[...a].sort((l,p)=>p[1]-l[1]),[n,s]=o[0],c=o.slice(1).map(([l,p])=>`${l} (×${String(p)})`);return{candidates:o.map(([l])=>l),conflict:!0,source:`siblings (most common: ${n} ×${String(s)}; conflicts: ${c.join(", ")})`,spec:n}},"resolveFromSiblings"),le=h((t,r)=>ie(t,r)||ce(t,r),"conformToCatalog");var pe=Object.defineProperty,d=$((t,r)=>pe(t,"name",{value:r,configurable:!0}),"m");const T=d(async(t,r=1e4)=>{const e=new Map,a=new AbortController,i=setTimeout(()=>{a.abort()},r);try{const o=t.map(async n=>{try{const s=await fetch(`https://registry.npmjs.org/${n}/latest`,{headers:{Accept:"application/json"},signal:a.signal});if(s.ok){const c=await s.json();c.version&&e.set(n,c.version)}}catch{}});await Promise.all(o)}finally{clearTimeout(i)}return e},"resolveLatestVersions"),fe=d((t,r,e)=>{const a=[];for(const i of t.values()){const{overall:o}=i.score,n=I(o),s=`${String(Math.round(o*100))}%`,c=i.alerts.length,l=b(i),p=N(l,i.version,e),f=n==="red"?U:n==="yellow"?B:E;if(p?g.info(` ${f(s)} ${R(i)} ${M(`[accepted: ${p.reason}]`)}`):g.info(` ${f(s)} ${R(i)}`),c>0){const u=i.alerts.filter(m=>m.severity==="critical"||m.severity==="high").length;u>0&&g.warn(` ${String(u)} critical/high alert${u===1?"":"s"}`)}o<r&&!p&&a.push(i)}return a},"displaySecurityReports"),ge=d(async(t,r)=>{const e=F({input:process.stdin,output:process.stdout}),a=d(s=>new Promise(c=>{e.question(s,l=>{c(l.trim())})}),"ask"),i=String(Math.round(r*100));g.warn(""),g.warn(`${String(t.length)} package${t.length===1?"":"s"} scored below the minimum threshold (${i}%):`);for(const s of t){const c=b(s),l=`${String(Math.round(s.score.overall*100))}%`;g.warn(` • ${c}@${s.version} — score: ${l} (${J(s.score.overall)})`)}g.warn("");const o=await a("Continue adding these packages? [y/N] ");if(o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes")return e.close(),!1;const n=await a("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),n.toLowerCase()==="y"||n.toLowerCase()==="yes"){g.notice(""),g.notice("Add the following to security.socket.acceptedRisks in vis.config.ts:"),g.notice("");for(const s of t){const c=b(s),l=z(c,s.version,s.score.overall,"Reviewed and accepted");g.notice(l)}g.notice("")}return!0},"confirmLowScorePackages"),ue=d(async(t,r,e,a)=>{const i=t.map(f=>C(f)),o=new Map;for(const f of i)if(f.versionSpec){const u=Q.coerce(f.versionSpec);u&&o.set(f.name,u.version)}const n=i.filter(f=>!o.has(f.name)).map(f=>f.name),s=n.length>0?await T(n):new Map,c=[];for(const f of i){const u=o.get(f.name)??s.get(f.name);u&&c.push({name:f.name,version:u})}if(c.length===0)return!0;g.info(""),g.info("Socket.dev security check:");const l=await Y(c,r);if(l.size===0)return g.info(" Could not fetch security data. Proceeding."),!0;const p=fe(l,e,a);return p.length===0?(g.info(""),!0):process.stdin.isTTY?ge(p,e):(g.warn(`Aborting: ${String(p.length)} package${p.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},"runSocketPreCheck"),de=["dependencies","devDependencies","peerDependencies","optionalDependencies"],me=d(t=>t.savePeer?"peerDependencies":t.saveOptional?"optionalDependencies":t.saveDev?"devDependencies":"dependencies","pickDepSection"),_=d((t,r)=>t.startsWith("catalog:")||!r?t:t.replace(/^[\^~]/,""),"applyExactPrefix"),ve=d(async(t,r)=>{const e=[];for(const o of t){const{name:n,versionSpec:s}=C(o);if(!n)continue;if(s!==void 0){e.push({explicit:s,name:n});continue}const c=le(n,r);if(c){c.conflict&&g.warn(`${n}: ambiguous constraint — picking ${c.spec} (${c.source}). Pass ${n}@<version> to override.`),e.push({entry:{name:n,source:c.source,spec:c.spec},kind:"resolved",name:n});continue}e.push({kind:"missing",name:n})}const a=e.filter(o=>"kind"in o&&o.kind==="missing").map(o=>o.name),i=a.length>0?await T(a):new Map;return e.map(o=>{if("explicit"in o)return{name:o.name,source:"explicit",spec:o.explicit};if(o.kind==="resolved")return o.entry;const n=i.get(o.name);if(n===void 0)throw new Error(`--to: cannot resolve a version for "${o.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${o.name}@<version> explicitly.`);const s=`^${n}`;return g.info(`${o.name}: no existing constraint — using registry latest (${s}). Add to a catalog to share this version across workspace packages.`),{name:o.name,source:"registry latest",spec:s}})},"planConformedSpecs"),we=d((t,r,e,a)=>{for(const{name:i,spec:o}of r){const n=_(o,a);for(const c of de){if(c===e)continue;const l=t[c];l?.[i]!==void 0&&(delete l[i],Object.keys(l).length===0&&delete t[c])}let s=t[e];s===void 0&&(s={},t[e]=s),s[i]=n}},"applyPlannedSpecsToPackageJson"),ke=d(async({ignoreScripts:t,logger:r,options:e,packages:a,pm:i,target:o,visConfig:n,workspaceRoot:s})=>{const{workspace:c}=Z(s,n??{}),l=c.projects[o];if(!l){const v=Object.keys(c.projects).sort();throw new Error(`--to: workspace package "${o}" not found. Available: ${v.length>0?v.slice(0,10).join(", "):"(none)"}${v.length>10?`, ... (${String(v.length-10)} more)`:""}.`)}const p=ne(s,l.root,"package.json"),{packageManager:f}=K(s),u=V(s,f),m=me(e),w=e.exact??!1,y=await ve(a,u);if(y.length===0)return 0;const x=te(p);we(x,y,m,w),se(p,x,{indent:W(p,{useEditorconfig:n?.editorconfig??!0}),overwrite:!0});for(const v of y){const D=_(v.spec,w);g.info(`${E("+")} ${v.name}@${D} → ${o}/${m} (${M(v.source)})`)}return X(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:t,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},s,r)},"applyConformedAdd"),Re=d(async({argument:t,logger:r,options:e,visConfig:a,workspaceRoot:i})=>{let o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const p=o.map(u=>C(u)),f=await re(p.map(u=>u.name),a?.security?.typosquatAllowlist);if(!f.ok){process.exitCode=1;return}o=p.map((u,m)=>{const w=f.packages[m];return w!==u.name?u.versionSpec?`${w}@${u.versionSpec}`:w??"":o[m]??""})}if(e.socketCheck!==!1){const p=G(a?.security?.socket);if(p){const f=p.minimumScore??H;if(!await ue(o,p,f,a?.security?.socket?.acceptedRisks)){process.exitCode=1;return}}}const n=process.cwd(),s=ee(i??n,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),c=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&j(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!i)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const p=await ke({ignoreScripts:c,logger:r,options:e,packages:o,pm:s,target:e.to,visConfig:a,workspaceRoot:i});p!==0&&(process.exitCode=p);return}const l=oe(s,{exact:e.exact||!1,filter:j(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:o,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},n,r,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:c});l!==0&&(process.exitCode=l)},"execute");export{Re as default};
1
+ var q=Object.defineProperty;var $=(t,a)=>q(t,"name",{value:a,configurable:!0});import{createRequire as A}from"node:module";import{B as I,Q as S,X as N,p as g,Y as R,E as M,d as U,e as B,c as E,Z as z,$ as J,a0 as Q,a as Y,y as Z,U as V,R as W,a1 as X,v as G,J as H,a2 as K,h as ee,a3 as oe}from"./bin.js";import{M as te,n as se,w as ne}from"../packem_shared/otel-CO8UEfTa.js";import{r as ae}from"../packem_shared/typosquats-Dr7VIL2B.js";import{d as C,o as j}from"../packem_shared/utils-DrNg0XTR.js";const O=A(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=$(t=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[a,e]=w.versions.node.split(".").map(Number);if(a>22||a===22&&e>=3||a===20&&e>=16)return w.getBuiltinModule(t)}return O(t)},"__cjs_getBuiltinModule"),{createInterface:F}=L("node:readline");var re=Object.defineProperty,h=$((t,a)=>re(t,"name",{value:a,configurable:!0}),"c");const P=h(t=>t==="default"?"catalog:":`catalog:${t}`,"buildCatalogRef"),b=h(t=>t==="default"?"default catalog":`catalog "${t}"`,"labelForCatalog"),ie=h((t,a)=>{const e=[];for(const[o,n]of a)o.includes(":")||n.has(t)&&e.push(o);if(e.length===0)return;if(e.length===1){const[o]=e;return{source:b(o),spec:P(o)}}const r=e.find(o=>o==="default")??e[0],i=e.filter(o=>o!==r);return{candidates:[...e],conflict:!0,source:`${b(r)} (also in: ${i.map(o=>b(o)).join(", ")})`,spec:P(r)}},"resolveFromCatalogs"),ce=h((t,a)=>{const e=new Map;for(const[l,p]of a){if(!l.includes(":"))continue;const f=p.get(t);f!==void 0&&e.set(f,(e.get(f)??0)+1)}if(e.size===0)return;const r=[...e.entries()],i=r.reduce((l,[,p])=>l+p,0);if(r.length===1){const[[l]]=r;return{source:`siblings (${String(i)} pkg${i===1?"":"s"} on ${l})`,spec:l}}const o=[...r].sort((l,p)=>p[1]-l[1]),[n,s]=o[0],c=o.slice(1).map(([l,p])=>`${l} (×${String(p)})`);return{candidates:o.map(([l])=>l),conflict:!0,source:`siblings (most common: ${n} ×${String(s)}; conflicts: ${c.join(", ")})`,spec:n}},"resolveFromSiblings"),le=h((t,a)=>ie(t,a)||ce(t,a),"conformToCatalog");var pe=Object.defineProperty,d=$((t,a)=>pe(t,"name",{value:a,configurable:!0}),"m");const T=d(async(t,a=1e4)=>{const e=new Map,r=new AbortController,i=setTimeout(()=>{r.abort()},a);try{const o=t.map(async n=>{try{const s=await fetch(`https://registry.npmjs.org/${n}/latest`,{headers:{Accept:"application/json"},signal:r.signal});if(s.ok){const c=await s.json();c.version&&e.set(n,c.version)}}catch{}});await Promise.all(o)}finally{clearTimeout(i)}return e},"resolveLatestVersions"),fe=d((t,a,e)=>{const r=[];for(const i of t.values()){const{overall:o}=i.score,n=I(o),s=`${String(Math.round(o*100))}%`,c=i.alerts.length,l=S(i),p=N(l,i.version,e),f=n==="red"?U:n==="yellow"?B:E;if(p?g.info(` ${f(s)} ${R(i)} ${M(`[accepted: ${p.reason}]`)}`):g.info(` ${f(s)} ${R(i)}`),c>0){const u=i.alerts.filter(m=>m.severity==="critical"||m.severity==="high").length;u>0&&g.warn(` ${String(u)} critical/high alert${u===1?"":"s"}`)}o<a&&!p&&r.push(i)}return r},"displaySecurityReports"),ge=d(async(t,a)=>{const e=F({input:process.stdin,output:process.stdout}),r=d(s=>new Promise(c=>{e.question(s,l=>{c(l.trim())})}),"ask"),i=String(Math.round(a*100));g.warn(""),g.warn(`${String(t.length)} package${t.length===1?"":"s"} scored below the minimum threshold (${i}%):`);for(const s of t){const c=S(s),l=`${String(Math.round(s.score.overall*100))}%`;g.warn(` • ${c}@${s.version} — score: ${l} (${z(s.score.overall)})`)}g.warn("");const o=await r("Continue adding these packages? [y/N] ");if(o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes")return e.close(),!1;const n=await r("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),n.toLowerCase()==="y"||n.toLowerCase()==="yes"){g.notice(""),g.notice("Add the following to security.socket.acceptedRisks in vis.config.ts:"),g.notice("");for(const s of t){const c=S(s),l=J(c,s.version,s.score.overall,"Reviewed and accepted");g.notice(l)}g.notice("")}return!0},"confirmLowScorePackages"),ue=d(async(t,a,e,r)=>{const i=t.map(f=>C(f)),o=new Map;for(const f of i)if(f.versionSpec){const u=Q.coerce(f.versionSpec);u&&o.set(f.name,u.version)}const n=i.filter(f=>!o.has(f.name)).map(f=>f.name),s=n.length>0?await T(n):new Map,c=[];for(const f of i){const u=o.get(f.name)??s.get(f.name);u&&c.push({name:f.name,version:u})}if(c.length===0)return!0;g.info(""),g.info("Socket.dev security check:");const l=await Y(c,a);if(l.size===0)return g.info(" Could not fetch security data. Proceeding."),!0;const p=fe(l,e,r);return p.length===0?(g.info(""),!0):process.stdin.isTTY?ge(p,e):(g.warn(`Aborting: ${String(p.length)} package${p.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},"runSocketPreCheck"),de=["dependencies","devDependencies","peerDependencies","optionalDependencies"],me=d(t=>t.savePeer?"peerDependencies":t.saveOptional?"optionalDependencies":t.saveDev?"devDependencies":"dependencies","pickDepSection"),_=d((t,a)=>t.startsWith("catalog:")||!a?t:t.replace(/^[\^~]/,""),"applyExactPrefix"),ve=d(async(t,a)=>{const e=[];for(const o of t){const{name:n,versionSpec:s}=C(o);if(!n)continue;if(s!==void 0){e.push({explicit:s,name:n});continue}const c=le(n,a);if(c){c.conflict&&g.warn(`${n}: ambiguous constraint — picking ${c.spec} (${c.source}). Pass ${n}@<version> to override.`),e.push({entry:{name:n,source:c.source,spec:c.spec},kind:"resolved",name:n});continue}e.push({kind:"missing",name:n})}const r=e.filter(o=>"kind"in o&&o.kind==="missing").map(o=>o.name),i=r.length>0?await T(r):new Map;return e.map(o=>{if("explicit"in o)return{name:o.name,source:"explicit",spec:o.explicit};if(o.kind==="resolved")return o.entry;const n=i.get(o.name);if(n===void 0)throw new Error(`--to: cannot resolve a version for "${o.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${o.name}@<version> explicitly.`);const s=`^${n}`;return g.info(`${o.name}: no existing constraint — using registry latest (${s}). Add to a catalog to share this version across workspace packages.`),{name:o.name,source:"registry latest",spec:s}})},"planConformedSpecs"),ke=d((t,a,e,r)=>{for(const{name:i,spec:o}of a){const n=_(o,r);for(const c of de){if(c===e)continue;const l=t[c];l?.[i]!==void 0&&(delete l[i],Object.keys(l).length===0&&delete t[c])}let s=t[e];s===void 0&&(s={},t[e]=s),s[i]=n}},"applyPlannedSpecsToPackageJson"),we=d(async({ignoreScripts:t,logger:a,options:e,packages:r,pm:i,target:o,visConfig:n,workspaceRoot:s})=>{const{workspace:c}=Z(s,n??{}),l=c.projects[o];if(!l){const v=Object.keys(c.projects).sort();throw new Error(`--to: workspace package "${o}" not found. Available: ${v.length>0?v.slice(0,10).join(", "):"(none)"}${v.length>10?`, ... (${String(v.length-10)} more)`:""}.`)}const p=te(s,l.root,"package.json"),{packageManager:f}=V(s),u=W(s,f),m=me(e),k=e.exact??!1,y=await ve(r,u);if(y.length===0)return 0;const x=se(p);ke(x,y,m,k),ne(p,x,{indent:X(p,{useEditorconfig:n?.editorconfig??!0}),overwrite:!0});for(const v of y){const D=_(v.spec,k);g.info(`${E("+")} ${v.name}@${D} → ${o}/${m} (${M(v.source)})`)}return G(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:t,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},s,a)},"applyConformedAdd"),xe=d(async({argument:t,logger:a,options:e,visConfig:r,workspaceRoot:i})=>{let o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const p=o.map(u=>C(u)),f=await ae(p.map(u=>u.name),r?.security?.typosquatAllowlist);if(!f.ok){process.exitCode=1;return}o=p.map((u,m)=>{const k=f.packages[m];return k!==u.name?u.versionSpec?`${k}@${u.versionSpec}`:k??"":o[m]??""})}if(e.socketCheck!==!1){const p=H(r?.security?.socket);if(p){const f=p.minimumScore??K;if(!await ue(o,p,f,r?.security?.socket?.acceptedRisks)){process.exitCode=1;return}}}const n=process.cwd(),s=ee(i??n,{configBackend:r?.install?.backend,configCorepack:r?.install?.corepack}),c=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&j(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!i)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const p=await we({ignoreScripts:c,logger:a,options:e,packages:o,pm:s,target:e.to,visConfig:r,workspaceRoot:i});p!==0&&(process.exitCode=p);return}const l=oe(s,{exact:e.exact||!1,filter:j(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:o,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},n,a,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:c});l!==0&&(process.exitCode=l)},"execute");export{xe as default};
@@ -1,7 +1,7 @@
1
- var x=Object.defineProperty;var l=(e,o)=>x(e,"name",{value:o,configurable:!0});import{b as g,O as E,_ as S,R as f}from"../packem_shared/ai-analysis-Dzs_nUwM.js";import{renderToString as w,Table as D}from"@visulima/tui";import P from"react";import{j as I,E as d,q as O,c as j,e as N}from"./bin.js";var T=Object.defineProperty,u=l((e,o)=>T(e,"name",{value:o,configurable:!0}),"s");const v={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},R=u(e=>{if(typeof e!="function")return String(e);const{name:o}=e;return o==="Boolean"?"boolean":o==="Number"?"number":o==="String"?"string":o??"unknown"},"typeName"),A=u(e=>{const o=[...e.commandPath??[],e.name].join(" "),i=(e.examples??[]).map(([t,s])=>({command:t??"",description:s??""})),a=(e.options??[]).map(t=>({defaultValue:t.defaultValue,description:t.description,name:t.name,type:R(t.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:i,name:e.name,options:a,path:o}},"buildSubcommand"),h=u((e,o=v)=>({command:o.command,description:o.description,subcommands:e.map(i=>A(i))}),"buildDiscoveryPayload"),C=u((e,o=v)=>`${JSON.stringify(h(e,o),void 0,2)}
1
+ var x=Object.defineProperty;var l=(e,o)=>x(e,"name",{value:o,configurable:!0});import{b as g,O as E,_ as S,R as f}from"../packem_shared/ai-analysis-CGVjqwdc.js";import{renderToString as w,Table as D}from"@visulima/tui";import P from"react";import{j as I,E as d,q as O,c as j,e as N}from"./bin.js";var T=Object.defineProperty,u=l((e,o)=>T(e,"name",{value:o,configurable:!0}),"s");const v={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},R=u(e=>{if(typeof e!="function")return String(e);const{name:o}=e;return o==="Boolean"?"boolean":o==="Number"?"number":o==="String"?"string":o??"unknown"},"typeName"),A=u(e=>{const o=[...e.commandPath??[],e.name].join(" "),i=(e.examples??[]).map(([t,s])=>({command:t??"",description:s??""})),a=(e.options??[]).map(t=>({defaultValue:t.defaultValue,description:t.description,name:t.name,type:R(t.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:i,name:e.name,options:a,path:o}},"buildSubcommand"),h=u((e,o=v)=>({command:o.command,description:o.description,subcommands:e.map(i=>A(i))}),"buildDiscoveryPayload"),C=u((e,o=v)=>`${JSON.stringify(h(e,o),void 0,2)}
2
2
  `,"renderDiscoveryJson"),J=u((e,o=v)=>{const i=h(e,o),a=[I(`vis ${i.command} — ${i.description}`),"",d("Subcommands:")];for(const t of i.subcommands){const s=t.argument?` ${O(`<${t.argument.name}>`)}`:"";if(a.push(""),a.push(` ${j(`vis ${t.path}`)}${s}`),t.description&&a.push(` ${t.description}`),t.options.length>0){const n=t.options.map(c=>`--${c.name}${c.type==="boolean"?"":`=<${c.type}>`}`).join(", ");a.push(d(` options: ${n}`))}if(t.examples.length>0){a.push(d(" examples:"));for(const n of t.examples){const c=n.description?d(` — ${n.description}`):"";a.push(` ${N(n.command)}${c}`)}}}return a.push(""),a.push(d(`Run \`vis ${i.command} discover-help\` for the machine-readable JSON catalogue (designed for AI agents).`)),a.push(d(`Run \`vis ${i.command} <subcommand> --help\` for full usage of a specific subcommand.`)),`${a.join(`
3
3
  `)}
4
- `},"renderDiscoveryText");var F=Object.defineProperty,p=l((e,o)=>F(e,"name",{value:o,configurable:!0}),"r");const b=p(async()=>{const{default:e}=await import("./bin.js").then(o=>o.b6);return e.filter(o=>o.name!=="ai")},"loadDiscoverableSubcommands"),B=p(async()=>{const e=await b();process.stderr.write(J(e))},"aiRootExecute"),K=p(async()=>{const e=await b();process.stdout.write(C(e))},"aiDiscoverHelpExecute"),L=p(async({logger:e,visConfig:o})=>{const i=o?.ai,a=g(i);if(!a){e.error("No AI provider available to test."),process.exitCode=1;return}e.info(`Testing ${a.name}...`);try{const t=await E(a,"Reply with exactly: OK",{timeoutMs:3e4});e.info(`Provider ${a.name} responded: ${t.stdout.trim().slice(0,200)}`)}catch(t){const s=t instanceof Error?t.message:String(t);e.error(`Provider ${a.name} failed: ${s}`),process.exitCode=1}},"aiTestExecute"),_=p(({logger:e,options:o,visConfig:i})=>{const a=o.format??"table",t=i?.ai,s=S(),n=g(t);if(a==="json"){const r=s.map(m=>({available:m.available,method:m.detectionMethod,name:m.name,path:m.path,priority:f[m.name]??0,selected:m.name===n?.name,version:m.version}));process.stdout.write(`${JSON.stringify(r,void 0,2)}
4
+ `},"renderDiscoveryText");var F=Object.defineProperty,p=l((e,o)=>F(e,"name",{value:o,configurable:!0}),"r");const b=p(async()=>{const{default:e}=await import("./bin.js").then(o=>o.bc);return e.filter(o=>o.name!=="ai")},"loadDiscoverableSubcommands"),B=p(async()=>{const e=await b();process.stderr.write(J(e))},"aiRootExecute"),K=p(async()=>{const e=await b();process.stdout.write(C(e))},"aiDiscoverHelpExecute"),L=p(async({logger:e,visConfig:o})=>{const i=o?.ai,a=g(i);if(!a){e.error("No AI provider available to test."),process.exitCode=1;return}e.info(`Testing ${a.name}...`);try{const t=await E(a,"Reply with exactly: OK",{timeoutMs:3e4});e.info(`Provider ${a.name} responded: ${t.stdout.trim().slice(0,200)}`)}catch(t){const s=t instanceof Error?t.message:String(t);e.error(`Provider ${a.name} failed: ${s}`),process.exitCode=1}},"aiTestExecute"),_=p(({logger:e,options:o,visConfig:i})=>{const a=o.format??"table",t=i?.ai,s=S(),n=g(t);if(a==="json"){const r=s.map(m=>({available:m.available,method:m.detectionMethod,name:m.name,path:m.path,priority:f[m.name]??0,selected:m.name===n?.name,version:m.version}));process.stdout.write(`${JSON.stringify(r,void 0,2)}
5
5
  `);return}const c=s.map(r=>({method:r.detectionMethod??"-",path:r.path??"-",priority:String(f[r.name]??0),provider:r.name,selected:r.name===n?.name?">>>":"",status:r.available?"available":"not found",version:r.version??"-"})),y=process.stdout.columns||80,$=w(P.createElement(D,{data:c}),{columns:y});e.info($),n?e.info(`
6
6
  Selected provider: ${n.name} (priority ${String(f[n.name]??0)})`):e.info(`
7
7
  No AI provider available. Install one of the supported AI CLI tools.`)},"aiProvidersExecute"),z=p(async e=>{const{aiFix:o}=await import("./fix.js");await o(e)},"aiFixExecute");export{K as aiDiscoverHelpExecute,z as aiFixExecute,_ as aiProvidersExecute,B as aiRootExecute,L as aiTestExecute};
@@ -1,4 +1,4 @@
1
- var re=Object.defineProperty;var U=(t,n)=>re(t,"name",{value:n,configurable:!0});import{E,e as q,q as Z,a1 as _,d as ee,w as oe,Q as ae,A as ce,p as a,J as le,N as de,a as ue,K as ge,$ as W}from"./bin.js";import{isAccessibleSync as G,readFileSync as z,writeFileSync as B}from"@visulima/fs";import{readYamlSync as se}from"@visulima/fs/yaml";import{M as H}from"../packem_shared/index-OlP7U_t5.js";import{l as fe,f as pe,s as he}from"../packem_shared/dependency-scan-DmwPKwLy.js";var ve=Object.defineProperty,S=U((t,n)=>ve(t,"name",{value:n,configurable:!0}),"o");const L=S(t=>Array.isArray(t)?t.filter(n=>typeof n=="string"):[],"toStringArray"),K=S((t,n)=>{for(const r of n)if(r===t||r.endsWith("*")&&t.startsWith(r.slice(0,-1)))return!0;return!1},"matchesGlobList"),te=S(t=>{const n=H(t,"pnpm-workspace.yaml");if(!G(n))return{excludedPackages:[],ignoredAdvisories:[]};try{const r=se(n);return{excludedPackages:[],ignoredAdvisories:[...L(r?.auditConfig?.ignoreCves),...L(r?.auditConfig?.ignoreGhsas)]}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readPnpmAuditExclusions"),ne=S(t=>{const n=H(t,".yarnrc.yml");if(!G(n))return{excludedPackages:[],ignoredAdvisories:[]};try{const r=se(n);return{excludedPackages:L(r?.npmAuditExcludePackages),ignoredAdvisories:L(r?.npmAuditIgnoreAdvisories)}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readYarnAuditExclusions"),$e=S((t,n)=>{switch(n){case"pnpm":return te(t);case"yarn":return ne(t);default:return{excludedPackages:[],ignoredAdvisories:[]}}},"readNativeAuditExclusions"),X=S((t,n,r)=>{if(K(t,n.ignoredAdvisories))return!0;if(r){for(const l of r)if(K(l,n.ignoredAdvisories))return!0}return!1},"isAdvisoryExcluded"),me=S((t,n)=>K(t,n.excludedPackages),"isPackageExcluded"),ke=S((t,n,r)=>{if(r.length===0)return["No advisory IDs to sync."];const l=[];switch(t){case"bun":{l.push(`bun has no audit config file. Use CLI flags: bun audit ${r.map(f=>`--ignore ${f}`).join(" ")}`);break}case"npm":{l.push("npm has no native audit exclusion config. vis accepted risks are the only layer.");break}case"pnpm":{const f=H(n,"pnpm-workspace.yaml");if(!G(f)){l.push("pnpm-workspace.yaml not found. Cannot sync.");break}const h=te(n),k=new Set(h.ignoredAdvisories.filter(c=>c.startsWith("CVE-"))),$=new Set(h.ignoredAdvisories.filter(c=>c.startsWith("GHSA-"))),y=r.filter(c=>c.startsWith("CVE-")),m=r.filter(c=>c.startsWith("GHSA-")),p=[...new Set([...k,...y])],d=[...new Set([...$,...m])],v=y.filter(c=>!k.has(c)).length,w=m.filter(c=>!$.has(c)).length;if(v===0&&w===0){l.push("All advisory IDs already present in pnpm-workspace.yaml.");break}let g=z(f);if(p.length>0){const c=` ignoreCves:
1
+ var re=Object.defineProperty;var U=(t,n)=>re(t,"name",{value:n,configurable:!0});import{t as z,E,e as q,q as _,a4 as ee,d as se,Q as oe,Z as ae,A as ce,p as a,J as le,N as de,a as ue,X as ge,a2 as W}from"./bin.js";import{M as G,i as H,$ as Q,B as X}from"../packem_shared/otel-CO8UEfTa.js";import{l as fe,f as pe,s as he}from"../packem_shared/dependency-scan-SQeRzrpJ.js";var ve=Object.defineProperty,S=U((t,n)=>ve(t,"name",{value:n,configurable:!0}),"o");const L=S(t=>Array.isArray(t)?t.filter(n=>typeof n=="string"):[],"toStringArray"),K=S((t,n)=>{for(const r of n)if(r===t||r.endsWith("*")&&t.startsWith(r.slice(0,-1)))return!0;return!1},"matchesGlobList"),te=S(t=>{const n=G(t,"pnpm-workspace.yaml");if(!H(n))return{excludedPackages:[],ignoredAdvisories:[]};try{const r=z(n);return{excludedPackages:[],ignoredAdvisories:[...L(r?.auditConfig?.ignoreCves),...L(r?.auditConfig?.ignoreGhsas)]}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readPnpmAuditExclusions"),ne=S(t=>{const n=G(t,".yarnrc.yml");if(!H(n))return{excludedPackages:[],ignoredAdvisories:[]};try{const r=z(n);return{excludedPackages:L(r?.npmAuditExcludePackages),ignoredAdvisories:L(r?.npmAuditIgnoreAdvisories)}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readYarnAuditExclusions"),$e=S((t,n)=>{switch(n){case"pnpm":return te(t);case"yarn":return ne(t);default:return{excludedPackages:[],ignoredAdvisories:[]}}},"readNativeAuditExclusions"),Z=S((t,n,r)=>{if(K(t,n.ignoredAdvisories))return!0;if(r){for(const l of r)if(K(l,n.ignoredAdvisories))return!0}return!1},"isAdvisoryExcluded"),me=S((t,n)=>K(t,n.excludedPackages),"isPackageExcluded"),ke=S((t,n,r)=>{if(r.length===0)return["No advisory IDs to sync."];const l=[];switch(t){case"bun":{l.push(`bun has no audit config file. Use CLI flags: bun audit ${r.map(f=>`--ignore ${f}`).join(" ")}`);break}case"npm":{l.push("npm has no native audit exclusion config. vis accepted risks are the only layer.");break}case"pnpm":{const f=G(n,"pnpm-workspace.yaml");if(!H(f)){l.push("pnpm-workspace.yaml not found. Cannot sync.");break}const h=te(n),k=new Set(h.ignoredAdvisories.filter(c=>c.startsWith("CVE-"))),$=new Set(h.ignoredAdvisories.filter(c=>c.startsWith("GHSA-"))),y=r.filter(c=>c.startsWith("CVE-")),m=r.filter(c=>c.startsWith("GHSA-")),p=[...new Set([...k,...y])],d=[...new Set([...$,...m])],v=y.filter(c=>!k.has(c)).length,w=m.filter(c=>!$.has(c)).length;if(v===0&&w===0){l.push("All advisory IDs already present in pnpm-workspace.yaml.");break}let g=Q(f);if(p.length>0){const c=` ignoreCves:
2
2
  ${p.map(x=>` - ${x}`).join(`
3
3
  `)}
4
4
  `;/auditConfig:/.test(g)?g=/ignoreCves:/.test(g)?g.replace(/ignoreCves:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,c):g.replace(/auditConfig:\s*\n/,`auditConfig:
@@ -8,16 +8,16 @@ auditConfig:
8
8
  ${c}`,v>0&&l.push(`Added ${String(v)} new CVE${v===1?"":"s"} to pnpm-workspace.yaml (${String(p.length)} total)`)}if(d.length>0){const c=` ignoreGhsas:
9
9
  ${d.map(x=>` - ${x}`).join(`
10
10
  `)}
11
- `;/auditConfig:/.test(g)&&(g=/ignoreGhsas:/.test(g)?g.replace(/ignoreGhsas:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,c):g.replace(/(auditConfig:[\s\S]*?)(\n\S|\n?$)/m,`$1${c}$2`)),w>0&&l.push(`Added ${String(w)} new GHSA${w===1?"":"s"} to pnpm-workspace.yaml (${String(d.length)} total)`)}B(f,g);break}case"yarn":{const f=H(n,".yarnrc.yml");if(!G(f)){l.push(".yarnrc.yml not found. Cannot sync.");break}const h=ne(n),k=new Set(h.ignoredAdvisories),$=[...new Set([...k,...r])],y=r.filter(d=>!k.has(d)).length;if(y===0){l.push("All advisory IDs already present in .yarnrc.yml.");break}let m=z(f);const p=`npmAuditIgnoreAdvisories:
11
+ `;/auditConfig:/.test(g)&&(g=/ignoreGhsas:/.test(g)?g.replace(/ignoreGhsas:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,c):g.replace(/(auditConfig:[\s\S]*?)(\n\S|\n?$)/m,`$1${c}$2`)),w>0&&l.push(`Added ${String(w)} new GHSA${w===1?"":"s"} to pnpm-workspace.yaml (${String(d.length)} total)`)}X(f,g);break}case"yarn":{const f=G(n,".yarnrc.yml");if(!H(f)){l.push(".yarnrc.yml not found. Cannot sync.");break}const h=ne(n),k=new Set(h.ignoredAdvisories),$=[...new Set([...k,...r])],y=r.filter(d=>!k.has(d)).length;if(y===0){l.push("All advisory IDs already present in .yarnrc.yml.");break}let m=Q(f);const p=`npmAuditIgnoreAdvisories:
12
12
  ${$.map(d=>` - "${d}"`).join(`
13
13
  `)}
14
14
  `;m=/npmAuditIgnoreAdvisories:/.test(m)?m.replace(/npmAuditIgnoreAdvisories:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,p):`${m.trimEnd()}
15
15
 
16
- ${p}`,B(f,m),l.push(`Synced ${String(y)} advisor${y===1?"y":"ies"} to .yarnrc.yml (${String($.length)} total)`);break}default:l.push(`Unknown package manager: ${t}`)}return l},"syncAcceptedRisksToNativeConfig");var ye=Object.defineProperty,R=U((t,n)=>ye(t,"name",{value:n,configurable:!0}),"m");const V={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},Ae={critical:ee,high:_,low:Z,medium:q},j=R((t,n)=>{const r=V[n.toUpperCase()]??V.MODERATE??2;return(V[t.toUpperCase()]??4)<=r},"severityPassesFilter"),Se={CRITICAL:ee,HIGH:_,LOW:Z,MODERATE:q,UNKNOWN:E},we=R((t,n,r,l)=>{const f=Se[r.severity]??E,h=l?` ${E("[acknowledged]")}`:"",k=r.fixedVersions??[],$=k.length>0?` (fix: ${k.join(", ")})`:"";return` ${f(r.severity)} ${r.id} — ${t}@${n}${h}
16
+ ${p}`,X(f,m),l.push(`Synced ${String(y)} advisor${y===1?"y":"ies"} to .yarnrc.yml (${String($.length)} total)`);break}default:l.push(`Unknown package manager: ${t}`)}return l},"syncAcceptedRisksToNativeConfig");var ye=Object.defineProperty,R=U((t,n)=>ye(t,"name",{value:n,configurable:!0}),"m");const V={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},Ae={critical:se,high:ee,low:_,medium:q},j=R((t,n)=>{const r=V[n.toUpperCase()]??V.MODERATE??2;return(V[t.toUpperCase()]??4)<=r},"severityPassesFilter"),Se={CRITICAL:se,HIGH:ee,LOW:_,MODERATE:q,UNKNOWN:E},we=R((t,n,r,l)=>{const f=Se[r.severity]??E,h=l?` ${E("[acknowledged]")}`:"",k=r.fixedVersions??[],$=k.length>0?` (fix: ${k.join(", ")})`:"";return` ${f(r.severity)} ${r.id} — ${t}@${n}${h}
17
17
  ${r.summary}${$}`},"formatVulnLine"),Ce=R((t,n)=>{const r=oe(t),l=`${String(Math.round(t.score.overall*100))}%`,f=n?` ${E("[acknowledged]")}`:"",h=t.alerts.length>0?`, ${String(t.alerts.length)} alert${t.alerts.length===1?"":"s"}`:"";return` ${l} ${r}@${t.version} (${ae(t.score.overall)}${h})${f}`},"formatSocketLine"),Re=R(async(t,n,r,l)=>{const f=n.severity??"low",h=n.format==="json"||!!n.json,k=!!n.fix,$=!!n.showAccepted,y=r?.security?.socket,m=y?.acceptedRisks,p=ce(t),d=$e(t,p.name);(d.ignoredAdvisories.length>0||d.excludedPackages.length>0)&&a.info(`Loaded ${String(d.ignoredAdvisories.length)} ignored advisor${d.ignoredAdvisories.length===1?"y":"ies"} and ${String(d.excludedPackages.length)} excluded package${d.excludedPackages.length===1?"":"s"} from ${p.name} config.`);const v=fe(t,p.name);if(v.length===0){a.info(`No ${p.name} lockfile entries found. Run ${p.name} install first.`);return}h||a.info(`Scanning ${String(v.length)} installed packages…`);const w=v.map(e=>({name:e.name,version:e.version})),g=le(y),c=pe(t,p.name),x=[{id:"vulnerabilities",label:"Known vulnerabilities (OSV)"},...g?[{id:"socket",label:"Socket.dev supply-chain reports"}]:[]],C=he(x,{live:!h}),ie=Date.now(),b=R(e=>{const s=Date.now()-e;return s>=1e3?`${(s/1e3).toFixed(1)}s`:`${String(Math.round(s))}ms`},"fmtElapsed");let J,Y;try{const e=Date.now(),s=Date.now();C.start("vulnerabilities"),g&&C.start("socket"),[J,Y]=await Promise.all([de(w).then(i=>{let o=0;for(const u of i.values())o+=u.length;return C.finish("vulnerabilities",o>0?"warn":"ok",o>0?`${String(o)} found · ${b(e)}`:`none found · ${b(e)}`),i}).catch(i=>{const o=i instanceof Error?i.message:String(i);return C.finish("vulnerabilities","error",o),new Map}),g?ue(w,g).then(i=>{let o=0,u=0;for(const D of i.values())o+=D.alerts.length,D.score.overall<W&&(u+=1);const O=o+u;return C.finish("socket",O>0?"warn":"ok",O>0?`${String(o)} alert${o===1?"":"s"}, ${String(u)} low-score · ${b(s)}`:`clean · ${b(s)}`),i}).catch(i=>{const o=i instanceof Error?i.message:String(i);return C.finish("socket","error",o),new Map}):Promise.resolve(new Map)])}finally{C.stop()}h||a.info(E(`Scan completed in ${b(ie)}`));const M=[];for(const e of v){if(me(e.name,d))continue;const s=J.get(e.name)??[],i=Y.get(`${e.name}@${e.version}`),o=ge(e.name,e.version,m),u=s.length>0,O=i?i.score.overall<W:!1,D=i?i.alerts.length>0:!1;(u||O||D)&&M.push({acceptedRisk:o,name:e.name,socketReport:i,version:e.version,vulnerabilities:s})}const A=M.filter(e=>{const s=e.vulnerabilities.some(u=>j(u.severity,f)),i=e.socketReport?.alerts.some(u=>j(u.severity==="medium"?"MODERATE":u.severity.toUpperCase(),f)),o=e.socketReport&&e.socketReport.score.overall<W;return s||i||o});if(h){const e={duplicates:c.map(s=>({name:s.name,versionCount:s.versions.length,versions:s.versions})),packages:v.length,results:A.map(s=>({acceptedRisk:s.acceptedRisk??null,name:s.name,socketAlerts:s.socketReport?.alerts??[],socketScore:s.socketReport?.score.overall??null,version:s.version,vulnerabilities:s.vulnerabilities})),summary:{accepted:A.filter(s=>s.acceptedRisk).length,duplicatePackages:c.length,issues:A.filter(s=>!s.acceptedRisk).length,total:A.length}};process.stdout.write(`${JSON.stringify(e,void 0,2)}
18
- `),n.exitCode&&e.summary.issues>0&&(process.exitCode=1);return}if(A.length===0){a.success(`No security issues found across ${String(v.length)} packages.`);return}const I={CRITICAL:[],HIGH:[],LOW:[],MODERATE:[]};for(const e of A)for(const s of e.vulnerabilities)if(j(s.severity,f)){const i=s.severity==="UNKNOWN"?"LOW":s.severity;I[i]?.push({entry:e,vuln:s})}let F=0,T=0;for(const e of["CRITICAL","HIGH","MODERATE","LOW"]){const s=I[e];if(!(!s||s.length===0)){a.info(`
19
- ── ${e} (${String(s.length)}) ──`);for(const{entry:i,vuln:o}of s){const u=!!i.acceptedRisk||X(o.id,d,o.aliases);u&&(T++,!$)||(F++,a.info(we(i.name,i.version,o,u)),k&&(o.fixedVersions??[]).length>0&&a.notice(` Fix: update to ${o.fixedVersions.at(-1)}`))}}}const P=A.filter(e=>e.socketReport&&(e.socketReport.score.overall<W||e.socketReport.alerts.length>0));if(P.length>0){a.info(`
18
+ `),n.exitCode&&e.summary.issues>0&&(process.exitCode=1);return}if(A.length===0){a.success(`No security issues found across ${String(v.length)} packages.`);return}const I={CRITICAL:[],HIGH:[],LOW:[],MODERATE:[]};for(const e of A)for(const s of e.vulnerabilities)if(j(s.severity,f)){const i=s.severity==="UNKNOWN"?"LOW":s.severity;I[i]?.push({entry:e,vuln:s})}let N=0,T=0;for(const e of["CRITICAL","HIGH","MODERATE","LOW"]){const s=I[e];if(!(!s||s.length===0)){a.info(`
19
+ ── ${e} (${String(s.length)}) ──`);for(const{entry:i,vuln:o}of s){const u=!!i.acceptedRisk||Z(o.id,d,o.aliases);u&&(T++,!$)||(N++,a.info(we(i.name,i.version,o,u)),k&&(o.fixedVersions??[]).length>0&&a.notice(` Fix: update to ${o.fixedVersions.at(-1)}`))}}}const P=A.filter(e=>e.socketReport&&(e.socketReport.score.overall<W||e.socketReport.alerts.length>0));if(P.length>0){a.info(`
20
20
  ── Socket.dev Supply Chain (${String(P.length)}) ──`);for(const e of P){if(!e.socketReport)continue;const s=!!e.acceptedRisk;if(!(s&&!$)){a.info(Ce(e.socketReport,s));for(const i of e.socketReport.alerts){const o=Ae[i.severity]??E;a.info(` ${o(`[${i.severity.toUpperCase()}]`)} ${i.type} — ${i.category}`)}}}}if(c.length>0){a.info(`
21
- ── Duplicate Dependencies (${String(c.length)}) ──`);for(const e of c){const s=e.versions.join(", ");a.info(` ${e.name} — ${String(e.versions.length)} versions: ${q(s)}`)}}const N=R(e=>!!e.acceptedRisk||e.vulnerabilities.length>0&&e.vulnerabilities.every(s=>X(s.id,d,s.aliases)),"isEntryExcluded"),Q=A.filter(e=>!N(e)).length;if(a.info(""),a.info("─ Audit Summary"),a.info(` ${String(v.length)} packages scanned`),d.ignoredAdvisories.length>0&&a.info(` ${String(d.ignoredAdvisories.length)} ${p.name} audit exclusion${d.ignoredAdvisories.length===1?"":"s"} applied`),F>0){const e=I.CRITICAL?.filter(i=>!N(i.entry)).length??0,s=I.HIGH?.filter(i=>!N(i.entry)).length??0;a.error(` ${String(F)} vulnerabilit${F===1?"y":"ies"} found`),e>0&&a.error(` ${String(e)} critical`),s>0&&a.warn(` ${String(s)} high`)}else a.success(" No vulnerabilities found");if(P.length>0){const e=P.filter(s=>!N(s)).length;a.warn(` ${String(e)} package${e===1?"":"s"} with Socket.dev supply chain issues`)}if(c.length>0&&(a.warn(` ${String(c.length)} package${c.length===1?"":"s"} with duplicate versions`),a.notice(" Run 'vis dedupe' or your package manager's dedupe command to reduce duplicates.")),T>0&&(a.info(` ${String(T)} acknowledged (accepted risks)`),$||a.notice(" Use --show-accepted to see acknowledged issues.")),Q===0&&a.success(`
21
+ ── Duplicate Dependencies (${String(c.length)}) ──`);for(const e of c){const s=e.versions.join(", ");a.info(` ${e.name} — ${String(e.versions.length)} versions: ${q(s)}`)}}const F=R(e=>!!e.acceptedRisk||e.vulnerabilities.length>0&&e.vulnerabilities.every(s=>Z(s.id,d,s.aliases)),"isEntryExcluded"),B=A.filter(e=>!F(e)).length;if(a.info(""),a.info("─ Audit Summary"),a.info(` ${String(v.length)} packages scanned`),d.ignoredAdvisories.length>0&&a.info(` ${String(d.ignoredAdvisories.length)} ${p.name} audit exclusion${d.ignoredAdvisories.length===1?"":"s"} applied`),N>0){const e=I.CRITICAL?.filter(i=>!F(i.entry)).length??0,s=I.HIGH?.filter(i=>!F(i.entry)).length??0;a.error(` ${String(N)} vulnerabilit${N===1?"y":"ies"} found`),e>0&&a.error(` ${String(e)} critical`),s>0&&a.warn(` ${String(s)} high`)}else a.success(" No vulnerabilities found");if(P.length>0){const e=P.filter(s=>!F(s)).length;a.warn(` ${String(e)} package${e===1?"":"s"} with Socket.dev supply chain issues`)}if(c.length>0&&(a.warn(` ${String(c.length)} package${c.length===1?"":"s"} with duplicate versions`),a.notice(" Run 'vis dedupe' or your package manager's dedupe command to reduce duplicates.")),T>0&&(a.info(` ${String(T)} acknowledged (accepted risks)`),$||a.notice(" Use --show-accepted to see acknowledged issues.")),B===0&&a.success(`
22
22
  All issues are acknowledged. No action required.`),n.sync&&m){const e=new Set;for(const i of M)if(i.acceptedRisk){for(const o of i.vulnerabilities)if((o.id.startsWith("CVE-")||o.id.startsWith("GHSA-"))&&e.add(o.id),o.aliases)for(const u of o.aliases)(u.startsWith("CVE-")||u.startsWith("GHSA-"))&&e.add(u)}const s=[...e];if(s.length>0){a.info("");const i=ke(p.name,t,s);for(const o of i)a.success(` ${o}`)}else a.info(`
23
- No advisory IDs to sync to native PM config.`)}n.exitCode&&Q>0&&(process.exitCode=1)},"executeAudit"),Ne=R(async({logger:t,options:n,visConfig:r,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");await Re(l,n,r,t)},"execute");export{Ne as default};
23
+ No advisory IDs to sync to native PM config.`)}n.exitCode&&B>0&&(process.exitCode=1)},"executeAudit"),Ie=R(async({logger:t,options:n,visConfig:r,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");await Re(l,n,r,t)},"execute");export{Ie as default};
@@ -1,4 +1,4 @@
1
- var C=Object.defineProperty;var h=(n,t)=>C(n,"name",{value:t,configurable:!0});import{U as T,R as U,T as x,S as b,z as j,_ as z,N as O,J as P,a as J}from"./bin.js";import{H as M,e as S,Z as q}from"../packem_shared/ai-analysis-Dzs_nUwM.js";var A=Object.defineProperty,F=h((n,t)=>A(n,"name",{value:t,configurable:!0}),"x");const H=/^[\^~>=<]+/,_=F(async({argument:n,logger:t,options:f,visConfig:u,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const p=n,e=p[0];if(!e)throw new Error("Package name is required. Usage: vis analyze <package> [version]");const w=p[1],{packageManager:R}=T(l);let o,d="default";const E=U(l,R);for(const[a,s]of E){const i=s.get(e);if(i){o=i,d=a;break}}if(!o)throw new Error(`Package "${e}" not found in any catalog or package.json. Make sure it exists in your workspace dependencies.`);let r;if(w)r=w;else{t.info(`Fetching latest version for ${e}...
1
+ var C=Object.defineProperty;var h=(n,t)=>C(n,"name",{value:t,configurable:!0});import{U as T,R as U,T as x,S as b,z as j,_ as z,N as O,J as P,a as J}from"./bin.js";import{H as M,e as S,Z as q}from"../packem_shared/ai-analysis-CGVjqwdc.js";var A=Object.defineProperty,F=h((n,t)=>A(n,"name",{value:t,configurable:!0}),"x");const H=/^[\^~>=<]+/,_=F(async({argument:n,logger:t,options:f,visConfig:u,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const p=n,e=p[0];if(!e)throw new Error("Package name is required. Usage: vis analyze <package> [version]");const w=p[1],{packageManager:R}=T(l);let o,d="default";const E=U(l,R);for(const[a,s]of E){const i=s.get(e);if(i){o=i,d=a;break}}if(!o)throw new Error(`Package "${e}" not found in any catalog or package.json. Make sure it exists in your workspace dependencies.`);let r;if(w)r=w;else{t.info(`Fetching latest version for ${e}...
2
2
  `);const a=await x(e);if(!a.latest)throw new Error(`Could not determine latest version for "${e}".`);r=a.latest}const m=b(o),k=b(r);if(!m||!k)throw new Error(`Could not parse versions: current="${o}", target="${r}".`);const v=j(m,k);if(v==="none"){t.info(`${e} is already at ${r}. Nothing to analyze.`);return}const N=z(o),g={catalogName:d,currentRange:o,newRange:`${N}${r}`,packageName:e,targetVersion:r,updateType:v},y=M(f.aiType??"impact");if(y==="security"||f.security){t.info(`Checking for known vulnerabilities...
3
3
  `);const a=o.replace(H,""),s=(await O([{name:e,version:a}])).get(e);s&&s.length>0&&(g.vulnerabilities=s);const i=P(u?.security?.socket);if(i){const c=(await J([{name:e,version:a}],i)).get(`${e}@${a}`);c&&(g.socketReport={alerts:c.alerts,license:c.license,score:c.score})}}const $=await S([g],t,u?.ai,y);(f.format??"table")==="json"?process.stdout.write(`${JSON.stringify($,void 0,2)}
4
4
  `):t.info(q($))},"execute");export{_ as default};
@@ -1,18 +1,18 @@
1
- var ee=Object.defineProperty;var E=(e,o)=>ee(e,"name",{value:o,configurable:!0});import{createRequire as te}from"node:module";import{isAccessibleSync as x}from"@visulima/fs";import{M as b,z as ie}from"../packem_shared/index-OlP7U_t5.js";import{Cache as I,parseCacheSize as ne,readLastRunSummary as U,getLastRunSummaryPath as ce,digestFile as W}from"@visulima/task-runner";import{B as he,J as z}from"../packem_shared/ai-cache-Dtvmbsru.js";import{m as le,E as J}from"../packem_shared/cache-directory-xASJia6M.js";import{p as n,a2 as ue,a3 as T}from"./bin.js";import{r as H,f as A,a as de,d as fe}from"../packem_shared/run-summary-utils-D39XBHWW.js";const oe=te(import.meta.url),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=E(e=>{if(typeof S<"u"&&S.versions&&S.versions.node){const[o,t]=S.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return S.getBuiltinModule(e)}return oe(e)},"__cjs_getBuiltinModule"),{readdir:P,stat:D,realpath:F,rm:j,mkdtemp:se}=O("node:fs/promises"),{tmpdir:re}=O("node:os"),{createInterface:ae}=O("node:readline");var me=Object.defineProperty,pe=E((e,o)=>me(e,"name",{value:o,configurable:!0}),"y"),ge=Object.defineProperty,ye=pe((e,o)=>ge(e,"name",{value:o,configurable:!0}),"y"),we=Object.defineProperty,B=ye((e,o)=>we(e,"name",{value:o,configurable:!0}),"i");const $e=/^(?<value>-?\d+(?:[.,]\d+)*) *(?<type>[a-z]+)?$/i,ke=/^KIBI/,ve=/^MIBI/,Se=/^GIBI/,xe=/^TEBI/,be=/^PEBI/,Ce=/^EXBI/,Ee=/^ZEBI/,Ie=/^YIBI/,De=/^(.)IB$/,Z={iec:[{long:"Bytes",short:"B"},{long:"Kibibytes",short:"KiB"},{long:"Mebibytes",short:"MiB"},{long:"Gibibytes",short:"GiB"},{long:"Tebibytes",short:"TiB"},{long:"Pebibytes",short:"PiB"},{long:"Exbibytes",short:"EiB"},{long:"Zebibytes",short:"ZiB"},{long:"Yobibytes",short:"YiB"}],iec_octet:[{long:"Octets",short:"o"},{long:"Kibioctets",short:"Kio"},{long:"Mebioctets",short:"Mio"},{long:"Gibioctets",short:"Gio"},{long:"Tebioctets",short:"Tio"},{long:"Pebioctets",short:"Pio"},{long:"Exbioctets",short:"Eio"},{long:"Zebioctets",short:"Zio"},{long:"Yobioctets",short:"Yio"}],metric:[{long:"Bytes",short:"Bytes"},{long:"Kilobytes",short:"KB"},{long:"Megabytes",short:"MB"},{long:"Gigabytes",short:"GB"},{long:"Terabytes",short:"TB"},{long:"Petabytes",short:"PB"},{long:"Exabytes",short:"EB"},{long:"Zettabytes",short:"ZB"},{long:"Yottabytes",short:"YB"}],metric_octet:[{long:"Octets",short:"o"},{long:"Kilo-octets",short:"ko"},{long:"Mega-octets",short:"Mo"},{long:"Giga-octets",short:"Go"},{long:"Tera-octets",short:"To"},{long:"Peta-octets",short:"Po"},{long:"Exa-octets",short:"Eo"},{long:"Zetta-octets",short:"Zo"},{long:"Yotta-octets",short:"Yo"}]},Be=B((e,o)=>{const t=new Intl.NumberFormat(o).format(11111).replaceAll(new RegExp("\\p{Number}","gu"),""),r=new Intl.NumberFormat(o).format(1.1).replaceAll(new RegExp("\\p{Number}","gu"),"");return Number.parseFloat(e.replaceAll(new RegExp(`\\${t}`,"g"),"").replace(new RegExp(`\\${r}`),"."))},"parseLocalizedNumber"),K=B(e=>{switch(e){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},"fromBase");B((e,o)=>{const t={base:2,locale:"en-US",units:"metric",...o};if(typeof e!="string"||e.length===0)throw new TypeError("Value is not a string or is empty.");if(e.length>100)throw new TypeError("Value exceeds the maximum length of 100 characters.");const r=$e.exec(e)?.groups;if(!r)return Number.NaN;const s=Be(r.value,t.locale),a=(r.type??"Bytes").toUpperCase().replace(ke,"KILO").replace(ve,"MEGA").replace(Se,"GIGA").replace(xe,"TERA").replace(be,"PETA").replace(Ce,"EXA").replace(Ee,"ZETTA").replace(Ie,"YOTTA").replace(De,"$1B"),i=Z[t.units].findIndex(m=>m.short[0].toUpperCase()===a[0]),h=K(t.base);return s*h**i},"parseBytes");const w=B((e,o)=>{if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("Bytesize is not a number.");const{base:t,decimals:r,locale:s,long:a,unit:i,units:h,...m}={base:2,decimals:0,locale:"en-US",long:!1,units:"metric",...o},d=K(t),c=Math.abs(e),l=o?.space??!0?" ":"",u=Z[h],p=u.findIndex(N=>N.short===i);if(e===0){const N=Math.min(0,Math.max(p,u.length-1));return"0"+l+u[N][a?"long":"short"]}const C=p===-1?Math.min(Math.floor(Math.log(c)/Math.log(d)),u.length-1):p,v=u[C][a?"long":"short"],M=e/d**C,L=r<0?void 0:r;return new Intl.NumberFormat(s,{maximumFractionDigits:L,minimumFractionDigits:L,...m}).format(M)+l+v},"formatBytes");var Me=Object.defineProperty,f=E((e,o)=>Me(e,"name",{value:o,configurable:!0}),"f");const V=f(async e=>{let o=0;try{const t=await P(e,{withFileTypes:!0});for(const r of t){const s=b(e,r.name);if(r.isDirectory())o+=await V(s);else if(r.isFile()){const a=await D(s);o+=a.size}}}catch{}return o},"sumDirectorySize"),$=f(async e=>{const o=[];let t;try{t=await P(e)}catch{return[]}for(const r of t){if(r.startsWith("."))continue;const s=b(e,r);try{const a=await D(s);if(!a.isDirectory())continue;const i=await V(s);o.push({hash:r,mtimeMs:a.mtimeMs,path:s,sizeBytes:i})}catch{}}return o.sort((r,s)=>s.mtimeMs-r.mtimeMs),o},"collectCacheEntries"),Ne=f((e,o=Date.now())=>{const t=Math.max(0,Math.floor((o-e)/1e3));return t<60?`${String(t)}s`:t<3600?`${String(Math.floor(t/60))}m`:t<86400?`${String(Math.floor(t/3600))}h`:`${String(Math.floor(t/86400))}d`},"formatAge"),Re=f(e=>new Promise(o=>{const t=ae({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const s=r.trim().toLowerCase();o(s==="y"||s==="yes")})}),"confirmPrompt"),ze=f(async(e,o,t)=>{if(!x(e)){if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
1
+ var ee=Object.defineProperty;var E=(e,o)=>ee(e,"name",{value:o,configurable:!0});import{createRequire as te}from"node:module";import{M as x,i as b,z as ie}from"../packem_shared/otel-CO8UEfTa.js";import{Cache as I,parseCacheSize as ne,readLastRunSummary as U,getLastRunSummaryPath as ce,digestFile as W}from"@visulima/task-runner";import{B as he,J as z}from"../packem_shared/ai-cache-BdPgSfg2.js";import{m as le,E as J}from"../packem_shared/cache-directory-DTfMSzT9.js";import{p as n,a5 as ue,a6 as T}from"./bin.js";import{r as H,f as O,a as de,d as fe}from"../packem_shared/run-summary-utils-BPraMTcm.js";const oe=te(import.meta.url),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=E(e=>{if(typeof S<"u"&&S.versions&&S.versions.node){const[o,t]=S.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return S.getBuiltinModule(e)}return oe(e)},"__cjs_getBuiltinModule"),{readdir:P,stat:D,realpath:F,rm:j,mkdtemp:se}=A("node:fs/promises"),{tmpdir:re}=A("node:os"),{createInterface:ae}=A("node:readline");var me=Object.defineProperty,pe=E((e,o)=>me(e,"name",{value:o,configurable:!0}),"y"),ge=Object.defineProperty,ye=pe((e,o)=>ge(e,"name",{value:o,configurable:!0}),"y"),we=Object.defineProperty,B=ye((e,o)=>we(e,"name",{value:o,configurable:!0}),"i");const $e=/^(?<value>-?\d+(?:[.,]\d+)*) *(?<type>[a-z]+)?$/i,ke=/^KIBI/,ve=/^MIBI/,Se=/^GIBI/,xe=/^TEBI/,be=/^PEBI/,Ce=/^EXBI/,Ee=/^ZEBI/,Ie=/^YIBI/,De=/^(.)IB$/,Z={iec:[{long:"Bytes",short:"B"},{long:"Kibibytes",short:"KiB"},{long:"Mebibytes",short:"MiB"},{long:"Gibibytes",short:"GiB"},{long:"Tebibytes",short:"TiB"},{long:"Pebibytes",short:"PiB"},{long:"Exbibytes",short:"EiB"},{long:"Zebibytes",short:"ZiB"},{long:"Yobibytes",short:"YiB"}],iec_octet:[{long:"Octets",short:"o"},{long:"Kibioctets",short:"Kio"},{long:"Mebioctets",short:"Mio"},{long:"Gibioctets",short:"Gio"},{long:"Tebioctets",short:"Tio"},{long:"Pebioctets",short:"Pio"},{long:"Exbioctets",short:"Eio"},{long:"Zebioctets",short:"Zio"},{long:"Yobioctets",short:"Yio"}],metric:[{long:"Bytes",short:"Bytes"},{long:"Kilobytes",short:"KB"},{long:"Megabytes",short:"MB"},{long:"Gigabytes",short:"GB"},{long:"Terabytes",short:"TB"},{long:"Petabytes",short:"PB"},{long:"Exabytes",short:"EB"},{long:"Zettabytes",short:"ZB"},{long:"Yottabytes",short:"YB"}],metric_octet:[{long:"Octets",short:"o"},{long:"Kilo-octets",short:"ko"},{long:"Mega-octets",short:"Mo"},{long:"Giga-octets",short:"Go"},{long:"Tera-octets",short:"To"},{long:"Peta-octets",short:"Po"},{long:"Exa-octets",short:"Eo"},{long:"Zetta-octets",short:"Zo"},{long:"Yotta-octets",short:"Yo"}]},Be=B((e,o)=>{const t=new Intl.NumberFormat(o).format(11111).replaceAll(new RegExp("\\p{Number}","gu"),""),r=new Intl.NumberFormat(o).format(1.1).replaceAll(new RegExp("\\p{Number}","gu"),"");return Number.parseFloat(e.replaceAll(new RegExp(`\\${t}`,"g"),"").replace(new RegExp(`\\${r}`),"."))},"parseLocalizedNumber"),K=B(e=>{switch(e){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},"fromBase");B((e,o)=>{const t={base:2,locale:"en-US",units:"metric",...o};if(typeof e!="string"||e.length===0)throw new TypeError("Value is not a string or is empty.");if(e.length>100)throw new TypeError("Value exceeds the maximum length of 100 characters.");const r=$e.exec(e)?.groups;if(!r)return Number.NaN;const s=Be(r.value,t.locale),a=(r.type??"Bytes").toUpperCase().replace(ke,"KILO").replace(ve,"MEGA").replace(Se,"GIGA").replace(xe,"TERA").replace(be,"PETA").replace(Ce,"EXA").replace(Ee,"ZETTA").replace(Ie,"YOTTA").replace(De,"$1B"),i=Z[t.units].findIndex(m=>m.short[0].toUpperCase()===a[0]),h=K(t.base);return s*h**i},"parseBytes");const w=B((e,o)=>{if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("Bytesize is not a number.");const{base:t,decimals:r,locale:s,long:a,unit:i,units:h,...m}={base:2,decimals:0,locale:"en-US",long:!1,units:"metric",...o},d=K(t),c=Math.abs(e),l=o?.space??!0?" ":"",u=Z[h],p=u.findIndex(N=>N.short===i);if(e===0){const N=Math.min(0,Math.max(p,u.length-1));return"0"+l+u[N][a?"long":"short"]}const C=p===-1?Math.min(Math.floor(Math.log(c)/Math.log(d)),u.length-1):p,v=u[C][a?"long":"short"],M=e/d**C,L=r<0?void 0:r;return new Intl.NumberFormat(s,{maximumFractionDigits:L,minimumFractionDigits:L,...m}).format(M)+l+v},"formatBytes");var Me=Object.defineProperty,f=E((e,o)=>Me(e,"name",{value:o,configurable:!0}),"f");const V=f(async e=>{let o=0;try{const t=await P(e,{withFileTypes:!0});for(const r of t){const s=x(e,r.name);if(r.isDirectory())o+=await V(s);else if(r.isFile()){const a=await D(s);o+=a.size}}}catch{}return o},"sumDirectorySize"),$=f(async e=>{const o=[];let t;try{t=await P(e)}catch{return[]}for(const r of t){if(r.startsWith("."))continue;const s=x(e,r);try{const a=await D(s);if(!a.isDirectory())continue;const i=await V(s);o.push({hash:r,mtimeMs:a.mtimeMs,path:s,sizeBytes:i})}catch{}}return o.sort((r,s)=>s.mtimeMs-r.mtimeMs),o},"collectCacheEntries"),Ne=f((e,o=Date.now())=>{const t=Math.max(0,Math.floor((o-e)/1e3));return t<60?`${String(t)}s`:t<3600?`${String(Math.floor(t/60))}m`:t<86400?`${String(Math.floor(t/3600))}h`:`${String(Math.floor(t/86400))}d`},"formatAge"),Re=f(e=>new Promise(o=>{const t=ae({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const s=r.trim().toLowerCase();o(s==="y"||s==="yes")})}),"confirmPrompt"),ze=f(async(e,o,t)=>{if(!b(e)){if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
2
2
  `);return}n.info(`No cache directory found at ${e}`);return}const r=await $(e);if(r.length===0){if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
3
3
  `);return}n.info(`Cache directory is empty: ${e}`);return}const s=r.reduce((c,l)=>c+l.sizeBytes,0);if(o==="json"){const c=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:r.map(l=>({ageMs:c-l.mtimeMs,hash:l.hash,mtimeIso:new Date(l.mtimeMs).toISOString(),sizeBytes:l.sizeBytes})),totalBytes:s,totalCount:r.length},void 0,2)}
4
- `);return}n.info(`Cache directory: ${e}`),n.info(`Entries: ${String(r.length)} (${w(s,{decimals:1,space:!1})})`),t.info("");const a=Date.now(),i=r.map(c=>({age:Ne(c.mtimeMs,a),hash:c.hash.slice(0,12),size:w(c.sizeBytes,{decimals:1,space:!1})})),h=Math.max(4,...i.map(c=>c.hash.length)),m=Math.max(4,...i.map(c=>c.size.length)),d=Math.max(3,...i.map(c=>c.age.length));t.info(` ${"hash".padEnd(h)} ${"size".padEnd(m)} ${"age".padEnd(d)}`),t.info(` ${"-".repeat(h)} ${"-".repeat(m)} ${"-".repeat(d)}`);for(const c of i)t.info(` ${c.hash.padEnd(h)} ${c.size.padEnd(m)} ${c.age.padEnd(d)}`)},"runList"),Te=f(()=>{try{const e=he();e>0&&n.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){n.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},"clearAiCacheSafe"),Ae=f(()=>{try{const e=ue();e>0&&n.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){n.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},"clearSocketCacheSafe"),Oe=f(async(e,o,t)=>{if(!x(e)){n.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const s=await $(e),a=s.reduce((i,h)=>i+h.sizeBytes,0);n.info(`Would remove ${String(s.length)} cache entr${s.length===1?"y":"ies"} (${w(a,{decimals:1,space:!1})}) from ${e}`);return}const r=le(e,o);try{const s=await F(e),a=await F(o);if(s===a){n.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(n.warn(`Cache directory is outside the workspace root: ${e}`),n.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){n.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await Re(" Continue?")){n.info("Aborted.");return}}r?await new I({cacheDirectory:e,workspaceRoot:o}).clear():await j(e,{force:!0,recursive:!0}),n.success(`Cleared cache: ${e}`)},"runClean"),Pe=f(async(e,o,t)=>{if(!x(e)){n.info(`No cache directory to prune at ${e}`);return}if(t.maxCacheAgeDays!==void 0&&(!Number.isFinite(t.maxCacheAgeDays)||t.maxCacheAgeDays<0)){n.error(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(t.maxCacheAgeDays)}`),process.exitCode=1;return}if(t.keepLast!==void 0&&(!Number.isFinite(t.keepLast)||t.keepLast<0||!Number.isInteger(t.keepLast))){n.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(t.keepLast)}`),process.exitCode=1;return}if(t.maxCacheSize!==void 0){let c;try{c=ne(t.maxCacheSize)}catch(l){n.error(`Invalid --max-size value: ${l instanceof Error?l.message:String(l)}`),process.exitCode=1;return}if(!Number.isFinite(c)||c<=0){n.error(`Invalid --max-size value: expected a positive size, got "${t.maxCacheSize}" (${String(c)} bytes)`),process.exitCode=1;return}}const r=t.maxCacheAgeDays===void 0?void 0:t.maxCacheAgeDays*24*60*60*1e3,s=await $(e),a=s.reduce((c,l)=>c+l.sizeBytes,0);if(t.keepLast!==void 0&&s.length>t.keepLast){const c=s.slice(t.keepLast);await Promise.all(c.map(l=>j(l.path,{force:!0,recursive:!0})))}await new I({cacheDirectory:e,maxCacheAge:r,maxCacheSize:t.maxCacheSize,workspaceRoot:o}).removeOldEntries();const i=await $(e),h=i.reduce((c,l)=>c+l.sizeBytes,0),m=s.length-i.length,d=a-h;if(m<=0){n.info("Nothing to prune — all entries are within the configured limits.");return}n.success(`Pruned ${String(m)} entr${m===1?"y":"ies"}, freed ${w(d,{decimals:1,space:!1})}.`)},"runPrune"),_=16,q=f(e=>e.length>_?`${e.slice(0,_)}…`:e,"truncateHash"),R=f((e,o,t)=>{const r=Object.entries(o??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([s],[a])=>s.localeCompare(a));for(const[s,a]of r)t.info(` ${s.padEnd(40)} ${q(a)}`)}},"renderHashDetailsBucket"),je=f(async(e,o,t)=>{const{format:r,runId:s,workspaceRoot:a}=o,i=s===void 0?await U(a):await H(a,s);if(!i){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:s??null,taskId:e},void 0,2)}
5
- `),process.exitCode=1;return}s===void 0?n.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):n.error(`Run summary "${s}" not found in .task-runner/runs/.`),process.exitCode=1;return}const h=A(i,e);if(!h){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:i.id,taskId:e},void 0,2)}
6
- `),process.exitCode=1;return}n.error(`Task "${e}" was not part of run ${i.id}.`),n.info(`Tasks in this run: ${i.tasks.map(l=>l.taskId).join(", ")||"(none)"}`),process.exitCode=1;return}const m=await de(a,i.id),d=m?A(m,e):void 0,c=fe(h.hashDetails,d?.hashDetails);if(r==="json"){process.stdout.write(`${JSON.stringify({diff:c,previousRunId:m?.id??null,previousTask:d?{cacheStatus:d.cacheStatus,hash:d.hash??null,hashDetails:d.hashDetails??null}:null,runId:i.id,task:{cacheStatus:h.cacheStatus,hash:h.hash??null,hashDetails:h.hashDetails??null,taskId:h.taskId}},void 0,2)}
4
+ `);return}n.info(`Cache directory: ${e}`),n.info(`Entries: ${String(r.length)} (${w(s,{decimals:1,space:!1})})`),t.info("");const a=Date.now(),i=r.map(c=>({age:Ne(c.mtimeMs,a),hash:c.hash.slice(0,12),size:w(c.sizeBytes,{decimals:1,space:!1})})),h=Math.max(4,...i.map(c=>c.hash.length)),m=Math.max(4,...i.map(c=>c.size.length)),d=Math.max(3,...i.map(c=>c.age.length));t.info(` ${"hash".padEnd(h)} ${"size".padEnd(m)} ${"age".padEnd(d)}`),t.info(` ${"-".repeat(h)} ${"-".repeat(m)} ${"-".repeat(d)}`);for(const c of i)t.info(` ${c.hash.padEnd(h)} ${c.size.padEnd(m)} ${c.age.padEnd(d)}`)},"runList"),Te=f(()=>{try{const e=he();e>0&&n.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){n.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},"clearAiCacheSafe"),Oe=f(()=>{try{const e=ue();e>0&&n.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){n.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},"clearSocketCacheSafe"),Ae=f(async(e,o,t)=>{if(!b(e)){n.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const s=await $(e),a=s.reduce((i,h)=>i+h.sizeBytes,0);n.info(`Would remove ${String(s.length)} cache entr${s.length===1?"y":"ies"} (${w(a,{decimals:1,space:!1})}) from ${e}`);return}const r=le(e,o);try{const s=await F(e),a=await F(o);if(s===a){n.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(n.warn(`Cache directory is outside the workspace root: ${e}`),n.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){n.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await Re(" Continue?")){n.info("Aborted.");return}}r?await new I({cacheDirectory:e,workspaceRoot:o}).clear():await j(e,{force:!0,recursive:!0}),n.success(`Cleared cache: ${e}`)},"runClean"),Pe=f(async(e,o,t)=>{if(!b(e)){n.info(`No cache directory to prune at ${e}`);return}if(t.maxCacheAgeDays!==void 0&&(!Number.isFinite(t.maxCacheAgeDays)||t.maxCacheAgeDays<0)){n.error(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(t.maxCacheAgeDays)}`),process.exitCode=1;return}if(t.keepLast!==void 0&&(!Number.isFinite(t.keepLast)||t.keepLast<0||!Number.isInteger(t.keepLast))){n.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(t.keepLast)}`),process.exitCode=1;return}if(t.maxCacheSize!==void 0){let c;try{c=ne(t.maxCacheSize)}catch(l){n.error(`Invalid --max-size value: ${l instanceof Error?l.message:String(l)}`),process.exitCode=1;return}if(!Number.isFinite(c)||c<=0){n.error(`Invalid --max-size value: expected a positive size, got "${t.maxCacheSize}" (${String(c)} bytes)`),process.exitCode=1;return}}const r=t.maxCacheAgeDays===void 0?void 0:t.maxCacheAgeDays*24*60*60*1e3,s=await $(e),a=s.reduce((c,l)=>c+l.sizeBytes,0);if(t.keepLast!==void 0&&s.length>t.keepLast){const c=s.slice(t.keepLast);await Promise.all(c.map(l=>j(l.path,{force:!0,recursive:!0})))}await new I({cacheDirectory:e,maxCacheAge:r,maxCacheSize:t.maxCacheSize,workspaceRoot:o}).removeOldEntries();const i=await $(e),h=i.reduce((c,l)=>c+l.sizeBytes,0),m=s.length-i.length,d=a-h;if(m<=0){n.info("Nothing to prune — all entries are within the configured limits.");return}n.success(`Pruned ${String(m)} entr${m===1?"y":"ies"}, freed ${w(d,{decimals:1,space:!1})}.`)},"runPrune"),_=16,q=f(e=>e.length>_?`${e.slice(0,_)}…`:e,"truncateHash"),R=f((e,o,t)=>{const r=Object.entries(o??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([s],[a])=>s.localeCompare(a));for(const[s,a]of r)t.info(` ${s.padEnd(40)} ${q(a)}`)}},"renderHashDetailsBucket"),je=f(async(e,o,t)=>{const{format:r,runId:s,workspaceRoot:a}=o,i=s===void 0?await U(a):await H(a,s);if(!i){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:s??null,taskId:e},void 0,2)}
5
+ `),process.exitCode=1;return}s===void 0?n.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):n.error(`Run summary "${s}" not found in .task-runner/runs/.`),process.exitCode=1;return}const h=O(i,e);if(!h){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:i.id,taskId:e},void 0,2)}
6
+ `),process.exitCode=1;return}n.error(`Task "${e}" was not part of run ${i.id}.`),n.info(`Tasks in this run: ${i.tasks.map(l=>l.taskId).join(", ")||"(none)"}`),process.exitCode=1;return}const m=await de(a,i.id),d=m?O(m,e):void 0,c=fe(h.hashDetails,d?.hashDetails);if(r==="json"){process.stdout.write(`${JSON.stringify({diff:c,previousRunId:m?.id??null,previousTask:d?{cacheStatus:d.cacheStatus,hash:d.hash??null,hashDetails:d.hashDetails??null}:null,runId:i.id,task:{cacheStatus:h.cacheStatus,hash:h.hash??null,hashDetails:h.hashDetails??null,taskId:h.taskId}},void 0,2)}
7
7
  `);return}if(n.info(`Why ${e}? (run ${i.id})`),t.info(""),t.info(` status: ${h.cacheStatus}`),t.info(` hash: ${h.hash??"(none)"}`),d?t.info(` prev: ${d.hash??"(none)"} [run ${m?.id??"?"}]`):t.info(" prev: (no prior run found)"),t.info(""),!d){n.info("No previous run to diff against — first time this task was recorded.");return}if(!c.commandChanged&&c.nodes.added.length===0&&c.nodes.changed.length===0&&c.nodes.removed.length===0&&c.runtime.added.length===0&&c.runtime.changed.length===0&&c.runtime.removed.length===0&&c.implicitDeps.added.length===0&&c.implicitDeps.changed.length===0&&c.implicitDeps.removed.length===0){n.success("No hash inputs changed since the previous run.");return}t.info("Hash inputs that changed since the previous run:"),t.info(""),c.commandChanged&&t.info(" command: changed");for(const l of["nodes","runtime","implicitDeps"]){const u=c[l];if(!(u.added.length===0&&u.changed.length===0&&u.removed.length===0)){t.info(` ${l}:`);for(const p of u.added)t.info(` + ${p}`);for(const p of u.changed)t.info(` ~ ${p}`);for(const p of u.removed)t.info(` - ${p}`)}}t.info(""),n.info(`Last summary file: ${ce(a)}`)},"runWhy"),Le=f(async(e,o,t)=>{const{format:r,runId:s,workspaceRoot:a}=o,i=s===void 0?await U(a):await H(a,s);if(!i){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:s??null,taskId:e},void 0,2)}
8
- `),process.exitCode=1;return}s===void 0?n.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):n.error(`Run summary "${s}" not found in .task-runner/runs/.`),process.exitCode=1;return}const h=A(i,e);if(!h){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:i.id,taskId:e},void 0,2)}
8
+ `),process.exitCode=1;return}s===void 0?n.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):n.error(`Run summary "${s}" not found in .task-runner/runs/.`),process.exitCode=1;return}const h=O(i,e);if(!h){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:i.id,taskId:e},void 0,2)}
9
9
  `),process.exitCode=1;return}n.error(`Task "${e}" was not part of run ${i.id}.`),process.exitCode=1;return}if(r==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:h.cacheStatus,hash:h.hash??null,hashDetails:h.hashDetails??null,runId:i.id,taskId:h.taskId},void 0,2)}
10
- `);return}n.info(`Hash for ${e} (run ${i.id})`),t.info(""),t.info(` status: ${h.cacheStatus}`),t.info(` hash: ${h.hash??"(none)"}`),h.hashDetails?(t.info(""),t.info(` command: ${q(h.hashDetails.command)}`),R("nodes",h.hashDetails.nodes,t),R("runtime",h.hashDetails.runtime,t),R("implicitDeps",h.hashDetails.implicitDeps,t)):(t.info(""),n.info("No hash details recorded for this task."))},"runHash"),Fe=f(async(e,o)=>{if(!x(e)){if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
10
+ `);return}n.info(`Hash for ${e} (run ${i.id})`),t.info(""),t.info(` status: ${h.cacheStatus}`),t.info(` hash: ${h.hash??"(none)"}`),h.hashDetails?(t.info(""),t.info(` command: ${q(h.hashDetails.command)}`),R("nodes",h.hashDetails.nodes,t),R("runtime",h.hashDetails.runtime,t),R("implicitDeps",h.hashDetails.implicitDeps,t)):(t.info(""),n.info("No hash details recorded for this task."))},"runHash"),Fe=f(async(e,o)=>{if(!b(e)){if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
11
11
  `);return}n.info(`No cache directory at ${e}`);return}const t=await $(e),r=t.reduce((s,a)=>s+a.sizeBytes,0);if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:r,totalCount:t.length})}
12
- `);return}n.info(`Cache directory: ${e}`),n.info(`Entries: ${String(t.length)}`),n.info(`Total size: ${w(r,{decimals:1,space:!1})}`)},"runSize"),Je=f(async e=>{const o=[],t=f(async r=>{const s=(await P(r,{withFileTypes:!0})).toSorted((a,i)=>a.name.localeCompare(i.name));for(const a of s){const i=b(r,a.name);if(a.isDirectory()){await t(i);continue}if(!a.isFile())continue;const[h,m]=await Promise.all([D(i),W(i)]);o.push({hash:m?.hash??"",mode:h.mode&4095,mtimeMs:h.mtimeMs,relativePath:ie(e,i).replaceAll("\\","/"),sizeBytes:h.size})}},"walk");return await t(e),o},"walkAndDigest"),_e=f((e,o)=>Math.floor(e/1e3)===Math.floor(o/1e3),"compareSecondsTruncated"),G=16,Ge=f(async(e,o)=>{const t=b(o,e.relativePath),r=await D(t).catch(()=>{});if(!r)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const s=await W(t),a=[];(s?.hash??"")!==e.hash&&a.push("content");const i=r.mode&4095;if(process.platform!=="win32"&&i!==e.mode&&a.push("mode"),_e(r.mtimeMs,e.mtimeMs)||a.push("mtime"),a.length!==0)return{actual:{hash:s?.hash,mode:i,mtimeMs:r.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:a,relativePath:e.relativePath}},"computeFileDiff"),Ye=f(async(e,o,t)=>{const{cacheDirectories:r,format:s,workspaceRoot:a}=o;if(r.length===0){s==="json"?process.stdout.write(`${JSON.stringify({error:"no-cache-directory",taskId:e},void 0,2)}
12
+ `);return}n.info(`Cache directory: ${e}`),n.info(`Entries: ${String(t.length)}`),n.info(`Total size: ${w(r,{decimals:1,space:!1})}`)},"runSize"),Je=f(async e=>{const o=[],t=f(async r=>{const s=(await P(r,{withFileTypes:!0})).toSorted((a,i)=>a.name.localeCompare(i.name));for(const a of s){const i=x(r,a.name);if(a.isDirectory()){await t(i);continue}if(!a.isFile())continue;const[h,m]=await Promise.all([D(i),W(i)]);o.push({hash:m?.hash??"",mode:h.mode&4095,mtimeMs:h.mtimeMs,relativePath:ie(e,i).replaceAll("\\","/"),sizeBytes:h.size})}},"walk");return await t(e),o},"walkAndDigest"),_e=f((e,o)=>Math.floor(e/1e3)===Math.floor(o/1e3),"compareSecondsTruncated"),G=16,Ge=f(async(e,o)=>{const t=x(o,e.relativePath),r=await D(t).catch(()=>{});if(!r)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const s=await W(t),a=[];(s?.hash??"")!==e.hash&&a.push("content");const i=r.mode&4095;if(process.platform!=="win32"&&i!==e.mode&&a.push("mode"),_e(r.mtimeMs,e.mtimeMs)||a.push("mtime"),a.length!==0)return{actual:{hash:s?.hash,mode:i,mtimeMs:r.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:a,relativePath:e.relativePath}},"computeFileDiff"),Ye=f(async(e,o,t)=>{const{cacheDirectories:r,format:s,workspaceRoot:a}=o;if(r.length===0){s==="json"?process.stdout.write(`${JSON.stringify({error:"no-cache-directory",taskId:e},void 0,2)}
13
13
  `):n.error("No cache directory resolved — pass --cache-dir or run inside a workspace."),process.exitCode=1;return}let i,h;for(const d of r){const c=await new I({cacheDirectory:d,workspaceRoot:a}).getByTaskId(e);if(c){i=d,h=c;break}}if(!h||!i){s==="json"?process.stdout.write(`${JSON.stringify({error:"no-cached-entry",searchedCaches:r,taskId:e},void 0,2)}
14
- `):n.error(`No cached entry found for task "${e}". Run it once before verifying.`),process.exitCode=1;return}const m=await se(b(re(),"vis-cache-verify-"));try{if(!await new I({cacheDirectory:i,workspaceRoot:m}).restoreOutputs(h.hash)){s==="json"?process.stdout.write(`${JSON.stringify({error:"restore-failed",hash:h.hash,taskId:e},void 0,2)}
14
+ `):n.error(`No cached entry found for task "${e}". Run it once before verifying.`),process.exitCode=1;return}const m=await se(x(re(),"vis-cache-verify-"));try{if(!await new I({cacheDirectory:i,workspaceRoot:m}).restoreOutputs(h.hash)){s==="json"?process.stdout.write(`${JSON.stringify({error:"restore-failed",hash:h.hash,taskId:e},void 0,2)}
15
15
  `):n.error(`Cache restore failed for ${e} (hash ${h.hash}).`),process.exitCode=1;return}const d=await Je(m);if(d.length===0){s==="json"?process.stdout.write(`${JSON.stringify({diffs:[],hash:h.hash,status:"no-outputs",taskId:e},void 0,2)}
16
16
  `):n.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const c=Array.from({length:d.length});for(let u=0;u<d.length;u+=G){const p=d.slice(u,u+G),C=await Promise.all(p.map(async v=>Ge(v,a)));for(const[v,M]of C.entries())c[u+v]=M}const l=c.filter(u=>u!==void 0);if(s==="json"){process.stdout.write(`${JSON.stringify({cachedFileCount:d.length,cacheDirectory:i,diffs:l,hash:h.hash,status:l.length===0?"ok":"drift",taskId:e},void 0,2)}
17
- `),l.length>0&&(process.exitCode=1);return}if(n.info(`Verify ${e} (hash ${h.hash})`),t.info(""),t.info(` cache: ${i}`),t.info(` files: ${String(d.length)}`),l.length===0){t.info(""),n.success("Cache restore is faithful — all files match content, mode, and mtime.");return}t.info(` drift: ${String(l.length)} file(s)`),t.info("");for(const u of l){const p=u.issues.includes("missing")?"MISSING":u.issues.join(",").toUpperCase();t.info(` [${p}] ${u.relativePath}`),!u.issues.includes("missing")&&u.expected&&u.actual&&(u.issues.includes("content")&&(t.info(` expected hash: ${u.expected.hash||"(none)"}`),t.info(` actual hash: ${u.actual.hash??"(unreadable)"}`)),u.issues.includes("mode")&&(t.info(` expected mode: ${u.expected.mode.toString(8)}`),t.info(` actual mode: ${(u.actual.mode??0).toString(8)}`)),u.issues.includes("mtime")&&(t.info(` expected mtime: ${new Date(u.expected.mtimeMs).toISOString()}`),t.info(` actual mtime: ${u.actual.mtimeMs===void 0?"(unreadable)":new Date(u.actual.mtimeMs).toISOString()}`)))}process.exitCode=1}finally{await j(m,{force:!0,recursive:!0}).catch(()=>{})}},"runVerify"),X=f(e=>e==="task"||e==="ai"||e==="socket"||e==="all"?e:(e&&e.length>0&&n.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),"parseCacheTarget"),g=f((e,o)=>e==="all"||e===o,"includesTarget"),y=f(e=>e===void 0?null:new Date(e).toISOString(),"isoOrNull"),Y=f((e,o)=>{n.info(`${e}:`),n.info(` Entries: ${String(o.entries)}`),n.info(` Total size: ${w(o.totalSizeBytes,{decimals:1,space:!1})}`),n.info(` Oldest: ${o.oldestEntry?new Date(o.oldestEntry).toISOString():"N/A"}`),n.info(` Newest: ${o.newestEntry?new Date(o.newestEntry).toISOString():"N/A"}`)},"printAuxStatsBlock"),Ue=f(e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&n.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),"parseScope"),k=f((e,o,t)=>{const r=e??process.cwd(),s=t??{},a=s.taskRunnerOptions??{},i=Ue(o.scope),h=o.cacheDir,m=J(r,h,a.cacheDirectory,!1),d=J(r,h,a.cacheDirectory,s.sharedWorktreeCache);let c,l;switch(i){case"all":{c=d,l=d===m?[d]:[d,m];break}case"worktree":{c=m,l=[m];break}default:c=d,l=[d]}return{cacheDirectories:l,cacheDirectory:c,scope:i,sharedWorktreeCache:s.sharedWorktreeCache,workspaceRoot:r}},"resolveCacheDirectoryFromContext"),tt=f(async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const{cacheDirectories:s}=k(r,o,t),a=o.format??"table";for(const i of s)s.length>1&&n.info(`# ${i}`),await ze(i,a,e)},"cacheListExecute"),ot=f(async({options:e,visConfig:o,workspaceRoot:t})=>{const r=X(e.type),s=!!e.dryRun;if(g(r,"task")){const{cacheDirectory:a,workspaceRoot:i}=k(t,e,o);await Oe(a,i,{dryRun:s,force:!!e.force})}if(g(r,"ai"))if(s){const a=z();n.info(`Would clear ${String(a.entries)} cached AI response${a.entries===1?"":"s"}.`)}else Te();if(g(r,"socket"))if(s){const a=T();n.info(`Would clear ${String(a.entries)} cached Socket.dev report${a.entries===1?"":"s"}.`)}else Ae()},"cacheCleanExecute"),st=f(async({options:e,visConfig:o,workspaceRoot:t})=>{const{cacheDirectories:r,workspaceRoot:s}=k(t,e,o);for(const a of r)r.length>1&&n.info(`# ${a}`),await Pe(a,s,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},"cachePruneExecute"),Q=f(e=>e??process.cwd(),"resolveWorkspaceRoot"),rt=f(async({argument:e,logger:o,options:t,workspaceRoot:r})=>{const s=e[0];if(!s){n.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await je(s,{format:t.format??"table",runId:t.run,workspaceRoot:Q(r)},o)},"cacheWhyExecute"),at=f(async({argument:e,logger:o,options:t,workspaceRoot:r})=>{const s=e[0];if(!s){n.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}await Le(s,{format:t.format??"table",runId:t.run,workspaceRoot:Q(r)},o)},"cacheHashExecute"),it=f(async({options:e,visConfig:o,workspaceRoot:t})=>{const r=X(e.type);if((e.format??"table")==="json"){const s={};if(g(r,"task")){const{cacheDirectories:a}=k(t,e,o);s.task=await Promise.all(a.map(async i=>{const h=x(i),m=h?await $(i):[],d=m.reduce((c,l)=>c+l.sizeBytes,0);return{directory:i,entries:m.length,exists:h,newestEntry:y(m[0]?.mtimeMs),oldestEntry:y(m.at(-1)?.mtimeMs),totalBytes:d}}))}if(g(r,"ai")){const a=z();s.ai={entries:a.entries,newestEntry:y(a.newestEntry),oldestEntry:y(a.oldestEntry),totalBytes:a.totalSizeBytes}}if(g(r,"socket")){const a=T();s.socket={entries:a.entries,newestEntry:y(a.newestEntry),oldestEntry:y(a.oldestEntry),totalBytes:a.totalSizeBytes}}process.stdout.write(`${JSON.stringify(s,void 0,2)}
18
- `);return}if(g(r,"task")){const{cacheDirectories:s}=k(t,e,o);for(const a of s)s.length>1&&n.info(`# ${a}`),await Fe(a,"table")}g(r,"ai")&&Y("AI response cache",z()),g(r,"socket")&&Y("Socket.dev report cache",T())},"cacheSizeExecute"),nt=f(async({argument:e,logger:o,options:t,visConfig:r,workspaceRoot:s})=>{const a=e[0];if(!a){n.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{cacheDirectories:i,workspaceRoot:h}=k(s,t,r);await Ye(a,{cacheDirectories:i,format:t.format??"table",workspaceRoot:h},o)},"cacheVerifyExecute");export{ot as cacheCleanExecute,at as cacheHashExecute,tt as cacheListExecute,st as cachePruneExecute,it as cacheSizeExecute,nt as cacheVerifyExecute,rt as cacheWhyExecute,Te as clearAiCacheSafe,Ae as clearSocketCacheSafe,$ as collectCacheEntries,Ne as formatAge,Oe as runClean,Le as runHash,ze as runList,Pe as runPrune,Fe as runSize,Ye as runVerify,je as runWhy};
17
+ `),l.length>0&&(process.exitCode=1);return}if(n.info(`Verify ${e} (hash ${h.hash})`),t.info(""),t.info(` cache: ${i}`),t.info(` files: ${String(d.length)}`),l.length===0){t.info(""),n.success("Cache restore is faithful — all files match content, mode, and mtime.");return}t.info(` drift: ${String(l.length)} file(s)`),t.info("");for(const u of l){const p=u.issues.includes("missing")?"MISSING":u.issues.join(",").toUpperCase();t.info(` [${p}] ${u.relativePath}`),!u.issues.includes("missing")&&u.expected&&u.actual&&(u.issues.includes("content")&&(t.info(` expected hash: ${u.expected.hash||"(none)"}`),t.info(` actual hash: ${u.actual.hash??"(unreadable)"}`)),u.issues.includes("mode")&&(t.info(` expected mode: ${u.expected.mode.toString(8)}`),t.info(` actual mode: ${(u.actual.mode??0).toString(8)}`)),u.issues.includes("mtime")&&(t.info(` expected mtime: ${new Date(u.expected.mtimeMs).toISOString()}`),t.info(` actual mtime: ${u.actual.mtimeMs===void 0?"(unreadable)":new Date(u.actual.mtimeMs).toISOString()}`)))}process.exitCode=1}finally{await j(m,{force:!0,recursive:!0}).catch(()=>{})}},"runVerify"),X=f(e=>e==="task"||e==="ai"||e==="socket"||e==="all"?e:(e&&e.length>0&&n.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),"parseCacheTarget"),g=f((e,o)=>e==="all"||e===o,"includesTarget"),y=f(e=>e===void 0?null:new Date(e).toISOString(),"isoOrNull"),Y=f((e,o)=>{n.info(`${e}:`),n.info(` Entries: ${String(o.entries)}`),n.info(` Total size: ${w(o.totalSizeBytes,{decimals:1,space:!1})}`),n.info(` Oldest: ${o.oldestEntry?new Date(o.oldestEntry).toISOString():"N/A"}`),n.info(` Newest: ${o.newestEntry?new Date(o.newestEntry).toISOString():"N/A"}`)},"printAuxStatsBlock"),Ue=f(e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&n.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),"parseScope"),k=f((e,o,t)=>{const r=e??process.cwd(),s=t??{},a=s.taskRunnerOptions??{},i=Ue(o.scope),h=o.cacheDir,m=J(r,h,a.cacheDirectory,!1),d=J(r,h,a.cacheDirectory,s.sharedWorktreeCache);let c,l;switch(i){case"all":{c=d,l=d===m?[d]:[d,m];break}case"worktree":{c=m,l=[m];break}default:c=d,l=[d]}return{cacheDirectories:l,cacheDirectory:c,scope:i,sharedWorktreeCache:s.sharedWorktreeCache,workspaceRoot:r}},"resolveCacheDirectoryFromContext"),et=f(async({logger:e,options:o,visConfig:t,workspaceRoot:r})=>{const{cacheDirectories:s}=k(r,o,t),a=o.format??"table";for(const i of s)s.length>1&&n.info(`# ${i}`),await ze(i,a,e)},"cacheListExecute"),tt=f(async({options:e,visConfig:o,workspaceRoot:t})=>{const r=X(e.type),s=!!e.dryRun;if(g(r,"task")){const{cacheDirectory:a,workspaceRoot:i}=k(t,e,o);await Ae(a,i,{dryRun:s,force:!!e.force})}if(g(r,"ai"))if(s){const a=z();n.info(`Would clear ${String(a.entries)} cached AI response${a.entries===1?"":"s"}.`)}else Te();if(g(r,"socket"))if(s){const a=T();n.info(`Would clear ${String(a.entries)} cached Socket.dev report${a.entries===1?"":"s"}.`)}else Oe()},"cacheCleanExecute"),ot=f(async({options:e,visConfig:o,workspaceRoot:t})=>{const{cacheDirectories:r,workspaceRoot:s}=k(t,e,o);for(const a of r)r.length>1&&n.info(`# ${a}`),await Pe(a,s,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},"cachePruneExecute"),Q=f(e=>e??process.cwd(),"resolveWorkspaceRoot"),st=f(async({argument:e,logger:o,options:t,workspaceRoot:r})=>{const s=e[0];if(!s){n.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await je(s,{format:t.format??"table",runId:t.run,workspaceRoot:Q(r)},o)},"cacheWhyExecute"),rt=f(async({argument:e,logger:o,options:t,workspaceRoot:r})=>{const s=e[0];if(!s){n.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}await Le(s,{format:t.format??"table",runId:t.run,workspaceRoot:Q(r)},o)},"cacheHashExecute"),at=f(async({options:e,visConfig:o,workspaceRoot:t})=>{const r=X(e.type);if((e.format??"table")==="json"){const s={};if(g(r,"task")){const{cacheDirectories:a}=k(t,e,o);s.task=await Promise.all(a.map(async i=>{const h=b(i),m=h?await $(i):[],d=m.reduce((c,l)=>c+l.sizeBytes,0);return{directory:i,entries:m.length,exists:h,newestEntry:y(m[0]?.mtimeMs),oldestEntry:y(m.at(-1)?.mtimeMs),totalBytes:d}}))}if(g(r,"ai")){const a=z();s.ai={entries:a.entries,newestEntry:y(a.newestEntry),oldestEntry:y(a.oldestEntry),totalBytes:a.totalSizeBytes}}if(g(r,"socket")){const a=T();s.socket={entries:a.entries,newestEntry:y(a.newestEntry),oldestEntry:y(a.oldestEntry),totalBytes:a.totalSizeBytes}}process.stdout.write(`${JSON.stringify(s,void 0,2)}
18
+ `);return}if(g(r,"task")){const{cacheDirectories:s}=k(t,e,o);for(const a of s)s.length>1&&n.info(`# ${a}`),await Fe(a,"table")}g(r,"ai")&&Y("AI response cache",z()),g(r,"socket")&&Y("Socket.dev report cache",T())},"cacheSizeExecute"),it=f(async({argument:e,logger:o,options:t,visConfig:r,workspaceRoot:s})=>{const a=e[0];if(!a){n.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{cacheDirectories:i,workspaceRoot:h}=k(s,t,r);await Ye(a,{cacheDirectories:i,format:t.format??"table",workspaceRoot:h},o)},"cacheVerifyExecute");export{tt as cacheCleanExecute,rt as cacheHashExecute,et as cacheListExecute,ot as cachePruneExecute,at as cacheSizeExecute,it as cacheVerifyExecute,st as cacheWhyExecute,Te as clearAiCacheSafe,Oe as clearSocketCacheSafe,$ as collectCacheEntries,Ne as formatAge,Ae as runClean,Le as runHash,ze as runList,Pe as runPrune,Fe as runSize,Ye as runVerify,je as runWhy};