@visulima/vis 1.0.0-alpha.10 → 1.0.0-alpha.12

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 (107) hide show
  1. package/CHANGELOG.md +185 -42
  2. package/LICENSE.md +586 -0
  3. package/README.md +26 -4
  4. package/dist/config/index.d.ts +1739 -0
  5. package/dist/config/index.js +1 -0
  6. package/dist/generate/index.d.ts +1 -1
  7. package/dist/packem_chunks/applyDefaults.js +2 -0
  8. package/dist/packem_chunks/bin.js +232 -60
  9. package/dist/packem_chunks/doctor-probe.js +2 -0
  10. package/dist/packem_chunks/fix.js +11 -53
  11. package/dist/packem_chunks/handler.js +1 -1
  12. package/dist/packem_chunks/handler10.js +2 -1
  13. package/dist/packem_chunks/handler11.js +1 -1
  14. package/dist/packem_chunks/handler12.js +5 -2
  15. package/dist/packem_chunks/handler13.js +1 -1
  16. package/dist/packem_chunks/handler14.js +18 -5
  17. package/dist/packem_chunks/handler15.js +20 -1
  18. package/dist/packem_chunks/handler16.js +1 -20
  19. package/dist/packem_chunks/handler17.js +1 -1
  20. package/dist/packem_chunks/handler18.js +1 -1
  21. package/dist/packem_chunks/handler19.js +1 -1
  22. package/dist/packem_chunks/handler2.js +2 -1
  23. package/dist/packem_chunks/handler20.js +5 -1
  24. package/dist/packem_chunks/handler21.js +1 -1
  25. package/dist/packem_chunks/handler22.js +1 -5
  26. package/dist/packem_chunks/handler23.js +5 -1
  27. package/dist/packem_chunks/handler24.js +1 -1
  28. package/dist/packem_chunks/handler25.js +3 -5
  29. package/dist/packem_chunks/handler26.js +1 -1
  30. package/dist/packem_chunks/handler27.js +1 -3
  31. package/dist/packem_chunks/handler28.js +7 -1
  32. package/dist/packem_chunks/handler29.js +22 -6
  33. package/dist/packem_chunks/handler3.js +4 -2
  34. package/dist/packem_chunks/handler30.js +3 -23
  35. package/dist/packem_chunks/handler31.js +1 -3
  36. package/dist/packem_chunks/handler32.js +2 -2
  37. package/dist/packem_chunks/handler33.js +24 -23
  38. package/dist/packem_chunks/handler34.js +2 -2
  39. package/dist/packem_chunks/handler35.js +3 -19
  40. package/dist/packem_chunks/handler36.js +22 -428
  41. package/dist/packem_chunks/handler37.js +428 -22
  42. package/dist/packem_chunks/handler38.js +20 -20
  43. package/dist/packem_chunks/handler39.js +21 -21
  44. package/dist/packem_chunks/handler4.js +2 -4
  45. package/dist/packem_chunks/handler40.js +22 -3
  46. package/dist/packem_chunks/handler41.js +6 -10
  47. package/dist/packem_chunks/handler42.js +5 -153
  48. package/dist/packem_chunks/handler43.js +10 -42
  49. package/dist/packem_chunks/handler44.js +153 -3
  50. package/dist/packem_chunks/handler45.js +25 -27
  51. package/dist/packem_chunks/handler46.js +3 -0
  52. package/dist/packem_chunks/handler47.js +27 -0
  53. package/dist/packem_chunks/handler48.js +42 -0
  54. package/dist/packem_chunks/handler5.js +8 -2
  55. package/dist/packem_chunks/handler6.js +1 -13
  56. package/dist/packem_chunks/handler7.js +1 -8
  57. package/dist/packem_chunks/handler8.js +1 -1
  58. package/dist/packem_chunks/handler9.js +1 -1
  59. package/dist/packem_chunks/heal-accept.js +10 -0
  60. package/dist/packem_chunks/heal.js +14 -0
  61. package/dist/packem_chunks/index.js +3 -3
  62. package/dist/packem_chunks/tar.js +3 -0
  63. package/dist/packem_shared/ai-analysis-hm8d2W7z.js +67 -0
  64. package/dist/packem_shared/{ai-cache-Bynt6Y9x.js → ai-cache-DoiF80AR.js} +1 -1
  65. package/dist/packem_shared/ai-fix-nn4zOE95.js +43 -0
  66. package/dist/packem_shared/cache-directory-CwHlJhgx.js +1 -0
  67. package/dist/packem_shared/dependency-scan-COr5n63B.js +2 -0
  68. package/dist/packem_shared/{docker-BcfqH4Av.js → docker-D6OGr5_S.js} +1 -1
  69. package/dist/packem_shared/{failure-log-DqYen0LC.js → failure-log-iUVLf6ts.js} +1 -1
  70. package/dist/packem_shared/flakiness-D9wf0t56.js +1 -0
  71. package/dist/packem_shared/giget-CcEy_Elm.js +2 -0
  72. package/dist/packem_shared/index-DH-5hsrC.js +1 -0
  73. package/dist/packem_shared/otel-DxDUPJJH.js +6 -0
  74. package/dist/packem_shared/otelPlugin-CQq6poq8.js +1 -0
  75. package/dist/packem_shared/registry-CkubDdiY.js +2 -0
  76. package/dist/packem_shared/run-summary-utils-BfBvjzhY.js +1 -0
  77. package/dist/packem_shared/{runtime-check-CGHal8SO.js → runtime-check-BXZ43CBW.js} +1 -1
  78. package/dist/packem_shared/{selectors-CfH9ZY08.js → selectors-BylODRiM.js} +1 -1
  79. package/dist/packem_shared/toolchain-BgBOUHII.js +5 -0
  80. package/dist/packem_shared/typosquats-CcZl99B1.js +1 -0
  81. package/dist/packem_shared/verify-Baj5mFJ7.js +1 -0
  82. package/dist/packem_shared/vis-update-app-D1jl0UZZ.js +1 -0
  83. package/index.js +54 -53
  84. package/package.json +34 -26
  85. package/schemas/project.schema.json +739 -299
  86. package/schemas/vis-config.schema.json +3383 -278
  87. package/skills/vis/SKILL.md +96 -0
  88. package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
  89. package/templates/buildkite-ci/template.yml +20 -0
  90. package/dist/errors/index.d.ts +0 -26
  91. package/dist/errors/index.js +0 -1
  92. package/dist/packem_chunks/config.js +0 -2
  93. package/dist/packem_shared/VisConfigCycleError-CAYNC7d-.js +0 -1
  94. package/dist/packem_shared/VisConfigError-B5LP1zRf.js +0 -1
  95. package/dist/packem_shared/VisConfigLoadError-CeqBSd2Z.js +0 -2
  96. package/dist/packem_shared/VisConfigNotFoundError-DZ9KC527.js +0 -5
  97. package/dist/packem_shared/VisUpdateApp-D-L4_-Iu.js +0 -1
  98. package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +0 -1
  99. package/dist/packem_shared/ai-analysis-CGuy7dfE.js +0 -67
  100. package/dist/packem_shared/cache-directory-D72ZEag2.js +0 -1
  101. package/dist/packem_shared/catalog-BVPerCwG.js +0 -12
  102. package/dist/packem_shared/dependency-scan-Du0tBu64.js +0 -2
  103. package/dist/packem_shared/flakiness-DSIHZGBT.js +0 -1
  104. package/dist/packem_shared/run-summary-utils-C24Aaf9E.js +0 -1
  105. package/dist/packem_shared/target-merge-DNa-6eWu.js +0 -1
  106. package/dist/packem_shared/toolchain-DQfTQY8E.js +0 -5
  107. package/dist/packem_shared/typosquats-DOR8izpX.js +0 -1
@@ -0,0 +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,53 +1,11 @@
1
- var J=Object.defineProperty;var y=(t,e)=>J(t,"name",{value:e,configurable:!0});import{createRequire as L}from"node:module";import{bold as P,dim as O,yellow as j,cyan as K,red as E,green as M}from"@visulima/colorize";import{isAbsolute as B,resolve as T,join as z,relative as F}from"@visulima/path";import{readLastRunSummary as G}from"@visulima/task-runner";import{l as Q,a as N}from"../packem_shared/failure-log-DqYen0LC.js";import{r as V,f as R,a as X,d as Z}from"../packem_shared/run-summary-utils-C24Aaf9E.js";import{w as rt,b as at,r as it}from"../packem_shared/ai-analysis-CGuy7dfE.js";import{M as ot,N as st,O as nt}from"../packem_shared/ai-cache-Bynt6Y9x.js";import{p as d}from"./bin.js";const U=L(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=y(t=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[e,r]=$.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return $.getBuiltinModule(t)}return U(t)},"__cjs_getBuiltinModule"),{createInterface:Y}=_("node:readline"),{readFile:tt,writeFile:et}=_("node:fs/promises");var ut=Object.defineProperty,k=y((t,e)=>ut(t,"name",{value:e,configurable:!0}),"u");const ct=32*1024,pt=k((t,e)=>{if(t.length<=e)return t;const r=t.slice(-e),a=t.length-r.length;return`[…${String(a)} bytes truncated from head…]
2
- ${r}`},"truncateHead"),lt=k(async(t,e)=>e===void 0?G(t):V(t,e),"loadSummary"),dt=k(async(t,e,r={})=>{const a=r.terminalOutputLimit??ct,[o,s]=await Promise.all([Q(t,e),lt(t,r.runId)]),i=s?R(s,e):void 0;if(!o&&!i)return;let n,u;if(s&&i){const c=await X(t,s.id),h=c?R(c,e):void 0;n=Z(i.hashDetails,h?.hashDetails),u=c?.id}const l=o?.terminalOutput??"";return{command:o?.command??void 0,cwd:o?.cwd??void 0,dependencies:i?.dependencies??[],duration:i?.duration,exitCode:o?.exitCode??i?.exitCode,hash:i?.hash??o?.hash,hashDetails:i?.hashDetails,hashDiff:n,previousRunId:u,project:i?.target.project,runId:s?.id??o?.runId,status:o?.status??(i?ht(i):void 0),target:i?.target.target,taskId:e,terminalOutput:pt(l,a),terminalOutputCaptured:!!o,timestamp:o?.timestamp??i?.endTime??i?.startTime}},"aggregateFailureContext"),ht=k(t=>{if(t.exitCode!==void 0&&t.exitCode!==0)return"failure";switch(t.cacheStatus){case"HIT":return"local-cache";case"REMOTE_HIT":return"remote-cache";case"SKIPPED":return"skipped";default:return t.exitCode===0?"success":void 0}},"mapCacheStatusToTaskStatus");var ft=Object.defineProperty,p=y((t,e)=>ft(t,"name",{value:e,configurable:!0}),"a");const mt=3600*1e3,D=80,gt=new Set(["high","low","medium"]),wt=p(()=>`You are an expert software engineer helping fix a failing build/test/lint task.
3
-
4
- You will be given:
5
- - The terminal output (stdout/stderr) from the failed task.
6
- - Optional metadata: command, working directory, project, task hash, and a diff describing what changed in the task's hash inputs since the previous run that did not fail.
7
-
8
- Your job:
9
- 1. Identify the root cause from the terminal output.
10
- 2. Propose a minimal set of source-file patches that fix the cause.
11
- 3. If you cannot determine a safe fix, set "cannotFix" with a clear, actionable explanation.
12
-
13
- Constraints:
14
- - Patches MUST be exact string replacements. The "oldString" must appear verbatim in the named file. Paths are relative to the working directory.
15
- - Each "oldString" must be unique within its file. Include surrounding context so the match is unambiguous.
16
- - Do NOT include unrelated cleanup, formatting changes, or speculative refactors.
17
- - If the failure is environmental (missing tool, network) or requires running commands, prefer "cannotFix" over a guess.
18
- - Keep "explanation" short (1-3 sentences). Reserve "reason" on each patch for why that specific edit fixes the cause.
19
-
20
- Respond ONLY with valid JSON in this exact structure:
21
- {
22
- "explanation": "Brief root-cause analysis and what the fix does.",
23
- "confidence": "low|medium|high",
24
- "patches": [
25
- {
26
- "file": "path/relative/to/cwd.ts",
27
- "oldString": "exact text to find",
28
- "newString": "exact replacement text",
29
- "reason": "why this change fixes it"
30
- }
31
- ],
32
- "cannotFix": "optional — set when no safe patch can be proposed"
33
- }`,"buildSystemPrompt"),C=p((t,e)=>{const r=[];if(e.added.length>0&&r.push(` added: ${e.added.join(", ")}`),e.changed.length>0&&r.push(` changed: ${e.changed.join(", ")}`),e.removed.length>0&&r.push(` removed: ${e.removed.join(", ")}`),r.length!==0)return`- ${t}:
34
- ${r.join(`
35
- `)}`},"formatBucket"),vt=p(t=>{if(!t.hashDiff)return"No hash-diff available — there is no previous run to compare against.";const e=[];t.hashDiff.commandChanged&&e.push("- command line changed since previous run");const r=C("file inputs",t.hashDiff.nodes),a=C("implicit deps",t.hashDiff.implicitDeps),o=C("runtime/env",t.hashDiff.runtime);return r&&e.push(r),a&&e.push(a),o&&e.push(o),e.length===0?"No detectable changes between this run and the previous run.":e.join(`
36
- `)},"buildHashDiffSummary"),xt=p(t=>{const e=[];return e.push(`Task: ${t.taskId}`),t.project&&e.push(`Project: ${t.project}`),t.target&&e.push(`Target: ${t.target}`),t.command&&e.push(`Command: ${t.command}`),t.cwd&&e.push(`CWD: ${t.cwd}`),t.exitCode!==void 0&&e.push(`Exit code: ${String(t.exitCode)}`),t.hash&&e.push(`Task hash: ${t.hash}`),e.push("","Hash-diff since previous run:",vt(t),""),t.terminalOutputCaptured?e.push("Terminal output:","```",t.terminalOutput,"```"):e.push("Terminal output: <no failure log was captured for this task>",'Set "cannotFix" and tell the user to re-run with `vis run` so logs can be captured.'),e.join(`
37
- `)},"buildUserPrompt"),yt=p(t=>`${wt()}
38
-
39
- ${xt(t)}`,"buildFixPrompt"),$t=p((t,e)=>{const r=Array.isArray(t.patches)?t.patches:[],a=[];for(const s of r)typeof s.file!="string"||s.file.length===0||typeof s.oldString!="string"||s.oldString.length===0||typeof s.newString=="string"&&a.push({file:s.file,newString:s.newString,oldString:s.oldString,reason:typeof s.reason=="string"&&s.reason.length>0?s.reason:void 0});const o=typeof t.cannotFix=="string"&&t.cannotFix.length>0?t.cannotFix:void 0;return{cannotFix:o,confidence:gt.has(t.confidence)?t.confidence:"low",explanation:typeof t.explanation=="string"?t.explanation:"",patches:o?[]:a,provider:e}},"normalizeFixProposal"),bt=p((t,e)=>{const r=rt(t);return!r||typeof r!="object"?{cannotFix:"AI response was not valid JSON.",confidence:"low",explanation:"Failed to parse AI response.",patches:[],provider:e}:$t(r,e)},"parseFixResponse"),St=p((t,e)=>ot({cwd:e.cwd??null,flow:"ai-fix",hash:e.hash??null,provider:t,taskId:e.taskId,terminalOutput:e.terminalOutput,terminalOutputCaptured:e.terminalOutputCaptured}),"buildFixCacheKey"),Pt=p(async(t,e,r={})=>{const a=at(r.config);if(!a){e.warn(`No AI provider available — install one of: claude, gemini, copilot, codex.
40
- `);return}const o=r.cache!==!1,s=St(a.name,t);if(o){const i=st(s);if(i)return e.info(`Using cached fix proposal from ${i.provider}.
41
- `),i}e.info(`Generating fix proposal with ${a.name}...
42
- `);try{const i=await it(a,yt(t)),n=bt(i,a.name);return o&&n.patches.length>0&&!n.cannotFix&&nt(s,n,mt),n}catch(i){const n=i instanceof Error?i.message:String(i);e.warn(`AI fix proposal failed (${n}).
43
- `);return}},"runFixAnalysis"),W=p((t,e,r)=>B(r)?T(r):T(z(e??t,r)),"resolvePatchPath"),kt=p((t,e)=>{const r=F(t,e);return r===""?!0:!r.startsWith("..")&&!B(r)},"isInsideWorkspace"),Ct=p((t,e,r)=>{const a=t.indexOf(e),o=Math.max(0,a-D),s=Math.min(t.length,a+e.length+D),i=t.slice(o,s);return{previewAfter:`${t.slice(o,a)}${r}${t.slice(a+e.length,s)}`,previewBefore:i}},"buildPreview"),S=p(async(t,e,r,a={})=>{const o=a.dryRun===!0,s=new Map,i=[];for(const n of r.patches){const u=W(t,e,n.file);if(!kt(t,u)){i.push({absolutePath:u,patch:n,status:"outside-workspace"});continue}let l=s.get(u);if(l===void 0){try{l=await tt(u,"utf8")}catch(m){const f=m.code;i.push({absolutePath:u,error:f==="ENOENT"?void 0:m.message,patch:n,status:f==="ENOENT"?"missing-file":"error"});continue}s.set(u,l)}const c=l.indexOf(n.oldString);if(c===-1){i.push({absolutePath:u,patch:n,status:"no-match"});continue}if(l.indexOf(n.oldString,c+n.oldString.length)!==-1){i.push({absolutePath:u,patch:n,status:"ambiguous-match"});continue}const{previewAfter:h,previewBefore:b}=Ct(l,n.oldString,n.newString),w=`${l.slice(0,c)}${n.newString}${l.slice(c+n.oldString.length)}`;if(!o)try{await et(u,w,"utf8")}catch(m){s.delete(u),i.push({absolutePath:u,error:m.message,patch:n,status:"error"});continue}s.set(u,w),i.push({absolutePath:u,patch:n,previewAfter:h,previewBefore:b,status:"applied"})}return i},"applyFixProposal");var It=Object.defineProperty,g=y((t,e)=>It(t,"name",{value:e,configurable:!0}),"c");const Ft={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},q=g((t,e,r)=>{const a=W(t,e,r),o=F(t,a);return o===""||o.startsWith("..")?a:o},"formatDisplayPath"),Ot=g((t,e,r)=>{const a=[];if(a.push(P(`Fix proposal (${t.provider}, confidence: ${t.confidence})`)),a.push(""),a.push(t.explanation||O("<no explanation>")),t.cannotFix)return a.push(""),a.push(j(`Cannot fix automatically: ${t.cannotFix}`)),a.join(`
44
- `);if(t.patches.length===0)return a.push(""),a.push(j("No patches were proposed.")),a.join(`
45
- `);a.push(""),a.push(P(`Patches (${String(t.patches.length)}):`));for(const[o,s]of t.patches.entries()){const i=q(e,r,s.file);a.push(""),a.push(K(`[${String(o+1)}] ${i}`)),s.reason&&a.push(O(` reason: ${s.reason}`));for(const n of s.oldString.split(`
46
- `))a.push(E(` - ${n}`));for(const n of s.newString.split(`
47
- `))a.push(M(` + ${n}`))}return a.join(`
48
- `)},"formatProposalText"),A=g((t,e,r)=>{const a=[];for(const o of t){const s=o.absolutePath?F(e,o.absolutePath)||o.absolutePath:q(e,r,o.patch.file),i=Ft[o.status];o.status==="applied"?a.push(M(` ✓ ${s}: ${i}`)):a.push(E(` ✗ ${s}: ${i}${o.error?` (${o.error})`:""}`))}return a.join(`
49
- `)},"formatPatchResultsText"),I=g(t=>{let e=0,r=0;for(const a of t)a.status==="applied"?e+=1:r+=1;return{applied:e,failed:r}},"summarizePatchResults"),jt=g(t=>new Promise(e=>{const r=Y({input:process.stdin,output:process.stderr});r.question(`${t} (y/N) `,a=>{r.close();const o=a.trim().toLowerCase();e(o==="y"||o==="yes")})}),"confirmPrompt"),Tt=g(t=>t??process.cwd(),"resolveWorkspaceRoot"),Ht=g(async({argument:t,logger:e,options:r,visConfig:a,workspaceRoot:o})=>{const s=t[0],i=Tt(o),n=(r.format??"text")==="json";if(!s){if(n){const v=N(i);process.stdout.write(`${JSON.stringify({availableTasks:v,error:"No task ID specified"},void 0,2)}
50
- `)}else{d.error("No task ID specified. Usage: vis ai fix <project>:<target>");const v=N(i);if(v.length>0){d.info("Tasks with captured failure logs:");for(const x of v)d.info(` - ${x}`)}else d.notice("No failure logs found. Re-run a failing task with `vis run` to capture logs.")}process.exitCode=1;return}const u=await dt(i,s,{runId:r.run});if(!u){n?process.stdout.write(`${JSON.stringify({error:"No failure log or run summary found",taskId:s},void 0,2)}
51
- `):(d.error(`No failure log or run summary found for task "${s}".`),d.notice("Re-run the task with `vis run` so its terminal output and run metadata are captured.")),process.exitCode=1;return}u.terminalOutputCaptured||d.warn(`No captured terminal output for "${s}". Re-run with \`vis run\` for a better fix proposal.`);const l=a?.ai,c=await Pt(u,e,{cache:r.noCache!==!0,config:l});if(!c){n&&process.stdout.write(`${JSON.stringify({error:"AI fix proposal failed or no provider available",taskId:s},void 0,2)}
52
- `),process.exitCode=1;return}const h=r.apply===!0;if(n){const v=h?void 0:await S(i,u.cwd,c,{dryRun:!0}),x=h?await S(i,u.cwd,c):void 0;if(process.stdout.write(`${JSON.stringify({appliedResults:x,dryRunResults:v,failureContext:{cwd:u.cwd,hash:u.hash,runId:u.runId,taskId:u.taskId,terminalOutputCaptured:u.terminalOutputCaptured},proposal:c},void 0,2)}
53
- `),h&&x){const{failed:H}=I(x);H>0&&(process.exitCode=1)}return}if(e.info(Ot(c,i,u.cwd)),c.cannotFix||c.patches.length===0)return;const b=await S(i,u.cwd,c,{dryRun:!0}),w=I(b);if(e.info(""),e.info(P("Patch validation:")),e.info(A(b,i,u.cwd)),!h){e.info(""),d.info("Re-run with --apply to write these patches to disk.");return}if(w.applied===0){d.error("No patches can be applied (every patch failed validation)."),process.exitCode=1;return}if(r.yes!==!0&&(e.info(""),!await jt(`Apply ${String(w.applied)} patch${w.applied===1?"":"es"} to disk?`))){d.notice("Aborted. Nothing written.");return}const m=await S(i,u.cwd,c),f=I(m);e.info(""),e.info(P("Apply results:")),e.info(A(m,i,u.cwd)),e.info(""),f.failed===0?d.success(`Applied ${String(f.applied)} patch${f.applied===1?"":"es"}.`):(d.warn(`${String(f.applied)} applied, ${String(f.failed)} failed.`),process.exitCode=1)},"aiFix");export{Ht as aiFix};
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 +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{r as E,s as R}from"./bin.js";import{r as x,f as G}from"../packem_shared/selectors-CfH9ZY08.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 v=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(v,{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 y=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 y)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{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 +1,2 @@
1
- var i=Object.defineProperty;var n=(e,o)=>i(e,"name",{value:o,configurable:!0});import{J as p,n as d}from"./bin.js";var f=Object.defineProperty,l=n((e,o)=>f(e,"name",{value:o,configurable:!0}),"t");const k=l(async({logger:e,options:o,visConfig:s,workspaceRoot:t})=>{const c=t??process.cwd(),r=p(c,{configBackend:s?.install?.backend}),a=d(r,o.check||!1,c,e);a!==0&&(process.exitCode=a)},"execute");export{k as default};
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(`
2
+ `));return}throw new Error(`Unknown subcommand: "${n}". Expected scaffold or prune.`)},"execute");export{C as default};
@@ -1 +1 @@
1
- var k=Object.defineProperty;var n=(e,s)=>k(e,"name",{value:s,configurable:!0});import{J as f,o as u}from"./bin.js";var v=Object.defineProperty,h=n((e,s)=>v(e,"name",{value:s,configurable:!0}),"n");const x=h(async({argument:e,logger:s,options:a,visConfig:i,workspaceRoot:t})=>{const o=e;if(!o||o.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[g,...l]=o,r=t??process.cwd(),p=f(r,{configBackend:i?.install?.backend}),d=a.package?Array.isArray(a.package)?a.package:[a.package]:[],c=u(p,{additionalPackages:d,args:l,package:g,shellMode:a.shellMode||!1,silent:a.silent||!1},r,s);c!==0&&(process.exitCode=c)},"execute");export{x as default};
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,2 +1,5 @@
1
- var g=Object.defineProperty;var p=(t,o)=>g(t,"name",{value:o,configurable:!0});import{join as d}from"@visulima/path";import{r as k,s as v}from"./bin.js";import{s as h,p as j}from"../packem_shared/docker-BcfqH4Av.js";var x=Object.defineProperty,E=p((t,o)=>x(t,"name",{value:o,configurable:!0}),"m");const P=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}=k(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.sort().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
- `));return}throw new Error(`Unknown subcommand: "${n}". Expected scaffold or prune.`)},"execute");export{P 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 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 +1 @@
1
- var p=Object.defineProperty;var c=(o,r)=>p(o,"name",{value:r,configurable:!0});import{J as m,l as g}from"./bin.js";import{o as u}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,w=c((o,r)=>v(o,"name",{value:r,configurable:!0}),"l");const b=w(async({argument:o,logger:r,options:e,visConfig:t,workspaceRoot:n})=>{const s=o;if(!s||s.length===0)throw new Error("No command specified. Usage: vis exec <command> [args...]");const[i,...f]=s,a=n??process.cwd(),d=m(a,{configBackend:t?.install?.backend}),l=g(d,{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},a,r);l!==0&&(process.exitCode=l)},"execute");export{b as default};
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,5 +1,18 @@
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,o]=c.versions.node.split(".").map(Number);if(i>22||i===22&&o>=3||i===20&&o>=16)return c.getBuiltinModule(e)}return _(e)},"__cjs_getBuiltinModule"),{rmSync:b}=d("node:fs"),{homedir:s}=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(s(),".vis"),h=[r(s(),".zshrc"),r(s(),".zshenv"),r(s(),".bashrc"),r(s(),".bash_profile"),r(s(),".profile"),r(s(),".config","fish","config.fish")],T=m(e=>{const i=[];for(const o of h)if(u(o))try{const l=p(o).split(`
2
- `),n=l.filter(t=>!t.includes(".vis/bin")&&!t.includes("VIS_HOME")&&!t.includes("# vis "));n.length!==l.length&&(j(o,n.join(`
3
- `)),i.push(o))}catch{e.warn(`warning: could not clean ${o}`)}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 o=h.filter(n=>u(n)&&p(n).includes(".vis"));for(const n of o)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)}`)}e.info(" vis has been uninstalled.")},"execute");export{F as default};
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 +1,20 @@
1
- var g=Object.defineProperty;var n=(e,a)=>g(e,"name",{value:a,configurable:!0});import{J as l,e as d}from"./bin.js";var k=Object.defineProperty,u=n((e,a)=>k(e,"name",{value:a,configurable:!0}),"c");const w=u(async({argument:e,logger:a,options:c,visConfig:r,workspaceRoot:i})=>{if(!e||e.length===0)throw new Error("No package specified. Usage: vis info <package> [field...]");const[t,...f]=e,s=i??process.cwd(),p=l(s,{configBackend:r?.install?.backend}),o=d(p,{fields:f,json:c.json||!1,package:t},s,a);o!==0&&o!==1&&(process.exitCode=o)},"execute");export{w as default};
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,20 +1 @@
1
- var _=Object.defineProperty;var v=(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 $}from"@visulima/path";import{findVisConfigFile as B}from"./config.js";import{p as t,I as E,T as x,c as R}from"./bin.js";const I=C(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=v(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"),{execSync:T}=j("node:child_process"),{createInterface:O}=j("node:readline");var N=Object.defineProperty,f=v((s,e)=>N(s,"name",{value:e,configurable:!0}),"l");const M=f(s=>{const e=[];return g($(s,"turbo.json"))&&e.push("turborepo"),g($(s,"nx.json"))&&e.push("nx"),g($(s,".moon"))&&e.push("moon"),e},"detectExistingTools"),P=f((s,e)=>new Promise(o=>{s.question(e,n=>{o(n.trim())})}),"ask"),d=f(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=f((s,e)=>{const o=[],n=Object.entries(e.allowBuilds).filter(([,c])=>c).map(([c])=>` "${c}": 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=f(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 c=await d(n," Scan for packages with build scripts?"),l={};if(c){t.info(" Scanning node_modules...");const a=E(s,{});if(a.length>0){t.info(` Found ${String(a.length)} package${a.length===1?"":"s"} with build scripts:
20
- `);for(const r of a){const u=await d(n,` Allow ${r}?`,!1),S=r.split(" (")[0]??r;l[S]=u,u&&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 h=!1;(e.name==="pnpm"||e.name==="yarn"||e.name==="npm"||e.name==="bun")&&(t.info(""),h=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 a=e.name==="pnpm"?"pnpm exec":e.name==="yarn"?"yarn exec":e.name==="bun"?"bunx":"npx";for(const r of m){t.info(` Migrating from ${r}...`);try{T(`${a} vis migrate ${r}`,{cwd:s,stdio:"inherit"})}catch{t.warn(` Migration from ${r} had issues — run \`vis migrate ${r}\` manually.`)}}if(g(o))t.success(`Migrated config written to ${o}`);else{const r=w(e.name,{allowBuilds:l,enableSocket:i,staged:y});b(o,r),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(b(o,k),t.success(`Created ${o}`),h){const a=Object.fromEntries(Object.entries(l).filter(([,u])=>u)),r=x(e.name,s,a);for(const u of r)t.success(` ${u}`)}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: ${h?"done":"skipped"}`),t.info(""),t.notice(" Run 'vis doctor' to see your project's full health status."),t.info("")},"runInteractiveInit"),K=f((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 c=x(e.name,s,{});for(const l of c)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=f(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 c=i??$(o,"vis.config.ts");process.stdin.isTTY&&s.interactive!==!1&&!s.noInteractive?await q(o,n,c):K(o,n,s,c)},"execute");export{G as default};
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 +1 @@
1
- var x=Object.defineProperty;var f=(o,e)=>x(o,"name",{value:e,configurable:!0});import{createRequire as C}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,c as $,J as L,G as A,g as B}from"./bin.js";import{s as D}from"../packem_shared/typosquats-DOR8izpX.js";import{o as E}from"../packem_shared/utils-DrNg0XTR.js";const O=C(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=_?$(s):L(s,{backend:v,configBackend:r?.install?.backend})}catch(n){t.error(n instanceof Error?n.message:String(n)),process.exitCode=1;return}const p=A(s,a);p&&t.warn(p);const w=E(e.filter),u=e.ci||!1,d=e.frozenLockfile||u,j=e.noFrozenLockfile||e.force||e.lockfileOnly,h=P(s),m=d||!j&&h;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 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 +1 @@
1
- var l=Object.defineProperty;var c=(e,o)=>l(e,"name",{value:o,configurable:!0});import{J as u,t as d}from"./bin.js";var f=Object.defineProperty,g=c((e,o)=>f(e,"name",{value:o,configurable:!0}),"s");const v=g(async({argument:e,logger:o,visConfig:n,workspaceRoot:r})=>{const s=e?.[0]??null,t=r??process.cwd(),i=u(t,{configBackend:n?.install?.backend}),a=d(i,s,t,o);a!==0&&(process.exitCode=a)},"execute");export{v as default};
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 +1 @@
1
- var b=Object.defineProperty;var u=(r,n)=>b(r,"name",{value:n,configurable:!0});import{r as O}from"./bin.js";import{f as T}from"../packem_shared/selectors-CfH9ZY08.js";var w=Object.defineProperty,d=u((r,n)=>w(r,"name",{value:n,configurable:!0}),"f");const S=d(async({logger:r,options:n,visConfig:h,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root.");const{projectOptions:k,workspace:s}=O(l,h);let a=Object.keys(s.projects).sort();if(n.query&&(a=T(a,s,n.query)),a.length===0){r.info("No projects found.");return}if(n.json){const o=a.map(e=>{const t=s.projects[e],p=k.get(e)??{},g=Object.entries(t.targets??{}).map(([y])=>{const i=p[y];return{aliases:i?.aliases??[],command:i?.command,description:i?.description,name:y,type:i?.type}});return{language:t.language,layer:t.layer,name:e,root:t.root,stack:t.stack,tags:t.tags??[],targets:g,type:t.projectType??"library"}});r.info(JSON.stringify(o,null,2));return}const f=["Project","Type","Layer","Tags","Targets"],j=a.map(o=>{const e=s.projects[o],t=Object.keys(e.targets??{});return[o,e.projectType??"library",e.layer??"—",(e.tags??[]).join(", ")||"—",t.length>4?`${t.slice(0,4).join(", ")}… (${String(t.length)})`:t.join(", ")||"—"]}),c=f.map((o,e)=>{const t=j.reduce((p,g)=>Math.max(p,(g[e]??"").length),0);return Math.max(o.length,t)}),m=d((o,e)=>o.padEnd(e),"pad");r.info(f.map((o,e)=>m(o,c[e])).join(" ")),r.info(c.map(o=>"─".repeat(o)).join("──"));for(const o of j)r.info(o.map((e,t)=>m(e,c[t])).join(" "));r.info(""),r.info(`${String(a.length)} project(s)`)},"execute");export{S as default};
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 +1,2 @@
1
- var S=Object.defineProperty;var v=(s,i)=>S(s,"name",{value:i,configurable:!0});import{createRequire as b}from"node:module";import{dim as j,red as T,yellow as q,green as M}from"@visulima/colorize";import{coerce as P}from"semver";import{B as x,S as k,q as L,p as c,N as y,R as A,Q as N,U,V as B,b as D,J as I,Y as O}from"./bin.js";import{r as V}from"../packem_shared/typosquats-DOR8izpX.js";import{d as $,o as Y}from"../packem_shared/utils-DrNg0XTR.js";const C=b(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=v(s=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[i,e]=h.versions.node.split(".").map(Number);if(i>22||i===22&&e>=3||i===20&&e>=16)return h.getBuiltinModule(s)}return C(s)},"__cjs_getBuiltinModule"),{createInterface:R}=_("node:readline");var z=Object.defineProperty,d=v((s,i)=>z(s,"name",{value:i,configurable:!0}),"d");const E=d(async(s,i=1e4)=>{const e=new Map,p=new AbortController,n=setTimeout(()=>{p.abort()},i);try{const o=s.map(async u=>{try{const t=await fetch(`https://registry.npmjs.org/${u}/latest`,{headers:{Accept:"application/json"},signal:p.signal});if(t.ok){const l=await t.json();l.version&&e.set(u,l.version)}}catch{}});await Promise.all(o)}finally{clearTimeout(n)}return e},"resolveLatestVersions"),F=d((s,i,e)=>{const p=[];for(const n of s.values()){const{overall:o}=n.score,u=x(o),t=`${String(Math.round(o*100))}%`,l=n.alerts.length,m=k(n),f=L(m,n.version,e),r=u==="red"?T:u==="yellow"?q:M;if(f?c.info(` ${r(t)} ${y(n)} ${j(`[accepted: ${f.reason}]`)}`):c.info(` ${r(t)} ${y(n)}`),l>0){const a=n.alerts.filter(g=>g.severity==="critical"||g.severity==="high").length;a>0&&c.warn(` ${String(a)} critical/high alert${a===1?"":"s"}`)}o<i&&!f&&p.push(n)}return p},"displaySecurityReports"),H=d(async(s,i)=>{const e=R({input:process.stdin,output:process.stdout}),p=d(t=>new Promise(l=>{e.question(t,m=>{l(m.trim())})}),"ask"),n=String(Math.round(i*100));c.warn(""),c.warn(`${String(s.length)} package${s.length===1?"":"s"} scored below the minimum threshold (${n}%):`);for(const t of s){const l=k(t),m=`${String(Math.round(t.score.overall*100))}%`;c.warn(` ${l}@${t.version} score: ${m} (${A(t.score.overall)})`)}c.warn("");const o=await p("Continue adding these packages? [y/N] ");if(o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes")return e.close(),!1;const u=await p("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),u.toLowerCase()==="y"||u.toLowerCase()==="yes"){c.notice(""),c.notice("Add the following to security.socket.acceptedRisks in vis.config.ts:"),c.notice("");for(const t of s){const l=k(t),m=N(l,t.version,t.score.overall,"Reviewed and accepted");c.notice(m)}c.notice("")}return!0},"confirmLowScorePackages"),J=d(async(s,i,e,p)=>{const n=s.map($),o=new Map;for(const r of n)if(r.versionSpec){const a=P(r.versionSpec);a&&o.set(r.name,a.version)}const u=n.filter(r=>!o.has(r.name)).map(r=>r.name),t=u.length>0?await E(u):new Map,l=[];for(const r of n){const a=o.get(r.name)??t.get(r.name);a&&l.push({name:r.name,version:a})}if(l.length===0)return!0;c.info(""),c.info("Socket.dev security check:");const m=await U(l,i);if(m.size===0)return c.info(" Could not fetch security data. Proceeding."),!0;const f=F(m,e,p);return f.length===0?(c.info(""),!0):process.stdin.isTTY?H(f,e):(c.warn(`Aborting: ${String(f.length)} package${f.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},"runSocketPreCheck"),oe=d(async({argument:s,logger:i,options:e,visConfig:p,workspaceRoot:n})=>{let o=s;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(!e.noTyposquatCheck){const f=o.map(a=>$(a)),r=await V(f.map(a=>a.name),p?.security?.typosquatAllowlist);if(!r.ok){process.exitCode=1;return}o=f.map((a,g)=>{const w=r.packages[g];return w!==a.name?a.versionSpec?`${w}@${a.versionSpec}`:w??"":o[g]??""})}if(!e.noSocketCheck){const f=B(p?.security?.socket);if(f){const r=f.minimumScore??D;if(!await J(o,f,r,p?.security?.socket?.acceptedRisks)){process.exitCode=1;return}}}const u=process.cwd(),t=I(n??u,{configBackend:p?.install?.backend}),l=!e.runScripts,m=O(t,{exact:e.exact||!1,filter:Y(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},u,i,{ignoreScripts:l});m!==0&&(process.exitCode=m)},"execute");export{oe as default};
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(`
2
+ `));const t=[f,`--projects=${a.join(",")}`];e.parallel!==void 0&&t.push(`--parallel=${String(e.parallel)}`),e.cache||t.push("--no-cache"),e.dryRun&&t.push("--dry-run"),e.partition&&t.push(`--partition=${String(e.partition)}`),e.reverse&&t.push("--reverse"),typeof e.runnerTags=="string"&&e.runnerTags!==""&&t.push(`--runner-tags=${e.runnerTags}`);try{await l.runCommand("run",{argv:t})}finally{delete process.env.VIS_AFFECTED_FILES}},"execute");export{T as default};
@@ -1 +1,5 @@
1
- var d=Object.defineProperty;var c=(e,o)=>d(e,"name",{value:o,configurable:!0});import{J as g,u as p}from"./bin.js";var f=Object.defineProperty,b=c((e,o)=>f(e,"name",{value:o,configurable:!0}),"n");const h=b(async({argument:e,logger:o,visConfig:r,workspaceRoot:i})=>{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=i??process.cwd(),u=g(n,{configBackend:r?.install?.backend}),t=p(u,s,l,n,o);t!==0&&(process.exitCode=t)},"execute");export{h 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-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 +1 @@
1
- var f=Object.defineProperty;var t=(e,o)=>f(e,"name",{value:o,configurable:!0});import{J as p,Z as g}from"./bin.js";import{o as v}from"../packem_shared/utils-DrNg0XTR.js";var d=Object.defineProperty,k=t((e,o)=>d(e,"name",{value:o,configurable:!0}),"t");const b=k(async({argument:e,logger:o,options:a,visConfig:i,workspaceRoot:l})=>{const s=e;if(!s||s.length===0)throw new Error("No packages specified. Usage: vis remove <packages...>");const r=process.cwd(),n=p(l??r,{configBackend:i?.install?.backend}),c=g(n,{filter:v(a.filter),global:a.global||!1,packages:s,recursive:a.recursive||!1,saveDev:a.saveDev||!1,workspaceRoot:a.workspaceRoot||!1},r,o);c!==0&&(process.exitCode=c)},"execute");export{b as default};
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,5 +1 @@
1
- var _=Object.defineProperty;var $=(e,r)=>_(e,"name",{value:r,configurable:!0});import{createRequire as N}from"node:module";import{isAccessibleSync as w,readFileSync as b}from"@visulima/fs";import{resolve as J,join as y,relative as F,basename as I}from"@visulima/path";import P from"zeptomatch";import{sortPackageJsonStringWithOptions as C}from"#native";import{D as M,f as k,p as d}from"./bin.js";import{f as O}from"../packem_shared/utils-DrNg0XTR.js";const A=N(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=$(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[r,s]=g.versions.node.split(".").map(Number);if(r>22||r===22&&s>=3||r===20&&s>=16)return g.getBuiltinModule(e)}return A(e)},"__cjs_getBuiltinModule"),{writeFileSync:E}=x("node:fs");var T=Object.defineProperty,a=$((e,r)=>T(e,"name",{value:r,configurable:!0}),"c");const q=a(e=>{const r=new Set,s=[],i=a(n=>{const o=J(n);!r.has(o)&&w(o)&&(r.add(o),s.push(o))},"addFile");i(y(e,"package.json"));const t=M(e);if(t){const n=k(e,t);for(const o of n)i(y(e,o,"package.json"))}else{const n=y(e,"package.json");if(w(n)){const o=JSON.parse(b(n)),l=Array.isArray(o.workspaces)?o.workspaces:o.workspaces?.packages;if(l){const m=k(e,l);for(const f of m)i(y(e,f,"package.json"))}}}return s},"findPackageJsonFiles"),B=a(e=>/\n([ \t]+)/.exec(e)?.[1]??" ","detectIndent"),D=a(e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},"resolveIndentOverride"),j=a(e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),"splitList"),L=a(e=>e.includes(`\r
2
- `)?"crlf":"lf","detectLineEnding"),R=new Set(["auto","crlf","lf"]),W=a(e=>{if(e===void 0||e==="")return"auto";if(R.has(e))return e;d.error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`),process.exit(2)},"validateLineEnding"),z=a((e,r,s)=>r.length===0?e:e.filter(i=>{const t=F(s,i),n=I(i);return!r.some(o=>{const l=o.includes("/")?t:n;return P(o,l)})}),"filterByIgnore"),U=a((e,r)=>{if(r.length===0)return e;const s={},i=new Set;for(const t of r)Object.hasOwn(e,t)&&(s[t]=e[t],i.add(t));for(const t of Object.keys(e))i.has(t)||(s[t]=e[t]);return s},"applySortOrder"),G=a((e,r,s)=>{if(s.length===0)return e;const i={...e};for(const t of s)Object.hasOwn(r,t)&&(i[t]=r[t]);return i},"restoreUnsortedSections"),H=a((e,r)=>{const s=r.indent??B(e),i=r.lineEnding==="auto"?L(e):r.lineEnding,t=C(e,{pretty:!1,sortScripts:r.sortScripts});let n=JSON.parse(t);if(r.unsorted.length>0){const l=JSON.parse(e);n=G(n,l,r.unsorted)}n=U(n,r.sortOrder);let o=JSON.stringify(n,null,s);return r.finalNewline&&(o+=`
3
- `),i==="crlf"&&(o=o.replaceAll(`
4
- `,`\r
5
- `)),o},"sortContents"),te=a(async({options:e,visConfig:r,workspaceRoot:s})=>{const i=s??process.cwd(),t=r?.sortPackageJson,n=e.check||!1,o={finalNewline:e.finalNewline??t?.finalNewline??!0,ignore:[...j(e.ignore),...t?.ignore??[]],indent:D(e.indent??t?.indent),lineEnding:W(e.lineEnding??t?.lineEnding),sortOrder:[...j(e.sortOrder),...t?.sortOrder??[]],sortScripts:e.sortScripts||t?.sortScripts||!1,unsorted:[...j(e.unsorted),...t?.unsorted??[]]},l=q(i),m=z(l,o.ignore,i);if(m.length===0){d.info(l.length===0?"No package.json files found.":"All package.json files were excluded by --ignore.");return}let f=0,p=0,u=0;for(const c of m)try{const h=b(c);let S;try{S=H(h,o)}catch(v){d.error(`${c}: ${O(v)}`),u++;continue}if(h===S){p++;continue}f++,n?d.warn(`${c} is not sorted`):(E(c,S,"utf8"),d.success(`Sorted ${c}`))}catch(h){d.error(`${c}: ${O(h)}`),u++}if(n)f>0?(d.info(`${f} file${f===1?"":"s"} not sorted, ${p} already sorted`),process.exitCode=1):d.info(`All ${p} package.json file${p===1?" is":"s are"} sorted`);else{const c=[];f>0&&c.push(`sorted ${f} file${f===1?"":"s"}`),p>0&&c.push(`${p} already sorted`),u>0&&c.push(`${u} error${u===1?"":"s"}`),d.info(c.join(", "))}u>0&&(process.exitCode=1)},"execute");export{te 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{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 +1,5 @@
1
- var T=Object.defineProperty;var j=(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{r as z,s as A}from"./bin.js";import{a as B}from"../packem_shared/flakiness-DSIHZGBT.js";import{c as I}from"../packem_shared/runtime-check-CGHal8SO.js";const q=C(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=j(e=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[t,i]=n.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return n.getBuiltinModule(e)}return q(e)},"__cjs_getBuiltinModule"),{readdirSync:F}=x("node:fs");var K=Object.defineProperty,O=j((e,t)=>K(e,"name",{value:t,configurable:!0}),"h");const r=O(e=>e?f("✓"):v("✗"),"icon"),X=O(async({logger:e,options:t,visConfig:i,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root.");const{config:y,packageJsons:w,workspace:u}=z(s,i),R=A(s,u,w),$=Object.keys(u.projects).length,k=new Set(Object.values(u.projects).flatMap(p=>Object.keys(p.targets??{}))).size,a=I(s);let o=0;y.constraints&&(o=V(R,y.constraints).length);const c=B(s,{minRuns:2});let l;const g=b(s,".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:o,flakyTasks:c.length,projects:$,runtimeIssues:a.length,targets:k},null,2));return}e.info(""),e.info(` ${J("VIS STATUS")}`),e.info(""),e.info(` ${r(!0)} ${String($)} 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{X 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{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 +1 @@
1
- var b=Object.defineProperty;var j=(t,e)=>b(t,"name",{value:e,configurable:!0});import{createTaskGraph as v}from"@visulima/task-runner";import{r as y,s 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}=y(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=v(m,{projectGraph:f,workspace:r});if(!p.tasks[o])throw new Error(`Task "${o}" is not reachable in the graph.`);const d=O(p,o),g=x(p,o);if(e.info(""),e.info(`Why ${o}?`),e.info(""),d&&d.length>1){e.info("Shortest path from a root to this task:");for(const[n,u]of d.entries()){const h=n===0?" ":`${" ".repeat(n+1)}└─ `;e.info(`${h}${u}`)}e.info("")}else e.info(" This task is itself a root — nothing upstream depends on it."),e.info("");if(g.length>0){e.info(`Directly depended on by ${g.length} task(s):`);for(const n of g)e.info(` - ${n}`);e.info("")}const l=p.dependencies[o]??[];if(l.length>0){e.info(`This task depends on ${l.length} task(s):`);for(const n of[...l].sort())e.info(` - ${n}`);e.info("")}},"execute");export{I as default};
1
+ var 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};