@visulima/vis 1.0.0-alpha.3 → 1.0.0-alpha.30

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 (172) hide show
  1. package/CHANGELOG.md +1117 -24
  2. package/LICENSE.md +11958 -0
  3. package/README.md +344 -20
  4. package/dashboard/dist/index.html +152 -0
  5. package/dist/bin.js +1 -146
  6. package/dist/binx.js +3 -0
  7. package/dist/config/index.d.ts +3154 -0
  8. package/dist/config/index.js +1 -0
  9. package/dist/generate/index.d.ts +157 -0
  10. package/dist/generate/index.js +1 -0
  11. package/dist/packem_chunks/bin.js +1415 -0
  12. package/dist/packem_chunks/bloom-status.js +2 -0
  13. package/dist/packem_chunks/bloom-sync.js +2 -0
  14. package/dist/packem_chunks/cache-attestation.js +1 -0
  15. package/dist/packem_chunks/config.js +19 -0
  16. package/dist/packem_chunks/devtools.js +82 -0
  17. package/dist/packem_chunks/doctor-probe.js +2 -0
  18. package/dist/packem_chunks/fix.js +11 -0
  19. package/dist/packem_chunks/handler.js +1 -0
  20. package/dist/packem_chunks/handler10.js +1 -0
  21. package/dist/packem_chunks/handler11.js +5 -0
  22. package/dist/packem_chunks/handler12.js +1 -0
  23. package/dist/packem_chunks/handler13.js +27 -0
  24. package/dist/packem_chunks/handler14.js +5 -0
  25. package/dist/packem_chunks/handler15.js +1 -0
  26. package/dist/packem_chunks/handler16.js +1 -0
  27. package/dist/packem_chunks/handler17.js +1 -0
  28. package/dist/packem_chunks/handler18.js +1 -0
  29. package/dist/packem_chunks/handler19.js +1 -0
  30. package/dist/packem_chunks/handler2.js +4 -0
  31. package/dist/packem_chunks/handler20.js +5 -0
  32. package/dist/packem_chunks/handler21.js +2 -0
  33. package/dist/packem_chunks/handler22.js +2 -0
  34. package/dist/packem_chunks/handler23.js +1 -0
  35. package/dist/packem_chunks/handler24.js +1 -0
  36. package/dist/packem_chunks/handler25.js +5 -0
  37. package/dist/packem_chunks/handler26.js +1 -0
  38. package/dist/packem_chunks/handler27.js +3 -0
  39. package/dist/packem_chunks/handler28.js +1 -0
  40. package/dist/packem_chunks/handler29.js +7 -0
  41. package/dist/packem_chunks/handler3.js +4 -0
  42. package/dist/packem_chunks/handler30.js +33 -0
  43. package/dist/packem_chunks/handler31.js +3 -0
  44. package/dist/packem_chunks/handler32.js +8 -0
  45. package/dist/packem_chunks/handler33.js +1 -0
  46. package/dist/packem_chunks/handler34.js +5 -0
  47. package/dist/packem_chunks/handler35.js +11 -0
  48. package/dist/packem_chunks/handler36.js +3 -0
  49. package/dist/packem_chunks/handler37.js +22 -0
  50. package/dist/packem_chunks/handler38.js +61 -0
  51. package/dist/packem_chunks/handler39.js +3 -0
  52. package/dist/packem_chunks/handler4.js +6 -0
  53. package/dist/packem_chunks/handler40.js +6 -0
  54. package/dist/packem_chunks/handler41.js +24 -0
  55. package/dist/packem_chunks/handler42.js +153 -0
  56. package/dist/packem_chunks/handler43.js +25 -0
  57. package/dist/packem_chunks/handler44.js +10 -0
  58. package/dist/packem_chunks/handler45.js +708 -0
  59. package/dist/packem_chunks/handler46.js +24 -0
  60. package/dist/packem_chunks/handler47.js +322 -0
  61. package/dist/packem_chunks/handler48.js +48 -0
  62. package/dist/packem_chunks/handler49.js +3 -0
  63. package/dist/packem_chunks/handler5.js +8 -0
  64. package/dist/packem_chunks/handler50.js +27 -0
  65. package/dist/packem_chunks/handler51.js +195 -0
  66. package/dist/packem_chunks/handler52.js +34 -0
  67. package/dist/packem_chunks/handler6.js +1 -0
  68. package/dist/packem_chunks/handler7.js +1 -0
  69. package/dist/packem_chunks/handler8.js +1 -0
  70. package/dist/packem_chunks/handler9.js +1 -0
  71. package/dist/packem_chunks/heal-accept.js +10 -0
  72. package/dist/packem_chunks/heal.js +14 -0
  73. package/dist/packem_chunks/help-command.js +8 -0
  74. package/dist/packem_chunks/index.js +7 -0
  75. package/dist/packem_chunks/keys-refresh.js +4 -0
  76. package/dist/packem_chunks/list.js +3 -0
  77. package/dist/packem_chunks/loader.js +4 -0
  78. package/dist/packem_chunks/loader2.js +1 -0
  79. package/dist/packem_chunks/prune.js +3 -0
  80. package/dist/packem_chunks/run.js +1 -0
  81. package/dist/packem_chunks/status.js +2 -0
  82. package/dist/packem_chunks/sync.js +2 -0
  83. package/dist/packem_chunks/sync2.js +2 -0
  84. package/dist/packem_chunks/tar.js +3 -0
  85. package/dist/packem_chunks/tripwire.js +2 -0
  86. package/dist/packem_chunks/verify-lockfile.js +2 -0
  87. package/dist/packem_shared/Table-DoSoazT6-DwnyTUsA.js +12 -0
  88. package/dist/packem_shared/_commonjsHelpers-CLblCigl.js +1 -0
  89. package/dist/packem_shared/advisories-BxXiKFbL.js +1 -0
  90. package/dist/packem_shared/affected-shas-BdnlfiV1.js +1 -0
  91. package/dist/packem_shared/ai-analysis-KP8b5lc0.js +68 -0
  92. package/dist/packem_shared/ai-fix-BkPUHA0z.js +43 -0
  93. package/dist/packem_shared/anolilab-text-CAM_E6uK.js +13 -0
  94. package/dist/packem_shared/applyDefaults-BogleaFi.js +1 -0
  95. package/dist/packem_shared/build-scripts-DE6U8jVq.js +1 -0
  96. package/dist/packem_shared/cyclonedx-BpGVHqSW.js +4 -0
  97. package/dist/packem_shared/definePlugin-CWm4Dv_t.js +1 -0
  98. package/dist/packem_shared/dependency-scan-BUbOcMwX.js +1 -0
  99. package/dist/packem_shared/docker-CTE3s4LW.js +60 -0
  100. package/dist/packem_shared/failure-log-34Wl3npC.js +2 -0
  101. package/dist/packem_shared/giget-CcEy_Elm.js +2 -0
  102. package/dist/packem_shared/glob-D_7bct6p-D8itOHsr.js +1 -0
  103. package/dist/packem_shared/index-D1xC1Y_R.js +1 -0
  104. package/dist/packem_shared/index-DH-5hsrC.js +1 -0
  105. package/dist/packem_shared/index-hoWfZmNo.js +30 -0
  106. package/dist/packem_shared/license-zZU7aavK.js +1 -0
  107. package/dist/packem_shared/lifecycle-CXaqPGAQ.js +2 -0
  108. package/dist/packem_shared/lockfile-CrT86D6d.js +1 -0
  109. package/dist/packem_shared/lockfile-Cu2BH6bl.js +1 -0
  110. package/dist/packem_shared/manifests-BzWpKW8F.js +1 -0
  111. package/dist/packem_shared/min-release-age-BPVXwPUg.js +34 -0
  112. package/dist/packem_shared/native-config-sync-BRZZetn3.js +21 -0
  113. package/dist/packem_shared/osv-bloom-DSZcHLsM.js +2 -0
  114. package/dist/packem_shared/otelPlugin-CJR2T_lk.js +1 -0
  115. package/dist/packem_shared/peer-warnings-EvSJ18gE.js +1 -0
  116. package/dist/packem_shared/pm-runner-DmKT2FqF.js +1 -0
  117. package/dist/packem_shared/provenance-DkCA8BrN.js +1 -0
  118. package/dist/packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js +1 -0
  119. package/dist/packem_shared/registry-keys-Mixm4eAY.js +1 -0
  120. package/dist/packem_shared/resolve-explicit-D5E72FfN.js +5 -0
  121. package/dist/packem_shared/runtime-check-CilFOqUU.js +1 -0
  122. package/dist/packem_shared/s1ngularity-Qxc6tRRI.js +1 -0
  123. package/dist/packem_shared/scan-progress-DVtCtI2z.js +2 -0
  124. package/dist/packem_shared/selectors-DkgYFzdq.js +3 -0
  125. package/dist/packem_shared/signatures-byuFrtAH.js +2 -0
  126. package/dist/packem_shared/spinner-C8xs6QZv.js +1 -0
  127. package/dist/packem_shared/spinners-f91Rbo99-Bjf3NcO0.js +1 -0
  128. package/dist/packem_shared/symbols-CQmER5MT.js +1 -0
  129. package/dist/packem_shared/tabs-xZkm6Y_J.js +1 -0
  130. package/dist/packem_shared/toolchain-DoG6b_G_.js +5 -0
  131. package/dist/packem_shared/typosquats-BiDxQj7R.js +1 -0
  132. package/dist/packem_shared/use-measured-height-Lea6TCVD.js +1 -0
  133. package/dist/packem_shared/utils-DrNg0XTR.js +1 -0
  134. package/dist/packem_shared/verify-cLcZwKqe.js +1 -0
  135. package/dist/packem_shared/vis-update-app-BCKzlqj8.js +1 -0
  136. package/dist/packem_shared/watch-DEL0yol9.js +1 -0
  137. package/dist/packem_shared/watch-loop-C31Ar7BX.js +11 -0
  138. package/index.d.ts +436 -0
  139. package/index.js +613 -0
  140. package/package.json +71 -26
  141. package/schemas/project.schema.json +991 -0
  142. package/schemas/vis-config.schema.json +4958 -0
  143. package/skills/vis/SKILL.md +96 -0
  144. package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
  145. package/templates/buildkite-ci/template.yml +20 -0
  146. package/dist/ai-analysis.d.ts +0 -40
  147. package/dist/ai-cache.d.ts +0 -21
  148. package/dist/bin.d.ts +0 -1
  149. package/dist/catalog.d.ts +0 -110
  150. package/dist/commands/affected.d.ts +0 -3
  151. package/dist/commands/ai.d.ts +0 -3
  152. package/dist/commands/analyze.d.ts +0 -3
  153. package/dist/commands/check.d.ts +0 -3
  154. package/dist/commands/graph.d.ts +0 -3
  155. package/dist/commands/hook/constants.d.ts +0 -8
  156. package/dist/commands/hook/index.d.ts +0 -3
  157. package/dist/commands/hook/install.d.ts +0 -7
  158. package/dist/commands/hook/migrate.d.ts +0 -27
  159. package/dist/commands/hook/uninstall.d.ts +0 -3
  160. package/dist/commands/migrate/constants.d.ts +0 -12
  161. package/dist/commands/migrate/deps.d.ts +0 -32
  162. package/dist/commands/migrate/index.d.ts +0 -3
  163. package/dist/commands/migrate/json.d.ts +0 -20
  164. package/dist/commands/migrate/lint-staged.d.ts +0 -62
  165. package/dist/commands/migrate/types.d.ts +0 -20
  166. package/dist/commands/run.d.ts +0 -3
  167. package/dist/commands/staged.d.ts +0 -3
  168. package/dist/commands/update.d.ts +0 -3
  169. package/dist/config.d.ts +0 -40
  170. package/dist/config.js +0 -1
  171. package/dist/package-manager.d.ts +0 -23
  172. package/dist/workspace.d.ts +0 -58
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var m=(n,o)=>u(n,"name",{value:o,configurable:!0});import{r as h}from"../packem_shared/affected-shas-BdnlfiV1.js";import{r as w}from"../packem_shared/toolchain-DoG6b_G_.js";var $=Object.defineProperty,a=m((n,o)=>$(n,"name",{value:o,configurable:!0}),"t");const S=a(async({argument:n,logger:o,options:r,runtime:l,visConfig:f,workspaceRoot:s})=>{const p=n[0];if(!p)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const c=p.split(",").map(e=>e.trim()).filter(Boolean);if(c.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!s)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const t=h({defaultBase:f?.defaultBase,workspaceRoot:s}),d=r.base??t.base,g=r.head??t.head;!r.base&&!r.head&&o.info(`▸ Resolved affected refs from ${t.provider} (${t.notes.join("; ")})`),r.skipToolchain||o.info("▸ Toolchain pre-flight"),await w(s,f?.toolchain,{error:a(e=>{o.error(e)},"error"),info:a(e=>{o.info(e)},"info"),warn:a(e=>{o.warn(e)},"warn")},!!r.skipToolchain),r.install===!1?o.info("▸ Skipping install (--no-install)"):(o.info("▸ Installing dependencies"),await l.runCommand("install",{argv:["--ci","--frozen-lockfile"]}));for(const e of c){o.info(`▸ Running affected ${e} (base=${d}, head=${g})`);const i=[e,`--base=${d}`,`--head=${g}`,`--upstream=${String(r.upstream??"none")}`,`--downstream=${String(r.downstream??"deep")}`];r.parallel!==void 0&&i.push(`--parallel=${String(r.parallel)}`),r.partition&&i.push(`--partition=${String(r.partition)}`),r.query&&i.push(`--query=${String(r.query)}`),await l.runCommand("affected",{argv:i})}o.info("▸ CI pipeline complete")},"execute");export{S as default};
@@ -0,0 +1 @@
1
+ var m=Object.defineProperty;var d=(s,o)=>m(s,"name",{value:o,configurable:!0});import{createRequire as p}from"node:module";import{M as a,l as k}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{cleanWorkspace as b}from"#native";import{p as c}from"./bin.js";import{f as $}from"../packem_shared/utils-DrNg0XTR.js";const g=p(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=d(s=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[o,n]=f.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return f.getBuiltinModule(s)}return g(s)},"__cjs_getBuiltinModule"),{readdirSync:v,lstatSync:y,unlinkSync:_}=h("node:fs");var R=Object.defineProperty,u=d((s,o)=>R(s,"name",{value:o,configurable:!0}),"f");const j=u(s=>{const o=[],n=[s];for(;n.length>0;){const t=n.pop();let i;try{i=v(t)}catch{continue}for(const r of i){const e=a(t,r);try{const l=y(e);if(l.isSymbolicLink()||!l.isDirectory())continue}catch{continue}r==="node_modules"?o.push(e):r!==".git"&&r!==".hg"&&n.push(e)}}return o},"findNodeModulesDirectories"),M=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],x=u((s,o,n)=>{let t=0,i=!1;for(const r of M){const e=a(s,r);if(k(e)){if(o){n.info(` ${e}`),t++;continue}try{_(e),c.success(`Removed ${e}`),t++}catch(l){c.error(`${e}: ${$(l)}`),i=!0}}}return{hadError:i,removed:t}},"removeLockfiles"),C=u(async({logger:s,options:o,workspaceRoot:n})=>{const t=n??process.cwd(),i=o.lockfile||!1;if(o.dryRun){const e=j(t);if(e.length>0){c.info("Would remove:");for(const l of e)s.info(` ${l}`)}else c.info("No node_modules directories found.");i&&x(t,!0,s);return}const r=b(t,i);for(const e of r.removed)c.success(`Removed ${e}`);for(const e of r.lockfilesRemoved)c.success(`Removed ${e}`);for(const e of r.errors)c.error(e);r.removed.length===0&&r.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${r.removed.length} node_modules director${r.removed.length===1?"y":"ies"}`),r.errors.length>0&&(process.exitCode=1)},"execute");export{C as default};
@@ -0,0 +1 @@
1
+ var i=Object.defineProperty;var s=(e,o)=>i(e,"name",{value:o,configurable:!0});import{R as l,M as p}from"../packem_shared/pm-runner-DmKT2FqF.js";var f=Object.defineProperty,d=s((e,o)=>f(e,"name",{value:o,configurable:!0}),"n");const u=d(async({logger:e,options:o,visConfig:a,workspaceRoot:r})=>{const c=r??process.cwd(),t=l(c,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),n=p(t,o.check||!1,c,e);n!==0&&(process.exitCode=n)},"execute");export{u as default};
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var i=(e,s)=>d(e,"name",{value:s,configurable:!0});import{R as k,B as u}from"../packem_shared/pm-runner-DmKT2FqF.js";var v=Object.defineProperty,x=i((e,s)=>v(e,"name",{value:s,configurable:!0}),"n");const w=x(async({argument:e,logger:s,options:a,visConfig:r,workspaceRoot:l})=>{const o=e;if(!o||o.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[t,...g]=o,n=l??process.cwd(),p=k(n,{configBackend:r?.install?.backend,configCorepack:r?.install?.corepack}),f=a.package?Array.isArray(a.package)?a.package:[a.package]:[],c=u(p,{additionalPackages:f,args:g,package:t,shellMode:a.shellMode||!1,silent:a.silent||!1},n,s,{offline:a.offline||!1});c!==0&&(process.exitCode=c)},"execute");export{w as default};
@@ -0,0 +1,10 @@
1
+ var H=Object.defineProperty;var I=(e,t)=>H(e,"name",{value:t,configurable:!0});import{createRequire as U}from"node:module";import{C as O,z as F}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{d as D,P as K,R as S,w as j,p as V}from"./heal.js";import{A as q,P as Y}from"../packem_shared/pm-runner-DmKT2FqF.js";import{p as a}from"./bin.js";const P=U(import.meta.url),T=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=I(e=>{if(typeof T<"u"&&T.versions&&T.versions.node){const[t,o]=T.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return T.getBuiltinModule(e)}return P(e)},"__cjs_getBuiltinModule"),{readFile:B}=A("node:fs/promises"),{createInterface:M}=A("node:readline");var J=Object.defineProperty,k=I((e,t)=>J(e,"name",{value:t,configurable:!0}),"o");const z=k(()=>!!process.stdout.isTTY&&process.env.CI!=="true","isInteractive"),W=k(e=>new Promise(t=>{const o=M({input:process.stdin,output:process.stderr});o.question(`${e} (Y/n) `,i=>{o.close();const s=i.trim().toLowerCase();t(s===""||s==="y"||s==="yes")})}),"defaultPrompt"),X=k((e,t)=>{const o=q(t),i=Y(o,{exact:!1,filter:[],global:!1,optional:!1,packages:[e],peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},t,console);return Promise.resolve({exitCode:i})},"defaultRunInstall"),y=k(e=>`pnpm add ${e}`,"installCommandFor"),Q=k(e=>e==="@gitbeaker/rest"?import("@gitbeaker/rest"):import("@octokit/rest"),"defaultImport"),L=k(async(e,t={})=>{const o=t.interactive??z(),i=t.prompt??W,s=t.runInstall??X,l=t.importImpl??Q,d=t.workspaceRoot??process.cwd();try{return await l(e)}catch(n){const{code:p}=n;if(p!=="ERR_MODULE_NOT_FOUND"&&p!=="MODULE_NOT_FOUND")throw n}if(!o)throw new Error(`${e} is not installed. \`vis ai heal accept\` needs it to talk to the host. Install it in your repo first:
2
+ ${y(e)}`);if(!await i(`${e} isn't installed. Install it now?`))throw new Error(`${e} install declined. Re-run \`vis ai heal accept\` after installing manually:
3
+ ${y(e)}`);const r=await s(e,d);if(r.exitCode!==0)throw new Error(`Install of ${e} failed (exit ${String(r.exitCode)}). Install manually and retry:
4
+ ${y(e)}`);return await l(e)},"loadOptionalSdk");var Z=Object.defineProperty,_=I((e,t)=>Z(e,"name",{value:t,configurable:!0}),"s");const ee=_(e=>{const t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`Expected GITHUB_REPOSITORY in "owner/repo" form, got: ${e}`);return{owner:e.slice(0,t),repo:e.slice(t+1)}},"splitGithubRepo"),te=_(async(e,t)=>{if(t.githubClient)return t.githubClient;const o=(await(t.loadSdk??L)("@octokit/rest")).Octokit;if(!o)throw new TypeError("Loaded `@octokit/rest` but no `Octokit` export was found. Reinstall the package or pin to a supported major.");return new o({auth:e})},"loadGithubClient"),oe=_(async(e,t,o)=>{if(o.gitlabClient)return o.gitlabClient;const i=(await(o.loadSdk??L)("@gitbeaker/rest")).Gitlab;if(!i)throw new TypeError("Loaded `@gitbeaker/rest` but no `Gitlab` export was found. Reinstall the package or pin to a supported major.");return new i({host:t,token:e})},"loadGitlabClient"),re=_(e=>e.replace(/\/api\/v\d+\/?$/,""),"apiBaseToHost"),ie=_(async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(w=>B(w,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitHub: GITHUB_REPOSITORY (owner/repo) is not set.");if(!o.token)throw new Error("Cannot commit on GitHub: GITHUB_TOKEN is not set. Grant the workflow `contents: write` and pass the token through.");const{owner:r,repo:n}=ee(o.repo),p=await te(o.token,e),u=(await p.rest.git.getRef({owner:r,ref:`heads/${t}`,repo:n})).data.object.sha,h=(await p.rest.git.getCommit({commit_sha:u,owner:r,repo:n})).data.tree.sha,m=await Promise.all(i.map(async w=>{const v=O(l,w),E=await d(v),C=await p.rest.git.createBlob({content:Buffer.from(E,"utf8").toString("base64"),encoding:"base64",owner:r,repo:n});return{mode:"100644",path:w,sha:C.data.sha,type:"blob"}})),f=await p.rest.git.createTree({base_tree:h,owner:r,repo:n,tree:m}),b=await p.rest.git.createCommit({message:s,owner:r,parents:[u],repo:n,tree:f.data.sha});return await p.rest.git.updateRef({owner:r,ref:`heads/${t}`,repo:n,sha:b.data.sha}),{sha:b.data.sha,url:b.data.html_url}},"commitToGithub"),ae=_(async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(m=>B(m,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitLab: CI_PROJECT_ID / CI_PROJECT_PATH is not set.");if(!o.token)throw new Error("Cannot commit on GitLab: no token. CI_JOB_TOKEN cannot push commits — set GITLAB_TOKEN to a PAT/project-token with `api` scope.");if(!o.apiBaseUrl)throw new Error("Cannot commit on GitLab: CI_API_V4_URL is not set.");const r=re(o.apiBaseUrl),n=await oe(o.token,r,e),p=await Promise.all(i.map(async m=>{const f=O(l,m);return{action:"update",content:await d(f),filePath:m}})),u=await n.Commits.create(o.repo,t,s,p),h=u.id??u.sha;if(!h)throw new Error("GitLab Commits.create returned no commit ID — cannot reference the new commit.");return{sha:h,url:u.web_url??u.webUrl}},"commitToGitlab"),ne=_(async e=>{if(e.files.length===0)throw new Error("Cannot commit: no files to include.");if(e.ciContext.provider==="github-actions")return await ie(e);if(e.ciContext.provider==="gitlab-ci")return await ae(e);throw new Error(`Cannot commit: unsupported CI provider \`${e.ciContext.provider}\`. Run \`vis ai heal accept\` from a recognised CI environment.`)},"commitFiles");var se=Object.defineProperty,g=I((e,t)=>se(e,"name",{value:t,configurable:!0}),"u");const G="/vis heal accept",ce=g(async e=>{if(!e)return;let t;try{t=await B(e,"utf8")}catch{return}const o=JSON.parse(t),i=o.comment?.body??"",s=o.comment?.user?.login??"",l=o.pull_request?.head?.repo?.full_name,d=o.pull_request?.base?.repo?.full_name??o.repository?.full_name,r=l!==void 0&&d!==void 0&&l!==d;return{actor:s,body:i,headRef:o.pull_request?.head?.ref,isFork:r}},"loadGithubTrigger"),le=g(e=>{const t=e.VIS_HEAL_TRIGGER_BODY,o=e.VIS_HEAL_TRIGGER_ACTOR;if(!(!t||!o))return{actor:o,body:t,headRef:e.VIS_HEAL_HEAD_REF,isFork:!1}},"loadGitlabTrigger"),de=g(e=>{const t=e.BUILDKITE_UNBLOCKER_EMAIL??e.BUILDKITE_UNBLOCKER;if(t)return{actor:t,body:G,headRef:e.BUILDKITE_BRANCH,isFork:!1}},"loadBuildkiteTrigger"),pe=g(async(e,t)=>{if(e.provider==="github-actions")return await ce(t.GITHUB_EVENT_PATH);if(e.provider==="gitlab-ci")return le(t);if(e.provider==="buildkite")return de(t)},"loadTrigger"),ue=g((e,t)=>{const o=t.BUILDKITE_REPO;if(!o)return;const i=/(?:^|@|\/\/)github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(o);if(i&&t.GITHUB_TOKEN)return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"github-actions",repo:`${i[1]}/${i[2]}`,sha:e.sha,token:t.GITHUB_TOKEN};const s=/\/\/([^/]*gitlab[^/]*)\/([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),l=s?null:/@([^/:]*gitlab[^/:]*):([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),d=s??l;if(d&&t.GITLAB_TOKEN){const r=d[1];return{apiBaseUrl:t.CI_API_V4_URL??`https://${r}/api/v4`,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"gitlab-ci",repo:`${d[2]}/${d[3]}`,sha:e.sha,token:t.GITLAB_TOKEN}}},"deriveBuildkiteCommitContext"),me=g(async e=>{const t=e.fetchImpl??globalThis.fetch,o=`${(e.apiBaseUrl??"https://api.github.com").replace(/\/+$/,"")}/repos/${e.repo}/pulls/${String(e.prNumber)}`;try{const i=await t(o,{headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${e.token}`,"X-GitHub-Api-Version":"2022-11-28"}});return i.ok?(await i.json()).head?.ref:void 0}catch{return}},"fetchGithubHeadRef"),fe=g((e,t,o,i)=>{const s=t.map(l=>`- \`${l}\``).join(`
5
+ `);return["## vis ai heal — committed","",`Accepted by @${i}.`,"",`Failing task: \`${o}\``,e.url?`Commit: [\`${e.sha.slice(0,7)}\`](${e.url})`:`Commit: \`${e.sha.slice(0,7)}\``,"","### Files changed",s,"","_Re-run the failing job to confirm the fix landed._"].join(`
6
+ `)},"summariseDetail"),he=g(async(e,t={})=>{const{logger:o,visConfig:i,workspaceRoot:s}=e,l=s??process.cwd(),d=t.env??process.env,r=await(t.detectCi??(()=>D(d)))();if(r.provider==="unknown"){a.error("`vis ai heal accept` must run inside a recognised CI provider (GitHub Actions, GitLab CI, or Buildkite)."),process.exitCode=1;return}const n=await pe(r,d);if(!n){const c=r.provider==="github-actions"?"No issue_comment payload found. Trigger this command from a workflow listening for `issue_comment.created`.":r.provider==="gitlab-ci"?"No GitLab trigger payload found. Set VIS_HEAL_TRIGGER_BODY, VIS_HEAL_TRIGGER_ACTOR, and VIS_HEAL_HEAD_REF in the bridge that re-emits note hooks as pipeline runs.":"No Buildkite unblock signal found. Wire this command to run after a manually-unblocked block step so BUILDKITE_UNBLOCKER_EMAIL is set.";a.error(c),process.exitCode=1;return}if(r.provider!=="buildkite"&&!n.body.includes(G)){a.notice(`Trigger comment does not contain \`${G}\`; nothing to do.`);return}const p=i?.ai?.heal?.allowedActors??[];if(p.length===0){a.error("`ai.heal.allowedActors` is empty. Configure the allow-list in `vis.config.*` before enabling auto-commit."),process.exitCode=1;return}if(!n.actor||!p.includes(n.actor)){const c=r.provider==="buildkite"?"Buildkite entries are emails (BUILDKITE_UNBLOCKER_EMAIL) or Buildkite usernames (BUILDKITE_UNBLOCKER), not the upstream GitHub/GitLab username.":r.provider==="gitlab-ci"?"GitLab entries are platform usernames (without the leading `@`).":"GitHub entries are platform usernames (without the leading `@`).";a.error(`Actor \`${n.actor||"(unknown)"}\` is not in \`ai.heal.allowedActors\`. Refusing to commit. ${c}`),process.exitCode=1;return}if(n.isFork){a.error("Refusing to accept: the change is from a forked repository. The CI token does not have write access to the fork."),process.exitCode=1;return}let u=n.headRef;if(!u&&r.provider==="github-actions"&&r.prNumber!==void 0&&r.repo&&r.token&&(u=await me({fetchImpl:t.fetchImpl,prNumber:r.prNumber,repo:r.repo,token:r.token})),!u){a.error("Could not resolve the PR / MR head branch. Ensure the trigger payload includes head.ref or set VIS_HEAL_HEAD_REF."),process.exitCode=1;return}a.info(`Accepting fix on \`${u}\` for actor \`${n.actor}\`.`);const h=await K(l,e.options.run);if(h.outcome==="no-failed-task"){a.error("No failed tasks found in the run summary. The accept command should run on the same workspace as the original failure."),process.exitCode=1;return}if(h.outcome==="missing-metadata"){a.error(`Failed task ${h.failedTask.taskId} is missing project/target metadata; cannot validate the fix.`),process.exitCode=1;return}if(h.outcome==="no-failure-context"){a.error(`No failure log or run summary found for ${h.failedTask.taskId}.`),process.exitCode=1;return}const m=h,f=await S(e,m);if(f.outcome==="no-proposal"){a.error("AI fix proposal failed; cannot commit."),process.exitCode=1;return}if(f.outcome==="cannot-fix"){a.warn(`AI declined to fix: ${f.detail??"(no reason)"}. Nothing to commit.`),process.exitCode=1;return}if(f.outcome==="empty-patches"){a.warn("AI returned an empty patch set. Nothing to commit."),process.exitCode=1;return}if(f.outcome==="no-patches-applied"){a.error("Patches could not be applied to the workspace. Refusing to commit."),process.exitCode=1;return}a.info(`Re-running ${m.failedTask.taskId} to validate the fix before committing...`);const b=await j(e,m,{validate:t.validate});if(b.exitCode!==0){a.error(`Validation failed (exit ${String(b.exitCode)}). Refusing to commit.`),b.stderr.trim().length>0&&(o.info("--- validation stderr (tail) ---"),o.info(b.stderr.split(`
7
+ `).slice(-20).join(`
8
+ `))),process.exitCode=1;return}a.success("Validation passed. Committing.");const w=(f.applyResults??[]).filter(c=>c.status==="applied").map(c=>{const $=c.absolutePath??c.patch.file,x=F(l,$);return x===""||x.startsWith("..")?c.patch.file:x});if(w.length===0){a.error("No applied files to commit. Aborting."),process.exitCode=1;return}const v=[`fix: vis ai heal accepted by @${n.actor}`,"",`Failing task: ${m.failedTask.taskId}`,f.proposal?.explanation?`
9
+ ${f.proposal.explanation}`:"","","Auto-committed by `vis ai heal accept`."].join(`
10
+ `);let E=r;if(r.provider==="buildkite"){const c=ue(r,d);if(!c){a.error("Cannot determine the upstream VCS to commit to. Buildkite jobs need GITHUB_TOKEN or GITLAB_TOKEN set (matching the host parsed from BUILDKITE_REPO) for `vis ai heal accept` to land the commit."),process.exitCode=1;return}E=c}let C;try{C=await ne({branch:u,ciContext:E,files:w,message:v,workspaceRoot:l,...t.commitOverrides})}catch(c){a.error(`Commit failed: ${c instanceof Error?c.message:String(c)}`),process.exitCode=1;return}a.success(`Committed as ${C.sha.slice(0,7)}${C.url?` — ${C.url}`:""}.`);const N=fe(C,w,m.failedTask.taskId,n.actor),R=await(t.postComment??(async(c,$)=>V({body:c,context:$})))(N,r);!R.posted&&R.method!=="skipped"&&a.warn(`Commit landed but the confirmation comment failed: ${R.error??"unknown"}`)},"acceptHeal"),Ie=g(async e=>{await he(e)},"aiHealAccept");export{G as TRIGGER_PHRASE,Ie as aiHealAccept,ue as deriveBuildkiteCommitContextForTesting,me as fetchGithubHeadRefForTesting,de as loadBuildkiteTriggerForTesting,ce as loadGithubTriggerForTesting,le as loadGitlabTriggerForTesting,he as runHealAcceptForTesting,fe as summariseDetailForTesting};
@@ -0,0 +1,14 @@
1
+ var U=Object.defineProperty;var I=(t,e)=>U(t,"name",{value:e,configurable:!0});import{createRequire as A}from"node:module";import{j as O,E as v,T as G,I as j,e as F}from"../packem_shared/Table-DoSoazT6-DwnyTUsA.js";import{z as D}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{readLastRunSummary as K}from"@visulima/task-runner";import{r as H,a as M,b as V,c as z}from"../packem_shared/ai-fix-BkPUHA0z.js";import{F as q,p as u}from"./bin.js";const L=A(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=I(t=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[e,o]=b.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return b.getBuiltinModule(t)}return L(t)},"__cjs_getBuiltinModule"),{spawn:k}=T("node:child_process"),{readFile:J}=T("node:fs/promises");var Q=Object.defineProperty,g=I((t,e)=>Q(t,"name",{value:e,configurable:!0}),"i");const W=g(t=>{if(!t)return;const e=/^refs\/pull\/(\d+)\//.exec(t);return e?Number.parseInt(e[1],10):void 0},"parsePrNumberFromGithubRef"),Y=g(async t=>{if(!t)return{prNumber:void 0,sha:void 0};try{const e=await J(t,"utf8"),o=JSON.parse(e),r=o.pull_request?.number??o.issue?.number??o.number,i=o.pull_request?.head?.sha;return{prNumber:r,sha:i}}catch{return{prNumber:void 0,sha:void 0}}},"readPrNumberFromGithubEvent"),Z=g(async t=>{const e=W(t.GITHUB_REF),{prNumber:o,sha:r}=e===void 0?await Y(t.GITHUB_EVENT_PATH):{prNumber:e,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:e??o,provider:"github-actions",repo:t.GITHUB_REPOSITORY,sha:r??t.GITHUB_SHA,token:t.GITHUB_TOKEN}},"detectGithubActions"),X=g(t=>{const e=t.CI_MERGE_REQUEST_IID,o=e!==void 0&&e!==""?Number.parseInt(e,10):void 0,r=t.CI_API_V4_URL,i=t.GITLAB_TOKEN??t.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:t.CI_PROJECT_ID??t.CI_PROJECT_PATH,sha:t.CI_COMMIT_SHA,token:i}},"detectGitlabCi"),ee=g(t=>{const e=t.BUILDKITE_PULL_REQUEST,o=e!==void 0&&e!==""&&e!=="false"?Number.parseInt(e,10):void 0,r=t.BUILDKITE_BUILD_NUMBER,i=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=t.BUILDKITE_ORGANIZATION_SLUG,a=t.BUILDKITE_PIPELINE_SLUG,s=n!==void 0&&n!==""&&a!==void 0&&a!==""?`${n}/${a}`:void 0;return{apiBaseUrl:(t.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:t.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(i)?i:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:s,sha:t.BUILDKITE_COMMIT,token:t.BUILDKITE_API_TOKEN}},"detectBuildkite"),te=g(async(t=process.env)=>t.GITHUB_ACTIONS==="true"?await Z(t):t.GITLAB_CI==="true"?X(t):t.BUILDKITE==="true"?ee(t):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},"detectCiContext");var oe=Object.defineProperty,h=I((t,e)=>oe(t,"name",{value:e,configurable:!0}),"p");const re=h((t,e,o,r)=>new Promise(i=>{const n=["pr","comment",String(e),"--body-file","-"];r&&n.push("--repo",r);const a=k(t,n,{stdio:["pipe","ignore","pipe"]});let s="";a.stderr?.setEncoding("utf8"),a.stderr?.on("data",d=>{s+=d}),a.once("error",()=>{i({exitCode:127,stderr:s})}),a.once("close",d=>{i({exitCode:d??-1,stderr:s})}),a.stdin?.on("error",()=>{}),a.stdin?.end(o)}),"runGhComment"),ie=h(async(t,e,o,r,i)=>{const n=`https://api.github.com/repos/${e}/issues/${String(o)}/comments`;try{const a=await t(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!a.ok){const s=await a.text().catch(()=>"");return{error:`GitHub REST returned ${String(a.status)}: ${s.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(a){return{error:a instanceof Error?a.message:String(a),ok:!1}}},"postViaGithubRest"),ne=h(async(t,e,o,r,i,n)=>{const a=encodeURIComponent(o),s=`${e.replace(/\/+$/,"")}/projects/${a}/merge_requests/${String(r)}/notes`;try{const d=await t(s,{body:JSON.stringify({body:i}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const p=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${p.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},"postViaGitlabRest"),ae=h((t,e,o,r)=>new Promise(i=>{const n=k(t,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";n.stderr?.setEncoding("utf8"),n.stderr?.on("data",s=>{a+=s}),n.once("error",()=>{i({exitCode:127,stderr:a})}),n.once("close",s=>{i({exitCode:s??-1,stderr:a})}),n.stdin?.on("error",()=>{}),n.stdin?.end(e)}),"runBuildkiteAnnotate"),se=h(async(t,e,o,r,i,n,a,s)=>{const[d,p]=o.split("/",2);if(!d||!p)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const m=`${e}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(p)}/builds/${String(r)}/annotations`;try{const c=await t(m,{body:JSON.stringify({body:i,context:a,style:n}),headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},method:"POST"});if(!c.ok){const l=await c.text().catch(()=>"");return{error:`Buildkite REST returned ${String(c.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(c){return{error:c instanceof Error?c.message:String(c),ok:!1}}},"postViaBuildkiteRest"),de=h(async(t,e,o,r)=>{const i=e.buildId?`vis-ai-heal-${e.buildId}`:"vis-ai-heal",n="info",a=await ae(o,t,n,i);if(a.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!e.apiBaseUrl||!e.repo||e.buildNumber===void 0||!e.token){const d=[];return e.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),e.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),e.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(a.exitCode)} (${a.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const s=await se(r,e.apiBaseUrl,e.repo,e.buildNumber,t,n,i,e.token);return s.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(a.exitCode)}; REST fallback also failed: ${s.error??"unknown"}`,method:"rest",posted:!1}},"postBuildkiteAnnotation"),pe=h(async(t,e,o,r)=>{if(e.prNumber===void 0)return{method:"skipped",posted:!1};const i=await re(o,e.prNumber,t,e.repo);if(i.exitCode===0)return{method:"gh-cli",posted:!0};if(!e.repo||!e.token)return{error:`gh exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await ie(r,e.repo,e.prNumber,t,e.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(i.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},"postGithubComment"),ce=h(async(t,e,o)=>{if(e.prNumber===void 0)return{method:"skipped",posted:!1};if(!e.apiBaseUrl||!e.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!e.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await ne(o,e.apiBaseUrl,e.repo,e.prNumber,t,e.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},"postGitlabComment"),ue=h(async t=>{const{body:e,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:i=globalThis.fetch,ghBin:n="gh"}=t;return r.provider==="github-actions"?await pe(e,r,n,i):r.provider==="gitlab-ci"?await ce(e,r,i):r.provider==="buildkite"?await de(e,r,o,i):{method:"skipped",posted:!1}},"postPrComment");var le=Object.defineProperty,f=I((t,e)=>le(t,"name",{value:e,configurable:!0}),"l");const C=f(t=>{let e=0,o=0;for(const r of t)r.status==="applied"?e+=1:o+=1;return{applied:e,failed:o}},"summarizeApply"),_=f((t,e,o)=>{const r=H(t,e,o),i=D(t,r);return i===""||i.startsWith("..")?r:i},"formatDisplayPath"),fe=f((t,e,o,r)=>new Promise(i=>{const n=process.argv[1];if(!n){i({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const a=[n,"run",o,"--projects",e,"--no-cache","--summarize","--fail-fast"],s=k(process.execPath,a,{cwd:t,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",p="";const m=setTimeout(()=>{s.kill("SIGTERM"),setTimeout(()=>s.kill("SIGKILL"),2e3).unref()},r);s.stdout?.setEncoding("utf8"),s.stdout?.on("data",c=>{d+=c}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",c=>{p+=c}),s.once("error",c=>{clearTimeout(m),i({exitCode:-1,stderr:c.message,stdout:d})}),s.once("close",c=>{clearTimeout(m),i({exitCode:c??-1,stderr:p,stdout:d})})}),"validateFixByRerun"),me=6e4,y=f(t=>{let e=0;const o=t.match(/`{3,}/g);if(o)for(const r of o)e=Math.max(e,r.length);return"`".repeat(Math.max(3,e+1))},"pickFence"),$=f((t,e,o)=>{if(t.patches.length===0)return"_No patches proposed._";const r=[];for(const[i,n]of t.patches.entries()){const a=_(e,o,n.file),s=[`**[${String(i+1)}] \`${a}\`**`];n.reason&&s.push(`_${n.reason}_`);const d=y(`${n.oldString}
2
+ ${n.newString}`);s.push(`${d}diff`);for(const p of n.oldString.split(`
3
+ `))s.push(`- ${p}`);for(const p of n.newString.split(`
4
+ `))s.push(`+ ${p}`);s.push(d),r.push(s.join(`
5
+ `))}return r.join(`
6
+
7
+ `)},"renderProposalDiff"),x=f((t,e,o,r)=>{const i=["## vis ai heal — proposed fix","",`Failing task: \`${e.taskId}\` (provider: \`${t.provider}\`, confidence: \`${t.confidence}\`)`];r&&i.push(`Run anchored at \`${r.slice(0,7)}\`.`),i.push(""),i.push("### Root cause"),i.push(t.explanation||"_(no explanation)_"),i.push("");const n=["### Proposed patch",$(t,o,e.cwd),""],a=["### Validation",`Re-ran \`${e.taskId}\` after applying the patch on the CI runner — task **passed**.`,"","### Apply locally","```sh",`vis ai fix ${e.taskId} --apply`,"```","","---","","_Auto-generated by `vis ai heal`. Auto-commit is on the roadmap; for now the patch lives in this comment and is yours to accept or reject._"],s=[...i,...n,...a].join(`
8
+ `);if(Buffer.byteLength(s,"utf8")<=me)return s;const d=["### Proposed patch",`_Patch set is too large for a comment (${String(t.patches.length)} files). Run \`vis ai fix ${e.taskId} --apply\` locally to inspect and apply it._`,""];return[...i,...d,...a].join(`
9
+ `)},"renderCommentBody"),he=f((t,e,o)=>{const r=[O(`Proposal (${t.provider}, confidence: ${t.confidence})`),t.explanation||v("<no explanation>")];for(const[i,n]of t.patches.entries()){r.push(""),r.push(`[${String(i+1)}] ${_(e,o,n.file)}`),n.reason&&r.push(v(` reason: ${n.reason}`));for(const a of n.oldString.split(`
10
+ `))r.push(G(` - ${a}`));for(const a of n.newString.split(`
11
+ `))r.push(j(` + ${a}`))}return r.join(`
12
+ `)},"renderProposalForLog"),ge=f(async(t,e)=>{const o=e===void 0?await K(t):await q(t,e);if(o){for(const r of o.tasks)if(r.exitCode!==void 0&&r.exitCode!==0)return{project:r.target?.project,runId:o.id,target:r.target?.target,taskId:r.taskId}}},"findFirstFailedTask"),Ie=1800*1e3,w=f(async(t,e)=>{const o=await ge(t,e);if(!o)return{outcome:"no-failed-task"};if(!o.project||!o.target)return{failedTask:o,outcome:"missing-metadata"};const r=await M(t,o.taskId,{runId:o.runId});return r?{failedTask:{project:o.project,runId:o.runId,target:o.target,taskId:o.taskId},failureContext:r,outcome:"ready"}:{failedTask:{project:o.project,runId:o.runId,target:o.target,taskId:o.taskId},outcome:"no-failure-context"}},"findHealCandidate"),N=f(async(t,e)=>{const{logger:o,options:r,visConfig:i,workspaceRoot:n}=t,a=n??process.cwd(),s=r.dryRun===!0,d=i?.ai,p=await V(e.failureContext,o,{cache:r.cache!==!1,config:d});if(!p)return{outcome:"no-proposal"};if(p.cannotFix)return{detail:p.cannotFix,outcome:"cannot-fix",proposal:p};if(p.patches.length===0)return{outcome:"empty-patches",proposal:p};if(s)return{outcome:"dry-run",proposal:p};const m=await z(a,e.failureContext.cwd,p);return C(m).applied===0?{applyResults:m,outcome:"no-patches-applied",proposal:p}:{applyResults:m,outcome:"applied",proposal:p}},"proposeAndApply"),E=f(async(t,e,o={})=>{const r=t.workspaceRoot??process.cwd(),i=t.options.validationTimeout===void 0?Ie:t.options.validationTimeout*1e3;return await(o.validate??((n,a)=>fe(r,n,a,i)))(e.failedTask.project,e.failedTask.target)},"validateAppliedFix"),S=f(async(t,e,o,r={})=>{const i=await(r.detectCi??te)(),n=i.provider==="gitlab-ci"?"MR":i.provider==="buildkite"?"annotation":"PR";if(i.provider==="unknown")return{ciContext:i,outcome:"no-ci",surface:n};const a=x(e,o,t,i.sha),s=await(r.postComment??(async(d,p)=>ue({body:d,context:p})))(a,i);return s.posted?{ciContext:i,method:s.method,outcome:"posted",surface:n}:s.method==="skipped"?{ciContext:i,outcome:"no-pr",surface:n}:{ciContext:i,error:s.error,method:s.method,outcome:"post-failed",surface:n}},"postHealComment"),R=f(async(t,e={})=>{const{logger:o,workspaceRoot:r}=t,i=r??process.cwd(),n=await w(i,t.options.run);if(n.outcome==="no-failed-task"){u.info("No failed tasks found in the latest run summary. Nothing to heal.");return}if(n.outcome==="missing-metadata"){u.error(`Failed task ${n.failedTask.taskId} is missing project/target metadata in the run summary; cannot validate a fix.`),process.exitCode=1;return}if(n.outcome==="no-failure-context"){u.error(`No failure log or run summary found for ${n.failedTask.taskId}.`),process.exitCode=1;return}const a={failedTask:n.failedTask,failureContext:n.failureContext};u.info(`Healing ${a.failedTask.taskId} (run ${a.failedTask.runId??"unknown"})`),a.failureContext.terminalOutputCaptured||u.warn(`No captured terminal output for ${a.failedTask.taskId}; the AI proposal will be weaker without it.`);const s=await N(t,a);if(s.outcome==="no-proposal"){u.error("AI fix proposal failed or no provider available."),process.exitCode=1;return}if(s.outcome==="cannot-fix"){u.warn(`AI declined to fix: ${s.detail??"(no reason)"}`);return}if(s.outcome==="empty-patches"){u.warn("AI returned an empty patch set.");return}const d=s.proposal;if(o.info(he(d,i,a.failureContext.cwd)),s.outcome==="dry-run"){u.info("Dry run: skipping apply, validation, and PR comment.");return}const p=s.applyResults??[],m=C(p);if(u.info(`Applied ${String(m.applied)}/${String(p.length)} patches.`),s.outcome==="no-patches-applied"){u.error("No patches could be applied (all failed validation)."),process.exitCode=1;return}u.info(`Re-running ${a.failedTask.taskId} to validate the fix...`);const c=await E(t,a,{validate:e.validate});if(c.exitCode!==0){u.error(`Validation failed (exit ${String(c.exitCode)}). Patch is not posted.`),c.stderr.trim().length>0&&(o.info(F("--- validation stderr (tail) ---")),o.info(c.stderr.split(`
13
+ `).slice(-20).join(`
14
+ `))),process.exitCode=1;return}u.success("Validation passed.");const l=await S(i,d,a.failureContext,{detectCi:e.detectCi,postComment:e.postComment});if(l.outcome==="no-ci"){u.notice("Not running in a recognised CI provider; skipping PR comment. Patch was applied + validated locally.");return}if(l.outcome==="posted"){const P=l.surface==="annotation"?`build #${String(l.ciContext.buildNumber??"?")}`:`${l.surface} #${String(l.ciContext.prNumber)}`;u.success(`Posted fix proposal to ${P} via ${l.method??"unknown"}.`);return}if(l.outcome==="no-pr"){u.notice(`No ${l.surface} number detected (push-event run); skipping comment.`);return}const B=l.surface==="annotation"?"annotation":`${l.surface} comment`;u.error(`Failed to post ${B}: ${l.error??"unknown error"}`)},"heal"),be=f(async t=>{await R(t)},"aiHeal"),xe=Object.defineProperty({__proto__:null,aiHeal:be,findHealCandidate:w,pickFenceForTesting:y,postHealComment:S,proposeAndApply:N,renderCommentBodyForTesting:x,renderProposalDiffForTesting:$,runHealForTesting:R,validateAppliedFix:E},Symbol.toStringTag,{value:"Module"});export{w as P,N as R,te as d,xe as h,ue as p,E as w};
@@ -0,0 +1,8 @@
1
+ var Ke=Object.defineProperty;var m=(e,t)=>Ke(e,"name",{value:t,configurable:!0});import{createRequire as Ze}from"node:module";import{B as et,M as U,r as V,j as tt,I as N,N as w,q as W,e as z}from"../packem_shared/Table-DoSoazT6-DwnyTUsA.js";import{h as it,E as R,c as L,b as ne}from"../packem_shared/index-hoWfZmNo.js";const Qe=Ze(import.meta.url),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xe=m(e=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[t,n]=M.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return M.getBuiltinModule(e)}return Qe(e)},"__cjs_getBuiltinModule"),{createRequire:nt}=Xe("node:module");var rt=Object.defineProperty,ot=m((e,t)=>rt(e,"name",{value:t,configurable:!0}),"f$2"),at=Object.defineProperty,st=ot((e,t)=>at(e,"name",{value:t,configurable:!0}),"s"),lt=Object.defineProperty,ct=st((e,t)=>lt(e,"name",{value:t,configurable:!0}),"a");const ut=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,re=ct(e=>{let[,t]=ut.exec(e)??[];const n=t?t.length:0;if(n===3){const r=t.charAt(0),o=t.charAt(1),a=t.charAt(2);t=r+r+o+o+a+a}else if(n!==6)return[0,0,0];const i=Number.parseInt(t,16);return[i>>16&255,i>>8&255,i&255]},"convertHexToRgb");var dt=Object.defineProperty,ht=m((e,t)=>dt(e,"name",{value:t,configurable:!0}),"o$1"),ft=Object.defineProperty,pt=ht((e,t)=>ft(e,"name",{value:t,configurable:!0}),"s"),gt=Object.defineProperty,fe=pt((e,t)=>gt(e,"name",{value:t,configurable:!0}),"e");const Me=fe((e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/51)+6*Math.round(t/51)+Math.round(n/51),"rgbToAnsi256"),oe=fe(e=>{let t,n,i;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)t=n=i=((e-232)*10+8)/255;else{e-=16;const a=e%36;t=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}const r=Math.max(t,n,i)*2;if(r===0)return 30;const o=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(t));return r===2?o+60:o},"ansi256To16"),we=fe((e,t,n)=>oe(Me(e,t,n)),"rgbToAnsi16");var mt=Object.defineProperty,Re=m((e,t)=>mt(e,"name",{value:t,configurable:!0}),"m"),bt=Object.defineProperty,P=Re((e,t)=>bt(e,"name",{value:t,configurable:!0}),"u"),wt=Object.defineProperty,yt=P((e,t)=>wt(e,"name",{value:t,configurable:!0}),"e");function J({onlyFirst:e=!1}={}){const t="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(t,e?void 0:"g")}m(J,"$$3");Re(J,"j");P(J,"t$1");yt(J,"ansiRegex");var $t=Object.defineProperty,vt=P((e,t)=>$t(e,"name",{value:t,configurable:!0}),"n$1");const A=vt((e,t,n)=>t>e?t:Math.min(e,n),"clamp");var Nt=Object.defineProperty,y=P((e,t)=>Nt(e,"name",{value:t,configurable:!0}),"b");const p=39,g=49,ye=10,ae=et(),ke={close:"",open:""},l=ae>0?(e,t)=>({close:`\x1B[${String(t)}m`,open:`\x1B[${String(e)}m`}):()=>ke,$e=y(e=>(t,n,i)=>e(Me(Number(t),Number(n),Number(i))),"createRgbFunction"),ve=y(e=>t=>{const[n,i,r]=re(t);return e(n,i,r)},"createHexFunction");let se=y(e=>l(`38;5;${String(e)}`,p),"createAnsi256"),le=y(e=>l(`48;5;${String(e)}`,g),"createBgAnsi256"),D=y((e,t,n)=>l(`38;2;${String(e)};${String(t)};${String(n)}`,p),"createRgb"),Y=y((e,t,n)=>l(`48;2;${String(e)};${String(t)};${String(n)}`,g),"createBgRgb");ae===1?(se=y(e=>l(oe(Number(e)),p),"createAnsi256"),le=y(e=>l(oe(Number(e))+ye,g),"createBgAnsi256"),D=y((e,t,n)=>l(we(Number(e),Number(t),Number(n)),p),"createRgb"),Y=y((e,t,n)=>l(we(Number(e),Number(t),Number(n))+ye,g),"createBgRgb")):ae===2&&(D=$e(se),Y=$e(le));const Ne={bold:l(1,22),dim:l(2,22),hidden:l(8,28),inverse:l(7,27),italic:l(3,23),overline:l(53,55),reset:l(0,0),strike:l(9,29),strikethrough:l(9,29),underline:l(4,24),visible:ke},Oe={bgBlack:l(40,g),bgBlackBright:l(100,g),bgBlue:l(44,g),bgBlueBright:l(104,g),bgCyan:l(46,g),bgCyanBright:l(106,g),bgGray:l(100,g),bgGreen:l(42,g),bgGreenBright:l(102,g),bgGrey:l(100,g),bgMagenta:l(45,g),bgMagentaBright:l(105,g),bgRed:l(41,g),bgRedBright:l(101,g),bgWhite:l(47,g),bgWhiteBright:l(107,g),bgYellow:l(43,g),bgYellowBright:l(103,g),black:l(30,p),blackBright:l(90,p),blue:l(34,p),blueBright:l(94,p),cyan:l(36,p),cyanBright:l(96,p),gray:l(90,p),green:l(32,p),greenBright:l(92,p),grey:l(90,p),magenta:l(35,p),magentaBright:l(95,p),red:l(31,p),redBright:l(91,p),white:l(37,p),whiteBright:l(97,p),yellow:l(33,p),yellowBright:l(93,p)},Ae={bg:y(e=>le(A(e,0,255)),"bg"),bgHex:ve(Y),bgRgb:y((e,t,n)=>Y(A(e,0,255),A(t,0,255),A(n,0,255)),"bgRgb"),fg:y(e=>se(A(e,0,255)),"fg"),hex:ve(D),rgb:y((e,t,n)=>D(A(e,0,255),A(t,0,255),A(n,0,255)),"rgb")};var Ot=Object.defineProperty,At=P((e,t)=>Ot(e,"name",{value:t,configurable:!0}),"s");const St=At((e,t,n)=>{if(t==="")return e;let i=e.indexOf(t);if(i<0)return e;const r=t.length;let o=0,a="";for(;~i;)a+=e.slice(o,i)+n,o=i+r,i=e.indexOf(t,o);return a+e.slice(o)},"stringReplaceAll");var jt=Object.defineProperty,T=P((e,t)=>jt(e,"name",{value:t,configurable:!0}),"a");const S={};let ce=null;const xt=T((e,t,n)=>{if(!e)return"";let i;if(e.raw===void 0?i=String(e):i=String.raw(e,...t),i.includes("\x1B"))for(let r=n;r;r=r.props)i=St(i,r.close,r.open);return i.includes(`
2
+ `)&&(i=i.replace(/(\r*\n)/g,`${n.closeStack}$1${n.openStack}`)),n.openStack+i+n.closeStack},"wrapText"),ue=T(({props:e},{close:t,open:n})=>{const i=(e?.openStack??"")+n,r=t+(e?.closeStack??""),o=T((a,...s)=>xt(a,s,o.props),"style");return Object.setPrototypeOf(o,ce),o.props={close:t,closeStack:r,open:n,openStack:i,props:e},o.open=i,o.close=r,o},"createStyle"),Et=T(function(){const e=T(t=>String(t),"self");e.strip=t=>t.replaceAll(J(),"");for(const t in Oe)S[t]={get(){const n=ue(this,Oe[t]);return Object.defineProperty(this,t,{value:n}),n}};for(const t in Ne)S[t]={get(){const n=ue(this,Ne[t]);return Object.defineProperty(this,t,{value:n}),n}};return ce=Object.defineProperties({},S),Object.setPrototypeOf(e,ce),e},"Colorize");for(const e in Ae)S[e]={get(){return(...t)=>ue(this,Ae[e](...t))}};S.ansi256=S.fg;S.bgAnsi256=S.bg;var It=Object.defineProperty,Bt=m((e,t)=>It(e,"name",{value:t,configurable:!0}),"g"),Wt=Object.defineProperty,K=Bt((e,t)=>Wt(e,"name",{value:t,configurable:!0}),"i"),Pt=Object.defineProperty,Mt=K((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"n");const Ce=Mt(e=>(t,...n)=>{if(!Array.isArray(t)||!Array.isArray(t.raw))throw new TypeError("A tagged template literal must be provided");const i=[t.raw[0]];for(let r=1;r<t.raw.length;r+=1)i.push(String(n[r-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(t.raw[r]));return e(i.join(""))},"makeColorizeTemplate");var Rt=Object.defineProperty,kt=K((e,t)=>Rt(e,"name",{value:t,configurable:!0}),"e$1");const Ct=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
3
+ `],["r","\r"],["t"," "],["v","\v"]]),Te=kt(e=>{const t=e.startsWith("u"),n=e[1]==="{";return t&&!n&&e.length===5||e.startsWith("x")&&e.length===3?String.fromCodePoint(Number.parseInt(e.slice(1),16)):t&&n?String.fromCodePoint(Number.parseInt(e.slice(2,-1),16)):Ct.get(e)??e},"unescape");var Tt=Object.defineProperty,Z=K((e,t)=>Tt(e,"name",{value:t,configurable:!0}),"u");const _t=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,Se=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,Lt=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,Ft=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,Ut=/\s*,\s*/,Vt=Z((e,t)=>{const n=[],i=t.trim().split(Ut);let r;for(const o of i){const a=Number(o);if(!Number.isNaN(a))n.push(a);else if(r=Lt.exec(o))n.push(r[2].replaceAll(Ft,(s,c,u)=>c?Te(c):u));else throw new Error(`Invalid template style argument: ${o} (in style '${e}')`)}return n},"parseArguments"),qt=Z(e=>{Se.lastIndex=0;const t=[];let n;for(;(n=Se.exec(e))!==null;){const i=n[1];n[2]?t.push([i,...Vt(i,n[2])]):n[3]||n[4]?(n[3]&&t.push(["rgb",...re(n[3])]),n[4]&&t.push(["bgRgb",...re(n[4])])):t.push([i])}return t},"parseStyle"),je=Z((e,t)=>{const n={};for(const r of t)for(const o of r.styles)n[o[0]]=r.inverse?void 0:o.slice(1);let i=e;for(const[r,o]of Object.entries(n))if(Array.isArray(o)){if(!(r in i))throw new Error(`Unknown style: ${r}`);i=o.length>0?i[r](...o):i[r]}return i},"buildStyle"),_e=Z(e=>t=>{const n=[],i=[];let r=[];if(t.replaceAll(_t,(o,a,s,c,u,d)=>{if(a)r.push(Te(a));else if(c){const f=r.join("");r=[],i.push(n.length===0?f:je(e,n)(f)),n.push({inverse:s,styles:qt(c)})}else if(u){if(n.length===0)throw new Error("Found extraneous } in template literal");i.push(je(e,n)(r.join(""))),r=[],n.pop()}else r.push(d)}),i.push(r.join("")),n.length>0)throw new Error(`template literal is missing ${String(n.length)} closing bracket${n.length===1?"":"s"} (\`}\`)`);return i.join("")},"makeTemplate");var Gt=Object.defineProperty,Ht=K((e,t)=>Gt(e,"name",{value:t,configurable:!0}),"e");const zt=new Et;Ht(e=>Ce(_e(e)),"makeTaggedTemplate");const Dt=_e(zt),Yt=Ce(Dt);var Jt=Object.defineProperty,h=m((e,t)=>Jt(e,"name",{value:t,configurable:!0}),"a");const Kt=nt(import.meta.url),B=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Q=h(e=>{if(typeof B<"u"&&B.versions&&B.versions.node){const[t,n]=B.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return B.getBuiltinModule(e)}return Kt(e)},"R"),x=B,{execFileSync:Zt}=Q("node:child_process"),C=Q("node:fs"),Qt=Q("node:tty"),Xt=Q("node:os"),en=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],tn=12288,nn=65510,rn=[12288,12288,65281,65376,65504,65510],on=8361,an=65518,sn=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],ln=32,cn=10630,un=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],dn=4352,hn=262141,Le=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],_=h((e,t)=>{let n=0,i=Math.floor(e.length/2)-1;for(;n<=i;){const r=Math.floor((n+i)/2),o=r*2;if(t<e[o])i=r-1;else if(t>e[o+1])n=r+1;else return!0}return!1},"$"),xe=19968,[fn,pn]=Fe(Le);function Fe(e){let t=e[0],n=e[1];for(let i=0;i<e.length;i+=2){const r=e[i],o=e[i+1];if(xe>=r&&xe<=o)return[r,o];o-r>n-t&&(t=r,n=o)}return[t,n]}m(Fe,"Wt");h(Fe,"N1");const gn=h(e=>e<161||e>1114109?!1:_(en,e),"I1"),mn=h(e=>e<tn||e>nn?!1:_(rn,e),"W1"),bn=h(e=>e<on||e>an?!1:_(sn,e),"$1"),wn=h(e=>e<ln||e>cn?!1:_(un,e),"O1"),yn=h(e=>e>=fn&&e<=pn?!0:e<dn||e>hn?!1:_(Le,e),"x1");function Ue(e){return gn(e)?"ambiguous":mn(e)?"fullwidth":bn(e)?"halfwidth":wn(e)?"narrow":yn(e)?"wide":"neutral"}m(Ue,"Mt");h(Ue,"E1");function Ve(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}m(Ve,"St");h(Ve,"v1");function pe(e){return Ve(e),Ue(e)}m(pe,"q");h(pe,"Y");const Ee=new Map,F=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,q=h(e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other","A"),$n=h((e,t)=>{const n=Math.floor(e/65536),i=e%65536;let r=Ee.get(n);if(r||(r=new Map,Ee.set(n,r)),r.has(i))return r.get(i);let o;if(q(e)==="latin")o=t.width.regular;else if(q(e)==="control")o=t.width.control;else if(q(e)==="wide")o=t.width.wide;else switch(pe(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}return r.set(i,o),o},"A1"),vn=h(e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,"M1"),de=h((e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?de(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},i=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:r}=e,o=r>1e4;let a=0,s=0,c=r,u=!1;const d=e.includes("\x1B")||e.includes("›");for(;a<r;){if(d&&(e[a]==="\x1B"||e[a]==="›")){if(e.startsWith("\x1B]8;;",a)){const v="\x1B]8;;\x07",j=v.length,X=e.indexOf("\x07",a+5);if(X!==-1){const ee=e.indexOf(v,X+1);if(ee!==-1){const Ye=ee+j,Je=e.slice(X+1,ee).replace(R,""),be=de(Je,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,i-s),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),te=be.width;if(be.truncated)u=!0,c=Math.min(c,a);else if(s+te>i&&(c=Math.min(c,a),u=!0,s+te>n.truncation.limit))break;if(s+=te,a=Ye,u&&s>=n.truncation.limit)break;continue}}}if(R.lastIndex=a,R.test(e)){const v=R.lastIndex-a,j=n.truncation.countAnsiEscapeCodes?v:n.width.ansi;if(s+j>i&&(c=Math.min(c,a),s+j>n.truncation.limit)){u=!0;break}s+=j,a=R.lastIndex;continue}}const O=e.codePointAt(a);if(O===8203||O===65279||O>=8288&&O<=8292){a+=1;continue}if(O===9){if(s+n.width.tab>i&&(c=Math.min(c,a),s+n.width.tab>n.truncation.limit)){u=!0;break}s+=n.width.tab,a+=1;continue}if(F.lastIndex=a,F.test(e)){const v=(F.lastIndex-a)*n.width.regular;if(s+v>i){const j=Math.floor((i-s)/n.width.regular);if(c=Math.min(c,a+j),s+v>n.truncation.limit){u=!0;break}}s+=v,a=F.lastIndex;continue}if((O<=31||O>=127&&O<=159)&&(L.lastIndex=a,L.test(e))){const v=(L.lastIndex-a)*n.width.control;if(s+v>i&&(c=Math.min(c,a+Math.floor((i-s)/n.width.control)),s+v>n.truncation.limit)){u=!0;break}s+=v,a=L.lastIndex;continue}if(ne.lastIndex=a,ne.test(e)){if(s+n.width.emoji>i&&(c=Math.min(c,a),s+n.width.emoji>n.truncation.limit)){u=!0;break}s+=n.width.emoji,a=ne.lastIndex;continue}const I=e.codePointAt(a)??0;if(vn(I)){a+=I>65535?2:1;continue}let $;if(o)$=$n(I,n);else switch(q(I)){case"control":{$=n.width.control;break}case"latin":{$=n.width.regular;break}case"wide":{$=n.width.wide;break}case"zero":{$=0;break}default:switch(pe(I)){case"ambiguous":{$=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{$=n.width.fullWidth;break}case"wide":{$=n.width.wide;break}default:$=n.width.regular}}if(s+$>i&&(c=Math.min(c,a),s+$>n.truncation.limit)){u=!0;break}s+=$,a+=I>65535?2:1}let f=s,me=!1;return u&&n.truncation.limit>=n.truncation.ellipsisWidth&&(f=n.truncation.limit,me=!0),{ellipsed:me,index:u?c:r,truncated:u,width:f}},"C"),Nn=h((e,t={})=>de(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"_1"),qe=80,Ge=24,he=h((e,t,{shell:n,env:i}={})=>Zt(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:i}).trim(),"B"),G=h((e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),"M"),He=h((e,t)=>{const{columns:n,rows:i}=G(e,t);if(!(Number.isNaN(n)||Number.isNaN(i))&&!(n===qe&&i===Ge))return{columns:n,rows:i}},"K"),On=h(()=>{if(x.platform!=="linux")return!0;try{const e=C.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),i=Number.parseInt(n[2],10),r=Number.parseInt(n[5],10);return Number.isNaN(i)||Number.isNaN(r)||r<=0?!1:i===r}catch{return!1}},"R1");function ze(){const{env:e,stdout:t,stderr:n}=x;if(t?.columns&&t?.rows)return G(t.columns,t.rows);if(n?.columns&&n?.rows)return G(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return G(e.COLUMNS,e.LINES);const i={columns:qe,rows:Ge};return x.platform==="win32"?ie()??i:x.platform==="darwin"?Ie()??ie()??i:Ie()??ie()??An()??i}m(ze,"Tt");h(ze,"S1");const Ie=h(()=>{try{const e=x.platform==="darwin"?C.constants.O_EVTONLY|C.constants.O_NONBLOCK:C.constants.O_NONBLOCK,{columns:t,rows:n}=Qt.WriteStream(C.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},"H"),ie=h(()=>{try{const e=he("tput",["cols"],{env:{TERM:"dumb",...x.env}}),t=he("tput",["lines"],{env:{TERM:"dumb",...x.env}});if(e&&t)return He(e,t)}catch{}},"T"),An=h(()=>{try{if(!On())return;const e=he("resize",["-u"]).match(/\d+/g);if(e.length===2)return He(e[0],e[1])}catch{}},"k1"),k=new Map,Sn=500,b=h(e=>{if(!e||e==="")return"";const t=k.get(e);if(t!==void 0)return t;const n=Yt(Object.assign([],{raw:[e]}));if(k.size>=Sn){const i=k.keys().next().value;i!==void 0&&k.delete(i)}return k.set(e,n),n},"u"),H=h(()=>{const e=it().CEREBRO_TERMINAL_WIDTH;if(e===void 0)return;const t=Number.parseInt(e,10);if(!(Number.isNaN(t)||t<=0))return t},"_");let De=class{static{m(this,"G")}static{h(this,"U")}lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(Xt.EOL)}header(e){this.add(tt(e)),this.lines.push("")}};const jn=h(e=>e!==void 0&&e>0?e:ze().columns,"L1"),xn=h((e,t,n,i)=>{if(e.length===0||e.some(u=>u.length!==2))return;let r=0;for(const u of e){const d=u[0];if(d===void 0)continue;const f=Nn(d);f>r&&(r=f)}if(r===0)return;const o=n+i,a=r+o,s=20+o;if(a+s>t)return;const c=t-a;return[a,c]},"T1");class En extends De{static{m(this,"Ft")}static{h(this,"C1")}constructor(t){if(super(),t.header&&this.header(b(t.header)),t.content){if(t.raw)if(Array.isArray(t.content)&&t.content.every(n=>typeof n=="string"))t.content.forEach(n=>{Array.isArray(n)?n.forEach(i=>{this.add(b(i))}):this.add(b(n))});else if(typeof t.content=="string")this.add(b(t.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(t.content));this.add("")}}getContentLines(t){if(typeof t=="string"){const n=U({showHeader:!1,style:{border:V,paddingLeft:4,paddingRight:1},terminalWidth:H(),truncateOverflow:!1,wordWrap:!0});return n.addRow([b(t)]),n.toString()}if(Array.isArray(t)&&t.every(n=>typeof n=="string"||Array.isArray(n)&&n.every(i=>typeof i=="string"))){const n=jn(H()),i=h(s=>Array.isArray(s)?s.map(c=>b(c)):[b(s)],"t"),r=t.map(s=>i(s)),o=xn(r,n,4,1),a=U({columnWidths:o,showHeader:!1,style:{border:V,paddingLeft:4,paddingRight:1},terminalWidth:n,truncateOverflow:!1,wordWrap:!0});return r.forEach(s=>{o!==void 0&&s.length===2?a.addRow([{content:s[0],wordWrap:!1},s[1]]):a.addRow(s)}),a.toString()}if(typeof t=="object"){const n=t;if(!n.options||!n.data)throw new Error(`Must have an "options" or "data" property
4
+ ${JSON.stringify(t)}`);const i=U({showHeader:!1,style:{border:V,paddingLeft:4,paddingRight:1},terminalWidth:H(),truncateOverflow:!1,wordWrap:!0});return n.data.forEach(r=>{Array.isArray(r)?i.addRow(r.map(o=>b(o))):i.addRow([b(r)])}),i.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
5
+
6
+ ${JSON.stringify(t)}`)}}class In extends De{static{m(this,"zt")}static{h(this,"B1")}constructor(t){super();let n=t.optionList??[];const i=Array.isArray(t.hide)?t.hide:[t.hide].filter(a=>typeof a=="string"),r=Array.isArray(t.group)?t.group:[t.group].filter(a=>typeof a=="string");i.length>0&&(n=n.filter(a=>!i.includes(a.name))),t.header&&this.header(b(t.header)),r.length>0&&(n=n.filter(a=>{const s=a,c=r.includes("_none")&&!s.group,u=s.group,d=this.intersect(Array.isArray(u)?u:[u],r);return c||d?a:void 0}));const o=U({showHeader:!1,style:{border:V,paddingLeft:2,paddingRight:1,...t.tableOptions?.style},terminalWidth:H()??t.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:t.tableOptions?.wordWrap??!0,...t.tableOptions});n.forEach(a=>{const s=a;o.addRow([this.getOptionNames(s,t.reverseNameOrder??!1,t.isArgument??!1),b(s.description)])}),this.add(o.toString()),this.lines.push("")}getOptionNames(t,n,i){if(!t.name)throw new TypeError("Invalid option definition, name is required.");let r=t.type?t.type.name.toLowerCase():"string";const o=t.multiple||t.lazyMultiple?"[]":"";r=b(t.typeLabel??`{underline ${r}${o}}`);let a;if(t.alias)if(t.name){const s=i?t.name:`{yellow --${t.name}}`;a=b(n?`{bold ${s}}, {bold -${t.alias}} ${r}`:`{bold -${t.alias}}, {bold ${s}} ${r}`)}else n?a=b(`{bold -${t.alias}} ${r}`):a=b(`{bold -${t.alias}} ${r}`);else a=b(`{bold ${i?t.name:`{yellow --${t.name}}`}} ${r}`);return a}intersect(t,n){return t.some(i=>n.includes(i))}}const ge=h(e=>(Array.isArray(e)?e:[e]).length===0?"":`
7
+ ${e.map(t=>t.optionList?new In(t).toString():new En(t).toString()).join(`
8
+ `)}`,"J1");var Bn=Object.defineProperty,E=m((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"u");const Wn=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],Be="__Other",We=E(e=>e.charAt(0).toUpperCase()+e.slice(1),"v"),Pn=E((e,t,n,i)=>{e.debug("no command given, printing general help...");let r=[...new Set(n.values())].filter(s=>!s.hidden);i&&(r=r.filter(s=>s.group===i));const o=r.reduce((s,c)=>{const u=c.group??Be;return s[u]??=[],s[u].push(c),s},{}),a=E(s=>s.map(c=>{let u="";typeof c.alias=="string"?u=c.alias:Array.isArray(c.alias)&&(u=c.alias.join(", ")),u!==""&&(u=` [${u}]`);let d=c.name;return c.commandPath&&c.commandPath.length>0&&(d=`${c.commandPath.join(" ")} ${c.name}`),[`${N(d)}${u}`,c.description??""]}),"a");(e.raw??e.log)(ge([{content:`${W(t.getCliName())} ${N("<command>")} [positional arguments] ${z("[options]")}`,header:w.cyan(" Usage ")},...Object.keys(o).map(s=>{const c=i?` ${We(i)}`:"";return{content:a(o[s]),header:s===Be||i?w.green(` Available${c} Commands `):` ${w.green(` ${We(s)} `)}`}}),n.has("help")?{header:w.yellow(" Command Options "),optionList:n.get("help").options?.filter(s=>!s.hidden)}:void 0,{header:w.yellow(" Global Options "),optionList:t.getGlobalOptions()},{content:Wn.filter(s=>!s.hidden).map(s=>[s.name,s.description??""]),header:w.magenta(" Environment Variables ")},{content:`Run "${W(t.getCliName())} ${N("help <command>")}" or "${W(t.getCliName())} ${N("<command>")} ${z("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"w"),Pe=E((e,t)=>{const n=[];for(const i of e.values()){if(i.hidden)continue;const r=i.commandPath??[];if(r.length!==t.length)continue;let o=!0;for(const[a,s]of t.entries())if(r[a]!==s){o=!1;break}o&&n.push(i)}return n},"$"),Mn=E((e,t,n,i)=>{const r=n.join(" "),o=[{content:`${W(t.getCliName())} ${N(r)} ${N("<subcommand>")} [positional arguments] ${z("[options]")}`,header:w.cyan(" Usage ")},{content:i.map(a=>{const s=[...a.commandPath??[],a.name].join(" ");return[N(s),a.description??""]}),header:w.green(" Subcommands ")},{header:w.yellow(" Global Options "),optionList:t.getGlobalOptions()},{content:`Run "${W(t.getCliName())} ${N(`${r} <subcommand>`)} ${z("--help")}" for help with a specific subcommand.`,raw:!0}];(e.raw??e.log)(ge(o))},"E"),Rn=E((e,t,n,i,r)=>{let o=r??n.get(i);if(!o)for(const d of n.values()){const f=d.commandPath?[...d.commandPath,d.name]:[d.name];if(f.at(-1)===i||f.join(" ")===i){o=d;break}}if(!o){const d=i.split(" ").filter(Boolean),f=d.length>0?Pe(n,d):[];if(f.length>0){Mn(e,t,d,f);return}e.error(`Command "${i}" not found`);return}const a=[],s=(o.commandPath?[...o.commandPath,o.name]:[o.name]).join(" ");if(a.push({content:`${W(t.getCliName())} ${N(s)}${o.argument?" [positional arguments]":""}${o.options?" [options]":""}`,header:w.cyan(" Usage ")}),o.description&&a.push({content:o.description,header:w.green(" Description ")}),o.argument&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:[o.argument]}),Array.isArray(o.options)&&o.options.length>0&&a.push({header:w.yellow(" Command Options "),optionList:o.options.filter(d=>!d.hidden)}),a.push({header:w.yellow(" Global Options "),optionList:t.getGlobalOptions()}),Array.isArray(o.env)&&o.env.length>0){const d=o.env.filter(f=>!f.hidden);d.length>0&&a.push({content:d.map(f=>[f.name,f.description??""]),header:w.magenta(" Environment Variables ")})}if(o.alias!==void 0&&o.alias.length>0){let d=o.alias;typeof o.alias=="string"&&(d=[o.alias]),a.splice(1,0,{content:d,header:"Alias(es)"})}Array.isArray(o.examples)&&o.examples.length>0&&a.push({content:o.examples,header:"Examples"});const c=[...o.commandPath??[],o.name],u=Pe(n,c);u.length>0&&a.push({content:u.map(d=>{const f=[...d.commandPath??[],d.name].join(" ");return[N(f),d.description??""]}),header:w.green(" Subcommands ")}),(e.raw??e.log)(ge(a))},"N");class Ln{static{m(this,"P")}static{E(this,"P")}argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(t){this.commands=t}execute(t){const{argument:n,command:i,commandName:r,logger:o,options:a,runtime:s}=t,{footer:c,header:u}=s.getCommandSection();u&&(o.raw??o.log)(b(u));const d=r==="help"&&Array.isArray(n)&&n.length>0?n.join(" "):void 0;if(r==="help"&&d===void 0)Pn(o,s,this.commands,typeof a?.group=="string"?a.group:void 0);else{const f=d!==void 0||i===void 0||i.name==="help"?void 0:i;Rn(o,s,this.commands,d??r,f)}c&&(o.raw??o.log)(b(c))}}export{Ln as default};
@@ -0,0 +1,7 @@
1
+ var We=Object.defineProperty;var k=(e,t)=>We(e,"name",{value:t,configurable:!0});import{createRequire as Ue}from"node:module";import{bc as _,bd as U,be as T,bf as A,bg as G,bh as te,bi as Pe,bj as ne,bk as Te,bl as se,bm as re,bn as ie,bo as ze,bp as Me,bq as Ie,br as Re,bs as Fe,bt as Ne,bu as Be,bv as qe,bw as De,bx as Ve,by as Ge,bz as Qe,bA as Je,bB as Ke,bC as He,bD as Ye,bE as oe,bF as S,bG as Xe,bH as Ze,r as et,an as tt,p as nt,b0 as st}from"./bin.js";import{z as ue,M as pe,B as N}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";const Se=Ue(import.meta.url),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_e=k(e=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[t,n]=M.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return M.getBuiltinModule(e)}return Se(e)},"__cjs_getBuiltinModule"),{createRequire:rt}=_e("node:module");var it=Object.defineProperty,ot=k((e,t)=>it(e,"name",{value:t,configurable:!0}),"e$2");const at=ot((e,t)=>typeof e!="string"||e===""?"":(t?.locale?e[0].toLocaleLowerCase(t.locale):e[0].toLowerCase())+e.slice(1),"a");var lt=Object.defineProperty,y=k((e,t)=>lt(e,"name",{value:t,configurable:!0}),"g");const ct=rt(import.meta.url),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ft=y(e=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[t,n]=I.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return I.getBuiltinModule(e)}return ct(e)},"V"),{stripVTControlCharacters:ut}=ft("node:util"),Q=new _(1e3),pt=/[.*+?^${}()|[\]\\]/g,ht=y(e=>{const t=e.join("");if(Q.has(t)){const r=Q.get(t);return r.lastIndex=0,r}const n=e.map(r=>r.replaceAll(pt,String.raw`\$&`)).join("|"),s=new RegExp(n,"g");return Q.set(t,s),s},"Le"),mt=y(e=>{const t=[];let n=0,s;for(U.lastIndex=0;(s=U.exec(e))!==null;)s.index>n&&t.push(e.slice(n,s.index)),t.push(s[0]),n=U.lastIndex;return n<e.length&&t.push(e.slice(n)),t.filter(Boolean)},"Ce"),dt=/[ČŠŽĐ]/i,he=new Uint8Array(128),me=new Uint8Array(128),de=new Uint8Array(128);for(let e=0;e<128;e++)he[e]=e>=65&&e<=90?1:0,me[e]=e>=97&&e<=122?1:0,de[e]=e>=48&&e<=57?1:0;const J=y(e=>he[e],"j"),ae=y(e=>me[e],"O"),K=y(e=>de[e],"w"),W=y((e,t,n,s,r)=>{if(e.length===0)return[];let i=!1;const l=Object.values(t);for(const f of l)if(f(e[0])){i=!0;break}if(!i&&!n)return[e];const a=[...e],h=[];let o=a[0],p="other";const m=Object.entries(t);for(const f of m){const[u,g]=f;if(g(a[0])){p=u;break}}let c=n&&s?a[0]===a[0].toLocaleUpperCase(s):!1;for(let f=1;f<a.length;f++){const u=a[f];let g="other";for(const $ of m){const[v,j]=$;if(j(u)){g=v;break}}const b=n&&s?u===u.toLocaleUpperCase(s):!1;let d=!1;r?d=r(p,g,c,b,u,f,a):(p!==g&&p!=="other"&&g!=="other"&&(d=!0),n&&g!=="other"&&!c&&b&&(d=!0)),d?(h.push(o),o=u):o+=u,p=g,n&&(c=b)}return o&&o.length>0&&h.push(o),h.length>0?h:[e]},"k"),gt=y((e,t,n,s)=>{if(n.size===0)return t;for(const r of n)if(e.startsWith(r,t))return s.push(r),t+r.length;return t},"Ue"),ge=y((e,t=new Set)=>{if(e.length===0)return[];if(e.toUpperCase()===e)return[e];let n=0;const s=[],r=e.length;for(let i=1;i<r;i++){const l=gt(e,n,t,s);if(l!==n){n=l,i=n-1;continue}const a=e.codePointAt(i-1),h=e.codePointAt(i),o=a&&a<128&&J(a),p=h&&h<128&&J(h),m=a&&a<128&&ae(a),c=a&&a<128&&K(a),f=h&&h<128&&K(h);if(m&&p){s.push(e.slice(n,i)),n=i;continue}if(c&&!f||!c&&f){s.push(e.slice(n,i)),n=i;continue}if(f&&!c){let u=!1,g=!1;if(i+1<r){const b=e.codePointAt(i+1);u=b&&b<128&&J(b),g=b&&b<128&&K(b)}if(!g&&u){s.push(e.slice(n,i),e.slice(i,i+1)),n=i+1;continue}}if(i+1<r){const u=e.codePointAt(i+1),g=u&&u<128&&ae(u);if(o&&p&&g){const b=e.slice(n,i+1);t.has(b)||(s.push(e.slice(n,i)),n=i)}}}return n<r&&s.push(e.slice(n)),s.filter(i=>i!=="")},"D"),be=y((e,t,n)=>{if(e.length===0)return[];const s=e===e.toLocaleUpperCase(t);if(t.startsWith("de")){if(!s&&e.replaceAll("ß","SS")===e.toLocaleUpperCase(t))return[e];const o=[...e],p=o.length,m=[];let c=o[0],f=o[0]===o[0].toLocaleUpperCase(t),u=f,g=f?0:-1;for(let b=1;b<p;b++){const d=o[b],$=d===d.toLocaleUpperCase(t);if($===f)c+=d;else if($)c&&c.length>0&&(m.push(c),c=d),u=!0,g=b;else{if(u&&b-g>1){const v=o[b-1],j=c.slice(0,-1);j&&j.length>0&&m.push(j),c=v+d}else c+=d;u=!1,g=-1}f=$}return c&&c.length>0&&m.push(c),m}if(t.startsWith("uk")||t.startsWith("ru")||t.startsWith("bg")||t.startsWith("sr")||t.startsWith("mk")||t.startsWith("be")){if(!T.test(e)&&!A.test(e))return[e];const o=[...e],p=o.length,m=[];let c=o[0];const f=o[0];let u;T.test(f)?u=1:A.test(f)?u=2:u=0;let g=f===f.toLocaleUpperCase(t);for(let d=1;d<p;d++){const $=o[d];let v;T.test($)?v=1:A.test($)?v=2:v=0;const j=$===$.toLocaleUpperCase(t);u!==v&&(u===1||u===2)&&(v===1||v===2)||v===u&&!g&&j?(m.push(c),c=$):c+=$,u=v,g=j}c&&c.length>0&&m.push(c);const b=[];for(let d=0;d<m.length;d++)d<m.length-1&&m[d].length===1&&A.test(m[d])&&T.test(m[d+1][0])?(b.push(m[d]+m[d+1]),d+=1):b.push(m[d]);return b}if(t.startsWith("el")){if(!G.test(e)&&!A.test(e))return[e];const o=[];te.lastIndex=0;let p;for(;(p=te.exec(e))!==null;)o.push(p[0]);o.length===0&&o.push(e);const m=[];if(o.length===1){const c=o[0];if(!c||!G.test(c[0])||c.length===1)return[c??e]}for(const c of o){if(!c)continue;if(!G.test(c[0])||c.length===1){m.push(c);continue}const f=c.length;let u=c[0],g=c[0]===c[0].toLocaleUpperCase(t);for(let b=1;b<f;b++){const d=c[b],$=d===d.toLocaleUpperCase(t);!g&&$?(m.push(u),u=d):u+=d,g=$}u&&m.push(u)}return m}if(t.startsWith("ja")||t.startsWith("ko")){const o=t.startsWith("ja"),p=o?{hiragana:y(c=>Te.test(c),"hiragana"),kanji:y(c=>ne.test(c),"kanji"),katakana:y(c=>Pe.test(c),"katakana"),latin:y(c=>A.test(c),"latin")}:{hangul:y(c=>se.test(c),"hangul"),latin:y(c=>A.test(c),"latin")},m=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(o){const c=W(e,p,!1,t,(u,g)=>u==="hiragana"&&g==="katakana"||u==="katakana"&&g==="hiragana"||u==="hiragana"&&g==="latin"||u==="katakana"&&g==="latin"||u==="kanji"&&g==="latin"||u==="latin"&&(g==="hiragana"||g==="katakana"||g==="kanji")),f=[];for(const u of c){const g=u;g.length===1&&m.has(g)&&f.length>0?f[f.length-1]=f.at(-1)+g:f.push(g)}return f.length>0?f:[e]}return W(e,p,!1,t,(c,f)=>c==="hangul"&&f==="latin"||c==="latin"&&f==="hangul")}if(t.startsWith("sl")){const o=[...e],p=o.length,m=[];let c=o[0],f=o[0]===o[0].toLocaleUpperCase(t);for(let u=1;u<p;u++){const g=o[u],b=g===g.toLocaleUpperCase(t),d=dt.test(g),$=u<p-1&&o[u+1]===o[u+1].toLocaleUpperCase(t);!f&&b||d&&$?(m.push(c),c=g,d&&$&&(m.push(c),c="")):c+=g,f=b}return c&&c.length>0&&m.push(c),m}if(t.startsWith("zh"))return W(e,{han:y(o=>ne.test(o),"han"),latin:y(o=>A.test(o),"latin")},!1,t);if(["ar","fa","he","ur"].includes(t.split("-")[0])){const o=y(p=>re.test(p)||ie.test(p),"s");return W(e,{latin:y(p=>A.test(p),"latin"),rtl:y(p=>o(p),"rtl")},!1,t)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(t.split("-")[0])){const o=y(p=>ze.test(p)||Me.test(p)||Ie.test(p)||Re.test(p)||Fe.test(p)||Ne.test(p)||Be.test(p)||qe.test(p)||De.test(p)||Ve.test(p)||Ge.test(p)||Qe.test(p)||Je.test(p)||Ke.test(p)||He.test(p)||Ye.test(p),"s");return W(e,{indic:y(p=>o(p),"indic"),latin:y(p=>A.test(p),"latin")},!1,t)}if(["be","bg","ru","sr","uk"].includes(t))return W(e,{cyrillic:y(o=>T.test(o),"cyrillic"),latin:y(o=>A.test(o),"latin")},!0,t);if(["ar","fa","he"].includes(t))return W(e,{latin:y(o=>A.test(o),"latin"),rtl:y(o=>re.test(o)||ie.test(o),"rtl")},!1,t);if(t.startsWith("ko"))return W(e,{hangul:y(o=>se.test(o),"hangul"),latin:y(o=>A.test(o),"latin")},!1,t);if(t.startsWith("uz")){if(!T.test(e)&&!A.test(e))return[e];const o=[...e],p=o.length,m=[];let c=o[0],f=o[0]===o[0].toLocaleUpperCase(t);for(let u=1;u<p;u++){const g=o[u],b=g===g.toLocaleUpperCase(t);if(oe.test(g)||oe.test(o[u-1])){c+=g;continue}!f&&b?(m.push(c),c=g):c+=g,f=b}return c&&c.length>0&&m.push(c),m}const r=[...e],i=r.length,l=[];let a=r[0],h=r[0]===r[0].toLocaleUpperCase(t);for(const o of n)if(e.startsWith(o)){l.push(o),a=r[o.length],h=a===a.toLocaleUpperCase(t);break}for(let o=1;o<i;o++){const p=r[o],m=p===p.toLocaleUpperCase(t);let c=0;for(const f of n)if(e.startsWith(f,o)){l.push(a,f),c=f.length,a="";const u=f.at(-1);u&&(h=u===u.toLocaleUpperCase(t));break}if(c>0){o+=c-1;continue}!h&&m?(l.push(a),a=p):a+=p,h=m}return a&&l.push(a),l},"q"),bt=y((e,t,n)=>{const s=[],r=S.test(e)?e.split(S).filter(Boolean):[e];for(const i of r){const l=i;if(S.test(l))s.push(l);else{U.lastIndex=0;const a=U.test(l)?mt(l).filter(Boolean):[l];for(const h of a)if(U.lastIndex=0,U.test(h))s.push(h);else if(t){const o=t.toLowerCase().split("-")[0];s.push(...be(h,o,n))}else s.push(...ge(h,n))}}return s},"Ie"),q=y((e,t={})=>{if(!e||typeof e!="string")return[];const{handleAnsi:n=!1,handleEmoji:s=!1,knownAcronyms:r=[],locale:i,normalize:l=!1,separators:a,stripAnsi:h=!1,stripEmoji:o=!1}=t,p=new Set([...r].toSorted((d,$)=>$.length-d.length));let m=e;h&&(m=ut(m)),o&&(m=Xe(m));let c;Array.isArray(a)?c=ht(a):a instanceof RegExp?c=a:c=Ze;const f=[];let u=m;const g=c.flags.includes("g")?c:new RegExp(c.source,`${c.flags}g`);for(;u.length>0;){const d=g.exec(u);if(!d){u===".."?f.push(".."):u==="."?f.push("."):u.length>0&&f.push(u);break}const $=d.index,v=d[0],j=v.length,F=u.slice(0,$),Oe=u.slice($+j);if(v.startsWith("../"))f.push(".."),u=u.slice($+3);else if(v.startsWith("./"))f.push("."),u=u.slice($+2);else if($===0&&v==="..")f.push(".."),u=u.slice(2);else if($===0&&v===".")f.push("."),u=u.slice(1);else{F.length>0&&f.push(F);let L=0;for(;(L=v.indexOf("../",L))!==-1;)f.push(".."),L+=3;for(L=0;(L=v.indexOf("./",L))!==-1;)(L===0||v[L-1]!==".")&&f.push("."),L+=2;let O=Oe;for(;O.startsWith("../");)f.push(".."),O=O.slice(3);for(;O.startsWith("./");)f.push("."),O=O.slice(2);if(O===".."){f.push("..");break}else if(O==="."){f.push(".");break}else u=O}g.lastIndex=0}if(f.length===0){const d=m.split(c).filter(Boolean);f.push(...d)}let b=[];for(const d of f)n||s?b.push(...bt(d,i,p)):i?b.push(...be(d,i,p)):b.push(...ge(d,p));return l&&(b=b.map(d=>p.has(d)?d:i&&d===d.toLocaleUpperCase(i)?d[0]+d.slice(1).toLocaleLowerCase(i):d.toUpperCase()===d&&!p.has(d)?d.slice(0,1)+d.slice(1).toLowerCase():d)),b},"be");var yt=Object.defineProperty,$t=k((e,t)=>yt(e,"name",{value:t,configurable:!0}),"l$4");const X=$t((e,t)=>typeof e!="string"||e===""?"":(t?.locale?e[0].toLocaleUpperCase(t.locale):e[0].toUpperCase())+e.slice(1),"a");var vt=Object.defineProperty,wt=k((e,t)=>vt(e,"name",{value:t,configurable:!0}),"r$2");const D=wt((e,t)=>`${e}::${t?.joiner??""}::${t?.locale??""}::${t?.knownAcronyms?.join(",")??""}::${t?.normalize?"true":"false"}`,"r");var jt=Object.defineProperty,kt=k((e,t)=>jt(e,"name",{value:t,configurable:!0}),"p$4");const V=kt((e,t)=>{const{length:n}=e;if(n===0)return"";if(n===1)return e[0];const s=[];let r="",i="";for(let l=0;l<n;l++){const a=e[l];if(S.test(a)){r?(s.push(r+i+a),r="",i=""):(s.length>0&&s.push(t),r=a);continue}r?(i&&(i+=t),i+=a):(s.length>0&&s.push(t),s.push(a))}return s.join("")},"p");var At=Object.defineProperty,Ct=k((e,t)=>At(e,"name",{value:t,configurable:!0}),"e$1");const xt=/(?<![a-zß])SS(?![a-z])/g,Z=Ct(e=>e.replaceAll(xt,"ß"),"l");var Et=Object.defineProperty,Lt=k((e,t)=>Et(e,"name",{value:t,configurable:!0}),"p$2");const Ot=new _(1e3),Wt=Lt((e,t)=>{if(typeof e!="string"||!e)return"";const n=t?.cache??!1,s=t?.cacheStore??Ot;let r;if(n&&(r=D(e,t)),n&&r&&s.has(r))return s.get(r);let i=!0;const l=V(q(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(a=>{if(t?.handleAnsi&&S.test(a))return a;const h=t?.locale?.startsWith("de")?Z(a):a,o=t?.locale?h.toLocaleLowerCase(t.locale):h.toLowerCase();return i?(i=!1,at(o,t)):X(o,t)}),"");return n&&r&&s.set(r,l),l},"R");var Ut=Object.defineProperty,St=k((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"l$2");const _t=new _(1e3),ee=St((e,t)=>{if(typeof e!="string")return"";const n=t?.cache??!1,s=t?.cacheStore??_t;let r;if(n&&(r=D(e,t)),n&&r&&s.has(r))return s.get(r);const i=q(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(a=>{if(t?.handleAnsi&&S.test(a))return a;if(t?.toUpperCase)return t.locale?a.toLocaleUpperCase(t.locale):a.toUpperCase();const h=t?.locale?.startsWith("de")?Z(a):a;return t?.locale?h.toLocaleLowerCase(t.locale):h.toLowerCase()}),l=V(i,t?.joiner??"-");return n&&r&&s.set(r,l),l},"L");var Pt=Object.defineProperty,Tt=k((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"r$1");const zt=new _(1e3),Mt=Tt((e,t)=>ee(e,{cacheStore:zt,...t,joiner:"_",toUpperCase:!0}),"m");var It=Object.defineProperty,Rt=k((e,t)=>It(e,"name",{value:t,configurable:!0}),"l$1");const Ft=new _(1e3),Nt=Rt((e,t)=>{if(typeof e!="string"||!e)return"";const n=t?.cache??!1,s=t?.cacheStore??Ft;let r;if(n&&(r=D(e,t)),n&&r&&s.has(r))return s.get(r);const i=V(q(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(l=>{if(t?.handleAnsi&&S.test(l))return l;const a=t?.locale?.startsWith("de")?Z(l):l;return X(t?.locale?a.toLocaleLowerCase(t.locale):a.toLowerCase(),{locale:t?.locale})}),"");return n&&r&&s.set(r,i),i},"L");var Bt=Object.defineProperty,qt=k((e,t)=>Bt(e,"name",{value:t,configurable:!0}),"r");const Dt=new _(1e3),Vt=qt((e,t)=>ee(e,{cacheStore:Dt,...t,joiner:"_"}),"n");var Gt=Object.defineProperty,Qt=k((e,t)=>Gt(e,"name",{value:t,configurable:!0}),"a$1");const Jt=new _(1e3),Kt=Qt((e,t)=>{if(typeof e!="string")return"";const n=t?.cache??!1,s=t?.cacheStore??Jt;let r;if(n&&(r=D(e,t)),n&&r&&s.has(r))return s.get(r);const i=V(q(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(l=>X(l,{locale:t?.locale})),"-");return n&&r&&s.set(r,i),i},"y");var Ht=Object.defineProperty,C=k((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"e");const x=C(e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),"stringify"),H={camel_case:C(e=>Wt(x(e)),"camel_case"),kebab_case:C(e=>ee(x(e)),"kebab_case"),lower_case:C(e=>x(e).toLowerCase(),"lower_case"),pascal_case:C(e=>Nt(x(e)),"pascal_case"),path_join:C((e,...t)=>{const n=[x(e),...t.map(s=>x(s))];return pe(...n)},"path_join"),path_relative:C((e,t)=>ue(x(t),x(e)),"path_relative"),snake_case:C(e=>Vt(x(e)),"snake_case"),upper_case:C(e=>x(e).toUpperCase(),"upper_case"),upper_kebab_case:C(e=>Kt(x(e)),"upper_kebab_case"),upper_snake_case:C(e=>Mt(x(e)),"upper_snake_case")};C(e=>Object.hasOwn(H,e),"isKnownFilter");const ye=C((e,t,n=[])=>{const s=H[e];if(!s)throw new Error(`Unknown filter "${e}". Known filters: ${Object.keys(H).sort().join(", ")}.`);return s(t,...n)},"applyFilter");var Yt=Object.defineProperty,$e=k((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"d$1");const ve=$e(e=>{const t=[];let n=0,s=0,r,i=-1;for(const l of e){if(i+=1,r){l===r&&(r=void 0);continue}if(l==='"'||l==="'"){r=l;continue}l==="("?n+=1:l===")"?n-=1:l===","&&n===0&&(t.push(e.slice(s,i)),s=i+1)}return t.push(e.slice(s)),t},"splitCommaOutsideQuotes"),Xt=$e(e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},"stripQuotes");var Zt=Object.defineProperty,P=k((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"s$1");const en=/\[([^\]]+)\]/g,tn=P(e=>{const t=e.trim(),n=t.indexOf("(");if(n===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const s=t.slice(0,n).trim(),r=t.slice(n+1,-1).trim();return r===""?{args:[],name:s}:{args:ve(r).map(i=>{const l=i.trim();return Xt(l)??l}),name:s}},"parseFilterCall"),nn=P(e=>{const t=e.split("|").map(s=>s.trim()),n=t[0]??"";if(!n)throw new Error(`Empty variable name in expression "${e}"`);return{filters:t.slice(1).map(s=>tn(s)),name:n}},"parsePipe"),sn=P(e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),"stringify"),rn=P((e,t)=>{const n=e.replaceAll(en,(s,r)=>{const{filters:i,name:l}=nn(r);if(!Object.hasOwn(t,l))throw new Error(`Variable "${l}" used in filename "${e}" but not defined`);let a=t[l];for(const h of i)a=ye(h.name,a,h.args);return sn(a)});return we(n)},"interpolateFilename"),we=P(e=>e.split("/").map(t=>t.endsWith(".tera")||t.endsWith(".twig")?t.slice(0,-5):t).join("/"),"stripTeraSuffix"),on=P(e=>e.endsWith(".raw")?e.slice(0,-4):e,"stripRawSuffix"),an=P(e=>{const t=e.split("/");return(t.at(-1)??"").startsWith("_")?!0:t.slice(0,-1).includes("partials")},"isPartialPath");var ln=Object.defineProperty,cn=k((e,t)=>ln(e,"name",{value:t,configurable:!0}),"i");const fn=cn((e,t)=>{if(!e.startsWith(`---
2
+ `)&&!e.startsWith(`---\r
3
+ `))return{body:e};const n=e.indexOf(`
4
+ ---`,3);if(n===-1)return{body:e};let s=n+1+3;e[s]==="\r"&&(s+=1),e[s]===`
5
+ `&&(s+=1);const r=e.startsWith(`---\r
6
+ `)?5:4,i=e.slice(r,n).replaceAll("\r","");let l;try{l=t(i)}catch(a){const h=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse frontmatter YAML: ${h}`,{cause:a})}if(l==null)return{body:e.slice(s)};if(typeof l!="object"||Array.isArray(l))throw new TypeError(`Frontmatter must be a YAML mapping, got ${Array.isArray(l)?"array":typeof l}`);return{body:e.slice(s),frontmatter:l}},"splitFrontmatter");var un=Object.defineProperty,w=k((e,t)=>un(e,"name",{value:t,configurable:!0}),"c");const pn=/\{\{-?(.+?)-?\}\}|\{%-?(.+?)-?%\}/gs,je=w(e=>{const t=[];let n=0,s=1;const r=w(i=>{for(const l of i)l===`
7
+ `&&(s+=1)},"advanceLine");for(const i of e.matchAll(pn)){const l=i.index??0;if(l>n){const o=e.slice(n,l);t.push({line:s,type:"text",value:o}),r(o)}const a=s,h=i[0];h.startsWith("{{")?t.push({line:a,type:"expr",value:(i[1]??"").trim()}):t.push({line:a,type:"stmt",value:(i[2]??"").trim()}),r(h),n=l+h.length}if(n<e.length){const i=e.slice(n);t.push({line:s,type:"text",value:i})}return t},"tokenize"),hn=new Set(["block","endblock","endfilter","endmacro","extends","filter","import","macro","set"]),ke=w((e,t)=>{let n=0;const s=w((i,l)=>{throw new Error(`${t}:${i}: ${l}`)},"error"),r=w(i=>{const l=[];for(;n<e.length;){const a=e[n];if(a.type==="text"){l.push({type:"text",value:a.value}),n+=1;continue}if(a.type==="expr"){l.push({expression:a.value,line:a.line,type:"expr"}),n+=1;continue}const h=a.value.split(/\s+/)[0]??"";if(i.includes(h))return l;if(hn.has(h)&&s(a.line,`Tera feature "{% ${h} %}" is not supported. Supported: if/else/endif, for/endfor, include. Rewrite the template to avoid macros, set, extends, block, and import.`),h==="if"){n+=1;const o=a.value.slice(2).trim(),p=r(["else","endif"]);let m;n<e.length&&e[n].type==="stmt"&&e[n].value.split(/\s+/)[0]==="else"&&(n+=1,m=r(["endif"])),(n>=e.length||e[n].type!=="stmt"||e[n].value.split(/\s+/)[0]!=="endif")&&s(a.line,"Unterminated {% if %} — missing {% endif %}"),n+=1,l.push({alternate:m,condition:o,consequent:p,line:a.line,type:"if"});continue}if(h==="for"){n+=1;const o=a.value.slice(3).trim(),p=o.indexOf(" in ");p===-1&&s(a.line,"Malformed {% for %} — expected `for <name> in <collection>`");const m=o.slice(0,p).trim(),c=o.slice(p+4).trim();(!m||!c)&&s(a.line,"Malformed {% for %} — missing binding or collection");const f=r(["endfor"]);(n>=e.length||e[n].type!=="stmt"||e[n].value.split(/\s+/)[0]!=="endfor")&&s(a.line,"Unterminated {% for %} — missing {% endfor %}"),n+=1,l.push({binding:m,body:f,collection:c,line:a.line,type:"for"});continue}if(h==="include"){n+=1;const o=a.value.slice(7).trim(),p=Ae(o);p===void 0&&s(a.line,"Malformed {% include %} — expected a quoted partial name"),l.push({line:a.line,name:p,type:"include"});continue}s(a.line,`Unknown tag "{% ${h} %}". Supported: if, for, include.`)}return l},"parseBlock");return r([])},"parse"),Ae=w(e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},"stripQuotes"),mn=w(e=>e==null?"":typeof e=="boolean"||typeof e=="number"?String(e):typeof e=="string"?e:JSON.stringify(e),"stringify"),dn=w(e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:!0,"isTruthy"),Ce=w((e,t,n,s,r=!0)=>{const i=e.split(".");if(r&&i.length>0&&!Object.hasOwn(t,i[0]))throw new Error(`${s}:${n}: Variable "${e}" is not defined`);let l=t;for(const a of i){if(l==null)return;if(typeof l!="object")throw new TypeError(`${s}:${n}: Cannot read "${a}" on non-object value`);l=l[a]}return l},"lookupVariable"),gn=w(e=>{const t=[];let n=0,s=0,r;for(let i=0;i<e.length;i+=1){const l=e[i];if(r){l===r&&(r=void 0);continue}if(l==='"'||l==="'"){r=l;continue}l==="("?n+=1:l===")"?n-=1:l==="|"&&n===0&&(t.push(e.slice(s,i)),s=i+1)}return t.push(e.slice(s)),t},"splitFilterPipe"),bn=w(e=>{const t=e.trim(),n=t.indexOf("(");if(n===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const s=t.slice(0,n).trim(),r=t.slice(n+1,-1).trim();return r?{args:ve(r).map(i=>i.trim()),name:s}:{args:[],name:s}},"parseFilterCall"),B=w((e,t,n,s,r=!0)=>{const i=e.trim();if(i==="true")return!0;if(i==="false")return!1;if(i==="null"||i==="none")return null;const l=Ae(i);return l!==void 0?l:/^-?\d+(?:\.\d+)?$/.test(i)?Number(i):Ce(i,t,n,s,r)},"evaluatePrimary"),xe=w((e,t,n,s,r=!0)=>{const i=gn(e),l=i[0].trim();let a=B(l,t,n,s,r);for(let h=1;h<i.length;h+=1){const o=i[h].trim(),{args:p,name:m}=bn(o),c=p.map(f=>B(f,t,n,s,r));try{a=ye(m,a,c)}catch(f){const u=f instanceof Error?f.message:String(f);throw new Error(`${s}:${n}: ${u}`,{cause:f})}}return a},"evaluateExpression"),Ee=w((e,t)=>{let n,s=0;for(let r=0;r<=e.length-t.length;r+=1){const i=e[r];if(n){i===n&&(n=void 0);continue}if(i==='"'||i==="'"){n=i;continue}if(i==="("){s+=1;continue}if(i===")"){s-=1;continue}if(s===0&&e.slice(r,r+t.length)===t)return r}return-1},"findOperatorOutsideQuotes"),le=w((e,t)=>{const n=[];let s=0,r=0;for(;r<=e.length-t.length;){const i=Ee(e.slice(r),t);if(i===-1)break;n.push(e.slice(s,r+i)),r+=i+t.length,s=r}return n.push(e.slice(s)),n},"splitLogical"),z=w((e,t,n,s)=>{const r=e.trim();if(r==="")return!1;if(r.startsWith("(")&&r.endsWith(")")&&yn(r)===r.length-1)return z(r.slice(1,-1),t,n,s);const i=le(r," or ");if(i.length>1)return i.some(a=>z(a,t,n,s));const l=le(r," and ");if(l.length>1)return l.every(a=>z(a,t,n,s));if(r.startsWith("not "))return!z(r.slice(4),t,n,s);for(const a of["==","!="]){const h=Ee(r,a);if(h!==-1){const o=B(r.slice(0,h),t,s,n,!1),p=B(r.slice(h+a.length),t,s,n,!1),m=o===p;return a==="=="?m:!m}}return dn(xe(r,t,s,n,!1))},"evaluateConditionExpression"),yn=w(e=>{if(e[0]!=="(")return-1;let t=0,n,s=-1;for(const r of e){if(s+=1,n){r===n&&(n=void 0);continue}if(r==='"'||r==="'"){n=r;continue}if(r==="(")t+=1;else if(r===")"&&(t-=1,t===0))return s}return-1},"matchingParen"),R=w((e,t)=>{let n="";for(const s of e){if(s.type==="text"){n+=s.value;continue}if(s.type==="expr"){n+=mn(xe(s.expression,t.scope,s.line,t.filename));continue}if(s.type==="if"){const r=z(s.condition,t.scope,t.filename,s.line)?s.consequent:s.alternate??[];n+=R(r,t);continue}if(s.type==="for"){const r=Ce(s.collection,t.scope,s.line,t.filename,!1);if(r==null)continue;if(!Array.isArray(r))throw new TypeError(`${t.filename}:${s.line}: {% for %} expected an array, got ${typeof r}`);for(const i of r){const l={...t.scope,[s.binding]:i};n+=R(s.body,{...t,scope:l})}continue}if(s.type==="include"){const r=t.partials?.get(s.name);if(!r)throw new Error(`${t.filename}:${s.line}: Partial "${s.name}" not found. Available: ${[...t.partials?.keys()??[]].join(", ")||"(none)"}`);const i=t.includeStack??new Set;if(i.has(s.name)){const l=[...i,s.name].join(" → ");throw new Error(`${t.filename}:${s.line}: Circular partial include detected: ${l}`)}i.add(s.name);try{n+=R(r,{...t,filename:`<partial:${s.name}>`,includeStack:i})}finally{i.delete(s.name)}}}return n},"renderNodes"),$n=w((e,t)=>ke(je(e),t),"parseTemplate");w((e,t)=>R(e,t),"renderAst");const Y=w((e,t)=>R(ke(je(e),t.filename),t),"renderTemplate");var vn=Object.defineProperty,E=k((e,t)=>vn(e,"name",{value:t,configurable:!0}),"s");const ce="template.yml",wn=".raw",jn=new Set([".cjs",".css",".env",".gitattributes",".gitignore",".graphql",".html",".ini",".js",".json",".json5",".jsonc",".jsx",".lock",".md",".mdx",".mjs",".prettierrc",".raw",".rs",".scss",".sh",".sql",".svg",".tera",".toml",".ts",".tsx",".twig",".txt",".vue",".xml",".yaml",".yml"]),kn=new Set(["Brewfile","CHANGELOG","CODEOWNERS","CONTRIBUTING","COPYING","Dockerfile","Gemfile","LICENCE","LICENSE","Makefile","NOTICE","Procfile","Rakefile","README","VERSION"]),An=E(e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),n=t===-1?e:e.slice(t+1),s=n.lastIndexOf(".");return s===-1||s===0?"":n.slice(s).toLowerCase()},"lastDot"),Le=E(e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?e:e.slice(t+1)},"basename"),Cn=E(e=>{const t=An(e);if(t!=="")return jn.has(t);const n=Le(e);return kn.has(n)},"isLikelyText"),xn=E(e=>{const t={default:e.default,internal:e.internal,order:e.order,prompt:e.prompt,required:e.required};switch(e.type){case"array":return{...t,type:"array"};case"boolean":return{...t,default:typeof t.default=="boolean"?t.default:void 0,type:"boolean"};case"enum":return{...t,multiple:e.multiple,type:"enum",values:e.values??[]};case"number":return{...t,type:"number"};case"string":return{...t,type:"string"};default:throw new Error(`Unsupported variable type "${String(e.type)}"`)}},"yamlVariableToVariable"),En=E(e=>e.replaceAll("\\","/").replace(/^\.\//,"").replaceAll(/\/+/g,"/"),"normalizeDestinationPath"),Ln=E((e,t,n)=>{const s=t.split("/").filter(Boolean);if(s.length===0)throw new Error("Empty destination path for value");let r=e;for(let i=0;i<s.length-1;i+=1){const l=s[i],a=r[l];if(a===void 0){const h={};r[l]=h,r=h}else if(typeof a=="object"&&!Buffer.isBuffer(a))r=a;else throw new TypeError(`Path conflict: "${s.slice(0,i+1).join("/")}" is both a file and a directory`)}r[s.at(-1)]=n},"flattenFiles"),fe=E((e,t,n)=>{if(typeof e!="string")return On(e);const s=e.includes("{{")||e.includes("{%")?Y(e,{filename:`${n}#frontmatter`,scope:t}):e;return z(s,t,`${n}#frontmatter`,1)},"evaluateGate"),On=E(e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e!=="false"&&e!=="0":!0,"truthyValue"),Tn=E((e,t)=>{const n=pe(e,ce),s=et(n);if(!s||typeof s!="object")throw new Error(`${n}: must contain a YAML mapping`);const r={};if(s.variables)for(const[h,o]of Object.entries(s.variables))r[h]=xn(o);const i=new Map,l=[];for(const h of tt(e,{includeDirs:!1,includeSymlinks:!1})){if(h.path===n)continue;const o=ue(e,h.path).replaceAll("\\","/");if(o===ce)continue;if(an(o)){const m=N(h.path),c=$n(m,o);for(const f of Wn(o))i.has(f)&&i.get(f)!==c&&nt.warn(`partial name "${f}" is declared by multiple files — last one wins. Use distinct names or fully-qualified includes.`),i.set(f,c);continue}if(o.endsWith(wn)){const m=N(h.path);l.push({binary:null,isRaw:!0,rawText:m,relativePath:o});continue}if(Cn(o)){const m=N(h.path);l.push({binary:null,isRaw:!1,rawText:m,relativePath:o});continue}const p=N(h.path,{buffer:!0});l.push({binary:p,isRaw:!1,rawText:null,relativePath:o})}const a=E(h=>{const o={...h.builtins,...h.options},p={},m={};for(const f of l){const u=f.relativePath;let g,b,d=!1;if(f.binary)g=f.binary;else if(f.isRaw)g=f.rawText??"";else{const v=f.rawText??"",j=fn(v,F=>st(F));if(j.frontmatter){if(j.frontmatter.skip!==void 0&&fe(j.frontmatter.skip,o,u)||j.frontmatter.if!==void 0&&!fe(j.frontmatter.if,o,u))continue;typeof j.frontmatter.to=="string"&&(b=Y(j.frontmatter.to,{filename:`${u}#frontmatter.to`,partials:i,scope:o})),j.frontmatter.force===!0&&(d=!0)}g=Y(j.body,{filename:u,partials:i,scope:o})}const $=En(b??rn(on(u),o));Ln(p,$,g),d&&(m[$]={force:!0})}const c={files:p};return Object.keys(m).length>0&&(c.filesMeta=m),c},"produce");return{about:{description:s.description??`Moon-format template at ${e}`,name:s.title??t},destination:s.destination,options:r,produce:a}},"loadMoonTemplate"),Wn=E(e=>{const t=we(e),n=Le(t),s=new Set([n,t]);if(n.startsWith("_")){s.add(n.replace(/^_+/,""));const r=t.slice(0,t.length-n.length);s.add(`${r}${n.replace(/^_+/,"")}`)}return[...s]},"partialKeys");export{Tn as loadMoonTemplate};
@@ -0,0 +1,4 @@
1
+ var i=Object.defineProperty;var a=(r,e)=>i(r,"name",{value:e,configurable:!0});import{p as s}from"./bin.js";import{c as o,f as c}from"../packem_shared/registry-keys-Mixm4eAY.js";var n=Object.defineProperty,f=a((r,e)=>n(r,"name",{value:e,configurable:!0}),"n");const g=f(async({options:r})=>{if(r.clear){const t=o();if(r.json){process.stdout.write(`${JSON.stringify({cleared:t,refetched:!1},void 0,2)}
2
+ `);return}s.success(t?"Cleared cached npm signing keys.":"No cached npm signing keys to clear.");return}const e=await c({forceRefresh:!0});if(e===void 0){if(r.json){process.stdout.write(`${JSON.stringify({cleared:!1,error:"fetch-failed",refetched:!1},void 0,2)}
3
+ `),process.exitCode=1;return}s.error("Failed to fetch npm signing keys (network error and no cached keys available)."),process.exitCode=1;return}if(r.json){process.stdout.write(`${JSON.stringify({cleared:!1,fromCache:e.fromCache,keyCount:e.keys.length,refetched:!e.fromCache,stale:e.stale??!1},void 0,2)}
4
+ `);return}if(e.fromCache&&e.stale===!0){s.warn(`Network fetch failed — falling back to expired cache (${String(e.keys.length)} keys).`);return}s.success(`Refreshed npm signing keys (${String(e.keys.length)} keys).`)},"execute");export{g as default};
@@ -0,0 +1,3 @@
1
+ var x=Object.defineProperty;var w=(t,s)=>x(t,"name",{value:s,configurable:!0});import{createRequire as B}from"node:module";import{ah as P,p as o,ai as R}from"./bin.js";import{A as V}from"../packem_shared/pm-runner-DmKT2FqF.js";import{x as C}from"../packem_shared/build-scripts-DE6U8jVq.js";import{M as y,l as k}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{s as q}from"./config.js";const D=B(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=w(t=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[s,f]=v.versions.node.split(".").map(Number);if(s>22||s===22&&f>=3||s===20&&f>=16)return v.getBuiltinModule(t)}return D(t)},"__cjs_getBuiltinModule"),{readdirSync:j,statSync:O}=M("node:fs");var A=Object.defineProperty,_=w((t,s)=>A(t,"name",{value:s,configurable:!0}),"p$1");const N=_((t,s={})=>{const f=y(t,"node_modules");if(!k(f))return[];const l=new Map,p=new Set,b=_((n,i,a)=>{const e=`${i}@${a}`;if(p.has(e))return;p.add(e);const r=a.startsWith(t)?a.slice(t.length+1):a;let u=l.get(n);u||(u=[],l.set(n,u)),u.some($=>$.name===i)||u.push({name:i,relativePath:r})},"recordBin"),m=_((n,i="")=>{let a;try{a=j(n)}catch{return}for(const e of a){const r=y(n,e);if(e.startsWith("@")){m(r,`${e}/`);continue}if(e===".pnpm"&&i===""){let c;try{c=j(r)}catch{continue}for(const d of c){const h=y(r,d,"node_modules");k(h)&&m(h)}continue}if(e.startsWith("."))continue;const u=i+e,$=y(r,"package.json");try{if(!O(r).isDirectory()||!k($))continue;const c=q($),d=typeof c.name=="string"?c.name:u;if(typeof c.bin=="string"){const S=d.includes("/")?d.split("/").pop():d;b(S,d,r)}else if(c.bin&&typeof c.bin=="object")for(const S of Object.keys(c.bin))b(S,d,r);const h=y(r,"node_modules");k(h)&&m(h)}catch{}}},"scanDir");m(f);const g=[];for(const[n,i]of l)i.length<2||s[n]===!0||i.every(a=>s[`${a.name}#${n}`]===!0)||g.push({bin:n,packages:i});return g.sort((n,i)=>n.bin.localeCompare(i.bin))},"collectBinShadows");var T=Object.defineProperty,W=w((t,s)=>T(t,"name",{value:s,configurable:!0}),"p");const U=new Set(["bun","npm","pnpm","yarn"]),K=W(({options:t,visConfig:s,workspaceRoot:f})=>{const l=f??process.cwd(),p=V(l),b=s?.security?.policies?.installScripts?.allow??{},m=s?.security?.allowBins??{},g=s?.security?.pinVersions===!0,n=C(l,b,{pinVersions:g}),i=N(l,m),a=s&&U.has(p.name)?P(s,p.name,l):void 0;if(t.json){process.stdout.write(`${JSON.stringify({binConflicts:i,drift:a,excess:n.excess,installed:n.installed.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),packageManager:p.name,pinVersions:g,unapproved:n.unapproved.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),versionDrift:n.versionDrift},void 0,2)}
2
+ `);return}if(o.info(`Build-script status (${p.name}):
3
+ `),n.installed.length===0&&n.unapproved.length===0&&o.success(" No installed packages declare lifecycle scripts."),n.installed.length>0){o.success(` Approved (${String(n.installed.length)}):`);for(const e of n.installed)o.info(` ✓ ${e.name} — ${e.hooks.join(", ")}`)}if(n.unapproved.length>0){o.info(""),o.warn(` Unapproved (${String(n.unapproved.length)}):`);for(const e of n.unapproved)o.info(` ✗ ${e.name} — ${e.hooks.join(", ")}`);o.notice(" Run 'vis approve-builds' to review.")}if(n.excess.length>0){o.info(""),o.warn(` Stale allowlist entries (${String(n.excess.length)}):`);for(const e of n.excess)o.info(` ! ${e}`);o.notice(" Remove these from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){o.info(""),o.warn(` Version drift (pinVersions: true) — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} point at outdated versions:`);for(const{from:e,to:r}of n.versionDrift)o.info(` ${e} → ${r}`);o.notice(" Update vis.config.ts security.policies.installScripts.allow keys to migrate.")}if(i.length>0){o.info(""),o.warn(` Bin conflicts (${String(i.length)}) — multiple packages expose the same bin name:`);for(const e of i)o.info(` ${e.bin} ← ${e.packages.map(r=>r.name).join(", ")}`);o.notice(" Add the bin (or 'pkg#bin') to vis.config.ts security.allowBins to silence this.")}if(a?.hasDrift){o.info("");for(const e of R(a))o.warn(e)}},"execute");export{K as default};
@@ -0,0 +1,4 @@
1
+ var w=Object.defineProperty;var c=(e,t)=>w(e,"name",{value:t,configurable:!0});import{createRequire as y}from"node:module";import{A as m,P as $}from"../packem_shared/pm-runner-DmKT2FqF.js";const _=y(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=c(e=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[t,s]=a.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return a.getBuiltinModule(e)}return _(e)},"__cjs_getBuiltinModule"),{createInterface:I}=v("node:readline");var h=Object.defineProperty,o=c((e,t)=>h(e,"name",{value:t,configurable:!0}),"n");const r="sigstore",b=o(()=>!!process.stdout.isTTY&&process.env.CI!=="true","isInteractive"),O=o(e=>new Promise(t=>{const s=I({input:process.stdin,output:process.stderr});s.question(`${e} (Y/n) `,i=>{s.close();const n=i.trim().toLowerCase();t(n===""||n==="y"||n==="yes")})}),"defaultPrompt"),D=o(e=>{const t=m(e),s=$(t,{exact:!1,filter:[],global:!1,optional:!1,packages:[r],peer:!1,saveDev:!0,workspace:!1,workspaceRoot:!1},e,console);return Promise.resolve({exitCode:s})},"defaultRunInstall"),k=o(()=>{try{return import.meta.resolve(r),!0}catch{return!1}},"isSigstoreInstalled"),P=o(e=>{let t="pnpm";try{t=m(e).name}catch{}switch(t){case"bun":return`bun add -d ${r}`;case"npm":return`npm install -D ${r}`;case"yarn":return`yarn add -D ${r}`;default:return`pnpm add -D ${r}`}},"installCommandFor"),R=o(()=>import("sigstore"),"defaultImport"),x=o(async(e={})=>{const t=e.interactive??b(),s=e.prompt??O,i=e.runInstall??D,n=e.importImpl??R,d=e.workspaceRoot??process.cwd(),l=P(d);try{return await n()}catch(p){const{code:f,message:g}=p;if(!(f==="ERR_MODULE_NOT_FOUND"||f==="MODULE_NOT_FOUND")||!g.includes(r))throw p}if(!t)throw new Error(`${r} is not installed. \`vis attest\` needs it for keyless signing/verification. Install it in your repo first:
2
+ ${l}`);if(!await s(`${r} isn't installed. Install it now?`))throw new Error(`${r} install declined. Re-run \`vis attest\` after installing manually:
3
+ ${l}`);const u=await i(d);if(u.exitCode!==0)throw new Error(`Install of ${r} failed (exit ${String(u.exitCode)}). Install manually and retry:
4
+ ${l}`);return await n()},"loadOptionalSigstore");export{P as installCommandFor,k as isSigstoreInstalled,x as loadOptionalSigstore};
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var o=(t,e)=>u(t,"name",{value:e,configurable:!0});import{K as n}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{createJiti as l}from"jiti";var p=Object.defineProperty,a=o((t,e)=>p(t,"name",{value:e,configurable:!0}),"r");const i=a((t,e)=>{if(!e||typeof e!="object")throw new TypeError(`${t}: default export must be an object (got ${e===null?"null":typeof e}). Use createTemplate({ ... }).`);const r=e;if(typeof r.about!="object"||r.about===null)throw new TypeError(`${t}: default export missing required "about" object`);if(typeof r.produce!="function")throw new TypeError(`${t}: default export missing required "produce" function`);return e},"validateTemplateExport"),s=a(async t=>{const e=await l(n(t),{fsCache:!1,moduleCache:!1}).import(t,{default:!0,try:!0})??null;return i(t,e)},"loadNativeTemplate");export{s as loadNativeTemplate};
@@ -0,0 +1,3 @@
1
+ var d=Object.defineProperty;var u=(r,o)=>d(r,"name",{value:o,configurable:!0});import{p as s}from"./bin.js";import{r as m}from"../packem_shared/advisories-BxXiKFbL.js";var p=Object.defineProperty,l=u((r,o)=>p(r,"name",{value:o,configurable:!0}),"a");const v=l(async({fs:r,logger:o,options:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const e=t.db??m(n),a=t.format==="json";if(!t.force){s.warn(`Prune is destructive. Will remove: ${e}`),s.info("Re-run with --force to proceed."),a&&process.stdout.write(`${JSON.stringify({dbPath:e,reason:"needs --force",removed:!1})}
2
+ `);return}const f=[e,`${e}-wal`,`${e}-shm`,`${e}-journal`],i=[];for(const c of f)try{await r.rm(c,{force:!0}),i.push(c)}catch{}if(a){process.stdout.write(`${JSON.stringify({dbPath:e,files:i,removed:!0})}
3
+ `);return}s.success(`Removed ${e}.`)},"execute"),b=v;export{b as advisoriesPruneExecute};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var a=(t,o)=>l(t,"name",{value:o,configurable:!0});import{p as c,I as p,L as u}from"./bin.js";var w=Object.defineProperty,f=a((t,o)=>w(t,"name",{value:o,configurable:!0}),"c");const m=f(({options:t,visConfig:o,workspaceRoot:s})=>{const i=s??process.cwd(),n=o?.security?.policies?.installScripts?.allow??{},r=Object.entries(n).filter(([,e])=>e).map(([e])=>e);r.length===0&&!t.rootOnly&&(c.warn("No approved packages in security.policies.installScripts.allow — nothing to run."),!t.withRoot)||(t.rootOnly||p(i,r),(t.withRoot||t.rootOnly)&&u(i))},"execute");export{m as default};
@@ -0,0 +1,2 @@
1
+ var l=Object.defineProperty;var c=(s,e)=>l(s,"name",{value:e,configurable:!0});import{e as v,E as f,I as p}from"../packem_shared/Table-DoSoazT6-DwnyTUsA.js";import{p as r}from"./bin.js";import{r as g,g as h}from"../packem_shared/advisories-BxXiKFbL.js";var $=Object.defineProperty,i=c((s,e)=>$(s,"name",{value:e,configurable:!0}),"a");const B=i(s=>{if(s===0)return"0 B";const e=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(s)/Math.log(1024)),e.length-1),o=s/1024**a;return`${o.toFixed(o<10&&a>0?1:0)} ${e[a]}`},"formatBytes"),w=i(s=>{if(!s)return"never";const e=Date.parse(s);if(Number.isNaN(e))return s;const a=Date.now()-e;if(a<0)return s;const o=Math.floor(a/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const t=Math.floor(o/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`},"formatRelative"),S=i(async({logger:s,options:e,workspaceRoot:a})=>{if(!a)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const o=e.db??g(a),t=await h(a,o);if(e.format==="json"){process.stdout.write(`${JSON.stringify({dbPath:o,ecosystems:t.ecosystems.map(n=>({advisoryCount:n.advisoryCount,lastSyncIso:n.lastSyncIso,manifestEtag:n.manifestEtag??null,name:n.name})),exists:t.exists,schemaVersion:t.schemaVersion,sizeBytes:t.sizeBytes},void 0,2)}
2
+ `);return}if(r.info(`DB: ${o}`),!t.exists){r.warn(`No advisory DB yet. Run ${v("vis advisories sync")} to populate.`);return}if(r.info(`Schema: v${t.schemaVersion} Size: ${B(t.sizeBytes)}`),t.ecosystems.length===0){r.warn("DB exists but contains no ecosystems. Run `vis advisories sync`.");return}r.info(""),r.info("Ecosystem Advisories Last sync ETag"),r.info(f("────────── ────────── ───────────────── ──────"));for(const n of t.ecosystems){const m=n.name.padEnd(10),u=n.advisoryCount.toLocaleString().padStart(10),d=`${n.lastSyncIso||"never"} (${w(n.lastSyncIso)})`.padEnd(19),y=n.manifestEtag??f("—");r.info(`${p(m)} ${u} ${d} ${y}`)}},"execute"),D=S;export{D as advisoriesStatusExecute};
@@ -0,0 +1,2 @@
1
+ var w=Object.defineProperty;var y=(e,o)=>w(e,"name",{value:o,configurable:!0});import{E as $}from"../packem_shared/Table-DoSoazT6-DwnyTUsA.js";import{p as l}from"./bin.js";import{s as D}from"../packem_shared/scan-progress-DVtCtI2z.js";import{s as b,D as S}from"../packem_shared/advisories-BxXiKFbL.js";var E=Object.defineProperty,c=y((e,o)=>E(e,"name",{value:o,configurable:!0}),"c");const P=c(e=>e?.security?.audit?.advisories??{},"readAdvisoriesConfig"),k=c(e=>e?e.split(",").map(o=>o.trim()).filter(o=>o.length>0):["npm"],"parseEcosystems"),x=c(async({logger:e,options:o,visConfig:g,workspaceRoot:d})=>{if(!d)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const u=o.format==="json",m=P(g),f=o.source??m.source??S,p=k(o.ecosystem),v=p.map(s=>({id:s,label:`Sync ${s} advisories`})),n=D(v,{live:!u}),i=[];try{for(const s of p){n.start(s);const r=Date.now();try{const t=await b({allowedHosts:m.allowedHosts,dbPath:o.db,ecosystem:s,force:!!o.force,source:f,workspaceRoot:d});i.push({ecosystem:s,result:t}),t.upToDate?n.finish(s,"ok",`up to date · ${h(Date.now()-r)}`):n.finish(s,"ok",`${t.advisoriesIngested.toLocaleString()} advisories · ${h(t.durationMs)}`)}catch(t){const a=t instanceof Error?t.message:String(t);i.push({ecosystem:s,error:a}),n.finish(s,"error",a)}}}finally{n.stop()}if(u){const s={ecosystems:i.map(r=>({advisoriesIngested:r.result?.advisoriesIngested??0,dbPath:r.result?.dbPath??null,durationMs:r.result?.durationMs??0,ecosystem:r.ecosystem,error:r.error??null,upToDate:r.result?.upToDate??!1})),source:f};process.stdout.write(`${JSON.stringify(s,void 0,2)}
2
+ `)}else{const s=i.filter(a=>a.error),r=i.filter(a=>a.result),t=r[0];t?.result?.dbPath&&l.info($(`DB: ${t.result.dbPath}`)),s.length===0?l.success(`Synced ${r.length} ecosystem${r.length===1?"":"s"}.`):l.error(`${s.length} ecosystem${s.length===1?"":"s"} failed to sync.`)}i.some(s=>s.error)&&(process.exitCode=1)},"execute"),h=c(e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`,"formatDuration"),O=x;export{O as advisoriesSyncExecute};
@@ -0,0 +1,2 @@
1
+ var m=Object.defineProperty;var f=(e,n)=>m(e,"name",{value:n,configurable:!0});import{p as i}from"./bin.js";import{A as g}from"../packem_shared/pm-runner-DmKT2FqF.js";import{N as y}from"../packem_shared/native-config-sync-BRZZetn3.js";import{E as v}from"../packem_shared/min-release-age-BPVXwPUg.js";var h=Object.defineProperty,w=f((e,n)=>h(e,"name",{value:n,configurable:!0}),"l");const b=new Set(["bun","npm","pnpm","yarn"]),x=w(({options:e,visConfig:n,workspaceRoot:u})=>{const o=u??process.cwd(),t=g(o);if(!b.has(t.name)){i.warn(`Package manager '${t.name}' has no native security config to sync.`);return}if(!n?.security){i.warn("vis.config has no `security` block — nothing to sync.");return}const r=n.security.policies??{},a=Object.fromEntries(Object.entries(r.installScripts?.allow??{}).filter(([,c])=>c)),p=r.firstSeen?.minutes,l=r.firstSeen?.exclude??[],s=[];if(Object.keys(a).length>0&&!e.skipAllowBuilds&&s.push(...y(t.name,o,a)),e.skipMinReleaseAge||s.push(...v(t.name,o,p,l)),s.length===0){i.success("Nothing to sync — vis.config and native PM config are aligned.");return}i.info(`Syncing vis.config security settings to ${t.name} native config…
2
+ `);for(const c of s)i.success(` ${c}`)},"execute");export{x as default};