@visulima/vis 7.1.0-next.5 → 7.1.0-next.7

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 (167) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +1 -1
  3. package/bin/route.mjs +154 -27
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +1 -1
  6. package/dist/config/index.d.ts +227 -12
  7. package/dist/packem_chunks/CONFIG_FILES.js +1 -1
  8. package/dist/packem_chunks/bloom-sync.js +1 -1
  9. package/dist/packem_chunks/catalog.js +1 -1
  10. package/dist/packem_chunks/cli-exec.js +1 -1
  11. package/dist/packem_chunks/cli-main.js +57 -57
  12. package/dist/packem_chunks/detect.js +4 -4
  13. package/dist/packem_chunks/dispatch.js +1 -1
  14. package/dist/packem_chunks/fix.js +1 -1
  15. package/dist/packem_chunks/handler.js +1 -1
  16. package/dist/packem_chunks/handler10.js +1 -1
  17. package/dist/packem_chunks/handler11.js +1 -1
  18. package/dist/packem_chunks/handler12.js +1 -1
  19. package/dist/packem_chunks/handler13.js +1 -1
  20. package/dist/packem_chunks/handler14.js +1 -1
  21. package/dist/packem_chunks/handler15.js +1 -1
  22. package/dist/packem_chunks/handler16.js +1 -1
  23. package/dist/packem_chunks/handler17.js +1 -1
  24. package/dist/packem_chunks/handler18.js +1 -1
  25. package/dist/packem_chunks/handler19.js +1 -1
  26. package/dist/packem_chunks/handler2.js +1 -1
  27. package/dist/packem_chunks/handler20.js +1 -1
  28. package/dist/packem_chunks/handler21.js +1 -1
  29. package/dist/packem_chunks/handler22.js +1 -1
  30. package/dist/packem_chunks/handler23.js +1 -1
  31. package/dist/packem_chunks/handler24.js +1 -1
  32. package/dist/packem_chunks/handler25.js +1 -1
  33. package/dist/packem_chunks/handler26.js +1 -1
  34. package/dist/packem_chunks/handler27.js +1 -1
  35. package/dist/packem_chunks/handler28.js +1 -1
  36. package/dist/packem_chunks/handler29.js +1 -1
  37. package/dist/packem_chunks/handler3.js +2 -2
  38. package/dist/packem_chunks/handler30.js +1 -1
  39. package/dist/packem_chunks/handler32.js +1 -1
  40. package/dist/packem_chunks/handler4.js +1 -1
  41. package/dist/packem_chunks/handler46.js +1 -1
  42. package/dist/packem_chunks/handler5.js +1 -1
  43. package/dist/packem_chunks/handler50.js +1 -1
  44. package/dist/packem_chunks/handler51.js +1 -1
  45. package/dist/packem_chunks/handler52.js +1 -1
  46. package/dist/packem_chunks/handler53.js +1 -1
  47. package/dist/packem_chunks/handler54.js +1 -1
  48. package/dist/packem_chunks/handler55.js +1 -1
  49. package/dist/packem_chunks/handler56.js +1 -1
  50. package/dist/packem_chunks/handler58.js +1 -1
  51. package/dist/packem_chunks/handler59.js +1 -1
  52. package/dist/packem_chunks/handler6.js +1 -1
  53. package/dist/packem_chunks/handler60.js +1 -1
  54. package/dist/packem_chunks/handler61.js +22 -3
  55. package/dist/packem_chunks/handler62.js +2 -22
  56. package/dist/packem_chunks/handler63.js +6 -2
  57. package/dist/packem_chunks/handler64.js +8 -61
  58. package/dist/packem_chunks/handler65.js +2 -6
  59. package/dist/packem_chunks/handler66.js +12 -8
  60. package/dist/packem_chunks/handler67.js +5 -2
  61. package/dist/packem_chunks/handler68.js +25 -12
  62. package/dist/packem_chunks/handler69.js +50 -25
  63. package/dist/packem_chunks/handler7.js +1 -1
  64. package/dist/packem_chunks/handler70.js +153 -50
  65. package/dist/packem_chunks/handler71.js +1 -1
  66. package/dist/packem_chunks/handler72.js +1 -1
  67. package/dist/packem_chunks/handler73.js +1 -1
  68. package/dist/packem_chunks/handler74.js +1 -1
  69. package/dist/packem_chunks/handler75.js +1 -1
  70. package/dist/packem_chunks/handler76.js +1 -1
  71. package/dist/packem_chunks/handler77.js +1 -1
  72. package/dist/packem_chunks/handler78.js +1 -1
  73. package/dist/packem_chunks/handler79.js +64 -64
  74. package/dist/packem_chunks/handler8.js +1 -1
  75. package/dist/packem_chunks/handler9.js +1 -1
  76. package/dist/packem_chunks/heal-accept.js +1 -1
  77. package/dist/packem_chunks/heal.js +1 -1
  78. package/dist/packem_chunks/help-command.js +1 -1
  79. package/dist/packem_chunks/index7.js +1 -1
  80. package/dist/packem_chunks/keys-refresh.js +1 -1
  81. package/dist/packem_chunks/lean.js +1 -1
  82. package/dist/packem_chunks/list.js +1 -1
  83. package/dist/packem_chunks/loader.js +1 -1
  84. package/dist/packem_chunks/prune.js +1 -1
  85. package/dist/packem_chunks/status.js +1 -1
  86. package/dist/packem_chunks/sync.js +1 -1
  87. package/dist/packem_chunks/sync2.js +1 -1
  88. package/dist/packem_chunks/tripwire.js +1 -1
  89. package/dist/packem_chunks/ts-loader.js +2 -2
  90. package/dist/packem_chunks/verify-lockfile.js +1 -1
  91. package/dist/packem_chunks/workflow-templates.js +29 -32
  92. package/dist/packem_shared/{ReleaseClient-C2xIJ6LK.js → ReleaseClient-CqGLb7S4.js} +1 -1
  93. package/dist/packem_shared/{advisories-DoJg1aO9.js → advisories-CyXUdibZ.js} +1 -1
  94. package/dist/packem_shared/{affected-selection-vthRDY8k.js → affected-selection-CJnDzyIK.js} +1 -1
  95. package/dist/packem_shared/affected-shas-CJLirD2O.js +1 -0
  96. package/dist/packem_shared/{ai-analysis-BQXQSrpM.js → ai-analysis-DHlzow2O.js} +1 -1
  97. package/dist/packem_shared/{ai-cache-_pgEsibl.js → ai-cache-D-BSLcuJ.js} +1 -1
  98. package/dist/packem_shared/{ai-fix-Bc5SFN7s.js → ai-fix-CyExJC_c.js} +1 -1
  99. package/dist/packem_shared/{augment-BSeqaai8.js → augment-Ub6PCwbh.js} +1 -1
  100. package/dist/packem_shared/{bin-N12LFeEP.js → bin-BaReRSyo.js} +1 -1
  101. package/dist/packem_shared/{build-scripts-Dff0s5AH.js → build-scripts-BeJkep8z.js} +1 -1
  102. package/dist/packem_shared/ci-commands-4W9d2six.js +1 -0
  103. package/dist/packem_shared/{command-runtime-DG49t2MT.js → command-runtime-DdnpiUmN.js} +1 -1
  104. package/dist/packem_shared/{dependency-scan-DheQqeil.js → dependency-scan-CyByCwef.js} +1 -1
  105. package/dist/packem_shared/{detect-CknQIlyA.js → detect-xqoTANJb.js} +1 -1
  106. package/dist/packem_shared/{docker-w_1gOq50.js → docker-CJXAt5Au.js} +1 -1
  107. package/dist/packem_shared/{ecosystem-gate-BKRW_EF3.js → ecosystem-gate-DEnubRcS.js} +1 -1
  108. package/dist/packem_shared/{env-CGTN0BFz.js → env-NauRSSEC.js} +1 -1
  109. package/dist/packem_shared/{env-consistency-2UlhhMn5.js → env-consistency-Cl1Rg65z.js} +1 -1
  110. package/dist/packem_shared/{failure-log-DwZ4pNmp.js → failure-log-DwroazKs.js} +1 -1
  111. package/dist/packem_shared/glob-Cyk1H9ZL-BtN6Zzwg.js +1 -0
  112. package/dist/packem_shared/{index-CypvJE1G.js → index-BCEhCrLl.js} +1 -1
  113. package/dist/packem_shared/{index-DGll9r9W.js → index-OmE1O0Ys.js} +1 -1
  114. package/dist/packem_shared/{index-0dnGN3GP.js → index-zq6Ehql6.js} +1 -1
  115. package/dist/packem_shared/{isAccessibleSync-DYKTrrvc-CBsMZhj-.js → isAccessibleSync-DYKTrrvc-CKahNmLy.js} +1 -1
  116. package/dist/packem_shared/{lifecycle-B2m1OncV.js → lifecycle-Cn1mSP5f.js} +1 -1
  117. package/dist/packem_shared/{lockfile-DEWjBrlY.js → lockfile-Cx2Ny3um.js} +1 -1
  118. package/dist/packem_shared/{manifests-hpWznbs9.js → manifests-BEGTH1ZG.js} +1 -1
  119. package/dist/packem_shared/{min-release-age-Dy7mkYsY.js → min-release-age-DLAERxRt.js} +1 -1
  120. package/dist/packem_shared/{missing-package-json-SDyf6fjC.js → missing-package-json-w74qGfyh.js} +1 -1
  121. package/dist/packem_shared/{multi-eco-lockfiles-DDjCxn43.js → multi-eco-lockfiles-SATPXx6-.js} +1 -1
  122. package/dist/packem_shared/{native-config-sync-DlljvZ64.js → native-config-sync-DDFn6Zsf.js} +1 -1
  123. package/dist/packem_shared/{npmrc-CIvOb61L.js → npmrc-DONprxrc.js} +1 -1
  124. package/dist/packem_shared/{osv-C4Vn7VCy.js → osv-dvIA_vX3.js} +1 -1
  125. package/dist/packem_shared/{package-version-DteJxz6k.js → package-version-BOK3IncQ.js} +2 -2
  126. package/dist/packem_shared/{packument-BHB4BqzR.js → packument-B678kHJO.js} +1 -1
  127. package/dist/packem_shared/{pm-runner-BXRi4ZM9.js → pm-runner-CYsiSHYa.js} +1 -1
  128. package/dist/packem_shared/{project-name-filter-yTiFERfc.js → project-name-filter-CBEoY08a.js} +1 -1
  129. package/dist/packem_shared/{provenance-BLycrdW2.js → provenance-D4ioWGBq.js} +1 -1
  130. package/dist/packem_shared/publish-missing-DgPXeH9w.js +38 -0
  131. package/dist/packem_shared/reachable-DX8FPErP.js +1 -0
  132. package/dist/packem_shared/{registry-48vkYPJB.js → registry-ClmannRw.js} +2 -2
  133. package/dist/packem_shared/{registry-keys-DdqAOng1.js → registry-keys-CF45rOur.js} +1 -1
  134. package/dist/packem_shared/{removeSync-g1D5kONg-jOsRSIIv.js → removeSync-g1D5kONg-DcG75b0G.js} +1 -1
  135. package/dist/packem_shared/{renderToString-DR0zDUjh-AcCpRdMt.js → renderToString-DR0zDUjh-CBDmAXxb.js} +1 -1
  136. package/dist/packem_shared/{resolve-explicit-BbIYCI43.js → resolve-explicit-C5-y-xEU.js} +1 -1
  137. package/dist/packem_shared/{resolve-runtime-D8rxuo3J.js → resolve-runtime-DBDozrmt.js} +1 -1
  138. package/dist/packem_shared/{run-file-D1mlOnd8.js → run-file-BKXvoVj2.js} +1 -1
  139. package/dist/packem_shared/{run-summary-utils-BIFZ0_Qf.js → run-summary-utils-75paIrLB.js} +1 -1
  140. package/dist/packem_shared/{runtime-check-B2u8WTUY.js → runtime-check-Yl8-Awkf.js} +1 -1
  141. package/dist/packem_shared/{s1ngularity-CTb560h1.js → s1ngularity-B2bqwE0C.js} +1 -1
  142. package/dist/packem_shared/{scaffold-files-CnWTGzav.js → scaffold-files-UiCBBCT5.js} +1 -1
  143. package/dist/packem_shared/{scan-progress-BEB4T6jo.js → scan-progress-Dws7Gif1.js} +1 -1
  144. package/dist/packem_shared/{selectors-DFzKNlk8.js → selectors-DZ4HDnlD.js} +1 -1
  145. package/dist/packem_shared/{signatures-CoRC1HW7.js → signatures-DNqgsRp7.js} +1 -1
  146. package/dist/packem_shared/{spinner-uH0pr4ln.js → spinner-BQ9mLz8X.js} +1 -1
  147. package/dist/packem_shared/{table-DL8yVcm3.js → table-D1CpySxU.js} +1 -1
  148. package/dist/packem_shared/{tabs-C1RRtWUi.js → tabs-BYtpIN5b.js} +1 -1
  149. package/dist/packem_shared/{target-options-rIthWS4M.js → target-options-CsevVc7U.js} +1 -1
  150. package/dist/packem_shared/{task-env-Cl4jNMCR.js → task-env-BftNOR00.js} +1 -1
  151. package/dist/packem_shared/{toolchain-BdYvWNPz.js → toolchain-BvluBdrw.js} +1 -1
  152. package/dist/packem_shared/{typosquats-D0yqKvP6.js → typosquats-XrArH9TO.js} +1 -1
  153. package/dist/packem_shared/{use-measured-height-Cq0aFDqE.js → use-measured-height-hHis1NaB.js} +1 -1
  154. package/dist/packem_shared/{verify-3WE9U_Bv.js → verify-Dic2G0nQ.js} +1 -1
  155. package/dist/packem_shared/{vis-update-app-B0FW7Sl_.js → vis-update-app-BNnbDZ--.js} +1 -1
  156. package/dist/packem_shared/{vis-user-error-Bdcaov20.js → vis-user-error-DhgW3DzD.js} +2 -2
  157. package/dist/packem_shared/{watch-C-9-PD2m.js → watch-BLHtUgfb.js} +1 -1
  158. package/dist/packem_shared/{watch-loop-B2vH6Ae0.js → watch-loop-Dh4GHUVS.js} +7 -7
  159. package/dist/release/index.js +1 -1
  160. package/dist/runtime/preload.js +1 -1
  161. package/index.d.ts +204 -213
  162. package/index.js +54 -54
  163. package/package.json +11 -10
  164. package/schemas/vis-config.schema.json +1419 -80
  165. package/dist/packem_shared/affected-shas-CycHU3nr.js +0 -1
  166. package/dist/packem_shared/glob-Cyk1H9ZL-DV-XWFct.js +0 -1
  167. package/dist/packem_shared/publish-missing-CZK1BpWt.js +0 -38
@@ -1 +1 @@
1
- import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-BdYvWNPz.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};
1
+ import{r as p}from"../packem_shared/affected-shas-CJLirD2O.js";import{r as u}from"../packem_shared/toolchain-BvluBdrw.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const l=h[0];if(!l)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const o=l.split(",").map(a=>a.trim()).filter(Boolean);if(o.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const t=p({defaultBase:f?.defaultBase,workspaceRoot:n}),d=e.base??t.base,c=e.head??t.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${t.provider} (${t.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of o){r.info(`▸ Running affected ${a} (base=${d}, head=${c})`);const i=[a,`--base=${d}`,`--head=${c}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&i.push(`--parallel=${String(e.parallel)}`),e.partition&&i.push(`--partition=${String(e.partition)}`),e.query&&i.push(`--query=${String(e.query)}`),e.depsOnly&&i.push("--deps-only"),e.skipDeps&&i.push("--skip-deps"),e.ifPresent&&i.push("--if-present"),await s.runCommand("affected",{argv:i})}r.info("▸ CI pipeline complete")};export{$ as default};
@@ -1,50 +1,153 @@
1
- import{createRequire as Ke}from"node:module";import{b as C,F as I,X as Xe,J as Ee,q as Ze}from"../packem_shared/index.server-Ca_EEVfw.js";import{m as Qe,v as E,U as x,a as M,e as V,z as et}from"../packem_shared/index-0dnGN3GP.js";import{wholeMatchFingerprint as tt,maskFinding as ee,fingerprint as H,legacyFingerprint as st,baselineKeys as ce,GIT_CONFIG_OVERRIDES as nt,DIFF_HARDENING_FLAGS as it,gitleaksIgnoreFingerprint as K,toSarifUri as rt,CONFIDENCE_LEVELS as le,DEFAULT_MAX_FILE_SIZE as O,MAX_ARCHIVE_DEPTH as ot,listRules as Te,listRequiredValidators as at,scan as ct,isPathExcluded as lt,scanStringDetailed as dt,scanGitHistoryDetailed as ut,scanDetailed as ht,scanGitStaged as pt,scanFilesDetailed as ft,inspectRuleset as mt}from"@visulima/secret-scanner";import{V as $}from"../packem_shared/vis-user-error-Bdcaov20.js";import{a3 as gt,a4 as de,p as T}from"./cli-main.js";import{E as vt,A as wt}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Rt}from"../packem_shared/package-version-DteJxz6k.js";import{w as z}from"../packem_shared/github-workflow-command-Bn0MgB78.js";import{e as W,c as Dt}from"../packem_shared/junit-audit-CuJShWCH.js";let Ye;const Je=e=>(Ye??=Ke(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,s]=N.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return N.getBuiltinModule(e)}return Je(e)},{createRequire:$t}=L("node:module"),{mkdirSync:yt,writeFileSync:X,openSync:Ae,fchmodSync:je,closeSync:Le,realpathSync:G,lstatSync:Me,fstatSync:bt,fchownSync:St,fsyncSync:kt,renameSync:It,rmSync:xt,readFileSync:Ft}=L("node:fs"),{randomUUID:Ct,createHash:Et}=L("node:crypto"),{resolve:ue,relative:Ne,join:Tt,dirname:At,basename:jt,sep:Lt,isAbsolute:Mt}=L("node:path"),{execFileSync:Nt}=L("node:child_process"),{pathToFileURL:De}=L("node:url");let Bt;const _t=e=>(Bt??=$t(import.meta.url))(e),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ut=e=>{if(typeof D<"u"&&D.versions&&D.versions.node){const[t,s]=D.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return D.getBuiltinModule(e)}return _t(e)},{styleText:Ot}=Ut("node:util"),qt={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},Pt=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},zt=/\u001B\[[\d;]*[a-z]/gi,Wt=e=>[...e.replaceAll(zt,"")].length,Vt=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?s=>s:s=>Ot(t,s)};class Ht{#r=0;#l;#e=!1;#i="";#o="";#g=0;#d=0;#t;#s;#u="";#a;#f;#n;#y;#h=0;#c;#b;constructor(t={},s){if(t.frames)this.#a=t.frames;else{const n=t.name??"dots",r=wt(n);if(!r)throw new Error(`Unknown spinner "${n}". Pass a custom \`frames\` set or use one of: ${vt().join(", ")}.`);this.#a=r}this.#f=t.verbose!==!1,this.#i=t.prefixText??"",this.#t=s,this.#n=t.stream??process.stderr,this.#y=s?!0:this.#n.isTTY&&!Pt(),this.#b={...qt,...t.icons},typeof t.style=="function"?this.#c=t.style:t.style&&(this.#c=Vt(t.style))}get elapsedTime(){return this.#g===0?0:(this.#d||Date.now())-this.#g}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#v()}get prefixText(){return this.#i}set prefixText(t){this.#i=t,this.#e&&this.#v()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#s=t}tick(){this.#e&&(this.#r=(this.#r+1)%this.#a.frames.length)}start(t,s){return this.#e?this:this.#f?(this.#e=!0,this.#g=Date.now(),this.#d=0,this.#r=0,this.#u="",t&&(this.#o=t),s?.prefixText&&(this.#i=s.prefixText),this.#s?(this.#s.renderAll(),this):(this.#t?(this.#t.hook(),this.#S(),this.#$()):(this.#k(),this.#$()),this)):this}stop(){if(this.#e){if(this.#p(),this.#e=!1,this.#d=Date.now(),this.#u="",this.#s){this.#s.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#w()}}stopAndPersist(t){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#f))return;const s=t?.prefixText??this.#i,n=t?.text??this.#o;let r=t?.symbol??"";s&&(r=r?`${s} ${r}`:s),n&&(r=r?`${r} ${n}`:n),this.#I(r)}succeed(t){this.#m("success",t)}failed(t){this.#m("error",t)}warn(t){this.#m("warning",t)}info(t){this.#m("info",t)}pause(){this.#p()}resume(){this.#e&&(this.#p(),this.#s||this.#$())}getFrameOutput(){if(!this.#e&&this.#u)return this.#u;const t=this.#a.frames[this.#r];let s=this.#c?this.#c(t):t;return this.#i&&(s=`${this.#i} ${s}`),this.#o&&(s=`${s} ${this.#o}`),s}#$(){this.#y&&(this.#l=setInterval(()=>{this.#e&&(this.#r=(this.#r+1)%this.#a.frames.length,this.#v())},this.#a.interval),this.#l.unref())}#p(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#v(){this.#s?this.#s.renderAll():this.#t?this.#S():this.#k()}#S(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#w(),this.#n.isTTY){this.#n.write(t);const s=this.#n.columns||80;this.#h=Math.max(1,Math.ceil(Wt(t)/s))}else this.#n.write(`${t}
2
- `),this.#h=0}#w(){if(this.#h>0&&this.#n.isTTY){for(let t=1;t<this.#h;t+=1)this.#n.write("\x1B[1A\x1B[2K");this.#n.write("\r\x1B[K")}this.#h=0}#I(t){this.#u=t,this.#s?this.#s.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#w(),this.#n.write(`${t}
3
- `))}#m(t,s){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#f))return;let n="";const r=this.#b[t];r&&(n=this.#c?this.#c(r):r),this.#i&&(n=`${this.#i} ${n}`),s&&(n=`${n} ${s}`),this.#I(n)}}const Be=(e={})=>{const t=new gt(new de(process.stdout),new de(process.stderr));return new Ht(e,t)},he=384,_e=(e,t,s)=>{if(yt(Qe(e),{recursive:!0}),!s){X(e,t);return}const n=Ae(e,"w",he);try{je(n,he),X(n,t)}finally{Le(n)}},Ue=(e,t)=>{if(!E(e))return e;const s=M(t,e);return s===""||s.startsWith("..")?e:s},Z=e=>{try{return G(e)}catch{return e}},Oe=(e,t)=>{const s=M(e,t);return s===""||s.startsWith("..")||E(s)?t:s},j=(e,t)=>{const s={...e,file:Ue(e.file,t)};return delete s.root,s},se=e=>{if(!te(e))return[];try{const t=Rt(e);return Array.isArray(t)?t:[]}catch{return[]}},ne=(e,t,s)=>{const n=E(e)?e:x(t,e);return Oe(Z(s),n)},pe=(e,t,s)=>{const n=ne(e.file,t,s);return n===e.file?e:{...e,file:n}},Gt=(e,t,s)=>{const n=e.files.map(r=>({...r,file:ne(r.file,t,s)}));return{...e,files:n}},Kt=(e,t,s)=>{const n=Z(t),r=Z(s);return se(e).flatMap(i=>{const a=Oe(r,E(i.file)?i.file:x(n,i.file));return a===i.file?[i]:[i,{...i,file:a}]})},fe=e=>[...ce(e),...ce(ee(e))],_=e=>typeof e=="string"?e:"",ie=e=>{const t={...e,match:_(e.match),secret:_(e.secret)};return Array.isArray(e.requiredFindings)?t.requiredFindings=e.requiredFindings.map(s=>({...s,match:_(s.match),secret:_(s.secret)})):delete t.requiredFindings,t},re=e=>ee(ie(e)),me=e=>[H(ie(e)),st(e),H(re(e))],Yt=(e,t,s)=>{const n=se(t).map(o=>j(o,s)),r=new Set(n.flatMap(o=>me(o))),i=e.map(o=>j(o,s)),a=new Set(i.flatMap(o=>fe(o))),c=o=>fe(o).some(d=>r.has(d));return{fresh:i.filter(o=>!c(o)),resolved:n.filter(o=>!me(o).some(d=>a.has(d))),surviving:i.filter(o=>c(o))}},ge=e=>H(re(e)),Jt=e=>{const t=_(e.secret);return re(e).secret===t},qe=(e,t,s,n={})=>{const r=e.map(a=>j(a,s));let i;if(n.replace)i=r;else{const a=new Set(r.filter(l=>l.secret!==l.match).map(l=>tt(ee(l)))),c=se(t).map(l=>j(l,s)).filter(l=>!a.has(ge(l))),o=new Set,d=new Set,f=new Set;i=[];for(const l of[...c,...r]){const b=H(ie(l)),h=ge(l),u=Jt(l);o.has(b)||(u?d.has(h):f.has(h))||(o.add(b),d.add(h),u&&f.add(h),i.push(l))}}return _e(t,`${JSON.stringify(i,null,4)}
4
- `,!0),i.length},Xt="********",Pe="<REDACTED>",Zt=Buffer.from(Pe,"utf8"),$e=(e,t)=>{const s=Ne(e,t);return s===".."||s.startsWith(`..${Lt}`)||Mt(s)},Qt=(e,t)=>{let s=1;for(let n=0;n<t;n++)e[n]===10&&s++;return s},es=(e,t,{gid:s,mode:n,uid:r})=>{const i=Tt(At(e),`.${jt(e)}.vis-fix-${process.pid}-${Ct()}`);try{const a=Ae(i,"wx",n);try{const c=bt(a);(c.uid!==r||c.gid!==s)&&St(a,r,s),je(a,n),X(a,t),kt(a)}finally{Le(a)}It(i,e)}catch(a){throw xt(i,{force:!0}),a}},ve=(e,t)=>Ne(e,t)||t,ze=e=>{try{const t=Me(e);return t.isSymbolicLink()?{reason:"symbolic link"}:t.isFile()?t.nlink>1?{reason:"hard-linked file"}:(t.mode&146)===0?{reason:"read-only file"}:{bytes:Ft(e),dev:t.dev,gid:t.gid,ino:t.ino,mode:t.mode%4096,mtimeMs:t.mtimeMs,size:t.size,uid:t.uid}:{reason:"not a regular file"}}catch{return{reason:"file unavailable"}}},ts=(e,t)=>{try{const s=ze(e);return!("reason"in s)&&G(e)===e&&s.dev===t.dev&&s.ino===t.ino&&s.mode===t.mode&&s.uid===t.uid&&s.gid===t.gid&&s.size===t.size&&s.mtimeMs===t.mtimeMs&&s.bytes.equals(t.bytes)}catch{return!1}},ss=({matchEnd:e,matchStart:t,secretEnd:s,secretStart:n},r,i)=>Number.isInteger(t)&&Number.isInteger(e)&&Number.isInteger(n)&&Number.isInteger(s)&&t>=0&&n>=t&&s>n&&s<=e&&e<=r.length&&r.subarray(n,s).equals(i),ns=e=>{const t=[];for(const{end:s,ruleId:n,start:r}of[...e].sort((i,a)=>i.start-a.start||i.end-a.end)){const i=t.at(-1);i!==void 0&&r<i.end?(i.end=Math.max(i.end,s),i.ruleIds.add(n)):t.push({end:s,ruleIds:new Set([n]),start:r})}return t},is=(e,t)=>{const s=[];let n=0;for(const{end:r,start:i}of t)s.push(e.subarray(n,i),Zt),n=r;return s.push(e.subarray(n)),Buffer.concat(s)},rs=(e,t,s,n=t)=>{const r=[],i=new Map,a=new Map,c=ue(t,n);let o;try{o=G(t)}catch{o=t}const d=h=>{const u=ue(c,h),p=ve(t,u);if($e(t,u))return{display:p,reason:"outside workspace"};let w;try{if(Me(u).isSymbolicLink())return{display:p,reason:"symbolic link"};w=G(u)}catch{return{display:p,reason:"file unavailable"}}if($e(o,w))return{display:p,reason:"outside workspace"};let v=a.get(w);return v===void 0&&(v=ze(w),a.set(w,v)),"reason"in v?{display:p,reason:v.reason}:{display:p,file:v,path:w}};for(const h of e){if(h.sourceSpan===void 0){r.push({file:h.file,line:h.startLine,reason:h.spanUnavailableReason??"no trusted byte span",ruleId:h.ruleId});continue}const u=d(h.file);for(const p of[h,...h.requiredFindings??[]]){const w=(S,y)=>{r.push({file:y,line:p.startLine,reason:S,ruleId:p.ruleId})},{sourceSpan:v}=p;if(v===void 0){w(p.spanUnavailableReason??"no trusted byte span",h.file);continue}if(p.secret.length===0){w("empty secret",h.file);continue}if("reason"in u){w(u.reason,u.display);continue}if(!ss(v,u.file.bytes,Buffer.from(p.secret,"utf8"))){w("span does not match file",u.display);continue}const g=i.get(u.path)??{file:u.file,spans:[]};g.spans.push({end:v.secretEnd,ruleId:p.ruleId,start:v.secretStart}),i.set(u.path,g)}}const f=[];let l=0,b=0;for(const[h,{file:u,spans:p}]of i){const w=ns(p),v=ve(t,h),g=w.map(({ruleIds:y,start:m})=>({line:Qt(u.bytes,m),ruleIds:y}));if(!s){let y;if(ts(h,u))try{es(h,is(u.bytes,w),u)}catch{y="write failed"}else y="file changed during scan";if(y!==void 0){for(const{line:m,ruleIds:k}of g)r.push({file:v,line:m,reason:y,ruleId:[...k].sort().join(", ")});continue}}l++,b+=w.length;const S=new Map;for(const{line:y,ruleIds:m}of g)S.set(y,new Set([...S.get(y)??[],...m]));for(const[y,m]of S)f.push({file:v,line:y,ruleId:[...m].sort().join(", ")})}return f.sort((h,u)=>h.file.localeCompare(u.file)||h.line-u.line),r.sort((h,u)=>h.file.localeCompare(u.file)||h.line-u.line||h.reason.localeCompare(u.reason)),{changedFiles:l,edits:f,replacements:b,skipped:r}},Q=(e,t)=>{try{return Nt("git",[...nt,...t],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}catch{return""}},os=e=>e.split("\0").filter(Boolean),we=(e,t)=>{if(t.startsWith("-"))throw new $(`--since "${t}" looks like a flag, not a git ref.`);const s=x(e,Q(e,["rev-parse","--show-cdup"]).trim()),n=i=>os(Q(e,["diff","-z","--name-only","--diff-filter=ACMR",...it,i,"--"]));let r=n(`${t}...HEAD`);return r.length===0&&(r=n(t)),r.map(i=>E(i)?i:V(s,i))},ye=e=>Q(e,["rev-parse","--show-toplevel"]).trim().length>0,as=/^[\t\r+=@-]/,F=e=>{const t=as.test(e)?`'${e}`:e;return/[\n\r",]/.test(t)?`"${t.replaceAll('"','""')}"`:t},cs=["RuleID","Commit","File","Secret","Match","StartLine","EndLine","StartColumn","EndColumn","Author","Message","Date","Email","Fingerprint","Tags"],ls=e=>{const t=e.map(s=>[F(s.ruleId),F(s.commit?.sha??""),F(s.file),F(s.secret),F(s.match),String(s.startLine),String(s.endLine),String(s.startColumn),String(s.endColumn),F(s.commit?.authorName??""),F(s.commit?.message??""),F(s.commit?.date??""),F(s.commit?.authorEmail??""),F(K(s)),F(s.tags.join(" "))].join(","));return`${[cs.join(","),...t].join(`\r
5
- `)}\r
6
- `},ds=e=>{const t=[...e];return t.length<=6?"******":`${t.slice(0,3).join("")}${"*".repeat(t.length-6)}${t.slice(-3).join("")}`},us=(e,t={})=>{const s=(t.now??new Date).toISOString().replace(/\.\d{3}Z$/,""),n=String(e.length),r=e.map(i=>{const a=`${i.file}:${String(i.startLine)}:${String(i.startColumn)}`,c=[`Rule: ${i.ruleId}`,`File: ${a}`,...i.commit===void 0?[]:[`Commit: ${i.commit.sha}`,`Author: ${i.commit.authorName} <${i.commit.authorEmail}>`],`Secret: ${ds(i.secret)}`,`Fingerprint: ${K(i)}`].join(`
7
- `),o=`<failure type="${W(i.ruleId)}" message="${W(i.description||i.ruleId)}">${Dt(c)}</failure>`;return[` <testcase classname="${W(i.file)}" name="${W(`${i.ruleId} at ${a}`)}">`,` ${o}`," </testcase>",""].join(`
8
- `)}).join("");return['<?xml version="1.0" encoding="UTF-8"?>',`<testsuites name="vis-secrets" tests="${n}" failures="${n}" skipped="0" errors="0" time="0">`,` <testsuite name="secrets" tests="${n}" failures="${n}" skipped="0" errors="0" timestamp="${s}" time="0">`,`${r} </testsuite>`,"</testsuites>",""].join(`
9
- `)},hs=e=>{const t=e.map(s=>({categories:["Security"],check_name:s.ruleId,description:`${s.ruleId}: ${s.description||"Potential secret"}`,engine_name:"vis-secrets",fingerprint:Et("sha256").update(`${K(s)}\0${String(s.startColumn)}\0${String(s.endLine)}\0${String(s.endColumn)}`).digest("hex"),location:{lines:{begin:s.startLine,end:s.endLine},path:s.file},severity:"critical",type:"issue"}));return`${JSON.stringify(t,void 0,2)}
10
- `},ps=/\.(?:zip|jar|war|ear|tar|tgz|gz)!/iu,fs=(e,t={})=>e.map(s=>{const n=s.description||s.ruleId,r=`${s.file}:${String(s.startLine)}`;return s.commit?z("error",{title:s.ruleId},`${n}
11
- ${r} in commit ${s.commit.sha.slice(0,7)}`):t.staged?z("error",{title:s.ruleId},`${n}
12
- ${r} (staged)`):ps.test(s.file)?z("error",{title:s.ruleId},`${n}
13
- ${r}`):z("error",{col:s.startColumn,endColumn:s.endColumn,endLine:s.endLine,file:s.file,line:s.startLine,title:s.ruleId},n)}).join(""),be=1,ms=e=>{const t=new Map;for(const s of e){const n=t.get(s.file);n?n.push(s):t.set(s.file,[s])}return t},gs=(e,t)=>{if(t!==void 0)return t.split(/\r?\n/);try{return et(e).split(/\r?\n/)}catch{return}},$s=(e,t,s)=>{const n=Math.max(1,t);return`${e.slice(0,n-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,s))}`},B=e=>e,We=e=>e?{cyan:Ze,dim:I,green:Ee,red:Xe,yellow:C}:{cyan:B,dim:B,green:B,red:B,yellow:B},vs=(e,t,s,n={})=>{if(e.length===0)return s?I("No secrets detected."):"No secrets detected.";const r=We(s),i=[],a=ms(e);for(const[c,o]of a){const d=M(t,c)||c;i.push(r.cyan(d));const f=n.redact?void 0:gs(c,n.virtualSource);for(const l of o){const b=[l.source,l.confidence].filter(Boolean).join(", "),h=b?` ${r.dim(`(${b})`)}`:"",u=l.alternateMatches&&l.alternateMatches.length>0?` ${r.dim(`also: ${l.alternateMatches.join(", ")}`)}`:"";let p="";switch(l.validation){case"error":{p=` ${r.yellow("! error")}`;break}case"rejected":{p=` ${r.red("✗ rejected")}`;break}case"skipped":{p=` ${r.dim("— unverifiable")}`;break}case"verified":{p=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${l.ruleId}]`)}${h}${p} ${r.dim(`line ${String(l.startLine)}:${String(l.startColumn)}`)}${u}`),f){const w=Math.max(0,l.startLine-1-be),v=Math.min(f.length,l.startLine+be);for(let g=w;g<v;g+=1){const S=String(g+1).padStart(4," "),y=g+1===l.startLine,m=y?r.red("▶"):" ";if(i.push(` ${m} ${r.dim(S)} │ ${f[g]??""}`),y){const k=Math.max(1,(l.endColumn??l.startColumn+1)-l.startColumn),P=$s(f[g]??"",l.startColumn,k);i.push(` ${r.dim(" │ ")}${r.red(P)}`)}}}i.push("")}}return i.join(`
14
- `).trimEnd()},ws=(e,t,s={})=>{if(e.length===0)return t?I("No secrets detected in git history."):"No secrets detected in git history.";const n=We(t),r=new Map;for(const a of e){const c=r.get(a.commit.sha);c?c.push(a):r.set(a.commit.sha,[a])}const i=[];for(const[a,c]of r){const{authorName:o,date:d,message:f}=c[0].commit;i.push(`${n.yellow(a.slice(0,10))} ${f}`),i.push(` ${n.dim(`${o} · ${d}`)}`);for(const l of c){const b=[l.source,l.confidence].filter(Boolean).join(", "),h=b?` ${n.dim(`(${b})`)}`:"",u=s.redact?"":` ${n.dim(l.match)}`;i.push(` ${n.red("✖")} ${n.yellow(`[${l.ruleId}]`)}${h} ${n.cyan(l.file)} ${n.dim(`line ${String(l.startLine)}:${String(l.startColumn)}`)}${u}`)}i.push("")}return i.join(`
15
- `).trimEnd()},ys=(e,t,s,n={})=>{const r=new Map;for(const o of e)r.set(o.reason,(r.get(o.reason)??0)+1);const i=[...r].map(([o,d])=>`${o}: ${String(d)}`).join(", "),a=`${String(e.length)} ${t}(s) not scanned (${i})${n.verbose?"":"; use --verbose to list them"}`,c=[s?C(a):a];if(n.verbose)for(const o of e){const d="sha"in o?` ${o.commit===void 0?"":`${o.commit.slice(0,10)} `}${o.sha.slice(0,10)}`:"",f=` - ${o.path} [${o.reason}]${d}`;c.push(s?I(f):f)}return c.join(`
16
- `)},bs=(e,t,s)=>{const n=`${String(e.length)} allow marker(s) name unknown rule ids and still suppress every rule (rename or remove the ids):`,r=[s?C(n):n];for(const i of e){const a=` - ${Ue(i.file,t)}:${String(i.line)} unknown: ${i.unknownRuleIds.join(", ")}`;r.push(s?I(a):a)}return r.join(`
17
- `)},Ss=(e,t)=>{if(!E(e))return rt(e);try{return De(e).toString()}catch{return`file://${x(t,e).replaceAll("\\","/")}`}},ks=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,Is=(e,t,s=process.cwd(),n=[])=>{const r=new Map(n.map(o=>[o.id,o])),i=new Set;for(const o of e)i.add(o.ruleId);const a=[...new Set([...r.keys(),...i])].sort((o,d)=>o.localeCompare(d)),c=new Map(a.map((o,d)=>[o,d]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:De(s).toString()}},results:e.map(o=>{const d={};return o.source&&(d.source=o.source),o.confidence&&(d.confidence=o.confidence),o.alternateMatches&&o.alternateMatches.length>0&&(d.alternateRules=o.alternateMatches),o.validation&&(d.validation=o.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:Ss(o.file,s),uriBaseId:E(o.file)?void 0:"SRCROOT"},region:{endColumn:o.endColumn,endLine:o.endLine,snippet:{text:o.match},startColumn:o.startColumn,startLine:o.startLine}}}],message:{text:o.description||o.ruleId},properties:Object.keys(d).length>0?d:void 0,ruleId:o.ruleId,ruleIndex:c.get(o.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:a.map(o=>{const d=r.get(o),f=d?.description??`Detected by rule \`${o}\``,l={};return d?.tags&&d.tags.length>0&&(l.tags=d.tags),d?.source&&(l.source=d.source),d?.confidence&&(l.confidence=d.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:f},helpUri:"https://visulima.com/packages/secret-scanner",id:o,name:o,properties:Object.keys(l).length>0?l:void 0,shortDescription:{text:ks(f)}}}),version:t}}}],version:"2.1.0"},void 0,2)},oe=["text","json","sarif","csv","junit","gitlab-code-quality","github"],Ve=e=>oe.includes(e),xs=e=>{const t=[],s=new Set;for(const n of e){const r=n.indexOf("="),i=r===-1?n:n.slice(0,r),a=r===-1?"":n.slice(r+1);if(!Ve(i))throw new $(`--report "${n}": format must be one of ${oe.join(", ")}, as <format>=<path> (e.g. sarif=secrets.sarif)`);if(a==="")throw new $(`--report "${n}" needs a file path: ${i}=<path>`);if(s.has(a))throw new $(`--report writes ${a} twice; give each report its own file.`);s.add(a),t.push({format:i,path:a})}return t},Se=(e,t,s)=>{const n=()=>t.map(r=>j(r,s.root));switch(e){case"csv":return ls(n());case"github":return fs(n(),{staged:s.staged});case"gitlab-code-quality":return hs(n());case"json":return`${JSON.stringify(n(),null,2)}
18
- `;case"junit":return us(n());case"sarif":return`${Is(t,s.toolVersion,s.root,s.ruleMetadata)}
19
- `;default:return`${s.history?ws(t,s.useColor,{redact:s.redact}):vs(t,s.root,s.useColor,{redact:s.redact,virtualSource:s.virtualSource})}
20
- `}},Fs=e=>e.kind==="secret"?"<secret-value entry>":e.raw,Rs=(e,t,s)=>{const n=`${String(e.length)} unused ${t} entr${e.length===1?"y":"ies"} (no finding matched; remove or update them):`,r=[s?C(n):n];for(const i of e){const a=` - line ${String(i.line)}: ${Fs(i)}`;r.push(s?I(a):a)}return r.join(`
21
- `)},Cs=(e,t,s)=>{const n=`${String(e.length)} finding(s) suppressed:`,r=[s?C(n):n];for(const i of e){const a=j(i,t),c=i.suppressedByEntry===void 0?"":` line ${String(i.suppressedByEntry.line)}`,o=`${i.suppressedBy}${c}`,d=` - [${i.ruleId}] ${K({...a,commit:i.commit})} (${o})`;r.push(s?I(d):d)}return r.join(`
22
- `)},Es=async(e,t)=>{try{return await e.access(t),!0}catch{return!1}},A=e=>e?Array.isArray(e)?e:[e]:[],Ts=e=>{if(e===void 0)return"text";if(!Ve(e))throw new $(`--format must be one of: ${oe.join(", ")} (got "${e}")`);return e},ke=(e,t,s)=>{if(e!==void 0){if(!Number.isInteger(e)||e<0||s!==void 0&&e>s){const n=s===void 0?"a non-negative integer":`an integer from 0 to ${String(s)}`;throw new $(`${t} must be ${n} (got ${String(e)}).`)}return e}},As=e=>{if(e!==void 0&&(!Number.isInteger(e)||e<1))throw new $(`--max-size must be a positive number of bytes (got ${String(e)}; default ${String(O)}).`);return e},js=e=>{if(e!==void 0){if(!le.includes(e))throw new $(`--min-confidence must be one of: ${le.join(", ")} (got "${e}")`);return e}},Ls=(e,t,s)=>{const n=t??{},r=m=>m?x(s,m):void 0,i=(m,k)=>{const P=A(m);return P.length>0?P:k},a=(n.config?.presets??[]).map(m=>`tag:preset:${m}`),c=i(e.enableRule,n.rules?.enable)??[],o=[...c,...a.filter(m=>!c.includes(m))],d=o.length>0?o:void 0,f=i(e.excludeRule,n.rules?.exclude),l=i(e.includeRule,n.rules?.include),b=i(e.exclude,n.walk?.excludePatterns),h=A(e.excludeFrom).map(m=>x(s,m)),u=n.walk?.excludeFromFiles?.map(m=>x(s,m)),p=r(e.baseline)??r(n.baseline),w=r(e.config)??r(n.config?.path),v=js(e.minConfidence??n.config?.minConfidence),g=A(e.secretlintignore).map(m=>x(s,m));let S,y=h.length>0?h:u;if(e.secretlintignore===!1)S=!1;else if(g.length>0&&n.secretlintIgnore===!1)S=!1,y=[...y??[],...g];else if(g.length>0){const m=Array.isArray(n.secretlintIgnore)?n.secretlintIgnore.map(k=>x(s,k)):[];S=[...new Set([...m,...g])]}else n.secretlintIgnore===!1?S=!1:S=n.secretlintIgnore?.map(m=>x(s,m));return{baseline:p,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:n.config?.extendBundled,inline:n.config?.inline,minConfidence:v,onlyVerified:e.onlyVerified??n.config?.onlyVerified??!1,path:w,validate:e.validate??n.config?.validate??!1},inlineAllow:e.inlineAllow,maxArchiveDepth:ke(e.maxArchiveDepth,"--max-archive-depth",ot),maxDecodeDepth:ke(e.maxDecodeDepth,"--max-decode-depth"),overrides:n.overrides,overridesRoot:s,profile:e.profile===!0,redact:e.redact??n.redact??!0,reportSuppressed:e.logIgnored===!0,rules:{enable:d,exclude:f,include:l},secretlintIgnore:S,verbose:e.verbose??!1,walk:{excludeFromFiles:y,excludePatterns:b,gitignore:e.gitignore===!1?!1:n.walk?.gitignore??!0,includeHidden:e.includeHidden??n.walk?.includeHidden,maxFileSize:As(e.maxSize)??n.walk?.maxFileSize}}},q=e=>{if(e.stdin!==void 0){if(e.stdin===null||e.stdin==="")throw new $("--stdin needs a filename used for rule and path matching, e.g. `cat .env | vis secrets --stdin .env`.");return e.stdin}},He=e=>[q(e)===void 0?void 0:"--stdin",e.history?"--history":void 0,e.staged?"--staged":void 0,e.since===void 0?void 0:"--since",e.affected?"--affected":void 0].filter(t=>t!==void 0),Ie=(e,t)=>[e.listRules?"--list-rules":void 0,e.listValidators?"--list-validators":void 0,e.init?"--init":void 0,t&&e.updateBaseline?"--update-baseline":void 0].find(s=>s!==void 0),Ms=e=>{const t=He(e);if(t.length>1)throw new $(`${t.join(", ")} each pick what to scan and can't be combined. Use one of them.`);if(!e.history){const s=[e.all?"--all":void 0,e.historyRange===void 0?void 0:"--history-range",e.maxCommits===void 0?void 0:"--max-commits"].filter(n=>n!==void 0);if(s.length>0)throw new $(`${s.join(", ")} only applies to git history scans. Did you mean \`vis secrets --history ${s.join(" ")}\`?`);return}if(e.all&&e.historyRange!==void 0)throw new $("--all walks every ref and can't be combined with --history-range. Use one or the other.");if(e.updateBaseline)throw new $("--update-baseline records working-tree findings and can't be combined with --history.");if(e.maxCommits!==void 0&&(!Number.isInteger(e.maxCommits)||e.maxCommits<1))throw new $(`--max-commits must be a positive integer (got ${String(e.maxCommits)}); omit it to walk every commit.`)},Ns=e=>{const t=e.history?"--history":e.staged?"--staged":void 0;if(e.maxArchiveDepth!==void 0&&t!==void 0)throw new $(`--max-archive-depth only applies to working-tree scans; ${t} scans git blobs as text and doesn't open archives. Drop --max-archive-depth or ${t}.`)},Ge=(e,t)=>[q(e)===void 0?void 0:"--stdin",e.staged?"--staged":void 0,e.since===void 0?void 0:"--since",e.affected?"--affected":void 0,e.historyRange===void 0?void 0:"--history-range",e.maxCommits===void 0?void 0:"--max-commits",t?"explicit paths":void 0].filter(s=>s!==void 0),Ds=(e,t)=>{if(q(e)!==void 0){if(t)throw new $("--stdin scans piped content and can't be combined with explicit paths.");const c=[e.updateBaseline?"--update-baseline":void 0,e.replaceBaseline?"--replace-baseline":void 0,e.logIgnored?"--log-ignored":void 0,e.maxSize===void 0?void 0:"--max-size",e.maxArchiveDepth===void 0?void 0:"--max-archive-depth",e.failOnUnreadable?"--fail-on-unreadable":void 0].filter(o=>o!==void 0);if(c.length>0)throw new $(`${c.join(", ")} can't be combined with --stdin: a single piped buffer can't seed a baseline, and there are no files to size-check, skip, list or open as archives.`)}const s=Ie(e,!0),n=[A(e.report).length>0?"--report":void 0,e.logIgnored?"--log-ignored":void 0,e.profile?"--profile":void 0,e.failOnUnreadable?"--fail-on-unreadable":void 0,e.failOnUnusedIgnores?"--fail-on-unused-ignores":void 0].filter(c=>c!==void 0);if(s!==void 0&&n.length>0)throw new $(`${n.join(", ")} only applies to a scan report and can't be combined with ${s}.`);const r=Ie(e,!1),i=[...He(e),...t?["explicit paths"]:[]];if(r!==void 0&&i.length>0)throw new $(`${i.join(", ")} picks what to scan and can't be combined with ${r}.`);if(!e.failOnUnusedIgnores)return;if(e.gitleaksIgnore===!1)throw new $("--fail-on-unused-ignores checks .gitleaksignore, which --no-gitleaks-ignore turns off. Drop one of them.");const a=Ge(e,t);if(a.length>0)throw new $(`--fail-on-unused-ignores needs a full scan: with ${a.join(", ")}, entries for files outside the scan would be reported as unused. Run it on a full \`vis secrets\` or \`vis secrets --history\` scan.`)},Bs=e=>{if(e.dryRun&&!e.fix&&!e.init)throw new $("--dry-run needs --fix (to preview rewrites) or --init (to preview a baseline).")},_s=(e,t,s)=>{if(!e.fix)return;const n=e.format??"text",r=[e.redact===!0?"--redact":void 0,e.history?"--history":void 0,e.staged?"--staged":void 0,e.init?"--init":void 0,q(e)===void 0?void 0:"--stdin",e.profile?"--profile":void 0,e.listRules?"--list-rules":void 0,e.listValidators?"--list-validators":void 0,e.updateBaseline?"--update-baseline":void 0,e.replaceBaseline?"--replace-baseline":void 0,A(e.report).length>0?"--report":void 0,e.logIgnored?"--log-ignored":void 0,e.failOnUnreadable?"--fail-on-unreadable":void 0,e.failOnUnusedIgnores?"--fail-on-unused-ignores":void 0,e.validate||t.config?.validate?"--validate":void 0,n==="text"?void 0:`--format ${n}`].filter(i=>i!==void 0);if(r.length>0)throw new $(`${r.join(", ")} cannot be combined with --fix. Fix mode rewrites working-tree files in place and prints only a masked summary.`);if(s>1)throw new $("--fix accepts at most one path; run one scan per path so rewrite targets stay unambiguous.")},ae=".gitleaksignore",R=T.child({stdout:process.stderr}),Us=(e,t)=>{const{flags:s,root:n,useColor:r}=t;s.quiet||(e.skipped.length>0&&process.stderr.write(`${ys(e.skipped,e.skippedUnit,r,{verbose:s.verbose})}
23
- `),e.allowWarnings.length>0&&process.stderr.write(`${bs(e.allowWarnings,n,r)}
24
- `),t.fullScan&&e.unusedIgnores.length>0&&process.stderr.write(`${Rs(e.unusedIgnores,ae,r)}
25
- `)),s.logIgnored&&process.stderr.write(`${Cs(e.suppressed,n,r)}
26
- `)},Y=44,J=(e,t,s="start")=>{const n=e.replaceAll(/\s+/gu," ").trim();return n.length<=t?n.padEnd(t):s==="end"?`…${n.slice(n.length-t+1)}`:`${n.slice(0,t-1)}…`},xe=(e,t,s,n="")=>` ${e} ${t.toFixed(1).padStart(7)} ms ×${String(s)}${n}`,Os=()=>({files:[],phases:[],rules:[],totalMs:0}),qs=(e,t=!1)=>{const s=i=>t?I(i):i,n=[`${s("profile:")} ${e.totalMs.toFixed(1)} ms total, ${String(e.files.length)} file(s)`],r=(i,a)=>{n.push(s(`${i}:`),...a.length>0?a:[" (none)"])};return r("phases",e.phases.slice(0,10).map(i=>xe(J(i.name,Y),i.ms,i.count))),r("rules",e.rules.slice(0,10).map(i=>xe(J(i.ruleId,Y),i.ms,i.count,` ${String(i.matches)} match(es)`))),r("files",e.files.slice(0,10).map(i=>` ${J(i.file,Y,"end")} ${i.ms.toFixed(1).padStart(7)} ms`)),n.join(`
27
- `)},Fe=(e,t)=>{e!==void 0&&process.stderr.write(`${qs(e,t)}
28
- `)},Ps=e=>{process.stderr.write(`${I("baseline diff: ")}${Ee(`+${String(e.fresh.length)} new`)} · ${C(`${String(e.surviving.length)} unchanged`)} · ${I(`-${String(e.resolved.length)} resolved`)}
29
- `)},zs=async(e,t)=>{const{flags:s,format:n,history:r,reports:i,root:a,scanOptions:c,stdin:o,toolbox:d,toolVersion:f,useColor:l}=t,b=c.redact,u=n==="sarif"||i.some(v=>v.format==="sarif")?await Te(c).catch(()=>[]):[],p={history:r,redact:b,root:a,ruleMetadata:u,staged:s.staged===!0,toolVersion:f,virtualSource:o},w=!b||r;process.stdout.write(Se(n,e.findings,{...p,useColor:l}));for(const v of i){const g=x(d.process.cwd,v.path);_e(g,Se(v.format,e.findings,{...p,useColor:!1}),w),s.quiet||R.info(`Wrote ${v.format} report to ${M(d.process.cwd,g)||g}`)}},Ws=(e,t)=>{if(t.failOnUnreadable){const s=e.skipped.filter(n=>n.reason!=="too-large"&&n.reason!=="binary").length;s>0&&(R.error(`${String(s)} ${e.skippedUnit}(s) could not be read; the scan is incomplete (--fail-on-unreadable).`),process.exitCode=1)}t.failOnUnusedIgnores&&e.unusedIgnores.length>0&&(R.error(`${String(e.unusedIgnores.length)} unused ${ae} entr${e.unusedIgnores.length===1?"y":"ies"} (--fail-on-unused-ignores).`),process.exitCode=1)},Vs=(e,t,s,n)=>{if(e.replacements===0&&e.skipped.length===0){n||process.stderr.write(t>0?`No secrets detected, but ${String(t)} file(s) were not scanned.
30
- `:`No secrets detected.
31
- `);return}for(const r of e.edits)process.stderr.write(`${r.file}:${String(r.line)} ${r.ruleId}: ${Xt} -> ${Pe}${s?" (dry-run)":""}
32
- `);for(const r of e.skipped)process.stderr.write(`Skipped ${r.file}:${String(r.line)} ${r.ruleId}: ${r.reason}
33
- `);n||(process.stderr.write(`${s?"Would replace":"Replaced"} ${String(e.replacements)} secret(s) in ${String(e.changedFiles)} file(s).
34
- `),t>0&&process.stderr.write(`${String(t)} file(s) were not scanned.
35
- `))},U=".secrets-baseline.json",Hs=async(e,t)=>{const s=await Te(e);process.stdout.write(`${String(s.length)} rules loaded
36
-
37
- `);for(const n of s){const r=t?C(n.id):n.id,i=n.tags.length>0?` ${t?I(`[${n.tags.join(", ")}]`):`[${n.tags.join(", ")}]`}`:"";if(process.stdout.write(`${r}${i}
38
- ${n.description}
39
- `),n.keywords.length>0){const a=`keywords: ${n.keywords.slice(0,6).join(", ")}${n.keywords.length>6?", ...":""}`;process.stdout.write(` ${t?I(a):a}
40
- `)}process.stdout.write(`
41
- `)}},Gs=async(e,t)=>{const s=await at(e);if(s.length===0){process.stdout.write(t?`${I("No non-HTTP validators required by the current ruleset.")}
42
- `:`No non-HTTP validators required by the current ruleset.
43
- `);return}process.stdout.write(`${String(s.length)} non-HTTP validator type(s) referenced by the current ruleset:
44
-
45
- `);for(const n of s){const r=t?C(n.displayName):n.displayName,i=`(${n.type}, ${String(n.ruleCount)} rule${n.ruleCount===1?"":"s"})`;process.stdout.write(`${r} ${t?I(i):i}
46
- `),process.stdout.write(` ${n.summary}
47
- `);const a=n.packageName?`install: npm add ${n.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?I(a):a}
48
-
49
- `)}},Ks=async(e,t,s)=>{const n=V(e,U);if(!s&&te(n)){T.warn(`Detected existing ${U} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}T.info(s?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Be();r.start("scanning");let i;try{i=await ct([e],t),r.succeed()}catch(c){throw r.failed(),c}if(s){T.info(`[dry-run] Would create ${U} with ${String(i.length)} finding(s).`);return}const a=qe(i,n,e,{replace:!0});T.success(`Wrote ${U} (${String(a)} findings).`),T.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},Re={files:{failure:"secret scan",spinner:"scanning for secrets"},history:{failure:"git-history secret scan",spinner:"scanning git history for secrets"},paths:{failure:"secret scan",spinner:"scanning for secrets"},staged:{failure:"secret scan",spinner:"scanning for secrets"},stdin:{failure:"piped-input secret scan",spinner:"scanning piped input"}},Ce=(e,t,s)=>{const n=x(s,e),r=M(t,n);return r===""||r===".."||r.startsWith("../")||E(r)?n:r},Ys=async()=>{const e=[];let t=0;for await(const s of process.stdin){if(t+=s.length,t>O)throw new $(`--stdin input exceeds ${String(O)} bytes, the largest file the scanner reads. Scan it as a file instead.`);e.push(s)}return Buffer.concat(e).toString("utf8")},Js=async(e,t,s,n,r)=>{const i=q(e);if(i!==void 0){if(r!==""){if(Buffer.byteLength(r)>O)throw new $(`--stdin input exceeds ${String(O)} bytes, the largest file the scanner reads. Scan it as a file instead.`);return{content:r,filename:Ce(i,s,n),kind:"stdin"}}if(process.stdin.isTTY)throw new $("--stdin expects piped input, but stdin is a terminal. Pipe content in, e.g. `cat .env | vis secrets --stdin .env`.");return{content:await Ys(),filename:Ce(i,s,n),kind:"stdin"}}const a=t.length>0?t.map(o=>x(s,o)):[s],c=e.history?"--history":e.staged?"--staged":e.since===void 0?void 0:"--since";if(c!==void 0&&!ye(s))throw new $(`${c} requires a git working tree, and none was detected.`);return e.history?{kind:"history"}:e.staged?{kind:"staged"}:e.since!==void 0?{files:we(s,e.since),kind:"files"}:e.affected?ye(s)?{files:we(s,process.env.VIS_BASE??"HEAD~1"),kind:"files"}:(R.warn("--affected requires git; falling back to full scan"),{kind:"paths",paths:a}):{kind:"paths",paths:a}},Xs=async(e,t,s,n)=>{if(e.kind==="stdin"){const{allowWarnings:c,findings:o}=lt(e.filename,s,n)?{allowWarnings:[],findings:[]}:await dt(e.content,e.filename,s);return{allowWarnings:c,findings:o,skipped:[],skippedUnit:"file",suppressed:[],unusedIgnores:[]}}if(e.kind==="history")return{...await ut({...s,all:t.all,cwd:n,maxCommits:t.maxCommits,range:t.historyRange}),skippedUnit:"blob"};if(e.kind==="paths")return{...await ht(e.paths,s),skippedUnit:"file"};const r=process.cwd(),i={...s,baseline:typeof s.baseline=="string"?Kt(s.baseline,n,r):s.baseline},a=e.kind==="staged"?await pt({...i,cwd:n}):await ft(e.files,{...i,ignoreRoot:n});return{allowWarnings:a.allowWarnings.map(c=>({...c,file:ne(c.file,r,n)})),findings:a.findings.map(c=>pe(c,r,n)),profile:a.profile&&Gt(a.profile,r,n),skipped:a.skipped,skippedUnit:e.kind==="staged"?"blob":"file",suppressed:a.suppressed.map(c=>pe(c,r,n)),unusedIgnores:a.unusedIgnores}},Zs=async e=>{const t=await mt(e);if(t.length>0){R.warn(`${String(t.length)} rule(s) skipped due to invalid regex. First few:`);for(const s of t.slice(0,5))process.stderr.write(` - ${s.ruleId}: ${s.reason}
50
- `)}},un=async e=>{const{argument:t,options:s,visConfig:n,workspaceRoot:r}=e,i=s,a=t??[],c=r??e.process.cwd,o=!i.quiet&&process.stdout.isTTY,d=n?.secrets,f=Ls(i,d,c),l="0.0.0-alpha";Ms(i),Ns(i),Ds(i,a.length>0),Bs(i),_s(i,f,a.length),i.fix&&(f.redact=!1);const b=Ts(i.format),h=xs(A(i.report)),u=V(c,ae);if(i.gitleaksIgnore!==!1&&await Es(e.fs,u)&&(f.gitleaksIgnore=u),i.listRules){await Hs(f,o);return}if(i.listValidators){await Gs(f,o);return}if(i.init){await Ks(c,f,i.dryRun??!1);return}const p=await Js(i,a,c,e.process.cwd,e.process.stdin),w=p.kind==="history";if(p.kind==="files"&&p.files.length===0){i.quiet||R.success("No files to scan."),i.profile&&Fe(Os(),o);return}const v=Be({verbose:!i.quiet&&b==="text"&&!i.fix});v.start(Re[p.kind].spinner);let g;try{g=await Xs(p,i,f,c),v.succeed()}catch(k){throw v.failed(),new $(`${Re[p.kind].failure} failed: ${k instanceof Error?k.message:String(k)}`,{cause:k})}if(i.fix){const k=rs(g.findings,c,i.dryRun===!0,p.kind==="paths"?p.paths[0]:c);Vs(k,g.skipped.length,i.dryRun===!0,i.quiet===!0),k.skipped.length>0&&(process.exitCode=1);return}const S={flags:i,format:b,fullScan:Ge(i,a.length>0).length===0,history:w,reports:h,root:c,scanOptions:f,stdin:p.kind==="stdin"?p.content:void 0,toolbox:e,toolVersion:l,useColor:o};Us(g,S),Fe(g.profile,o),i.verbose&&await Zs(f);const{findings:y}=g,m=typeof f.baseline=="string"?f.baseline:V(c,U);if(i.updateBaseline){const k=qe(y,m,c,{replace:i.replaceBaseline});R.success(`Baseline updated: ${M(c,m)||m} now contains ${String(k)} entries.`);return}await zs(g,S),b==="text"&&!w&&!i.quiet&&te(m)&&Ps(Yt(y,m,c)),y.length>0?(i.quiet||(R.warn(`${String(y.length)} potential secret(s) found${w?" across git history":""}`),R.notice(w?"Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.":"Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exitCode=1):i.quiet||R.success(w?"No secrets detected in git history.":"No secrets detected."),Ws(g,i)};export{un as default};
1
+ import{createRequire as me}from"node:module";import{G as ye,v as ke,z as je,m as oe,a as L,e as _}from"../packem_shared/index-zq6Ehql6.js";import{L as U}from"../packem_shared/index-BisalDCf.js";import Ce from"./index.js";import{d as ne,q as Ee,u as Se}from"../packem_shared/registry-ClmannRw.js";import{V as v}from"../packem_shared/vis-user-error-DhgW3DzD.js";import{d as Oe}from"../packem_shared/lockfile-Cx2Ny3um.js";import{C as P,G as E,u as _e}from"../packem_shared/ci-commands-4W9d2six.js";import{r as W}from"../packem_shared/reachable-DX8FPErP.js";import{n as Ne}from"../packem_shared/manifests-BEGTH1ZG.js";import{_ as G,Z as Ie}from"./cli-main.js";import{l as Pe}from"../packem_shared/glob-Cyk1H9ZL-BtN6Zzwg.js";import{g as Re}from"../packem_shared/package-version-BOK3IncQ.js";let we;const be=e=>(we??=me(import.meta.url))(e),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$e=e=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[t,o]=I.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return I.getBuiltinModule(e)}return be(e)},{isDeepStrictEqual:ve}=$e("node:util"),q=["lint","typecheck","lint:types","build","test"],se="Generated by `vis sync ci-workflow`. Do not edit by hand: change `ci.workflow` in vis.config.ts and re-run it.",Te=e=>{const t=typeof e=="string"?e:e.target;return t.startsWith("^")?t.slice(1):t},Me=(e,t={})=>{const o=new Map;for(const s of Object.values(e))for(const[n,a]of Object.entries(s.targets??{})){const r=o.get(n)??new Set;for(const i of a.dependsOn??t[n]?.dependsOn??[])r.add(Te(i));o.set(n,r)}return o},Ge=(e,t)=>{const o=new Map([...t].map(([r,i])=>[r,new Set(i)]));if(!e.includes("build"))return{edges:o,ordered:[]};const s=r=>W([r],i=>t.get(i)),n=s("build"),a=e.filter(r=>r!=="build"&&!s(r).has("build")&&!n.has(r));for(const r of a)o.set(r,new Set([...o.get(r)??[],"build"]));return{edges:o,ordered:a}},Ae=(e,t)=>{const o=new Set(e),s=new Map(e.map(c=>[c,[...W([c],u=>t.get(u))].filter(u=>o.has(u)&&u!==c)])),n=new Map,a=new Set,r=c=>{const u=n.get(c);if(u!==void 0)return u;if(a.has(c))throw new v(`ci.workflow.targets: "${c}" depends on itself through dependsOn, so it cannot be ordered.`);a.add(c);const f=Math.max(0,...(s.get(c)??[]).map(g=>r(g)+1));return a.delete(c),n.set(c,f),f},i=[];for(const c of e){const u=r(c),f=i[u]??[];f.push(c),i[u]=f}return i.filter(c=>c.length>0)},De=({cacheDirectory:e,defaultBase:t,ecosystems:o=[],packageManager:s,projects:n,providers:a,rootFiles:r=new Set,settings:i,targetDefaults:c,toolchainPins:u={},visVersion:f})=>{if(i.timeoutMinutes!==void 0&&(!Number.isInteger(i.timeoutMinutes)||i.timeoutMinutes<1))throw new v(`ci.workflow.timeoutMinutes must be a positive integer, got ${JSON.stringify(i.timeoutMinutes)}.`);if(i.targets?.length===0)throw new v("ci.workflow.targets is empty. List the targets to run, or remove it to use the defaults.");const g=new Set(Object.values(n).flatMap(p=>Object.keys(p.targets??{}))),$=(i.targets??[]).map(p=>typeof p=="string"?{env:void 0,name:p}:p),m=i.targets===void 0?q.filter(p=>g.has(p)):$.map(({name:p})=>p),y=new Map($.map(({env:p,name:C})=>[C,p])),w=m.find((p,C)=>m.indexOf(p)!==C);if(w!==void 0)throw new v(`ci.workflow.targets lists "${w}" more than once.`);const h=i.github??{};for(const[p,C]of Object.entries(h.steps??{}))for(const N of C)if(N.run===void 0==(N.uses===void 0))throw new v(`ci.workflow.github.steps.${p}: "${N.name}" needs exactly one of \`run\` or \`uses\`.`);const l=m.filter(p=>!g.has(p));if(l.length>0)throw new v(`ci.workflow.targets: no project defines ${l.map(p=>`"${p}"`).join(", ")}.`);if(m.length===0)throw new v(`No project defines any of ${q.join(", ")}. Set ci.workflow.targets in vis.config.ts.`);const b=i.partitions??{},d=Me(n,c);for(const[p,C]of Object.entries(b)){if(!m.includes(p))throw new v(`ci.workflow.partitions.${p}: "${p}" is not one of the workflow's targets (${m.join(", ")}).`);if(!Number.isInteger(C)||C<1)throw new v(`ci.workflow.partitions.${p} must be a positive integer, got ${JSON.stringify(C)}.`);if(C>1&&W([p],N=>d.get(N)).has(p))throw new v(`ci.workflow.partitions.${p}: ${p} depends on ${p} of other projects (^${p}), directly or through other targets, so its shards would depend on each other. Remove the partition.`)}let k=d,j=[];return(i.buildFirst??!0)&&({edges:k,ordered:j}=Ge(m,k)),{buildFirstOrdered:j,plan:{affected:i.affected??!0,branches:i.branches??[t??"main"],cacheDirectory:e,checkDrift:i.checkDrift??!0,ecosystems:o,github:h,gitlab:i.gitlab??{},layers:Ae(m,k).map(p=>p.map(C=>({env:y.get(C),name:C,shards:b[C]??1}))),nodeVersion:i.nodeVersion??u.node??"22",packageManager:s,providers:[...a].toSorted(),rootFiles:r,runsOn:i.runsOn??"ubuntu-latest",timeoutMinutes:i.timeoutMinutes??60,toolchainPins:u,visVersion:f}}},H=e=>/^[\w.:@/+-]+$/u.test(e)?e:`'${e.replaceAll("'",String.raw`'\''`)}'`,re=e=>e.packageManager===void 0?"vis":`${P[e.packageManager].exec} vis`,ie=e=>`${re(e)} sync ci-workflow --check --provider=${e.providers.join(",")}`,ae=e=>`npm install --global @visulima/vis@${e.visVersion}`,R=(e,t,o)=>{const s=re(e);return[e.affected?`${s} ci ${H(t)} --no-install`:`${s} run ${H(t)}`,...o,"--if-present"].join(" ")},S=e=>JSON.stringify(e),T=e=>/^[\w.-]+$/u.test(e)?e:S(e),J=(e,t)=>typeof e!="string"?String(e):e.includes(`
2
+ `)?`|
3
+ ${e.replace(/\n$/u,"").split(`
4
+ `).map(o=>`${t}${o}`).join(`
5
+ `)}`:S(e),ce=e=>typeof e=="boolean"||typeof e=="number"||typeof e=="string",K=(e,t)=>Object.entries(e).flatMap(([o,s])=>ce(s)||typeof s=="object"&&s!==null?O(o,s,t):[]),O=(e,t,o)=>{const s=`${o} `;return typeof t!="object"?[`${o}${T(e)}: ${J(t,s)}`]:Array.isArray(t)?[`${o}${T(e)}:`,...t.flatMap(n=>{if(ce(n))return[`${s}- ${J(n,`${s} `)}`];const[a="",...r]=typeof n=="object"&&n!==null?K(n,`${s} `):[];return[`${s}- ${a.trimStart()}`,...r]})]:[`${o}${T(e)}:`,...K(t,s)]},z=10,ue=(e,t)=>{if("parallel"in e)return`${t}- parallel:
6
+ ${e.parallel.map(g=>ue(g,`${t} `)).join("")}`;const o=`${t} `,{comment:s,env:n,name:a,run:r,uses:i,with:c,...u}=e,f=s===void 0?[]:s.split(`
7
+ `).map(g=>`${t}# ${g}`);f.push(`${t}- name: ${S(a)}`),u.if!==void 0&&f.push(...O("if",u.if,o)),typeof i=="string"?f.push(...O("uses",i,o)):i!==void 0&&f.push(`${o}uses: ${S(`${i.name}@${i.sha}`)} # ${i.version}`);for(const[g,$]of[["with",c],["env",n],["working-directory",u["working-directory"]],["shell",u.shell],["run",r],["continue-on-error",u["continue-on-error"]],["timeout-minutes",u["timeout-minutes"]]])$!==void 0&&f.push(...O(g,$,o));return`${f.join(`
8
+ `)}
9
+ `},Le=e=>e.includes("/")?e.slice(0,e.lastIndexOf("/")):".",We=(e,{manifests:t,name:o})=>{const s=e.toolchainPins,n=a=>e.rootFiles.has(a);switch(o){case"dart":return{name:"Setup Dart",uses:E.setupDart,with:{sdk:"stable"}};case"dotnet":{const a=n("global.json")?"global.json":t.find(r=>r.endsWith("/global.json"));return{name:"Setup .NET",uses:E.setupDotnet,with:a===void 0?{"dotnet-version":"8.0.x"}:{"global-json-file":a}}}case"elixir":return{name:"Setup Elixir",uses:E.setupBeam,with:n(".tool-versions")?{"version-file":".tool-versions","version-type":"strict"}:{"elixir-version":"1.18","otp-version":"27"}};case"go":{const a=t.find(r=>r.endsWith("go.mod"))??"go.mod";return{name:"Setup Go",uses:E.setupGo,with:{"cache-dependency-path":"**/go.sum",...s.go===void 0?{"go-version-file":a}:{"go-version":s.go}}}}case"gradle":case"maven":return{name:"Setup Java",uses:E.setupJava,with:{cache:o,distribution:"temurin","java-version":"21"}};case"php":return{name:"Setup PHP",uses:E.setupPhp,with:{...n(".php-version")?{"php-version-file":".php-version"}:{"php-version":"8.3"},tools:"composer"}};case"python":{const a=t.filter(i=>/(?:pyproject\.toml|requirements\.txt)$/u.test(i)),r=s.python===void 0?n(".python-version")?{"python-version-file":".python-version"}:{"python-version":"3.x"}:{"python-version":s.python};return{name:"Setup Python",uses:E.setupPython,with:{...r,...a.length>0?{cache:"pip","cache-dependency-path":`${a.join(`
10
+ `)}
11
+ `}:{}}}}case"ruby":{const a=t.find(r=>r.endsWith("Gemfile"));return{name:"Setup Ruby",uses:E.setupRuby,with:{...s.ruby===void 0?n(".ruby-version")||n(".tool-versions")?{}:{"ruby-version":"3.4"}:{"ruby-version":s.ruby},...a===void 0?{}:{"bundler-cache":!0,"working-directory":Le(a)}}}}case"rust":return{name:"Setup Rust",uses:E.setupRust,...s.rust===void 0?{}:{with:{toolchain:s.rust}}};case"zig":return{name:"Setup Zig",uses:E.setupZig};default:return}},xe=e=>{const t=[],o=n=>({name:"Setup Node.js",uses:E.setupNode,with:{"node-version":e.nodeVersion,...n===void 0?{}:{cache:n}}});if(e.packageManager===void 0)t.push(o(void 0),{name:"Install vis",run:ae(e)});else{const n=P[e.packageManager];n.githubAction===void 0?t.push(o(n.githubNodeCache),...n.setup.length>0?[{name:`Setup ${e.packageManager}`,run:`${n.setup.join(`
12
+ `)}
13
+ `}]:[]):t.push({name:`Setup ${e.packageManager}`,uses:n.githubAction},o(n.githubNodeCache)),t.push({name:"Install dependencies",run:n.install})}const s=new Set;for(const n of e.ecosystems){const a=We(e,n);a!==void 0&&!s.has(a.name)&&(s.add(a.name),t.push(a))}return t.push({comment:"The vis task cache, so unchanged tasks are restored instead of re-run.",name:"Restore vis cache",uses:E.cache,with:{key:"vis-${{ runner.os }}-${{ github.sha }}",path:e.cacheDirectory??"node_modules/.cache/vis","restore-keys":"vis-${{ runner.os }}-\n"}}),t.push(...e.github.steps?.afterSetup??[]),e.checkDrift&&t.push({comment:"Fails when vis.config.ts or the workspace changed without regenerating this file.",name:"Check the workflow is up to date",run:ie(e)}),t},Fe=e=>e.layers.map(t=>{const o=t.flatMap(({env:n,name:a,shards:r})=>{const i=["--skip-deps"];return r===1?[{env:n,name:a,run:R(e,a,i)}]:Array.from({length:r},(c,u)=>{const f=`${u+1}/${r}`;return{env:n,name:`${a} (${f})`,run:R(e,a,[...i,`--partition=${f}`])}})});if(o.length>z)throw new v(`The group ${t.map(({name:n})=>n).join(", ")} needs ${o.length} parallel steps, but GitHub runs at most ${z} at once. Lower ci.workflow.partitions.`);const[s]=o;return o.length===1&&s?s:{parallel:o}}),Be=e=>{const t=[{comment:"Full history, so affected detection can diff against the base.",name:"Checkout",uses:E.checkout,with:{"fetch-depth":0,"persist-credentials":!1}},...xe(e),{comment:`Builds what the targets below depend on once, so the parallel steps
14
+ never build or restore the same outputs at the same time.`,name:"Build dependencies",run:`${e.layers.flat().map(({name:r})=>R(e,r,["--deps-only"])).join(`
15
+ `)}
16
+ `},...Fe(e),...e.github.steps?.after??[]],{env:o,permissions:s,services:n}=e.github,a=[...o===void 0?[]:O("env",o," "),...n===void 0?[]:O("services",n," ")];return`# ${se}
17
+ name: "vis ci"
18
+
19
+ on: # yamllint disable-line rule:truthy
20
+ pull_request:
21
+ # Runs the checks for a merge queue too; an event no queue sends never fires.
22
+ merge_group:
23
+ push:
24
+ branches:
25
+ ${e.branches.map(r=>` - ${S(r)}`).join(`
26
+ `)}
27
+
28
+ ${O("permissions",{contents:"read",...s},"").join(`
29
+ `)}
30
+
31
+ concurrency:
32
+ group: "vis-ci-\${{ github.event_name == 'pull_request' && github.ref || github.sha }}"
33
+ # Supersede outdated pull request runs. Every other event gets a group per commit, because a
34
+ # shared group keeps only one pending run and would drop the middle one of three quick pushes.
35
+ cancel-in-progress: \${{ github.event_name == 'pull_request' }}
36
+
37
+ jobs:
38
+ ci:
39
+ name: "vis ci"
40
+ runs-on: ${S(e.runsOn)}
41
+ timeout-minutes: ${e.timeoutMinutes}
42
+ ${a.map(r=>`${r}
43
+ `).join("")} steps:
44
+ ${t.map(r=>ue(r," ")).join(`
45
+ `)}`},le=".gitlab/vis-ci.gitlab-ci.yml",V=200,Y=50,M=e=>`vis:${e}`,Ue=e=>`'${e.replaceAll("'","''")}'`,qe=e=>e.includes("*")?`$CI_COMMIT_BRANCH =~ /^${e.split("**").map(o=>o.split("*").map(s=>s.replaceAll(/[$()+.?[\\\]^{|}/]/gu,String.raw`\$&`)).join(String.raw`[^\/]*`)).join(".*")}$/`:`$CI_COMMIT_BRANCH == ${JSON.stringify(e)}`,He=e=>{if(e===void 0)return".vis-cache";const t=ye(e);if(ke(t)||t===".."||t.startsWith("../"))throw new v(`GitLab can only cache paths inside the project; taskRunner.cacheDirectory is "${e}".`);return t.replaceAll(/^\.\/|\/$/gu,"")},Je=e=>e==="go"||e==="python"||e==="ruby"||e==="rust",Ke=new Map([["go",{path:".go-mod",variable:"GOMODCACHE"}],["python",{path:".pip-cache",variable:"PIP_CACHE_DIR"}],["rust",{path:".cargo",variable:"CARGO_HOME"}]]),de=e=>e.gitlab.image===void 0?e.ecosystems.flatMap(({name:t})=>Je(t)&&e.toolchainPins[t]!==void 0?[]:[t]):[],ze=e=>{const t=e.branches.map(h=>` - if: ${Ue(qe(h))}`).join(`
46
+ `),o=He(e.cacheDirectory),s=e.ecosystems.flatMap(({name:h})=>{const l=Ke.get(h);return l===void 0?[]:[l]}),n=[" # Full history, so affected detection can diff against the base.",' GIT_DEPTH: "0"',...e.cacheDirectory===void 0?[" # Outside node_modules, so a clean install (npm ci) keeps the restored task cache.",` VIS_CACHE_DIRECTORY: "$CI_PROJECT_DIR/${o}"`]:[],...s.map(({path:h,variable:l})=>` ${l}: "$CI_PROJECT_DIR/${h}"`),...Object.entries(e.gitlab.variables??{}).flatMap(([h,l])=>O(h,l," "))].join(`
47
+ `),a=[o,...s.map(({path:h})=>h)].map(h=>` - ${S(`${h}/`)}`).join(`
48
+ `),i=[...e.packageManager===void 0?[ae(e)]:[...P[e.packageManager].setup,P[e.packageManager].install],...e.gitlab.beforeScript??[]].map(h=>` - ${S(h)}`).join(`
49
+ `),{afterScript:c,services:u,tags:f}=e.gitlab,g=[...f===void 0?[]:O("tags",f," "),...u===void 0?[]:O("services",u," "),...c===void 0?[]:O("after_script",c," ")],$=de(e),m=$.length===0?"":`#
50
+ # Not on the node image: ${$.join(", ")}. Pin go, python, ruby or rust in
51
+ # toolchain.tools (vis.config.ts) so vis installs them, or set \`image:\` on
52
+ # .vis-ci-base in your .gitlab-ci.yml to one that has them.
53
+ `;let y=e.checkDrift?`
54
+ "vis:workflow":
55
+ extends: ".vis-ci-base"
56
+ needs: []
57
+ script:
58
+ - ${S(ie(e))}
59
+ `:"",w=[];for(const h of e.layers){for(const{env:l,name:b,shards:d}of h){if(d>V)throw new v(`ci.workflow.partitions.${b} is ${d}, but GitLab runs at most ${V} parallel jobs. Lower it.`);if(w.length>Y)throw new v(`The job ${M(b)} would need ${w.length} jobs, but GitLab allows ${Y} in needs. List fewer targets.`);const k=d===1?[]:["--partition=$CI_NODE_INDEX/$CI_NODE_TOTAL"];y+=`
60
+ ${S(M(b))}:
61
+ extends: ".vis-ci-base"
62
+ needs: [${w.map(j=>S(j)).join(", ")}]
63
+ ${d===1?"":` parallel: ${d}
64
+ `}${l===void 0?"":`${O("variables",l," ").join(`
65
+ `)}
66
+ `} script:
67
+ - ${S(R(e,b,k))}
68
+ `}w=h.map(({name:l})=>M(l))}return`# ${se}
69
+ #
70
+ # Include it from .gitlab-ci.yml:
71
+ # include:
72
+ # - local: "${le}"
73
+ #
74
+ # Every target is its own job, so jobs in a group run on separate machines at
75
+ # the same time; a partitioned target fans out with \`parallel: N\`.
76
+ ${m}.vis-ci-base:
77
+ stage: ${S(e.gitlab.stage??"test")}
78
+ image: ${S(e.gitlab.image??`node:${e.nodeVersion}`)}
79
+ timeout: "${e.timeoutMinutes}m"
80
+ variables:
81
+ ${n}
82
+ cache:
83
+ # Per job: jobs of one group finish in any order, and a shared key keeps only the last upload.
84
+ key: "vis-$CI_JOB_NAME_SLUG-$CI_COMMIT_REF_SLUG"
85
+ paths:
86
+ ${a}
87
+ rules:
88
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
89
+ ${t}
90
+ before_script:
91
+ ${i}
92
+ ${g.map(h=>`${h}
93
+ `).join("")}${y}`},A={github:{path:".github/workflows/vis-ci.yml",render:Be},gitlab:{path:le,render:ze}},X=e=>Object.hasOwn(A,e),Ve=e=>e.providers.map(t=>({content:A[t].render(e),path:A[t].path})),Ye=[["dart",e=>e==="pubspec.yaml"],["dotnet",e=>/\.(?:cs|fs|vb)proj$|\.sln$/u.test(e)||e==="global.json"],["elixir",e=>e==="mix.exs"],["go",e=>e==="go.mod"],["gradle",e=>/^(?:build|settings)\.gradle(?:\.kts)?$/u.test(e)],["maven",e=>e==="pom.xml"],["php",e=>e==="composer.json"],["python",e=>["Pipfile","pyproject.toml","requirements.txt","setup.py"].includes(e)],["ruby",e=>e==="Gemfile"||e.endsWith(".gemspec")],["rust",e=>e==="Cargo.toml"],["swift",e=>e==="Package.swift"],["zig",e=>e==="build.zig"]],Xe=e=>{const t=new Map;for(const{files:o,path:s}of e)for(const n of o)for(const[a,r]of Ye)r(n)&&t.set(a,[...t.get(a)??[],s==="."||s===""?n:`${s}/${n}`]);return[...t].map(([o,s])=>({manifests:[...new Set(s)].toSorted(),name:o})).toSorted((o,s)=>o.name.localeCompare(s.name))},Ze=async({configured:e,detectRemote:t,exists:o,flag:s,prompt:n})=>{if(s!==void 0)return{providers:s,reason:"--provider"};if(e!==void 0)return{providers:e,reason:"ci.workflow.providers"};const a=[];if(await o(".github/workflows")&&a.push({file:".github/workflows",provider:"github"}),(await o(".gitlab-ci.yml")||await o(".gitlab/vis-ci.gitlab-ci.yml"))&&a.push({file:".gitlab-ci.yml",provider:"gitlab"}),a.length>0)return{providers:a.map(({provider:i})=>i),reason:`found ${a.map(({file:i})=>i).join(" and ")}`};const r=await t();if(r!==void 0)return{providers:[r],reason:`the git remote points at ${r==="github"?"GitHub":"GitLab"}`};if(n===void 0)throw new v("Could not tell which CI provider this repository uses (no .github/workflows, no .gitlab-ci.yml, no GitHub or GitLab remote). Pass --provider=github or --provider=gitlab, or set ci.workflow.providers in vis.config.ts.");return{providers:await n(),reason:"your choice"}},Qe=(e,t)=>{const o=t.replace(/^\.?\//,"");return o===""||o==="."?`/${e}/`:e===""||e==="."?`/${o}`:`/${e}/${o}`},Z=(e,t,o=[])=>{const s=[],n=new Set;for(const[r,i]of Object.entries(t?.globalPaths??{}))s.push({owners:i,path:r,source:"project-json"}),n.add(r);for(const[r,i]of Object.entries(e.projects)){const c=i.owners??[];for(const u of c){const f=Qe(i.root??r,u.path);s.push({channel:u.channel,owners:u.owners,path:f,projectId:r,source:"project-json"}),n.add(f)}}for(const r of o)n.has(r.path)||(s.push(r),n.add(r.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((r,i)=>(r.projectId??"").localeCompare(i.projectId??"")||r.path.localeCompare(i.path)):s.sort((r,i)=>r.path.localeCompare(i.path)),s},et="Update each project's project.json `owners` field and re-run the command.",tt=e=>["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${et}`,""],pe=e=>{const t=[];for(const o of e){const s=o.owners.join(" "),n=o.channel?` # notify: ${o.channel}`:"";t.push(`${o.path} ${s}${n}`)}return t},ot=(e,t={})=>[...tt(t.regenerationCommand),...pe(e),""].join(`
94
+ `),x={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},nt=(e,t=x,o={})=>{const s=o.regenerationCommand?`# Generated by vis sync codeowners — re-run with: ${o.regenerationCommand}`:"# Generated by `vis sync codeowners` — do not edit by hand.";return[t.begin,s,...pe(e),t.end].join(`
95
+ `)},st=(e,t,o=x)=>{const s=e.indexOf(o.begin),n=e.indexOf(o.end);if(s!==-1&&n!==-1&&n>s){const i=e.slice(0,s),c=n+o.end.length,u=e.slice(c);return`${i}${t}${u}`}const a=e.replace(/\s+$/u,"");return`${a.length===0?"":`${a}
96
+
97
+ `}${t}
98
+ `},rt=["**/CODEOWNERS"],it=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],at=e=>{const t=[];for(const o of e.split(/\r?\n/u)){const s=o.indexOf("#"),n=(s===-1?o:o.slice(0,s)).trim();if(n.length===0)continue;const a=n.split(/\s+/u);if(a.length<2)continue;const[r,...i]=a,c=i.filter(u=>u.length>0);!r||c.length===0||t.push({owners:c,path:r})}return t},ct=(e,t)=>{const o=t.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?o===""?e:`/${o}${e}`:o===""?`/${e}`:`/${o}/${e}`},ut=async(e,t,o)=>{const s=t&&t.length>0?[...t]:[...rt],n=[...it];if(o){const i=o.replace(/^\.\/?/,"").replace(/^\/+/,"");i.length>0&&n.push(i)}const a=await Pe(s,{absolute:!0,cwd:e,ignore:n}),r=[];for(const i of a){let c;try{c=je(i)}catch{continue}const u=oe(i),f=L(e,u);for(const g of at(c))r.push({owners:g.owners,path:ct(g.path,f)})}return r},lt=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)/iu,dt=e=>{if(!e)return;const t=e.match(lt);if(!t?.[1])return;const o=t[1].trim();if(!(o===""||o.includes(" ")))return`@${o.replace(/^@/,"")}`},pt=(e,t)=>{const o=[];for(const[s,n]of Object.entries(e.projects)){if(n.owners&&n.owners.length>0)continue;const a=n.root??s,r=_(t,a,"package.json"),i=G(r);if(!i)continue;const c=Ne(i.maintainers);if(!c||c.length===0)continue;const u=[],f=new Set;for(const g of c){const $=dt(g.url);$&&!f.has($)&&(f.add($),u.push($))}u.length!==0&&o.push({owners:u,path:a===""||a==="."?"/":`/${a}/`,projectId:s})}return o},ft=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(o){if(o.code==="ENOENT")return"";throw o}},F=async(e,{fs:t,isCurrent:o=(i,c)=>i.trim()===c.trim(),logger:s,mode:n,regenerateCommand:a,root:r})=>{const i=[];for(const c of e){const u=_(r,c.path);if(n==="write"){await t.mkdir(oe(u),{recursive:!0}),await t.writeFile(u,c.content),s.info(`Wrote ${c.path}`);continue}o(await ft(t,u),c.content)||(s.error(`${c.path} is out of date. Run \`${a}\` to update it.`),i.push(c.path))}return{stale:i}},ht=["author","bugs","homepage","license","repository","engines"],Q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),D=(e,t)=>{if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(const[o,s]of e.entries())if(!D(s,t[o]))return!1;return!0}if(typeof e=="object"&&typeof t=="object"){const o=Object.keys(e),s=Object.keys(t);if(o.length!==s.length)return!1;for(const n of o)if(!D(e[n],t[n]))return!1;return!0}return!1},ee=e=>e===void 0?e:structuredClone(e),gt=(e,t,o)=>{if(e==="repository"&&Q(t)&&Q(o)){const s={};for(const[n,a]of Object.entries(t))n!=="directory"&&(s[n]=ee(a));return typeof o.directory=="string"&&(s.directory=o.directory),s}return ee(t)},mt=(e,t,o)=>{const s=[];for(const n of o.fields){if(!Object.hasOwn(e,n))continue;const a=e[n],r=t[n],i=gt(n,a,r);D(i,r)||s.push({after:i,before:r,field:n,packageJsonPath:""})}return s},wt=(e,t)=>{for(const o of t)e[o.field]=o.after},fe="Generated by `vis sync codeowners --write-guard`. Do not edit by hand.",bt=e=>{const t=e.replace(/^\.?\/+/u,"").replace(/\/+$/u,"");return t===""||t==="."?"**":`${t}/**`},he=e=>{const t=new Set,o=[];for(const s of[...e].sort((n,a)=>n.name.localeCompare(a.name))){const n=bt(s.root);t.has(n)||(t.add(n),o.push(n))}return o},$t=e=>{const t=he(e),o=t.map(n=>` - "${n}"`).join(`
99
+ `),s=t.map(n=>` ${n}`).join(`
100
+ `);return`# ${fe}
101
+ name: Write Guard
102
+
103
+ on:
104
+ pull_request:
105
+ paths:
106
+ ${o}
107
+
108
+ permissions:
109
+ contents: read
110
+ pull-requests: read
111
+
112
+ jobs:
113
+ write-guard:
114
+ runs-on: ubuntu-latest
115
+ steps:
116
+ - uses: ${_e(E.checkout)}
117
+ with:
118
+ fetch-depth: 0
119
+ - uses: geritol/write-guard@v1
120
+ with:
121
+ codeowners: CODEOWNERS
122
+ paths: |
123
+ ${s}
124
+ `},vt=e=>{const o=he(e).map(s=>` - "${s}/*"`).join(`
125
+ `);return`# ${fe}
126
+ #
127
+ # SOFT GUARD ONLY — this job does NOT block a merge by itself.
128
+ # It verifies the generated CODEOWNERS is in sync and flags that a
129
+ # restricted path changed. GitLab CI cannot portably gate a merge on
130
+ # code-owner *approval* from a job, so REAL ENFORCEMENT REQUIRES the
131
+ # native GitLab setting:
132
+ # Settings -> Repository -> Protected branches ->
133
+ # "Require approval from Code Owners" (GitLab Premium / Ultimate)
134
+ # https://docs.gitlab.com/ee/user/project/codeowners/
135
+ # Without that setting enabled, this job is advisory only.
136
+ write-guard:
137
+ stage: test
138
+ image: node:22-alpine
139
+ rules:
140
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
141
+ changes:
142
+ ${o}
143
+ script:
144
+ - corepack enable
145
+ - pnpm install --frozen-lockfile
146
+ - pnpm vis sync codeowners --check
147
+ - >-
148
+ echo "SOFT GUARD: a restricted path changed. This job does NOT enforce
149
+ code-owner approval. Enable 'Require approval from Code Owners' on the
150
+ protected branch (GitLab Premium/Ultimate) for a real merge gate:
151
+ https://docs.gitlab.com/ee/user/project/codeowners/"
152
+ `},yt=e=>e.length===0?[]:[{content:$t(e),path:".github/workflows/write-guard.yml"},{content:vt(e),path:".gitlab/write-guard.gitlab-ci.yml"}],ge=new Set(["nested-codeowners","package-json-maintainers","project-json"]),B=(e,t,o)=>{const s=new Set,n=[];for(const a of e??[])for(const r of a.split(",")){const i=r.trim();if(i.length===0)continue;if(o&&!o(i))throw new Error(`Unknown codeowners source: "${i}". Known: ${[...ge].join(", ")}.`);const c=i;s.has(c)||(s.add(c),n.push(c))}return n.length>0?n:[...t]},kt=e=>ge.has(e),te=["ci-workflow","codeowners","package-json-fields"],jt=(e,t)=>t.some(o=>Ce(o,e)),Ct=async(e,t,o,s,n)=>{const a=Object.entries(s.projects).filter(([,c])=>c.restricted===!0).map(([c,u])=>({name:c,root:u.root??c})),r=yt(a);if(r.length===0){t.info("No projects flagged `restricted: true` in project.json. Skipping Write Guard.");return}const{stale:i}=await F(r,{fs:e,logger:t,mode:n?"check":"write",regenerateCommand:"vis sync codeowners --write-guard",root:o});if(n){i.length>0?process.exitCode=1:t.info(`Write Guard CI is up to date (${r.length} files, ${a.length} restricted projects).`);return}t.info(`Write Guard CI scoped to ${a.length} restricted project${a.length===1?"":"s"}.`)},Et=async({fs:e,logger:t,options:o,visConfig:s,workspaceRoot:n})=>{const a=n,{workspace:r}=ne(a,s),i=s?.codeowners;o.writeGuard&&await Ct(e,t,a,r,o.check);const c=B(o.from,i?.sources??["project-json"],kt),u=o.regenerationCommand??i?.regenerationCommand,f=o.preserveBlock||i?.preserveBlock===!0,g=i?.blockMarker??x,$=o.nestedIncludes??i?.nestedIncludes,m=o.out??"CODEOWNERS",y=[];if(c.includes("nested-codeowners")){const j=await ut(a,$,m);for(const p of j)y.push({...p,source:"nested"})}if(c.includes("package-json-maintainers")){const j=pt(r,a);for(const p of j)y.push({...p,source:"maintainers"})}const w=c.includes("project-json")?Z(r,i,y):Z({projects:{}},i,y);if(w.length===0){t.info("No `owners` entries found in any source. Nothing to sync.");return}const h=_(a,m);let l="";try{l=await e.readFile(h,"utf8")}catch(j){if(j.code!=="ENOENT")throw j}const b={regenerationCommand:u},d=f?st(l,nt(w,g,b),g):ot(w,b),{stale:k}=await F([{content:d,path:L(a,h)}],{fs:e,logger:t,mode:o.check?"check":"write",regenerateCommand:"vis sync codeowners",root:a});k.length>0?process.exitCode=1:o.check?t.info(`${h} is up to date.`):t.info(`Wrote ${w.length} entries to ${h}`)},St=({logger:e,options:t,visConfig:o,workspaceRoot:s})=>{const n=s,a=o?.editorconfig??!0,r=G(_(n,"package.json"));if(!r){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const i=B(t.fields,ht),c=t.ignorePackageName??[],u=t.check,f=(t.format??"human").toLowerCase(),{quiet:g}=t,$=Ie(n).filter(l=>l!=="."),m=[];let y=0;for(const l of $){const b=_(n,l,"package.json"),d=G(b);if(!d)continue;const k=typeof d.name=="string"?d.name:void 0;if(k!==void 0&&c.length>0&&jt(k,c))continue;y+=1;const j=mt(r,d,{fields:i});j.length!==0&&m.push({filePath:b,packageJsonPath:L(n,b),packageName:k,pkg:d,pkgChanges:j})}if(!u)for(const l of m)wt(l.pkg,l.pkgChanges),Ee(l.filePath,l.pkg,{indent:Se(l.filePath,{useEditorconfig:a}),overwrite:!0});const w=m.flatMap(l=>l.pkgChanges.map(b=>({after:b.after,before:b.before,field:b.field,packageJsonPath:l.packageJsonPath,packageName:l.packageName}))),h={changes:w,fields:i,kind:"package-json-fields",mode:u?"check":"write",totalChanges:w.length,totalPackages:y};if(f==="json")process.stdout.write(`${JSON.stringify(h,null,4)}
153
+ `);else if(w.length===0)e.info(`All ${y} package${y===1?"":"s"} in sync (fields: ${i.join(", ")}).`);else if(u){if(!g)for(const l of w)e.error(`${l.packageJsonPath}: ${l.field} drifts from root`);e.error(`Found ${w.length} field drift${w.length===1?"":"s"} across ${m.length} package${m.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!g)for(const l of m)e.info(`${l.packageJsonPath}: synced ${l.pkgChanges.map(b=>b.field).join(", ")}`);e.info(`Synced ${w.length} field${w.length===1?"":"s"} across ${m.length} package${m.length===1?"":"s"}.`)}u&&w.length>0&&(process.exitCode=1)},Ot=(e,t)=>{try{return ve(U(e),U(t))}catch{return!1}},_t=async({fs:e,logger:t,options:o,visConfig:s,workspaceRoot:n})=>{const a=n,{config:r,workspace:i}=ne(a,s),c=r.ci?.workflow??{},u=o.provider===void 0?void 0:B(o.provider,[]),f=[...u??[],...c.providers??[]].filter(d=>!X(d));if(f.length>0)throw new v(`Unknown CI provider: ${f.map(d=>`"${d}"`).join(", ")}. Known: github, gitlab.`);const{providers:g,reason:$}=await Ze({configured:c.providers,detectRemote:async()=>{const[{detectKnownRemoteProvider:d},{createShellRunner:k}]=await Promise.all([import("./detect.js"),import("./shell-runner.js")]);return d(a,k())},exists:async d=>{try{return await e.stat(_(a,d)),!0}catch{return!1}},flag:u?.filter(X),prompt:o.check||!process.stdout.isTTY||process.env.CI==="true"?void 0:async()=>{const{multiSelectPrompt:d}=await import("./prompts.js");return d("Which CI providers should vis generate a workflow for?",[{label:"GitHub Actions",value:"github"},{label:"GitLab CI",value:"gitlab"}])}});if(g.length===0)throw new v("No CI provider selected. Pass --provider=github,gitlab or set ci.workflow.providers.");t.info(`▸ CI providers: ${g.join(", ")} (${$})`);const m=await Promise.all([...new Set([".",...Object.values(i.projects).map(d=>d.root??".")])].toSorted().map(async d=>({files:await e.readdir(_(a,d)).catch(()=>[]),path:d}))),y=new Set(m.find(({path:d})=>d===".")?.files),{buildFirstOrdered:w,plan:h}=De({cacheDirectory:r.taskRunner?.cacheDirectory,defaultBase:r.defaultBase,ecosystems:Xe(m),packageManager:Oe(a)?.manager,projects:i.projects,providers:g,rootFiles:y,settings:c,targetDefaults:r.tasks,toolchainPins:r.toolchain?.tools,visVersion:Re()});h.ecosystems.length>0&&t.info(`▸ Toolchains: ${h.ecosystems.map(({name:d})=>d).join(", ")}`);const l=g.includes("gitlab")?de(h):[];l.length>0&&t.warn(`GitLab jobs run in a node image without ${l.join(", ")}. Pin go, python, ruby or rust in toolchain.tools so vis installs them, or give .vis-ci-base an image that has them.`),w.length>0&&t.info(`▸ Running build before ${w.join(", ")} (ci.workflow.buildFirst; set it to false if dependsOn already says what needs build).`);const{stale:b}=await F(Ve(h),{fs:e,isCurrent:Ot,logger:t,mode:o.check?"check":"write",regenerateCommand:"vis sync ci-workflow",root:a});if(b.length>0){process.exitCode=1;return}t.info(`CI workflow ${o.check?"is up to date":"generated"}: ${h.layers.map(d=>d.map(({name:k})=>k).join(" + ")).join(" → ")}`)},Bt=async e=>{const t=e.argument[0];if(!t)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${te.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(t!=="ci-workflow"&&e.options.provider!==void 0)throw new v(`--provider only applies to \`vis sync ci-workflow\`, not ${t}.`);if(t==="ci-workflow"){await _t(e);return}if(t==="codeowners"){await Et(e);return}if(t==="package-json-fields"){St(e);return}throw new Error(`Unknown sync kind: "${t}". Known kinds: ${te.join(", ")}.`)};export{Bt as default};
@@ -1,4 +1,4 @@
1
- import{e as C,z as P,U as pe}from"../packem_shared/index-0dnGN3GP.js";import{M as ge,N as le,P as de,L as me,C as ye,R as ke,p as m,q as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-48vkYPJB.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as D}from"../packem_shared/env-CGTN0BFz.js";import{d as we,n as Me}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{p as re}from"../packem_shared/package-version-DteJxz6k.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-DV-XWFct.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"}},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),Y=(r,e)=>{const s=e;for(const o of Ee){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of $e){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
1
+ import{e as C,z as P,U as pe}from"../packem_shared/index-zq6Ehql6.js";import{M as ge,N as le,P as de,L as me,C as ye,R as ke,p as m,q as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-ClmannRw.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CKahNmLy.js";import{U as D}from"../packem_shared/env-NauRSSEC.js";import{d as we,n as Me}from"../packem_shared/pm-runner-CYsiSHYa.js";import{p as re}from"../packem_shared/package-version-BOK3IncQ.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-BtN6Zzwg.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"}},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),Y=(r,e)=>{const s=e;for(const o of Ee){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of $e){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
2
2
  ${Object.entries(e).map(([p,d])=>` '${p}': '${d}'`).join(`
3
3
  `)}
4
4
  `;i=/^overrides:\s*$/m.test(i)||/^overrides:\s*\n/m.test(i)?i.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,n):`${i.trimEnd()}
@@ -1,4 +1,4 @@
1
- import{createRequire as Dt}from"node:module";import{X as xe,F as I,b as ke,q as ut,T as mt}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as V,z as $e,U as Ft}from"../packem_shared/index-0dnGN3GP.js";import{i as Me}from"../packem_shared/index-BjdW45xX.js";import{whichBin as zt}from"#native";import{b as Bt,a as Wt,e as Ht}from"../packem_shared/ai-analysis-BQXQSrpM.js";import{e as Gt,b as Kt,g as qt,s as Yt}from"../packem_shared/ai-cache-_pgEsibl.js";import{l as Fe}from"./ts-loader.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as et,e as Jt,i as tt,f as Xt,k as Zt}from"../packem_shared/env-CGTN0BFz.js";import{L as Qt,h as en,i as tn,K as nn,a as an,f as on,d as rn,b as sn}from"../packem_shared/registry-48vkYPJB.js";import{p as f,c as nt}from"./cli-main.js";import{d as cn,c as ln}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{a as T}from"../packem_shared/index--eV4qIz5.js";import{c as ht,s as ye,g as dn,p as pn,e as fn}from"../packem_shared/index-CypvJE1G.js";import{d as gn}from"../packem_shared/anolilab-text-CAM_E6uK.js";import{S as un,a as M,b as vt,d as be,s as mn,f as hn,g as vn,h as wn}from"../packem_shared/junit-audit-CuJShWCH.js";import{t as yn,b as bn,G as xn}from"../packem_shared/ecosystem-gate-BKRW_EF3.js";import{s as Sn}from"../packem_shared/scan-progress-BEB4T6jo.js";import{r as An,b as Nn,c as it,q as at,a as ot}from"../packem_shared/advisories-DoJg1aO9.js";import{p as yt}from"../packem_shared/package-version-DteJxz6k.js";import{r as Cn,l as En,f as jn,a as Pn}from"../packem_shared/dependency-scan-DheQqeil.js";import{r as Rn}from"../packem_shared/manifests-hpWznbs9.js";import{c as oe,h as On,i as In,l as Ln,m as Dn}from"../packem_shared/multi-eco-lockfiles-DDjCxn43.js";import{l as Tn,p as Mn,O as _n}from"../packem_shared/osv-bloom-DU6avR2k.js";import{f as Bn}from"../packem_shared/osv-C4Vn7VCy.js";let Tt;const Mt=e=>(Tt??=Dt(import.meta.url))(e),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=e=>{if(typeof te<"u"&&te.versions&&te.versions.node){const[t,n]=te.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return te.getBuiltinModule(e)}return Mt(e)},{spawnSync:_t}=Z("node:child_process"),{createInterface:Vt}=Z("node:readline"),{stripVTControlCharacters:Ut}=Z("node:util"),{createHash:kn}=Z("node:crypto"),{relative:wt,join:$n}=Z("node:path"),{readFileSync:Vn,writeFileSync:Fn,renameSync:zn,unlinkSync:Un}=Z("node:fs"),rt=(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const n=[];for(const i of Qt(e,t))n.push(i.path);return n},Se=e=>`${e.packageName}@${e.packageVersion}:${e.vulnerability.id}`,Wn=e=>e==null||e===!0||e===""||e==="true"||e.toString().toLowerCase()==="all",Hn=(e,t)=>{if(Wn(t))return e;const n=String(t).trim();if(/^\d+$/.test(n)){const a=Number.parseInt(n,10)-1,o=e[a];return o?[o]:[]}const i=n.toLowerCase();return e.filter(a=>{const{aliases:o,id:r}=a.vulnerability;return r.toLowerCase()===i||(o??[]).some(c=>c.toLowerCase()===i)})},Gn=e=>{const{packageName:t,packageVersion:n,vulnerability:i}=e,a=(i.aliases??[]).join(", ")||"none",o=(i.fixedVersions??[]).join(", ")||"no fixed version published";return`You are a security engineer. Explain this dependency vulnerability for a developer triaging it.
1
+ import{createRequire as Dt}from"node:module";import{X as xe,F as I,b as ke,q as ut,T as mt}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as V,z as $e,U as Ft}from"../packem_shared/index-zq6Ehql6.js";import{i as Me}from"../packem_shared/index-BjdW45xX.js";import{whichBin as zt}from"#native";import{b as Bt,a as Wt,e as Ht}from"../packem_shared/ai-analysis-DHlzow2O.js";import{e as Gt,b as Kt,g as qt,s as Yt}from"../packem_shared/ai-cache-D-BSLcuJ.js";import{l as Fe}from"./ts-loader.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CKahNmLy.js";import{U as et,e as Jt,i as tt,f as Xt,k as Zt}from"../packem_shared/env-NauRSSEC.js";import{L as Qt,h as en,i as tn,K as nn,a as an,f as on,d as rn,b as sn}from"../packem_shared/registry-ClmannRw.js";import{p as f,c as nt}from"./cli-main.js";import{d as cn,c as ln}from"../packem_shared/pm-runner-CYsiSHYa.js";import{a as T}from"../packem_shared/index--eV4qIz5.js";import{c as ht,s as ye,g as dn,p as pn,e as fn}from"../packem_shared/index-BCEhCrLl.js";import{d as gn}from"../packem_shared/anolilab-text-CAM_E6uK.js";import{S as un,a as M,b as vt,d as be,s as mn,f as hn,g as vn,h as wn}from"../packem_shared/junit-audit-CuJShWCH.js";import{t as yn,b as bn,G as xn}from"../packem_shared/ecosystem-gate-DEnubRcS.js";import{s as Sn}from"../packem_shared/scan-progress-Dws7Gif1.js";import{r as An,b as Nn,c as it,q as at,a as ot}from"../packem_shared/advisories-CyXUdibZ.js";import{p as yt}from"../packem_shared/package-version-BOK3IncQ.js";import{r as Cn,l as En,f as jn,a as Pn}from"../packem_shared/dependency-scan-CyByCwef.js";import{r as Rn}from"../packem_shared/manifests-BEGTH1ZG.js";import{c as oe,h as On,i as In,l as Ln,m as Dn}from"../packem_shared/multi-eco-lockfiles-SATPXx6-.js";import{l as Tn,p as Mn,O as _n}from"../packem_shared/osv-bloom-DU6avR2k.js";import{f as Bn}from"../packem_shared/osv-dvIA_vX3.js";let Tt;const Mt=e=>(Tt??=Dt(import.meta.url))(e),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=e=>{if(typeof te<"u"&&te.versions&&te.versions.node){const[t,n]=te.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return te.getBuiltinModule(e)}return Mt(e)},{spawnSync:_t}=Z("node:child_process"),{createInterface:Vt}=Z("node:readline"),{stripVTControlCharacters:Ut}=Z("node:util"),{createHash:kn}=Z("node:crypto"),{relative:wt,join:$n}=Z("node:path"),{readFileSync:Vn,writeFileSync:Fn,renameSync:zn,unlinkSync:Un}=Z("node:fs"),rt=(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const n=[];for(const i of Qt(e,t))n.push(i.path);return n},Se=e=>`${e.packageName}@${e.packageVersion}:${e.vulnerability.id}`,Wn=e=>e==null||e===!0||e===""||e==="true"||e.toString().toLowerCase()==="all",Hn=(e,t)=>{if(Wn(t))return e;const n=String(t).trim();if(/^\d+$/.test(n)){const a=Number.parseInt(n,10)-1,o=e[a];return o?[o]:[]}const i=n.toLowerCase();return e.filter(a=>{const{aliases:o,id:r}=a.vulnerability;return r.toLowerCase()===i||(o??[]).some(c=>c.toLowerCase()===i)})},Gn=e=>{const{packageName:t,packageVersion:n,vulnerability:i}=e,a=(i.aliases??[]).join(", ")||"none",o=(i.fixedVersions??[]).join(", ")||"no fixed version published";return`You are a security engineer. Explain this dependency vulnerability for a developer triaging it.
2
2
 
3
3
  Package: ${t}@${n}
4
4
  Advisory: ${i.id} (aliases: ${a})