@visulima/vis 1.0.0-alpha.35 → 1.0.0-alpha.37

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 (193) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/LICENSE.md +3244 -1611
  3. package/README.md +44 -0
  4. package/dashboard/dist/index.html +11 -11
  5. package/dist/bin.js +1 -1
  6. package/dist/binx.js +1 -1
  7. package/dist/config/index.d.ts +74 -2
  8. package/dist/config/index.js +1 -1
  9. package/dist/generate/index.js +1 -1
  10. package/dist/packem_chunks/bin.js +584 -588
  11. package/dist/packem_chunks/bloom-status.js +2 -2
  12. package/dist/packem_chunks/bloom-sync.js +2 -2
  13. package/dist/packem_chunks/cache-attestation.js +1 -1
  14. package/dist/packem_chunks/config.js +18 -16
  15. package/dist/packem_chunks/devtools.js +56 -57
  16. package/dist/packem_chunks/doctor-probe.js +2 -2
  17. package/dist/packem_chunks/fix.js +11 -11
  18. package/dist/packem_chunks/handler.js +1 -1
  19. package/dist/packem_chunks/handler10.js +1 -1
  20. package/dist/packem_chunks/handler11.js +5 -5
  21. package/dist/packem_chunks/handler12.js +1 -1
  22. package/dist/packem_chunks/handler13.js +7 -7
  23. package/dist/packem_chunks/handler14.js +4 -4
  24. package/dist/packem_chunks/handler15.js +1 -1
  25. package/dist/packem_chunks/handler16.js +1 -1
  26. package/dist/packem_chunks/handler17.js +1 -1
  27. package/dist/packem_chunks/handler18.js +1 -1
  28. package/dist/packem_chunks/handler19.js +1 -1
  29. package/dist/packem_chunks/handler2.js +3 -3
  30. package/dist/packem_chunks/handler20.js +5 -5
  31. package/dist/packem_chunks/handler21.js +2 -2
  32. package/dist/packem_chunks/handler22.js +2 -2
  33. package/dist/packem_chunks/handler23.js +1 -1
  34. package/dist/packem_chunks/handler24.js +1 -1
  35. package/dist/packem_chunks/handler25.js +1 -5
  36. package/dist/packem_chunks/handler26.js +5 -1
  37. package/dist/packem_chunks/handler27.js +1 -3
  38. package/dist/packem_chunks/handler28.js +3 -1
  39. package/dist/packem_chunks/handler29.js +1 -7
  40. package/dist/packem_chunks/handler3.js +4 -4
  41. package/dist/packem_chunks/handler30.js +6 -32
  42. package/dist/packem_chunks/handler31.js +33 -3
  43. package/dist/packem_chunks/handler32.js +3 -8
  44. package/dist/packem_chunks/handler33.js +8 -1
  45. package/dist/packem_chunks/handler34.js +4 -5
  46. package/dist/packem_chunks/handler35.js +1 -11
  47. package/dist/packem_chunks/handler36.js +5 -3
  48. package/dist/packem_chunks/handler37.js +11 -22
  49. package/dist/packem_chunks/handler38.js +3 -61
  50. package/dist/packem_chunks/handler39.js +22 -3
  51. package/dist/packem_chunks/handler4.js +6 -6
  52. package/dist/packem_chunks/handler40.js +61 -6
  53. package/dist/packem_chunks/handler41.js +3 -24
  54. package/dist/packem_chunks/handler42.js +6 -25
  55. package/dist/packem_chunks/handler43.js +24 -153
  56. package/dist/packem_chunks/handler44.js +25 -10
  57. package/dist/packem_chunks/handler45.js +152 -707
  58. package/dist/packem_chunks/handler46.js +10 -24
  59. package/dist/packem_chunks/handler47.js +24 -322
  60. package/dist/packem_chunks/handler48.js +322 -48
  61. package/dist/packem_chunks/handler49.js +708 -3
  62. package/dist/packem_chunks/handler5.js +7 -7
  63. package/dist/packem_chunks/handler50.js +48 -27
  64. package/dist/packem_chunks/handler51.js +21 -189
  65. package/dist/packem_chunks/handler52.js +3 -34
  66. package/dist/packem_chunks/handler53.js +200 -0
  67. package/dist/packem_chunks/handler54.js +38 -0
  68. package/dist/packem_chunks/handler6.js +1 -1
  69. package/dist/packem_chunks/handler7.js +1 -1
  70. package/dist/packem_chunks/handler8.js +1 -1
  71. package/dist/packem_chunks/handler9.js +1 -1
  72. package/dist/packem_chunks/heal-accept.js +7 -7
  73. package/dist/packem_chunks/heal.js +11 -11
  74. package/dist/packem_chunks/help-command.js +30 -7
  75. package/dist/packem_chunks/index.js +6 -6
  76. package/dist/packem_chunks/keys-refresh.js +4 -4
  77. package/dist/packem_chunks/list.js +2 -2
  78. package/dist/packem_chunks/loader.js +4 -4
  79. package/dist/packem_chunks/loader2.js +1 -1
  80. package/dist/packem_chunks/prune.js +3 -3
  81. package/dist/packem_chunks/run.js +1 -1
  82. package/dist/packem_chunks/status.js +2 -2
  83. package/dist/packem_chunks/sync.js +2 -2
  84. package/dist/packem_chunks/sync2.js +2 -2
  85. package/dist/packem_chunks/tar.js +3 -3
  86. package/dist/packem_chunks/tripwire.js +2 -2
  87. package/dist/packem_chunks/verify-lockfile.js +2 -2
  88. package/dist/packem_shared/CONFIG_FILES-BfaR0jKT.js +1 -0
  89. package/dist/packem_shared/MultiSpinner-B9U0-aE3-B-gIXhFk.js +3 -0
  90. package/dist/packem_shared/Table-CcVkyULl-B_ef6zfS.js +35 -0
  91. package/dist/packem_shared/_commonjsHelpers-B5Y90VFO.js +1 -0
  92. package/dist/packem_shared/advisories-DLeO5KMN.js +1 -0
  93. package/dist/packem_shared/affected-shas-cVnX8-zs.js +1 -0
  94. package/dist/packem_shared/ai-analysis-DT3bU-_M.js +68 -0
  95. package/dist/packem_shared/ai-fix-BkNqd5nP.js +43 -0
  96. package/dist/packem_shared/build-scripts-CCCi8U66.js +1 -0
  97. package/dist/packem_shared/cyclonedx-86-DbHtf.js +4 -0
  98. package/dist/packem_shared/definePlugin-DoUcoYSy.js +1 -0
  99. package/dist/packem_shared/dependency-scan-BDTH898x.js +1 -0
  100. package/dist/packem_shared/docker-tNrDU3oK.js +59 -0
  101. package/dist/packem_shared/failure-log-Dwqt6_Ga.js +2 -0
  102. package/dist/packem_shared/giget-DHY1sQZC.js +2 -0
  103. package/dist/packem_shared/glob-fqg4KepW-B7EjLRvw.js +1 -0
  104. package/dist/packem_shared/index-BDmTbWX1.js +19 -0
  105. package/dist/packem_shared/index-CB4p298r.js +1 -0
  106. package/dist/packem_shared/index-DMefdF51.js +1 -0
  107. package/dist/packem_shared/index-dQ37x8_P.js +30 -0
  108. package/dist/packem_shared/license-t5KnNX6v.js +1 -0
  109. package/dist/packem_shared/lifecycle-4z9hHE5b.js +2 -0
  110. package/dist/packem_shared/lockfile-C8Q1_4KK.js +1 -0
  111. package/dist/packem_shared/manifests-Dj3pRKBT.js +1 -0
  112. package/dist/packem_shared/min-release-age-D1alDE3K.js +34 -0
  113. package/dist/packem_shared/missing-package-json-41VUWFBY.js +1 -0
  114. package/dist/packem_shared/native-config-sync-BKAZ0NIs.js +21 -0
  115. package/dist/packem_shared/osv-bloom-B03tUWf3.js +2 -0
  116. package/dist/packem_shared/otelPlugin-DmKDBaPo.js +1 -0
  117. package/dist/packem_shared/peer-warnings-BXAzXqY3.js +1 -0
  118. package/dist/packem_shared/pm-runner-pVihAfxV.js +1 -0
  119. package/dist/packem_shared/provenance-DMuEftgc.js +1 -0
  120. package/dist/packem_shared/registry-keys-Bf2zzlcZ.js +1 -0
  121. package/dist/packem_shared/resolve-explicit-jH0RKyMJ.js +5 -0
  122. package/dist/packem_shared/runtime-check-Stc9AI78.js +1 -0
  123. package/dist/packem_shared/s1ngularity-BkfgC6NO.js +1 -0
  124. package/dist/packem_shared/scan-progress-JBbd9QeT.js +2 -0
  125. package/dist/packem_shared/selectors-GCJIe342.js +3 -0
  126. package/dist/packem_shared/signatures-D1H6h6GH.js +2 -0
  127. package/dist/packem_shared/spinner-BXSl864p.js +1 -0
  128. package/dist/packem_shared/subtree-C7bZuiSQ.js +2 -0
  129. package/dist/packem_shared/symbols-DPTlrJ3B.js +1 -0
  130. package/dist/packem_shared/tabs-BqUepRaD.js +1 -0
  131. package/dist/packem_shared/toolchain-pR7AJ-tB.js +5 -0
  132. package/dist/packem_shared/typosquats-C8qg1neE.js +1 -0
  133. package/dist/packem_shared/use-measured-height-BBJ9intr.js +1 -0
  134. package/dist/packem_shared/utils-Cxree603.js +1 -0
  135. package/dist/packem_shared/verify-Du7xZ2BJ.js +1 -0
  136. package/dist/packem_shared/vis-update-app-CTwRkNgj.js +1 -0
  137. package/dist/packem_shared/watch-BvIwLG4N.js +1 -0
  138. package/dist/packem_shared/watch-loop-DWkvv2tK.js +11 -0
  139. package/index.d.ts +201 -201
  140. package/index.js +751 -567
  141. package/package.json +16 -16
  142. package/schemas/vis-config.schema.json +4 -0
  143. package/dist/packem_shared/Table-3pFgIUZ2-DABgc6rj.js +0 -12
  144. package/dist/packem_shared/_commonjsHelpers-CLblCigl.js +0 -1
  145. package/dist/packem_shared/advisories-CGKZo9Rx.js +0 -1
  146. package/dist/packem_shared/affected-shas-BdnlfiV1.js +0 -1
  147. package/dist/packem_shared/ai-analysis-3QD_RS6F.js +0 -68
  148. package/dist/packem_shared/ai-fix-TsjDQz_0.js +0 -43
  149. package/dist/packem_shared/applyDefaults-BogleaFi.js +0 -1
  150. package/dist/packem_shared/build-scripts-DE6U8jVq.js +0 -1
  151. package/dist/packem_shared/cyclonedx-zf9R2jCs.js +0 -4
  152. package/dist/packem_shared/definePlugin-CWm4Dv_t.js +0 -1
  153. package/dist/packem_shared/dependency-scan-B70azq4x.js +0 -1
  154. package/dist/packem_shared/docker-EJiTY0Sz.js +0 -60
  155. package/dist/packem_shared/failure-log-Dxafk3t4.js +0 -2
  156. package/dist/packem_shared/giget-CcEy_Elm.js +0 -2
  157. package/dist/packem_shared/glob-D_7bct6p-D8itOHsr.js +0 -1
  158. package/dist/packem_shared/index-BpbjpCNL.js +0 -1
  159. package/dist/packem_shared/index-DH-5hsrC.js +0 -1
  160. package/dist/packem_shared/index-Dc3ht2bL.js +0 -30
  161. package/dist/packem_shared/license-zZU7aavK.js +0 -1
  162. package/dist/packem_shared/lifecycle-DvVTL8nx.js +0 -2
  163. package/dist/packem_shared/lockfile-CedmXr44.js +0 -1
  164. package/dist/packem_shared/lockfile-Cu2BH6bl.js +0 -1
  165. package/dist/packem_shared/manifests-BzWpKW8F.js +0 -1
  166. package/dist/packem_shared/min-release-age-DKMW2N_v.js +0 -34
  167. package/dist/packem_shared/missing-package-json-DKAwoiWK.js +0 -1
  168. package/dist/packem_shared/native-config-sync-DBkJ-hsF.js +0 -21
  169. package/dist/packem_shared/osv-bloom-0Vu8YRhg.js +0 -2
  170. package/dist/packem_shared/otelPlugin-CJR2T_lk.js +0 -1
  171. package/dist/packem_shared/peer-warnings-EvSJ18gE.js +0 -1
  172. package/dist/packem_shared/pm-runner-DmKT2FqF.js +0 -1
  173. package/dist/packem_shared/provenance-Cu6VR1Hy.js +0 -1
  174. package/dist/packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js +0 -1
  175. package/dist/packem_shared/registry-keys-CuBAVdsk.js +0 -1
  176. package/dist/packem_shared/resolve-explicit-Xue0oq8V.js +0 -5
  177. package/dist/packem_shared/runtime-check-CilFOqUU.js +0 -1
  178. package/dist/packem_shared/s1ngularity-adnHbyTd.js +0 -1
  179. package/dist/packem_shared/scan-progress-lZdk5KJ-.js +0 -2
  180. package/dist/packem_shared/selectors-DkgYFzdq.js +0 -3
  181. package/dist/packem_shared/signatures-FGbYV5QE.js +0 -2
  182. package/dist/packem_shared/spinner-0acw5pd_.js +0 -1
  183. package/dist/packem_shared/spinners-f91Rbo99-Bjf3NcO0.js +0 -1
  184. package/dist/packem_shared/symbols-CQmER5MT.js +0 -1
  185. package/dist/packem_shared/tabs-zUSdR1HI.js +0 -1
  186. package/dist/packem_shared/toolchain-DoG6b_G_.js +0 -5
  187. package/dist/packem_shared/typosquats-acxQ7blw.js +0 -1
  188. package/dist/packem_shared/use-measured-height-DyCBfLtu.js +0 -1
  189. package/dist/packem_shared/utils-DrNg0XTR.js +0 -1
  190. package/dist/packem_shared/verify-BYzxSKWD.js +0 -1
  191. package/dist/packem_shared/vis-update-app-D0QyGneK.js +0 -1
  192. package/dist/packem_shared/watch-DEL0yol9.js +0 -1
  193. package/dist/packem_shared/watch-loop-jmQQl2Qe.js +0 -11
@@ -1 +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};
1
+ import{r as g}from"../packem_shared/affected-shas-cVnX8-zs.js";import{r as m}from"../packem_shared/toolchain-pR7AJ-tB.js";const w=async({argument:d,logger:t,options:o,runtime:r,visConfig:s,workspaceRoot:e})=>{const l=d[0];if(!l)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const f=l.split(",").map(a=>a.trim()).filter(Boolean);if(f.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!e)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=g({defaultBase:s?.defaultBase,workspaceRoot:e}),p=o.base??i.base,c=o.head??i.head;!o.base&&!o.head&&t.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),o.skipToolchain||t.info("▸ Toolchain pre-flight"),await m(e,s?.toolchain,{error:a=>{t.error(a)},info:a=>{t.info(a)},warn:a=>{t.warn(a)}},!!o.skipToolchain),o.install===!1?t.info("▸ Skipping install (--no-install)"):(t.info("▸ Installing dependencies"),await r.runCommand("install",{argv:["--ci","--frozen-lockfile"]}));for(const a of f){t.info(`▸ Running affected ${a} (base=${p}, head=${c})`);const n=[a,`--base=${p}`,`--head=${c}`,`--upstream=${String(o.upstream??"none")}`,`--downstream=${String(o.downstream??"deep")}`];o.parallel!==void 0&&n.push(`--parallel=${String(o.parallel)}`),o.partition&&n.push(`--partition=${String(o.partition)}`),o.query&&n.push(`--query=${String(o.query)}`),await r.runCommand("affected",{argv:n})}t.info("▸ CI pipeline complete")};export{w as default};
@@ -1 +1 @@
1
- var k=Object.defineProperty;var m=(o,r)=>k(o,"name",{value:r,configurable:!0});import{createRequire as v}from"node:module";import{p as n,m as P}from"./bin.js";import{M as p,l as S}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{cleanWorkspace as M}from"#native";import{l as D}from"../packem_shared/missing-package-json-DKAwoiWK.js";import{f as y}from"../packem_shared/utils-DrNg0XTR.js";const h=v(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=m(o=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[r,t]=u.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return u.getBuiltinModule(o)}return h(o)},"__cjs_getBuiltinModule"),{readdirSync:$,lstatSync:b,unlinkSync:R,rmSync:j}=_("node:fs");var w=Object.defineProperty,d=m((o,r)=>w(o,"name",{value:r,configurable:!0}),"f");const x=/node_modules/,E=/\.git/,N=d(o=>{const r=[],t=[o];for(;t.length>0;){const s=t.pop();let c;try{c=$(s)}catch{continue}for(const i of c){const e=p(s,i);try{const f=b(e);if(f.isSymbolicLink()||!f.isDirectory())continue}catch{continue}i==="node_modules"?r.push(e):i!==".git"&&i!==".hg"&&t.push(e)}}return r},"findNodeModulesDirectories"),q=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],C=d((o,r,t)=>{let s=0,c=!1;for(const i of q){const e=p(o,i);if(S(e)){if(r){t.info(` ${e}`),s++;continue}try{R(e),n.success(`Removed ${e}`),s++}catch(f){n.error(`${e}: ${y(f)}`),c=!0}}}return{hadError:c,removed:s}},"removeLockfiles"),L=d(o=>{for(const r of P(o,{includeDirs:!1,includeSymlinks:!1,skip:[x,E]}))if(r.name==="package.json")return!0;return!1},"containsPackageJson"),g=d((o,r,t)=>{let s=0,c=!1;for(const{packageDir:i}of D(o)){const e=p(o,i);if(!L(e)){if(r){t.info(` ${e}`),s++;continue}try{j(e,{force:!0,recursive:!0}),n.success(`Removed empty package ${e}`),s++}catch(f){n.error(`${e}: ${y(f)}`),c=!0}}}return{hadError:c,removed:s}},"removeEmptyPackages"),F=d(async({logger:o,options:r,workspaceRoot:t})=>{const s=t??process.cwd(),c=r.lockfile||!1,i=r.emptyPackages||!1;if(r.dryRun){const l=N(s);if(l.length>0){n.info("Would remove:");for(const a of l)o.info(` ${a}`)}else n.info("No node_modules directories found.");c&&C(s,!0,o),i&&(n.info("Would remove empty packages:"),g(s,!0,o));return}const e=M(s,c);for(const l of e.removed)n.success(`Removed ${l}`);for(const l of e.lockfilesRemoved)n.success(`Removed ${l}`);for(const l of e.errors)n.error(l);e.removed.length===0&&e.lockfilesRemoved.length===0?n.info("No node_modules directories found."):n.info(`Cleaned ${e.removed.length} node_modules director${e.removed.length===1?"y":"ies"}`);let f=!1;if(i){const{hadError:l,removed:a}=g(s,!1,o);f=l,a>0&&n.info(`Cleaned ${a} empty package director${a===1?"y":"ies"}`)}(e.errors.length>0||f)&&(process.exitCode=1)},"execute");export{F as default};
1
+ import{createRequire as p}from"node:module";import{m as u,f as _,I as $}from"../packem_shared/index-BDmTbWX1.js";import{cleanWorkspace as R}from"#native";import{l as b}from"../packem_shared/missing-package-json-41VUWFBY.js";import{p as c}from"./bin.js";import{c as j}from"../packem_shared/utils-Cxree603.js";const g=p(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=o=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[r,n]=d.versions.node.split(".").map(Number);if(r>22||r===22&&n>=3||r===20&&n>=16)return d.getBuiltinModule(o)}return g(o)},{readdirSync:y,lstatSync:h,rmSync:v}=k("node:fs"),S=/node_modules/,w=/\.git/,C=o=>{const r=[],n=[o];for(;n.length>0;){const s=n.pop();let i;try{i=y(s)}catch{continue}for(const t of i){const e=u(s,t);try{const f=h(e);if(f.isSymbolicLink()||!f.isDirectory())continue}catch{continue}t==="node_modules"?r.push(e):t!==".git"&&t!==".hg"&&n.push(e)}}return r},P=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],q=(o,r,n)=>{let s=0,i=!1;for(const t of P){const e=u(o,t);if(_(e)){n.info(` ${e}`),s++;continue}}return{hadError:i,removed:s}},x=o=>{for(const r of $(o,{includeDirs:!1,includeSymlinks:!1,skip:[S,w]}))if(r.name==="package.json")return!0;return!1},m=(o,r,n)=>{let s=0,i=!1;for(const{packageDir:t}of b(o)){const e=u(o,t);if(!x(e)){if(r){n.info(` ${e}`),s++;continue}try{v(e,{force:!0,recursive:!0}),c.success(`Removed empty package ${e}`),s++}catch(f){c.error(`${e}: ${j(f)}`),i=!0}}}return{hadError:i,removed:s}},B=async({logger:o,options:r,workspaceRoot:n})=>{const s=n??process.cwd(),i=r.lockfile||!1,t=r.emptyPackages||!1;if(r.dryRun){const l=C(s);if(l.length>0){c.info("Would remove:");for(const a of l)o.info(` ${a}`)}else c.info("No node_modules directories found.");i&&q(s,!0,o),t&&(c.info("Would remove empty packages:"),m(s,!0,o));return}const e=R(s,i);for(const l of e.removed)c.success(`Removed ${l}`);for(const l of e.lockfilesRemoved)c.success(`Removed ${l}`);for(const l of e.errors)c.error(l);e.removed.length===0&&e.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${e.removed.length} node_modules director${e.removed.length===1?"y":"ies"}`);let f=!1;if(t){const{hadError:l,removed:a}=m(s,!1,o);f=l,a>0&&c.info(`Cleaned ${a} empty package director${a===1?"y":"ies"}`)}(e.errors.length>0||f)&&(process.exitCode=1)};export{B as default};
@@ -1 +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};
1
+ import{I as t,x as i}from"../packem_shared/pm-runner-pVihAfxV.js";const l=async({logger:e,options:a,visConfig:o,workspaceRoot:n})=>{const c=n??process.cwd(),r=t(c,{configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),s=i(r,a.check||!1,c,e);s!==0&&(process.exitCode=s)};export{l as default};
@@ -1 +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};
1
+ import{I as f,$ as k}from"../packem_shared/pm-runner-pVihAfxV.js";const h=async({argument:n,logger:i,options:a,visConfig:s,workspaceRoot:r})=>{const e=n;if(!e||e.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[l,...g]=e,o=r??process.cwd(),t=f(o,{configBackend:s?.install?.backend,configCorepack:s?.install?.corepack}),p=a.package?Array.isArray(a.package)?a.package:[a.package]:[],c=k(t,{additionalPackages:p,args:g,package:l,shellMode:a.shellMode||!1,silent:a.silent||!1},o,i,{offline:a.offline||!1});c!==0&&(process.exitCode=c)};export{h as default};
@@ -1,10 +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(`
1
+ import{createRequire as G}from"node:module";import{B as y,y as N}from"../packem_shared/index-BDmTbWX1.js";import{d as O,k as U,P as H,R as F,p as P}from"./heal.js";import{w as D,M as S}from"../packem_shared/pm-runner-pVihAfxV.js";import{p as a}from"./bin.js";const L=G(import.meta.url),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,o]=_.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return _.getBuiltinModule(e)}return L(e)},{readFile:$}=x("node:fs/promises"),{createInterface:K}=x("node:readline"),j=()=>!!process.stdout.isTTY&&process.env.CI!=="true",V=e=>new Promise(t=>{const o=K({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")})}),M=(e,t)=>{const o=D(t),i=S(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})},R=e=>`pnpm add ${e}`,q=e=>e==="@gitbeaker/rest"?import("@gitbeaker/rest"):import("@octokit/rest"),B=async(e,t={})=>{const o=t.interactive??j(),i=t.prompt??V,s=t.runInstall??M,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
+ ${R(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
+ ${R(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
+ ${R(e)}`);return await l(e)},Y=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)}},J=async(e,t)=>{if(t.githubClient)return t.githubClient;const o=(await(t.loadSdk??B)("@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})},W=async(e,t,o)=>{if(o.gitlabClient)return o.gitlabClient;const i=(await(o.loadSdk??B)("@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})},z=e=>e.replace(/\/api\/v\d+\/?$/,""),X=async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(w=>$(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}=Y(o.repo),p=await J(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 C=y(l,w),k=await d(C),b=await p.rest.git.createBlob({content:Buffer.from(k,"utf8").toString("base64"),encoding:"base64",owner:r,repo:n});return{mode:"100644",path:w,sha:b.data.sha,type:"blob"}})),f=await p.rest.git.createTree({base_tree:h,owner:r,repo:n,tree:m}),g=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:g.data.sha}),{sha:g.data.sha,url:g.data.html_url}},Q=async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(m=>$(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=z(o.apiBaseUrl),n=await W(o.token,r,e),p=await Promise.all(i.map(async m=>{const f=y(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}},Z=async e=>{if(e.files.length===0)throw new Error("Cannot commit: no files to include.");if(e.ciContext.provider==="github-actions")return await X(e);if(e.ciContext.provider==="gitlab-ci")return await Q(e);throw new Error(`Cannot commit: unsupported CI provider \`${e.ciContext.provider}\`. Run \`vis ai heal accept\` from a recognised CI environment.`)},v="/vis heal accept",ee=async e=>{if(!e)return;let t;try{t=await $(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}},te=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}},oe=e=>{const t=e.BUILDKITE_UNBLOCKER_EMAIL??e.BUILDKITE_UNBLOCKER;if(t)return{actor:t,body:v,headRef:e.BUILDKITE_BRANCH,isFork:!1}},re=async(e,t)=>{if(e.provider==="github-actions")return await ee(t.GITHUB_EVENT_PATH);if(e.provider==="gitlab-ci")return te(t);if(e.provider==="buildkite")return oe(t)},ie=(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}}},ae=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}},ne=(e,t,o,i)=>{const s=t.map(l=>`- \`${l}\``).join(`
5
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(`
6
+ `)},se=async(e,t={})=>{const{logger:o,visConfig:i,workspaceRoot:s}=e,l=s??process.cwd(),d=t.env??process.env,r=await(t.detectCi??(()=>O(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 re(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(v)){a.notice(`Trigger comment does not contain \`${v}\`; 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 ae({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 U(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 H(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 g=await F(e,m,{validate:t.validate});if(g.exitCode!==0){a.error(`Validation failed (exit ${String(g.exitCode)}). Refusing to commit.`),g.stderr.trim().length>0&&(o.info("--- validation stderr (tail) ---"),o.info(g.stderr.split(`
7
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?`
8
+ `))),process.exitCode=1;return}a.success("Validation passed. Committing.");const w=(f.applyResults??[]).filter(c=>c.status==="applied").map(c=>{const T=c.absolutePath??c.patch.file,E=N(l,T);return E===""||E.startsWith("..")?c.patch.file:E});if(w.length===0){a.error("No applied files to commit. Aborting."),process.exitCode=1;return}const C=[`fix: vis ai heal accepted by @${n.actor}`,"",`Failing task: ${m.failedTask.taskId}`,f.proposal?.explanation?`
9
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};
10
+ `);let k=r;if(r.provider==="buildkite"){const c=ie(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}k=c}let b;try{b=await Z({branch:u,ciContext:k,files:w,message:C,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 ${b.sha.slice(0,7)}${b.url?` — ${b.url}`:""}.`);const A=ne(b,w,m.failedTask.taskId,n.actor),I=await(t.postComment??(async(c,T)=>P({body:c,context:T})))(A,r);!I.posted&&I.method!=="skipped"&&a.warn(`Commit landed but the confirmation comment failed: ${I.error??"unknown"}`)},me=async e=>{await se(e)};export{v as TRIGGER_PHRASE,me as aiHealAccept,ie as deriveBuildkiteCommitContextForTesting,ae as fetchGithubHeadRefForTesting,oe as loadBuildkiteTriggerForTesting,ee as loadGithubTriggerForTesting,te as loadGitlabTriggerForTesting,se as runHealAcceptForTesting,ne as summariseDetailForTesting};
@@ -1,14 +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-3pFgIUZ2-DABgc6rj.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-TsjDQz_0.js";import{H 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(`
1
+ import{createRequire as S}from"node:module";import{s as B,j as U,E as I,V as P,I as L}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{y as A}from"../packem_shared/index-BDmTbWX1.js";import{readLastRunSummary as O}from"@visulima/task-runner";import{a as j,r as G,b as K,c as D}from"../packem_shared/ai-fix-BkNqd5nP.js";import{p as u,A as H}from"./bin.js";const R=S(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return R(e)},{spawn:h}=g("node:child_process"),{readFile:F}=g("node:fs/promises"),M=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},V=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await F(e,"utf8"),o=JSON.parse(t),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}}},J=async e=>{const t=M(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await V(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},q=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,i=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:i}},z=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,i=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,a=e.BUILDKITE_PIPELINE_SLUG,s=n!==void 0&&n!==""&&a!==void 0&&a!==""?`${n}/${a}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(i)?i:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:s,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Q=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await J(e):e.GITLAB_CI==="true"?q(e):e.BUILDKITE==="true"?z(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Y=(e,t,o,r)=>new Promise(i=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const a=h(e,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)}),Z=async(e,t,o,r,i)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const a=await e(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}}},W=async(e,t,o,r,i,n)=>{const a=encodeURIComponent(o),s=`${t.replace(/\/+$/,"")}/projects/${a}/merge_requests/${String(r)}/notes`;try{const d=await e(s,{body:JSON.stringify({body:i}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},X=(e,t,o,r)=>new Promise(i=>{const n=h(e,["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(t)}),tt=async(e,t,o,r,i,n,a,s)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const p=await e(f,{body:JSON.stringify({body:i,context:a,style:n}),headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},method:"POST"});if(!p.ok){const l=await p.text().catch(()=>"");return{error:`Buildkite REST returned ${String(p.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(p){return{error:p instanceof Error?p.message:String(p),ok:!1}}},et=async(e,t,o,r)=>{const i=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",a=await X(o,e,n,i);if(a.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.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 tt(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,i,t.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}},ot=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const i=await Y(o,t.prNumber,e,t.repo);if(i.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.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 Z(r,t.repo,t.prNumber,e,t.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}},rt=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.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 W(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},it=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:i=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await ot(t,r,n,i):r.provider==="gitlab-ci"?await rt(t,r,i):r.provider==="buildkite"?await et(t,r,o,i):{method:"skipped",posted:!1}},k=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},b=(e,t,o)=>{const r=D(e,t,o),i=A(e,r);return i===""||i.startsWith("..")?r:i},nt=(e,t,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",t,"--no-cache","--summarize","--fail-fast"],s=h(process.execPath,a,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{s.kill("SIGTERM"),setTimeout(()=>s.kill("SIGKILL"),2e3).unref()},r);s.stdout?.setEncoding("utf8"),s.stdout?.on("data",p=>{d+=p}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",p=>{c+=p}),s.once("error",p=>{clearTimeout(f),i({exitCode:-1,stderr:p.message,stdout:d})}),s.once("close",p=>{clearTimeout(f),i({exitCode:p??-1,stderr:c,stdout:d})})}),at=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},v=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[i,n]of e.patches.entries()){const a=b(t,o,n.file),s=[`**[${String(i+1)}] \`${a}\`**`];n.reason&&s.push(`_${n.reason}_`);const d=T(`${n.oldString}
2
+ ${n.newString}`);s.push(`${d}diff`);for(const c of n.oldString.split(`
3
+ `))s.push(`- ${c}`);for(const c of n.newString.split(`
4
+ `))s.push(`+ ${c}`);s.push(d),r.push(s.join(`
5
5
  `))}return r.join(`
6
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(`
7
+ `)},_=(e,t,o,r)=>{const i=["## vis ai heal — proposed fix","",`Failing task: \`${t.taskId}\` (provider: \`${e.provider}\`, confidence: \`${e.confidence}\`)`];r&&i.push(`Run anchored at \`${r.slice(0,7)}\`.`),i.push(""),i.push("### Root cause"),i.push(e.explanation||"_(no explanation)_"),i.push("");const n=["### Proposed patch",v(e,o,t.cwd),""],a=["### Validation",`Re-ran \`${t.taskId}\` after applying the patch on the CI runner — task **passed**.`,"","### Apply locally","```sh",`vis ai fix ${t.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")<=at)return s;const d=["### Proposed patch",`_Patch set is too large for a comment (${String(e.patches.length)} files). Run \`vis ai fix ${t.taskId} --apply\` locally to inspect and apply it._`,""];return[...i,...d,...a].join(`
9
+ `)},st=(e,t,o)=>{const r=[U(`Proposal (${e.provider}, confidence: ${e.confidence})`),e.explanation||I("<no explanation>")];for(const[i,n]of e.patches.entries()){r.push(""),r.push(`[${String(i+1)}] ${b(t,o,n.file)}`),n.reason&&r.push(I(` reason: ${n.reason}`));for(const a of n.oldString.split(`
10
+ `))r.push(P(` - ${a}`));for(const a of n.newString.split(`
11
+ `))r.push(L(` + ${a}`))}return r.join(`
12
+ `)},dt=async(e,t)=>{const o=t===void 0?await O(e):await H(e,t);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}}},ct=1800*1e3,$=async(e,t)=>{const o=await dt(e,t);if(!o)return{outcome:"no-failed-task"};if(!o.project||!o.target)return{failedTask:o,outcome:"missing-metadata"};const r=await j(e,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"}},C=async(e,t)=>{const{logger:o,options:r,visConfig:i,workspaceRoot:n}=e,a=n??process.cwd(),s=r.dryRun===!0,d=i?.ai,c=await G(t.failureContext,o,{cache:r.cache!==!1,config:d});if(!c)return{outcome:"no-proposal"};if(c.cannotFix)return{detail:c.cannotFix,outcome:"cannot-fix",proposal:c};if(c.patches.length===0)return{outcome:"empty-patches",proposal:c};if(s)return{outcome:"dry-run",proposal:c};const f=await K(a,t.failureContext.cwd,c);return k(f).applied===0?{applyResults:f,outcome:"no-patches-applied",proposal:c}:{applyResults:f,outcome:"applied",proposal:c}},y=async(e,t,o={})=>{const r=e.workspaceRoot??process.cwd(),i=e.options.validationTimeout===void 0?ct:e.options.validationTimeout*1e3;return await(o.validate??((n,a)=>nt(r,n,a,i)))(t.failedTask.project,t.failedTask.target)},x=async(e,t,o,r={})=>{const i=await(r.detectCi??Q)(),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=_(t,o,e,i.sha),s=await(r.postComment??(async(d,c)=>it({body:d,context:c})))(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}},w=async(e,t={})=>{const{logger:o,workspaceRoot:r}=e,i=r??process.cwd(),n=await $(i,e.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 C(e,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(st(d,i,a.failureContext.cwd)),s.outcome==="dry-run"){u.info("Dry run: skipping apply, validation, and PR comment.");return}const c=s.applyResults??[],f=k(c);if(u.info(`Applied ${String(f.applied)}/${String(c.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 p=await y(e,a,{validate:t.validate});if(p.exitCode!==0){u.error(`Validation failed (exit ${String(p.exitCode)}). Patch is not posted.`),p.stderr.trim().length>0&&(o.info(B("--- validation stderr (tail) ---")),o.info(p.stderr.split(`
13
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};
14
+ `))),process.exitCode=1;return}u.success("Validation passed.");const l=await x(i,d,a.failureContext,{detectCi:t.detectCi,postComment:t.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 E=l.surface==="annotation"?`build #${String(l.ciContext.buildNumber??"?")}`:`${l.surface} #${String(l.ciContext.prNumber)}`;u.success(`Posted fix proposal to ${E} via ${l.method??"unknown"}.`);return}if(l.outcome==="no-pr"){u.notice(`No ${l.surface} number detected (push-event run); skipping comment.`);return}const N=l.surface==="annotation"?"annotation":`${l.surface} comment`;u.error(`Failed to post ${N}: ${l.error??"unknown error"}`)},pt=async e=>{await w(e)},gt=Object.defineProperty({__proto__:null,aiHeal:pt,findHealCandidate:$,pickFenceForTesting:T,postHealComment:x,proposeAndApply:C,renderCommentBodyForTesting:_,renderProposalDiffForTesting:v,runHealForTesting:w,validateAppliedFix:y},Symbol.toStringTag,{value:"Module"});export{C as P,y as R,Q as d,gt as h,$ as k,it as p};