@visulima/vis 6.1.0 → 6.1.2

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 (175) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/config/index.d.ts +1226 -1216
  5. package/dist/packem_chunks/bloom-sync.js +1 -1
  6. package/dist/packem_chunks/cargo-lock.js +5 -0
  7. package/dist/packem_chunks/cargo-plan.js +3 -3
  8. package/dist/packem_chunks/catalog-detector.js +1 -1
  9. package/dist/packem_chunks/catalog.js +1 -94
  10. package/dist/packem_chunks/catalog2.js +11 -0
  11. package/dist/packem_chunks/cli-exec.js +1 -1
  12. package/dist/packem_chunks/cli-main.js +156 -174
  13. package/dist/packem_chunks/context.js +8 -0
  14. package/dist/packem_chunks/fix.js +1 -1
  15. package/dist/packem_chunks/handler10.js +1 -1
  16. package/dist/packem_chunks/handler12.js +1 -1
  17. package/dist/packem_chunks/handler13.js +1 -1
  18. package/dist/packem_chunks/handler14.js +1 -1
  19. package/dist/packem_chunks/handler15.js +1 -1
  20. package/dist/packem_chunks/handler19.js +5 -5
  21. package/dist/packem_chunks/handler2.js +1 -1
  22. package/dist/packem_chunks/handler20.js +1 -1
  23. package/dist/packem_chunks/handler21.js +1 -1
  24. package/dist/packem_chunks/handler23.js +1 -1
  25. package/dist/packem_chunks/handler24.js +1 -1
  26. package/dist/packem_chunks/handler25.js +1 -1
  27. package/dist/packem_chunks/handler28.js +1 -1
  28. package/dist/packem_chunks/handler3.js +1 -1
  29. package/dist/packem_chunks/handler31.js +1 -1
  30. package/dist/packem_chunks/handler32.js +1 -1
  31. package/dist/packem_chunks/handler33.js +1 -1
  32. package/dist/packem_chunks/handler34.js +3 -3
  33. package/dist/packem_chunks/handler35.js +1 -1
  34. package/dist/packem_chunks/handler36.js +1 -1
  35. package/dist/packem_chunks/handler38.js +2 -2
  36. package/dist/packem_chunks/handler39.js +5 -5
  37. package/dist/packem_chunks/handler4.js +4 -4
  38. package/dist/packem_chunks/handler40.js +1 -1
  39. package/dist/packem_chunks/handler41.js +1 -1
  40. package/dist/packem_chunks/handler42.js +1 -1
  41. package/dist/packem_chunks/handler43.js +1 -1
  42. package/dist/packem_chunks/handler44.js +1 -1
  43. package/dist/packem_chunks/handler45.js +1 -1
  44. package/dist/packem_chunks/handler46.js +1 -1
  45. package/dist/packem_chunks/handler47.js +1 -1
  46. package/dist/packem_chunks/handler48.js +1 -1
  47. package/dist/packem_chunks/handler49.js +1 -1
  48. package/dist/packem_chunks/handler5.js +4 -4
  49. package/dist/packem_chunks/handler50.js +5 -5
  50. package/dist/packem_chunks/handler52.js +1 -1
  51. package/dist/packem_chunks/handler54.js +2 -2
  52. package/dist/packem_chunks/handler55.js +1 -1
  53. package/dist/packem_chunks/handler56.js +3 -3
  54. package/dist/packem_chunks/handler57.js +4 -4
  55. package/dist/packem_chunks/handler58.js +4 -4
  56. package/dist/packem_chunks/handler59.js +2 -2
  57. package/dist/packem_chunks/handler6.js +7 -7
  58. package/dist/packem_chunks/handler60.js +1 -1
  59. package/dist/packem_chunks/handler61.js +2 -2
  60. package/dist/packem_chunks/handler62.js +1 -1
  61. package/dist/packem_chunks/handler63.js +3 -3
  62. package/dist/packem_chunks/handler64.js +3 -3
  63. package/dist/packem_chunks/handler65.js +2 -2
  64. package/dist/packem_chunks/handler66.js +2 -2
  65. package/dist/packem_chunks/handler67.js +5 -5
  66. package/dist/packem_chunks/handler68.js +12 -25
  67. package/dist/packem_chunks/handler69.js +25 -22
  68. package/dist/packem_chunks/handler70.js +22 -10
  69. package/dist/packem_chunks/handler71.js +10 -133
  70. package/dist/packem_chunks/handler72.js +133 -23
  71. package/dist/packem_chunks/handler73.js +23 -323
  72. package/dist/packem_chunks/handler74.js +274 -659
  73. package/dist/packem_chunks/handler75.js +708 -48
  74. package/dist/packem_chunks/handler76.js +48 -27
  75. package/dist/packem_chunks/handler77.js +27 -3
  76. package/dist/packem_chunks/handler78.js +3 -191
  77. package/dist/packem_chunks/handler79.js +191 -0
  78. package/dist/packem_chunks/handler8.js +1 -1
  79. package/dist/packem_chunks/heal.js +2 -2
  80. package/dist/packem_chunks/help-command.js +1 -1
  81. package/dist/packem_chunks/index2.js +3 -58
  82. package/dist/packem_chunks/index3.js +40 -3
  83. package/dist/packem_chunks/index6.js +135 -7
  84. package/dist/packem_chunks/index7.js +7 -135
  85. package/dist/packem_chunks/keys-refresh.js +1 -1
  86. package/dist/packem_chunks/list.js +2 -2
  87. package/dist/packem_chunks/prune.js +1 -1
  88. package/dist/packem_chunks/python-plan.js +3 -3
  89. package/dist/packem_chunks/python-projects.js +1 -1
  90. package/dist/packem_chunks/python.js +1 -0
  91. package/dist/packem_chunks/run.js +1 -1
  92. package/dist/packem_chunks/snapshot.js +2 -2
  93. package/dist/packem_chunks/state.js +2 -2
  94. package/dist/packem_chunks/status.js +1 -1
  95. package/dist/packem_chunks/sync.js +1 -1
  96. package/dist/packem_chunks/verify-lockfile.js +1 -1
  97. package/dist/packem_chunks/version-resolver.js +1 -1
  98. package/dist/packem_chunks/workspace.js +2 -2
  99. package/dist/packem_shared/ReleaseClient-CWD9BC5w.js +1 -0
  100. package/dist/packem_shared/advisories-DO-P0V1_.js +1 -0
  101. package/dist/packem_shared/{affected-selection-DGb6Xu5K.js → affected-selection-CeeZo7Uy.js} +1 -1
  102. package/dist/packem_shared/{ai-analysis-pldoS_N4.js → ai-analysis-BCJ1kuDM.js} +3 -3
  103. package/dist/packem_shared/ai-cache-iSIyY3So.js +1 -0
  104. package/dist/packem_shared/{ai-fix-D9MxigBQ.js → ai-fix-DIMErSws.js} +6 -6
  105. package/dist/packem_shared/apply-DoeQAAGm.js +6 -0
  106. package/dist/packem_shared/apply-release-plan-BalHtK-g.js +15 -0
  107. package/dist/packem_shared/{bin-AZQv95jh.js → bin-BcLTer1k.js} +1 -1
  108. package/dist/packem_shared/clean-package-json-rutwkKl-.js +1 -0
  109. package/dist/packem_shared/createAdapter-DMK4bBET.js +1 -0
  110. package/dist/packem_shared/createVersionActions-DXo4z8VN.js +1 -0
  111. package/dist/packem_shared/dependency-scan-D_v3KM59.js +1 -0
  112. package/dist/packem_shared/{ecosystem-gate-DiqQj0LJ.js → ecosystem-gate-CwsTc7YW.js} +1 -1
  113. package/dist/packem_shared/env-BSXG3QKH.js +4 -0
  114. package/dist/packem_shared/failure-log-DIsKBKaI.js +2 -0
  115. package/dist/packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js +1 -0
  116. package/dist/packem_shared/glob-Cyk1H9ZL-CL9optrn.js +1 -0
  117. package/dist/packem_shared/{index-JRb5wabN.js → index-9Ot7jTd4.js} +1 -1
  118. package/dist/packem_shared/index-BS6A9QR_.js +1 -0
  119. package/dist/packem_shared/lifecycle-CQjeMPY0.js +2 -0
  120. package/dist/packem_shared/missing-package-json-1BIoWQq0.js +1 -0
  121. package/dist/packem_shared/multi-eco-lockfiles-fgkpeHJv.js +1 -0
  122. package/dist/packem_shared/npmrc-CHsOyMvA.js +2 -0
  123. package/dist/packem_shared/osv-Do9PMOea.js +1 -0
  124. package/dist/packem_shared/{package-version-KLwH0Ivy.js → package-version-Bq6Cne_7.js} +1 -1
  125. package/dist/packem_shared/packument-CbTmbHU4.js +1 -0
  126. package/dist/packem_shared/{project-name-filter-B1ZCsbOW.js → project-name-filter-ZQaLgytG.js} +1 -1
  127. package/dist/packem_shared/{provenance-L1M2FPy_.js → provenance-SX1MxPUZ.js} +1 -1
  128. package/dist/packem_shared/publish-Dc0XGH3K.js +34 -0
  129. package/dist/packem_shared/registry-Dg9XI6RT.js +81 -0
  130. package/dist/packem_shared/registry-keys-z038Ecb4.js +1 -0
  131. package/dist/packem_shared/removeSync-g1D5kONg-LbjATA8v.js +1 -0
  132. package/dist/packem_shared/renderToString-DR0zDUjh-DXppT6AM.js +3 -0
  133. package/dist/packem_shared/{resolve-explicit-CQa37JSq.js → resolve-explicit-D9kdTNvl.js} +1 -1
  134. package/dist/packem_shared/{run-D-uVGHQ4.js → run-DLvd3RIZ.js} +1 -1
  135. package/dist/packem_shared/run-summary-utils-CMeURYtS.js +1 -0
  136. package/dist/packem_shared/s1ngularity-BuU9Cxpy.js +1 -0
  137. package/dist/packem_shared/{scaffold-files-DVyfB0yz.js → scaffold-files-DJlz36Mu.js} +1 -1
  138. package/dist/packem_shared/scan-progress-DymX71_5.js +2 -0
  139. package/dist/packem_shared/{signatures-DIqFUOfs.js → signatures-CeL0bOEo.js} +1 -1
  140. package/dist/packem_shared/spinner-CPoBymcv.js +1 -0
  141. package/dist/packem_shared/table-oA7p7-yP.js +1 -0
  142. package/dist/packem_shared/tabs-BiSifphV.js +1 -0
  143. package/dist/packem_shared/{task-env-DzR4RkOj.js → task-env-C2lmxvzA.js} +1 -1
  144. package/dist/packem_shared/typosquats-BFKus_aM.js +1 -0
  145. package/dist/packem_shared/use-measured-height-BHm-HiSF.js +1 -0
  146. package/dist/packem_shared/vis-update-app-6QOYxnNx.js +1 -0
  147. package/dist/packem_shared/{vis-user-error-CRmrBaD1.js → vis-user-error-3YS7sPYy.js} +1 -1
  148. package/dist/packem_shared/{watch-loop-D1_e-qIl.js → watch-loop-CGi66Fs0.js} +1 -1
  149. package/dist/packem_shared/xxh3-BLHlvhgT.js +1 -0
  150. package/dist/release/core/package-managers/index.js +1 -1
  151. package/dist/release/core/version-actions/index.js +1 -1
  152. package/dist/release/index.js +1 -1
  153. package/index.js +26 -26
  154. package/package.json +9 -9
  155. package/dist/packem_chunks/orchestrator.js +0 -46
  156. package/dist/packem_shared/ReleaseClient-DAvbxCdo.js +0 -1
  157. package/dist/packem_shared/createAdapter-F7GidOzU.js +0 -1
  158. package/dist/packem_shared/createVersionActions-ByaJ1Nbv.js +0 -1
  159. package/dist/packem_shared/dependency-scan-CawAKoU_.js +0 -1
  160. package/dist/packem_shared/failure-log-BP-gCUb5.js +0 -2
  161. package/dist/packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js +0 -4
  162. package/dist/packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js +0 -1
  163. package/dist/packem_shared/index-CDHP1kby.js +0 -1
  164. package/dist/packem_shared/lifecycle-DvmDIRbb.js +0 -2
  165. package/dist/packem_shared/missing-package-json-Cu5YVAot.js +0 -1
  166. package/dist/packem_shared/multi-eco-lockfiles-B2X3yhyo.js +0 -1
  167. package/dist/packem_shared/packument-zb18Jnlw.js +0 -1
  168. package/dist/packem_shared/registry-keys-DxdqMzyp.js +0 -1
  169. package/dist/packem_shared/s1ngularity-CO5GkkqX.js +0 -1
  170. package/dist/packem_shared/scan-progress-RwCRxJdX.js +0 -2
  171. package/dist/packem_shared/spinner-BJjbNl1F.js +0 -1
  172. package/dist/packem_shared/tabs--uxJGL8N.js +0 -1
  173. package/dist/packem_shared/typosquats-D4DEHhFy.js +0 -1
  174. package/dist/packem_shared/use-measured-height-DUZyyias.js +0 -1
  175. package/dist/packem_shared/vis-update-app-9b2kSk9f.js +0 -1
@@ -1,2 +1,2 @@
1
- import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-BzhrR_iC.js";import{l as B,m as X,n as J,D as Q,o as Z,z as ee,k as _}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as se}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{h as re,U as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{g as ne,r as ce}from"../packem_shared/packument-zb18Jnlw.js";import{q as ie,j as ae,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as le,o as fe}from"../packem_shared/pm-runner-RM72mDZg.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-HSsYGCQd.js";let z;const V=e=>(z??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return V(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(te(k)){const e=se(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{re(B());const t=`${k}.${String(process.pid)}.tmp`;oe(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await ne(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ce(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await J([{name:t,version:c}],{apiToken:a,minimumScore:Q});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??X(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>Z(G(e)),Re={critical:E,high:E,low:v,medium:S},D=e=>{if(!(e===void 0||e<0))return ee(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=D(r),a=D(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},j=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ie(i.label.padEnd(j)):" ".repeat(j);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ae(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},De=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),je=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!De(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},je)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
2
- `);if(c)return R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:!0};const g=await Y("? Ok to proceed? (y/N) ",e.readline);return g&&R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:g}},Je=async({argument:e,logger:t,options:s,process:r,visConfig:o,workspaceRoot:a})=>{const n=e;if(!n||n.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[u,...i]=n,c=a??r.cwd,l=s.package?Array.isArray(s.package)?s.package:[s.package]:[],f=s.shellMode?l:[u,...l];for(const h of f){const d=!s.info||_(r.env.VIS_DLX_NO_INFO),b=!d&&s.info;if(!(await Be({forceInfo:b,noInfo:d,offline:s.offline||!1,pkg:h,socketToken:o?.security?.socket?.apiToken??r.env.VIS_SOCKET_TOKEN,workspaceRoot:c,yes:s.yes||_(r.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const y=ue({options:s,visConfig:o},c),p=le(c,{backend:pe(y),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),m=fe(p,{additionalPackages:l,args:i,package:u,shellMode:s.shellMode||!1,silent:s.silent||!1},c,t,{offline:s.offline||!1});m!==0&&(process.exitCode=m)};export{Je as default};
1
+ import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-BzhrR_iC.js";import{l as B,m as X,n as J,D as Q,o as Z,k as _}from"../packem_shared/env-BSXG3QKH.js";import{y as ee}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as te}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{h as se,U as re}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{g as oe,r as ne}from"../packem_shared/packument-CbTmbHU4.js";import{q as ce,j as ie,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-Ca_EEVfw.js";import{z as ae}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{a as le,o as fe}from"../packem_shared/pm-runner-RM72mDZg.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-HSsYGCQd.js";let z;const V=e=>(z??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return V(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(ee(k)){const e=te(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{se(B());const t=`${k}.${String(process.pid)}.tmp`;re(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ne(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await J([{name:t,version:c}],{apiToken:a,minimumScore:Q});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??X(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>Z(G(e)),Re={critical:E,high:E,low:v,medium:S},D=e=>{if(!(e===void 0||e<0))return ae(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=D(r),a=D(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},j=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ce(i.label.padEnd(j)):" ".repeat(j);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ie(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},De=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),je=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!De(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},je)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
2
+ `);if(c)return R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:!0};const g=await Y("? Ok to proceed? (y/N) ",e.readline);return g&&R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:g}},Qe=async({argument:e,logger:t,options:s,process:r,visConfig:o,workspaceRoot:a})=>{const n=e;if(!n||n.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[u,...i]=n,c=a??r.cwd,l=s.package?Array.isArray(s.package)?s.package:[s.package]:[],f=s.shellMode?l:[u,...l];for(const h of f){const d=!s.info||_(r.env.VIS_DLX_NO_INFO),b=!d&&s.info;if(!(await Be({forceInfo:b,noInfo:d,offline:s.offline||!1,pkg:h,socketToken:o?.security?.socket?.apiToken??r.env.VIS_SOCKET_TOKEN,workspaceRoot:c,yes:s.yes||_(r.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const y=ue({options:s,visConfig:o},c),p=le(c,{backend:pe(y),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),m=fe(p,{additionalPackages:l,args:i,package:u,shellMode:s.shellMode||!1,silent:s.silent||!1},c,t,{offline:s.offline||!1});m!==0&&(process.exitCode=m)};export{Qe as default};
@@ -1,8 +1,8 @@
1
- import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J as W,q as ae}from"../packem_shared/index.server-Ca_EEVfw.js";import{v as R,a as G,U as I,z as Se,e as M}from"../packem_shared/index-BzhrR_iC.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Re,scanGitHistory as Te}from"@visulima/secret-scanner";import{a4 as Ae,a5 as Q,p as y}from"./cli-main.js";import{E as je,A as Ne}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{U as Fe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as Me}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=J("node:module"),{pathToFileURL:ue}=J("node:url"),{execFileSync:Le}=J("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,ze=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let Ve=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=ze(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#y()):(this.#k(),this.#y()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#y())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#y(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#w())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
1
+ import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as ae}from"../packem_shared/index.server-Ca_EEVfw.js";import{v as R,a as G,U as I,z as Se,e as M}from"../packem_shared/index-BzhrR_iC.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Re,scanGitHistory as Te}from"@visulima/secret-scanner";import{U as Ae,W as Q,p as y}from"./cli-main.js";import{E as je,A as Ne}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{U as Fe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as Me}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,W=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=W("node:module"),{pathToFileURL:ue}=W("node:url"),{execFileSync:Le}=W("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,ze=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let Ve=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=ze(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#y()):(this.#k(),this.#y()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#y())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#y(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#w())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
2
2
  `),this.#d=0}#$(){if(this.#d>0&&this.#s.isTTY){for(let t=1;t<this.#d;t+=1)this.#s.write("\x1B[1A\x1B[2K");this.#s.write("\r\x1B[K")}this.#d=0}#S(t){this.#f=t,this.#n?this.#n.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#$(),this.#s.write(`${t}
3
- `))}#g(t,n){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;let s="";const r=this.#b[t];r&&(s=this.#a?this.#a(r):r),this.#r&&(s=`${this.#r} ${s}`),n&&(s=`${s} ${n}`),this.#S(s)}};const Je=(e,t,n)=>{const s=n.toLowerCase();e[s]??=new Map;const r=e[s].get(t);if(r!==void 0)return r;const{size:i}=e[s],c=`<${n.toUpperCase()}${i>0?String(i):""}>`;return e[s].set(t,c),c},Z=(e,t)=>{const{replacement:n,tag:s,text:r}=t;return typeof n=="function"?String(n(r,void 0)):typeof n=="string"?n:Je(e,r,s)},We=(e,t)=>{const n={};let s="",r=0;for(const i of e){const{start:c,text:o}=i;if(o==="")continue;if(Number.isInteger(c)&&c>=0&&t.slice(c,c+o.length)===o){if(c<r)continue;s+=t.slice(r,c)+Z(n,i),r=c+o.length;continue}let a=t.indexOf(o,r);if(a===-1)continue;const l=Z(n,i);for(;a!==-1;)s+=t.slice(r,a)+l,r=a+o.length,a=t.indexOf(o,r)}return s+t.slice(r)},Ge=e=>[...e.reduce((t,n)=>t.set(n.text+String(n.start)+n.tag,n),new Map).values()].toSorted((t,n)=>{const s=t.start-n.start;return s!==0?s:n.text.length-t.text.length}),Ke=(e,t)=>{const n=[];for(const s of e){const{key:r,pattern:i}=s,c=s.compiledPattern??new RegExp(i,"giu");c.lastIndex=0;let o;for(;(o=c.exec(t))!==null;){const a=s;n.push({replacement:a.userReplacement??a.replacement!==void 0?a.replacement:void 0,start:o.index,tag:r,text:o[0]}),o.index===c.lastIndex&&(c.lastIndex+=1)}}return n},Xe=(e,t,n,s)=>Ge([...Ke(n,e)]),fe=(e,t,n)=>{const s=[],r=[];for(const o of t)typeof o=="object"&&o.pattern&&s.push(o),r.push((typeof o=="object"?o.key:String(o)).toLowerCase());let i=e;const c=Xe(e,r,s);return i=We(c,i),i},k=e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},q=new Set(["__proto__","prototype","constructor"]),Ye=Math.max(...[...q].map(e=>e.length)),de=1e6,Qe=e=>e>="0"&&e<="9";function he(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=de}return!1}function D(e,t){return q.has(e)?!1:(e&&he(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function Ze(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let n="",s="",r=!1,i="start",c=!1,o=0;for(const a of e){if(o++,c){n+=a,c=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);c=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="property";break}if(!D(n,t))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=Ye&&q.has(n))return[];r=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(s===""){n+="[]",i="property";break}if((n!==""||r)&&!D(n,t))return[];n="",r=!1;const l=Number.parseInt(s,10),f=l<=de&&s===String(l);t.push(f?l:s),s="",i="indexEnd";break}default:{if(i==="index"){if(!Qe(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);s+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);i==="start"&&(i="property"),n+=a}}}switch(c&&(n+="\\"),i){case"property":{if(!D(n,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function U(e){if(typeof e=="string")return Ze(e);if(Array.isArray(e)){const t=[];for(const[n,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof s}`);if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${s}`);if(q.has(s))return[];typeof s=="string"&&he(s)?t.push(Number.parseInt(s,10)):t.push(s)}return t}return[]}function et(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=U(t);if(s.length===0)return n;for(let r=0;r<s.length;r++){const i=s[r];if(e=e[i],e==null){if(r!==s.length-1)return n;break}}return e===void 0?n:e}function tt(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=e,r=U(t);if(r.length===0)return e;for(let i=0;i<r.length;i++){const c=r[i];if(i===r.length-1){e[c]=n;continue}const o=e[c];if(k(o)){e=o;continue}const a=typeof r[i+1]=="number";e[c]=a?[]:{},e=e[c]}return s}function nt(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(let s=0;s<n.length;s++){const r=n[s];if(s===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;const i=e[r];if(!k(i))return!1;e=i}}function ee(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(const s of n){if(!k(e)||!(s in e))return!1;e=e[s]}return!0}const P="#;/?:@&",H=new RegExp(String.raw`([${P}][^${P}=\s]+=[^${P}=\s]*)`,"g"),st=e=>{const t=[];let n=0;H.lastIndex=0;let s=H.exec(e);for(;s!==null;){const{0:i,index:c}=s;t.push({key:void 0,value:e.slice(n,c+1)}),n=c+i.length,t.push({key:i.slice(1,i.indexOf("=")),value:i.slice(i.indexOf("=")+1)}),s=H.exec(e)}const r=e.slice(n);return r.length>0&&t.push({key:void 0,value:r}),t},te=(e,t)=>{for(let n=0;n<e.length;n+=1){let s=e[n].string,r=e[n].index;for(;r<t.length;){const i=t[r];if(!s.includes(i))break;const c=s.slice(1);for(e.push({index:r,string:c}),c.includes(i)||e.pop(),s=s.slice(s.indexOf(i)+i.length),r+=1;t[r]==="";)r+=1;if(r>=t.length){if(t.at(-1)!==""&&s.length>0)break;return!0}}}return!1},z=(e,t)=>{if(!t.includes("*"))return t===e;const n=t.split("*");let s=0,r=e;for(;n[s]==="";)if(s+=1,s===t.length)return!0;if(s===0&&!e.startsWith(n[0]))return!1;const i=[];for(;s<n.length;){const c=n[s];if(!r.includes(c))return te(i,n);const o=r.slice(1);for(i.push({index:s,string:o}),o.includes(c)||i.pop(),r=r.slice(r.indexOf(c)+c.length),s+=1;n[s]==="";)s+=1}return s>=n.length&&n.at(-1)!==""&&r.length>0?r===e?!1:te(i,n):!0},rt=/(?:http|https):\/\/?/,T=(e,t,n)=>typeof e.replacement=="function"?e.replacement(t,n):e.replacement,pe=(e,t,n)=>e.wildcard?z(t,e.key)||z(n,e.key):t===e.key||n===e.key,it=(e,t,n,s)=>{n.remove?delete e[t]:e[t]=T(n,e[t],s)},ne=(e,t,n,s,r,i)=>{const c=[],o=[];for(const l of s)!l.wildcard&&!l.deep&&ee(e,l.key)?o.push(l):c.push(l);const a=Object.keys(e);for(const l of a){if(!Object.hasOwn(e,l))continue;const f=l.toLowerCase(),u=i?`${i}.${f}`:f;let h;for(const g of c)pe(g,f,u)&&(h=g);h?it(e,l,h,u):e[l]=x(e[l],t,n,c,r,u)}for(const l of o)if(ee(e,l.key))if(l.remove)nt(e,l.key);else{const f=i?`${i}.${l.key}`:l.key;tt(e,l.key,T(l,et(e,l.key),f))}},se=(e,t)=>{const n=t.toLowerCase();return e.find(s=>s.key===n||!!s.wildcard&&z(n,s.key))},ot=(e,t,n)=>{const s=st(e),r=[];for(const i of s){const{key:c,value:o}=i;if(c===void 0){const a=se(t,o);r.push(a?String(T(a,o,void 0)):fe(o,t))}else{const a=se(t,c);a?r.push(`${c}=${String(T(a,o,void 0))}`):r.push(`${c}=${o}`)}}return r.join("")},x=(e,t,n,s,r,i)=>{if(e==null)return e;if(typeof e=="object"&&e.constructor===String)return x(String(e),t,n,s,r,i);if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof Error){const o=new Error(e.message);Object.defineProperties(o,{name:{configurable:!0,enumerable:!1,value:e.name,writable:!0},stack:{configurable:!0,enumerable:!1,value:e.stack,writable:!0}}),e.code!==void 0&&(o.code=e.code);const a=Object.keys(e);for(const l of a)o[l]=e[l];return n(e,o),ne(o,t,n,s,r,i),o}if(e instanceof Map){const o=new Map;n(e,o);const a=e.entries();let l=a.next();for(;!l.done;){const[f,u]=l.value;if(typeof f=="string"||typeof f=="object"&&f!==null&&f.constructor===String){const h=f.toLowerCase(),g=i?`${i}.${h}`:h;let p;for(const m of s)pe(m,h,g)&&(p=m);p?p.remove||o.set(f,T(p,u,g)):o.set(f,x(u,t,n,s,r,g))}else o.set(x(f,t,n,s,r),x(u,t,n,s,r));l=a.next()}return o}if(e instanceof Set){const o=new Set;n(e,o);const a=e.values();let l=a.next();for(;!l.done;)o.add(x(l.value,t,n,s,r,i)),l=a.next();return o}const c={...e};return n(e,c),ne(c,t,n,s,r,i),c}if(typeof e=="string"){const c=e;try{const o=JSON.parse(c);if(typeof o=="object"&&o!==null){const a=x(o,t,n,s,r,i);return JSON.stringify(a)}}catch{}return rt.test(c)?ot(c,s):fe(c,s)}if(Array.isArray(e)){const c=[];n(e,c);for(const[o,a]of e.entries()){const l=o.toString().toLowerCase(),f=i?`${i}.${l}`.toLowerCase():l,u=s.find(h=>h.key===l||h.key===f);u?c.push(T(u,a,f)):c.push(x(a,t,n,s,r,f))}return c}return e},ct=(e,t)=>{const n=[];for(const s of e)if(typeof s=="string"){const r=s.includes("*");n.push({deep:!1,key:s.toLowerCase(),replacement:`<${s.toUpperCase()}>`,userReplacement:!1,wildcard:r})}else if(typeof s=="number")n.push({deep:!1,key:s.toString(),replacement:"<REDACTED>"});else{const r=s.key.toLowerCase(),i={...s,key:r,replacement:s.replacement??`<${r.toUpperCase()}>`,userReplacement:s.replacement!==void 0,wildcard:r.includes("*")?!0:s.wildcard};if(i.pattern!==void 0){const c=i.pattern instanceof RegExp?i.pattern.source:i.pattern;i.compiledPattern=new RegExp(c,"giu")}n.push(i)}return n},at=(e,t,n)=>{if(e==null||typeof e=="number"||typeof e=="boolean")return e;const s=new WeakMap;return x(e,s,(r,i)=>{s.set(r,i)},t,n)},ge=(e,t,n)=>{const s=ct(t);return at(e,s,n)},Y=(e={})=>{const t=new Ae(new Q(process.stdout),new Q(process.stderr));return new Ve(e,t)},lt=(e,t)=>{if(!R(e))return e;const n=G(t,e);return n===""||n.startsWith("..")?e:n},A=(e,t)=>{const n=lt(e.file,t);return n===e.file?e:{...e,file:n}},me=e=>{if(!X(e))return[];try{const t=Me(e);return Array.isArray(t)?t:[]}catch{return[]}},ut=(e,t,n)=>{const s=me(t).map(o=>A(o,n)),r=new Set(s.map(o=>E(o))),i=e.map(o=>A(o,n)),c=new Set(i.map(o=>E(o)));return{fresh:i.filter(o=>!r.has(E(o))),resolved:s.filter(o=>!c.has(E(o))),surviving:i.filter(o=>r.has(E(o)))}},ye=(e,t,n,s={})=>{const r=e.map(c=>A(c,n));let i;if(s.replace)i=r;else{const c=me(t).map(a=>A(a,n)),o=new Set;i=[];for(const a of[...c,...r]){const l=E(a);o.has(l)||(o.add(l),i.push(a))}}return Fe(t,`${JSON.stringify(i,null,4)}
4
- `),i.length},re=1,ft=e=>{const t=new Map;for(const n of e){const s=t.get(n.file);s?s.push(n):t.set(n.file,[n])}return t},dt=e=>{try{return Se(e).split(/\r?\n/)}catch{return}},ht=(e,t,n)=>{const s=Math.max(1,t);return`${e.slice(0,s-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},pt=(e,t,n,s={})=>{if(e.length===0)return n?$("No secrets detected."):"No secrets detected.";const r=n?{cyan:ae,dim:$,green:W,red:ce,yellow:L}:{cyan:o=>o,dim:o=>o,green:o=>o,red:o=>o,yellow:o=>o},i=[],c=ft(e);for(const[o,a]of c){const l=G(t,o)||o;i.push(r.cyan(l));const f=s.redact?void 0:dt(o);for(const u of a){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${r.dim(`(${h})`)}`:"",p=u.alternateMatches&&u.alternateMatches.length>0?` ${r.dim(`also: ${u.alternateMatches.join(", ")}`)}`:"";let m="";switch(u.validation){case"error":{m=` ${r.yellow("! error")}`;break}case"rejected":{m=` ${r.red("✗ rejected")}`;break}case"skipped":{m=` ${r.dim("— unverifiable")}`;break}case"verified":{m=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${u.ruleId}]`)}${g}${m} ${r.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`),f){const C=Math.max(0,u.startLine-1-re),b=Math.min(f.length,u.startLine+re);for(let d=C;d<b;d+=1){const S=String(d+1).padStart(4," "),v=d+1===u.startLine,w=v?r.red("▶"):" ";if(i.push(` ${w} ${r.dim(S)} │ ${f[d]??""}`),v){const O=Math.max(1,(u.endColumn??u.startColumn+1)-u.startColumn),xe=ht(f[d]??"",u.startColumn,O);i.push(` ${r.dim(" │ ")}${r.red(xe)}`)}}}i.push("")}}return i.join(`
5
- `).trimEnd()},gt=(e,t,n={})=>{if(e.length===0)return t?$("No secrets detected in git history."):"No secrets detected in git history.";const s=t?{cyan:ae,dim:$,green:W,red:ce,yellow:L}:{cyan:c=>c,dim:c=>c,green:c=>c,red:c=>c,yellow:c=>c},r=new Map;for(const c of e){const o=r.get(c.commit.sha);o?o.push(c):r.set(c.commit.sha,[c])}const i=[];for(const[c,o]of r){const{authorName:a,date:l,message:f}=o[0].commit;i.push(`${s.yellow(c.slice(0,10))} ${f}`),i.push(` ${s.dim(`${a} · ${l}`)}`);for(const u of o){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${s.dim(`(${h})`)}`:"",p=n.redact?"":` ${s.dim(u.match)}`;i.push(` ${s.red("✖")} ${s.yellow(`[${u.ruleId}]`)}${g} ${s.cyan(u.file)} ${s.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`)}i.push("")}return i.join(`
3
+ `))}#g(t,n){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;let s="";const r=this.#b[t];r&&(s=this.#a?this.#a(r):r),this.#r&&(s=`${this.#r} ${s}`),n&&(s=`${s} ${n}`),this.#S(s)}};const We=(e,t,n)=>{const s=n.toLowerCase();e[s]??=new Map;const r=e[s].get(t);if(r!==void 0)return r;const{size:i}=e[s],c=`<${n.toUpperCase()}${i>0?String(i):""}>`;return e[s].set(t,c),c},Z=(e,t)=>{const{replacement:n,tag:s,text:r}=t;return typeof n=="function"?String(n(r,void 0)):typeof n=="string"?n:We(e,r,s)},Je=(e,t)=>{const n={};let s="",r=0;for(const i of e){const{start:c,text:o}=i;if(o==="")continue;if(Number.isInteger(c)&&c>=0&&t.slice(c,c+o.length)===o){if(c<r)continue;s+=t.slice(r,c)+Z(n,i),r=c+o.length;continue}let a=t.indexOf(o,r);if(a===-1)continue;const l=Z(n,i);for(;a!==-1;)s+=t.slice(r,a)+l,r=a+o.length,a=t.indexOf(o,r)}return s+t.slice(r)},Ge=e=>[...e.reduce((t,n)=>t.set(n.text+String(n.start)+n.tag,n),new Map).values()].toSorted((t,n)=>{const s=t.start-n.start;return s!==0?s:n.text.length-t.text.length}),Ke=(e,t)=>{const n=[];for(const s of e){const{key:r,pattern:i}=s,c=s.compiledPattern??new RegExp(i,"giu");c.lastIndex=0;let o;for(;(o=c.exec(t))!==null;){const a=s;n.push({replacement:a.userReplacement??a.replacement!==void 0?a.replacement:void 0,start:o.index,tag:r,text:o[0]}),o.index===c.lastIndex&&(c.lastIndex+=1)}}return n},Xe=(e,t,n,s)=>Ge([...Ke(n,e)]),fe=(e,t,n)=>{const s=[],r=[];for(const o of t)typeof o=="object"&&o.pattern&&s.push(o),r.push((typeof o=="object"?o.key:String(o)).toLowerCase());let i=e;const c=Xe(e,r,s);return i=Je(c,i),i},k=e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},q=new Set(["__proto__","prototype","constructor"]),Ye=Math.max(...[...q].map(e=>e.length)),de=1e6,Qe=e=>e>="0"&&e<="9";function he(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=de}return!1}function D(e,t){return q.has(e)?!1:(e&&he(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function Ze(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let n="",s="",r=!1,i="start",c=!1,o=0;for(const a of e){if(o++,c){n+=a,c=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);c=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="property";break}if(!D(n,t))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=Ye&&q.has(n))return[];r=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(s===""){n+="[]",i="property";break}if((n!==""||r)&&!D(n,t))return[];n="",r=!1;const l=Number.parseInt(s,10),f=l<=de&&s===String(l);t.push(f?l:s),s="",i="indexEnd";break}default:{if(i==="index"){if(!Qe(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);s+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);i==="start"&&(i="property"),n+=a}}}switch(c&&(n+="\\"),i){case"property":{if(!D(n,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function U(e){if(typeof e=="string")return Ze(e);if(Array.isArray(e)){const t=[];for(const[n,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof s}`);if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${s}`);if(q.has(s))return[];typeof s=="string"&&he(s)?t.push(Number.parseInt(s,10)):t.push(s)}return t}return[]}function et(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=U(t);if(s.length===0)return n;for(let r=0;r<s.length;r++){const i=s[r];if(e=e[i],e==null){if(r!==s.length-1)return n;break}}return e===void 0?n:e}function tt(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=e,r=U(t);if(r.length===0)return e;for(let i=0;i<r.length;i++){const c=r[i];if(i===r.length-1){e[c]=n;continue}const o=e[c];if(k(o)){e=o;continue}const a=typeof r[i+1]=="number";e[c]=a?[]:{},e=e[c]}return s}function nt(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(let s=0;s<n.length;s++){const r=n[s];if(s===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;const i=e[r];if(!k(i))return!1;e=i}}function ee(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(const s of n){if(!k(e)||!(s in e))return!1;e=e[s]}return!0}const P="#;/?:@&",H=new RegExp(String.raw`([${P}][^${P}=\s]+=[^${P}=\s]*)`,"g"),st=e=>{const t=[];let n=0;H.lastIndex=0;let s=H.exec(e);for(;s!==null;){const{0:i,index:c}=s;t.push({key:void 0,value:e.slice(n,c+1)}),n=c+i.length,t.push({key:i.slice(1,i.indexOf("=")),value:i.slice(i.indexOf("=")+1)}),s=H.exec(e)}const r=e.slice(n);return r.length>0&&t.push({key:void 0,value:r}),t},te=(e,t)=>{for(let n=0;n<e.length;n+=1){let s=e[n].string,r=e[n].index;for(;r<t.length;){const i=t[r];if(!s.includes(i))break;const c=s.slice(1);for(e.push({index:r,string:c}),c.includes(i)||e.pop(),s=s.slice(s.indexOf(i)+i.length),r+=1;t[r]==="";)r+=1;if(r>=t.length){if(t.at(-1)!==""&&s.length>0)break;return!0}}}return!1},z=(e,t)=>{if(!t.includes("*"))return t===e;const n=t.split("*");let s=0,r=e;for(;n[s]==="";)if(s+=1,s===t.length)return!0;if(s===0&&!e.startsWith(n[0]))return!1;const i=[];for(;s<n.length;){const c=n[s];if(!r.includes(c))return te(i,n);const o=r.slice(1);for(i.push({index:s,string:o}),o.includes(c)||i.pop(),r=r.slice(r.indexOf(c)+c.length),s+=1;n[s]==="";)s+=1}return s>=n.length&&n.at(-1)!==""&&r.length>0?r===e?!1:te(i,n):!0},rt=/(?:http|https):\/\/?/,T=(e,t,n)=>typeof e.replacement=="function"?e.replacement(t,n):e.replacement,pe=(e,t,n)=>e.wildcard?z(t,e.key)||z(n,e.key):t===e.key||n===e.key,it=(e,t,n,s)=>{n.remove?delete e[t]:e[t]=T(n,e[t],s)},ne=(e,t,n,s,r,i)=>{const c=[],o=[];for(const l of s)!l.wildcard&&!l.deep&&ee(e,l.key)?o.push(l):c.push(l);const a=Object.keys(e);for(const l of a){if(!Object.hasOwn(e,l))continue;const f=l.toLowerCase(),u=i?`${i}.${f}`:f;let h;for(const g of c)pe(g,f,u)&&(h=g);h?it(e,l,h,u):e[l]=x(e[l],t,n,c,r,u)}for(const l of o)if(ee(e,l.key))if(l.remove)nt(e,l.key);else{const f=i?`${i}.${l.key}`:l.key;tt(e,l.key,T(l,et(e,l.key),f))}},se=(e,t)=>{const n=t.toLowerCase();return e.find(s=>s.key===n||!!s.wildcard&&z(n,s.key))},ot=(e,t,n)=>{const s=st(e),r=[];for(const i of s){const{key:c,value:o}=i;if(c===void 0){const a=se(t,o);r.push(a?String(T(a,o,void 0)):fe(o,t))}else{const a=se(t,c);a?r.push(`${c}=${String(T(a,o,void 0))}`):r.push(`${c}=${o}`)}}return r.join("")},x=(e,t,n,s,r,i)=>{if(e==null)return e;if(typeof e=="object"&&e.constructor===String)return x(String(e),t,n,s,r,i);if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof Error){const o=new Error(e.message);Object.defineProperties(o,{name:{configurable:!0,enumerable:!1,value:e.name,writable:!0},stack:{configurable:!0,enumerable:!1,value:e.stack,writable:!0}}),e.code!==void 0&&(o.code=e.code);const a=Object.keys(e);for(const l of a)o[l]=e[l];return n(e,o),ne(o,t,n,s,r,i),o}if(e instanceof Map){const o=new Map;n(e,o);const a=e.entries();let l=a.next();for(;!l.done;){const[f,u]=l.value;if(typeof f=="string"||typeof f=="object"&&f!==null&&f.constructor===String){const h=f.toLowerCase(),g=i?`${i}.${h}`:h;let p;for(const m of s)pe(m,h,g)&&(p=m);p?p.remove||o.set(f,T(p,u,g)):o.set(f,x(u,t,n,s,r,g))}else o.set(x(f,t,n,s,r),x(u,t,n,s,r));l=a.next()}return o}if(e instanceof Set){const o=new Set;n(e,o);const a=e.values();let l=a.next();for(;!l.done;)o.add(x(l.value,t,n,s,r,i)),l=a.next();return o}const c={...e};return n(e,c),ne(c,t,n,s,r,i),c}if(typeof e=="string"){const c=e;try{const o=JSON.parse(c);if(typeof o=="object"&&o!==null){const a=x(o,t,n,s,r,i);return JSON.stringify(a)}}catch{}return rt.test(c)?ot(c,s):fe(c,s)}if(Array.isArray(e)){const c=[];n(e,c);for(const[o,a]of e.entries()){const l=o.toString().toLowerCase(),f=i?`${i}.${l}`.toLowerCase():l,u=s.find(h=>h.key===l||h.key===f);u?c.push(T(u,a,f)):c.push(x(a,t,n,s,r,f))}return c}return e},ct=(e,t)=>{const n=[];for(const s of e)if(typeof s=="string"){const r=s.includes("*");n.push({deep:!1,key:s.toLowerCase(),replacement:`<${s.toUpperCase()}>`,userReplacement:!1,wildcard:r})}else if(typeof s=="number")n.push({deep:!1,key:s.toString(),replacement:"<REDACTED>"});else{const r=s.key.toLowerCase(),i={...s,key:r,replacement:s.replacement??`<${r.toUpperCase()}>`,userReplacement:s.replacement!==void 0,wildcard:r.includes("*")?!0:s.wildcard};if(i.pattern!==void 0){const c=i.pattern instanceof RegExp?i.pattern.source:i.pattern;i.compiledPattern=new RegExp(c,"giu")}n.push(i)}return n},at=(e,t,n)=>{if(e==null||typeof e=="number"||typeof e=="boolean")return e;const s=new WeakMap;return x(e,s,(r,i)=>{s.set(r,i)},t,n)},ge=(e,t,n)=>{const s=ct(t);return at(e,s,n)},Y=(e={})=>{const t=new Ae(new Q(process.stdout),new Q(process.stderr));return new Ve(e,t)},lt=(e,t)=>{if(!R(e))return e;const n=G(t,e);return n===""||n.startsWith("..")?e:n},A=(e,t)=>{const n=lt(e.file,t);return n===e.file?e:{...e,file:n}},me=e=>{if(!X(e))return[];try{const t=Me(e);return Array.isArray(t)?t:[]}catch{return[]}},ut=(e,t,n)=>{const s=me(t).map(o=>A(o,n)),r=new Set(s.map(o=>E(o))),i=e.map(o=>A(o,n)),c=new Set(i.map(o=>E(o)));return{fresh:i.filter(o=>!r.has(E(o))),resolved:s.filter(o=>!c.has(E(o))),surviving:i.filter(o=>r.has(E(o)))}},ye=(e,t,n,s={})=>{const r=e.map(c=>A(c,n));let i;if(s.replace)i=r;else{const c=me(t).map(a=>A(a,n)),o=new Set;i=[];for(const a of[...c,...r]){const l=E(a);o.has(l)||(o.add(l),i.push(a))}}return Fe(t,`${JSON.stringify(i,null,4)}
4
+ `),i.length},re=1,ft=e=>{const t=new Map;for(const n of e){const s=t.get(n.file);s?s.push(n):t.set(n.file,[n])}return t},dt=e=>{try{return Se(e).split(/\r?\n/)}catch{return}},ht=(e,t,n)=>{const s=Math.max(1,t);return`${e.slice(0,s-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},pt=(e,t,n,s={})=>{if(e.length===0)return n?$("No secrets detected."):"No secrets detected.";const r=n?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:o=>o,dim:o=>o,green:o=>o,red:o=>o,yellow:o=>o},i=[],c=ft(e);for(const[o,a]of c){const l=G(t,o)||o;i.push(r.cyan(l));const f=s.redact?void 0:dt(o);for(const u of a){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${r.dim(`(${h})`)}`:"",p=u.alternateMatches&&u.alternateMatches.length>0?` ${r.dim(`also: ${u.alternateMatches.join(", ")}`)}`:"";let m="";switch(u.validation){case"error":{m=` ${r.yellow("! error")}`;break}case"rejected":{m=` ${r.red("✗ rejected")}`;break}case"skipped":{m=` ${r.dim("— unverifiable")}`;break}case"verified":{m=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${u.ruleId}]`)}${g}${m} ${r.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`),f){const C=Math.max(0,u.startLine-1-re),b=Math.min(f.length,u.startLine+re);for(let d=C;d<b;d+=1){const S=String(d+1).padStart(4," "),v=d+1===u.startLine,w=v?r.red("▶"):" ";if(i.push(` ${w} ${r.dim(S)} │ ${f[d]??""}`),v){const O=Math.max(1,(u.endColumn??u.startColumn+1)-u.startColumn),xe=ht(f[d]??"",u.startColumn,O);i.push(` ${r.dim(" │ ")}${r.red(xe)}`)}}}i.push("")}}return i.join(`
5
+ `).trimEnd()},gt=(e,t,n={})=>{if(e.length===0)return t?$("No secrets detected in git history."):"No secrets detected in git history.";const s=t?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:c=>c,dim:c=>c,green:c=>c,red:c=>c,yellow:c=>c},r=new Map;for(const c of e){const o=r.get(c.commit.sha);o?o.push(c):r.set(c.commit.sha,[c])}const i=[];for(const[c,o]of r){const{authorName:a,date:l,message:f}=o[0].commit;i.push(`${s.yellow(c.slice(0,10))} ${f}`),i.push(` ${s.dim(`${a} · ${l}`)}`);for(const u of o){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${s.dim(`(${h})`)}`:"",p=n.redact?"":` ${s.dim(u.match)}`;i.push(` ${s.red("✖")} ${s.yellow(`[${u.ruleId}]`)}${g} ${s.cyan(u.file)} ${s.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`)}i.push("")}return i.join(`
6
6
  `).trimEnd()},mt=(e,t)=>{if(!R(e))return e.replaceAll("\\","/");try{return ue(e).toString()}catch{return`file://${I(t,e).replaceAll("\\","/")}`}},yt=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,we=(e,t,n=process.cwd(),s=[])=>{const r=new Map(s.map(a=>[a.id,a])),i=new Set;for(const a of e)i.add(a.ruleId);const c=[...new Set([...r.keys(),...i])].sort((a,l)=>a.localeCompare(l)),o=new Map(c.map((a,l)=>[a,l]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:ue(n).toString()}},results:e.map(a=>{const l={};return a.source&&(l.source=a.source),a.confidence&&(l.confidence=a.confidence),a.alternateMatches&&a.alternateMatches.length>0&&(l.alternateRules=a.alternateMatches),a.validation&&(l.validation=a.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:mt(a.file,n),uriBaseId:R(a.file)?void 0:"SRCROOT"},region:{endColumn:a.endColumn,endLine:a.endLine,snippet:{text:a.match},startColumn:a.startColumn,startLine:a.startLine}}}],message:{text:a.description||a.ruleId},properties:Object.keys(l).length>0?l:void 0,ruleId:a.ruleId,ruleIndex:o.get(a.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:c.map(a=>{const l=r.get(a),f=l?.description??`Detected by rule \`${a}\``,u={};return l?.tags&&l.tags.length>0&&(u.tags=l.tags),l?.source&&(u.source=l.source),l?.confidence&&(u.confidence=l.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:f},helpUri:"https://visulima.com/packages/secret-scanner",id:a,name:a,properties:Object.keys(u).length>0?u:void 0,shortDescription:{text:yt(f)}}}),version:t}}}],version:"2.1.0"},void 0,2)},B=(e,t)=>{try{return Le("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch{return""}},V=e=>e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),wt=e=>V(B(e,["diff","--cached","--name-only","--diff-filter=ACMR"])).map(t=>R(t)?t:M(e,t)),ie=(e,t)=>{const n=B(e,["diff","--name-only","--diff-filter=ACMR",`${t}...HEAD`]),s=V(n);if(s.length===0){const r=B(e,["diff","--name-only","--diff-filter=ACMR",t]);return V(r).map(i=>R(i)?i:M(e,i))}return s.map(r=>R(r)?r:M(e,r))},_=e=>B(e,["rev-parse","--show-toplevel"]).length>0,F=".secrets-baseline.json",oe=e=>e?Array.isArray(e)?e:[e]:[],$e=e=>{const t=new Set(["json","sarif","text"]);if(e&&!t.has(e))throw new Error(`--format must be one of: ${[...t].join(", ")} (got "${e}")`);return e??"text"},$t=e=>{if(e===void 0)return;const t=new Set(["high","low","medium"]);if(!t.has(e))throw new Error(`--min-confidence must be one of: ${[...t].join(", ")} (got "${e}")`);return e},xt=async(e,t)=>{const n=await K(e);process.stdout.write(`${String(n.length)} rules loaded
7
7
 
8
8
  `);for(const s of n){const r=t?L(s.id):s.id,i=s.tags.length>0?` ${t?$(`[${s.tags.join(", ")}]`):`[${s.tags.join(", ")}]`}`:"";if(process.stdout.write(`${r}${i}
@@ -17,7 +17,7 @@ import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J as W
17
17
  `),process.stdout.write(` ${s.summary}
18
18
  `);const c=s.packageName?`install: npm add ${s.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?$(c):c}
19
19
 
20
- `)}},vt=async(e,t,n)=>{const s=M(e,F);if(!n&&X(s)){y.warn(`Detected existing ${F} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}y.info(n?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Y();r.start("scanning");let i;try{i=await le([e],t),r.succeed()}catch(o){throw r.failed(),o}if(n){y.info(`[dry-run] Would create ${F} with ${String(i.length)} finding(s).`);return}const c=ye(i,s,e,{replace:!0});y.success(`Wrote ${F} (${String(c)} findings).`),y.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},kt=(e,t,n)=>{const s=t??{},r=d=>d?I(n,d):void 0,i=(d,S)=>{const v=oe(d);return v.length>0?v:S},c=(s.config?.presets??[]).map(d=>`tag:preset:${d}`),o=i(e.enableRule,s.rules?.enable)??[],a=[...o,...c.filter(d=>!o.includes(d))],l=a.length>0?a:void 0,f=i(e.excludeRule,s.rules?.exclude),u=i(e.includeRule,s.rules?.include),h=i(e.exclude,s.walk?.excludePatterns),g=oe(e.excludeFrom).map(d=>I(n,d)),p=g.length>0?g:s.walk?.excludeFromFiles?.map(d=>I(n,d)),m=r(e.baseline)??r(s.baseline),C=r(e.config)??r(s.config?.path),b=$t(e.minConfidence??s.config?.minConfidence);return{baseline:m,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:s.config?.extendBundled,inline:s.config?.inline,minConfidence:b,onlyVerified:e.onlyVerified??s.config?.onlyVerified??!1,path:C,validate:e.validate??s.config?.validate??!1},redact:e.redact??s.redact,rules:{enable:l,exclude:f,include:u},verbose:e.verbose??!1,walk:{excludeFromFiles:p,excludePatterns:h,gitignore:e.gitignore===!1?!1:s.walk?.gitignore??!0,includeHidden:e.includeHidden??s.walk?.includeHidden,maxFileSize:e.maxSize??s.walk?.maxFileSize}}},St=e=>{process.stderr.write(`${$("baseline diff: ")}${W(`+${String(e.fresh.length)} new`)} · ${L(`${String(e.surviving.length)} unchanged`)} · ${$(`-${String(e.resolved.length)} resolved`)}
20
+ `)}},vt=async(e,t,n)=>{const s=M(e,F);if(!n&&X(s)){y.warn(`Detected existing ${F} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}y.info(n?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Y();r.start("scanning");let i;try{i=await le([e],t),r.succeed()}catch(o){throw r.failed(),o}if(n){y.info(`[dry-run] Would create ${F} with ${String(i.length)} finding(s).`);return}const c=ye(i,s,e,{replace:!0});y.success(`Wrote ${F} (${String(c)} findings).`),y.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},kt=(e,t,n)=>{const s=t??{},r=d=>d?I(n,d):void 0,i=(d,S)=>{const v=oe(d);return v.length>0?v:S},c=(s.config?.presets??[]).map(d=>`tag:preset:${d}`),o=i(e.enableRule,s.rules?.enable)??[],a=[...o,...c.filter(d=>!o.includes(d))],l=a.length>0?a:void 0,f=i(e.excludeRule,s.rules?.exclude),u=i(e.includeRule,s.rules?.include),h=i(e.exclude,s.walk?.excludePatterns),g=oe(e.excludeFrom).map(d=>I(n,d)),p=g.length>0?g:s.walk?.excludeFromFiles?.map(d=>I(n,d)),m=r(e.baseline)??r(s.baseline),C=r(e.config)??r(s.config?.path),b=$t(e.minConfidence??s.config?.minConfidence);return{baseline:m,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:s.config?.extendBundled,inline:s.config?.inline,minConfidence:b,onlyVerified:e.onlyVerified??s.config?.onlyVerified??!1,path:C,validate:e.validate??s.config?.validate??!1},redact:e.redact??s.redact,rules:{enable:l,exclude:f,include:u},verbose:e.verbose??!1,walk:{excludeFromFiles:p,excludePatterns:h,gitignore:e.gitignore===!1?!1:s.walk?.gitignore??!0,includeHidden:e.includeHidden??s.walk?.includeHidden,maxFileSize:e.maxSize??s.walk?.maxFileSize}}},St=e=>{process.stderr.write(`${$("baseline diff: ")}${J(`+${String(e.fresh.length)} new`)} · ${L(`${String(e.surviving.length)} unchanged`)} · ${$(`-${String(e.resolved.length)} resolved`)}
21
21
  `)},Et=async(e,t,n)=>{if(e.staged){if(!_(n))throw new Error("--staged requires a git working tree, and none was detected.");return{files:wt(n)}}if(e.since){if(!_(n))throw new Error("--since requires a git working tree, and none was detected.");return{files:ie(n,e.since)}}if(e.affected){if(!_(n))return y.warn("--affected requires git; falling back to full scan"),{paths:t&&t.length>0?t.map(r=>I(n,r)):[n]};const s=process.env.VIS_BASE??"HEAD~1";return{files:ie(n,s)}}return{paths:t&&t.length>0?t.map(s=>I(n,s)):[n]}},It=(e,t,n,s,r,i,c)=>{switch(t){case"json":{const o=e.map(a=>A(a,n));process.stdout.write(`${JSON.stringify(o,null,2)}
22
22
  `);break}case"sarif":{process.stdout.write(`${we(e,r,n,i)}
23
23
  `);break}default:process.stdout.write(`${pt(e,n,s,{redact:c})}
@@ -1,25 +1,12 @@
1
- import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as I,z as se,a as $}from"../packem_shared/index-BzhrR_iC.js";import U from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{$ as oe,_ as F,v as ne,a6 as ae,a7 as ie,a8 as re,a9 as ce}from"./cli-main.js";import{k as pe,l as z,E as W,p as L,N as K,a as fe}from"./catalog.js";import{p as S}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{U as le}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{T as j}from"../packem_shared/target-merge-DVJl-7Qz.js";import{l as ue}from"../packem_shared/missing-package-json-Cu5YVAot.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>U(s,a)),G=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&G(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&U(t,e.depName)&&G(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
2
- `)?`\r
3
- `:`
4
- `,o=a.filter(d=>d.catalogName==="default").sort((d,u)=>d.depName.localeCompare(u.depName));if(o.length===0)return;const i=r.length>0?r.split(n):[],c=i.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(c===-1){const d=["catalog:"];for(const J of o)d.push(` ${J.depName}: "${J.specifier}"`);let u=0;for(;u<i.length&&(i[u]??"").trim().length===0;)u+=1;const k=[...i.slice(0,u),...d,"",...i.slice(u)].join(n);return H(s,k.endsWith(n)?k:`${k}${n}`),s}let p=i.length;const f=new Set;for(let d=c+1;d<i.length;d+=1){const u=i[d]??"",k=u.trimStart();if(u.length===0)continue;if(u.length-k.length===0&&k.length>0&&!k.startsWith("#")){p=d;break}const P=/^([\w./@-]+)\s*:/.exec(k);P?.[1]&&f.add(P[1])}const m=[];for(const d of o)f.has(d.depName)||m.push(` ${d.depName}: "${d.specifier}"`);if(m.length===0)return;const h=[...i.slice(0,p),...m,...i.slice(p)].join(n);return H(s,h.endsWith(n)?h:`${h}${n}`),s},be=(e,a)=>{if(a.length===0)return"";const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=[...a].sort((f,m)=>f.depName.localeCompare(m.depName)),o=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],i=r.includes(`\r
5
- `)?`\r
6
- `:`
7
- `;if((r.length>0?r.split(i):[]).findIndex(f=>/^catalog\s*:\s*$/.test(f))===-1){o.push("@@ +1 @@","+catalog:");for(const f of n)o.push(`+ ${f.depName}: "${f.specifier}"`)}else{o.push("@@ catalog: @@");for(const f of n)o.push(`+ ${f.depName}: "${f.specifier}"`)}return o.join(i)},Ne=e=>{const a=[],s=pe(e);if(s){const r=I(e,"pnpm-workspace.yaml");for(const n of s)n.startsWith("!")||z(e,[n]).length===0&&a.push({pattern:n,source:"pnpm-workspace.yaml",sourcePath:r})}const t=I(e,"package.json");if(_(t)){const n=S(t).workspaces,o=Array.isArray(n)?n:n?.packages;if(o)for(const i of o)typeof i!="string"||i.startsWith("!")||z(e,[i]).length===0&&a.push({pattern:i,source:"package.json",sourcePath:t})}return a},Te=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.sourcePath);o?o.push(n):t.set(n.sourcePath,[n])}const r=[];for(const[n,o]of t){const i=new Set(o.map(m=>m.pattern));if(n.endsWith(".yaml")||n.endsWith(".yml")){const h=se(n).split(`
8
- `).filter(d=>{const u=d.trim();if(!u.startsWith("- "))return!0;const k=u.slice(2).replaceAll(/^['"]|['"]$/g,"");return!i.has(k)}).join(`
9
- `);le(n,h,{overwrite:!0}),r.push(n);continue}const p=S(n),f=p.workspaces;Array.isArray(f)?p.workspaces=f.filter(m=>typeof m!="string"||!i.has(m)):f&&Array.isArray(f.packages)&&(f.packages=f.packages.filter(m=>typeof m!="string"||!i.has(m))),j(n,p,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},xe=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Je=(e,a={})=>{const s=new Set(a.ignoreBlocks),t=oe(e),r=[];for(const n of t){const o=I(e,n,"package.json"),i=F(o);if(!i)continue;const c=typeof i.name=="string"?i.name:void 0;for(const p of xe){if(s.has(p))continue;const f=i[p];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:p,packageDir:n,packageJsonPath:o,packageName:c})}}return r},Se=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&!Array.isArray(p)&&Object.keys(p).length===0&&Reflect.deleteProperty(i,c.depType)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Ie=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Me=(e,a={})=>{const s=new Set(a.depTypes??Ie),t=new Set(a.ignoreDeps),r=new Map;for(const o of e)o.packageDir!=="."||!s.has(o.depType)||r.set(o.depName,{depType:o.depType,specifier:o.specifier});if(r.size===0)return[];const n=[];for(const o of e){if(o.packageDir==="."||!s.has(o.depType)||t.has(o.depName))continue;const i=r.get(o.depName);i&&n.push({childSpecifier:o.specifier,depName:o.depName,depType:o.depType,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},We=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:s}]},je=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath),o=n.dependencies;if(typeof o!="object"||o===null)continue;const i=o;n.devDependencies??={};const c=n.devDependencies;for(const p of r.depNames){const f=i[p];typeof f=="string"&&(p in c||(c[p]=f),Reflect.deleteProperty(i,p))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ee=/^[a-z][\w-]*@\S+$/i,Ae=(e,a,s={})=>{if(!a)return[];const t=I(e,"package.json"),r=F(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&Ee.test(n)?[]:[{packageJsonPath:t,suggested:s.suggested}]},Re=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){if(!r.suggested)continue;const n=S(r.packageJsonPath);n.packageManager=r.suggested,j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ce=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);return t?t.private===!0?[]:[{packageJsonPath:s,rawValue:t.private}]:[]},Ve=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath);let o=n;if("private"in n)n.private=!0;else{const{name:i,version:c,...p}=n,f={};i!==void 0&&(f.name=i),c!==void 0&&(f.version=c),f.private=!0;for(const[m,h]of Object.entries(p))f[m]=h;o=f}j(r.packageJsonPath,o,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},_e=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],Fe=new Set(["dependencies","devDependencies","peerDependencies"]),Oe=(e,a)=>{for(const s of e)if(s.members?.includes(a)||s.prefixes?.some(t=>a.startsWith(t)))return s},Be=e=>e.startsWith("workspace:")||e.startsWith("catalog:"),He=(e,a={})=>{const s=new Set(a.ignoreFamilies),t=new Map;for(const i of _e)t.set(i.id,i);for(const i of a.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!Fe.has(i.depType)||Be(i.specifier))continue;const c=Oe(r,i.depName);if(!c||s.has(c.id))continue;const p=n.get(c.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};p?p.push(f):n.set(c.id,[f])}const o=[];for(const[i,c]of n){const p=[...new Set(c.map(m=>m.specifier))];if(p.length<2)continue;const f=t.get(i);f&&o.push({family:i,familyLabel:f.label??i,members:c,specifiers:p})}return o},ze=e=>e.startsWith("@types/"),Le=(e,a={})=>{const s=new Set(a.ignoreDeps),t=new Map,r=o=>{const i=t.get(o);if(i!==void 0)return i;try{const p=S(o).private===!0;return t.set(o,p),p}catch{return t.set(o,!1),!1}},n=[];for(const o of e)o.depType==="dependencies"&&ze(o.depName)&&(s.has(o.depName)||r(o.packageJsonPath)&&n.push({childSpecifier:o.specifier,depName:o.depName,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName}));return n},Ke=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n),c=i.dependencies;if(typeof c!="object"||c===null)continue;const p=c;i.devDependencies??={};const f=i.devDependencies;for(const m of o){const h=p[m.depName];typeof h=="string"&&(m.depName in f||(f[m.depName]=h),Reflect.deleteProperty(p,m.depName))}Object.keys(p).length===0&&Reflect.deleteProperty(i,"dependencies"),j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},qe=e=>e.startsWith("workspace:"),Ge=(e,a={})=>{const s=a.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(qe(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:s,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},Ue=(e,a,s,t)=>{const r=a.split(".");let n=e;for(let c=0;c<r.length-1;c+=1){const p=r[c],f=n[p];(typeof f!="object"||f===null)&&(n[p]={}),n=n[p]}const o=r.at(-1);let i=n[o];(typeof i!="object"||i===null)&&(i={},n[o]=i),i[s]=t},Ye=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o)if(c.depType.includes("."))Ue(i,c.depType,c.depName,c.fix);else{const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Xe=new Set(["dependencies","devDependencies","peerDependencies"]),Qe=e=>e.startsWith("catalog:"),Ze=e=>e.startsWith("workspace:"),et=e=>{if(!e.startsWith("catalog:"))return;const a=e.slice(8);return a===""?"default":a},tt=(e,a)=>{if(e.get("default")?.has(a))return"default";const s=[...e.keys()].filter(t=>t!=="default").sort();for(const t of s)if(e.get(t)?.has(a))return t},st=e=>e==="default"?"catalog:":`catalog:${e}`,ot=(e,a)=>{const s=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of s){const n=L(r.specifier);if(!n)continue;if(!t){t=r;continue}const o=L(t.specifier);if(!o){t=r;continue}const i=K(o,n),c=K(n,o);(a==="highest"&&i||a==="lowest"&&c)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},nt=(e,a={})=>{const s=a.resolve??"highest",t=new Set(a.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!Xe.has(i.depType)||Ze(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),o=new Map;for(const i of n){const c=o.get(i.depName);c?c.push(i):o.set(i.depName,[i])}for(const[i,c]of o){const p=a.pinned?.get(i);if(p!==void 0){for(const u of c)u.specifier!==p&&r.push({canonicalSource:"cli:--pin",depName:i,depType:u.depType,fix:p,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier});continue}if(s==="catalog"){const{catalogs:u}=a;if(!u)continue;const k=tt(u,i);if(!k)continue;const J=st(k);for(const P of c)et(P.specifier)!==k&&r.push({canonicalSource:`catalog:${k}`,depName:i,depType:P.depType,fix:J,packageDir:P.packageDir,packageJsonPath:P.packageJsonPath,packageName:P.packageName,specifier:P.specifier});continue}const f=c.filter(u=>!Qe(u.specifier));if(f.length<2||new Set(f.map(u=>u.specifier)).size<=1)continue;const h=ot(f,s);if(!h)continue;const d=h.canonical.specifier;for(const u of f)u.specifier!==d&&r.push({canonicalSource:h.canonicalSource,depName:i,depType:u.depType,fix:d,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier})}return r},at=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},it=e=>{if(_(I(e,"pnpm-workspace.yaml")))return!0;const a=I(e,"package.json");if(!_(a))return!1;try{return S(a).workspaces!==void 0}catch{return!1}},E=(e,a)=>{const s=new Map;for(const t of e){const r=a(t),n=s.get(r);n?n.push(t):s.set(r,[t])}return s},rt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-protocol: no violations"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[o,i]of E(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i){const f=s?x("→"):b("→");t.info(` ${g(p.depType)} ${p.depName}: ${D(p.specifier)} ${f} ${v(p.fix)}`)}}s||t.info(g(" Run with --fix to rewrite specifiers in place."))},ct=(e,a,s)=>{if(e.length===0){s.info(v("✓ redefine-root: no violations"));return}s.info(b(w(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of E(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r)s.info(` ${g(o.depType)} ${o.depName}: ${D(o.childSpecifier)} ${g(`(root ${o.rootDepType}: ${o.rootSpecifier})`)}`)}s.info(g(" Remove these from child package.json files — root pin will resolve."))},pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-versions: no drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[o,i]of E(e,c=>c.depName)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)} ${g(f.depType)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align drifting specifiers."))},ft=(e,a,s)=>{if(e.length===0){s.info(v("✓ banned-deps: no violations"));return}s.info(D(w(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of E(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r){const i=o.replacement?` ${g("→")} ${v(o.replacement)}`:"";s.info(` ${g(o.depType)} ${D(o.depName)}${i}`),s.info(` ${g(o.reason)}`)}}},lt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ catalog-proposals: nothing worth promoting"));return}const r=s?"Added":"Would add",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const o of e)t.info(` ${w(o.depName)}: ${v(o.specifier)} ${g(`(${String(o.instanceCount)} packages agree)`)}`);if(!s){const o=be(a,e);if(o){t.info(""),t.info(g("Proposed pnpm-workspace.yaml changes:"));for(const i of o.split(`
10
- `))i.startsWith("+")?t.info(v(i)):i.startsWith("-")?t.info(D(i)):t.info(g(i))}t.info(g(" Run with --fix to write these entries to pnpm-workspace.yaml."))}},ut=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ custom-types: no engines / packageManager / volta drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} custom-type drift${e.length===1?"":"s"}`)));for(const[o,i]of E(e,c=>`${c.customType} ${c.depName}`)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align engines/packageManager/volta versions."))},dt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ empty-deps: no empty dependency blocks"));return}const r=s?"Removed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} empty dependency block${e.length===1?"":"s"}`)));for(const[o,i]of E(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${g(p.depType)}: ${D("{}")}`)}s||t.info(g(" Run with --fix to drop empty blocks."))},gt=(e,a,s,t)=>{if(e.length===0){t.info(v('✓ root-private: root package.json is "private": true'));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);if(t.info(n(w(`${r} "private": true on root ${g(`(${i})`)}`))),!s){const c=o.rawValue===void 0?"absent":JSON.stringify(o.rawValue);t.info(` ${g("current:")} ${D(c)}`)}}s||t.info(g(' Run with --fix to set "private": true.'))},mt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-package-manager: packageManager field present"));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} packageManager on root ${g(`(${i})`)}`))),!s&&!o.suggested&&t.info(g(" no canonical specifier configured (set policy.rootPackageManager.suggested to enable --fix)"))}s||t.info(g(' e.g. "packageManager": "pnpm@10.32.1"'))},ht=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-deps: no runtime dependencies on private root"));return}const r=s?"Moved":"Found",n=s?x:b;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} ${String(o.depNames.length)} runtime dep${o.depNames.length===1?"":"s"} on private root ${g(`(${i})`)}`)));for(const c of o.depNames)t.info(` ${D(c)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},kt=(e,a)=>{if(e.length===0){a.info(v("✓ missing-package-json: every workspace dir has a package.json"));return}a.info(b(w(`Found ${String(e.length)} workspace dir${e.length===1?"":"s"} without a package.json`)));for(const s of e)a.info(` ${D(s.packageDir)}`);a.info(g(" Either delete the directory or scaffold a package.json (vis create)."))},yt=(e,a,s)=>{if(e.length===0){s.info(v("✓ dead-workspace-pattern: every workspace pattern matches at least one package"));return}const t=a?"Removed":"Found",r=a?x:b;s.info(r(w(`${t} ${String(e.length)} unmatched workspace pattern${e.length===1?"":"s"}`)));for(const[n,o]of E(e,i=>i.source)){s.info(` ${w(n)}`);for(const i of o)s.info(` ${D(i.pattern)}`)}a||s.info(g(" Run with --fix to drop dead patterns."))},Pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ types-in-deps: no @types/* in dependencies of private packages"));return}const r=s?"Moved":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} @types/* dep${e.length===1?"":"s"} in dependencies`)));for(const[o,i]of E(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${D(p.depName)} ${g(p.childSpecifier)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},$t=(e,a,s)=>{if(e.length===0){s.info(v("✓ similar-deps: every related dep family is in sync"));return}s.info(b(w(`Found ${String(e.length)} family${e.length===1?"":" families"} with version drift`)));for(const t of e){s.info(` ${w(t.familyLabel)} ${g(`(${t.specifiers.join(", ")})`)}`);for(const r of t.members){const n=$(a,r.packageJsonPath),o=r.packageName??n;s.info(` ${o} ${g(`(${n})`)} ${g(r.depType)}: ${D(r.depName)}@${b(r.specifier)}`)}}s.info(g(" Pick a single specifier per family and align by hand — auto-fix is unsafe across name boundaries."))},wt=(e,a,s,t,r)=>{let n=!0;const o=i=>{n||r.info(""),n=!1,i()};t.workspaceProtocol&&o(()=>{rt(e.workspaceProtocol??[],a,s.workspaceProtocol,r)}),t.redefineRoot&&o(()=>{ct(e.redefineRoot??[],a,r)}),t.workspaceVersions&&o(()=>{pt(e.workspaceVersions??[],a,s.workspaceVersions,r)}),t.customTypes&&o(()=>{ut(e.customTypes??[],a,s.customTypes,r)}),e.catalogProposals!==void 0&&o(()=>{lt(e.catalogProposals??[],a,s.catalogProposals,r)}),t.bannedDeps&&o(()=>{ft(e.bannedDeps??[],a,r)}),t.emptyDeps&&o(()=>{dt(e.emptyDeps??[],a,s.emptyDeps,r)}),t.rootPrivate&&o(()=>{gt(e.rootPrivate??[],a,s.rootPrivate,r)}),t.rootPackageManager&&o(()=>{mt(e.rootPackageManager??[],a,s.rootPackageManager,r)}),t.rootDeps&&o(()=>{ht(e.rootDeps??[],a,s.rootDeps,r)}),t.missingPackageJson&&o(()=>{kt(e.missingPackageJson??[],r)}),t.deadWorkspacePatterns&&o(()=>{yt(e.deadWorkspacePatterns??[],s.deadWorkspacePatterns,r)}),t.typesInDeps&&o(()=>{Pt(e.typesInDeps??[],a,s.typesInDeps,r)}),t.similarDeps&&o(()=>{$t(e.similarDeps??[],a,r)})},vt=(e,a)=>{for(const s of e.workspaceProtocol??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`workspace-protocol ${t} ${s.depType} ${s.depName} ${s.specifier} → ${s.fix}
11
- `)}for(const s of e.redefineRoot??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`redefine-root ${t} ${s.depType} ${s.depName} ${s.childSpecifier}
12
- `)}for(const s of e.workspaceVersions??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`workspace-versions ${t} ${s.depType} ${s.depName} ${s.specifier} → ${s.fix}
13
- `)}for(const s of e.customTypes??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`custom-types ${t} ${s.customType} ${s.depName} ${s.specifier} → ${s.fix}
14
- `)}for(const s of e.bannedDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`banned-deps ${t} ${s.depType} ${s.depName} ${s.reason}
15
- `)}for(const s of e.catalogProposals??[])process.stdout.write(`catalog-proposal ${s.catalogName} ${s.depName} ${s.specifier} ${String(s.instanceCount)}
16
- `);for(const s of e.emptyDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`empty-deps ${t} ${s.depType}
17
- `)}for(const s of e.rootPrivate??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`root-private ${t}
18
- `)}for(const s of e.rootPackageManager??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`root-package-manager ${t} ${s.suggested??""}
19
- `)}for(const s of e.rootDeps??[]){const t=$(a,s.packageJsonPath);for(const r of s.depNames)process.stdout.write(`root-deps ${t} ${r}
20
- `)}for(const s of e.missingPackageJson??[])process.stdout.write(`missing-package-json ${s.packageDir}
21
- `);for(const s of e.deadWorkspacePatterns??[])process.stdout.write(`dead-workspace-pattern ${s.source} ${s.pattern}
22
- `);for(const s of e.typesInDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`types-in-deps ${t} ${s.depName} ${s.childSpecifier}
23
- `)}for(const s of e.similarDeps??[])for(const t of s.members){const r=$(a,t.packageJsonPath);process.stdout.write(`similar-deps ${s.family} ${r} ${t.depType} ${t.depName} ${t.specifier}
24
- `)}},Dt=(e,a,s,t)=>{const r=o=>({...o,packageJsonPath:$(a,o.packageJsonPath)}),n={fixed:s};if(t.workspaceProtocol){const o=(e.workspaceProtocol??[]).map(i=>r(i));n.workspaceProtocol={issues:o,total:o.length}}if(t.redefineRoot){const o=(e.redefineRoot??[]).map(i=>r(i));n.redefineRoot={issues:o,total:o.length}}if(t.workspaceVersions){const o=(e.workspaceVersions??[]).map(i=>r(i));n.workspaceVersions={issues:o,total:o.length}}if(t.customTypes){const o=(e.customTypes??[]).map(i=>r(i));n.customTypes={issues:o,total:o.length}}if(t.bannedDeps){const o=(e.bannedDeps??[]).map(i=>r(i));n.bannedDeps={issues:o,total:o.length}}if(e.catalogProposals!==void 0){const o=e.catalogProposals;n.catalogProposals={proposals:o,total:o.length}}if(t.emptyDeps){const o=(e.emptyDeps??[]).map(i=>r(i));n.emptyDeps={issues:o,total:o.length}}if(t.rootPrivate){const o=(e.rootPrivate??[]).map(i=>r(i));n.rootPrivate={issues:o,total:o.length}}if(t.rootPackageManager){const o=(e.rootPackageManager??[]).map(i=>r(i));n.rootPackageManager={issues:o,total:o.length}}if(t.rootDeps){const o=(e.rootDeps??[]).map(i=>r(i));n.rootDeps={issues:o,total:o.length}}if(t.missingPackageJson){const o=e.missingPackageJson??[];n.missingPackageJson={issues:o,total:o.length}}if(t.deadWorkspacePatterns){const o=e.deadWorkspacePatterns??[];n.deadWorkspacePatterns={issues:o,total:o.length}}if(t.typesInDeps){const o=(e.typesInDeps??[]).map(i=>r(i));n.typesInDeps={issues:o,total:o.length}}if(t.similarDeps){const o=(e.similarDeps??[]).map(i=>({...i,members:i.members.map(c=>({...c,packageJsonPath:$(a,c.packageJsonPath)}))}));n.similarDeps={issues:o,total:o.length}}process.stdout.write(`${JSON.stringify(n,void 0,2)}
25
- `)},T=(e,a,s)=>{const t=e[a];return typeof t=="boolean"?t:e[s]===!0},bt=e=>{const a=e,s=(e.ban?.length??0)>0,t=(e.pin?.length??0)>0,r=T(a,"workspaceProtocol","workspace-protocol"),n=T(a,"redefineRoot","redefine-root"),o=T(a,"bannedDeps","banned-deps"),i=T(a,"workspaceVersions","workspace-versions"),c=T(a,"customTypes","custom-types"),p=T(a,"emptyDeps","empty-deps"),f=T(a,"rootPrivate","root-private"),m=T(a,"rootPackageManager","root-package-manager"),h=T(a,"rootDeps","root-deps"),d=T(a,"missingPackageJson","missing-package-json"),u=T(a,"deadWorkspacePatterns","dead-workspace-patterns"),k=T(a,"typesInDeps","types-in-deps"),J=T(a,"similarDeps","similar-deps");return r||n||o||i||c||p||f||m||h||d||u||k||J||s||t?{bannedDeps:o||s,customTypes:c,deadWorkspacePatterns:u,emptyDeps:p,missingPackageJson:d,redefineRoot:n,rootDeps:h,rootPackageManager:m,rootPrivate:f,similarDeps:J,typesInDeps:k,workspaceProtocol:r,workspaceVersions:i||t}:{bannedDeps:!0,customTypes:!0,deadWorkspacePatterns:!0,emptyDeps:!0,missingPackageJson:!0,redefineRoot:!0,rootDeps:!0,rootPackageManager:!0,rootPrivate:!0,similarDeps:!0,typesInDeps:!0,workspaceProtocol:!0,workspaceVersions:!0}},Nt=e=>{const a=new Map;for(const s of e??[]){const t=s.lastIndexOf("@");if(t<=0||t===s.length-1)throw new Error(`Invalid --pin "${s}". Use: name@<specifier> (e.g. react@^18.2.0).`);const r=s.slice(0,t),n=s.slice(t+1);a.set(r,n)}return a},Tt=new Set(["catalog","highest","lowest"]),xt=e=>{if(e===void 0)return"highest";if(!Tt.has(e))throw new Error(`Invalid --resolve "${e}". Use: highest, lowest, or catalog.`);return e},M=(e,a)=>e?a===void 0||a===!0:!1,Jt={"custom-types":"policy.customTypes.autofix","workspace-protocol":"policy.workspaceProtocol.autofix","workspace-versions":"policy.workspaceVersions.autofix"},B=(e,a,s,t)=>{const r=Jt[a],n=s==="prompt"?`${r} = "prompt" (interactive mode not yet implemented; report-only)`:`${r} = false`,o=`Set "${r}": true (or remove it) to enable rewrites.`;e.warn(`${a}: ${String(t)} issue${t===1?"":"s"} not rewritten — ${n}. ${o}`)},Ft=async({logger:e,options:a,visConfig:s,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const r=t,n=a.fix??!1,o=a.format??"human",i=a.quiet??!1;if(!["human","json","minimal"].includes(o))throw new Error(`Invalid --format "${o}". Use: human, json, or minimal.`);const c=bt(a),p=s?.policy??{},f=s?.editorconfig??!0,m=Nt(a.pin),h=a.ban??[];(a.dep!==void 0||a.resolve!==void 0)&&!c.workspaceVersions&&!i&&e.warn("--dep / --resolve only apply to --workspace-versions; ignored.");const d=ne(r),u={},k={catalogProposals:!1,customTypes:!1,deadWorkspacePatterns:!1,emptyDeps:!1,rootDeps:!1,rootPackageManager:!1,rootPrivate:!1,typesInDeps:!1,workspaceProtocol:!1,workspaceVersions:!1},J=it(r);let P=0;if(c.workspaceProtocol){const l=Ge(d,{fixSpecifier:a.fixSpecifier}),y=M(n,p.workspaceProtocol?.autofix);y&&l.length>0&&(Ye(l,{useEditorconfig:f}),k.workspaceProtocol=!0),u.workspaceProtocol=l,y||(P+=l.length),n&&!y&&l.length>0&&!i&&B(e,"workspace-protocol",p.workspaceProtocol?.autofix,l.length)}if(c.redefineRoot){const l=Me(d,{ignoreDeps:p.redefineRoot?.ignore});u.redefineRoot=l,P+=l.length}if(c.workspaceVersions){const l=xt(a.resolve??p.workspaceVersions?.resolve),y=l==="catalog"?fe(r):void 0;l==="catalog"&&(!y||y.size===0)&&!i&&e.warn("--resolve catalog: no catalog found in pnpm-workspace.yaml or root package.json — nothing to align.");const N=nt(d,{catalogs:y,dep:a.dep,ignoreDeps:p.workspaceVersions?.ignore,pinned:m.size>0?m:void 0,resolve:l}),R=M(n,p.workspaceVersions?.autofix);if(R&&N.length>0&&(at(N,{useEditorconfig:f}),k.workspaceVersions=!0),u.workspaceVersions=N,R||(P+=N.length),n&&!R&&N.length>0&&!i&&B(e,"workspace-versions",p.workspaceVersions?.autofix,N.length),a.proposeMin!==void 0){if(l!=="catalog"&&!i)e.warn("--propose-min only runs under --resolve catalog; ignored.");else if(l==="catalog"){const C=ve(d,{catalogs:y,ignoreDeps:p.workspaceVersions?.ignore,min:a.proposeMin});R&&C.length>0&&(De(r,C),k.catalogProposals=!0),u.catalogProposals=C}}}if(c.customTypes){const l=p.customTypes?.extraTypes,y=ae(l);if(y.length>0){for(const X of y)e.error(`policy.customTypes.${X}`);process.exitCode=1;return}const N=ie(r,l),C=(a.resolve??p.customTypes?.resolve)==="lowest"?"lowest":"highest",A=re(N,{dep:a.dep,ignoreDeps:p.customTypes?.ignore,resolve:C}),O=M(n,p.customTypes?.autofix);O&&A.length>0&&(ce(A,{useEditorconfig:f}),k.customTypes=!0),u.customTypes=A,O||(P+=A.length),n&&!O&&A.length>0&&!i&&B(e,"custom-types",p.customTypes?.autofix,A.length)}if(c.bannedDeps){const l={...p.bannedDeps};for(const N of h)l[N]={reason:"banned via --ban CLI flag"};Object.keys(l).length===0&&a.bannedDeps&&!i&&e.warn("--banned-deps: no policy.bannedDeps in vis config, nothing to check.");const y=ke(d,l);u.bannedDeps=y,P+=y.length}if(c.emptyDeps){const l=Je(r,{ignoreBlocks:p.emptyDeps?.ignoreBlocks}),y=M(n,p.emptyDeps?.autofix);y&&l.length>0&&(Se(l,{useEditorconfig:f}),k.emptyDeps=!0),u.emptyDeps=l,y||(P+=l.length)}if(c.rootPrivate){const l=Ce(r,J),y=M(n,p.rootPrivate?.autofix);y&&l.length>0&&(Ve(l,{useEditorconfig:f}),k.rootPrivate=!0),u.rootPrivate=l,y||(P+=l.length)}if(c.rootPackageManager){const l=Ae(r,J,{suggested:p.rootPackageManager?.suggested}),y=M(n,p.rootPackageManager?.autofix);y&&l.some(N=>N.suggested!==void 0)&&(Re(l,{useEditorconfig:f}),k.rootPackageManager=!0),u.rootPackageManager=l,(!y||!k.rootPackageManager)&&(P+=l.filter(N=>N.suggested===void 0||!k.rootPackageManager).length)}if(c.rootDeps){const l=We(r,J),y=M(n,p.rootDeps?.autofix);y&&l.length>0&&(je(l,{useEditorconfig:f}),k.rootDeps=!0),u.rootDeps=l,y||(P+=l.length)}if(c.missingPackageJson){const l=ue(r);u.missingPackageJson=l,P+=l.length}if(c.deadWorkspacePatterns){const l=Ne(r),y=M(n,p.deadWorkspacePatterns?.autofix);y&&l.length>0&&(Te(l,{useEditorconfig:f}),k.deadWorkspacePatterns=!0),u.deadWorkspacePatterns=l,y||(P+=l.length)}if(c.typesInDeps){const l=Le(d,{ignoreDeps:p.typesInDeps?.ignore}),y=M(n,p.typesInDeps?.autofix);y&&l.length>0&&(Ke(l,{useEditorconfig:f}),k.typesInDeps=!0),u.typesInDeps=l,y||(P+=l.length)}if(c.similarDeps){const l=He(d,{extraFamilies:p.similarDeps?.extraFamilies,ignoreFamilies:p.similarDeps?.ignoreFamilies});u.similarDeps=l,P+=l.length}i||(o==="json"?Dt(u,r,k,c):o==="minimal"?vt(u,r):wt(u,r,k,c,e)),P>0&&(process.exitCode=1)};export{Ft as default};
1
+ import{createRequire as ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-BzhrR_iC.js";import{f as ae,h as M}from"../packem_shared/ai-cache-iSIyY3So.js";import{p as c,V,X as k,Y as ne,P as O,Z as L,_ as oe,g as ie}from"./cli-main.js";import{z as ce,A as de,B as N,C as z}from"../packem_shared/registry-Dg9XI6RT.js";import{p as he,d as x,a as U,q as I}from"../packem_shared/env-BSXG3QKH.js";import{z as b}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{Cache as E,readLastRunSummary as Y,getLastRunSummaryPath as P,parseCacheSize as me,digestFile as X,describeCacheMissReason as pe}from"@visulima/task-runner";import{y as R}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{r as G,f as F,a as ye,d as Se}from"../packem_shared/run-summary-utils-CMeURYtS.js";let te;const se=e=>(te??=ee(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(e)}return se(e)},{realpath:_,rm:W,mkdtemp:fe,readdir:ue,stat:q}=j("node:fs/promises"),{createInterface:le}=j("node:readline"),{tmpdir:$e}=j("node:os"),we=e=>new Promise(s=>{const t=le({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const n=r.trim().toLowerCase();s(n==="y"||n==="yes")})}),ve=()=>{try{const e=ae();e>0&&c.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},ke=()=>{try{const e=he();e>0&&c.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Ce=()=>{try{const e=ce();e>0&&c.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ge=()=>{try{const e=de();e>0&&c.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},De=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const a=(await Promise.all(V(e,!0).map(async i=>k(i)))).flat(),o=a.reduce((i,d)=>i+d.sizeBytes,0);c.info(`Would remove ${String(a.length)} cache entr${a.length===1?"y":"ies"} (${b(o,{decimals:1,space:!1})}) from ${e}`);return}const r=ne(e,s);try{const n=await _(e),a=await _(s);if(n===a){c.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(c.warn(`Cache directory is outside the workspace root: ${e}`),c.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){c.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await we(" Continue?")){c.info("Aborted.");return}}r?await new E({cacheDirectory:e,workspaceRoot:s}).clear():await W(e,{force:!0,recursive:!0}),c.success(`Cleared cache: ${e}`)},Z=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),m=(e,s)=>e==="all"||e===s,xe=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),w=(e,s,t)=>{const r=e??process.cwd(),n=t??{},a=n.taskRunner??{},o=xe(s.scope),i=s.cacheDir,d=O(r,i,a.cacheDirectory,!1),f=O(r,i,a.cacheDirectory,n.sharedWorktreeCache),h=L(d,r,n.branchScopedCache),u=L(f,r,n.branchScopedCache);let l;switch(o){case"all":{l=u===h?[{base:f,scoped:u}]:[{base:f,scoped:u},{base:d,scoped:h}];break}case"worktree":{l=[{base:d,scoped:h}];break}default:l=[{base:f,scoped:u}]}const S=n.branchScopedCache===!0;return{directoriesFor:T=>T==="read"?[...new Set(l.flatMap(p=>p.scoped!==p.base&&oe(p.base)?[p.scoped,p.base]:[p.scoped]))]:T==="wipe"?[...new Set(l.map(p=>p.base))]:[...new Set(l.flatMap(p=>V(p.base,S)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,K=e=>e.length>H?`${e.slice(0,H)}…`:e,v=(e,s,t)=>{const r=Object.entries(s??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([n],[a])=>n.localeCompare(a));for(const[n,a]of r)t.info(` ${n.padEnd(40)} ${K(a)}`)}},be=async(e,s,t)=>{if(e!==void 0)for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).get(e);if(n?.fingerprint)return n.fingerprint}},Ee=(e,s)=>{v("tracked files",e.fileHashes,s),v("tracked env",e.envHashes,s),v("missing files",Object.fromEntries(e.missingFiles.map(t=>[t,"absent"])),s)},Re=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await Y(a,{dataDirectory:x(a)}):await G(a,n);if(!o){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null,taskId:e},void 0,2)}
2
+ `),process.exitCode=1;return}n===void 0?c.error(`No previous run summary found. Run a task first to populate \`${P(a,{dataDirectory:x(a)})}\`.`):c.error(`Run summary "${n}" not found in ${U(a)}/.`),process.exitCode=1;return}const i=F(o,e);if(!i){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
3
+ `),process.exitCode=1;return}c.error(`Task "${e}" was not part of run ${o.id}.`),process.exitCode=1;return}const d=i.hashDetails===void 0?await be(i.hash,s.cacheDirectories??[],a):void 0;if(r==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:i.cacheStatus,hash:i.hash??null,hashDetails:i.hashDetails??null,hashSource:i.hashSource??null,runId:o.id,taskId:i.taskId,trackedFingerprint:d??null},void 0,2)}
4
+ `);return}c.info(`Hash for ${e} (run ${o.id})`),t.info(""),t.info(` status: ${i.cacheStatus}`),t.info(` hash: ${i.hash??"(none)"}`),i.hashSource==="declared-fallback"&&t.info(" key: declared-fallback (no files were tracked; the entry is keyed on the declared inputs below)"),i.hashDetails?(t.info(""),t.info(` command: ${K(i.hashDetails.command)}`),v("nodes",i.hashDetails.nodes,t),v("runtime",i.hashDetails.runtime,t),v("implicitDeps",i.hashDetails.implicitDeps,t)):d?(t.info(""),Ee(d,t)):(t.info(""),c.info("No hash details recorded for this task."))},$=e=>{process.stdout.write(`${e}
5
+ `)},C=e=>{process.stdout.write(`${JSON.stringify(e,void 0,2)}
6
+ `)},Be=async(e,s,t)=>{if(!R(e)){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
7
+ `);return}c.info(`No cache directory found at ${e}`);return}const r=await k(e);if(r.length===0){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
8
+ `);return}c.info(`Cache directory is empty: ${e}`);return}const n=r.reduce((h,u)=>h+u.sizeBytes,0);if(s==="json"){const h=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:r.map(u=>({ageMs:h-u.mtimeMs,hash:u.hash,mtimeIso:new Date(u.mtimeMs).toISOString(),sizeBytes:u.sizeBytes})),totalBytes:n,totalCount:r.length},void 0,2)}
9
+ `);return}$(`Cache directory: ${e}`),$(`Entries: ${String(r.length)} (${b(n,{decimals:1,space:!1})})`),t.info("");const a=Date.now(),o=r.map(h=>({age:ie(h.mtimeMs,a),hash:h.hash.slice(0,12),size:b(h.sizeBytes,{decimals:1,space:!1})})),i=Math.max(4,...o.map(h=>h.hash.length)),d=Math.max(4,...o.map(h=>h.size.length)),f=Math.max(3,...o.map(h=>h.age.length));t.info(` ${"hash".padEnd(i)} ${"size".padEnd(d)} ${"age".padEnd(f)}`),t.info(` ${"-".repeat(i)} ${"-".repeat(d)} ${"-".repeat(f)}`);for(const h of o)t.info(` ${h.hash.padEnd(i)} ${h.size.padEnd(d)} ${h.age.padEnd(f)}`)},Me=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to prune at ${e}`);return}if(t.maxCacheAgeDays!==void 0&&(!Number.isFinite(t.maxCacheAgeDays)||t.maxCacheAgeDays<0)){c.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))){c.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(t.keepLast)}`),process.exitCode=1;return}if(t.maxCacheSize!==void 0){let u;try{u=me(t.maxCacheSize)}catch(l){c.error(`Invalid --max-size value: ${l instanceof Error?l.message:String(l)}`),process.exitCode=1;return}if(!Number.isFinite(u)||u<=0){c.error(`Invalid --max-size value: expected a positive size, got "${t.maxCacheSize}" (${String(u)} bytes)`),process.exitCode=1;return}}const r=t.maxCacheAgeDays===void 0?void 0:t.maxCacheAgeDays*24*60*60*1e3,n=await k(e),a=n.reduce((u,l)=>u+l.sizeBytes,0);if(t.keepLast!==void 0&&n.length>t.keepLast){const u=n.slice(t.keepLast);await Promise.all(u.map(l=>W(l.path,{force:!0,recursive:!0})))}await new E({cacheDirectory:e,maxCacheAge:r,maxCacheSize:t.maxCacheSize,workspaceRoot:s}).removeOldEntries();const i=await k(e),d=i.reduce((u,l)=>u+l.sizeBytes,0),f=n.length-i.length,h=a-d;if(f<=0){c.info("Nothing to prune — all entries are within the configured limits.");return}c.success(`Pruned ${String(f)} entr${f===1?"y":"ies"}, freed ${b(h,{decimals:1,space:!1})}.`)},y=e=>e===void 0?null:new Date(e).toISOString(),D=(e,s)=>{$(`${e}:`),s.directory!==void 0&&$(` Directory: ${s.directory}`),$(` Entries: ${String(s.entries)}`),$(` Total size: ${b(s.totalSizeBytes,{decimals:1,space:!1})}`),$(` Oldest: ${s.oldestEntry?new Date(s.oldestEntry).toISOString():"N/A"}`),$(` Newest: ${s.newestEntry?new Date(s.newestEntry).toISOString():"N/A"}`)},Ne=async(e,s)=>{if(!R(e)){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
10
+ `);return}c.info(`No cache directory at ${e}`);return}const t=await k(e),r=t.reduce((n,a)=>n+a.sizeBytes,0);if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:r,totalCount:t.length})}
11
+ `);return}D("Task cache",{directory:e,entries:t.length,newestEntry:t[0]?.mtimeMs,oldestEntry:t.at(-1)?.mtimeMs,totalSizeBytes:r})},ze=async e=>{const s=[],t=async r=>{const a=(await ue(r,{withFileTypes:!0})).toSorted((o,i)=>o.name.localeCompare(i.name));for(const o of a){const i=A(r,o.name);if(o.isDirectory()){await t(i);continue}if(!o.isFile())continue;const[d,f]=await Promise.all([q(i),X(i)]);s.push({hash:f?.hash??"",mode:d.mode&4095,mtimeMs:d.mtimeMs,relativePath:re(e,i).replaceAll("\\","/"),sizeBytes:d.size})}};return await t(e),s},Ie=(e,s)=>Math.floor(e/1e3)===Math.floor(s/1e3),J=16,Fe=async(e,s)=>{const t=A(s,e.relativePath),r=await q(t).catch(()=>{});if(!r)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const n=await X(t),a=[];(n?.hash??"")!==e.hash&&a.push("content");const o=r.mode&4095;if(process.platform!=="win32"&&o!==e.mode&&a.push("mode"),Ie(r.mtimeMs,e.mtimeMs)||a.push("mtime"),a.length!==0)return{actual:{hash:n?.hash,mode:o,mtimeMs:r.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:a,relativePath:e.relativePath}},je=async(e,s,t)=>{for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).getByTaskId(e);if(n)return{cached:n,cacheDirectory:r}}},B=(e,s,t)=>{e==="json"?C(s):c.error(t),process.exitCode=1},Ae=async(e,s)=>{const t=Array.from({length:e.length});for(let r=0;r<e.length;r+=J){const n=e.slice(r,r+J),a=await Promise.all(n.map(async o=>Fe(o,s)));for(const[o,i]of a.entries())t[r+o]=i}return t.filter(r=>r!==void 0)},We=(e,s,t)=>{t.info(` expected hash: ${e.hash||"(none)"}`),t.info(` actual hash: ${s.hash??"(unreadable)"}`)},Pe=(e,s,t)=>{t.info(` expected mode: ${e.mode.toString(8)}`),t.info(` actual mode: ${(s.mode??0).toString(8)}`)},Te=(e,s,t)=>{t.info(` expected mtime: ${new Date(e.mtimeMs).toISOString()}`),t.info(` actual mtime: ${s.mtimeMs===void 0?"(unreadable)":new Date(s.mtimeMs).toISOString()}`)},Oe=(e,s)=>{const t=e.issues.includes("missing")?"MISSING":e.issues.join(",").toUpperCase();s.info(` [${t}] ${e.relativePath}`);const{expected:r}=e,{actual:n}=e;e.issues.includes("missing")||!r||!n||(e.issues.includes("content")&&We(r,n,s),e.issues.includes("mode")&&Pe(r,n,s),e.issues.includes("mtime")&&Te(r,n,s))},Le=(e,s,t,r,n,a)=>{if(c.info(`Verify ${e} (hash ${s})`),a.info(""),a.info(` cache: ${t}`),a.info(` files: ${String(r)}`),n.length===0){a.info(""),c.success("Cache restore is faithful — all files match content, mode, and mtime.");return}a.info(` drift: ${String(n.length)} file(s)`),a.info("");for(const o of n)Oe(o,a);process.exitCode=1},_e=async(e,s,t)=>{const{cacheDirectories:r,format:n,workspaceRoot:a}=s;if(r.length===0){B(n,{error:"no-cache-directory",taskId:e},"No cache directory resolved — pass --cache-dir or run inside a workspace.");return}const o=await je(e,r,a);if(!o){B(n,{error:"no-cached-entry",searchedCaches:r,taskId:e},`No cached entry found for task "${e}". Run it once before verifying.`);return}const{cached:i,cacheDirectory:d}=o,f=await fe(A($e(),"vis-cache-verify-"));try{if(!await new E({cacheDirectory:d,workspaceRoot:f}).restoreOutputs(i.hash)){B(n,{error:"restore-failed",hash:i.hash,taskId:e},`Cache restore failed for ${e} (hash ${i.hash}).`);return}const l=await ze(f);if(l.length===0){n==="json"?C({diffs:[],hash:i.hash,status:"no-outputs",taskId:e}):c.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const S=await Ae(l,a);if(n==="json"){C({cachedFileCount:l.length,cacheDirectory:d,diffs:S,hash:i.hash,status:S.length===0?"ok":"drift",taskId:e}),S.length>0&&(process.exitCode=1);return}Le(e,i.hash,d,l.length,S,t)}finally{await W(f,{force:!0,recursive:!0}).catch(()=>{})}},He=(e,s,t,r)=>{e==="json"?C({error:"no-summary",runId:t??null,taskId:s}):t===void 0?c.error(`No previous run summary found. Run a task first to populate \`${P(r,{dataDirectory:x(r)})}\`.`):c.error(`Run summary "${t}" not found in ${U(r)}/.`),process.exitCode=1},Je=(e,s,t)=>{e==="json"?C({error:"task-not-in-summary",runId:t.id,taskId:s}):(c.error(`Task "${s}" was not part of run ${t.id}.`),c.info(`Tasks in this run: ${t.tasks.map(r=>r.taskId).join(", ")||"(none)"}`)),process.exitCode=1},Ve=(e,s,t,r,n)=>({diff:n,previousRunId:t?.id??null,previousTask:r?{cacheStatus:r.cacheStatus,hash:r.hash??null,hashDetails:r.hashDetails??null}:null,runId:e.id,task:{cacheMissReasons:s.cacheMissReasons??null,cacheStatus:s.cacheStatus,hash:s.hash??null,hashDetails:s.hashDetails??null,hashSource:s.hashSource??null,taskId:s.taskId}}),Ue=(e,s,t,r,n,a)=>{c.info(`Why ${e}? (run ${s.id})`),a.info(""),a.info(` status: ${t.cacheStatus}`),a.info(` hash: ${t.hash??"(none)"}`),t.hashSource==="declared-fallback"&&a.info(" key: declared-fallback (tracker observed no workspace access; keyed on declared inputs)"),n?a.info(` prev: ${n.hash??"(none)"} [run ${r?.id??"?"}]`):a.info(" prev: (no prior run found)"),a.info("")},qe=(e,s,t,r)=>{if(t.cacheMissReasons&&t.cacheMissReasons.length>0){r.info("Cache miss reasons (trace-mode fingerprint):");for(const n of t.cacheMissReasons)r.info(` - ${pe(n)}`)}else c.info("No hash inputs recorded for this run (trace-mode tasks record a miss reason only when the cache misses).");r.info(""),c.info(`Tracked files and env of this run: vis cache hash ${e} --run ${s.id}`)},Ye=e=>!e.commandChanged&&[e.nodes,e.runtime,e.implicitDeps].every(s=>s.added.length===0&&s.changed.length===0&&s.removed.length===0),Xe=(e,s)=>{s.info("Hash inputs that changed since the previous run:"),s.info(""),e.commandChanged&&s.info(" command: changed");for(const t of["nodes","runtime","implicitDeps"]){const r=e[t];if(!(r.added.length===0&&r.changed.length===0&&r.removed.length===0)){s.info(` ${t}:`);for(const n of r.added)s.info(` + ${n}`);for(const n of r.changed)s.info(` ~ ${n}`);for(const n of r.removed)s.info(` - ${n}`)}}},Ge=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await Y(a,{dataDirectory:x(a)}):await G(a,n);if(!o){He(r,e,n,a);return}const i=F(o,e);if(!i){Je(r,e,o);return}const d=await ye(a,o.id),f=d?F(d,e):void 0,h=Se(i.hashDetails,f?.hashDetails);if(r==="json"){C(Ve(o,i,d,f,h));return}if(Ue(e,o,i,d,f,t),i.hashDetails===void 0){qe(e,o,i,t);return}if(!f){c.info("No previous run to diff against — first time this task was recorded.");return}if(Ye(h)){c.success("No hash inputs changed since the previous run.");return}Xe(h,t),t.info(""),c.info(`Last summary file: ${P(a,{dataDirectory:x(a)})}`)},it=async({logger:e,options:s,visConfig:t,workspaceRoot:r})=>{const{directoriesFor:n}=w(r,s,t),a=n("read"),o=s.format??"table";for(const i of a)a.length>1&&c.info(`# ${i}`),await Be(i,o,e)},ct=async({options:e,visConfig:s,workspaceRoot:t})=>{const r=Z(e.type),n=!!e.dryRun;if(m(r,"task")){const{directoriesFor:a,workspaceRoot:o}=w(t,e,s);for(const i of a("wipe"))await De(i,o,{dryRun:n,force:!!e.force})}if(m(r,"ai"))if(n){const a=M();c.info(`Would clear ${String(a.entries)} cached AI response${a.entries===1?"":"s"}.`)}else ve();if(m(r,"socket"))if(n){const a=I();c.info(`Would clear ${String(a.entries)} cached Socket.dev report${a.entries===1?"":"s"}.`)}else ke();if(m(r,"deps-dev"))if(n){const a=N();c.info(`Would clear ${String(a.entries)} cached deps.dev record${a.entries===1?"":"s"}.`)}else Ce();if(m(r,"snyk"))if(n){const a=z();c.info(`Would clear ${String(a.entries)} cached Snyk record${a.entries===1?"":"s"}.`)}else ge()},dt=async({options:e,visConfig:s,workspaceRoot:t})=>{const{directoriesFor:r,workspaceRoot:n}=w(t,e,s),a=r("evict");for(const o of a)a.length>1&&c.info(`# ${o}`),await Me(o,n,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},Q=e=>e??process.cwd(),ht=async({argument:e,logger:s,options:t,workspaceRoot:r})=>{const n=e[0];if(!n){c.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await Ge(n,{format:t.format??"table",runId:t.run,workspaceRoot:Q(r)},s)},ft=async({argument:e,logger:s,options:t,visConfig:r,workspaceRoot:n})=>{const a=e[0];if(!a){c.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}const{directoriesFor:o}=w(n,t,r);await Re(a,{cacheDirectories:o("read"),format:t.format??"table",runId:t.run,workspaceRoot:Q(n)},s)},ut=async({options:e,visConfig:s,workspaceRoot:t})=>{const r=Z(e.type);if((e.format??"table")==="json"){const a={};if(m(r,"task")){const{directoriesFor:o}=w(t,e,s),i=o("read");a.task=await Promise.all(i.map(async d=>{const f=R(d),h=f?await k(d):[],u=h.reduce((l,S)=>l+S.sizeBytes,0);return{directory:d,entries:h.length,exists:f,newestEntry:y(h[0]?.mtimeMs),oldestEntry:y(h.at(-1)?.mtimeMs),totalBytes:u}}))}if(m(r,"ai")){const o=M();a.ai={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"socket")){const o=I();a.socket={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"deps-dev")){const o=N();a["deps-dev"]={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"snyk")){const o=z();a.snyk={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}process.stdout.write(`${JSON.stringify(a,void 0,2)}
12
+ `);return}if(m(r,"task")){const{directoriesFor:a}=w(t,e,s),o=a("read");for(const i of o)o.length>1&&c.info(`# ${i}`),await Ne(i,"table")}m(r,"ai")&&D("AI response cache",M()),m(r,"socket")&&D("Socket.dev report cache",I()),m(r,"deps-dev")&&D("deps.dev cache",N()),m(r,"snyk")&&D("Snyk issue cache",z())},lt=async({argument:e,logger:s,options:t,visConfig:r,workspaceRoot:n})=>{const a=e[0];if(!a){c.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{directoriesFor:o,workspaceRoot:i}=w(n,t,r),d=o("read");await _e(a,{cacheDirectories:d,format:t.format??"table",workspaceRoot:i},s)};export{ct as cacheCleanExecute,ft as cacheHashExecute,it as cacheListExecute,dt as cachePruneExecute,ut as cacheSizeExecute,lt as cacheVerifyExecute,ht as cacheWhyExecute,ve as clearAiCacheSafe,Ce as clearDepsDevCacheSafe,ge as clearSnykCacheSafe,ke as clearSocketCacheSafe,k as collectCacheEntries,ie as formatAge,De as runClean,Re as runHash,Be as runList,Me as runPrune,Ne as runSize,_e as runVerify,Ge as runWhy};