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

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 (101) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE.md +44 -233
  3. package/dist/bin.js +1 -1
  4. package/dist/config/index.d.ts +121 -94
  5. package/dist/config/index.js +1 -1
  6. package/dist/packem_chunks/bin.js +271 -271
  7. package/dist/packem_chunks/config.js +18 -0
  8. package/dist/packem_chunks/fix.js +1 -1
  9. package/dist/packem_chunks/handler.js +1 -1
  10. package/dist/packem_chunks/handler10.js +1 -1
  11. package/dist/packem_chunks/handler11.js +1 -1
  12. package/dist/packem_chunks/handler12.js +1 -1
  13. package/dist/packem_chunks/handler13.js +1 -1
  14. package/dist/packem_chunks/handler14.js +4 -4
  15. package/dist/packem_chunks/handler15.js +1 -1
  16. package/dist/packem_chunks/handler16.js +1 -1
  17. package/dist/packem_chunks/handler17.js +1 -1
  18. package/dist/packem_chunks/handler18.js +1 -1
  19. package/dist/packem_chunks/handler19.js +5 -5
  20. package/dist/packem_chunks/handler2.js +1 -1
  21. package/dist/packem_chunks/handler20.js +2 -1
  22. package/dist/packem_chunks/handler21.js +18 -1
  23. package/dist/packem_chunks/handler22.js +1 -5
  24. package/dist/packem_chunks/handler23.js +1 -1
  25. package/dist/packem_chunks/handler24.js +5 -3
  26. package/dist/packem_chunks/handler25.js +1 -1
  27. package/dist/packem_chunks/handler26.js +3 -1
  28. package/dist/packem_chunks/handler27.js +1 -7
  29. package/dist/packem_chunks/handler28.js +1 -23
  30. package/dist/packem_chunks/handler29.js +7 -3
  31. package/dist/packem_chunks/handler3.js +1 -1
  32. package/dist/packem_chunks/handler30.js +23 -18
  33. package/dist/packem_chunks/handler31.js +3 -1
  34. package/dist/packem_chunks/handler32.js +1 -2
  35. package/dist/packem_chunks/handler33.js +2 -25
  36. package/dist/packem_chunks/handler34.js +25 -2
  37. package/dist/packem_chunks/handler35.js +2 -2
  38. package/dist/packem_chunks/handler36.js +8 -8
  39. package/dist/packem_chunks/handler37.js +3 -3
  40. package/dist/packem_chunks/handler38.js +4 -4
  41. package/dist/packem_chunks/handler39.js +6 -6
  42. package/dist/packem_chunks/handler40.js +5 -5
  43. package/dist/packem_chunks/handler41.js +9 -9
  44. package/dist/packem_chunks/handler42.js +10 -10
  45. package/dist/packem_chunks/handler43.js +1 -1
  46. package/dist/packem_chunks/handler44.js +5 -5
  47. package/dist/packem_chunks/handler45.js +3 -3
  48. package/dist/packem_chunks/handler46.js +9 -9
  49. package/dist/packem_chunks/handler47.js +161 -36
  50. package/dist/packem_chunks/handler48.js +1 -1
  51. package/dist/packem_chunks/handler5.js +5 -5
  52. package/dist/packem_chunks/handler6.js +1 -1
  53. package/dist/packem_chunks/handler7.js +1 -1
  54. package/dist/packem_chunks/handler8.js +1 -1
  55. package/dist/packem_chunks/handler9.js +1 -1
  56. package/dist/packem_chunks/heal-accept.js +2 -2
  57. package/dist/packem_chunks/heal.js +1 -1
  58. package/dist/packem_chunks/help-command.js +16 -16
  59. package/dist/packem_chunks/index.js +1 -1
  60. package/dist/packem_chunks/loader.js +1 -1
  61. package/dist/packem_shared/{ai-analysis-CGVjqwdc.js → ai-analysis-C_GpXikx.js} +3 -3
  62. package/dist/packem_shared/ai-cache-DrCLD4gc.js +1 -0
  63. package/dist/packem_shared/ai-fix-CWOz12Om.js +43 -0
  64. package/dist/packem_shared/applyDefaults-DLY94gWA.js +1 -0
  65. package/dist/packem_shared/cache-directory-C_U1qsIw.js +1 -0
  66. package/dist/packem_shared/definePlugin-CWm4Dv_t.js +1 -0
  67. package/dist/packem_shared/dependency-scan-YdgNVvoz.js +2 -0
  68. package/dist/packem_shared/docker-Dl0AoVTZ.js +60 -0
  69. package/dist/packem_shared/failure-log-CSC6KfcO.js +2 -0
  70. package/dist/packem_shared/flakiness-Dzz-I3dB.js +1 -0
  71. package/dist/packem_shared/lifecycle-BC6Nst6i.js +2 -0
  72. package/dist/packem_shared/{lockfile-B7JJzxnL.js → lockfile-i-qvq_k8.js} +1 -1
  73. package/dist/packem_shared/otelPlugin-CJR2T_lk.js +1 -0
  74. package/dist/packem_shared/{readTomlSync-1fKo0R52-DAKNI1Me.js → readTomlSync-1fKo0R52-DtxWULlF.js} +1 -1
  75. package/dist/packem_shared/run-summary-utils-CJv75pla.js +1 -0
  76. package/dist/packem_shared/runtime-check-CBU6W8qG.js +1 -0
  77. package/dist/packem_shared/{selectors-Sem2CTYA.js → selectors-B2ISH581.js} +1 -1
  78. package/dist/packem_shared/toolchain-B7dckBQ1.js +5 -0
  79. package/dist/packem_shared/typosquats-B3A38-qx.js +1 -0
  80. package/dist/packem_shared/verify-WDStBFvK.js +1 -0
  81. package/dist/packem_shared/vis-update-app-D0uL3eO5.js +1 -0
  82. package/package.json +13 -13
  83. package/schemas/project.schema.json +12 -2
  84. package/schemas/vis-config.schema.json +248 -3
  85. package/dist/packem_chunks/applyDefaults.js +0 -2
  86. package/dist/packem_shared/ai-cache-BdPgSfg2.js +0 -1
  87. package/dist/packem_shared/ai-fix-iHtGLkJS.js +0 -43
  88. package/dist/packem_shared/cache-directory-DTfMSzT9.js +0 -1
  89. package/dist/packem_shared/dependency-scan-SQeRzrpJ.js +0 -2
  90. package/dist/packem_shared/docker-D5p9mRPU.js +0 -2
  91. package/dist/packem_shared/failure-log-CElcbnb9.js +0 -2
  92. package/dist/packem_shared/flakiness-C4t4_NoA.js +0 -1
  93. package/dist/packem_shared/otel-CO8UEfTa.js +0 -17
  94. package/dist/packem_shared/otelPlugin-DTynZDWh.js +0 -1
  95. package/dist/packem_shared/registry-D04iOQ5H.js +0 -2
  96. package/dist/packem_shared/run-summary-utils-BPraMTcm.js +0 -1
  97. package/dist/packem_shared/runtime-check-l4qFpo08.js +0 -1
  98. package/dist/packem_shared/toolchain-BhZNts--.js +0 -5
  99. package/dist/packem_shared/typosquats-Dr7VIL2B.js +0 -1
  100. package/dist/packem_shared/verify-C6NNOhTA.js +0 -1
  101. package/dist/packem_shared/vis-update-app-DGiMc5kb.js +0 -1
@@ -1 +1,18 @@
1
- var y=Object.defineProperty;var j=(t,e)=>y(t,"name",{value:e,configurable:!0});import{createTaskGraph as b}from"@visulima/task-runner";import{y as v,m as E}from"./bin.js";var T=Object.defineProperty,w=j((t,e)=>T(t,"name",{value:e,configurable:!0}),"h");const O=w((t,e)=>{const s=new Map;for(const[i,r]of Object.entries(t.dependencies))for(const f of r){const c=s.get(f)??[];c.push(i),s.set(f,c)}if(!t.tasks[e])return;const a=new Set([e]),o=[{node:e,path:[e]}];for(;o.length>0;){const i=o.shift();if(t.roots.includes(i.node))return i.path;for(const r of s.get(i.node)??[])a.has(r)||(a.add(r),o.push({node:r,path:[r,...i.path]}))}return[e]},"findShortestPathToRoot"),x=w((t,e)=>{const s=[];for(const[a,o]of Object.entries(t.dependencies))o.includes(e)&&s.push(a);return s.sort()},"collectParents"),I=w(async({argument:t,logger:e,visConfig:s,workspaceRoot:a})=>{if(!a)throw new Error("Could not determine workspace root.");const o=t[0];if(!o)throw new Error("No task ID specified. Usage: vis task-why <project>:<target>");if(!o.includes(":"))throw new Error(`Invalid task ID "${o}" expected format "project:target".`);const{packageJsons:i,workspace:r}=v(a,s),f=E(a,r,i),[c,k]=o.split(":",2),$=r.projects[c];if(!$)throw new Error(`Unknown project "${c}".`);if(!$.targets?.[k])throw new Error(`Project "${c}" has no target "${k}".`);const m=Object.entries(r.projects).flatMap(([n,u])=>Object.keys(u.targets??{}).map(h=>({id:`${n}:${h}`,outputs:[],overrides:{},target:{project:n,target:h}}))),p=b(m,{projectGraph:f,workspace:r});if(!p.tasks[o])throw new Error(`Task "${o}" is not reachable in the graph.`);const d=O(p,o),g=x(p,o);if(e.info(""),e.info(`Why ${o}?`),e.info(""),d&&d.length>1){e.info("Shortest path from a root to this task:");for(const[n,u]of d.entries()){const h=n===0?" ":`${" ".repeat(n+1)}└─ `;e.info(`${h}${u}`)}e.info("")}else e.info(" This task is itself a root — nothing upstream depends on it."),e.info("");if(g.length>0){e.info(`Directly depended on by ${g.length} task(s):`);for(const n of g)e.info(` - ${n}`);e.info("")}const l=p.dependencies[o]??[];if(l.length>0){e.info(`This task depends on ${l.length} task(s):`);for(const n of[...l].sort())e.info(` - ${n}`);e.info("")}},"execute");export{I as default};
1
+ var se=Object.defineProperty;var E=(e,o)=>se(e,"name",{value:o,configurable:!0});import{createRequire as re}from"node:module";import{M as b,a as C,z as he}from"./config.js";import{Cache as I,parseCacheSize as le,readLastRunSummary as H,getLastRunSummaryPath as T,digestFile as Z}from"@visulima/task-runner";import{B as de,J as O}from"../packem_shared/ai-cache-DrCLD4gc.js";import{_ as ue,E as G}from"../packem_shared/cache-directory-C_U1qsIw.js";import{p as n,ad as fe,Q as x,n as K,ae as A}from"./bin.js";import{r as V,f as P,a as me,d as pe}from"../packem_shared/run-summary-utils-CJv75pla.js";const ae=re(import.meta.url),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=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 ae(e)},"__cjs_getBuiltinModule"),{readdir:F,stat:B,realpath:_,rm:L,mkdtemp:ie}=j("node:fs/promises"),{tmpdir:ne}=j("node:os"),{createInterface:ce}=j("node:readline");var ge=Object.defineProperty,ye=E((e,o)=>ge(e,"name",{value:o,configurable:!0}),"y"),we=Object.defineProperty,$e=ye((e,o)=>we(e,"name",{value:o,configurable:!0}),"y"),ke=Object.defineProperty,M=$e((e,o)=>ke(e,"name",{value:o,configurable:!0}),"i");const ve=/^(?<value>-?\d+(?:[.,]\d+)*) *(?<type>[a-z]+)?$/i,Se=/^KIBI/,xe=/^MIBI/,be=/^GIBI/,Ce=/^TEBI/,De=/^PEBI/,Ee=/^EXBI/,Ie=/^ZEBI/,Be=/^YIBI/,Me=/^(.)IB$/,q={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"}]},Ne=M((e,o)=>{const t=new Intl.NumberFormat(o).format(11111).replaceAll(new RegExp("\\p{Number}","gu"),""),a=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(`\\${a}`),"."))},"parseLocalizedNumber"),X=M(e=>{switch(e){case 2:return 1024;case 10:return 1e3;default:throw new Error("Unsupported base.")}},"fromBase");M((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 a=ve.exec(e)?.groups;if(!a)return Number.NaN;const r=Ne(a.value,t.locale),s=(a.type??"Bytes").toUpperCase().replace(Se,"KILO").replace(xe,"MEGA").replace(be,"GIGA").replace(Ce,"TERA").replace(De,"PETA").replace(Ee,"EXA").replace(Ie,"ZETTA").replace(Be,"YOTTA").replace(Me,"$1B"),i=q[t.units].findIndex(m=>m.short[0].toUpperCase()===s[0]),h=X(t.base);return r*h**i},"parseBytes");const w=M((e,o)=>{if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("Bytesize is not a number.");const{base:t,decimals:a,locale:r,long:s,unit:i,units:h,...m}={base:2,decimals:0,locale:"en-US",long:!1,units:"metric",...o},u=X(t),c=Math.abs(e),l=o?.space??!0?" ":"",d=q[h],p=d.findIndex(R=>R.short===i);if(e===0){const R=Math.min(0,Math.max(p,d.length-1));return"0"+l+d[R][s?"long":"short"]}const D=p===-1?Math.min(Math.floor(Math.log(c)/Math.log(u)),d.length-1):p,v=d[D][s?"long":"short"],N=e/u**D,J=a<0?void 0:a;return new Intl.NumberFormat(r,{maximumFractionDigits:J,minimumFractionDigits:J,...m}).format(N)+l+v},"formatBytes");var Re=Object.defineProperty,f=E((e,o)=>Re(e,"name",{value:o,configurable:!0}),"u");const Q=f(async e=>{let o=0;try{const t=await F(e,{withFileTypes:!0});for(const a of t){const r=b(e,a.name);if(a.isDirectory())o+=await Q(r);else if(a.isFile()){const s=await B(r);o+=s.size}}}catch{}return o},"sumDirectorySize"),$=f(async e=>{const o=[];let t;try{t=await F(e)}catch{return[]}for(const a of t){if(a.startsWith("."))continue;const r=b(e,a);try{const s=await B(r);if(!s.isDirectory())continue;const i=await Q(r);o.push({hash:a,mtimeMs:s.mtimeMs,path:r,sizeBytes:i})}catch{}}return o.sort((a,r)=>r.mtimeMs-a.mtimeMs),o},"collectCacheEntries"),ze=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"),Te=f(e=>new Promise(o=>{const t=ce({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,a=>{t.close();const r=a.trim().toLowerCase();o(r==="y"||r==="yes")})}),"confirmPrompt"),Oe=f(async(e,o,t)=>{if(!C(e)){if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
2
+ `);return}n.info(`No cache directory found at ${e}`);return}const a=await $(e);if(a.length===0){if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
3
+ `);return}n.info(`Cache directory is empty: ${e}`);return}const r=a.reduce((c,l)=>c+l.sizeBytes,0);if(o==="json"){const c=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:a.map(l=>({ageMs:c-l.mtimeMs,hash:l.hash,mtimeIso:new Date(l.mtimeMs).toISOString(),sizeBytes:l.sizeBytes})),totalBytes:r,totalCount:a.length},void 0,2)}
4
+ `);return}n.info(`Cache directory: ${e}`),n.info(`Entries: ${String(a.length)} (${w(r,{decimals:1,space:!1})})`),t.info("");const s=Date.now(),i=a.map(c=>({age:ze(c.mtimeMs,s),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)),u=Math.max(3,...i.map(c=>c.age.length));t.info(` ${"hash".padEnd(h)} ${"size".padEnd(m)} ${"age".padEnd(u)}`),t.info(` ${"-".repeat(h)} ${"-".repeat(m)} ${"-".repeat(u)}`);for(const c of i)t.info(` ${c.hash.padEnd(h)} ${c.size.padEnd(m)} ${c.age.padEnd(u)}`)},"runList"),Ae=f(()=>{try{const e=de();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"),Pe=f(()=>{try{const e=fe();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"),je=f(async(e,o,t)=>{if(!C(e)){n.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const r=await $(e),s=r.reduce((i,h)=>i+h.sizeBytes,0);n.info(`Would remove ${String(r.length)} cache entr${r.length===1?"y":"ies"} (${w(s,{decimals:1,space:!1})}) from ${e}`);return}const a=ue(e,o);try{const r=await _(e),s=await _(o);if(r===s){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(!a&&!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 Te(" Continue?")){n.info("Aborted.");return}}a?await new I({cacheDirectory:e,workspaceRoot:o}).clear():await L(e,{force:!0,recursive:!0}),n.success(`Cleared cache: ${e}`)},"runClean"),Fe=f(async(e,o,t)=>{if(!C(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=le(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 a=t.maxCacheAgeDays===void 0?void 0:t.maxCacheAgeDays*24*60*60*1e3,r=await $(e),s=r.reduce((c,l)=>c+l.sizeBytes,0);if(t.keepLast!==void 0&&r.length>t.keepLast){const c=r.slice(t.keepLast);await Promise.all(c.map(l=>L(l.path,{force:!0,recursive:!0})))}await new I({cacheDirectory:e,maxCacheAge:a,maxCacheSize:t.maxCacheSize,workspaceRoot:o}).removeOldEntries();const i=await $(e),h=i.reduce((c,l)=>c+l.sizeBytes,0),m=r.length-i.length,u=s-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(u,{decimals:1,space:!1})}.`)},"runPrune"),W=16,ee=f(e=>e.length>W?`${e.slice(0,W)}…`:e,"truncateHash"),z=f((e,o,t)=>{const a=Object.entries(o??{});if(a.length!==0){t.info(` ${e}:`),a.sort(([r],[s])=>r.localeCompare(s));for(const[r,s]of a)t.info(` ${r.padEnd(40)} ${ee(s)}`)}},"renderHashDetailsBucket"),Le=f(async(e,o,t)=>{const{format:a,runId:r,workspaceRoot:s}=o,i=r===void 0?await H(s,{dataDirectory:x(s)}):await V(s,r);if(!i){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:r??null,taskId:e},void 0,2)}
5
+ `),process.exitCode=1;return}r===void 0?n.error(`No previous run summary found. Run a task first to populate \`${T(s,{dataDirectory:x(s)})}\`.`):n.error(`Run summary "${r}" not found in ${K(s)}/.`),process.exitCode=1;return}const h=P(i,e);if(!h){if(a==="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 me(s,i.id),u=m?P(m,e):void 0,c=pe(h.hashDetails,u?.hashDetails);if(a==="json"){process.stdout.write(`${JSON.stringify({diff:c,previousRunId:m?.id??null,previousTask:u?{cacheStatus:u.cacheStatus,hash:u.hash??null,hashDetails:u.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
+ `);return}if(n.info(`Why ${e}? (run ${i.id})`),t.info(""),t.info(` status: ${h.cacheStatus}`),t.info(` hash: ${h.hash??"(none)"}`),u?t.info(` prev: ${u.hash??"(none)"} [run ${m?.id??"?"}]`):t.info(" prev: (no prior run found)"),t.info(""),!u){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 d=c[l];if(!(d.added.length===0&&d.changed.length===0&&d.removed.length===0)){t.info(` ${l}:`);for(const p of d.added)t.info(` + ${p}`);for(const p of d.changed)t.info(` ~ ${p}`);for(const p of d.removed)t.info(` - ${p}`)}}t.info(""),n.info(`Last summary file: ${T(s,{dataDirectory:x(s)})}`)},"runWhy"),Je=f(async(e,o,t)=>{const{format:a,runId:r,workspaceRoot:s}=o,i=r===void 0?await H(s,{dataDirectory:x(s)}):await V(s,r);if(!i){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:r??null,taskId:e},void 0,2)}
8
+ `),process.exitCode=1;return}r===void 0?n.error(`No previous run summary found. Run a task first to populate \`${T(s,{dataDirectory:x(s)})}\`.`):n.error(`Run summary "${r}" not found in ${K(s)}/.`),process.exitCode=1;return}const h=P(i,e);if(!h){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:i.id,taskId:e},void 0,2)}
9
+ `),process.exitCode=1;return}n.error(`Task "${e}" was not part of run ${i.id}.`),process.exitCode=1;return}if(a==="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: ${ee(h.hashDetails.command)}`),z("nodes",h.hashDetails.nodes,t),z("runtime",h.hashDetails.runtime,t),z("implicitDeps",h.hashDetails.implicitDeps,t)):(t.info(""),n.info("No hash details recorded for this task."))},"runHash"),_e=f(async(e,o)=>{if(!C(e)){if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
11
+ `);return}n.info(`No cache directory at ${e}`);return}const t=await $(e),a=t.reduce((r,s)=>r+s.sizeBytes,0);if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:a,totalCount:t.length})}
12
+ `);return}n.info(`Cache directory: ${e}`),n.info(`Entries: ${String(t.length)}`),n.info(`Total size: ${w(a,{decimals:1,space:!1})}`)},"runSize"),Ge=f(async e=>{const o=[],t=f(async a=>{const r=(await F(a,{withFileTypes:!0})).toSorted((s,i)=>s.name.localeCompare(i.name));for(const s of r){const i=b(a,s.name);if(s.isDirectory()){await t(i);continue}if(!s.isFile())continue;const[h,m]=await Promise.all([B(i),Z(i)]);o.push({hash:m?.hash??"",mode:h.mode&4095,mtimeMs:h.mtimeMs,relativePath:he(e,i).replaceAll("\\","/"),sizeBytes:h.size})}},"walk");return await t(e),o},"walkAndDigest"),We=f((e,o)=>Math.floor(e/1e3)===Math.floor(o/1e3),"compareSecondsTruncated"),Y=16,Ye=f(async(e,o)=>{const t=b(o,e.relativePath),a=await B(t).catch(()=>{});if(!a)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const r=await Z(t),s=[];(r?.hash??"")!==e.hash&&s.push("content");const i=a.mode&4095;if(process.platform!=="win32"&&i!==e.mode&&s.push("mode"),We(a.mtimeMs,e.mtimeMs)||s.push("mtime"),s.length!==0)return{actual:{hash:r?.hash,mode:i,mtimeMs:a.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:s,relativePath:e.relativePath}},"computeFileDiff"),Ue=f(async(e,o,t)=>{const{cacheDirectories:a,format:r,workspaceRoot:s}=o;if(a.length===0){r==="json"?process.stdout.write(`${JSON.stringify({error:"no-cache-directory",taskId:e},void 0,2)}
13
+ `):n.error("No cache directory resolved — pass --cache-dir or run inside a workspace."),process.exitCode=1;return}let i,h;for(const u of a){const c=await new I({cacheDirectory:u,workspaceRoot:s}).getByTaskId(e);if(c){i=u,h=c;break}}if(!h||!i){r==="json"?process.stdout.write(`${JSON.stringify({error:"no-cached-entry",searchedCaches:a,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 ie(b(ne(),"vis-cache-verify-"));try{if(!await new I({cacheDirectory:i,workspaceRoot:m}).restoreOutputs(h.hash)){r==="json"?process.stdout.write(`${JSON.stringify({error:"restore-failed",hash:h.hash,taskId:e},void 0,2)}
15
+ `):n.error(`Cache restore failed for ${e} (hash ${h.hash}).`),process.exitCode=1;return}const u=await Ge(m);if(u.length===0){r==="json"?process.stdout.write(`${JSON.stringify({diffs:[],hash:h.hash,status:"no-outputs",taskId:e},void 0,2)}
16
+ `):n.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const c=Array.from({length:u.length});for(let d=0;d<u.length;d+=Y){const p=u.slice(d,d+Y),D=await Promise.all(p.map(async v=>Ye(v,s)));for(const[v,N]of D.entries())c[d+v]=N}const l=c.filter(d=>d!==void 0);if(r==="json"){process.stdout.write(`${JSON.stringify({cachedFileCount:u.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(u.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 d of l){const p=d.issues.includes("missing")?"MISSING":d.issues.join(",").toUpperCase();t.info(` [${p}] ${d.relativePath}`),!d.issues.includes("missing")&&d.expected&&d.actual&&(d.issues.includes("content")&&(t.info(` expected hash: ${d.expected.hash||"(none)"}`),t.info(` actual hash: ${d.actual.hash??"(unreadable)"}`)),d.issues.includes("mode")&&(t.info(` expected mode: ${d.expected.mode.toString(8)}`),t.info(` actual mode: ${(d.actual.mode??0).toString(8)}`)),d.issues.includes("mtime")&&(t.info(` expected mtime: ${new Date(d.expected.mtimeMs).toISOString()}`),t.info(` actual mtime: ${d.actual.mtimeMs===void 0?"(unreadable)":new Date(d.actual.mtimeMs).toISOString()}`)))}process.exitCode=1}finally{await L(m,{force:!0,recursive:!0}).catch(()=>{})}},"runVerify"),te=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"),U=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"),He=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 a=e??process.cwd(),r=t??{},s=r.taskRunnerOptions??{},i=He(o.scope),h=o.cacheDir,m=G(a,h,s.cacheDirectory,!1),u=G(a,h,s.cacheDirectory,r.sharedWorktreeCache);let c,l;switch(i){case"all":{c=u,l=u===m?[u]:[u,m];break}case"worktree":{c=m,l=[m];break}default:c=u,l=[u]}return{cacheDirectories:l,cacheDirectory:c,scope:i,sharedWorktreeCache:r.sharedWorktreeCache,workspaceRoot:a}},"resolveCacheDirectoryFromContext"),ot=f(async({logger:e,options:o,visConfig:t,workspaceRoot:a})=>{const{cacheDirectories:r}=k(a,o,t),s=o.format??"table";for(const i of r)r.length>1&&n.info(`# ${i}`),await Oe(i,s,e)},"cacheListExecute"),st=f(async({options:e,visConfig:o,workspaceRoot:t})=>{const a=te(e.type),r=!!e.dryRun;if(g(a,"task")){const{cacheDirectory:s,workspaceRoot:i}=k(t,e,o);await je(s,i,{dryRun:r,force:!!e.force})}if(g(a,"ai"))if(r){const s=O();n.info(`Would clear ${String(s.entries)} cached AI response${s.entries===1?"":"s"}.`)}else Ae();if(g(a,"socket"))if(r){const s=A();n.info(`Would clear ${String(s.entries)} cached Socket.dev report${s.entries===1?"":"s"}.`)}else Pe()},"cacheCleanExecute"),rt=f(async({options:e,visConfig:o,workspaceRoot:t})=>{const{cacheDirectories:a,workspaceRoot:r}=k(t,e,o);for(const s of a)a.length>1&&n.info(`# ${s}`),await Fe(s,r,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},"cachePruneExecute"),oe=f(e=>e??process.cwd(),"resolveWorkspaceRoot"),at=f(async({argument:e,logger:o,options:t,workspaceRoot:a})=>{const r=e[0];if(!r){n.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await Le(r,{format:t.format??"table",runId:t.run,workspaceRoot:oe(a)},o)},"cacheWhyExecute"),it=f(async({argument:e,logger:o,options:t,workspaceRoot:a})=>{const r=e[0];if(!r){n.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}await Je(r,{format:t.format??"table",runId:t.run,workspaceRoot:oe(a)},o)},"cacheHashExecute"),nt=f(async({options:e,visConfig:o,workspaceRoot:t})=>{const a=te(e.type);if((e.format??"table")==="json"){const r={};if(g(a,"task")){const{cacheDirectories:s}=k(t,e,o);r.task=await Promise.all(s.map(async i=>{const h=C(i),m=h?await $(i):[],u=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:u}}))}if(g(a,"ai")){const s=O();r.ai={entries:s.entries,newestEntry:y(s.newestEntry),oldestEntry:y(s.oldestEntry),totalBytes:s.totalSizeBytes}}if(g(a,"socket")){const s=A();r.socket={entries:s.entries,newestEntry:y(s.newestEntry),oldestEntry:y(s.oldestEntry),totalBytes:s.totalSizeBytes}}process.stdout.write(`${JSON.stringify(r,void 0,2)}
18
+ `);return}if(g(a,"task")){const{cacheDirectories:r}=k(t,e,o);for(const s of r)r.length>1&&n.info(`# ${s}`),await _e(s,"table")}g(a,"ai")&&U("AI response cache",O()),g(a,"socket")&&U("Socket.dev report cache",A())},"cacheSizeExecute"),ct=f(async({argument:e,logger:o,options:t,visConfig:a,workspaceRoot:r})=>{const s=e[0];if(!s){n.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{cacheDirectories:i,workspaceRoot:h}=k(r,t,a);await Ue(s,{cacheDirectories:i,format:t.format??"table",workspaceRoot:h},o)},"cacheVerifyExecute");export{st as cacheCleanExecute,it as cacheHashExecute,ot as cacheListExecute,rt as cachePruneExecute,nt as cacheSizeExecute,ct as cacheVerifyExecute,at as cacheWhyExecute,Ae as clearAiCacheSafe,Pe as clearSocketCacheSafe,$ as collectCacheEntries,ze as formatAge,je as runClean,Je as runHash,Oe as runList,Fe as runPrune,_e as runSize,Ue as runVerify,Le as runWhy};
@@ -1,5 +1 @@
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
- `);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
- `)}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
- `)},"executeWhich"),oe=f((e,n)=>{const i=D(e,n);process.stdout.write(`${i.name}
5
- `)},"executeDetect"),ce=f(async({argument:e,options:n,visConfig:i,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run inside a monorepo.");const t=e[0]??"status",s=i?.toolchain;switch(t){case"detect":{oe(r,s);return}case"install":{Z(r,s,n);return}case"status":{X(r,s,n);return}case"use":{ee(r,s,e[1],n);return}case"which":{ne(r,s,e[1]);return}default:throw new Error(`Unknown toolchain action "${t}". Known: status, detect, install, use, which.`)}},"execute");export{ce as default};
1
+ var T=Object.defineProperty;var j=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createRequire as w}from"node:module";import{c as f,d as b,y as x,m as V,n as F,E as I,e as $}from"./bin.js";import{a as P,n as z,M as B}from"./config.js";import{enforceProjectConstraints as E}from"@visulima/task-runner";import{a as J}from"../packem_shared/flakiness-Dzz-I3dB.js";import{c as K}from"../packem_shared/runtime-check-CBU6W8qG.js";const C=w(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=j(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 C(e)},"__cjs_getBuiltinModule"),{readdirSync:q}=M("node:fs");var N=Object.defineProperty,v=j((e,t)=>N(e,"name",{value:t,configurable:!0}),"h");const r=v(e=>e?f("✓"):b("✗"),"icon"),Q=v(async({logger:e,options:t,visConfig:i,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root.");const{config:y,packageJsons:O,workspace:u}=x(s,i),R=V(s,u,O),k=Object.keys(u.projects).length,S=new Set(Object.values(u.projects).flatMap(p=>Object.keys(p.targets??{}))).size,a=K(s);let o=0;y.constraints&&(o=E(R,y.constraints).length);const c=J(s,{minRuns:2});let l;const g=F(s);if(P(g)){const p=q(g).filter(h=>h.endsWith(".json")).sort();let m=0,_=0;for(const h of p.slice(-20))try{const d=z(B(g,h));d.stats&&(m+=d.stats.total??0,_+=d.stats.cached??0)}catch{continue}m>0&&(l=`${(_/m*100).toFixed(0)}%`)}if(t.json){e.info(JSON.stringify({cacheHitRate:l??null,constraintViolations:o,flakyTasks:c.length,projects:k,runtimeIssues:a.length,targets:S},null,2));return}e.info(""),e.info(` ${I("VIS STATUS")}`),e.info(""),e.info(` ${r(!0)} ${String(k)} projects · ${String(S)} 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"):b(`${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 +1 @@
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
+ var y=Object.defineProperty;var j=(t,e)=>y(t,"name",{value:e,configurable:!0});import{createTaskGraph as b}from"@visulima/task-runner";import{y as v,m as E}from"./bin.js";var T=Object.defineProperty,w=j((t,e)=>T(t,"name",{value:e,configurable:!0}),"h");const O=w((t,e)=>{const s=new Map;for(const[i,r]of Object.entries(t.dependencies))for(const f of r){const c=s.get(f)??[];c.push(i),s.set(f,c)}if(!t.tasks[e])return;const a=new Set([e]),o=[{node:e,path:[e]}];for(;o.length>0;){const i=o.shift();if(t.roots.includes(i.node))return i.path;for(const r of s.get(i.node)??[])a.has(r)||(a.add(r),o.push({node:r,path:[r,...i.path]}))}return[e]},"findShortestPathToRoot"),x=w((t,e)=>{const s=[];for(const[a,o]of Object.entries(t.dependencies))o.includes(e)&&s.push(a);return s.sort()},"collectParents"),I=w(async({argument:t,logger:e,visConfig:s,workspaceRoot:a})=>{if(!a)throw new Error("Could not determine workspace root.");const o=t[0];if(!o)throw new Error("No task ID specified. Usage: vis task-why <project>:<target>");if(!o.includes(":"))throw new Error(`Invalid task ID "${o}" — expected format "project:target".`);const{packageJsons:i,workspace:r}=v(a,s),f=E(a,r,i),[c,k]=o.split(":",2),$=r.projects[c];if(!$)throw new Error(`Unknown project "${c}".`);if(!$.targets?.[k])throw new Error(`Project "${c}" has no target "${k}".`);const m=Object.entries(r.projects).flatMap(([n,u])=>Object.keys(u.targets??{}).map(h=>({id:`${n}:${h}`,outputs:[],overrides:{},target:{project:n,target:h}}))),p=b(m,{projectGraph:f,workspace:r});if(!p.tasks[o])throw new Error(`Task "${o}" is not reachable in the graph.`);const d=O(p,o),g=x(p,o);if(e.info(""),e.info(`Why ${o}?`),e.info(""),d&&d.length>1){e.info("Shortest path from a root to this task:");for(const[n,u]of d.entries()){const h=n===0?" ":`${" ".repeat(n+1)}└─ `;e.info(`${h}${u}`)}e.info("")}else e.info(" This task is itself a root — nothing upstream depends on it."),e.info("");if(g.length>0){e.info(`Directly depended on by ${g.length} task(s):`);for(const n of g)e.info(` - ${n}`);e.info("")}const l=p.dependencies[o]??[];if(l.length>0){e.info(`This task depends on ${l.length} task(s):`);for(const n of[...l].sort())e.info(` - ${n}`);e.info("")}},"execute");export{I as default};
@@ -1,3 +1,5 @@
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
- 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
- Updated @visulima/vis from ${o} → ${i}`)},"execute");export{w as default};
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"./config.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-B7dckBQ1.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
+ `);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
+ `)}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
+ `)},"executeWhich"),oe=f((e,n)=>{const i=D(e,n);process.stdout.write(`${i.name}
5
+ `)},"executeDetect"),ce=f(async({argument:e,options:n,visConfig:i,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run inside a monorepo.");const t=e[0]??"status",s=i?.toolchain;switch(t){case"detect":{oe(r,s);return}case"install":{Z(r,s,n);return}case"status":{X(r,s,n);return}case"use":{ee(r,s,e[1],n);return}case"which":{ne(r,s,e[1]);return}default:throw new Error(`Unknown toolchain action "${t}". Known: status, detect, install, use, which.`)}},"execute");export{ce as default};
@@ -1 +1 @@
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
+ var p=Object.defineProperty;var c=(e,a)=>p(e,"name",{value:a,configurable:!0});import{h as f,a0 as g}from"./bin.js";var u=Object.defineProperty,d=c((e,a)=>u(e,"name",{value:a,configurable:!0}),"t");const b=d(async({argument:e,logger:a,options:n,visConfig:o,workspaceRoot:t})=>{const i=e||[],r=t??process.cwd(),l=f(r,{configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),s=g(l,i,n.recursive||!1,r,a);s!==0&&(process.exitCode=s)},"execute");export{b as default};
@@ -1 +1,3 @@
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
+ var a=Object.defineProperty;var s=(n,e)=>a(n,"name",{value:e,configurable:!0});import{createRequire as f}from"node:module";import{a1 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
+ ✓ 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
+ ✓ Updated @visulima/vis from ${o} → ${i}`)},"execute");export{w as default};
@@ -1,7 +1 @@
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
- `,"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
- `)}
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
- `);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
- Selected provider: ${n.name} (priority ${String(f[n.name]??0)})`):e.info(`
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
+ var p=Object.defineProperty;var t=(a,o)=>p(a,"name",{value:o,configurable:!0});import{h as f,a2 as d}from"./bin.js";import{o as g}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,b=t((a,o)=>v(a,"name",{value:o,configurable:!0}),"n");const m=b(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{m as default};
@@ -1,23 +1 @@
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
- ${p.map(x=>` - ${x}`).join(`
3
- `)}
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:
5
- ${c}`):g=`${g.trimEnd()}
6
-
7
- auditConfig:
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
- ${d.map(x=>` - ${x}`).join(`
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)`)}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
- ${$.map(d=>` - "${d}"`).join(`
13
- `)}
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
-
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
- ${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 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
- ── 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 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
- 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&&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
+ 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,a3 as S,a4 as N,p as g,a5 as j,E as M,d as U,e as B,c as T,a6 as z,a7 as J,a8 as Q,a as V,y as W,U as Y,R as Z,a9 as G,x as H,J as K,aa as X,h as ee,ab as oe}from"./bin.js";import{M as te,n as se,w as ne}from"./config.js";import{r as ae}from"../packem_shared/typosquats-B3A38-qx.js";import{d as C,o as R}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 _=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:T;if(p?g.info(` ${f(s)} ${j(i)} ${M(`[accepted: ${p.reason}]`)}`):g.info(` ${f(s)} ${j(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 _(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 V(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=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 _(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=D(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}=W(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}=Y(s),u=Z(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:G(p,{useEditorconfig:n?.editorconfig??!0}),overwrite:!0});for(const v of y){const E=D(v.spec,k);g.info(`${T("+")} ${v.name}@${E} → ${o}/${m} (${M(v.source)})`)}return H(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=K(r?.security?.socket);if(p){const f=p.minimumScore??X;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&&R(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:R(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,3 +1,7 @@
1
- var I=Object.defineProperty;var y=(e,t)=>I(e,"name",{value:t,configurable:!0});import{createRequire as D}from"node:module";import{getAffectedProjects as G}from"@visulima/task-runner";import{y as q,m as L}from"./bin.js";const T=D(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=y(e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,r]=h.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return h.getBuiltinModule(e)}return T(e)},"__cjs_getBuiltinModule"),{execFile:N}=A("node:child_process"),{promisify:U}=A("node:util");var V=Object.defineProperty,i=y((e,t)=>V(e,"name",{value:t,configurable:!0}),"t");const M=U(N),J=["[skip ci]","[ci skip]","[no ci]","[vis skip]","[nx skip]"],z=["[vis deploy]","[nx deploy]"],W=["vis","nx"],Z=["CACHED_COMMIT_REF","VERCEL_GIT_PREVIOUS_SHA","GITHUB_BASE_REF","CI_COMMIT_BEFORE_SHA"],K=/^[\w./~^@{}][\w.\-/~^@{}]*$/,Q=i((e=process.env)=>{for(const t of Z){const r=e[t];if(r&&r.trim().length>0)return r.trim()}},"resolveCiBaseSha"),R=i(e=>{if(!K.test(e))throw new Error(`Invalid git ref: "${e}". Refs must start with an alphanumeric character or one of _ . / ~ ^ @ { } and may only contain letters, digits, dots, dashes, underscores, slashes, tildes, carets, @, and braces.`)},"validateGitRef"),X=i(async(e,t)=>{try{return await M("git",["rev-parse","--verify",`${t}^{commit}`],{cwd:e}),!0}catch{return!1}},"isRefReachable"),Y=i(async e=>{try{const{stdout:t}=await M("git",["log","-1","--pretty=%B"],{cwd:e});return t}catch{return""}},"readLastCommitMessage"),B=i((e,t,r)=>W.some(a=>e.includes(`[${a} ${t} ${r}]`)),"matchesPerProjectToken"),ee=i((e,t)=>J.some(r=>e.includes(r))||B(e,"skip",t),"commitHasSkipMessage"),te=i((e,t)=>z.some(r=>e.includes(r))||B(e,"deploy",t),"commitHasForceDeployMessage"),l=i((e,t,r,a)=>({action:"build",message:r,project:e,reason:t,...a}),"decideBuild"),k=i((e,t,r,a)=>({action:"skip",message:r,project:e,reason:t,...a}),"decideSkip"),re=i(e=>`${e.action==="skip"?"🛑":"✅"} ${e.message}`,"formatDecisionLine"),oe=i((e,t)=>e.action==="skip"||t?0:1,"exitCodeFor");var se=Object.defineProperty,_=y((e,t)=>se(e,"name",{value:t,configurable:!0}),"u");const S=new Set(["deep","direct","none"]),de=_(async({argument:e,logger:t,options:r,visConfig:a,workspaceRoot:p})=>{const o=e[0]??"",E=!!r.json,C=!!r.verbose,O=!!(r["exit-zero-on-build"]??r.exitZeroOnBuild),u=_(s=>{C&&!E&&t.info(`❱ ${s}`)},"debug"),n=_(s=>{E?process.stdout.write(`${JSON.stringify(s)}
2
- `):t.info(re(s)),process.exit(oe(s,O))},"emit");if(!o)return n(l("","missing-project-argument","Missing project argument. Usage: vis ignore <project>"));if(!p)return n(l(o,"workspace-error","Could not determine workspace root building defensively"));const g=await Y(p),w=g.trim().split(`
3
- `)[0]??"";if(u(`commit: ${w}`),g&&te(g,o))return n(l(o,"commit-force-deploy",`Force-deploy keyword in commit: "${w}"`));if(g&&ee(g,o))return n(k(o,"commit-skip",`Skip keyword in commit: "${w}"`));let $,P;try{({packageJsons:P,workspace:$}=q(p,a))}catch(s){const d=s instanceof Error?s.message:String(s);return n(l(o,"workspace-error",`Workspace discovery failed (${d}) — building defensively`))}if(!Object.hasOwn($.projects,o))return n(l(o,"project-unknown",`Project "${o}" not found in workspace — building defensively`));try{const s=r.base?.trim(),d=Q();let c=s||d||"HEAD~1";const m=r.head?.trim()||"HEAD";R(c),R(m),u(`resolved base ref: ${c} (source: ${s?"flag":d?"ci-env":"default"})`);const x=X(p,c),F=L(p,$,P);await x||(u(`base ref ${c} not reachable — falling back to HEAD~1`),c="HEAD~1"),u(`comparing ${c}...${m}`);const j=r.downstream??"deep",b=r.upstream??"none";if(!S.has(j))throw new Error(`Invalid --downstream value: "${j}". Must be "none", "direct", or "deep".`);if(!S.has(b))throw new Error(`Invalid --upstream value: "${b}". Must be "none", "direct", or "deep".`);const H={base:c,downstream:j,head:m,projectGraph:F,projects:$.projects,upstream:b,workspaceRoot:p},f=await G(H);u(`changed files: ${f.changedFiles.length}`),u(`affected projects: ${f.affectedProjects.join(", ")||"(none)"}`);const v={base:c,head:m};return f.changedFiles.length===0?n(k(o,"no-changes",`No files changed between ${c}...${m}`,{...v,affectedProjects:[]})):f.affectedProjects.includes(o)?n(l(o,"project-affected",`Build ${o}: affected by ${f.changedFiles.length} changed file(s)`,{...v,affectedProjects:f.affectedProjects})):n(k(o,"project-not-affected",`Skip ${o}: not affected by changes between ${c}...${m}`,{...v,affectedProjects:f.affectedProjects}))}catch(s){const d=s instanceof Error?s.message:String(s);return t.error(`Affected detection failed: ${d}`),n(l(o,"workspace-error",`Affected detection failed (${d}) — building defensively`))}},"execute");export{de as default};
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-C_GpXikx.js";import{renderToString as w}from"@visulima/tui";import{Table as D}from"@visulima/tui/components/table";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
+ `,"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
+ `)}
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.bk);return e.filter(o=>o.name!=="ai")},"loadDiscoverableSubcommands"),K=p(async()=>{const e=await b();process.stderr.write(J(e))},"aiRootExecute"),L=p(async()=>{const e=await b();process.stdout.write(C(e))},"aiDiscoverHelpExecute"),_=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"),z=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
+ `);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
+ Selected provider: ${n.name} (priority ${String(f[n.name]??0)})`):e.info(`
7
+ No AI provider available. Install one of the supported AI CLI tools.`)},"aiProvidersExecute"),G=p(async e=>{const{aiFix:o}=await import("./fix.js");await o(e)},"aiFixExecute");export{L as aiDiscoverHelpExecute,G as aiFixExecute,z as aiProvidersExecute,K as aiRootExecute,_ as aiTestExecute};
@@ -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-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}...
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-C_GpXikx.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,23 @@
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
- `);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
- `);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"),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
- `);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=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
- `),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(!b(e)){if(o==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
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=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
- `):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(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
- `):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
- `):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"),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};
1
+ var re=Object.defineProperty;var U=(t,n)=>re(t,"name",{value:n,configurable:!0});import{u as Z,E,e as q,q as _,ac as ee,d as se,a3 as oe,a6 as ae,A as ce,p as a,J as le,N as de,a as ue,a4 as ge,aa as W}from"./bin.js";import{M as G,a as H,$ as z,B as Q}from"./config.js";import{l as fe,f as pe,s as he}from"../packem_shared/dependency-scan-YdgNVvoz.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"),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=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=z(f);if(p.length>0){const c=` ignoreCves:
2
+ ${p.map(x=>` - ${x}`).join(`
3
+ `)}
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:
5
+ ${c}`):g=`${g.trimEnd()}
6
+
7
+ auditConfig:
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
+ ${d.map(x=>` - ${x}`).join(`
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)`)}Q(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=z(f);const p=`npmAuditIgnoreAdvisories:
12
+ ${$.map(d=>` - "${d}"`).join(`
13
+ `)}
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
+
16
+ ${p}`,Q(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
+ ${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 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||X(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
+ ── 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 F=R(e=>!!e.acceptedRisk||e.vulnerabilities.length>0&&e.vulnerabilities.every(s=>X(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
+ 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&&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};