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

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 (100) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE.md +7242 -385
  3. package/dist/bin.js +1 -1
  4. package/dist/config/index.d.ts +493 -1
  5. package/dist/config/index.js +1 -1
  6. package/dist/packem_chunks/applyDefaults.js +2 -2
  7. package/dist/packem_chunks/bin.js +1134 -199
  8. package/dist/packem_chunks/doctor-probe.js +2 -2
  9. package/dist/packem_chunks/fix.js +11 -11
  10. package/dist/packem_chunks/handler.js +1 -1
  11. package/dist/packem_chunks/handler10.js +1 -1
  12. package/dist/packem_chunks/handler11.js +1 -1
  13. package/dist/packem_chunks/handler12.js +5 -5
  14. package/dist/packem_chunks/handler13.js +1 -1
  15. package/dist/packem_chunks/handler14.js +20 -18
  16. package/dist/packem_chunks/handler15.js +1 -20
  17. package/dist/packem_chunks/handler16.js +1 -1
  18. package/dist/packem_chunks/handler17.js +1 -1
  19. package/dist/packem_chunks/handler18.js +1 -1
  20. package/dist/packem_chunks/handler19.js +5 -1
  21. package/dist/packem_chunks/handler2.js +1 -1
  22. package/dist/packem_chunks/handler20.js +1 -5
  23. package/dist/packem_chunks/handler21.js +1 -1
  24. package/dist/packem_chunks/handler22.js +5 -1
  25. package/dist/packem_chunks/handler23.js +1 -5
  26. package/dist/packem_chunks/handler24.js +3 -1
  27. package/dist/packem_chunks/handler25.js +1 -3
  28. package/dist/packem_chunks/handler26.js +1 -1
  29. package/dist/packem_chunks/handler27.js +7 -1
  30. package/dist/packem_chunks/handler28.js +22 -6
  31. package/dist/packem_chunks/handler29.js +3 -23
  32. package/dist/packem_chunks/handler3.js +4 -4
  33. package/dist/packem_chunks/handler30.js +18 -3
  34. package/dist/packem_chunks/handler31.js +1 -1
  35. package/dist/packem_chunks/handler32.js +2 -2
  36. package/dist/packem_chunks/handler33.js +24 -24
  37. package/dist/packem_chunks/handler34.js +2 -2
  38. package/dist/packem_chunks/handler35.js +2 -2
  39. package/dist/packem_chunks/handler36.js +20 -20
  40. package/dist/packem_chunks/handler37.js +2 -2
  41. package/dist/packem_chunks/handler38.js +6 -22
  42. package/dist/packem_chunks/handler39.js +11 -11
  43. package/dist/packem_chunks/handler4.js +1 -1
  44. package/dist/packem_chunks/handler40.js +5 -22
  45. package/dist/packem_chunks/handler41.js +24 -6
  46. package/dist/packem_chunks/handler42.js +10 -5
  47. package/dist/packem_chunks/handler43.js +153 -10
  48. package/dist/packem_chunks/handler44.js +25 -153
  49. package/dist/packem_chunks/handler45.js +3 -25
  50. package/dist/packem_chunks/handler46.js +27 -3
  51. package/dist/packem_chunks/handler47.js +41 -26
  52. package/dist/packem_chunks/handler48.js +32 -40
  53. package/dist/packem_chunks/handler5.js +7 -7
  54. package/dist/packem_chunks/handler6.js +1 -1
  55. package/dist/packem_chunks/handler7.js +1 -1
  56. package/dist/packem_chunks/handler8.js +1 -1
  57. package/dist/packem_chunks/handler9.js +1 -1
  58. package/dist/packem_chunks/heal-accept.js +4 -4
  59. package/dist/packem_chunks/heal.js +3 -3
  60. package/dist/packem_chunks/help-command.js +18 -0
  61. package/dist/packem_chunks/index.js +4 -4
  62. package/dist/packem_chunks/loader.js +1 -1
  63. package/dist/packem_chunks/tar.js +1 -1
  64. package/dist/packem_shared/ai-analysis-Dzs_nUwM.js +68 -0
  65. package/dist/packem_shared/ai-cache-Dtvmbsru.js +1 -0
  66. package/dist/packem_shared/{ai-fix-nn4zOE95.js → ai-fix-BmLM72GS.js} +4 -4
  67. package/dist/packem_shared/cache-directory-xASJia6M.js +1 -0
  68. package/dist/packem_shared/dependency-scan-DmwPKwLy.js +2 -0
  69. package/dist/packem_shared/docker-CA-scYu0.js +2 -0
  70. package/dist/packem_shared/failure-log-fD4DiFb1.js +2 -0
  71. package/dist/packem_shared/flakiness-BIg1rwvp.js +1 -0
  72. package/dist/packem_shared/{giget-CcEy_Elm.js → giget-BX2ixMoa.js} +2 -2
  73. package/dist/packem_shared/index-OlP7U_t5.js +6 -0
  74. package/dist/packem_shared/lockfile-BXylopgH.js +1 -0
  75. package/dist/packem_shared/otelPlugin-y5hoCw4b.js +1 -0
  76. package/dist/packem_shared/registry-BHqKXiLb.js +2 -0
  77. package/dist/packem_shared/run-summary-utils-D39XBHWW.js +1 -0
  78. package/dist/packem_shared/runtime-check-BaKni2y1.js +1 -0
  79. package/dist/packem_shared/selectors-BvtUXWGY.js +3 -0
  80. package/dist/packem_shared/toolchain-B7sIiJxK.js +5 -0
  81. package/dist/packem_shared/typosquats-XkC1CnOa.js +1 -0
  82. package/dist/packem_shared/verify-BVTcVfoW.js +1 -0
  83. package/dist/packem_shared/{vis-update-app-D1jl0UZZ.js → vis-update-app-DR8c4OfG.js} +1 -1
  84. package/package.json +15 -30
  85. package/dist/packem_shared/ai-analysis-hm8d2W7z.js +0 -67
  86. package/dist/packem_shared/ai-cache-DoiF80AR.js +0 -1
  87. package/dist/packem_shared/cache-directory-CwHlJhgx.js +0 -1
  88. package/dist/packem_shared/dependency-scan-COr5n63B.js +0 -2
  89. package/dist/packem_shared/docker-D6OGr5_S.js +0 -2
  90. package/dist/packem_shared/failure-log-iUVLf6ts.js +0 -2
  91. package/dist/packem_shared/flakiness-D9wf0t56.js +0 -1
  92. package/dist/packem_shared/otel-DxDUPJJH.js +0 -6
  93. package/dist/packem_shared/otelPlugin-CQq6poq8.js +0 -1
  94. package/dist/packem_shared/registry-CkubDdiY.js +0 -2
  95. package/dist/packem_shared/run-summary-utils-BfBvjzhY.js +0 -1
  96. package/dist/packem_shared/runtime-check-BXZ43CBW.js +0 -1
  97. package/dist/packem_shared/selectors-BylODRiM.js +0 -3
  98. package/dist/packem_shared/toolchain-BgBOUHII.js +0 -5
  99. package/dist/packem_shared/typosquats-CcZl99B1.js +0 -1
  100. package/dist/packem_shared/verify-Baj5mFJ7.js +0 -1
@@ -1,2 +1,2 @@
1
- var h=Object.defineProperty;var p=(e,t)=>h(e,"name",{value:t,configurable:!0});import{green as d,red as l,bold as g,dim as n,cyan as m,yellow as b}from"@visulima/colorize";import{ReapiRemoteCache as f}from"@visulima/task-runner";import{p as k}from"./bin.js";var $=Object.defineProperty,s=p((e,t)=>$(e,"name",{value:t,configurable:!0}),"s");const w=s((e,t)=>t==="http"||t==="reapi"?t:e.startsWith("grpc://")||e.startsWith("grpcs://")?"reapi":"http","inferBackend"),y=s(async(e,t)=>{const o=Date.now(),a=new AbortController,r=setTimeout(()=>{a.abort()},t);try{const i=await fetch(e,{method:"HEAD",signal:a.signal});return{backend:"http",durationMs:Date.now()-o,httpStatus:i.status,ok:!0,url:e}}catch(i){return{backend:"http",durationMs:Date.now()-o,error:i instanceof Error?i.message:String(i),ok:!1,url:e}}finally{clearTimeout(r)}},"probeHttp"),S=s(async(e,t)=>{const o=Date.now(),a=new f({...e,timeout:t});try{return{backend:"reapi",capabilities:await a.probeCapabilities(),durationMs:Date.now()-o,ok:!0,url:e.url}}catch(r){return{backend:"reapi",durationMs:Date.now()-o,error:r instanceof Error?r.message:String(r),ok:!1,url:e.url}}finally{try{await a.close()}catch{}}},"probeReapi"),D=s(e=>{const t=[],o=e.ok?d("OK"):l("FAIL");if(t.push(`${g("Remote cache")} ${o}`),t.push(` ${n("URL:")} ${m(e.url)}`),t.push(` ${n("Backend:")} ${e.backend}`),t.push(` ${n("Latency:")} ${String(e.durationMs)}ms`),e.httpStatus!==void 0&&t.push(` ${n("Status:")} ${String(e.httpStatus)}`),e.capabilities){const a=e.capabilities.digestFunctions.length>0?e.capabilities.digestFunctions.join(", "):b("(none advertised)");t.push(` ${n("Digests:")} ${a}`),t.push(` ${n("Batch:")} ${String(e.capabilities.maxBatchTotalSizeBytes)} bytes`)}return e.error&&t.push(` ${n("Error:")} ${l(e.error)}`),t.join(`
2
- `)},"formatTable"),E=s(async({logger:e,options:t,visConfig:o})=>{const a=(o??{}).taskRunnerOptions?.remoteCache,r=t.url??a?.url,i=t.format??"table",u=t.timeout??5e3;if(!r){k.error("No remote cache configured. Set taskRunnerOptions.remoteCache.url in vis.config.ts or pass --url=..."),process.exitCode=1;return}const c=w(r,t.backend)==="reapi"?await S({...a??{url:r},backend:"reapi",url:r},u):await y(r,u);i==="json"?e.log(JSON.stringify(c,null,2)):e.log(D(c)),c.ok||(process.exitCode=1)},"cacheDoctorExecute");export{E as cacheDoctorExecute};
1
+ var h=Object.defineProperty;var p=(t,e)=>h(t,"name",{value:e,configurable:!0});import{c as d,d as l,j as g,E as n,q as b,e as m,p as f}from"./bin.js";import{ReapiRemoteCache as k}from"@visulima/task-runner";var $=Object.defineProperty,s=p((t,e)=>$(t,"name",{value:e,configurable:!0}),"s");const w=s((t,e)=>e==="http"||e==="reapi"?e:t.startsWith("grpc://")||t.startsWith("grpcs://")?"reapi":"http","inferBackend"),y=s(async(t,e)=>{const o=Date.now(),a=new AbortController,r=setTimeout(()=>{a.abort()},e);try{const i=await fetch(t,{method:"HEAD",signal:a.signal});return{backend:"http",durationMs:Date.now()-o,httpStatus:i.status,ok:!0,url:t}}catch(i){return{backend:"http",durationMs:Date.now()-o,error:i instanceof Error?i.message:String(i),ok:!1,url:t}}finally{clearTimeout(r)}},"probeHttp"),S=s(async(t,e)=>{const o=Date.now(),a=new k({...t,timeout:e});try{return{backend:"reapi",capabilities:await a.probeCapabilities(),durationMs:Date.now()-o,ok:!0,url:t.url}}catch(r){return{backend:"reapi",durationMs:Date.now()-o,error:r instanceof Error?r.message:String(r),ok:!1,url:t.url}}finally{try{await a.close()}catch{}}},"probeReapi"),D=s(t=>{const e=[],o=t.ok?d("OK"):l("FAIL");if(e.push(`${g("Remote cache")} ${o}`),e.push(` ${n("URL:")} ${b(t.url)}`),e.push(` ${n("Backend:")} ${t.backend}`),e.push(` ${n("Latency:")} ${String(t.durationMs)}ms`),t.httpStatus!==void 0&&e.push(` ${n("Status:")} ${String(t.httpStatus)}`),t.capabilities){const a=t.capabilities.digestFunctions.length>0?t.capabilities.digestFunctions.join(", "):m("(none advertised)");e.push(` ${n("Digests:")} ${a}`),e.push(` ${n("Batch:")} ${String(t.capabilities.maxBatchTotalSizeBytes)} bytes`)}return t.error&&e.push(` ${n("Error:")} ${l(t.error)}`),e.join(`
2
+ `)},"formatTable"),E=s(async({logger:t,options:e,visConfig:o})=>{const a=(o??{}).taskRunnerOptions?.remoteCache,r=e.url??a?.url,i=e.format??"table",u=e.timeout??5e3;if(!r){f.error("No remote cache configured. Set taskRunnerOptions.remoteCache.url in vis.config.ts or pass --url=..."),process.exitCode=1;return}const c=w(r,e.backend)==="reapi"?await S({...a??{url:r},backend:"reapi",url:r},u):await y(r,u);i==="json"?t.log(JSON.stringify(c,null,2)):t.log(D(c)),c.ok||(process.exitCode=1)},"cacheDoctorExecute");export{E as cacheDoctorExecute};
@@ -1,11 +1,11 @@
1
- var T=Object.defineProperty;var v=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createRequire as A}from"node:module";import{bold as y,dim as P,yellow as C,cyan as W,red as S,green as _}from"@visulima/colorize";import{relative as j}from"@visulima/path";import{r as B,a as L,b as M,c as w}from"../packem_shared/ai-fix-nn4zOE95.js";import{p}from"./bin.js";import{l as N}from"../packem_shared/failure-log-iUVLf6ts.js";const q=A(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=v(e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,r]=m.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return m.getBuiltinModule(e)}return q(e)},"__cjs_getBuiltinModule"),{createInterface:D}=J("node:readline");var U=Object.defineProperty,l=v((e,t)=>U(e,"name",{value:t,configurable:!0}),"c");const z={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},I=l((e,t,r)=>{const o=B(e,t,r),s=j(e,o);return s===""||s.startsWith("..")?o:s},"formatDisplayPath"),E=l((e,t,r)=>{const o=[y(`Fix proposal (${e.provider}, confidence: ${e.confidence})`),"",e.explanation||P("<no explanation>")];if(e.cannotFix)return o.push(""),o.push(C(`Cannot fix automatically: ${e.cannotFix}`)),o.join(`
2
- `);if(e.patches.length===0)return o.push(""),o.push(C("No patches were proposed.")),o.join(`
3
- `);o.push(""),o.push(y(`Patches (${String(e.patches.length)}):`));for(const[s,i]of e.patches.entries()){const a=I(t,r,i.file);o.push(""),o.push(W(`[${String(s+1)}] ${a}`)),i.reason&&o.push(P(` reason: ${i.reason}`));for(const c of i.oldString.split(`
4
- `))o.push(S(` - ${c}`));for(const c of i.newString.split(`
5
- `))o.push(_(` + ${c}`))}return o.join(`
6
- `)},"formatProposalText"),R=l((e,t,r)=>{const o=[];for(const s of e){const i=s.absolutePath?j(t,s.absolutePath)||s.absolutePath:I(t,r,s.patch.file),a=z[s.status];s.status==="applied"?o.push(_(` ✓ ${i}: ${a}`)):o.push(S(` ✗ ${i}: ${a}${s.error?` (${s.error})`:""}`))}return o.join(`
7
- `)},"formatPatchResultsText"),x=l(e=>{let t=0,r=0;for(const o of e)o.status==="applied"?t+=1:r+=1;return{applied:t,failed:r}},"summarizePatchResults"),G=l(e=>new Promise(t=>{const r=D({input:process.stdin,output:process.stderr});r.question(`${e} (y/N) `,o=>{r.close();const s=o.trim().toLowerCase();t(s==="y"||s==="yes")})}),"confirmPrompt"),H=l(e=>e??process.cwd(),"resolveWorkspaceRoot"),et=l(async({argument:e,logger:t,options:r,visConfig:o,workspaceRoot:s})=>{const i=e[0],a=H(s),c=(r.format??"text")==="json";if(!i){if(c){const d=N(a);process.stdout.write(`${JSON.stringify({availableTasks:d,error:"No task ID specified"},void 0,2)}
8
- `)}else{p.error("No task ID specified. Usage: vis ai fix <project>:<target>");const d=N(a);if(d.length>0){p.info("Tasks with captured failure logs:");for(const h of d)p.info(` - ${h}`)}else p.notice("No failure logs found. Re-run a failing task with `vis run` to capture logs.")}process.exitCode=1;return}const n=await L(a,i,{runId:r.run});if(!n){c?process.stdout.write(`${JSON.stringify({error:"No failure log or run summary found",taskId:i},void 0,2)}
9
- `):(p.error(`No failure log or run summary found for task "${i}".`),p.notice("Re-run the task with `vis run` so its terminal output and run metadata are captured.")),process.exitCode=1;return}n.terminalOutputCaptured||p.warn(`No captured terminal output for "${i}". Re-run with \`vis run\` for a better fix proposal.`);const F=o?.ai,u=await M(n,t,{cache:r.noCache!==!0,config:F});if(!u){c&&process.stdout.write(`${JSON.stringify({error:"AI fix proposal failed or no provider available",taskId:i},void 0,2)}
10
- `),process.exitCode=1;return}const g=r.apply===!0;if(c){const d=g?void 0:await w(a,n.cwd,u,{dryRun:!0}),h=g?await w(a,n.cwd,u):void 0;if(process.stdout.write(`${JSON.stringify({appliedResults:h,dryRunResults:d,failureContext:{cwd:n.cwd,hash:n.hash,runId:n.runId,taskId:n.taskId,terminalOutputCaptured:n.terminalOutputCaptured},proposal:u},void 0,2)}
11
- `),g&&h){const{failed:O}=x(h);O>0&&(process.exitCode=1)}return}if(t.info(E(u,a,n.cwd)),u.cannotFix||u.patches.length===0)return;const b=await w(a,n.cwd,u,{dryRun:!0}),$=x(b);if(t.info(""),t.info(y("Patch validation:")),t.info(R(b,a,n.cwd)),!g){t.info(""),p.info("Re-run with --apply to write these patches to disk.");return}if($.applied===0){p.error("No patches can be applied (every patch failed validation)."),process.exitCode=1;return}if(r.yes!==!0&&(t.info(""),!await G(`Apply ${String($.applied)} patch${$.applied===1?"":"es"} to disk?`))){p.notice("Aborted. Nothing written.");return}const k=await w(a,n.cwd,u),f=x(k);t.info(""),t.info(y("Apply results:")),t.info(R(k,a,n.cwd)),t.info(""),f.failed===0?p.success(`Applied ${String(f.applied)} patch${f.applied===1?"":"es"}.`):(p.warn(`${String(f.applied)} applied, ${String(f.failed)} failed.`),process.exitCode=1)},"aiFix");export{et as aiFix};
1
+ var T=Object.defineProperty;var v=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createRequire as q}from"node:module";import{j as $,E as P,e as R,q as D,d as j,c as I,p}from"./bin.js";import{z as _}from"../packem_shared/index-OlP7U_t5.js";import{r as W,a as B,b as L,c as w}from"../packem_shared/ai-fix-BmLM72GS.js";import{l as N}from"../packem_shared/failure-log-fD4DiFb1.js";const A=q(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=v(e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,r]=m.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return m.getBuiltinModule(e)}return A(e)},"__cjs_getBuiltinModule"),{createInterface:z}=J("node:readline");var M=Object.defineProperty,l=v((e,t)=>M(e,"name",{value:t,configurable:!0}),"c");const U={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},S=l((e,t,r)=>{const o=W(e,t,r),s=_(e,o);return s===""||s.startsWith("..")?o:s},"formatDisplayPath"),E=l((e,t,r)=>{const o=[$(`Fix proposal (${e.provider}, confidence: ${e.confidence})`),"",e.explanation||P("<no explanation>")];if(e.cannotFix)return o.push(""),o.push(R(`Cannot fix automatically: ${e.cannotFix}`)),o.join(`
2
+ `);if(e.patches.length===0)return o.push(""),o.push(R("No patches were proposed.")),o.join(`
3
+ `);o.push(""),o.push($(`Patches (${String(e.patches.length)}):`));for(const[s,i]of e.patches.entries()){const a=S(t,r,i.file);o.push(""),o.push(D(`[${String(s+1)}] ${a}`)),i.reason&&o.push(P(` reason: ${i.reason}`));for(const u of i.oldString.split(`
4
+ `))o.push(j(` - ${u}`));for(const u of i.newString.split(`
5
+ `))o.push(I(` + ${u}`))}return o.join(`
6
+ `)},"formatProposalText"),C=l((e,t,r)=>{const o=[];for(const s of e){const i=s.absolutePath?_(t,s.absolutePath)||s.absolutePath:S(t,r,s.patch.file),a=U[s.status];s.status==="applied"?o.push(I(` ✓ ${i}: ${a}`)):o.push(j(` ✗ ${i}: ${a}${s.error?` (${s.error})`:""}`))}return o.join(`
7
+ `)},"formatPatchResultsText"),x=l(e=>{let t=0,r=0;for(const o of e)o.status==="applied"?t+=1:r+=1;return{applied:t,failed:r}},"summarizePatchResults"),G=l(e=>new Promise(t=>{const r=z({input:process.stdin,output:process.stderr});r.question(`${e} (y/N) `,o=>{r.close();const s=o.trim().toLowerCase();t(s==="y"||s==="yes")})}),"confirmPrompt"),H=l(e=>e??process.cwd(),"resolveWorkspaceRoot"),tt=l(async({argument:e,logger:t,options:r,visConfig:o,workspaceRoot:s})=>{const i=e[0],a=H(s),u=(r.format??"text")==="json";if(!i){if(u){const d=N(a);process.stdout.write(`${JSON.stringify({availableTasks:d,error:"No task ID specified"},void 0,2)}
8
+ `)}else{p.error("No task ID specified. Usage: vis ai fix <project>:<target>");const d=N(a);if(d.length>0){p.info("Tasks with captured failure logs:");for(const h of d)p.info(` - ${h}`)}else p.notice("No failure logs found. Re-run a failing task with `vis run` to capture logs.")}process.exitCode=1;return}const n=await B(a,i,{runId:r.run});if(!n){u?process.stdout.write(`${JSON.stringify({error:"No failure log or run summary found",taskId:i},void 0,2)}
9
+ `):(p.error(`No failure log or run summary found for task "${i}".`),p.notice("Re-run the task with `vis run` so its terminal output and run metadata are captured.")),process.exitCode=1;return}n.terminalOutputCaptured||p.warn(`No captured terminal output for "${i}". Re-run with \`vis run\` for a better fix proposal.`);const F=o?.ai,c=await L(n,t,{cache:r.cache!==!1,config:F});if(!c){u&&process.stdout.write(`${JSON.stringify({error:"AI fix proposal failed or no provider available",taskId:i},void 0,2)}
10
+ `),process.exitCode=1;return}const g=r.apply===!0;if(u){const d=g?void 0:await w(a,n.cwd,c,{dryRun:!0}),h=g?await w(a,n.cwd,c):void 0;if(process.stdout.write(`${JSON.stringify({appliedResults:h,dryRunResults:d,failureContext:{cwd:n.cwd,hash:n.hash,runId:n.runId,taskId:n.taskId,terminalOutputCaptured:n.terminalOutputCaptured},proposal:c},void 0,2)}
11
+ `),g&&h){const{failed:O}=x(h);O>0&&(process.exitCode=1)}return}if(t.info(E(c,a,n.cwd)),c.cannotFix||c.patches.length===0)return;const k=await w(a,n.cwd,c,{dryRun:!0}),y=x(k);if(t.info(""),t.info($("Patch validation:")),t.info(C(k,a,n.cwd)),!g){t.info(""),p.info("Re-run with --apply to write these patches to disk.");return}if(y.applied===0){p.error("No patches can be applied (every patch failed validation)."),process.exitCode=1;return}if(r.yes!==!0&&(t.info(""),!await G(`Apply ${String(y.applied)} patch${y.applied===1?"":"es"} to disk?`))){p.notice("Aborted. Nothing written.");return}const b=await w(a,n.cwd,c),f=x(b);t.info(""),t.info($("Apply results:")),t.info(C(b,a,n.cwd)),t.info(""),f.failed===0?p.success(`Applied ${String(f.applied)} patch${f.applied===1?"":"es"}.`):(p.warn(`${String(f.applied)} applied, ${String(f.failed)} failed.`),process.exitCode=1)},"aiFix");export{tt as aiFix};
@@ -1 +1 @@
1
- var O=Object.defineProperty;var w=(o,e)=>O(o,"name",{value:e,configurable:!0});import{createTaskGraph as b}from"@visulima/task-runner";import{k as E,y as R}from"./bin.js";import{r as x,f as G}from"../packem_shared/selectors-BylODRiM.js";var J=Object.defineProperty,m=w((o,e)=>J(o,"name",{value:e,configurable:!0}),"u");const P=m((o,e,n)=>{const c=[],t=new Set,l=m((r,f)=>{if(t.has(r))return;t.add(r);const s=e[r]??[];for(const i of s)l(i,f+1);const d=n[r],u=" ".repeat(f);c.push(`${u}${r}${d?.cache===!1?" (no-cache)":""}`)},"walk");for(const r of o)l(r,0);return c},"renderPlan"),S=m((o,e,n)=>({roots:o,tasks:Object.fromEntries(Object.entries(n).map(([c,t])=>[c,{cache:t.cache,dependsOn:e[c]??[],outputs:t.outputs,parallelism:t.parallelism,projectRoot:t.projectRoot,target:t.target}]))}),"toJson"),T=m(async({argument:o,logger:e,options:n,visConfig:c,workspaceRoot:t})=>{const l=o[0];if(!l)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!t)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:r,packageJsons:f,workspace:s}=E(t,c),d=R(t,s,f),u=await x(l,s,process.cwd(),t),{target:i}=u;let h=u.projects;n.query&&(h=G(h,s,n.query));const j=h.filter(p=>s.projects[p]?.targets?.[i]!==void 0);if(j.length===0){e.info(`No projects have a "${i}" target.`);return}const y=j.map(p=>{const k=s.projects[p],g=k.targets?.[i],$={project:p,target:i};return{cache:g?.cache,id:`${p}:${i}`,outputs:g?.outputs??[],overrides:{command:g?.command},parallelism:g?.parallelism,projectRoot:k.root,target:$}}),a=b(y,{projectGraph:d,targetDefaults:r.targetDefaults,workspace:s});if(n.json){e.info(JSON.stringify(S(a.roots,a.dependencies,a.tasks),null,2));return}const v=P(a.roots,a.dependencies,a.tasks);e.info(`Execution plan (${Object.keys(a.tasks).length} task(s), ${a.roots.length} root(s)):`),e.info("");for(const p of v)e.info(p)},"execute");export{T as default};
1
+ var O=Object.defineProperty;var w=(o,e)=>O(o,"name",{value:e,configurable:!0});import{createTaskGraph as b}from"@visulima/task-runner";import{y as E,m as R}from"./bin.js";import{r as x,f as G}from"../packem_shared/selectors-BvtUXWGY.js";var J=Object.defineProperty,m=w((o,e)=>J(o,"name",{value:e,configurable:!0}),"u");const P=m((o,e,n)=>{const c=[],t=new Set,l=m((r,f)=>{if(t.has(r))return;t.add(r);const s=e[r]??[];for(const i of s)l(i,f+1);const d=n[r],u=" ".repeat(f);c.push(`${u}${r}${d?.cache===!1?" (no-cache)":""}`)},"walk");for(const r of o)l(r,0);return c},"renderPlan"),S=m((o,e,n)=>({roots:o,tasks:Object.fromEntries(Object.entries(n).map(([c,t])=>[c,{cache:t.cache,dependsOn:e[c]??[],outputs:t.outputs,parallelism:t.parallelism,projectRoot:t.projectRoot,target:t.target}]))}),"toJson"),T=m(async({argument:o,logger:e,options:n,visConfig:c,workspaceRoot:t})=>{const l=o[0];if(!l)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!t)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:r,packageJsons:f,workspace:s}=E(t,c),d=R(t,s,f),u=await x(l,s,process.cwd(),t),{target:i}=u;let h=u.projects;n.query&&(h=G(h,s,n.query));const j=h.filter(p=>s.projects[p]?.targets?.[i]!==void 0);if(j.length===0){e.info(`No projects have a "${i}" target.`);return}const y=j.map(p=>{const k=s.projects[p],g=k.targets?.[i],$={project:p,target:i};return{cache:g?.cache,id:`${p}:${i}`,outputs:g?.outputs??[],overrides:{command:g?.command},parallelism:g?.parallelism,projectRoot:k.root,target:$}}),a=b(y,{projectGraph:d,targetDefaults:r.targetDefaults,workspace:s});if(n.json){e.info(JSON.stringify(S(a.roots,a.dependencies,a.tasks),null,2));return}const v=P(a.roots,a.dependencies,a.tasks);e.info(`Execution plan (${Object.keys(a.tasks).length} task(s), ${a.roots.length} root(s)):`),e.info("");for(const p of v)e.info(p)},"execute");export{T as default};
@@ -1,2 +1,2 @@
1
- var k=Object.defineProperty;var p=(t,o)=>k(t,"name",{value:o,configurable:!0});import{join as d}from"@visulima/path";import{k as g,y as v}from"./bin.js";import{s as h,p as j}from"../packem_shared/docker-D6OGr5_S.js";var x=Object.defineProperty,E=p((t,o)=>x(t,"name",{value:o,configurable:!0}),"f");const C=E(async({argument:t,logger:o,options:s,visConfig:l,workspaceRoot:e})=>{const n=t[0];if(!n)throw new Error("Missing subcommand. Usage: vis docker <scaffold|prune>");if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:m,workspace:c}=g(e,l);if(n==="scaffold"){const a=v(e,c,m),r=s.focus;if(!r)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const i=r.split(",").map(w=>w.trim()).filter(Boolean);if(i.length===0)throw new Error("--focus resolved to an empty list. Provide at least one project name.");const f=d(e,s.out??".vis/docker"),{projects:u}=h({focus:i,includeSources:!!s.includeSources,outDir:f,projectGraph:a,workspace:c,workspaceRoot:e});o.info(`Scaffolded ${u.length} project(s) into ${f}`),o.info(`Focus closure: ${u.toSorted().join(", ")}`);return}if(n==="prune"){const a=d(e,s.context??".vis/docker"),{removed:r}=j({contextRoot:a,workspace:c,workspaceRoot:e});o.info(`Pruned ${r.length} unfocused project(s)`),r.length>0&&o.debug?.(r.join(`
1
+ var g=Object.defineProperty;var p=(t,o)=>g(t,"name",{value:o,configurable:!0});import{M as d}from"../packem_shared/index-OlP7U_t5.js";import{y as k,m as v}from"./bin.js";import{s as h,p as j}from"../packem_shared/docker-CA-scYu0.js";var x=Object.defineProperty,E=p((t,o)=>x(t,"name",{value:o,configurable:!0}),"f");const C=E(async({argument:t,logger:o,options:s,visConfig:m,workspaceRoot:e})=>{const n=t[0];if(!n)throw new Error("Missing subcommand. Usage: vis docker <scaffold|prune>");if(!e)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:l,workspace:c}=k(e,m);if(n==="scaffold"){const a=v(e,c,l),r=s.focus;if(!r)throw new Error("Missing --focus. Pass one or more project names, comma-separated.");const i=r.split(",").map(w=>w.trim()).filter(Boolean);if(i.length===0)throw new Error("--focus resolved to an empty list. Provide at least one project name.");const f=d(e,s.out??".vis/docker"),{projects:u}=h({focus:i,includeSources:!!s.includeSources,outDir:f,projectGraph:a,workspace:c,workspaceRoot:e});o.info(`Scaffolded ${u.length} project(s) into ${f}`),o.info(`Focus closure: ${u.toSorted().join(", ")}`);return}if(n==="prune"){const a=d(e,s.context??".vis/docker"),{removed:r}=j({contextRoot:a,workspace:c,workspaceRoot:e});o.info(`Pruned ${r.length} unfocused project(s)`),r.length>0&&o.debug?.(r.join(`
2
2
  `));return}throw new Error(`Unknown subcommand: "${n}". Expected scaffold or prune.`)},"execute");export{C as default};
@@ -1 +1 @@
1
- var m=Object.defineProperty;var t=(o,r)=>m(o,"name",{value:r,configurable:!0});import{m as d,P as g}from"./bin.js";import{o as u}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,k=t((o,r)=>v(o,"name",{value:r,configurable:!0}),"t");const b=k(async({argument:o,logger:r,options:e,visConfig:s,workspaceRoot:n})=>{const a=o;if(!a||a.length===0)throw new Error("No command specified. Usage: vis exec <command> [args...]");const[i,...f]=a,l=n??process.cwd(),p=d(l,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),c=g(p,{args:f,command:i,filter:u(e.filter),parallel:e.parallel||!1,recursive:e.recursive||!1,reverse:e.reverse||!1,shellMode:e.shellMode||!1,workspaceRoot:e.workspaceRoot||!1},l,r);c!==0&&(process.exitCode=c)},"execute");export{b as default};
1
+ var d=Object.defineProperty;var t=(o,r)=>d(o,"name",{value:r,configurable:!0});import{h as m,P as g}from"./bin.js";import{o as u}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,k=t((o,r)=>v(o,"name",{value:r,configurable:!0}),"t");const b=k(async({argument:o,logger:r,options:e,visConfig:s,workspaceRoot:n})=>{const a=o;if(!a||a.length===0)throw new Error("No command specified. Usage: vis exec <command> [args...]");const[i,...f]=a,l=n??process.cwd(),p=m(l,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),c=g(p,{args:f,command:i,filter:u(e.filter),parallel:e.parallel||!1,recursive:e.recursive||!1,reverse:e.reverse||!1,shellMode:e.shellMode||!1,workspaceRoot:e.workspaceRoot||!1},l,r);c!==0&&(process.exitCode=c)},"execute");export{b as default};
@@ -1,5 +1,5 @@
1
- var g=Object.defineProperty;var a=(e,i)=>g(e,"name",{value:i,configurable:!0});import{createRequire as y}from"node:module";import{isAccessibleSync as u,readFileSync as p,writeFileSync as j}from"@visulima/fs";import{join as r}from"@visulima/path";const _=y(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=a(e=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[i,s]=c.versions.node.split(".").map(Number);if(i>22||i===22&&s>=3||i===20&&s>=16)return c.getBuiltinModule(e)}return _(e)},"__cjs_getBuiltinModule"),{rmSync:b}=d("node:fs"),{homedir:o}=d("node:os"),{createInterface:w}=d("node:readline");var S=Object.defineProperty,m=a((e,i)=>S(e,"name",{value:i,configurable:!0}),"l");const f=r(o(),".vis"),h=[r(o(),".zshrc"),r(o(),".zshenv"),r(o(),".bashrc"),r(o(),".bash_profile"),r(o(),".profile"),r(o(),".config","fish","config.fish")],T=m(e=>{const i=[];for(const s of h)if(u(s))try{const l=p(s).split(`
2
- `),n=l.filter(t=>!t.includes(".vis/bin")&&!t.includes("VIS_HOME")&&!t.includes("# vis "));n.length!==l.length&&(j(s,n.join(`
3
- `)),i.push(s))}catch{e.warn(`warning: could not clean ${s}`)}return i},"cleanShellProfiles"),F=m(async({logger:e,options:i})=>{if(!u(f)){e.info("vis is not installed (no ~/.vis directory found).");return}e.info("This will remove:"),e.info(` ${f}/`);const s=h.filter(n=>u(n)&&p(n).includes(".vis"));for(const n of s)e.info(` Lines in ${n}`);if(!i.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const n=w({input:process.stdin,output:process.stdout}),t=await new Promise(v=>{n.question(`
4
- Type "uninstall" to confirm: `,v)});if(n.close(),t.trim()!=="uninstall"){e.info("Aborted.");return}}const l=T(e);for(const n of l)e.info(`Cleaned ${n}`);try{b(f,{force:!0,recursive:!0}),e.info(`
5
- ✓ Removed ${f}`)}catch(n){throw new Error(`Failed to remove ${f}: ${n instanceof Error?n.message:String(n)}`,{cause:n})}e.info("✓ vis has been uninstalled.")},"execute");export{F as default};
1
+ var g=Object.defineProperty;var a=(e,i)=>g(e,"name",{value:i,configurable:!0});import{createRequire as y}from"node:module";import{isAccessibleSync as u,readFileSync as p,writeFileSync as S}from"@visulima/fs";import{M as r}from"../packem_shared/index-OlP7U_t5.js";import{l as j}from"./bin.js";const _=y(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=a(e=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[i,s]=c.versions.node.split(".").map(Number);if(i>22||i===22&&s>=3||i===20&&s>=16)return c.getBuiltinModule(e)}return _(e)},"__cjs_getBuiltinModule"),{rmSync:b}=d("node:fs"),{homedir:n}=d("node:os"),{createInterface:w}=d("node:readline");var T=Object.defineProperty,m=a((e,i)=>T(e,"name",{value:i,configurable:!0}),"l");const f=j(),h=[r(n(),".zshrc"),r(n(),".zshenv"),r(n(),".bashrc"),r(n(),".bash_profile"),r(n(),".profile"),r(n(),".config","fish","config.fish")],$=m(e=>{const i=[];for(const s of h)if(u(s))try{const l=p(s).split(`
2
+ `),o=l.filter(t=>!t.includes(".vis/bin")&&!t.includes("VIS_HOME")&&!t.includes("# vis "));o.length!==l.length&&(S(s,o.join(`
3
+ `)),i.push(s))}catch{e.warn(`warning: could not clean ${s}`)}return i},"cleanShellProfiles"),R=m(async({logger:e,options:i})=>{if(!u(f)){e.info("vis is not installed (no ~/.vis directory found).");return}e.info("This will remove:"),e.info(` ${f}/`);const s=h.filter(o=>u(o)&&p(o).includes(".vis"));for(const o of s)e.info(` Lines in ${o}`);if(!i.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const o=w({input:process.stdin,output:process.stdout}),t=await new Promise(v=>{o.question(`
4
+ Type "uninstall" to confirm: `,v)});if(o.close(),t.trim()!=="uninstall"){e.info("Aborted.");return}}const l=$(e);for(const o of l)e.info(`Cleaned ${o}`);try{b(f,{force:!0,recursive:!0}),e.info(`
5
+ ✓ Removed ${f}`)}catch(o){throw new Error(`Failed to remove ${f}: ${o instanceof Error?o.message:String(o)}`,{cause:o})}e.info("✓ vis has been uninstalled.")},"execute");export{R as default};
@@ -1 +1 @@
1
- var l=Object.defineProperty;var r=(e,a)=>l(e,"name",{value:a,configurable:!0});import{m as g,D as d}from"./bin.js";var k=Object.defineProperty,m=r((e,a)=>k(e,"name",{value:a,configurable:!0}),"t");const w=m(async({argument:e,logger:a,options:c,visConfig:s,workspaceRoot:i})=>{if(!e||e.length===0)throw new Error("No package specified. Usage: vis info <package> [field...]");const[t,...f]=e,n=i??process.cwd(),p=g(n,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),o=d(p,{fields:f,json:c.json||!1,package:t},n,a);o!==0&&o!==1&&(process.exitCode=o)},"execute");export{w as default};
1
+ var l=Object.defineProperty;var r=(e,a)=>l(e,"name",{value:a,configurable:!0});import{h as g,D as d}from"./bin.js";var k=Object.defineProperty,u=r((e,a)=>k(e,"name",{value:a,configurable:!0}),"t");const w=u(async({argument:e,logger:a,options:c,visConfig:s,workspaceRoot:i})=>{if(!e||e.length===0)throw new Error("No package specified. Usage: vis info <package> [field...]");const[t,...f]=e,n=i??process.cwd(),p=g(n,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),o=d(p,{fields:f,json:c.json||!1,package:t},n,a);o!==0&&o!==1&&(process.exitCode=o)},"execute");export{w as default};
@@ -1,18 +1,20 @@
1
- var G=Object.defineProperty;var E=(e,r)=>G(e,"name",{value:r,configurable:!0});import{createRequire as K}from"node:module";import{isAccessibleSync as S}from"@visulima/fs";import{formatBytes as w}from"@visulima/humanizer";import{join as C,relative as te}from"@visulima/path";import{Cache as x,parseCacheSize as se,readLastRunSummary as L,getLastRunSummaryPath as oe,digestFile as F}from"@visulima/task-runner";import{B as re,J as R}from"../packem_shared/ai-cache-DoiF80AR.js";import{m as ae,E as A}from"../packem_shared/cache-directory-CwHlJhgx.js";import{p as i,H as ie,J as z}from"./bin.js";import{r as W,f as M,a as ne,d as ce}from"../packem_shared/run-summary-utils-BfBvjzhY.js";const Q=K(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=E(e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[r,t]=v.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return v.getBuiltinModule(e)}return Q(e)},"__cjs_getBuiltinModule"),{readdir:j,stat:D,realpath:O,rm:B,mkdtemp:X}=b("node:fs/promises"),{tmpdir:Z}=b("node:os"),{createInterface:ee}=b("node:readline");var he=Object.defineProperty,f=E((e,r)=>he(e,"name",{value:r,configurable:!0}),"f");const _=f(async e=>{let r=0;try{const t=await j(e,{withFileTypes:!0});for(const o of t){const s=C(e,o.name);if(o.isDirectory())r+=await _(s);else if(o.isFile()){const a=await D(s);r+=a.size}}}catch{}return r},"sumDirectorySize"),$=f(async e=>{const r=[];let t;try{t=await j(e)}catch{return[]}for(const o of t){if(o.startsWith("."))continue;const s=C(e,o);try{const a=await D(s);if(!a.isDirectory())continue;const n=await _(s);r.push({hash:o,mtimeMs:a.mtimeMs,path:s,sizeBytes:n})}catch{}}return r.sort((o,s)=>s.mtimeMs-o.mtimeMs),r},"collectCacheEntries"),de=f((e,r=Date.now())=>{const t=Math.max(0,Math.floor((r-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"),ue=f(e=>new Promise(r=>{const t=ee({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,o=>{t.close();const s=o.trim().toLowerCase();r(s==="y"||s==="yes")})}),"confirmPrompt"),fe=f(async(e,r,t)=>{if(!S(e)){if(r==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
2
- `);return}i.info(`No cache directory found at ${e}`);return}const o=await $(e);if(o.length===0){if(r==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
3
- `);return}i.info(`Cache directory is empty: ${e}`);return}const s=o.reduce((c,d)=>c+d.sizeBytes,0);if(r==="json"){const c=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:o.map(d=>({ageMs:c-d.mtimeMs,hash:d.hash,mtimeIso:new Date(d.mtimeMs).toISOString(),sizeBytes:d.sizeBytes})),totalBytes:s,totalCount:o.length},void 0,2)}
4
- `);return}i.info(`Cache directory: ${e}`),i.info(`Entries: ${String(o.length)} (${w(s,{decimals:1,space:!1})})`),t.info("");const a=Date.now(),n=o.map(c=>({age:de(c.mtimeMs,a),hash:c.hash.slice(0,12),size:w(c.sizeBytes,{decimals:1,space:!1})})),h=Math.max(4,...n.map(c=>c.hash.length)),m=Math.max(4,...n.map(c=>c.size.length)),u=Math.max(3,...n.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 n)t.info(` ${c.hash.padEnd(h)} ${c.size.padEnd(m)} ${c.age.padEnd(u)}`)},"runList"),le=f(()=>{try{const e=re();e>0&&i.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){i.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},"clearAiCacheSafe"),me=f(()=>{try{const e=ie();e>0&&i.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){i.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},"clearSocketCacheSafe"),pe=f(async(e,r,t)=>{if(!S(e)){i.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const s=await $(e),a=s.reduce((n,h)=>n+h.sizeBytes,0);i.info(`Would remove ${String(s.length)} cache entr${s.length===1?"y":"ies"} (${w(a,{decimals:1,space:!1})}) from ${e}`);return}const o=ae(e,r);try{const s=await O(e),a=await O(r);if(s===a){i.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!o&&!t.force){if(i.warn(`Cache directory is outside the workspace root: ${e}`),i.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){i.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await ue(" Continue?")){i.info("Aborted.");return}}o?await new x({cacheDirectory:e,workspaceRoot:r}).clear():await B(e,{force:!0,recursive:!0}),i.success(`Cleared cache: ${e}`)},"runClean"),ye=f(async(e,r,t)=>{if(!S(e)){i.info(`No cache directory to prune at ${e}`);return}if(t.maxCacheAgeDays!==void 0&&(!Number.isFinite(t.maxCacheAgeDays)||t.maxCacheAgeDays<0)){i.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))){i.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=se(t.maxCacheSize)}catch(d){i.error(`Invalid --max-size value: ${d instanceof Error?d.message:String(d)}`),process.exitCode=1;return}if(!Number.isFinite(c)||c<=0){i.error(`Invalid --max-size value: expected a positive size, got "${t.maxCacheSize}" (${String(c)} bytes)`),process.exitCode=1;return}}const o=t.maxCacheAgeDays===void 0?void 0:t.maxCacheAgeDays*24*60*60*1e3,s=await $(e),a=s.reduce((c,d)=>c+d.sizeBytes,0);if(t.keepLast!==void 0&&s.length>t.keepLast){const c=s.slice(t.keepLast);await Promise.all(c.map(d=>B(d.path,{force:!0,recursive:!0})))}await new x({cacheDirectory:e,maxCacheAge:o,maxCacheSize:t.maxCacheSize,workspaceRoot:r}).removeOldEntries();const n=await $(e),h=n.reduce((c,d)=>c+d.sizeBytes,0),m=s.length-n.length,u=a-h;if(m<=0){i.info("Nothing to prune — all entries are within the configured limits.");return}i.success(`Pruned ${String(m)} entr${m===1?"y":"ies"}, freed ${w(u,{decimals:1,space:!1})}.`)},"runPrune"),T=16,H=f(e=>e.length>T?`${e.slice(0,T)}…`:e,"truncateHash"),N=f((e,r,t)=>{const o=Object.entries(r??{});if(o.length!==0){t.info(` ${e}:`),o.sort(([s],[a])=>s.localeCompare(a));for(const[s,a]of o)t.info(` ${s.padEnd(40)} ${H(a)}`)}},"renderHashDetailsBucket"),ge=f(async(e,r,t)=>{const{format:o,runId:s,workspaceRoot:a}=r,n=s===void 0?await L(a):await W(a,s);if(!n){if(o==="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?i.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):i.error(`Run summary "${s}" not found in .task-runner/runs/.`),process.exitCode=1;return}const h=M(n,e);if(!h){if(o==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:n.id,taskId:e},void 0,2)}
6
- `),process.exitCode=1;return}i.error(`Task "${e}" was not part of run ${n.id}.`),i.info(`Tasks in this run: ${n.tasks.map(d=>d.taskId).join(", ")||"(none)"}`),process.exitCode=1;return}const m=await ne(a,n.id),u=m?M(m,e):void 0,c=ce(h.hashDetails,u?.hashDetails);if(o==="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:n.id,task:{cacheStatus:h.cacheStatus,hash:h.hash??null,hashDetails:h.hashDetails??null,taskId:h.taskId}},void 0,2)}
7
- `);return}if(i.info(`Why ${e}? (run ${n.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){i.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){i.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 d of["nodes","runtime","implicitDeps"]){const l=c[d];if(!(l.added.length===0&&l.changed.length===0&&l.removed.length===0)){t.info(` ${d}:`);for(const p of l.added)t.info(` + ${p}`);for(const p of l.changed)t.info(` ~ ${p}`);for(const p of l.removed)t.info(` - ${p}`)}}t.info(""),i.info(`Last summary file: ${oe(a)}`)},"runWhy"),we=f(async(e,r,t)=>{const{format:o,runId:s,workspaceRoot:a}=r,n=s===void 0?await L(a):await W(a,s);if(!n){if(o==="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?i.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):i.error(`Run summary "${s}" not found in .task-runner/runs/.`),process.exitCode=1;return}const h=M(n,e);if(!h){if(o==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:n.id,taskId:e},void 0,2)}
9
- `),process.exitCode=1;return}i.error(`Task "${e}" was not part of run ${n.id}.`),process.exitCode=1;return}if(o==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:h.cacheStatus,hash:h.hash??null,hashDetails:h.hashDetails??null,runId:n.id,taskId:h.taskId},void 0,2)}
10
- `);return}i.info(`Hash for ${e} (run ${n.id})`),t.info(""),t.info(` status: ${h.cacheStatus}`),t.info(` hash: ${h.hash??"(none)"}`),h.hashDetails?(t.info(""),t.info(` command: ${H(h.hashDetails.command)}`),N("nodes",h.hashDetails.nodes,t),N("runtime",h.hashDetails.runtime,t),N("implicitDeps",h.hashDetails.implicitDeps,t)):(t.info(""),i.info("No hash details recorded for this task."))},"runHash"),$e=f(async(e,r)=>{if(!S(e)){if(r==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
11
- `);return}i.info(`No cache directory at ${e}`);return}const t=await $(e),o=t.reduce((s,a)=>s+a.sizeBytes,0);if(r==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:o,totalCount:t.length})}
12
- `);return}i.info(`Cache directory: ${e}`),i.info(`Entries: ${String(t.length)}`),i.info(`Total size: ${w(o,{decimals:1,space:!1})}`)},"runSize"),ke=f(async e=>{const r=[],t=f(async o=>{const s=(await j(o,{withFileTypes:!0})).toSorted((a,n)=>a.name.localeCompare(n.name));for(const a of s){const n=C(o,a.name);if(a.isDirectory()){await t(n);continue}if(!a.isFile())continue;const[h,m]=await Promise.all([D(n),F(n)]);r.push({hash:m?.hash??"",mode:h.mode&4095,mtimeMs:h.mtimeMs,relativePath:te(e,n).replaceAll("\\","/"),sizeBytes:h.size})}},"walk");return await t(e),r},"walkAndDigest"),ve=f((e,r)=>Math.floor(e/1e3)===Math.floor(r/1e3),"compareSecondsTruncated"),J=16,Se=f(async(e,r)=>{const t=C(r,e.relativePath),o=await D(t).catch(()=>{});if(!o)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const s=await F(t),a=[];(s?.hash??"")!==e.hash&&a.push("content");const n=o.mode&4095;if(process.platform!=="win32"&&n!==e.mode&&a.push("mode"),ve(o.mtimeMs,e.mtimeMs)||a.push("mtime"),a.length!==0)return{actual:{hash:s?.hash,mode:n,mtimeMs:o.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:a,relativePath:e.relativePath}},"computeFileDiff"),Ce=f(async(e,r,t)=>{const{cacheDirectories:o,format:s,workspaceRoot:a}=r;if(o.length===0){s==="json"?process.stdout.write(`${JSON.stringify({error:"no-cache-directory",taskId:e},void 0,2)}
13
- `):i.error("No cache directory resolved — pass --cache-dir or run inside a workspace."),process.exitCode=1;return}let n,h;for(const u of o){const c=await new x({cacheDirectory:u,workspaceRoot:a}).getByTaskId(e);if(c){n=u,h=c;break}}if(!h||!n){s==="json"?process.stdout.write(`${JSON.stringify({error:"no-cached-entry",searchedCaches:o,taskId:e},void 0,2)}
14
- `):i.error(`No cached entry found for task "${e}". Run it once before verifying.`),process.exitCode=1;return}const m=await X(C(Z(),"vis-cache-verify-"));try{if(!await new x({cacheDirectory:n,workspaceRoot:m}).restoreOutputs(h.hash)){s==="json"?process.stdout.write(`${JSON.stringify({error:"restore-failed",hash:h.hash,taskId:e},void 0,2)}
15
- `):i.error(`Cache restore failed for ${e} (hash ${h.hash}).`),process.exitCode=1;return}const u=await ke(m);if(u.length===0){s==="json"?process.stdout.write(`${JSON.stringify({diffs:[],hash:h.hash,status:"no-outputs",taskId:e},void 0,2)}
16
- `):i.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const c=Array.from({length:u.length});for(let l=0;l<u.length;l+=J){const p=u.slice(l,l+J),q=await Promise.all(p.map(async I=>Se(I,a)));for(const[I,Y]of q.entries())c[l+I]=Y}const d=c.filter(l=>l!==void 0);if(s==="json"){process.stdout.write(`${JSON.stringify({cachedFileCount:u.length,cacheDirectory:n,diffs:d,hash:h.hash,status:d.length===0?"ok":"drift",taskId:e},void 0,2)}
17
- `),d.length>0&&(process.exitCode=1);return}if(i.info(`Verify ${e} (hash ${h.hash})`),t.info(""),t.info(` cache: ${n}`),t.info(` files: ${String(u.length)}`),d.length===0){t.info(""),i.success("Cache restore is faithful — all files match content, mode, and mtime.");return}t.info(` drift: ${String(d.length)} file(s)`),t.info("");for(const l of d){const p=l.issues.includes("missing")?"MISSING":l.issues.join(",").toUpperCase();t.info(` [${p}] ${l.relativePath}`),!l.issues.includes("missing")&&l.expected&&l.actual&&(l.issues.includes("content")&&(t.info(` expected hash: ${l.expected.hash||"(none)"}`),t.info(` actual hash: ${l.actual.hash??"(unreadable)"}`)),l.issues.includes("mode")&&(t.info(` expected mode: ${l.expected.mode.toString(8)}`),t.info(` actual mode: ${(l.actual.mode??0).toString(8)}`)),l.issues.includes("mtime")&&(t.info(` expected mtime: ${new Date(l.expected.mtimeMs).toISOString()}`),t.info(` actual mtime: ${l.actual.mtimeMs===void 0?"(unreadable)":new Date(l.actual.mtimeMs).toISOString()}`)))}process.exitCode=1}finally{await B(m,{force:!0,recursive:!0}).catch(()=>{})}},"runVerify"),U=f(e=>e==="task"||e==="ai"||e==="socket"||e==="all"?e:(e&&e.length>0&&i.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),"parseCacheTarget"),y=f((e,r)=>e==="all"||e===r,"includesTarget"),g=f(e=>e===void 0?null:new Date(e).toISOString(),"isoOrNull"),P=f((e,r)=>{i.info(`${e}:`),i.info(` Entries: ${String(r.entries)}`),i.info(` Total size: ${w(r.totalSizeBytes,{decimals:1,space:!1})}`),i.info(` Oldest: ${r.oldestEntry?new Date(r.oldestEntry).toISOString():"N/A"}`),i.info(` Newest: ${r.newestEntry?new Date(r.newestEntry).toISOString():"N/A"}`)},"printAuxStatsBlock"),xe=f(e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&i.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),"parseScope"),k=f((e,r,t)=>{const o=e??process.cwd(),s=t??{},a=s.taskRunnerOptions??{},n=xe(r.scope),h=r.cacheDir,m=A(o,h,a.cacheDirectory,!1),u=A(o,h,a.cacheDirectory,s.sharedWorktreeCache);let c,d;switch(n){case"all":{c=u,d=u===m?[u]:[u,m];break}case"worktree":{c=m,d=[m];break}default:c=u,d=[u]}return{cacheDirectories:d,cacheDirectory:c,scope:n,sharedWorktreeCache:s.sharedWorktreeCache,workspaceRoot:o}},"resolveCacheDirectoryFromContext"),Oe=f(async({logger:e,options:r,visConfig:t,workspaceRoot:o})=>{const{cacheDirectories:s}=k(o,r,t),a=r.format??"table";for(const n of s)s.length>1&&i.info(`# ${n}`),await fe(n,a,e)},"cacheListExecute"),Ae=f(async({options:e,visConfig:r,workspaceRoot:t})=>{const o=U(e.type),s=!!e.dryRun;if(y(o,"task")){const{cacheDirectory:a,workspaceRoot:n}=k(t,e,r);await pe(a,n,{dryRun:s,force:!!e.force})}if(y(o,"ai"))if(s){const a=R();i.info(`Would clear ${String(a.entries)} cached AI response${a.entries===1?"":"s"}.`)}else le();if(y(o,"socket"))if(s){const a=z();i.info(`Would clear ${String(a.entries)} cached Socket.dev report${a.entries===1?"":"s"}.`)}else me()},"cacheCleanExecute"),Te=f(async({options:e,visConfig:r,workspaceRoot:t})=>{const{cacheDirectories:o,workspaceRoot:s}=k(t,e,r);for(const a of o)o.length>1&&i.info(`# ${a}`),await ye(a,s,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},"cachePruneExecute"),V=f(e=>e??process.cwd(),"resolveWorkspaceRoot"),Je=f(async({argument:e,logger:r,options:t,workspaceRoot:o})=>{const s=e[0];if(!s){i.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await ge(s,{format:t.format??"table",runId:t.run,workspaceRoot:V(o)},r)},"cacheWhyExecute"),Pe=f(async({argument:e,logger:r,options:t,workspaceRoot:o})=>{const s=e[0];if(!s){i.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}await we(s,{format:t.format??"table",runId:t.run,workspaceRoot:V(o)},r)},"cacheHashExecute"),Le=f(async({options:e,visConfig:r,workspaceRoot:t})=>{const o=U(e.type);if((e.format??"table")==="json"){const s={};if(y(o,"task")){const{cacheDirectories:a}=k(t,e,r);s.task=await Promise.all(a.map(async n=>{const h=S(n),m=h?await $(n):[],u=m.reduce((c,d)=>c+d.sizeBytes,0);return{directory:n,entries:m.length,exists:h,newestEntry:g(m[0]?.mtimeMs),oldestEntry:g(m.at(-1)?.mtimeMs),totalBytes:u}}))}if(y(o,"ai")){const a=R();s.ai={entries:a.entries,newestEntry:g(a.newestEntry),oldestEntry:g(a.oldestEntry),totalBytes:a.totalSizeBytes}}if(y(o,"socket")){const a=z();s.socket={entries:a.entries,newestEntry:g(a.newestEntry),oldestEntry:g(a.oldestEntry),totalBytes:a.totalSizeBytes}}process.stdout.write(`${JSON.stringify(s,void 0,2)}
18
- `);return}if(y(o,"task")){const{cacheDirectories:s}=k(t,e,r);for(const a of s)s.length>1&&i.info(`# ${a}`),await $e(a,"table")}y(o,"ai")&&P("AI response cache",R()),y(o,"socket")&&P("Socket.dev report cache",z())},"cacheSizeExecute"),Fe=f(async({argument:e,logger:r,options:t,visConfig:o,workspaceRoot:s})=>{const a=e[0];if(!a){i.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{cacheDirectories:n,workspaceRoot:h}=k(s,t,o);await Ce(a,{cacheDirectories:n,format:t.format??"table",workspaceRoot:h},r)},"cacheVerifyExecute");export{Ae as cacheCleanExecute,Pe as cacheHashExecute,Oe as cacheListExecute,Te as cachePruneExecute,Le as cacheSizeExecute,Fe as cacheVerifyExecute,Je as cacheWhyExecute,le as clearAiCacheSafe,me as clearSocketCacheSafe,$ as collectCacheEntries,de as formatAge,pe as runClean,we as runHash,fe as runList,ye as runPrune,$e as runSize,Ce as runVerify,ge as runWhy};
1
+ var _=Object.defineProperty;var b=(s,e)=>_(s,"name",{value:e,configurable:!0});import{createRequire as C}from"node:module";import{isAccessibleSync as g,writeFileSync as $}from"@visulima/fs";import{M as h}from"../packem_shared/index-OlP7U_t5.js";import{findVisConfigFile as B}from"./applyDefaults.js";import{p as t,I as E,b as x,A as M}from"./bin.js";const T=C(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=b(s=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,o]=p.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return p.getBuiltinModule(s)}return T(s)},"__cjs_getBuiltinModule"),{execFileSync:I}=j("node:child_process"),{createInterface:O}=j("node:readline");var R=Object.defineProperty,u=b((s,e)=>R(s,"name",{value:e,configurable:!0}),"f");const N=u(s=>{const e=[];return g(h(s,"turbo.json"))&&e.push("turborepo"),g(h(s,"nx.json"))&&e.push("nx"),g(h(s,".moon"))&&e.push("moon"),e},"detectExistingTools"),P=u((s,e)=>new Promise(o=>{s.question(e,n=>{o(n.trim())})}),"ask"),d=u(async(s,e,o=!0)=>{const n=await P(s,`${e} ${o?"[Y/n]":"[y/N]"} `);return n===""?o:n.toLowerCase()==="y"||n.toLowerCase()==="yes"},"confirm"),w=u((s,e)=>{const o=[],n=Object.entries(e.allowBuilds).filter(([,r])=>r).map(([r])=>` "${r}": true,`).join(`
2
+ `);let i=` allowBuilds: ${n?`{
3
+ ${n}
4
+ }`:"{}"},`;return e.enableSocket&&(i+=`
5
+ socket: { enabled: true },`),o.push(` security: {
6
+ ${i}
7
+ },`),e.staged&&o.push(` staged: {
8
+ "*.{ts,tsx}": "eslint --fix",
9
+ "*.{ts,tsx,js,jsx,json,md}": "prettier --write",
10
+ },`),`import { defineConfig } from "@visulima/vis/config";
11
+
12
+ export default defineConfig({
13
+ ${o.join(`
14
+
15
+ `)}
16
+ });
17
+ `},"generateConfigContent"),q=u(async(s,e,o)=>{const n=O({input:process.stdin,output:process.stdout});t.info(`
18
+ vis init interactive setup
19
+ `);const i=await d(n," Enable Socket.dev security scanning?");i&&(t.success(" Socket.dev enabled — scores, alerts, and supply chain data active."),process.env.VIS_SOCKET_TOKEN||t.notice(" Set VIS_SOCKET_TOKEN for a custom API token (optional).")),t.info("");const r=await d(n," Scan for packages with build scripts?"),l={};if(r){t.info(" Scanning node_modules...");const c=E(s,{});if(c.length>0){t.info(` Found ${String(c.length)} package${c.length===1?"":"s"} with build scripts:
20
+ `);for(const f of c){const a=await d(n,` Allow ${f}?`,!1),S=f.split(" (")[0]??f;l[S]=a,a&&t.success(` ✓ ${S} approved`)}}else t.info(" No packages with build scripts found.")}t.info("");const y=await d(n," Set up pre-commit hooks (lint-staged)?",!1);let v=!1;(e.name==="pnpm"||e.name==="yarn"||e.name==="npm"||e.name==="bun")&&(t.info(""),v=await d(n,` Sync security settings to ${e.name} config?`));const m=N(s);if(m.length>0&&(t.info(""),t.info(` Detected existing tools: ${m.join(", ")}`),await d(n,` Run \`vis migrate\` for ${m.join(", ")}?`,!1))){n.close();const[c,...f]=e.name==="pnpm"?["pnpm","exec"]:e.name==="yarn"?["yarn","exec"]:e.name==="bun"?["bunx"]:["npx"];for(const a of m){t.info(` Migrating from ${a}...`);try{I(c,[...f,"vis","migrate",a],{cwd:s,stdio:"inherit"})}catch{t.warn(` Migration from ${a} had issues — run \`vis migrate ${a}\` manually.`)}}if(g(o))t.success(`Migrated config written to ${o}`);else{const a=w(e.name,{allowBuilds:l,enableSocket:i,staged:y});$(o,a),t.success(`Created ${o}`)}t.notice(" Run 'vis doctor' to see your project's full health status.");return}n.close(),t.info("");const k=w(e.name,{allowBuilds:l,enableSocket:i,staged:y});if($(o,k),t.success(`Created ${o}`),v){const c=Object.fromEntries(Object.entries(l).filter(([,a])=>a)),f=x(e.name,s,c);for(const a of f)t.success(` ${a}`)}t.info(""),t.info(" Setup complete. Your config:"),t.info(` Security: ${i?"Socket.dev enabled":"defaults only"}`),t.info(` Build scripts: ${Object.values(l).filter(Boolean).length} approved`),t.info(` Git hooks: ${y?"lint-staged configured":"not configured"}`),t.info(` PM sync: ${v?"done":"skipped"}`),t.info(""),t.notice(" Run 'vis doctor' to see your project's full health status."),t.info("")},"runInteractiveInit"),A=u((s,e,o,n)=>{const i=w(e.name,{allowBuilds:{},enableSocket:!1,staged:!1});if($(n,i),t.success(`Created ${n}`),t.info(" Secure defaults applied automatically by defineConfig()."),o.syncNative){const r=x(e.name,s,{});for(const l of r)t.success(` ${l}`)}t.info(""),t.notice("Run 'vis doctor' for a full health check, or 'vis init' in a terminal for guided setup.")},"runStaticInit"),G=u(async({options:s,workspaceRoot:e})=>{const o=e??process.cwd(),n=M(o),i=B(o);if(i&&!s.force){t.warn(`Config already exists: ${i}`),t.notice("Use --force to overwrite, or edit the existing file.");return}const r=i??h(o,"vis.config.ts");process.stdin.isTTY&&s.interactive!==!1?await q(o,n,r):A(o,n,s,r)},"execute");export{G as default};
@@ -1,20 +1 @@
1
- var _=Object.defineProperty;var $=(s,e)=>_(s,"name",{value:e,configurable:!0});import{createRequire as C}from"node:module";import{isAccessibleSync as g,writeFileSync as b}from"@visulima/fs";import{join as h}from"@visulima/path";import{findVisConfigFile as B}from"./applyDefaults.js";import{p as t,I as E,T as x,A as R}from"./bin.js";const I=C(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=$(s=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,o]=p.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return p.getBuiltinModule(s)}return I(s)},"__cjs_getBuiltinModule"),{execFileSync:T}=j("node:child_process"),{createInterface:O}=j("node:readline");var N=Object.defineProperty,u=$((s,e)=>N(s,"name",{value:e,configurable:!0}),"f");const M=u(s=>{const e=[];return g(h(s,"turbo.json"))&&e.push("turborepo"),g(h(s,"nx.json"))&&e.push("nx"),g(h(s,".moon"))&&e.push("moon"),e},"detectExistingTools"),P=u((s,e)=>new Promise(o=>{s.question(e,n=>{o(n.trim())})}),"ask"),d=u(async(s,e,o=!0)=>{const n=await P(s,`${e} ${o?"[Y/n]":"[y/N]"} `);return n===""?o:n.toLowerCase()==="y"||n.toLowerCase()==="yes"},"confirm"),w=u((s,e)=>{const o=[],n=Object.entries(e.allowBuilds).filter(([,r])=>r).map(([r])=>` "${r}": true,`).join(`
2
- `);let i=` allowBuilds: ${n?`{
3
- ${n}
4
- }`:"{}"},`;return e.enableSocket&&(i+=`
5
- socket: { enabled: true },`),o.push(` security: {
6
- ${i}
7
- },`),e.staged&&o.push(` staged: {
8
- "*.{ts,tsx}": "eslint --fix",
9
- "*.{ts,tsx,js,jsx,json,md}": "prettier --write",
10
- },`),`import { defineConfig } from "@visulima/vis/config";
11
-
12
- export default defineConfig({
13
- ${o.join(`
14
-
15
- `)}
16
- });
17
- `},"generateConfigContent"),q=u(async(s,e,o)=>{const n=O({input:process.stdin,output:process.stdout});t.info(`
18
- vis init — interactive setup
19
- `);const i=await d(n," Enable Socket.dev security scanning?");i&&(t.success(" Socket.dev enabled — scores, alerts, and supply chain data active."),process.env.VIS_SOCKET_TOKEN||t.notice(" Set VIS_SOCKET_TOKEN for a custom API token (optional).")),t.info("");const r=await d(n," Scan for packages with build scripts?"),l={};if(r){t.info(" Scanning node_modules...");const c=E(s,{});if(c.length>0){t.info(` Found ${String(c.length)} package${c.length===1?"":"s"} with build scripts:
20
- `);for(const f of c){const a=await d(n,` Allow ${f}?`,!1),S=f.split(" (")[0]??f;l[S]=a,a&&t.success(` ✓ ${S} approved`)}}else t.info(" No packages with build scripts found.")}t.info("");const v=await d(n," Set up pre-commit hooks (lint-staged)?",!1);let y=!1;(e.name==="pnpm"||e.name==="yarn"||e.name==="npm"||e.name==="bun")&&(t.info(""),y=await d(n,` Sync security settings to ${e.name} config?`));const m=M(s);if(m.length>0&&(t.info(""),t.info(` Detected existing tools: ${m.join(", ")}`),await d(n,` Run \`vis migrate\` for ${m.join(", ")}?`,!1))){n.close();const[c,...f]=e.name==="pnpm"?["pnpm","exec"]:e.name==="yarn"?["yarn","exec"]:e.name==="bun"?["bunx"]:["npx"];for(const a of m){t.info(` Migrating from ${a}...`);try{T(c,[...f,"vis","migrate",a],{cwd:s,stdio:"inherit"})}catch{t.warn(` Migration from ${a} had issues — run \`vis migrate ${a}\` manually.`)}}if(g(o))t.success(`Migrated config written to ${o}`);else{const a=w(e.name,{allowBuilds:l,enableSocket:i,staged:v});b(o,a),t.success(`Created ${o}`)}t.notice(" Run 'vis doctor' to see your project's full health status.");return}n.close(),t.info("");const k=w(e.name,{allowBuilds:l,enableSocket:i,staged:v});if(b(o,k),t.success(`Created ${o}`),y){const c=Object.fromEntries(Object.entries(l).filter(([,a])=>a)),f=x(e.name,s,c);for(const a of f)t.success(` ${a}`)}t.info(""),t.info(" Setup complete. Your config:"),t.info(` Security: ${i?"Socket.dev enabled":"defaults only"}`),t.info(` Build scripts: ${Object.values(l).filter(Boolean).length} approved`),t.info(` Git hooks: ${v?"lint-staged configured":"not configured"}`),t.info(` PM sync: ${y?"done":"skipped"}`),t.info(""),t.notice(" Run 'vis doctor' to see your project's full health status."),t.info("")},"runInteractiveInit"),A=u((s,e,o,n)=>{const i=w(e.name,{allowBuilds:{},enableSocket:!1,staged:!1});if(b(n,i),t.success(`Created ${n}`),t.info(" Secure defaults applied automatically by defineConfig()."),o.syncNative){const r=x(e.name,s,{});for(const l of r)t.success(` ${l}`)}t.info(""),t.notice("Run 'vis doctor' for a full health check, or 'vis init' in a terminal for guided setup.")},"runStaticInit"),G=u(async({options:s,workspaceRoot:e})=>{const o=e??process.cwd(),n=R(o),i=B(o);if(i&&!s.force){t.warn(`Config already exists: ${i}`),t.notice("Use --force to overwrite, or edit the existing file.");return}const r=i??h(o,"vis.config.ts");process.stdin.isTTY&&s.interactive!==!1&&!s.noInteractive?await q(o,n,r):A(o,n,s,r)},"execute");export{G as default};
1
+ var j=Object.defineProperty;var f=(o,e)=>j(o,"name",{value:e,configurable:!0});import{createRequire as x}from"node:module";import{isAccessibleSync as z}from"@visulima/fs";import{M as y,K as R,c as L}from"../packem_shared/index-OlP7U_t5.js";import{p as t,A as M,h as T,o as $,r as A}from"./bin.js";import{s as B}from"../packem_shared/typosquats-XkC1CnOa.js";import{o as D}from"../packem_shared/utils-DrNg0XTR.js";const O=x(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=f(o=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[e,r]=i.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return i.getBuiltinModule(o)}return O(o)},"__cjs_getBuiltinModule"),{rmSync:q}=S("node:fs");var E=Object.defineProperty,b=f((o,e)=>E(o,"name",{value:e,configurable:!0}),"f");const F=["pnpm-lock.yaml","yarn.lock","package-lock.json","npm-shrinkwrap.json","bun.lock","bun.lockb"],P=b(o=>{let e=o;for(;;){for(const a of F)if(z(y(e,a)))return!0;const r=R(e);if(r===e||L(e).root===e)return!1;e=r}},"hasLockfile"),g=new Set(["aube","auto","bun","npm","pnpm","yarn"]),U=b(async({logger:o,options:e,visConfig:r,workspaceRoot:a})=>{const s=a??process.cwd();if(e.typosquatCheck!==!1&&!await B(s,r?.security?.typosquatAllowlist)){process.exitCode=1;return}const l=e.installer;if(l&&!g.has(l)){t.error(`Invalid --installer value: "${l}". Expected one of: ${[...g].join(", ")}.`),process.exitCode=1;return}const v=l,_=e.aube===!1;let c;try{c=_?M(s):T(s,{backend:v,configBackend:r?.install?.backend,configCorepack:r?.install?.corepack})}catch(n){t.error(n instanceof Error?n.message:String(n)),process.exitCode=1;return}const p=$(s,c);p&&t.warn(p);const w=D(e.filter),u=e.ci||!1,d=e.frozenLockfile||u,h=e.frozenLockfile===!1||e.force||e.lockfileOnly,C=P(s),m=d||!h&&C;if(!d&&m&&!e.silent&&t.info("Defaulting to frozen lockfile (pass --no-frozen-lockfile to allow lockfile updates)."),u){t.info("Clean install: removing node_modules...");try{q(y(s,"node_modules"),{force:!0,recursive:!0})}catch(n){t.error(`Failed to remove node_modules: ${n instanceof Error?n.message:String(n)}`),process.exitCode=1;return}}const k=A(c,{dev:e.dev||!1,filter:w,force:e.force||!1,frozenLockfile:m,ignoreScripts:!e.runScripts,lockfileOnly:e.lockfileOnly||!1,noOptional:e.optional===!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},s,o,{preferOffline:e.preferOffline||!1});k!==0&&(process.exitCode=k)},"execute");export{U as default};
@@ -1 +1 @@
1
- var C=Object.defineProperty;var f=(o,e)=>C(o,"name",{value:e,configurable:!0});import{createRequire as x}from"node:module";import{isAccessibleSync as R}from"@visulima/fs";import{join as y,dirname as T,parse as z}from"@visulima/path";import{p as t,A,m as L,f as $,h as B}from"./bin.js";import{s as D}from"../packem_shared/typosquats-CcZl99B1.js";import{o as E}from"../packem_shared/utils-DrNg0XTR.js";const O=x(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=f(o=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[e,r]=i.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return i.getBuiltinModule(o)}return O(o)},"__cjs_getBuiltinModule"),{rmSync:q}=S("node:fs");var F=Object.defineProperty,b=f((o,e)=>F(o,"name",{value:e,configurable:!0}),"f");const M=["pnpm-lock.yaml","yarn.lock","package-lock.json","npm-shrinkwrap.json","bun.lock","bun.lockb"],P=b(o=>{let e=o;for(;;){for(const c of M)if(R(y(e,c)))return!0;const r=T(e);if(r===e||z(e).root===e)return!1;e=r}},"hasLockfile"),g=new Set(["aube","auto","bun","npm","pnpm","yarn"]),U=b(async({logger:o,options:e,visConfig:r,workspaceRoot:c})=>{const s=c??process.cwd();if(!e.noTyposquatCheck&&!await D(s,r?.security?.typosquatAllowlist)){process.exitCode=1;return}const l=e.installer;if(l&&!g.has(l)){t.error(`Invalid --installer value: "${l}". Expected one of: ${[...g].join(", ")}.`),process.exitCode=1;return}const v=l,_=e.noAube||!1;let a;try{a=_?A(s):L(s,{backend:v,configBackend:r?.install?.backend,configCorepack:r?.install?.corepack})}catch(n){t.error(n instanceof Error?n.message:String(n)),process.exitCode=1;return}const p=$(s,a);p&&t.warn(p);const w=E(e.filter),u=e.ci||!1,d=e.frozenLockfile||u,h=e.noFrozenLockfile||e.force||e.lockfileOnly,j=P(s),m=d||!h&&j;if(!d&&m&&!e.silent&&t.info("Defaulting to frozen lockfile (pass --no-frozen-lockfile to allow lockfile updates)."),u){t.info("Clean install: removing node_modules...");try{q(y(s,"node_modules"),{force:!0,recursive:!0})}catch(n){t.error(`Failed to remove node_modules: ${n instanceof Error?n.message:String(n)}`),process.exitCode=1;return}}const k=B(a,{dev:e.dev||!1,filter:w,force:e.force||!1,frozenLockfile:m,ignoreScripts:!e.runScripts,lockfileOnly:e.lockfileOnly||!1,noOptional:e.noOptional||!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},s,o,{preferOffline:e.preferOffline||!1});k!==0&&(process.exitCode=k)},"execute");export{U as default};
1
+ var l=Object.defineProperty;var n=(e,a)=>l(e,"name",{value:a,configurable:!0});import{h as p,M as f}from"./bin.js";var g=Object.defineProperty,u=n((e,a)=>g(e,"name",{value:a,configurable:!0}),"s");const k=u(async({argument:e,logger:a,visConfig:o,workspaceRoot:s})=>{const t=e?.[0]??null,r=s??process.cwd(),i=p(r,{configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),c=f(i,t,r,a);c!==0&&(process.exitCode=c)},"execute");export{k as default};
@@ -1 +1 @@
1
- var i=Object.defineProperty;var n=(e,a)=>i(e,"name",{value:a,configurable:!0});import{m as p,l as f}from"./bin.js";var g=Object.defineProperty,m=n((e,a)=>g(e,"name",{value:a,configurable:!0}),"s");const k=m(async({argument:e,logger:a,visConfig:o,workspaceRoot:s})=>{const t=e?.[0]??null,r=s??process.cwd(),l=p(r,{configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),c=f(l,t,r,a);c!==0&&(process.exitCode=c)},"execute");export{k as default};
1
+ var d=Object.defineProperty;var t=(e,o)=>d(e,"name",{value:o,configurable:!0});import{h as g,x as u}from"./bin.js";var f=Object.defineProperty,b=t((e,o)=>f(e,"name",{value:o,configurable:!0}),"n");const k=b(async({argument:e,logger:o,visConfig:c,workspaceRoot:r})=>{const a=e;if(!a||a.length===0)throw new Error("No subcommand specified. Available: cache, publish, audit, list, view, config, whoami, login, logout, pack, owner, dist-tag, search, fund, ping, token, deprecate, rebuild, prune");const[s,...l]=a,n=r??process.cwd(),p=g(n,{configBackend:c?.install?.backend,configCorepack:c?.install?.corepack}),i=u(p,s,l,n,o);i!==0&&(process.exitCode=i)},"execute");export{k as default};
@@ -1 +1 @@
1
- var d=Object.defineProperty;var t=(e,o)=>d(e,"name",{value:o,configurable:!0});import{m as g,x as u}from"./bin.js";var f=Object.defineProperty,m=t((e,o)=>f(e,"name",{value:o,configurable:!0}),"n");const w=m(async({argument:e,logger:o,visConfig:c,workspaceRoot:r})=>{const a=e;if(!a||a.length===0)throw new Error("No subcommand specified. Available: cache, publish, audit, list, view, config, whoami, login, logout, pack, owner, dist-tag, search, fund, ping, token, deprecate, rebuild, prune");const[s,...l]=a,n=r??process.cwd(),p=g(n,{configBackend:c?.install?.backend,configCorepack:c?.install?.corepack}),i=u(p,s,l,n,o);i!==0&&(process.exitCode=i)},"execute");export{w as default};
1
+ var f=Object.defineProperty;var i=(e,o)=>f(e,"name",{value:o,configurable:!0});import{h as p,t as g}from"./bin.js";import{o as v}from"../packem_shared/utils-DrNg0XTR.js";var k=Object.defineProperty,m=i((e,o)=>k(e,"name",{value:o,configurable:!0}),"l");const b=m(async({argument:e,logger:o,options:a,visConfig:s,workspaceRoot:l})=>{const r=e;if(!r||r.length===0)throw new Error("No packages specified. Usage: vis remove <packages...>");const c=process.cwd(),n=p(l??c,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),t=g(n,{filter:v(a.filter),global:a.global||!1,packages:r,recursive:a.recursive||!1,saveDev:a.saveDev||!1,workspaceRoot:a.workspaceRoot||!1},c,o);t!==0&&(process.exitCode=t)},"execute");export{b as default};
@@ -1 +1,5 @@
1
- var f=Object.defineProperty;var i=(e,o)=>f(e,"name",{value:o,configurable:!0});import{m as p,n as g}from"./bin.js";import{o as v}from"../packem_shared/utils-DrNg0XTR.js";var k=Object.defineProperty,m=i((e,o)=>k(e,"name",{value:o,configurable:!0}),"l");const b=m(async({argument:e,logger:o,options:a,visConfig:s,workspaceRoot:l})=>{const r=e;if(!r||r.length===0)throw new Error("No packages specified. Usage: vis remove <packages...>");const c=process.cwd(),n=p(l??c,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),t=g(n,{filter:v(a.filter),global:a.global||!1,packages:r,recursive:a.recursive||!1,saveDev:a.saveDev||!1,workspaceRoot:a.workspaceRoot||!1},c,o);t!==0&&(process.exitCode=t)},"execute");export{b as default};
1
+ var k=Object.defineProperty;var p=(t,e)=>k(t,"name",{value:e,configurable:!0});import{readLastRunSummary as S}from"@visulima/task-runner";import{p as m}from"./bin.js";import{r as g,l as v}from"../packem_shared/run-summary-utils-D39XBHWW.js";var x=Object.defineProperty,o=p((t,e)=>x(t,"name",{value:e,configurable:!0}),"s");const I=new Set(["json","table"]),y=o(t=>t??process.cwd(),"resolveWorkspaceRoot"),c=o(t=>t===void 0?"-":t<1e3?`${String(t)}ms`:`${(t/1e3).toFixed(2)}s`,"formatDuration"),l=o(t=>t.exitCode===void 0?t.cacheStatus:t.exitCode===0?t.cacheStatus==="MISS"?"OK":t.cacheStatus:`FAIL(${String(t.exitCode)})`,"formatStatus"),n=o((t,e)=>t.length>=e?t:t+" ".repeat(e-t.length),"padCell"),w=o(t=>t.exitCode!==void 0&&t.exitCode!==0,"isFailedTask"),$=o((t,e)=>{e.info(`Run ${t.id}`),e.info(` start: ${t.startTime}`),e.info(` end: ${t.endTime}`),e.info(` duration: ${c(t.duration)}`),e.info(` totals: ${String(t.stats.total)} total · ${String(t.stats.succeeded)} ok · ${String(t.stats.cached)} cached · ${String(t.stats.skipped)} skipped · ${String(t.stats.failed)} failed`),e.info(` env: node ${t.environment.nodeVersion} · ${t.environment.platform}/${t.environment.arch}`),e.info("")},"renderRunHeader"),T=o((t,e)=>{if(t.length===0){e.info("(no tasks match the current filter)");return}const a=t.map(r=>({duration:c(r.duration),hash:r.hash?r.hash.slice(0,12):"-",status:l(r),taskId:r.taskId})),s={duration:Math.max(8,...a.map(r=>r.duration.length)),hash:Math.max(4,...a.map(r=>r.hash.length)),status:Math.max(6,...a.map(r=>r.status.length)),taskId:Math.max(4,...a.map(r=>r.taskId.length))};e.info(` ${n("task",s.taskId)} ${n("status",s.status)} ${n("duration",s.duration)} ${n("hash",s.hash)}`),e.info(` ${"-".repeat(s.taskId)} ${"-".repeat(s.status)} ${"-".repeat(s.duration)} ${"-".repeat(s.hash)}`);for(const r of a)e.info(` ${n(r.taskId,s.taskId)} ${n(r.status,s.status)} ${n(r.duration,s.duration)} ${n(r.hash,s.hash)}`)},"renderTaskTable"),C=o((t,e,a)=>{$(t,a),a.info(`Task ${e.taskId}`),a.info(` status: ${l(e)}`),a.info(` cache: ${e.cacheStatus}`),a.info(` duration: ${c(e.duration)}`),a.info(` exit: ${e.exitCode===void 0?"-":String(e.exitCode)}`),a.info(` hash: ${e.hash??"(none)"}`),a.info(` start: ${e.startTime??"-"}`),a.info(` end: ${e.endTime??"-"}`),e.dependencies.length>0&&a.info(` deps: ${e.dependencies.join(", ")}`),a.info(""),m.info(`Drill into hash inputs with: vis cache why ${e.taskId} --run ${t.id}`)},"renderTaskDetail"),R=o(t=>{process.stdout.write(`${JSON.stringify(t.map(e=>({id:e.id,mtime:new Date(e.mtimeMs).toISOString(),path:e.path})),void 0,2)}
2
+ `)},"renderListJson"),j=o((t,e)=>{if(t.length===0){m.info("No recorded runs found in .task-runner/runs/. Run with --summarize to record a run.");return}const a={id:Math.max(2,...t.map(s=>s.id.length)),mtime:24};e.info(` ${n("id",a.id)} ${n("mtime",a.mtime)}`),e.info(` ${"-".repeat(a.id)} ${"-".repeat(a.mtime)}`);for(const s of t)e.info(` ${n(s.id,a.id)} ${new Date(s.mtimeMs).toISOString()}`)},"renderListTable"),O=o((t,e)=>{let{tasks:a}=t;return e.task!==void 0&&(a=a.filter(s=>s.taskId===e.task)),e.failed&&(a=a.filter(s=>w(s))),a},"filterTasks"),b=o(async(t,e)=>{const{failed:a,format:s,runId:r,task:d,workspaceRoot:h}=t,i=r===void 0?await S(h):await g(h,r);if(!i){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:r??null},void 0,2)}
3
+ `),process.exitCode=1;return}r===void 0?m.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):m.error(`Run summary "${r}" not found in .task-runner/runs/.`),process.exitCode=1;return}const f=O(i,{failed:a,task:d});if(d!==void 0&&f.length===0){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:i.id,taskId:d},void 0,2)}
4
+ `),process.exitCode=1;return}m.error(`Task "${d}" was not part of run ${i.id}.`),process.exitCode=1;return}if(i.stats.failed>0&&(process.exitCode=1),s==="json"){process.stdout.write(`${JSON.stringify({duration:i.duration,endTime:i.endTime,environment:i.environment,runId:i.id,startTime:i.startTime,stats:i.stats,tasks:f.map(u=>({cacheStatus:u.cacheStatus,dependencies:u.dependencies,duration:u.duration,endTime:u.endTime,exitCode:u.exitCode,hash:u.hash??null,startTime:u.startTime,taskId:u.taskId}))},void 0,2)}
5
+ `);return}if(d!==void 0){C(i,f[0],e);return}$(i,e),T(f,e)},"runReplay"),L=o(async({logger:t,options:e,workspaceRoot:a})=>{const s=y(a),r=e.format??"table";if(!I.has(r)){m.error(`Invalid --format: ${r}. Expected "table" or "json".`),process.exitCode=1;return}if(e.list===!0){const d=await v(s);if(r==="json"){R(d);return}j(d,t);return}await b({failed:e.failed===!0,format:r,runId:e.run,task:e.task,workspaceRoot:s},t)},"replayExecute");export{L as default,L as replayExecute,b as runReplay};
@@ -1,2 +1,2 @@
1
- var j=Object.defineProperty;var g=(n,r)=>j(n,"name",{value:r,configurable:!0});import{getAffectedProjects as v}from"@visulima/task-runner";import{k as E,y as F}from"./bin.js";import{f as b}from"../packem_shared/selectors-BylODRiM.js";var S=Object.defineProperty,$=g((n,r)=>S(n,"name",{value:r,configurable:!0}),"m");const T=$(async({argument:n,logger:r,options:e,runtime:l,visConfig:h,workspaceRoot:u})=>{const f=n[0];if(!f)throw new Error("Missing target. Usage: vis affected <target>");if(!u)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const s=u,{packageJsons:m,workspace:i}=E(s,h),w=F(s,i,m),d=new Set(["deep","direct","none"]),c=e.downstream??"deep",p=e.upstream??"none";if(!d.has(c))throw new Error(`Invalid --downstream value: "${c}". Must be "none", "direct", or "deep".`);if(!d.has(p))throw new Error(`Invalid --upstream value: "${p}". Must be "none", "direct", or "deep".`);const y={base:e.base,downstream:c,head:e.head,projectGraph:w,projects:i.projects,upstream:p,workspaceRoot:s},o=await v(y);if(o.changedFiles.length===0){r.info("No files changed. Nothing to run.");return}if(o.affectedProjects.length===0){r.info("No projects affected by the changes.");return}let{affectedProjects:a}=o;if(e.query&&(a=b(a,i,e.query),a.length===0)){r.info(`Query "${String(e.query)}" matched no affected projects.`);return}r.info(`Affected projects: ${a.join(", ")}`),o.changedFiles.length>0&&(process.env.VIS_AFFECTED_FILES=o.changedFiles.join(`
1
+ var j=Object.defineProperty;var g=(n,r)=>j(n,"name",{value:r,configurable:!0});import{getAffectedProjects as v}from"@visulima/task-runner";import{y as E,m as F}from"./bin.js";import{f as b}from"../packem_shared/selectors-BvtUXWGY.js";var S=Object.defineProperty,$=g((n,r)=>S(n,"name",{value:r,configurable:!0}),"m");const T=$(async({argument:n,logger:r,options:e,runtime:l,visConfig:h,workspaceRoot:u})=>{const f=n[0];if(!f)throw new Error("Missing target. Usage: vis affected <target>");if(!u)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const s=u,{packageJsons:m,workspace:i}=E(s,h),w=F(s,i,m),d=new Set(["deep","direct","none"]),c=e.downstream??"deep",p=e.upstream??"none";if(!d.has(c))throw new Error(`Invalid --downstream value: "${c}". Must be "none", "direct", or "deep".`);if(!d.has(p))throw new Error(`Invalid --upstream value: "${p}". Must be "none", "direct", or "deep".`);const y={base:e.base,downstream:c,head:e.head,projectGraph:w,projects:i.projects,upstream:p,workspaceRoot:s},o=await v(y);if(o.changedFiles.length===0){r.info("No files changed. Nothing to run.");return}if(o.affectedProjects.length===0){r.info("No projects affected by the changes.");return}let{affectedProjects:a}=o;if(e.query&&(a=b(a,i,e.query),a.length===0)){r.info(`Query "${String(e.query)}" matched no affected projects.`);return}r.info(`Affected projects: ${a.join(", ")}`),o.changedFiles.length>0&&(process.env.VIS_AFFECTED_FILES=o.changedFiles.join(`
2
2
  `));const t=[f,`--projects=${a.join(",")}`];e.parallel!==void 0&&t.push(`--parallel=${String(e.parallel)}`),e.cache||t.push("--no-cache"),e.dryRun&&t.push("--dry-run"),e.partition&&t.push(`--partition=${String(e.partition)}`),e.reverse&&t.push("--reverse"),typeof e.runnerTags=="string"&&e.runnerTags!==""&&t.push(`--runner-tags=${e.runnerTags}`);try{await l.runCommand("run",{argv:t})}finally{delete process.env.VIS_AFFECTED_FILES}},"execute");export{T as default};
@@ -1,5 +1 @@
1
- var k=Object.defineProperty;var p=(t,e)=>k(t,"name",{value:e,configurable:!0});import{readLastRunSummary as S}from"@visulima/task-runner";import{p as m}from"./bin.js";import{r as g,l as v}from"../packem_shared/run-summary-utils-BfBvjzhY.js";var x=Object.defineProperty,o=p((t,e)=>x(t,"name",{value:e,configurable:!0}),"s");const I=new Set(["json","table"]),y=o(t=>t??process.cwd(),"resolveWorkspaceRoot"),c=o(t=>t===void 0?"-":t<1e3?`${String(t)}ms`:`${(t/1e3).toFixed(2)}s`,"formatDuration"),l=o(t=>t.exitCode===void 0?t.cacheStatus:t.exitCode===0?t.cacheStatus==="MISS"?"OK":t.cacheStatus:`FAIL(${String(t.exitCode)})`,"formatStatus"),n=o((t,e)=>t.length>=e?t:t+" ".repeat(e-t.length),"padCell"),w=o(t=>t.exitCode!==void 0&&t.exitCode!==0,"isFailedTask"),$=o((t,e)=>{e.info(`Run ${t.id}`),e.info(` start: ${t.startTime}`),e.info(` end: ${t.endTime}`),e.info(` duration: ${c(t.duration)}`),e.info(` totals: ${String(t.stats.total)} total · ${String(t.stats.succeeded)} ok · ${String(t.stats.cached)} cached · ${String(t.stats.skipped)} skipped · ${String(t.stats.failed)} failed`),e.info(` env: node ${t.environment.nodeVersion} · ${t.environment.platform}/${t.environment.arch}`),e.info("")},"renderRunHeader"),T=o((t,e)=>{if(t.length===0){e.info("(no tasks match the current filter)");return}const a=t.map(r=>({duration:c(r.duration),hash:r.hash?r.hash.slice(0,12):"-",status:l(r),taskId:r.taskId})),s={duration:Math.max(8,...a.map(r=>r.duration.length)),hash:Math.max(4,...a.map(r=>r.hash.length)),status:Math.max(6,...a.map(r=>r.status.length)),taskId:Math.max(4,...a.map(r=>r.taskId.length))};e.info(` ${n("task",s.taskId)} ${n("status",s.status)} ${n("duration",s.duration)} ${n("hash",s.hash)}`),e.info(` ${"-".repeat(s.taskId)} ${"-".repeat(s.status)} ${"-".repeat(s.duration)} ${"-".repeat(s.hash)}`);for(const r of a)e.info(` ${n(r.taskId,s.taskId)} ${n(r.status,s.status)} ${n(r.duration,s.duration)} ${n(r.hash,s.hash)}`)},"renderTaskTable"),C=o((t,e,a)=>{$(t,a),a.info(`Task ${e.taskId}`),a.info(` status: ${l(e)}`),a.info(` cache: ${e.cacheStatus}`),a.info(` duration: ${c(e.duration)}`),a.info(` exit: ${e.exitCode===void 0?"-":String(e.exitCode)}`),a.info(` hash: ${e.hash??"(none)"}`),a.info(` start: ${e.startTime??"-"}`),a.info(` end: ${e.endTime??"-"}`),e.dependencies.length>0&&a.info(` deps: ${e.dependencies.join(", ")}`),a.info(""),m.info(`Drill into hash inputs with: vis cache why ${e.taskId} --run ${t.id}`)},"renderTaskDetail"),R=o(t=>{process.stdout.write(`${JSON.stringify(t.map(e=>({id:e.id,mtime:new Date(e.mtimeMs).toISOString(),path:e.path})),void 0,2)}
2
- `)},"renderListJson"),j=o((t,e)=>{if(t.length===0){m.info("No recorded runs found in .task-runner/runs/. Run with --summarize to record a run.");return}const a={id:Math.max(2,...t.map(s=>s.id.length)),mtime:24};e.info(` ${n("id",a.id)} ${n("mtime",a.mtime)}`),e.info(` ${"-".repeat(a.id)} ${"-".repeat(a.mtime)}`);for(const s of t)e.info(` ${n(s.id,a.id)} ${new Date(s.mtimeMs).toISOString()}`)},"renderListTable"),O=o((t,e)=>{let{tasks:a}=t;return e.task!==void 0&&(a=a.filter(s=>s.taskId===e.task)),e.failed&&(a=a.filter(s=>w(s))),a},"filterTasks"),b=o(async(t,e)=>{const{failed:a,format:s,runId:r,task:d,workspaceRoot:h}=t,i=r===void 0?await S(h):await g(h,r);if(!i){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:r??null},void 0,2)}
3
- `),process.exitCode=1;return}r===void 0?m.error("No previous run summary found. Run a task first to populate `.task-runner/last-summary.json`."):m.error(`Run summary "${r}" not found in .task-runner/runs/.`),process.exitCode=1;return}const f=O(i,{failed:a,task:d});if(d!==void 0&&f.length===0){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:i.id,taskId:d},void 0,2)}
4
- `),process.exitCode=1;return}m.error(`Task "${d}" was not part of run ${i.id}.`),process.exitCode=1;return}if(i.stats.failed>0&&(process.exitCode=1),s==="json"){process.stdout.write(`${JSON.stringify({duration:i.duration,endTime:i.endTime,environment:i.environment,runId:i.id,startTime:i.startTime,stats:i.stats,tasks:f.map(u=>({cacheStatus:u.cacheStatus,dependencies:u.dependencies,duration:u.duration,endTime:u.endTime,exitCode:u.exitCode,hash:u.hash??null,startTime:u.startTime,taskId:u.taskId}))},void 0,2)}
5
- `);return}if(d!==void 0){C(i,f[0],e);return}$(i,e),T(f,e)},"runReplay"),L=o(async({logger:t,options:e,workspaceRoot:a})=>{const s=y(a),r=e.format??"table";if(!I.has(r)){m.error(`Invalid --format: ${r}. Expected "table" or "json".`),process.exitCode=1;return}if(e.list===!0){const d=await v(s);if(r==="json"){R(d);return}j(d,t);return}await b({failed:e.failed===!0,format:r,runId:e.run,task:e.task,workspaceRoot:s},t)},"replayExecute");export{L as default,L as replayExecute,b as runReplay};
1
+ var w=Object.defineProperty;var y=(e,t)=>w(e,"name",{value:t,configurable:!0});import{createRequire as C}from"node:module";import{c as f,d as v,y as F,m as I,E as J,e as _}from"./bin.js";import{isAccessibleSync as P,readJsonSync as V}from"@visulima/fs";import{M as b}from"../packem_shared/index-OlP7U_t5.js";import{enforceProjectConstraints as z}from"@visulima/task-runner";import{a as A}from"../packem_shared/flakiness-BIg1rwvp.js";import{c as B}from"../packem_shared/runtime-check-BaKni2y1.js";const M=C(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=y(e=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[t,i]=n.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return n.getBuiltinModule(e)}return M(e)},"__cjs_getBuiltinModule"),{readdirSync:x}=q("node:fs");var E=Object.defineProperty,O=y((e,t)=>E(e,"name",{value:t,configurable:!0}),"h");const r=O(e=>e?f("✓"):v(""),"icon"),Q=O(async({logger:e,options:t,visConfig:i,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root.");const{config:$,packageJsons:T,workspace:u}=F(s,i),R=I(s,u,T),j=Object.keys(u.projects).length,k=new Set(Object.values(u.projects).flatMap(p=>Object.keys(p.targets??{}))).size,a=B(s);let o=0;$.constraints&&(o=z(R,$.constraints).length);const c=A(s,{minRuns:2});let l;const g=b(s,".task-runner","runs");if(P(g)){const p=x(g).filter(d=>d.endsWith(".json")).sort();let m=0,S=0;for(const d of p.slice(-20))try{const h=V(b(g,d));h.stats&&(m+=h.stats.total??0,S+=h.stats.cached??0)}catch{continue}m>0&&(l=`${(S/m*100).toFixed(0)}%`)}if(t.json){e.info(JSON.stringify({cacheHitRate:l??null,constraintViolations:o,flakyTasks:c.length,projects:j,runtimeIssues:a.length,targets:k},null,2));return}e.info(""),e.info(` ${J("VIS STATUS")}`),e.info(""),e.info(` ${r(!0)} ${String(j)} projects · ${String(k)} unique targets`),e.info(` ${r(a.length===0)} Runtime: ${a.length===0?f("OK"):_(`${String(a.length)} issue(s)`)}`),e.info(` ${r(o===0)} Constraints: ${o===0?f("OK"):v(`${String(o)} violation(s)`)}`),e.info(` ${r(c.length===0)} Flaky tasks: ${c.length===0?f("none"):_(String(c.length))}`),l&&e.info(` ${r(!0)} Cache hit rate: ${l} (last 20 runs)`),e.info("")},"execute");export{Q as default};
@@ -1 +1 @@
1
- var T=Object.defineProperty;var y=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createRequire as C}from"node:module";import{green as f,red as v,dim as J,yellow as _}from"@visulima/colorize";import{isAccessibleSync as M,readJsonSync as P}from"@visulima/fs";import{join as b}from"@visulima/path";import{enforceProjectConstraints as V}from"@visulima/task-runner";import{k as z,y as A}from"./bin.js";import{a as B}from"../packem_shared/flakiness-D9wf0t56.js";import{c as I}from"../packem_shared/runtime-check-BXZ43CBW.js";const q=C(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=y(e=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[t,i]=n.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return n.getBuiltinModule(e)}return q(e)},"__cjs_getBuiltinModule"),{readdirSync:F}=x("node:fs");var K=Object.defineProperty,O=y((e,t)=>K(e,"name",{value:t,configurable:!0}),"h");const r=O(e=>e?f("✓"):v("✗"),"icon"),X=O(async({logger:e,options:t,visConfig:i,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root.");const{config:j,packageJsons:w,workspace:u}=z(o,i),R=A(o,u,w),k=Object.keys(u.projects).length,$=new Set(Object.values(u.projects).flatMap(p=>Object.keys(p.targets??{}))).size,a=I(o);let s=0;j.constraints&&(s=V(R,j.constraints).length);const c=B(o,{minRuns:2});let l;const g=b(o,".task-runner","runs");if(M(g)){const p=F(g).filter(d=>d.endsWith(".json")).sort();let m=0,S=0;for(const d of p.slice(-20))try{const h=P(b(g,d));h.stats&&(m+=h.stats.total??0,S+=h.stats.cached??0)}catch{continue}m>0&&(l=`${(S/m*100).toFixed(0)}%`)}if(t.json){e.info(JSON.stringify({cacheHitRate:l??null,constraintViolations:s,flakyTasks:c.length,projects:k,runtimeIssues:a.length,targets:$},null,2));return}e.info(""),e.info(` ${J("VIS STATUS")}`),e.info(""),e.info(` ${r(!0)} ${String(k)} projects · ${String($)} unique targets`),e.info(` ${r(a.length===0)} Runtime: ${a.length===0?f("OK"):_(`${String(a.length)} issue(s)`)}`),e.info(` ${r(s===0)} Constraints: ${s===0?f("OK"):v(`${String(s)} 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{X 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 +1,5 @@
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{k as v,y as E}from"./bin.js";var T=Object.defineProperty,u=j((t,e)=>T(t,"name",{value:e,configurable:!0}),"h");const O=u((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=u((t,e)=>{const s=[];for(const[a,o]of Object.entries(t.dependencies))o.includes(e)&&s.push(a);return s.sort()},"collectParents"),I=u(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,w]=o.split(":",2),$=r.projects[c];if(!$)throw new Error(`Unknown project "${c}".`);if(!$.targets?.[w])throw new Error(`Project "${c}" has no target "${w}".`);const m=Object.entries(r.projects).flatMap(([n,k])=>Object.keys(k.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,k]of d.entries()){const h=n===0?" ":`${" ".repeat(n+1)}└─ `;e.info(`${h}${k}`)}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 P=Object.defineProperty;var v=(e,n)=>P(e,"name",{value:n,configurable:!0});import{createRequire as R}from"node:module";import{c as S,d as W,e as A,E as d,p as o}from"./bin.js";import{M as N}from"../packem_shared/index-OlP7U_t5.js";import{S as w,g as C,w as M,b as B,p as q,f as j,a as k,c as H,u as y,d as K,e as O,h as D}from"../packem_shared/toolchain-B7sIiJxK.js";const I=R(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=v(e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[n,i]=$.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return $.getBuiltinModule(e)}return I(e)},"__cjs_getBuiltinModule"),{spawnSync:U}=b("node:child_process"),{writeFileSync:F}=b("node:fs");var L=Object.defineProperty,f=v((e,n)=>L(e,"name",{value:n,configurable:!0}),"d");const x=["bun","deno","go","node","npm","pnpm","python","ruby","rust","yarn"],G=f(e=>x.includes(e),"isKnownTool"),p=f(e=>e?S("✓"):W("✗"),"icon"),T=A(""),J=f(e=>{if(e.installed){const n=e.version?` v${e.version}`:"",i=e.configFiles.length>0?` (${e.configFiles.join(", ")})`:"";return`${p(!0)} ${e.name}${n}${i}`}return`${T} ${e.name} — referenced by ${e.configFiles.join(", ")} but not installed`},"renderManagerLine"),z=f(e=>{if(e.matches)return"";const{manager:n}=e;return n.name==="none"?d("→ (no manager)"):n.name==="self-activate"?"":n.installed?d(`→ ${n.name}`):d(`→ ${n.name} (missing)`)},"renderToolManager"),Q=f(e=>e.matches?p(!0):e.actual?T:p(!1),"toolIcon"),V=f(e=>{if(o.info(""),o.info(d("── Toolchain ───────────────────────")),e.detected.length===0)o.info(` ${p(!1)} No version manager detected`),o.notice(` Install one of: ${w.join(", ")}`);else for(const n of e.detected)o.info(` ${J(n)}`);if(o.info(""),e.tools.length===0){o.info(` ${d("No tool pins found add engines.node, .nvmrc, or a manager config file.")}`);return}o.info(d("── Tools ───────────────────────────"));for(const n of e.tools){const i=`${n.expected.tool} ${n.expected.version}`,r=n.actual?`actual ${n.actual}`:"not installed",t=n.matches?"":d(` [${n.expected.source}]`),s=z(n),u=s===""?"":` ${s}`;o.info(` ${Q(n)} ${i} — ${r}${t}${u}`),n.manager.note&&o.notice(` ${n.manager.note}`)}},"printStatus"),X=f((e,n,i)=>{const r=C(e,n);if(i.json){process.stdout.write(`${JSON.stringify({detected:r.detected.map(s=>({binPath:s.binPath??null,configFiles:s.configFiles,installed:s.installed,name:s.name,version:s.version??null})),tools:r.tools.map(s=>({actual:s.actual??null,expected:s.expected.version,manager:s.manager.name,managerInstalled:s.manager.installed,matches:s.matches,note:s.manager.note??null,source:s.expected.source,tool:s.expected.tool}))},void 0,2)}
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,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{green as S,red as W,yellow as A,dim as d}from"@visulima/colorize";import{join as N}from"@visulima/path";import{p as o}from"./bin.js";import{S as w,g as C,w as j,b as B,p as q,f as k,a as M,c as H,u as y,d as K,e as O,h as D}from"../packem_shared/toolchain-BgBOUHII.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,r]=$.versions.node.split(".").map(Number);if(n>22||n===22&&r>=3||n===20&&r>=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}`:"",r=e.configFiles.length>0?` (${e.configFiles.join(", ")})`:"";return`${p(!0)} ${e.name}${n}${r}`}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 r=`${n.expected.tool} ${n.expected.version}`,i=n.actual?`actual ${n.actual}`:"not installed",t=n.matches?"":d(` [${n.expected.source}]`),s=z(n),u=s===""?"":` ${s}`;o.info(` ${Q(n)} ${r} ${i}${t}${u}`),n.manager.note&&o.notice(` ${n.manager.note}`)}},"printStatus"),X=f((e,n,r)=>{const i=C(e,n);if(r.json){process.stdout.write(`${JSON.stringify({detected:i.detected.map(s=>({binPath:s.binPath??null,configFiles:s.configFiles,installed:s.installed,name:s.name,version:s.version??null})),tools:i.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(i);const t=i.tools.filter(s=>!s.matches);t.length>0&&(o.info(""),o.notice(" Run `vis toolchain install` to install pinned versions.")),r.exitCode&&t.length>0&&(process.exitCode=1)},"executeStatus"),Y=f(e=>{const n=new Map;for(const r of e){const i=n.get(r.manager.name);i?i.push(r):n.set(r.manager.name,[r])}return n},"groupByManager"),_=f((e,n,r)=>U(e,n,{cwd:r,stdio:"inherit"}).status??1,"runInvocation"),Z=f((e,n,r)=>{const i=C(e,n),t=i.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(i.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}`),r.dryRun)l=!0;else try{j(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(!i.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 E=m.map(a=>B(c,a.expected)).filter(Boolean);for(const a of E){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}`),r.dryRun){l=!0;continue}const h=_(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,r,i)=>{if(!r)throw new Error("Usage: vis toolchain use <tool>@<version> (e.g. vis toolchain use node@22.13.0)");const t=q(r);if(!t)throw new Error(`Could not parse "${r}". Expected "<tool>@<version>" where <tool> is one of ${x.join(", ")}.`);const s=k(e),u=M(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...`),i.dryRun){o.notice(` Would set packageManager: "${t.tool}@${t.version}"`);return}try{const c=j(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.`),i.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}...`),i.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}`),i.dryRun)return;const g=_(l.bin,l.args,e);if(g!==0){process.exitCode=g;return}if(o.success(`Pinned ${t.tool} to ${t.version}.`),i.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,r)=>{if(!r)throw new Error("Usage: vis toolchain which <tool> (e.g. vis toolchain which node)");const i=r.toLowerCase();if(!G(i))throw new Error(`Unknown tool "${r}". Known: ${x.join(", ")}.`);const t=k(e),s=M({source:"vis.config.ts",tool:i,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,i):O(i);if(!l){o.error(`${r} not found in PATH${u?` or via ${u.name}`:""}.`),process.exitCode=1;return}process.stdout.write(`${l}
4
- `)},"executeWhich"),oe=f((e,n)=>{const r=D(e,n);process.stdout.write(`${r.name}
5
- `)},"executeDetect"),le=f(async({argument:e,options:n,visConfig:r,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run inside a monorepo.");const t=e[0]??"status",s=r?.toolchain;switch(t){case"detect":{oe(i,s);return}case"install":{Z(i,s,n);return}case"status":{X(i,s,n);return}case"use":{ee(i,s,e[1],n);return}case"which":{ne(i,s,e[1]);return}default:throw new Error(`Unknown toolchain action "${t}". Known: status, detect, install, use, which.`)}},"execute");export{le as default};
1
+ var p=Object.defineProperty;var c=(e,o)=>p(e,"name",{value:o,configurable:!0});import{h as f,u}from"./bin.js";var g=Object.defineProperty,d=c((e,o)=>g(e,"name",{value:o,configurable:!0}),"t");const v=d(async({argument:e,logger:o,options:n,visConfig:a,workspaceRoot:t})=>{const i=e||[],r=t??process.cwd(),l=f(r,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),s=u(l,i,n.recursive||!1,r,o);s!==0&&(process.exitCode=s)},"execute");export{v as default};
@@ -1 +1,3 @@
1
- var p=Object.defineProperty;var c=(e,o)=>p(e,"name",{value:o,configurable:!0});import{m as f,o 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 a=Object.defineProperty;var s=(n,e)=>a(n,"name",{value:e,configurable:!0});import{createRequire as f}from"node:module";import{v}from"./bin.js";const d=f(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=s(n=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,r]=t.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return t.getBuiltinModule(n)}return d(n)},"__cjs_getBuiltinModule"),{execSync:p,spawnSync:m}=l("node:child_process");var g=Object.defineProperty,y=s((n,e)=>g(n,"name",{value:e,configurable:!0}),"r");const w=y(async({argument:n,logger:e,options:r})=>{const c=n?.[0];e.info("info: checking for updates...");const o=v.version;let i;try{const u=p("npm view @visulima/vis version",{encoding:"utf8"}).trim();i=c??u}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(o===i&&!r.force){e.info(`
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,3 +1 @@
1
- var a=Object.defineProperty;var s=(n,e)=>a(n,"name",{value:e,configurable:!0});import{createRequire as f}from"node:module";import{q 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 t=(a,o)=>p(a,"name",{value:o,configurable:!0});import{h as f,C as d}from"./bin.js";import{o as g}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,u=t((a,o)=>v(a,"name",{value:o,configurable:!0}),"n");const h=u(async({argument:a,logger:o,options:e,visConfig:l,workspaceRoot:c})=>{const s=a;if(!s||s.length===0)throw new Error("No packages specified. Usage: vis why <package...>");const n=c??process.cwd(),i=f(n,{configBackend:l?.install?.backend,configCorepack:l?.install?.corepack}),r=d(i,{depth:e.depth===void 0?void 0:Number(e.depth),dev:e.dev||!1,filter:g(e.filter),global:e.global||!1,json:e.json||!1,long:e.long||!1,noOptional:e.optional===!1,packages:s,parseable:e.parseable||!1,prod:e.prod||!1,recursive:e.recursive||!1},n,o);r!==0&&r!==1&&(process.exitCode=r)},"execute");export{h as default};
@@ -1 +1 @@
1
- var p=Object.defineProperty;var t=(o,a)=>p(o,"name",{value:a,configurable:!0});import{m as f,C as d}from"./bin.js";import{o as g}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,m=t((o,a)=>v(o,"name",{value:a,configurable:!0}),"n");const h=m(async({argument:o,logger:a,options:e,visConfig:l,workspaceRoot:i})=>{const s=o;if(!s||s.length===0)throw new Error("No packages specified. Usage: vis why <package...>");const n=i??process.cwd(),c=f(n,{configBackend:l?.install?.backend,configCorepack:l?.install?.corepack}),r=d(c,{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.noOptional||!1,packages:s,parseable:e.parseable||!1,prod:e.prod||!1,recursive:e.recursive||!1},n,a);r!==0&&r!==1&&(process.exitCode=r)},"execute");export{h as default};
1
+ var q=Object.defineProperty;var $=(t,r)=>q(t,"name",{value:r,configurable:!0});import{createRequire as A}from"node:module";import{B as I,w as b,K as N,p as g,L as R,E as M,d as U,e as B,c as E,Q as J,X as z,Y as Q,a as Y,y as Z,U as K,R as V,Z as W,r as X,J as G,$ as H,h as ee,a0 as oe}from"./bin.js";import{readJsonSync as te,writeJsonSync as se}from"@visulima/fs";import{M as ne}from"../packem_shared/index-OlP7U_t5.js";import{r as re}from"../packem_shared/typosquats-XkC1CnOa.js";import{d as C,o as j}from"../packem_shared/utils-DrNg0XTR.js";const L=A(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=$(t=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[r,e]=k.versions.node.split(".").map(Number);if(r>22||r===22&&e>=3||r===20&&e>=16)return k.getBuiltinModule(t)}return L(t)},"__cjs_getBuiltinModule"),{createInterface:F}=O("node:readline");var ae=Object.defineProperty,h=$((t,r)=>ae(t,"name",{value:r,configurable:!0}),"c");const P=h(t=>t==="default"?"catalog:":`catalog:${t}`,"buildCatalogRef"),S=h(t=>t==="default"?"default catalog":`catalog "${t}"`,"labelForCatalog"),ie=h((t,r)=>{const e=[];for(const[o,n]of r)o.includes(":")||n.has(t)&&e.push(o);if(e.length===0)return;if(e.length===1){const[o]=e;return{source:S(o),spec:P(o)}}const a=e.find(o=>o==="default")??e[0],i=e.filter(o=>o!==a);return{candidates:[...e],conflict:!0,source:`${S(a)} (also in: ${i.map(o=>S(o)).join(", ")})`,spec:P(a)}},"resolveFromCatalogs"),ce=h((t,r)=>{const e=new Map;for(const[l,p]of r){if(!l.includes(":"))continue;const f=p.get(t);f!==void 0&&e.set(f,(e.get(f)??0)+1)}if(e.size===0)return;const a=[...e.entries()],i=a.reduce((l,[,p])=>l+p,0);if(a.length===1){const[[l]]=a;return{source:`siblings (${String(i)} pkg${i===1?"":"s"} on ${l})`,spec:l}}const o=[...a].sort((l,p)=>p[1]-l[1]),[n,s]=o[0],c=o.slice(1).map(([l,p])=>`${l} (×${String(p)})`);return{candidates:o.map(([l])=>l),conflict:!0,source:`siblings (most common: ${n} ×${String(s)}; conflicts: ${c.join(", ")})`,spec:n}},"resolveFromSiblings"),le=h((t,r)=>ie(t,r)||ce(t,r),"conformToCatalog");var pe=Object.defineProperty,d=$((t,r)=>pe(t,"name",{value:r,configurable:!0}),"m");const T=d(async(t,r=1e4)=>{const e=new Map,a=new AbortController,i=setTimeout(()=>{a.abort()},r);try{const o=t.map(async n=>{try{const s=await fetch(`https://registry.npmjs.org/${n}/latest`,{headers:{Accept:"application/json"},signal:a.signal});if(s.ok){const c=await s.json();c.version&&e.set(n,c.version)}}catch{}});await Promise.all(o)}finally{clearTimeout(i)}return e},"resolveLatestVersions"),fe=d((t,r,e)=>{const a=[];for(const i of t.values()){const{overall:o}=i.score,n=I(o),s=`${String(Math.round(o*100))}%`,c=i.alerts.length,l=b(i),p=N(l,i.version,e),f=n==="red"?U:n==="yellow"?B:E;if(p?g.info(` ${f(s)} ${R(i)} ${M(`[accepted: ${p.reason}]`)}`):g.info(` ${f(s)} ${R(i)}`),c>0){const u=i.alerts.filter(m=>m.severity==="critical"||m.severity==="high").length;u>0&&g.warn(` ${String(u)} critical/high alert${u===1?"":"s"}`)}o<r&&!p&&a.push(i)}return a},"displaySecurityReports"),ge=d(async(t,r)=>{const e=F({input:process.stdin,output:process.stdout}),a=d(s=>new Promise(c=>{e.question(s,l=>{c(l.trim())})}),"ask"),i=String(Math.round(r*100));g.warn(""),g.warn(`${String(t.length)} package${t.length===1?"":"s"} scored below the minimum threshold (${i}%):`);for(const s of t){const c=b(s),l=`${String(Math.round(s.score.overall*100))}%`;g.warn(` • ${c}@${s.version} — score: ${l} (${J(s.score.overall)})`)}g.warn("");const o=await a("Continue adding these packages? [y/N] ");if(o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes")return e.close(),!1;const n=await a("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),n.toLowerCase()==="y"||n.toLowerCase()==="yes"){g.notice(""),g.notice("Add the following to security.socket.acceptedRisks in vis.config.ts:"),g.notice("");for(const s of t){const c=b(s),l=z(c,s.version,s.score.overall,"Reviewed and accepted");g.notice(l)}g.notice("")}return!0},"confirmLowScorePackages"),ue=d(async(t,r,e,a)=>{const i=t.map(f=>C(f)),o=new Map;for(const f of i)if(f.versionSpec){const u=Q.coerce(f.versionSpec);u&&o.set(f.name,u.version)}const n=i.filter(f=>!o.has(f.name)).map(f=>f.name),s=n.length>0?await T(n):new Map,c=[];for(const f of i){const u=o.get(f.name)??s.get(f.name);u&&c.push({name:f.name,version:u})}if(c.length===0)return!0;g.info(""),g.info("Socket.dev security check:");const l=await Y(c,r);if(l.size===0)return g.info(" Could not fetch security data. Proceeding."),!0;const p=fe(l,e,a);return p.length===0?(g.info(""),!0):process.stdin.isTTY?ge(p,e):(g.warn(`Aborting: ${String(p.length)} package${p.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},"runSocketPreCheck"),de=["dependencies","devDependencies","peerDependencies","optionalDependencies"],me=d(t=>t.savePeer?"peerDependencies":t.saveOptional?"optionalDependencies":t.saveDev?"devDependencies":"dependencies","pickDepSection"),_=d((t,r)=>t.startsWith("catalog:")||!r?t:t.replace(/^[\^~]/,""),"applyExactPrefix"),ve=d(async(t,r)=>{const e=[];for(const o of t){const{name:n,versionSpec:s}=C(o);if(!n)continue;if(s!==void 0){e.push({explicit:s,name:n});continue}const c=le(n,r);if(c){c.conflict&&g.warn(`${n}: ambiguous constraint — picking ${c.spec} (${c.source}). Pass ${n}@<version> to override.`),e.push({entry:{name:n,source:c.source,spec:c.spec},kind:"resolved",name:n});continue}e.push({kind:"missing",name:n})}const a=e.filter(o=>"kind"in o&&o.kind==="missing").map(o=>o.name),i=a.length>0?await T(a):new Map;return e.map(o=>{if("explicit"in o)return{name:o.name,source:"explicit",spec:o.explicit};if(o.kind==="resolved")return o.entry;const n=i.get(o.name);if(n===void 0)throw new Error(`--to: cannot resolve a version for "${o.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${o.name}@<version> explicitly.`);const s=`^${n}`;return g.info(`${o.name}: no existing constraint — using registry latest (${s}). Add to a catalog to share this version across workspace packages.`),{name:o.name,source:"registry latest",spec:s}})},"planConformedSpecs"),we=d((t,r,e,a)=>{for(const{name:i,spec:o}of r){const n=_(o,a);for(const c of de){if(c===e)continue;const l=t[c];l?.[i]!==void 0&&(delete l[i],Object.keys(l).length===0&&delete t[c])}let s=t[e];s===void 0&&(s={},t[e]=s),s[i]=n}},"applyPlannedSpecsToPackageJson"),ke=d(async({ignoreScripts:t,logger:r,options:e,packages:a,pm:i,target:o,visConfig:n,workspaceRoot:s})=>{const{workspace:c}=Z(s,n??{}),l=c.projects[o];if(!l){const v=Object.keys(c.projects).sort();throw new Error(`--to: workspace package "${o}" not found. Available: ${v.length>0?v.slice(0,10).join(", "):"(none)"}${v.length>10?`, ... (${String(v.length-10)} more)`:""}.`)}const p=ne(s,l.root,"package.json"),{packageManager:f}=K(s),u=V(s,f),m=me(e),w=e.exact??!1,y=await ve(a,u);if(y.length===0)return 0;const x=te(p);we(x,y,m,w),se(p,x,{indent:W(p,{useEditorconfig:n?.editorconfig??!0}),overwrite:!0});for(const v of y){const D=_(v.spec,w);g.info(`${E("+")} ${v.name}@${D} → ${o}/${m} (${M(v.source)})`)}return X(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:t,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},s,r)},"applyConformedAdd"),Re=d(async({argument:t,logger:r,options:e,visConfig:a,workspaceRoot:i})=>{let o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const p=o.map(u=>C(u)),f=await re(p.map(u=>u.name),a?.security?.typosquatAllowlist);if(!f.ok){process.exitCode=1;return}o=p.map((u,m)=>{const w=f.packages[m];return w!==u.name?u.versionSpec?`${w}@${u.versionSpec}`:w??"":o[m]??""})}if(e.socketCheck!==!1){const p=G(a?.security?.socket);if(p){const f=p.minimumScore??H;if(!await ue(o,p,f,a?.security?.socket?.acceptedRisks)){process.exitCode=1;return}}}const n=process.cwd(),s=ee(i??n,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),c=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&j(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!i)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const p=await ke({ignoreScripts:c,logger:r,options:e,packages:o,pm:s,target:e.to,visConfig:a,workspaceRoot:i});p!==0&&(process.exitCode=p);return}const l=oe(s,{exact:e.exact||!1,filter:j(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:o,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},n,r,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:c});l!==0&&(process.exitCode=l)},"execute");export{Re as default};