@buddysh/buddy 0.11.18 → 0.11.20

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 (180) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/bin/cli.ts +81 -71
  3. package/dist/bin/cli.js +72 -108
  4. package/dist/bin/entry.js +1 -1
  5. package/dist/bin/stacks.js +1 -1
  6. package/dist/{chunk-1pecmenc.js → chunk-016ce171.js} +1 -1
  7. package/dist/{chunk-w3ktf7th.js → chunk-038mdwdf.js} +3 -3
  8. package/dist/{chunk-8efgn47g.js → chunk-0668q6tf.js} +1 -1
  9. package/dist/{chunk-r976qdkb.js → chunk-09wkxvnt.js} +2 -2
  10. package/dist/{chunk-2z9mh5y4.js → chunk-0cqhy9qh.js} +1 -1
  11. package/dist/{chunk-4yy4f6wc.js → chunk-0n78c2xd.js} +1 -1
  12. package/dist/{chunk-v9aakgat.js → chunk-1ajy5sev.js} +1 -1
  13. package/dist/{chunk-h3vdnyqy.js → chunk-1aw736x8.js} +1 -1
  14. package/dist/{chunk-b22d85q8.js → chunk-2mtwdyka.js} +1 -1
  15. package/dist/{chunk-vx23zjwq.js → chunk-2qwk5xfp.js} +2 -2
  16. package/dist/chunk-3nvrjrtp.js +2 -0
  17. package/dist/{chunk-b75yqx1f.js → chunk-3sbrd9az.js} +1 -1
  18. package/dist/{chunk-gs26n8tm.js → chunk-5qj3vteh.js} +2 -2
  19. package/dist/chunk-5xgq771b.js +2 -0
  20. package/dist/chunk-64nen17y.js +2 -0
  21. package/dist/{chunk-13cpe0kf.js → chunk-64zgq7hq.js} +2 -2
  22. package/dist/{chunk-6v9c84ds.js → chunk-6evq4y1q.js} +2 -2
  23. package/dist/{chunk-18wwzwcz.js → chunk-6jak98cy.js} +1 -1
  24. package/dist/{chunk-rxqph6cj.js → chunk-6njk0m4a.js} +2 -2
  25. package/dist/{chunk-yy8vb4yk.js → chunk-6zp71ecf.js} +1 -1
  26. package/dist/chunk-71mhymva.js +2 -0
  27. package/dist/{chunk-09qpgqgj.js → chunk-7523xqb9.js} +2 -2
  28. package/dist/{chunk-5107xbwj.js → chunk-75rj89c2.js} +2 -2
  29. package/dist/chunk-7dgdvzxn.js +2 -0
  30. package/dist/{chunk-24xvskkf.js → chunk-7h8qjayv.js} +1 -1
  31. package/dist/{chunk-cj4d5ad7.js → chunk-7khgke9n.js} +1 -1
  32. package/dist/{chunk-48a66w2p.js → chunk-7vk0vrwm.js} +2 -2
  33. package/dist/{chunk-56t2za4k.js → chunk-91gpxfta.js} +1 -1
  34. package/dist/chunk-9dtfray9.js +2 -0
  35. package/dist/{chunk-dbhgxe35.js → chunk-9g0am1m2.js} +2 -2
  36. package/dist/chunk-9k79e8wa.js +2 -0
  37. package/dist/{chunk-p09rsh3z.js → chunk-9rvapdmv.js} +2 -2
  38. package/dist/chunk-a1ta528t.js +2 -0
  39. package/dist/{chunk-jpbq9xqv.js → chunk-a7r9dwmt.js} +1 -1
  40. package/dist/chunk-aa8gbnyc.js +2 -0
  41. package/dist/chunk-aw70467z.js +2 -0
  42. package/dist/{chunk-97857d8t.js → chunk-b1ng5aqx.js} +2 -2
  43. package/dist/chunk-b7f35wap.js +2 -0
  44. package/dist/{chunk-ad8ws736.js → chunk-brk9jn8q.js} +1 -1
  45. package/dist/chunk-cb6g7nt3.js +2 -0
  46. package/dist/{chunk-142zh7e5.js → chunk-cbzc9ggs.js} +1 -1
  47. package/dist/{chunk-n2de4spv.js → chunk-cf5czw9m.js} +2 -2
  48. package/dist/{chunk-gkdmk7xt.js → chunk-cftyw099.js} +1 -1
  49. package/dist/chunk-cndn37he.js +2 -0
  50. package/dist/chunk-cpc1y0gs.js +2 -0
  51. package/dist/{chunk-zdh3gd22.js → chunk-cqh3eadc.js} +2 -2
  52. package/dist/chunk-csf42r3d.js +2 -0
  53. package/dist/{chunk-sveh3wjr.js → chunk-dmqptf7k.js} +2 -2
  54. package/dist/chunk-dvnshk0g.js +2 -0
  55. package/dist/{chunk-rzxj5fgp.js → chunk-dz2e81v7.js} +2 -2
  56. package/dist/{chunk-3zp7a103.js → chunk-ep7hn1za.js} +1 -1
  57. package/dist/chunk-ezjvwa4v.js +2 -0
  58. package/dist/{chunk-rb6gzts6.js → chunk-fanj4t6c.js} +2 -2
  59. package/dist/chunk-fr2rhvnt.js +2 -0
  60. package/dist/chunk-fr7tw9n2.js +2 -0
  61. package/dist/{chunk-0baffydm.js → chunk-g0ttytab.js} +2 -2
  62. package/dist/chunk-gcmx3cp6.js +2 -0
  63. package/dist/{chunk-nn9rcqsz.js → chunk-gn3tjadq.js} +2 -2
  64. package/dist/chunk-gqqqhe3n.js +2 -0
  65. package/dist/{chunk-yh13j2af.js → chunk-gt3m1eqn.js} +1 -1
  66. package/dist/{chunk-w20n4t27.js → chunk-h0bf6z4x.js} +2 -2
  67. package/dist/{chunk-dcbkac9x.js → chunk-jrkmj5ex.js} +1 -1
  68. package/dist/chunk-jzhsa1xh.js +2 -0
  69. package/dist/chunk-kebfqksf.js +2 -0
  70. package/dist/{chunk-kqwdg3nw.js → chunk-kfn6xbc6.js} +1 -1
  71. package/dist/{chunk-wjzravb7.js → chunk-m7v1dba6.js} +2 -2
  72. package/dist/chunk-me7y4rd3.js +3 -0
  73. package/dist/{chunk-nkwfez01.js → chunk-mpk7ypxd.js} +1 -1
  74. package/dist/{chunk-5czhqsvn.js → chunk-n1g9gs8x.js} +3 -3
  75. package/dist/{chunk-c5d5webv.js → chunk-n5mvfhd0.js} +2 -2
  76. package/dist/{chunk-s3t54kj1.js → chunk-n7hbbha7.js} +2 -2
  77. package/dist/{chunk-b27ezdzq.js → chunk-n8zfts91.js} +4 -4
  78. package/dist/{chunk-xaw1yts1.js → chunk-nap5dm82.js} +2 -2
  79. package/dist/chunk-nekgd2v5.js +2 -0
  80. package/dist/{chunk-q2tjkhez.js → chunk-np5qajht.js} +1 -1
  81. package/dist/{chunk-drn3hq53.js → chunk-nqgn0drz.js} +7 -7
  82. package/dist/{chunk-35wxea5y.js → chunk-nrm7vjmv.js} +2 -2
  83. package/dist/chunk-nwj826gp.js +2 -0
  84. package/dist/chunk-p0s7w67s.js +2 -0
  85. package/dist/{chunk-r7c4arkp.js → chunk-p59g8wwa.js} +1 -1
  86. package/dist/{chunk-2z54h4e9.js → chunk-pakq6dsv.js} +2 -2
  87. package/dist/{chunk-hzpsmg4z.js → chunk-q31cbz9d.js} +2 -2
  88. package/dist/{chunk-292qaqqe.js → chunk-q496yz80.js} +1 -1
  89. package/dist/chunk-q7250hvx.js +4 -0
  90. package/dist/chunk-q8wzcyxj.js +2 -0
  91. package/dist/{chunk-vna64r40.js → chunk-qeg388qq.js} +2 -2
  92. package/dist/{chunk-wkjv03yr.js → chunk-rad9rc2j.js} +1 -1
  93. package/dist/chunk-rbhz8bda.js +2 -0
  94. package/dist/{chunk-wm6g7y1r.js → chunk-rk5j5mcr.js} +1 -1
  95. package/dist/chunk-rma8b124.js +2 -0
  96. package/dist/chunk-s3g9x8wf.js +1043 -0
  97. package/dist/{chunk-j9xw849s.js → chunk-s44q0cps.js} +2 -2
  98. package/dist/{chunk-jan74vw2.js → chunk-s8apaa3h.js} +5 -5
  99. package/dist/chunk-sa2m2y9s.js +2 -0
  100. package/dist/{chunk-vjav82c6.js → chunk-skg1syjj.js} +1 -1
  101. package/dist/chunk-swmkkya0.js +2 -0
  102. package/dist/chunk-t64134ws.js +2 -0
  103. package/dist/{chunk-9mpeqda3.js → chunk-t68hsq01.js} +2 -2
  104. package/dist/{chunk-c067bnx5.js → chunk-t81252jj.js} +2 -2
  105. package/dist/{chunk-339ae7vn.js → chunk-tf0mb8m0.js} +2 -2
  106. package/dist/chunk-txpb6btd.js +2 -0
  107. package/dist/chunk-tzz4mpz5.js +2 -0
  108. package/dist/{chunk-0g44mytk.js → chunk-v32q2vv7.js} +1 -1
  109. package/dist/chunk-v8dteyvv.js +2 -0
  110. package/dist/{chunk-2k7b8te1.js → chunk-vcn1gemr.js} +1 -1
  111. package/dist/chunk-ve9xvyez.js +2 -0
  112. package/dist/chunk-vtjh07ea.js +2 -0
  113. package/dist/chunk-wc68652g.js +2 -0
  114. package/dist/{chunk-j46f90n8.js → chunk-we0x722x.js} +1 -1
  115. package/dist/{chunk-d3cqth47.js → chunk-weqbnsnn.js} +1 -1
  116. package/dist/{chunk-mm9b9pwb.js → chunk-wr7scn9c.js} +1 -1
  117. package/dist/{chunk-t74w5ddy.js → chunk-x33ryte5.js} +2 -2
  118. package/dist/{chunk-x9vpk4kk.js → chunk-x496v9vb.js} +1 -1
  119. package/dist/chunk-x7y2eh7c.js +2 -0
  120. package/dist/chunk-xd6sxr1m.js +3 -0
  121. package/dist/{chunk-ejfyc7r8.js → chunk-xdqk8fzw.js} +1 -1
  122. package/dist/chunk-xkhznax2.js +2 -0
  123. package/dist/{chunk-eaz23nsf.js → chunk-xmqv24zr.js} +1 -1
  124. package/dist/{chunk-0hrxtesf.js → chunk-xt0k22yx.js} +2 -2
  125. package/dist/{chunk-npjgqzfg.js → chunk-xx7cytzs.js} +2 -2
  126. package/dist/chunk-y59p36an.js +2 -0
  127. package/dist/{chunk-nznpzbq4.js → chunk-y5t07fny.js} +1 -1
  128. package/dist/{chunk-b8bfag6k.js → chunk-yknz94wd.js} +2 -2
  129. package/dist/{chunk-d2vrstjq.js → chunk-yzyqkwsc.js} +1 -1
  130. package/dist/{chunk-g482e1b0.js → chunk-zbk3g5vf.js} +3 -3
  131. package/dist/{chunk-249qcsjm.js → chunk-ze91acnq.js} +1 -1
  132. package/dist/chunk-zhgwbbj9.js +2 -0
  133. package/dist/chunk-zqrgvftj.js +3 -0
  134. package/dist/chunk-zza4y6dx.js +2 -0
  135. package/dist/src/index.js +1 -1
  136. package/dist/src/setup.js +1 -1
  137. package/package.json +2 -4
  138. package/dist/chunk-255r8t6k.js +0 -2
  139. package/dist/chunk-2c2bkhwj.js +0 -2
  140. package/dist/chunk-4aavwqyt.js +0 -2
  141. package/dist/chunk-6c6e5xgb.js +0 -2
  142. package/dist/chunk-7qp8ng5e.js +0 -2
  143. package/dist/chunk-7rdqaj9g.js +0 -2
  144. package/dist/chunk-87x43s85.js +0 -2
  145. package/dist/chunk-981xyxzj.js +0 -2
  146. package/dist/chunk-a12s15m8.js +0 -2
  147. package/dist/chunk-a7veqg3a.js +0 -2
  148. package/dist/chunk-b9b3xwar.js +0 -2
  149. package/dist/chunk-bjvx1r6g.js +0 -2
  150. package/dist/chunk-c7s8nsbr.js +0 -2
  151. package/dist/chunk-ckvtfmyg.js +0 -2
  152. package/dist/chunk-ems4rhqe.js +0 -2
  153. package/dist/chunk-erges5h8.js +0 -1070
  154. package/dist/chunk-f1d20z92.js +0 -2
  155. package/dist/chunk-f4rmh2s9.js +0 -2
  156. package/dist/chunk-ff1dah6m.js +0 -2
  157. package/dist/chunk-fz9th4yv.js +0 -2
  158. package/dist/chunk-haemkbh1.js +0 -2
  159. package/dist/chunk-hgcr63c6.js +0 -2
  160. package/dist/chunk-hh4zq6m0.js +0 -2
  161. package/dist/chunk-j5k195b6.js +0 -2
  162. package/dist/chunk-jf4s1r34.js +0 -2
  163. package/dist/chunk-k1w134pz.js +0 -2
  164. package/dist/chunk-ksght1x7.js +0 -2
  165. package/dist/chunk-mkfsh53w.js +0 -2
  166. package/dist/chunk-nfcxgb5d.js +0 -2
  167. package/dist/chunk-pbrpej0s.js +0 -2
  168. package/dist/chunk-pz2nmnhh.js +0 -2
  169. package/dist/chunk-sc4bxrwb.js +0 -2
  170. package/dist/chunk-tp3hze1v.js +0 -2
  171. package/dist/chunk-v02hzntq.js +0 -2
  172. package/dist/chunk-vg0pry4b.js +0 -2
  173. package/dist/chunk-vgys0c1v.js +0 -2
  174. package/dist/chunk-wk4rtet9.js +0 -2
  175. package/dist/chunk-wq4g8082.js +0 -2
  176. package/dist/chunk-x8dry63m.js +0 -2
  177. package/dist/chunk-y2zqnbbf.js +0 -2
  178. package/dist/chunk-z18bksyr.js +0 -3
  179. package/dist/chunk-za2yg8vc.js +0 -2
  180. package/dist/chunk-zrnfjw7d.js +0 -2
package/dist/bin/entry.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env -S bun --config=/dev/null --no-install --no-env-file
2
2
  // @bun
3
- import{Eh as n,Fh as o}from"../chunk-2k7b8te1.js";import{il as s}from"../chunk-eaz23nsf.js";import a from"process";async function t(){let i=n(a.argv.slice(2));if(i)o(i);let{cli:r}=await import("./cli.js");r.parse()}if(import.meta.main)await t();export{t as main};
3
+ import{Jh as n,Kh as o}from"../chunk-vcn1gemr.js";import{nl as s}from"../chunk-xmqv24zr.js";import a from"process";async function t(){let i=n(a.argv.slice(2));if(i)o(i);let{cli:r}=await import("./cli.js");r.parse()}if(import.meta.main)await t();export{t as main};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env -S bun --config=/dev/null --no-install --no-env-file
2
2
  // @bun
3
- import{Fh as n}from"../chunk-2k7b8te1.js";import"../chunk-eaz23nsf.js";import i from"process";if(import.meta.main)n(i.argv.slice(2));
3
+ import{Kh as n}from"../chunk-vcn1gemr.js";import"../chunk-xmqv24zr.js";import i from"process";if(import.meta.main)n(i.argv.slice(2));
@@ -59,4 +59,4 @@ You cannot modify anything.
59
59
 
60
60
  Name the files that would change and why, the order of the work, the risks,
61
61
  and how the result would be verified.`},z={review:B,implement:F,"fix-ci":H,plan:I};function J(j){let q=z[j];if(!q)throw Error(`Unknown agent mode: ${j}. Available: ${Object.keys(z).join(", ")}`);return q}
62
- export{B as zf,F as Af,H as Bf,I as Cf,z as Df,J as Ef};
62
+ export{B as Cf,F as Df,H as Ef,I as Ff,z as Gf,J as Hf};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{tg as C,yg as B}from"./chunk-x9vpk4kk.js";import{Ag as v,Bg as x}from"./chunk-5107xbwj.js";import{zh as w}from"./chunk-yh13j2af.js";import{Nh as S}from"./chunk-kqwdg3nw.js";import{il as T}from"./chunk-eaz23nsf.js";var R={critical:"\uD83D\uDD34 Critical",high:"\uD83D\uDFE0 High",moderate:"\uD83D\uDFE1 Moderate",low:"\u26AA Low"};function F(J){let Q=J.filter((O)=>(O.securityAdvisories?.length??0)>0);if(Q.length===0)return"";let q=Q.reduce((O,Z)=>O+(Z.securityAdvisories?.length??0),0),X=`## \uD83D\uDD12 Security Advisories
2
+ import{Bg as B,wg as C}from"./chunk-x496v9vb.js";import{Dg as v,Eg as x}from"./chunk-75rj89c2.js";import{Eh as w}from"./chunk-gt3m1eqn.js";import{Sh as S}from"./chunk-kfn6xbc6.js";import{nl as T}from"./chunk-xmqv24zr.js";var R={critical:"\uD83D\uDD34 Critical",high:"\uD83D\uDFE0 High",moderate:"\uD83D\uDFE1 Moderate",low:"\u26AA Low"};function F(J){let Q=J.filter((O)=>(O.securityAdvisories?.length??0)>0);if(Q.length===0)return"";let q=Q.reduce((O,Z)=>O+(Z.securityAdvisories?.length??0),0),X=`## \uD83D\uDD12 Security Advisories
3
3
 
4
4
  `;X+=`This PR resolves ${q} known ${q===1?"vulnerability":"vulnerabilities"} `,X+=`across ${Q.length} ${Q.length===1?"package":"packages"}.
5
5
 
@@ -7,7 +7,7 @@ import{tg as C,yg as B}from"./chunk-x9vpk4kk.js";import{Ag as v,Bg as x}from"./c
7
7
  `,X+=`|---|---|---|---|---|
8
8
  `;for(let O of Q)for(let Z of O.securityAdvisories??[]){let L=R[Z.severity]??Z.severity,_=Z.url?`[${Z.id}](${Z.url})`:Z.id,$=Z.aliases.length>0?` (${Z.aliases.join(", ")})`:"",G=Z.summary.replace(/\|/g,"\\|").replace(/\s*\n\s*/g," ").trim();X+=`| \`${O.name}\` | ${L} | ${_}${$} | \`${Z.fixedVersion??"n/a"}\` | ${G} |
9
9
  `}return`${X}
10
- `}async function u(J,Q){try{let q=Q.split("/").pop()||"";if(q==="package.json"){let X=JSON.parse(J),O=[];return W(X.dependencies,"dependencies",Q,O),W(X.devDependencies,"devDependencies",Q,O),W(X.peerDependencies,"peerDependencies",Q,O),W(X.optionalDependencies,"optionalDependencies",Q,O),{path:Q,type:"package.json",content:J,dependencies:O}}if(v(Q))return await x(Q,J);if(q==="composer.json"||q==="composer.lock"){let{parseComposerFile:X}=await import("./chunk-gkdmk7xt.js");return await X(Q,J)}return null}catch{return null}}function W(J,Q,q,X){if(!J)return;for(let[O,Z]of Object.entries(J))X.push({name:O,currentVersion:Z,type:Q,file:q})}function n(J){let{existsSync:Q}=T("fs"),{join:q}=T("path");if(Q(q(J,"bun.lockb"))||Q(q(J,"bun.lock")))return"bun";if(Q(q(J,"pnpm-lock.yaml")))return"pnpm";if(Q(q(J,"yarn.lock")))return"yarn";if(Q(q(J,"package-lock.json")))return"npm";return"bun"}function d(J,Q){if(Q)return Q;if(J.length===1){let Z=J[0];return`chore(deps): update dependency ${Z.name} to ${Z.newVersion}`}let q=J.filter((Z)=>Z.updateType==="major"),X=J.filter((Z)=>Z.updateType==="minor"),O=J.filter((Z)=>Z.updateType==="patch");if(q.length>0)return`chore(deps): update ${q.length} major dependencies`;else if(X.length>0)return`chore(deps): update ${X.length} minor dependencies`;else return`chore(deps): update ${O.length} patch dependencies`}function o(J,Q){if(Q)return Q;if(J.length===1){let X=J[0];return`chore(deps): update dependency ${X.name} to v${X.newVersion}`}let q=J.filter((X)=>X.updateType==="major");if(q.length>0)return`chore(deps): update ${q.length} major dependencies`;else return"chore(deps): update all non-major dependencies"}function z(J,Q){if(Q)return Q;let q=`This PR contains the following updates:
10
+ `}async function u(J,Q){try{let q=Q.split("/").pop()||"";if(q==="package.json"){let X=JSON.parse(J),O=[];return W(X.dependencies,"dependencies",Q,O),W(X.devDependencies,"devDependencies",Q,O),W(X.peerDependencies,"peerDependencies",Q,O),W(X.optionalDependencies,"optionalDependencies",Q,O),{path:Q,type:"package.json",content:J,dependencies:O}}if(v(Q))return await x(Q,J);if(q==="composer.json"||q==="composer.lock"){let{parseComposerFile:X}=await import("./chunk-cftyw099.js");return await X(Q,J)}return null}catch{return null}}function W(J,Q,q,X){if(!J)return;for(let[O,Z]of Object.entries(J))X.push({name:O,currentVersion:Z,type:Q,file:q})}function n(J){let{existsSync:Q}=T("fs"),{join:q}=T("path");if(Q(q(J,"bun.lockb"))||Q(q(J,"bun.lock")))return"bun";if(Q(q(J,"pnpm-lock.yaml")))return"pnpm";if(Q(q(J,"yarn.lock")))return"yarn";if(Q(q(J,"package-lock.json")))return"npm";return"bun"}function d(J,Q){if(Q)return Q;if(J.length===1){let Z=J[0];return`chore(deps): update dependency ${Z.name} to ${Z.newVersion}`}let q=J.filter((Z)=>Z.updateType==="major"),X=J.filter((Z)=>Z.updateType==="minor"),O=J.filter((Z)=>Z.updateType==="patch");if(q.length>0)return`chore(deps): update ${q.length} major dependencies`;else if(X.length>0)return`chore(deps): update ${X.length} minor dependencies`;else return`chore(deps): update ${O.length} patch dependencies`}function o(J,Q){if(Q)return Q;if(J.length===1){let X=J[0];return`chore(deps): update dependency ${X.name} to v${X.newVersion}`}let q=J.filter((X)=>X.updateType==="major");if(q.length>0)return`chore(deps): update ${q.length} major dependencies`;else return"chore(deps): update all non-major dependencies"}function z(J,Q){if(Q)return Q;let q=`This PR contains the following updates:
11
11
 
12
12
  `;q+=F(J),q+=`| Package | Change | Age | Adoption | Passing | Confidence |
13
13
  `,q+=`|---|---|---|---|---|---|
@@ -41,4 +41,4 @@ import{tg as C,yg as B}from"./chunk-x9vpk4kk.js";import{Ag as v,Bg as x}from"./c
41
41
  `,q+=`---
42
42
 
43
43
  `,q+="This PR was generated by [Buddy](https://github.com/stacksjs/buddy).",q}function i(J,Q="buddy"){if(J.length===1){let X=J[0],O=X.name.replace(/[^a-z0-9-]/gi,"-");return`${Q}/update-${O}-to-${X.newVersion}`}if(J.filter((X)=>X.updateType==="major").length>0)return`${Q}/update-major-dependencies`;return`${Q}/update-dependencies`}function j(J){let Q=new Map;for(let X of J){let O=`${X.name}:${X.currentVersion}:${X.newVersion}`;Q.set(O,[...Q.get(O)??[],X])}let q=[];for(let X of Q.values()){let O=X.filter((L)=>k(L.file));if(O.length>0){let L=new Set;for(let _ of O)if(!L.has(_.file))L.add(_.file),q.push(_);continue}let Z=X[0];for(let L of X.slice(1))if(N(L.file)>N(Z.file))Z=L;q.push(Z)}return q}function k(J){let Q=J.split("/").pop()??"";return Q==="package.json"||Q==="composer.json"}function N(J){if(J==="package.json")return 3;if(J.endsWith("composer.json"))return 2;if(J.includes(".github/workflows/"))return 1;return 0}function s(J,Q={}){let{prioritizeSecurity:q=!0}=Q,X=[],O=j(J),Z=q?O.filter((Y)=>(Y.securityAdvisories?.length??0)>0):[],L=q?O.filter((Y)=>(Y.securityAdvisories?.length??0)===0):O;if(Z.length>0)X.push({name:"Security Updates",updates:Z,updateType:D(Z),title:"fix(deps): update vulnerable dependencies",body:z(Z)});let _=L.filter((Y)=>Y.dependencyType==="github-actions"),$=L.filter((Y)=>Y.dependencyType==="docker-image"),G=L.filter((Y)=>Y.dependencyType!=="github-actions"&&Y.dependencyType!=="docker-image");if(_.length>0)X.push({name:"GitHub Actions",updates:_,updateType:D(_),title:"chore(deps): update github actions",body:z(_)});if($.length>0)X.push({name:"Docker Images",updates:$,updateType:D($),title:"chore(deps): update docker images",body:z($)});let H=G.filter((Y)=>Y.updateType==="major"),K=G.filter((Y)=>Y.updateType==="minor"),I=G.filter((Y)=>Y.updateType==="patch");if(K.length>0||I.length>0){let Y=[...K,...I];X.push({name:"Non-Major Updates",updates:Y,updateType:K.length>0?"minor":"patch",title:"chore(deps): update all non-major dependencies",body:z(Y)})}let A=new Map;for(let Y of H){let E=`${Y.name}@${Y.newVersion}`;A.set(E,[...A.get(E)??[],Y])}for(let Y of A.values()){let E=Y[0];X.push({name:`Major Update - ${E.name}`,updates:Y,updateType:"major",title:`chore(deps): update dependency ${E.name} to ${E.newVersion}`,body:z(Y)})}return X}function D(J){if(J.some((Q)=>Q.updateType==="major"))return"major";if(J.some((Q)=>Q.updateType==="minor"))return"minor";return"patch"}var U={critical:4,high:3,moderate:2,low:1};function V(J){let Q=0;for(let q of J.securityAdvisories??[])Q=Math.max(Q,U[q.severity]??0);return Q}function r(J,Q={}){let{prioritizeSecurity:q=!0}=Q,X={major:3,minor:2,patch:1};return J.sort((O,Z)=>{let L=q?V(O):0,_=q?V(Z):0;if(L!==_)return _-L;let $=X[O.updateType],G=X[Z.updateType];if($!==G)return G-$;return O.name.localeCompare(Z.name)})}function p(J,Q){let q=M(J.replace(/^[v^~>=<@]+/,"")),X=M(Q.replace(/^[v^~>=<@]+/,""));try{if(Bun.semver.order(X,q)<=0)return"patch"}catch{return"patch"}let O=q.split(".").map((H)=>Number.parseInt(H,10)),Z=X.split(".").map((H)=>Number.parseInt(H,10));while(O.length<3)O.push(0);while(Z.length<3)Z.push(0);let[L,_]=O,[$,G]=Z;if($>L)return"major";if($===L&&G>_)return"minor";return"patch"}function M(J){let Q=J.split(".");if(Q.length>=3||!Q.every((q)=>/^\d+$/.test(q)))return J;while(Q.length<3)Q.push("0");return Q.join(".")}function a(J,Q){try{return Bun.semver.satisfies(J,Q)}catch{return!1}}async function t(J,Q,q){if(!J)throw Error("GitHub token is required");try{let X=await S(`${w()}/repos/${Q}/${q}/pulls?state=open`,{headers:{Authorization:`Bearer ${J}`,Accept:"application/vnd.github+json","User-Agent":"buddy"}});if(!X.ok)throw Error(`GitHub API error: ${X.status} ${X.statusText}`);return(await X.json()).filter((L)=>{if(!L.body)return!1;return/\s*-\s*\[x\]\s*<!--\s*rebase-check\s*-->.*(?:rebase|update)\/retry/i.test(L.body)}).map((L)=>({number:L.number,branchName:L.head.ref}))}catch(X){throw Error(`Failed to check for rebase requests: ${X}`)}}function e(J){let Q=C(J);if(Q)return[...new Set(Q.updates.map((O)=>O.name))];let q=[],X=J.match(/\|[^|]*\|[^|]*\|[^|]*\|[^|]*\|/g);if(X)for(let O of X){let Z=O.match(/\[([^\]]+)\]\([^)]*\)/);if(Z)q.push(Z[1])}return q}async function qq(J,Q,q){if(await b(J,Q,q))return!0;if(await m(J,Q,q))return!0;return!1}async function b(J,Q,q){if(!(Q.packages?.respectLatest??!0))return q.debug(`\uD83D\uDD0D PR #${J.number}: respectLatest is false, skipping auto-close`),!1;let O=["latest","*","main","master","develop","dev"],Z=C(J.body);if(Z){let H=Z.updates.filter((K)=>O.includes(K.current.toLowerCase().trim()));for(let K of H)q.debug(`\uD83D\uDD0D PR #${J.number}: Package ${K.name} has dynamic version "${K.current}"`);return q.debug(`\uD83D\uDD0D PR #${J.number}: Should auto-close: ${H.length>0}`),H.length>0}let L=/\|\s*\[([^\]]+)\][^|]*\|\s*\[?`?[v^~>=]*([^`|\s]+)`?\s*(?:->|\u2192)\s*`?[v^~>=]*([^`|\s]+)`?\]?/g,_,$=[];while((_=L.exec(J.body))!==null){let[,H,K]=_,I=K.toLowerCase().trim();if(O.includes(I))$.push(H),q.debug(`\uD83D\uDD0D PR #${J.number}: Package ${H} has dynamic version "${I}"`)}let G=$.length>0;return q.debug(`\uD83D\uDD0D PR #${J.number}: Packages with dynamic versions: ${$.join(", ")}`),q.debug(`\uD83D\uDD0D PR #${J.number}: Should auto-close: ${G}`),G}async function m(J,Q,q){let X=Q.packages?.ignorePaths;if(!X||X.length===0)return q.debug(`\uD83D\uDD0D PR #${J.number}: No ignorePaths configured, skipping auto-close`),!1;let O=P(J.body);if(O.length===0)return q.debug(`\uD83D\uDD0D PR #${J.number}: No file paths found in PR body`),!1;q.debug(`\uD83D\uDD0D PR #${J.number}: Found file paths: ${O.join(", ")}`);let{Glob:Z}=globalThis.Bun,L=O.filter((_)=>{let $=_.replace(/^\.\//,"");return X.some((G)=>{try{return new Z(G).match($)}catch(H){return q.debug(`Failed to match path ${$} against pattern ${G}: ${H}`),!1}})});if(L.length>0)return q.debug(`\uD83D\uDD0D PR #${J.number}: Contains files now in ignorePaths: ${L.join(", ")}`),!0;return q.debug(`\uD83D\uDD0D PR #${J.number}: No files match ignorePaths patterns`),!1}function P(J){let Q=C(J);if(Q)return B(Q);let q=[],X=/\|\s*\[[^\]]+\]\([^)]*\)\s*\|[^|]*\|\s*\*\*([^*]+)\*\*\s*\|/g,O;while((O=X.exec(J))!==null){let $=O[1].trim();if($&&!q.includes($))q.push($)}let Z=/\*\*([^*]+\.(?:json|yaml|yml|lock))\*\*/g;while((O=Z.exec(J))!==null){let $=O[1].trim();if($&&!q.includes($))q.push($)}let L=/\|[^|]+\|[^|]+\|([^|]+)\|[^|]*\|/g;while((O=L.exec(J))!==null){let $=O[1].trim();if($&&($.includes("/")||/\.(?:json|yaml|yml|lock)$/.test($))&&!q.includes($))q.push($)}let _=/(?:^|\s)([\w-]+(?:\/[\w.-]+)*\/[\w.-]+\.(?:json|yaml|yml|lock))(?:\s|$)/gm;while((O=_.exec(J))!==null){let $=O[1].trim();if($&&!q.includes($))q.push($)}return q}
44
- export{F as bg,u as cg,n as dg,d as eg,o as fg,z as gg,i as hg,s as ig,r as jg,p as kg,a as lg,t as mg,e as ng,qq as og};
44
+ export{F as eg,u as fg,n as gg,d as hg,o as ig,z as jg,i as kg,s as lg,r as mg,p as ng,a as og,t as pg,e as qg,qq as rg};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{pg as a,qg as b,rg as c,sg as d,tg as e,ug as f,vg as g,wg as h,xg as i,yg as j,zg as k}from"./chunk-x9vpk4kk.js";import"./chunk-eaz23nsf.js";export{h as withManifest,g as stripManifest,c as serializeManifest,d as serializeGroupManifest,e as parseManifest,i as manifestUpdates,j as manifestFiles,f as hasManifest,k as findGroupForPullRequest,a as MANIFEST_SCHEMA_VERSION,b as MANIFEST_MAX_LENGTH};
2
+ import{Ag as i,Bg as j,Cg as k,sg as a,tg as b,ug as c,vg as d,wg as e,xg as f,yg as g,zg as h}from"./chunk-x496v9vb.js";import"./chunk-xmqv24zr.js";export{h as withManifest,g as stripManifest,c as serializeManifest,d as serializeGroupManifest,e as parseManifest,i as manifestUpdates,j as manifestFiles,f as hasManifest,k as findGroupForPullRequest,a as MANIFEST_SCHEMA_VERSION,b as MANIFEST_MAX_LENGTH};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Ih as V}from"./chunk-wkjv03yr.js";import{Nh as M}from"./chunk-kqwdg3nw.js";import{Qh as K,Th as Q}from"./chunk-56t2za4k.js";class X{token;apiUrl;logger;slug;constructor(j,z,A,C,F){this.token=j;this.apiUrl=(C??"https://api.bitbucket.org/2.0").replace(/\/+$/,""),this.logger=F??Q(),this.slug=`${encodeURIComponent(z)}/${encodeURIComponent(A)}`}capabilities(){return{pinIssues:!1,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!1,nativeAutoMerge:!1,commentReactions:!1,ciLogs:!1,ciRuns:!1,reviewThreads:!1,teamReviewers:!1,draftPullRequests:!1,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!1,labels:!1}}async request(j,z,A,C={}){let F={Authorization:`Bearer ${this.token}`,Accept:C.raw?"text/plain":"application/json","User-Agent":"buddy"},H;if(C.form)F["Content-Type"]="application/x-www-form-urlencoded",H=new URLSearchParams(C.form).toString();else if(A)F["Content-Type"]="application/json",H=JSON.stringify(A);let G=await M(`${this.apiUrl}${z}`,{method:j,headers:F,...H?{body:H}:{}});if(!G.ok){let J=await G.text().catch(()=>"");throw Error(`Bitbucket ${j} ${z} failed: ${G.status} ${J.slice(0,200)}`)}let I=await G.text();if(C.raw)return I;return I.trim()?JSON.parse(I):void 0}async optional(j,z){try{return await this.request(j,z)}catch(A){if(String(A).includes("404"))return null;throw A}}async collect(j,z=10){let A=[],C=`${this.apiUrl}${j}`;for(let F=0;F<z&&C;F++){let H=C,G=await this.optional("GET",H.startsWith(this.apiUrl)?H.slice(this.apiUrl.length):H);if(!G)break;A.push(...G.values??[]),C=G.next}return A}async branchExists(j){return await this.optional("GET",`/repositories/${this.slug}/refs/branches/${encodeURIComponent(j)}`)!==null}async createBranch(j,z){await this.request("POST",`/repositories/${this.slug}/refs/branches`,{name:j,target:{hash:z}})}async deleteBranch(j){await this.request("DELETE",`/repositories/${this.slug}/refs/branches/${encodeURIComponent(j)}`)}async commitChanges(j,z,A,C="main"){if(A.length===0)return;let F={message:z,branch:j};for(let I of A)if(I.type==="delete")F.files=F.files?`${F.files},${I.path}`:I.path;else F[I.path]=I.content;let H=new URLSearchParams;for(let[I,J]of Object.entries(F)){if(I==="files")continue;H.append(I,J)}for(let I of A)if(I.type==="delete")H.append("files",I.path);let G=await this.headOf(C);if(G)H.append("parents",G);await this.request("POST",`/repositories/${this.slug}/src`,void 0,{form:Object.fromEntries(H.entries())})}async headOf(j){return(await this.optional("GET",`/repositories/${this.slug}/refs/branches/${encodeURIComponent(j)}`))?.target?.hash??null}async getFileContent(j,z){try{return await this.request("GET",`/repositories/${this.slug}/src/${encodeURIComponent(z)}/${j}`,void 0,{raw:!0})}catch(A){if(String(A).includes("404"))return null;throw A}}async createPullRequest(j){if(j.draft)this.logger.debug("Bitbucket has no draft pull requests; opening as ready");let z=await this.request("POST",`/repositories/${this.slug}/pullrequests`,{title:j.title,description:j.body,source:{branch:{name:j.head}},destination:{branch:{name:j.base}},close_source_branch:!0,...j.reviewers?.length?{reviewers:j.reviewers.map((A)=>({nickname:A}))}:{}});return this.toPullRequest(z)}async getPullRequests(j="open"){let A=(j==="open"?["OPEN"]:j==="closed"?["MERGED","DECLINED","SUPERSEDED"]:["OPEN","MERGED","DECLINED","SUPERSEDED"]).map((F)=>`state=${F}`).join("&");return(await this.collect(`/repositories/${this.slug}/pullrequests?${A}&pagelen=50`)).map((F)=>this.toPullRequest(F))}async updatePullRequest(j,z){let A=await this.request("PUT",`/repositories/${this.slug}/pullrequests/${j}`,{...z.title!==void 0?{title:z.title}:{},...z.body!==void 0?{description:z.body}:{},...z.base!==void 0?{destination:{branch:{name:z.base}}}:{}});return this.toPullRequest(A)}async closePullRequest(j){await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/decline`)}async reopenPullRequest(j){throw Error(`Bitbucket cannot reopen declined pull request #${j}; open a new one from the same branch.`)}async mergePullRequest(j,z="squash"){let A={merge:"merge_commit",squash:"squash",rebase:"fast_forward"};await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/merge`,{merge_strategy:A[z]??"squash",close_source_branch:!0})}async getPullRequestDiff(j){return await this.request("GET",`/repositories/${this.slug}/pullrequests/${j}/diff`,void 0,{raw:!0})}async getPullRequestHeadSha(j){return(await this.request("GET",`/repositories/${this.slug}/pullrequests/${j}`)).source?.commit?.hash??""}async createComment(j,z){await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/comments`,{content:{raw:z}})}async createIssue(j){let z=await this.request("POST",`/repositories/${this.slug}/issues`,{title:j.title,content:{raw:j.body},kind:"task"});return this.toIssue(z)}async getIssues(j="open"){let A=(await this.collect(`/repositories/${this.slug}/issues?pagelen=50`)).map((C)=>this.toIssue(C));return j==="all"?A:A.filter((C)=>C.state===j)}async updateIssue(j,z){let A=await this.request("PUT",`/repositories/${this.slug}/issues/${j}`,{...z.title!==void 0?{title:z.title}:{},...z.body!==void 0?{content:{raw:z.body}}:{}});return this.toIssue(A)}async closeIssue(j){await this.request("PUT",`/repositories/${this.slug}/issues/${j}`,{state:"closed"})}async unpinIssue(j){return!1}async getPullRequestChecksState(j){let z=await this.getPullRequestHeadSha(j);if(!z)return"none";let A=await this.collect(`/repositories/${this.slug}/commit/${z}/statuses?pagelen=50`);if(A.length===0)return"none";if(A.some((C)=>C.state==="FAILED"||C.state==="STOPPED"))return"failure";if(A.some((C)=>C.state==="INPROGRESS"))return"pending";if(A.every((C)=>C.state==="SUCCESSFUL"))return"success";return"pending"}async createReview(j,z){if(await this.createComment(j,z.body),!z.comments?.length)return{posted:!0,inlineComments:0};let A=0;for(let C of z.comments)try{await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/comments`,{content:{raw:C.body},inline:{path:C.path,...C.side==="RIGHT"?{to:C.line}:{from:C.line}}}),A++}catch(F){this.logger.debug(`Could not place a comment on ${C.path}:${C.line}: ${K(F)}`)}return{posted:!0,inlineComments:A}}async createCheckRun(j,z,A){try{await this.request("POST",`/repositories/${this.slug}/commit/${z}/statuses/build`,{key:j.replace(/[^\w-]/g,"-").slice(0,40),state:A.conclusion==="failure"?"FAILED":"SUCCESSFUL",name:A.title.slice(0,100),description:A.summary.slice(0,300),url:"https://buddy.sh"})}catch(C){this.logger.warn(`\u26A0\uFE0F Could not report build status ${j}: ${K(C)}`)}}async hasWriteAccess(j){let A=(await this.optional("GET",`/repositories/${this.slug}/permissions-config/users`))?.values?.find((C)=>C.user?.nickname===j);return A?.permission==="write"||A?.permission==="admin"}async getBuddyBranches(){return(await this.collect(`/repositories/${this.slug}/refs/branches?q=${encodeURIComponent('name ~ "buddy/"')}&pagelen=50`)).filter((z)=>V(z.name)).map((z)=>({name:z.name,sha:z.target?.hash??"",lastCommitDate:z.target?.date?new Date(z.target.date):new Date(0)}))}async getOrphanedBuddyBranches(){let[j,z]=await Promise.all([this.getBuddyBranches(),this.getPullRequests("open")]),A=new Set(z.map((C)=>C.head));return j.filter((C)=>!A.has(C.name))}async cleanupStaleBranches(j=7,z=!1){let A=new Date(Date.now()-j*24*60*60*1000),C=(await this.getOrphanedBuddyBranches()).filter((G)=>G.lastCommitDate<A);if(z)return{deleted:C.map((G)=>G.name),failed:[]};let F=[],H=[];for(let G of C)try{await this.deleteBranch(G.name),F.push(G.name)}catch{H.push(G.name)}return{deleted:F,failed:H}}toPullRequest(j){let z=j.state==="MERGED"?"merged":j.state==="OPEN"?"open":"closed";return{number:j.id,title:j.title,body:j.description??"",head:j.source?.branch?.name??"",base:j.destination?.branch?.name??"",state:z,url:j.links?.html?.href??"",createdAt:new Date(j.created_on),updatedAt:new Date(j.updated_on),...z==="merged"?{mergedAt:new Date(j.updated_on)}:{},author:j.author?.nickname??j.author?.display_name??"",reviewers:(j.reviewers??[]).map((A)=>A.nickname??A.display_name??"").filter(Boolean),assignees:[],labels:[],draft:!1}}toIssue(j){let z=["new","open","on hold"].includes(j.state);return{number:j.id,title:j.title,body:j.content?.raw??"",state:z?"open":"closed",url:j.links?.html?.href??"",createdAt:new Date(j.created_on),updatedAt:new Date(j.updated_on),...z?{}:{closedAt:new Date(j.updated_on)},author:j.reporter?.nickname??j.reporter?.display_name??"",assignees:[],labels:[]}}}
3
- export{X as Hh};
2
+ import{Nh as V}from"./chunk-rad9rc2j.js";import{Sh as M}from"./chunk-kfn6xbc6.js";import{Vh as K,Yh as Q}from"./chunk-91gpxfta.js";class X{token;apiUrl;logger;slug;constructor(j,z,A,C,F){this.token=j;this.apiUrl=(C??"https://api.bitbucket.org/2.0").replace(/\/+$/,""),this.logger=F??Q(),this.slug=`${encodeURIComponent(z)}/${encodeURIComponent(A)}`}capabilities(){return{pinIssues:!1,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!1,nativeAutoMerge:!1,commentReactions:!1,ciLogs:!1,ciRuns:!1,reviewThreads:!1,teamReviewers:!1,draftPullRequests:!1,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!1,labels:!1}}async request(j,z,A,C={}){let F={Authorization:`Bearer ${this.token}`,Accept:C.raw?"text/plain":"application/json","User-Agent":"buddy"},H;if(C.form)F["Content-Type"]="application/x-www-form-urlencoded",H=new URLSearchParams(C.form).toString();else if(A)F["Content-Type"]="application/json",H=JSON.stringify(A);let G=await M(`${this.apiUrl}${z}`,{method:j,headers:F,...H?{body:H}:{}});if(!G.ok){let J=await G.text().catch(()=>"");throw Error(`Bitbucket ${j} ${z} failed: ${G.status} ${J.slice(0,200)}`)}let I=await G.text();if(C.raw)return I;return I.trim()?JSON.parse(I):void 0}async optional(j,z){try{return await this.request(j,z)}catch(A){if(String(A).includes("404"))return null;throw A}}async collect(j,z=10){let A=[],C=`${this.apiUrl}${j}`;for(let F=0;F<z&&C;F++){let H=C,G=await this.optional("GET",H.startsWith(this.apiUrl)?H.slice(this.apiUrl.length):H);if(!G)break;A.push(...G.values??[]),C=G.next}return A}async branchExists(j){return await this.optional("GET",`/repositories/${this.slug}/refs/branches/${encodeURIComponent(j)}`)!==null}async createBranch(j,z){await this.request("POST",`/repositories/${this.slug}/refs/branches`,{name:j,target:{hash:z}})}async deleteBranch(j){await this.request("DELETE",`/repositories/${this.slug}/refs/branches/${encodeURIComponent(j)}`)}async commitChanges(j,z,A,C="main"){if(A.length===0)return;let F={message:z,branch:j};for(let I of A)if(I.type==="delete")F.files=F.files?`${F.files},${I.path}`:I.path;else F[I.path]=I.content;let H=new URLSearchParams;for(let[I,J]of Object.entries(F)){if(I==="files")continue;H.append(I,J)}for(let I of A)if(I.type==="delete")H.append("files",I.path);let G=await this.headOf(C);if(G)H.append("parents",G);await this.request("POST",`/repositories/${this.slug}/src`,void 0,{form:Object.fromEntries(H.entries())})}async headOf(j){return(await this.optional("GET",`/repositories/${this.slug}/refs/branches/${encodeURIComponent(j)}`))?.target?.hash??null}async getFileContent(j,z){try{return await this.request("GET",`/repositories/${this.slug}/src/${encodeURIComponent(z)}/${j}`,void 0,{raw:!0})}catch(A){if(String(A).includes("404"))return null;throw A}}async createPullRequest(j){if(j.draft)this.logger.debug("Bitbucket has no draft pull requests; opening as ready");let z=await this.request("POST",`/repositories/${this.slug}/pullrequests`,{title:j.title,description:j.body,source:{branch:{name:j.head}},destination:{branch:{name:j.base}},close_source_branch:!0,...j.reviewers?.length?{reviewers:j.reviewers.map((A)=>({nickname:A}))}:{}});return this.toPullRequest(z)}async getPullRequests(j="open"){let A=(j==="open"?["OPEN"]:j==="closed"?["MERGED","DECLINED","SUPERSEDED"]:["OPEN","MERGED","DECLINED","SUPERSEDED"]).map((F)=>`state=${F}`).join("&");return(await this.collect(`/repositories/${this.slug}/pullrequests?${A}&pagelen=50`)).map((F)=>this.toPullRequest(F))}async updatePullRequest(j,z){let A=await this.request("PUT",`/repositories/${this.slug}/pullrequests/${j}`,{...z.title!==void 0?{title:z.title}:{},...z.body!==void 0?{description:z.body}:{},...z.base!==void 0?{destination:{branch:{name:z.base}}}:{}});return this.toPullRequest(A)}async closePullRequest(j){await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/decline`)}async reopenPullRequest(j){throw Error(`Bitbucket cannot reopen declined pull request #${j}; open a new one from the same branch.`)}async mergePullRequest(j,z="squash"){let A={merge:"merge_commit",squash:"squash",rebase:"fast_forward"};await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/merge`,{merge_strategy:A[z]??"squash",close_source_branch:!0})}async getPullRequestDiff(j){return await this.request("GET",`/repositories/${this.slug}/pullrequests/${j}/diff`,void 0,{raw:!0})}async getPullRequestHeadSha(j){return(await this.request("GET",`/repositories/${this.slug}/pullrequests/${j}`)).source?.commit?.hash??""}async createComment(j,z){await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/comments`,{content:{raw:z}})}async createIssue(j){let z=await this.request("POST",`/repositories/${this.slug}/issues`,{title:j.title,content:{raw:j.body},kind:"task"});return this.toIssue(z)}async getIssues(j="open"){let A=(await this.collect(`/repositories/${this.slug}/issues?pagelen=50`)).map((C)=>this.toIssue(C));return j==="all"?A:A.filter((C)=>C.state===j)}async updateIssue(j,z){let A=await this.request("PUT",`/repositories/${this.slug}/issues/${j}`,{...z.title!==void 0?{title:z.title}:{},...z.body!==void 0?{content:{raw:z.body}}:{}});return this.toIssue(A)}async closeIssue(j){await this.request("PUT",`/repositories/${this.slug}/issues/${j}`,{state:"closed"})}async unpinIssue(j){return!1}async getPullRequestChecksState(j){let z=await this.getPullRequestHeadSha(j);if(!z)return"none";let A=await this.collect(`/repositories/${this.slug}/commit/${z}/statuses?pagelen=50`);if(A.length===0)return"none";if(A.some((C)=>C.state==="FAILED"||C.state==="STOPPED"))return"failure";if(A.some((C)=>C.state==="INPROGRESS"))return"pending";if(A.every((C)=>C.state==="SUCCESSFUL"))return"success";return"pending"}async createReview(j,z){if(await this.createComment(j,z.body),!z.comments?.length)return{posted:!0,inlineComments:0};let A=0;for(let C of z.comments)try{await this.request("POST",`/repositories/${this.slug}/pullrequests/${j}/comments`,{content:{raw:C.body},inline:{path:C.path,...C.side==="RIGHT"?{to:C.line}:{from:C.line}}}),A++}catch(F){this.logger.debug(`Could not place a comment on ${C.path}:${C.line}: ${K(F)}`)}return{posted:!0,inlineComments:A}}async createCheckRun(j,z,A){try{await this.request("POST",`/repositories/${this.slug}/commit/${z}/statuses/build`,{key:j.replace(/[^\w-]/g,"-").slice(0,40),state:A.conclusion==="failure"?"FAILED":"SUCCESSFUL",name:A.title.slice(0,100),description:A.summary.slice(0,300),url:"https://buddy.sh"})}catch(C){this.logger.warn(`\u26A0\uFE0F Could not report build status ${j}: ${K(C)}`)}}async hasWriteAccess(j){let A=(await this.optional("GET",`/repositories/${this.slug}/permissions-config/users`))?.values?.find((C)=>C.user?.nickname===j);return A?.permission==="write"||A?.permission==="admin"}async getBuddyBranches(){return(await this.collect(`/repositories/${this.slug}/refs/branches?q=${encodeURIComponent('name ~ "buddy/"')}&pagelen=50`)).filter((z)=>V(z.name)).map((z)=>({name:z.name,sha:z.target?.hash??"",lastCommitDate:z.target?.date?new Date(z.target.date):new Date(0)}))}async getOrphanedBuddyBranches(){let[j,z]=await Promise.all([this.getBuddyBranches(),this.getPullRequests("open")]),A=new Set(z.map((C)=>C.head));return j.filter((C)=>!A.has(C.name))}async cleanupStaleBranches(j=7,z=!1){let A=new Date(Date.now()-j*24*60*60*1000),C=(await this.getOrphanedBuddyBranches()).filter((G)=>G.lastCommitDate<A);if(z)return{deleted:C.map((G)=>G.name),failed:[]};let F=[],H=[];for(let G of C)try{await this.deleteBranch(G.name),F.push(G.name)}catch{H.push(G.name)}return{deleted:F,failed:H}}toPullRequest(j){let z=j.state==="MERGED"?"merged":j.state==="OPEN"?"open":"closed";return{number:j.id,title:j.title,body:j.description??"",head:j.source?.branch?.name??"",base:j.destination?.branch?.name??"",state:z,url:j.links?.html?.href??"",createdAt:new Date(j.created_on),updatedAt:new Date(j.updated_on),...z==="merged"?{mergedAt:new Date(j.updated_on)}:{},author:j.author?.nickname??j.author?.display_name??"",reviewers:(j.reviewers??[]).map((A)=>A.nickname??A.display_name??"").filter(Boolean),assignees:[],labels:[],draft:!1}}toIssue(j){let z=["new","open","on hold"].includes(j.state);return{number:j.id,title:j.title,body:j.content?.raw??"",state:z?"open":"closed",url:j.links?.html?.href??"",createdAt:new Date(j.created_on),updatedAt:new Date(j.updated_on),...z?{}:{closedAt:new Date(j.updated_on)},author:j.reporter?.nickname??j.reporter?.display_name??"",assignees:[],labels:[]}}}
3
+ export{X as Mh};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{execSync as h}from"child_process";import{existsSync as P,mkdirSync as F,mkdtempSync as L,rmSync as V,writeFileSync as U}from"fs";import{tmpdir as G}from"os";import{join as w}from"path";var i=new Set,A=!1;function q(){if(A)return;A=!0;let a=()=>{for(let e of i)try{h(`pantry stop ${e}`,{stdio:"ignore",timeout:1e4})}catch{}i.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function o(a,e=!1){let s={encoding:"utf-8",timeout:30000,stdio:e?"pipe":["pipe","pipe","pipe"]};return h(`pantry ${a}`,s)}function O(a){let e=a.match(/Name:\s+(\S+)/)?.[1]??"",s=/Status:\s+running/i.test(a),t=a.match(/Port:\s+(\d+)/),r=a.match(/PID:\s+(\d+)/),S=a.match(/Data Dir:\s+(.+)/);return{name:e,running:s,port:t?Number.parseInt(t[1],10):null,pid:r?Number.parseInt(r[1],10):null,dataDir:S?S[1].trim():null}}class n{config;_startedByUs=!1;constructor(a){this.config={name:a.name,port:a.port??0,readyTimeoutMs:a.readyTimeoutMs??15000,pollIntervalMs:a.pollIntervalMs??200,quiet:a.quiet??!0}}static isAvailable(){try{return h("pantry --version",{stdio:"ignore",timeout:5000}),!0}catch{return!1}}status(){try{let a=o(`inspect ${this.config.name}`,!0);return O(a)}catch{return{name:this.config.name,running:!1,port:null,pid:null,dataDir:null}}}isRunning(){return this.status().running}getPort(){return this.status().port}async start(){if(q(),this.isRunning())return this.status();return o(`start ${this.config.name}`,this.config.quiet),this._startedByUs=!0,i.add(this.config.name),await this.waitReady(),this.status()}async stop(){if(!this._startedByUs)return;try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async forceStop(){try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async ensureRunning(){if(this.isRunning())return this.status();return this.start()}async waitReady(){let a=Date.now()+this.config.readyTimeoutMs;while(Date.now()<a){if(this.isRunning())return;await new Promise((e)=>setTimeout(e,this.config.pollIntervalMs))}throw Error(`Service '${this.config.name}' did not become ready within ${this.config.readyTimeoutMs}ms`)}}var v=new n({name:"mysql"});async function c(a){let e=await v.ensureRunning();return{port:a?.port??e.port??3306,host:a?.host??"localhost",database:a?.database??"test",username:a?.username??"root"}}async function u(){await v.stop()}function I(a){let e=null;return{get connection(){if(!e)throw Error("MySQL not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await c(a)},afterAll:async()=>{await u(),e=null}}}async function D(a,e){let s=await c(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await u()}}var R=new n({name:"postgres"});async function p(a){let e=await R.ensureRunning();return{port:a?.port??e.port??5432,host:a?.host??"localhost",database:a?.database??"postgres",username:a?.username??process.env.USER??"postgres"}}async function g(){await R.stop()}function T(a){let e=null;return{get connection(){if(!e)throw Error("Postgres not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await p(a)},afterAll:async()=>{await g(),e=null}}}async function C(a,e){let s=await p(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await g()}}var M=new n({name:"redis"});async function f(a){let e=await M.ensureRunning(),s=a?.port??e.port??6379,t=a?.host??"localhost";return{port:s,host:t,url:`redis://${t}:${s}`}}async function d(){await M.stop()}function E(a){let e=null;return{get connection(){if(!e)throw Error("Redis not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await f(a)},afterAll:async()=>{await d(),e=null}}}async function b(a,e){let s=await f(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await d()}}var l=new Set,k=!1;function H(){if(k)return;k=!0;let a=()=>{for(let e of l)try{if(P(e))V(e,{recursive:!0,force:!0})}catch{}l.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function m(a="pantry-test-"){H();let e=L(w(G(),a));return l.add(e),e}function y(a){l.delete(a);try{if(P(a))V(a,{recursive:!0,force:!0})}catch{}}async function N(a,e){let s=m(a);try{return await e(s)}finally{y(s)}}function x(a,e){let s=m(a);try{return e(s)}finally{y(s)}}function _(a,e,s){let t=w(a,e),r=t.substring(0,t.lastIndexOf("/"));if(r&&!P(r))F(r,{recursive:!0});return U(t,s),t}function B(a,e){let s=w(a,e);return F(s,{recursive:!0}),s}var $={createTempDir:m,createTestDir:B,createTestFile:_,PantryService:n,removeTempDir:y,startMysql:c,startPostgres:p,startRedis:f,stopMysql:u,stopPostgres:g,stopRedis:d,useMysql:I,usePostgres:T,useRedis:E,withMysql:D,withPostgres:C,withRedis:b,withTempDir:N,withTempDirSync:x};export{n as Fg,c as Gg,u as Hg,I as Ig,D as Jg,p as Kg,g as Lg,T as Mg,C as Ng,f as Og,d as Pg,E as Qg,b as Rg,m as Sg,y as Tg,N as Ug,x as Vg,_ as Wg,B as Xg,$ as Yg};
2
+ import{execSync as h}from"child_process";import{existsSync as P,mkdirSync as F,mkdtempSync as L,rmSync as V,writeFileSync as U}from"fs";import{tmpdir as G}from"os";import{join as w}from"path";var i=new Set,A=!1;function q(){if(A)return;A=!0;let a=()=>{for(let e of i)try{h(`pantry stop ${e}`,{stdio:"ignore",timeout:1e4})}catch{}i.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function o(a,e=!1){let s={encoding:"utf-8",timeout:30000,stdio:e?"pipe":["pipe","pipe","pipe"]};return h(`pantry ${a}`,s)}function O(a){let e=a.match(/Name:\s+(\S+)/)?.[1]??"",s=/Status:\s+running/i.test(a),t=a.match(/Port:\s+(\d+)/),r=a.match(/PID:\s+(\d+)/),S=a.match(/Data Dir:\s+(.+)/);return{name:e,running:s,port:t?Number.parseInt(t[1],10):null,pid:r?Number.parseInt(r[1],10):null,dataDir:S?S[1].trim():null}}class n{config;_startedByUs=!1;constructor(a){this.config={name:a.name,port:a.port??0,readyTimeoutMs:a.readyTimeoutMs??15000,pollIntervalMs:a.pollIntervalMs??200,quiet:a.quiet??!0}}static isAvailable(){try{return h("pantry --version",{stdio:"ignore",timeout:5000}),!0}catch{return!1}}status(){try{let a=o(`inspect ${this.config.name}`,!0);return O(a)}catch{return{name:this.config.name,running:!1,port:null,pid:null,dataDir:null}}}isRunning(){return this.status().running}getPort(){return this.status().port}async start(){if(q(),this.isRunning())return this.status();return o(`start ${this.config.name}`,this.config.quiet),this._startedByUs=!0,i.add(this.config.name),await this.waitReady(),this.status()}async stop(){if(!this._startedByUs)return;try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async forceStop(){try{o(`stop ${this.config.name}`,this.config.quiet)}catch{}i.delete(this.config.name),this._startedByUs=!1}async ensureRunning(){if(this.isRunning())return this.status();return this.start()}async waitReady(){let a=Date.now()+this.config.readyTimeoutMs;while(Date.now()<a){if(this.isRunning())return;await new Promise((e)=>setTimeout(e,this.config.pollIntervalMs))}throw Error(`Service '${this.config.name}' did not become ready within ${this.config.readyTimeoutMs}ms`)}}var v=new n({name:"mysql"});async function c(a){let e=await v.ensureRunning();return{port:a?.port??e.port??3306,host:a?.host??"localhost",database:a?.database??"test",username:a?.username??"root"}}async function u(){await v.stop()}function I(a){let e=null;return{get connection(){if(!e)throw Error("MySQL not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await c(a)},afterAll:async()=>{await u(),e=null}}}async function D(a,e){let s=await c(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await u()}}var R=new n({name:"postgres"});async function p(a){let e=await R.ensureRunning();return{port:a?.port??e.port??5432,host:a?.host??"localhost",database:a?.database??"postgres",username:a?.username??process.env.USER??"postgres"}}async function g(){await R.stop()}function T(a){let e=null;return{get connection(){if(!e)throw Error("Postgres not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await p(a)},afterAll:async()=>{await g(),e=null}}}async function C(a,e){let s=await p(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await g()}}var M=new n({name:"redis"});async function f(a){let e=await M.ensureRunning(),s=a?.port??e.port??6379,t=a?.host??"localhost";return{port:s,host:t,url:`redis://${t}:${s}`}}async function d(){await M.stop()}function E(a){let e=null;return{get connection(){if(!e)throw Error("Redis not started. Ensure beforeAll has run.");return e},beforeAll:async()=>{e=await f(a)},afterAll:async()=>{await d(),e=null}}}async function b(a,e){let s=await f(e);try{return await a(s)}finally{if(e?.stopAfter!==!1)await d()}}var l=new Set,k=!1;function H(){if(k)return;k=!0;let a=()=>{for(let e of l)try{if(P(e))V(e,{recursive:!0,force:!0})}catch{}l.clear()};process.on("exit",a),process.on("SIGINT",()=>{a(),process.exit(130)}),process.on("SIGTERM",()=>{a(),process.exit(143)})}function m(a="pantry-test-"){H();let e=L(w(G(),a));return l.add(e),e}function y(a){l.delete(a);try{if(P(a))V(a,{recursive:!0,force:!0})}catch{}}async function N(a,e){let s=m(a);try{return await e(s)}finally{y(s)}}function x(a,e){let s=m(a);try{return e(s)}finally{y(s)}}function _(a,e,s){let t=w(a,e),r=t.substring(0,t.lastIndexOf("/"));if(r&&!P(r))F(r,{recursive:!0});return U(t,s),t}function B(a,e){let s=w(a,e);return F(s,{recursive:!0}),s}var $={createTempDir:m,createTestDir:B,createTestFile:_,PantryService:n,removeTempDir:y,startMysql:c,startPostgres:p,startRedis:f,stopMysql:u,stopPostgres:g,stopRedis:d,useMysql:I,usePostgres:T,useRedis:E,withMysql:D,withPostgres:C,withRedis:b,withTempDir:N,withTempDirSync:x};export{n as Ig,c as Jg,u as Kg,I as Lg,D as Mg,p as Ng,g as Og,T as Pg,C as Qg,f as Rg,d as Sg,E as Tg,b as Ug,m as Vg,y as Wg,N as Xg,x as Yg,_ as Zg,B as _g,$ as $g};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{re as p}from"./chunk-p09rsh3z.js";import{Th as E}from"./chunk-56t2za4k.js";var x=["github-actions[bot]","buddy","buddy[bot]"];function w(f,r){let e=f.authorLogins[0];if(!e)return!1;return r?e===r:x.includes(e)}async function F(f){let r=f.logger??E(),{provider:e,prNumber:t}=f;if(!p(e,"reviewThreads","listReviewThreads"))return"This provider cannot resolve review threads.";let n=await e.listReviewThreads(t),i=n.filter((R)=>!R.isResolved&&w(R,f.author));if(i.length===0)return n.length===0?"There are no review threads on this pull request.":"None of the open threads here are mine to close.";if(!p(e,"reviewThreads","resolveReviewThread"))return"This provider cannot resolve review threads.";let o=0;for(let R of i)if(await e.resolveReviewThread(t,R.id))o++;else r.warn(`Could not resolve thread ${R.id} on #${t}`);if(o===0)return`I could not close any of the ${i.length} thread(s) I opened.`;let m=o<i.length?` (${i.length-o} refused)`:"";return`Closed ${o} thread(s) I opened${m}.`}export{F as Wa};
2
+ import{ue as p}from"./chunk-9rvapdmv.js";import{Yh as E}from"./chunk-91gpxfta.js";var x=["github-actions[bot]","buddy","buddy[bot]"];function w(f,r){let e=f.authorLogins[0];if(!e)return!1;return r?e===r:x.includes(e)}async function F(f){let r=f.logger??E(),{provider:e,prNumber:t}=f;if(!p(e,"reviewThreads","listReviewThreads"))return"This provider cannot resolve review threads.";let n=await e.listReviewThreads(t),i=n.filter((R)=>!R.isResolved&&w(R,f.author));if(i.length===0)return n.length===0?"There are no review threads on this pull request.":"None of the open threads here are mine to close.";if(!p(e,"reviewThreads","resolveReviewThread"))return"This provider cannot resolve review threads.";let o=0;for(let R of i)if(await e.resolveReviewThread(t,R.id))o++;else r.warn(`Could not resolve thread ${R.id} on #${t}`);if(o===0)return`I could not close any of the ${i.length} thread(s) I opened.`;let m=o<i.length?` (${i.length-o} refused)`:"";return`Closed ${o} thread(s) I opened${m}.`}export{F as Ya};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Fa as a,Ga as b,Ha as c,Ia as d,Ja as e,Ka as f,La as g,Ma as h,Na as i,Oa as j,Pa as k,Qa as l}from"./chunk-zdh3gd22.js";import"./chunk-1pecmenc.js";import"./chunk-eaz23nsf.js";export{k as withTouchOffer,b as unitTestsTouch,d as simplifyTouch,i as renderTouchOffer,e as planTouch,l as parseTouchSelections,j as hasTouchOffer,g as getFinishingTouch,a as docstringsTouch,c as autofixTouch,h as TOUCH_OFFER_MARKER,f as FINISHING_TOUCHES};
2
+ import{Ha as a,Ia as b,Ja as c,Ka as d,La as e,Ma as f,Na as g,Oa as h,Pa as i,Qa as j,Ra as k,Sa as l}from"./chunk-cqh3eadc.js";import"./chunk-016ce171.js";import"./chunk-xmqv24zr.js";export{k as withTouchOffer,b as unitTestsTouch,d as simplifyTouch,i as renderTouchOffer,e as planTouch,l as parseTouchSelections,j as hasTouchOffer,g as getFinishingTouch,a as docstringsTouch,c as autofixTouch,h as TOUCH_OFFER_MARKER,f as FINISHING_TOUCHES};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ei as a,Fi as e,Gi as s,Hi as t,Ii as c,Ji as r,Ki as P,Li as n,Mi as o,Ni as g,Oi as l,Pi as p,Qi as d,Ri as k}from"./chunk-drn3hq53.js";import"./chunk-eaz23nsf.js";export{o as startPeriodicCleanup,n as setupCleanupHandlers,p as scanPantryPackages,t as saveToCacheAndOutput,a as savePackageAsTypeScript,d as readPantryPackageInfo,s as getValidCachedPackage,r as fetchPkgxProjects,k as fetchPantryPackageWithMetadata,P as fetchPantryPackage,l as fetchAndSavePackage,g as fetchAndSaveAllPackages,c as cleanupBrowserResources,e as cleanStaleOutputFiles};
2
+ import{Ji as a,Ki as e,Li as s,Mi as t,Ni as c,Oi as r,Pi as P,Qi as n,Ri as o,Si as g,Ti as l,Ui as p,Vi as d,Wi as k}from"./chunk-nqgn0drz.js";import"./chunk-xmqv24zr.js";export{o as startPeriodicCleanup,n as setupCleanupHandlers,p as scanPantryPackages,t as saveToCacheAndOutput,a as savePackageAsTypeScript,d as readPantryPackageInfo,s as getValidCachedPackage,r as fetchPkgxProjects,k as fetchPantryPackageWithMetadata,P as fetchPantryPackage,l as fetchAndSavePackage,g as fetchAndSaveAllPackages,c as cleanupBrowserResources,e as cleanStaleOutputFiles};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Fg as mc,Gg as nc,Hg as oc,Ig as pc,Jg as qc,Kg as rc,Lg as sc,Mg as tc,Ng as uc,Og as vc,Pg as wc,Qg as xc,Rg as yc,Sg as zc,Tg as Ac,Ug as Bc,Vg as Cc,Wg as Dc,Xg as Ec,Yg as Fc}from"./chunk-2z9mh5y4.js";import{$h as g,$i as fa,$j as fb,$k as fc,Ai as G,Aj as Ga,Ak as Gb,Bi as H,Bj as Ha,Bk as Hb,Ci as I,Cj as Ia,Ck as Ib,Di as J,Dj as Ja,Dk as Jb,Ei as K,Ej as Ka,Ek as Kb,Fi as L,Fj as La,Fk as Lb,Gi as M,Gj as Ma,Gk as Mb,Hi as N,Hj as Na,Hk as Nb,Ii as O,Ij as Oa,Ik as Ob,Ji as P,Jj as Pa,Jk as Pb,Ki as Q,Kj as Qa,Kk as Qb,Li as R,Lj as Ra,Lk as Rb,Mi as S,Mj as Sa,Mk as Sb,Ni as T,Nj as Ta,Nk as Tb,Oi as U,Oj as Ua,Ok as Ub,Pi as V,Pj as Va,Pk as Vb,Qi as W,Qj as Wa,Qk as Wb,Ri as X,Rj as Xa,Rk as Xb,Si as Y,Sj as Ya,Sk as Yb,Ti as Z,Tj as Za,Tk as Zb,Uh as a,Ui as _,Uj as _a,Uk as _b,Vh as b,Vi as $,Vj as $a,Vk as $b,Wh as c,Wi as aa,Wj as ab,Wk as ac,Xi as ba,Xj as bb,Xk as bc,Yh as d,Yi as ca,Yj as cb,Yk as cc,Zh as e,Zi as da,Zj as db,Zk as dc,_h as f,_i as ea,_j as eb,_k as ec,ai as h,aj as ga,ak as gb,al as gc,bi as i,bj as ha,bk as hb,bl as hc,ci as j,cj as ia,ck as ib,cl as ic,di as k,dj as ja,dk as jb,dl as jc,ei as l,ej as ka,ek as kb,el as kc,fi as m,fj as la,fk as lb,fl as lc,gi as n,gj as ma,gk as mb,hi as o,hj as na,hk as nb,ii as p,ij as oa,ik as ob,ji as q,jj as pa,jk as pb,ki as r,kj as qa,kk as qb,li as s,lj as ra,lk as rb,mi as t,mj as sa,mk as sb,ni as u,nj as ta,nk as tb,oi as v,oj as ua,ok as ub,pi as w,pj as va,pk as vb,qi as x,qj as wa,qk as wb,ri as y,rj as xa,rk as xb,si as z,sj as ya,sk as yb,ti as A,tj as za,tk as zb,ui as B,uj as Aa,uk as Ab,vi as C,vj as Ba,vk as Bb,wi as D,wj as Ca,wk as Cb,xj as Da,xk as Db,yi as E,yj as Ea,yk as Eb,zi as F,zj as Fa,zk as Fb}from"./chunk-drn3hq53.js";import"./chunk-eaz23nsf.js";export{Ta as ziglangOfficialDownload,ab as zigRegistryMirror,bb as zigPurgedDevBuildHint,eb as zigOriginVersions,Wb as writeOciLayout,Xb as writeDockerArchive,Cc as withTempDirSync,Bc as withTempDir,yc as withRedis,uc as withPostgres,qc as withMysql,ic as waitForAppStoreBuilds,ac as verifyBlob,n as validatePackageSpec,Aa as validatePackage,sa as v,xc as useRedis,tc as usePostgres,pc as useMysql,zb as updatePackageVersionMap,ca as updateApp,sb as uninstallShellInit,ub as toTypeName,tb as toSafeVarName,vb as toPackageVarName,Fc as testingRuntime,mb as supportedPackages,wc as stopRedis,sc as stopPostgres,oc as stopMysql,vc as startRedis,rc as startPostgres,S as startPeriodicCleanup,nc as startMysql,Ua as sqliteOfficialDownloadUrl,va as showPackageInfo,x as shouldProceedWithGitHubRequest,R as setupCleanupHandlers,Ub as serializeConfig,wa as searchPackagesCommand,j as searchPackages,V as scanPantryPackages,$ as scanInstalledApps,N as saveToCacheAndOutput,w as saveRateLimitInfo,K as savePackageAsTypeScript,z as saveGitHubPackageCache,db as satisfiesInstallerConstraint,ib as retryNetworkOperation,q as resolveVersionFromMetadata,Ka as resolveVersionConstraint,h as resolveVersion,Ma as resolveTransitiveDependencies,ka as resolvePackageName,G as resolvePackageDomain,Cb as resolvePackageDependencies,Xa as resolveLatestVersion,gb as resolveInstallerConstraintFromCandidates,Oa as resolveDependencyFile,Bb as resolveDependenciesFromYaml,Ab as resolveDependencies,Mb as resolveBuildStages,qb as renderShellSnippet,dc as renderDockerfile,Ac as removeTempDir,Za as registryVersionsForPlatform,Ya as registryPlatformKey,_a as registryDownloadSource,Eb as readProjectDependencies,W as readPantryPackageInfo,pb as rcFileFor,$b as pushImage,_b as pullImage,jc as provisionMacApp,ta as pkg,o as parseVersion,la as parsePackageSpec,cb as parseInstallerConstraint,Zb as parseImageRef,Nb as parseFreezer,Lb as parseExecForm,Kb as parseDockerfile,Ia as parseDepsYamlConfig,Ha as parseDependencyFile,b as pantry,c as packages,Qa as normalizeInstallerVersion,B as logPkgxProjects,Pb as loadFreezer,xa as listPopularPackages,za as listAliases,ya as listActivePackages,g as isVersionAvailable,fa as isValidPackageName,ga as isSupportedPlatform,ha as isSupportedArchitecture,kb as isSupported,hb as isRetryableNetworkError,ra as isPackageInCategory,ea as isPackageDomain,da as isPackageAlias,_ as isNewerVersion,I as isKnownAlias,lb as isInstallable,$a as installedRegistryBinaries,rb as installShellInit,Wa as installPackages,Va as installPackage,F as guessOriginalDomain,Ra as globalBinDir,Ca as getVersionInfo,M as getValidCachedPackage,Ga as getSystemInfo,nb as getPrimaryBinary,l as getPopularPackages,f as getPhpVersionsForWorkflow,k as getPackagesByPattern,qa as getPackagesByCategory,i as getPackageInfo,H as getPackageAliases,d as getLatestVersion,Db as getInstallCommand,y as getGitHubPackageCache,J as getCanonicalDomain,Ja as getAvailableVersionsForPackage,e as getAvailableVersions,ja as getAllPackageDomains,ia as getAllPackageAliases,m as getActivePackages,kc as generateMacCertificateRequests,wb as generateIndex,yb as generateDocs,ec as generateContainerFiles,xb as generateAliases,Ea as formatSearchResults,ma as formatPackageSpec,Da as formatPackageInfo,C as formatObjectWithoutQuotedKeys,Fa as formatInstallPlan,Pa as findDependencyFiles,P as fetchPkgxProjects,X as fetchPantryPackageWithMetadata,Q as fetchPantryPackage,A as fetchPackageListFromGitHub,aa as fetchDesktopCatalogue,U as fetchAndSavePackage,T as fetchAndSaveAllPackages,bc as extractLayer,lc as exportAppleCertificateP12,hc as ensureAppStoreVersions,jb as downloadFileReliably,Sb as digestHex,Rb as digest,ob as detectShell,Sa as detectPlatform,ua as dependencies,Ib as definePantryConfig,Gb as definePackageList,Fb as defineDependencies,Na as deduplicateDependencies,Dc as createTestFile,Ec as createTestDir,zc as createTempDir,Ob as createMatcher,na as createInstallationContext,Ba as createInstallPlan,D as convertDomainToVarName,E as convertDomainToFileName,p as compareVersionsDesc,La as compareVersions,fb as compareInstallerVersionsDesc,Jb as collectBuildContext,O as cleanupBrowserResources,L as cleanStaleOutputFiles,ba as checkAppUpdates,Vb as buildManifest,Tb as buildLayerFromRootfs,cc as buildImage,fc as appStoreConnectToken,a as aliases,oa as VERSION_SPECS,Y as SYSTEM_APPS,mc as PantryService,Yb as PANTRY_REGISTRY,pa as PACKAGE_CATEGORIES,u as PACKAGE_ALIASES,Qb as MEDIA_TYPE,Z as MAS_APPS,Hb as DISTRIBUTION_CONFIG,t as DEFAULT_TIMEOUT_MS,s as DEFAULT_CACHE_EXPIRATION_MINUTES,r as DEFAULT_CACHE_DIR,gc as AppStoreConnectClient,v as ALL_KNOWN_PACKAGES};
2
+ import{$g as Fc,Ig as mc,Jg as nc,Kg as oc,Lg as pc,Mg as qc,Ng as rc,Og as sc,Pg as tc,Qg as uc,Rg as vc,Sg as wc,Tg as xc,Ug as yc,Vg as zc,Wg as Ac,Xg as Bc,Yg as Cc,Zg as Dc,_g as Ec}from"./chunk-0cqhy9qh.js";import{$h as c,$i as aa,$j as ab,$k as ac,Ai as C,Aj as Ba,Ak as Bb,Bi as D,Bj as Ca,Bk as Cb,Cj as Da,Ck as Db,Di as E,Dj as Ea,Dk as Eb,Ei as F,Ej as Fa,Ek as Fb,Fi as G,Fj as Ga,Fk as Gb,Gi as H,Gj as Ha,Gk as Hb,Hi as I,Hj as Ia,Hk as Ib,Ii as J,Ij as Ja,Ik as Jb,Ji as K,Jj as Ka,Jk as Kb,Ki as L,Kj as La,Kk as Lb,Li as M,Lj as Ma,Lk as Mb,Mi as N,Mj as Na,Mk as Nb,Ni as O,Nj as Oa,Nk as Ob,Oi as P,Oj as Pa,Ok as Pb,Pi as Q,Pj as Qa,Pk as Qb,Qi as R,Qj as Ra,Qk as Rb,Ri as S,Rj as Sa,Rk as Sb,Si as T,Sj as Ta,Sk as Tb,Ti as U,Tj as Ua,Tk as Ub,Ui as V,Uj as Va,Uk as Vb,Vi as W,Vj as Wa,Vk as Wb,Wi as X,Wj as Xa,Wk as Xb,Xi as Y,Xj as Ya,Xk as Yb,Yi as Z,Yj as Za,Yk as Zb,Zh as a,Zi as _,Zj as _a,Zk as _b,_h as b,_i as $,_j as $a,_k as $b,aj as ba,ak as bb,al as bc,bi as d,bj as ca,bk as cb,bl as cc,ci as e,cj as da,ck as db,cl as dc,di as f,dj as ea,dk as eb,dl as ec,ei as g,ej as fa,ek as fb,el as fc,fi as h,fj as ga,fk as gb,fl as gc,gi as i,gj as ha,gk as hb,gl as hc,hi as j,hj as ia,hk as ib,hl as ic,ii as k,ij as ja,ik as jb,il as jc,ji as l,jj as ka,jk as kb,jl as kc,ki as m,kj as la,kk as lb,kl as lc,li as n,lj as ma,lk as mb,mi as o,mj as na,mk as nb,ni as p,nj as oa,nk as ob,oi as q,oj as pa,ok as pb,pi as r,pj as qa,pk as qb,qi as s,qj as ra,qk as rb,ri as t,rj as sa,rk as sb,si as u,sj as ta,sk as tb,ti as v,tj as ua,tk as ub,ui as w,uj as va,uk as vb,vi as x,vj as wa,vk as wb,wi as y,wj as xa,wk as xb,xi as z,xj as ya,xk as yb,yi as A,yj as za,yk as zb,zi as B,zj as Aa,zk as Ab}from"./chunk-nqgn0drz.js";import"./chunk-xmqv24zr.js";export{Ta as ziglangOfficialDownload,ab as zigRegistryMirror,bb as zigPurgedDevBuildHint,eb as zigOriginVersions,Wb as writeOciLayout,Xb as writeDockerArchive,Cc as withTempDirSync,Bc as withTempDir,yc as withRedis,uc as withPostgres,qc as withMysql,ic as waitForAppStoreBuilds,ac as verifyBlob,n as validatePackageSpec,Aa as validatePackage,sa as v,xc as useRedis,tc as usePostgres,pc as useMysql,zb as updatePackageVersionMap,ca as updateApp,sb as uninstallShellInit,ub as toTypeName,tb as toSafeVarName,vb as toPackageVarName,Fc as testingRuntime,mb as supportedPackages,wc as stopRedis,sc as stopPostgres,oc as stopMysql,vc as startRedis,rc as startPostgres,S as startPeriodicCleanup,nc as startMysql,Ua as sqliteOfficialDownloadUrl,va as showPackageInfo,x as shouldProceedWithGitHubRequest,R as setupCleanupHandlers,Ub as serializeConfig,wa as searchPackagesCommand,j as searchPackages,V as scanPantryPackages,$ as scanInstalledApps,N as saveToCacheAndOutput,w as saveRateLimitInfo,K as savePackageAsTypeScript,z as saveGitHubPackageCache,db as satisfiesInstallerConstraint,ib as retryNetworkOperation,q as resolveVersionFromMetadata,Ka as resolveVersionConstraint,h as resolveVersion,Ma as resolveTransitiveDependencies,ka as resolvePackageName,G as resolvePackageDomain,Cb as resolvePackageDependencies,Xa as resolveLatestVersion,gb as resolveInstallerConstraintFromCandidates,Oa as resolveDependencyFile,Bb as resolveDependenciesFromYaml,Ab as resolveDependencies,Mb as resolveBuildStages,qb as renderShellSnippet,dc as renderDockerfile,Ac as removeTempDir,Za as registryVersionsForPlatform,Ya as registryPlatformKey,_a as registryDownloadSource,Eb as readProjectDependencies,W as readPantryPackageInfo,pb as rcFileFor,$b as pushImage,_b as pullImage,jc as provisionMacApp,ta as pkg,o as parseVersion,la as parsePackageSpec,cb as parseInstallerConstraint,Zb as parseImageRef,Nb as parseFreezer,Lb as parseExecForm,Kb as parseDockerfile,Ia as parseDepsYamlConfig,Ha as parseDependencyFile,b as pantry,c as packages,Qa as normalizeInstallerVersion,B as logPkgxProjects,Pb as loadFreezer,xa as listPopularPackages,za as listAliases,ya as listActivePackages,g as isVersionAvailable,fa as isValidPackageName,ga as isSupportedPlatform,ha as isSupportedArchitecture,kb as isSupported,hb as isRetryableNetworkError,ra as isPackageInCategory,ea as isPackageDomain,da as isPackageAlias,_ as isNewerVersion,I as isKnownAlias,lb as isInstallable,$a as installedRegistryBinaries,rb as installShellInit,Wa as installPackages,Va as installPackage,F as guessOriginalDomain,Ra as globalBinDir,Ca as getVersionInfo,M as getValidCachedPackage,Ga as getSystemInfo,nb as getPrimaryBinary,l as getPopularPackages,f as getPhpVersionsForWorkflow,k as getPackagesByPattern,qa as getPackagesByCategory,i as getPackageInfo,H as getPackageAliases,d as getLatestVersion,Db as getInstallCommand,y as getGitHubPackageCache,J as getCanonicalDomain,Ja as getAvailableVersionsForPackage,e as getAvailableVersions,ja as getAllPackageDomains,ia as getAllPackageAliases,m as getActivePackages,kc as generateMacCertificateRequests,wb as generateIndex,yb as generateDocs,ec as generateContainerFiles,xb as generateAliases,Ea as formatSearchResults,ma as formatPackageSpec,Da as formatPackageInfo,C as formatObjectWithoutQuotedKeys,Fa as formatInstallPlan,Pa as findDependencyFiles,P as fetchPkgxProjects,X as fetchPantryPackageWithMetadata,Q as fetchPantryPackage,A as fetchPackageListFromGitHub,aa as fetchDesktopCatalogue,U as fetchAndSavePackage,T as fetchAndSaveAllPackages,bc as extractLayer,lc as exportAppleCertificateP12,hc as ensureAppStoreVersions,jb as downloadFileReliably,Sb as digestHex,Rb as digest,ob as detectShell,Sa as detectPlatform,ua as dependencies,Ib as definePantryConfig,Gb as definePackageList,Fb as defineDependencies,Na as deduplicateDependencies,Dc as createTestFile,Ec as createTestDir,zc as createTempDir,Ob as createMatcher,na as createInstallationContext,Ba as createInstallPlan,D as convertDomainToVarName,E as convertDomainToFileName,p as compareVersionsDesc,La as compareVersions,fb as compareInstallerVersionsDesc,Jb as collectBuildContext,O as cleanupBrowserResources,L as cleanStaleOutputFiles,ba as checkAppUpdates,Vb as buildManifest,Tb as buildLayerFromRootfs,cc as buildImage,fc as appStoreConnectToken,a as aliases,oa as VERSION_SPECS,Y as SYSTEM_APPS,mc as PantryService,Yb as PANTRY_REGISTRY,pa as PACKAGE_CATEGORIES,u as PACKAGE_ALIASES,Qb as MEDIA_TYPE,Z as MAS_APPS,Hb as DISTRIBUTION_CONFIG,t as DEFAULT_TIMEOUT_MS,s as DEFAULT_CACHE_EXPIRATION_MINUTES,r as DEFAULT_CACHE_DIR,gc as AppStoreConnectClient,v as ALL_KNOWN_PACKAGES};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Nh as U}from"./chunk-kqwdg3nw.js";import{Th as f}from"./chunk-56t2za4k.js";var{Glob:u}=globalThis.Bun;import{readdir as m}from"fs/promises";import{join as P,relative as l}from"path";import O from"process";var c=new Set(["node_modules","vendor","target",".git",".venv","venv","dist","build","__pycache__",".next",".cache"]);function W(z){return z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function L(z,H,$=4){let X=H.map((K)=>new u(K)),Z=[];async function J(K,G){if(G>$)return;let V=await m(K,{withFileTypes:!0}).catch(()=>[]);for(let Q of V){let j=P(K,Q.name);if(Q.isDirectory()){if(!c.has(Q.name)&&!Q.name.startsWith("."))await J(j,G+1);continue}if(!Q.isFile())continue;let q=l(z,j);if(X.some((Y)=>Y.match(Q.name)||Y.match(q)))Z.push(q)}}return await J(z,0),Z.sort()}async function M(z,H){let $=[],X=[];for(let Z of H){if(!await Bun.file(P(z,Z.lockfile)).exists())continue;let[J]=Z.command;if(!await E(J)){X.push(`${Z.lockfile} (needs \`${Z.command.join(" ")}\`)`);continue}if(await Bun.spawn(Z.command,{cwd:z,stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??"",HOME:O.env.HOME??""}}).exited===0)$.push(Z.lockfile);else X.push(`${Z.lockfile} (\`${Z.command.join(" ")}\` failed)`)}return{regenerated:$,...X.length>0?{note:`These lockfiles were not regenerated and need updating locally: ${X.join(", ")}.`}:{}}}async function E(z){try{return await Bun.spawn(["which",z],{stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??""}}).exited===0}catch{return!1}}function B(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);for(let J=0;J<Math.max(X.length,Z.length);J++){let K=(X[J]??0)-(Z[J]??0);if(K!==0)return K}return 0}function C(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);if((X[0]??0)!==(Z[0]??0))return"major";if((X[1]??0)!==(Z[1]??0))return"minor";return"patch"}var p=/^\s*(?:require\s+)?([\w.~-]+(?:\.[\w.~-]+)*\/[^\s]+)\s+(v[\w.+-]+)\s*(\/\/.*)?$/,R=/^v\d+\.\d+\.\d+-\d{14}-[a-f0-9]{12}$/,I={name:"go",manifestPatterns:["go.mod"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=!1;for(let Z of H.split(`
2
+ import{Sh as U}from"./chunk-kfn6xbc6.js";import{Yh as f}from"./chunk-91gpxfta.js";var{Glob:u}=globalThis.Bun;import{readdir as m}from"fs/promises";import{join as P,relative as l}from"path";import O from"process";var c=new Set(["node_modules","vendor","target",".git",".venv","venv","dist","build","__pycache__",".next",".cache"]);function W(z){return z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function L(z,H,$=4){let X=H.map((K)=>new u(K)),Z=[];async function J(K,G){if(G>$)return;let V=await m(K,{withFileTypes:!0}).catch(()=>[]);for(let Q of V){let j=P(K,Q.name);if(Q.isDirectory()){if(!c.has(Q.name)&&!Q.name.startsWith("."))await J(j,G+1);continue}if(!Q.isFile())continue;let q=l(z,j);if(X.some((Y)=>Y.match(Q.name)||Y.match(q)))Z.push(q)}}return await J(z,0),Z.sort()}async function M(z,H){let $=[],X=[];for(let Z of H){if(!await Bun.file(P(z,Z.lockfile)).exists())continue;let[J]=Z.command;if(!await E(J)){X.push(`${Z.lockfile} (needs \`${Z.command.join(" ")}\`)`);continue}if(await Bun.spawn(Z.command,{cwd:z,stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??"",HOME:O.env.HOME??""}}).exited===0)$.push(Z.lockfile);else X.push(`${Z.lockfile} (\`${Z.command.join(" ")}\` failed)`)}return{regenerated:$,...X.length>0?{note:`These lockfiles were not regenerated and need updating locally: ${X.join(", ")}.`}:{}}}async function E(z){try{return await Bun.spawn(["which",z],{stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??""}}).exited===0}catch{return!1}}function B(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);for(let J=0;J<Math.max(X.length,Z.length);J++){let K=(X[J]??0)-(Z[J]??0);if(K!==0)return K}return 0}function C(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);if((X[0]??0)!==(Z[0]??0))return"major";if((X[1]??0)!==(Z[1]??0))return"minor";return"patch"}var p=/^\s*(?:require\s+)?([\w.~-]+(?:\.[\w.~-]+)*\/[^\s]+)\s+(v[\w.+-]+)\s*(\/\/.*)?$/,R=/^v\d+\.\d+\.\d+-\d{14}-[a-f0-9]{12}$/,I={name:"go",manifestPatterns:["go.mod"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=!1;for(let Z of H.split(`
3
3
  `)){let J=Z.trim();if(/^require\s*\($/.test(J)){X=!0;continue}if(X&&J===")"){X=!1;continue}if(!X&&!J.startsWith("require "))continue;let K=p.exec(Z);if(!K)continue;let[,G,V,Q]=K;if(Q?.includes("indirect"))continue;if(R.test(V))continue;$.push({name:G,currentVersion:V,section:"require",file:z})}return $},async latest(z,H={}){let $=H.registryUrl??"https://proxy.golang.org",X=z.name.replace(/[A-Z]/g,(K)=>`!${K.toLowerCase()}`),Z=await U(`${$}/${X}/@latest`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!Z?.ok)return null;let J=await Z.json().catch(()=>null);if(!J?.Version)return null;if(R.test(J.Version))return null;return{latest:J.Version,...J.Time?{publishedAt:new Date(J.Time)}:{},releaseNotesUrl:`https://pkg.go.dev/${z.name}@${J.Version}`,homepage:`https://pkg.go.dev/${z.name}`}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion);return z.replace(new RegExp(`^(\\s*(?:require\\s+)?${$}\\s+)${X}(\\s|$)`,"gm"),`$1${H.newVersion}$2`)},async postWrite(z){return M(z,[{lockfile:"go.sum",command:["go","mod","tidy"]}])},osvEcosystem:"Go",compareVersions:B,updateType:C};var s=/^\s*v?(?:(\d+)!)?(\d+(?:\.\d+)*)((?:[-_.]?(?:a|b|c|rc|alpha|beta|pre|preview)[-_.]?\d*)?)((?:[-_.]?(?:post|rev|r)[-_.]?\d*|-\d+)?)((?:[-_.]?dev[-_.]?\d*)?)(?:\+([a-z0-9]+(?:[-_.][a-z0-9]+)*))?\s*$/i,i={a:"a",alpha:"a",b:"b",beta:"b",c:"rc",rc:"rc",pre:"rc",preview:"rc"},v={a:0,b:1,rc:2};function S(z){let H=s.exec(z);if(!H)return null;let[,$,X,Z,J,K,G]=H,V={epoch:$?Number($):0,release:X.split(".").map(Number)};if(Z){let Q=/([a-z]+)[-_.]?(\d*)/i.exec(Z);if(Q){let j=i[Q[1].toLowerCase()];if(j)V.pre=[j,Q[2]?Number(Q[2]):0]}}if(J){let Q=/(\d+)/.exec(J);V.post=Q?Number(Q[1]):0}if(K){let Q=/(\d+)/.exec(K);V.dev=Q?Number(Q[1]):0}if(G)V.local=G.toLowerCase();return V}function d(z,H){for(let $=0;$<Math.max(z.length,H.length);$++){let X=(z[$]??0)-(H[$]??0);if(X!==0)return X}return 0}function A(z,H){let $=S(z),X=S(H);if(!$||!X)return z===H?0:z<H?-1:1;if($.epoch!==X.epoch)return $.epoch-X.epoch;let Z=d($.release,X.release);if(Z!==0)return Z;let J=(Q)=>{if(Q.dev!==void 0&&Q.pre===void 0&&Q.post===void 0)return 0;if(Q.pre!==void 0)return 1;if(Q.post!==void 0)return 3;return 2},K=J($)-J(X);if(K!==0)return K;if($.pre&&X.pre){let Q=v[$.pre[0]]-v[X.pre[0]];if(Q!==0)return Q;if($.pre[1]!==X.pre[1])return $.pre[1]-X.pre[1]}if(($.post??0)!==(X.post??0))return($.post??0)-(X.post??0);let G=$.dev??Number.POSITIVE_INFINITY,V=X.dev??Number.POSITIVE_INFINITY;if(G!==V)return G<V?-1:1;return 0}function g(z){let H=S(z);return Boolean(H&&(H.pre!==void 0||H.dev!==void 0))}function D(z,H){let $=S(z),X=S(H);if(!$||!X)return"patch";if($.epoch!==X.epoch||($.release[0]??0)!==(X.release[0]??0))return"major";if(($.release[1]??0)!==(X.release[1]??0))return"minor";return"patch"}function N(z){let H=/^\s*(~=|===|==|!=|<=|>=|<|>|\^)?\s*(.*)$/.exec(z.trim());if(!H)return{operator:"",version:z.trim()};return{operator:H[1]??"",version:H[2].trim()}}var b=/^\s*([A-Z0-9][\w.-]*)\s*(\[[^\]]*\])?\s*([<>=!~^].*?)?\s*(?:;.*)?$/i,o=/^\s*(?:-|#|$)/;function r(z,H){let $=[];return H.split(`
4
4
  `).forEach((X)=>{let Z=X.split("#")[0];if(o.test(Z))return;let J=b.exec(Z);if(!J?.[1]||!J[3])return;$.push({name:J[1],currentVersion:J[3].trim(),section:"dependencies",file:z,...J[2]?{metadata:{extras:J[2]}}:{}})}),$}var a=[[/^\s*dependencies\s*=\s*\[/m,"dependencies"],[/^\s*(?:dev-dependencies|dev)\s*=\s*\[/m,"devDependencies"]];function n(z,H){let $=[],X=new Set,Z=(K,G,V)=>{let Q=`${V}:${K}`;if(!G.trim()||G.trim()==="*"||X.has(Q))return;X.add(Q),$.push({name:K,currentVersion:G.trim(),section:V,file:z})};for(let[K,G]of a){let V=K.exec(H);if(!V)continue;let Q=V.index+V[0].length,j=H.indexOf("]",Q);if(j===-1)continue;for(let q of H.slice(Q,j).matchAll(/["']([^"']+)["']/g)){let Y=b.exec(q[1]);if(Y?.[1]&&Y[3])Z(Y[1],Y[3],G)}}let J=H.matchAll(/\[tool\.poetry\.(?:group\.[\w-]+\.)?(dependencies|dev-dependencies)\]([\s\S]*?)(?=\n\[|$)/g);for(let K of J){let G=K[1]==="dependencies"?"dependencies":"devDependencies";for(let V of K[2].matchAll(/^\s*([A-Z0-9][\w.-]*)\s*=\s*(.+)$/gim)){let Q=V[1];if(Q.toLowerCase()==="python")continue;let j=V[2].trim(),q=/version\s*=\s*["']([^"']+)["']/.exec(j),Y=/^["']([^"']+)["']/.exec(j),F=q?.[1]??Y?.[1];if(F)Z(Q,F,G)}}return $}var w={name:"python",manifestPatterns:["pyproject.toml","requirements.txt","requirements-*.txt","requirements/*.txt"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){return z.endsWith(".toml")?n(z,H):r(z,H)},async latest(z,H={}){let $=H.registryUrl??"https://pypi.org",X=await U(`${$}/pypi/${encodeURIComponent(z.name)}/json`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Z?.info?.version)return null;let J=Z.info.version;if(H.includePrerelease&&Z.releases){let V=Object.keys(Z.releases).filter((Q)=>!Z.releases[Q]?.every((j)=>j.yanked)).sort(A);J=V[V.length-1]??J}let G=Z.releases?.[J]?.find((V)=>V.upload_time_iso_8601)?.upload_time_iso_8601;return{latest:J,...G?{publishedAt:new Date(G)}:{},...Z.info.yanked?{deprecated:!0}:{},...Z.info.project_urls?.Changelog?{releaseNotesUrl:Z.info.project_urls.Changelog}:{},...Z.info.home_page?{homepage:Z.info.home_page}:{}}},applyUpdate(z,H){let{operator:$}=N(H.currentVersion),X=W(H.name),Z=W(H.currentVersion),J=N(H.newVersion).version,K=$?`${$}${J}`:J;return z.replace(new RegExp(`(^|["'\\s])(${X})(\\[[^\\]]*\\])?\\s*${Z}`,"gim"),(G,V,Q,j)=>`${V}${Q}${j??""}${K}`).replace(new RegExp(`^(\\s*${X}\\s*=\\s*["'])${Z}(["'])`,"gim"),`$1${K}$2`).replace(new RegExp(`^(\\s*${X}\\s*=\\s*\\{[^}]*version\\s*=\\s*["'])${Z}(["'])`,"gim"),`$1${K}$2`)},async postWrite(z){return M(z,[{lockfile:"uv.lock",command:["uv","lock"]},{lockfile:"poetry.lock",command:["poetry","lock","--no-update"]}])},osvEcosystem:"PyPI",compareVersions:A,updateType:D};var t=/^\s*gem\s+["']([\w-]+)["']\s*(?:,\s*["']([^"']+)["'])?/,e=/^\s*group\s+(.+?)\s+do\s*$/,zz=/^\s*end\s*$/,x={name:"ruby",manifestPatterns:["Gemfile","*.gemspec"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=[];for(let Z of H.split(`
5
5
  `)){let J=Z.replace(/#.*$/,""),K=e.exec(J);if(K){X.push(K[1].replace(/[:'",\s]/g,"")||"default");continue}if(zz.test(J)){X.pop();continue}let G=t.exec(J);if(!G?.[1])continue;if(!G[2])continue;if(/\b(?:path|git|github|branch):/.test(J))continue;$.push({name:G[1],currentVersion:G[2],section:X.length>0?X[X.length-1]:"dependencies",file:z})}return $},async latest(z,H={}){let $=H.registryUrl??"https://rubygems.org",X=await U(`${$}/api/v1/versions/${encodeURIComponent(z.name)}.json`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Array.isArray(Z)||Z.length===0)return null;let J=Z.filter((G)=>G.number&&!G.yanked).filter((G)=>H.includePrerelease?!0:!G.prerelease).sort((G,V)=>B(G.number,V.number)),K=J[J.length-1];if(!K?.number)return null;return{latest:K.number,...K.created_at?{publishedAt:new Date(K.created_at)}:{},homepage:`${$}/gems/${z.name}`}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion),Z=/^\s*(~>|>=|<=|>|<|=)?\s*/.exec(H.currentVersion)?.[1]??"",J=Z?`${Z} ${H.newVersion}`:H.newVersion;return z.replace(new RegExp(`^(\\s*gem\\s+["']${$}["']\\s*,\\s*["'])${X}(["'])`,"gm"),`$1${J}$2`)},async postWrite(z){return M(z,[{lockfile:"Gemfile.lock",command:["bundle","lock","--update"]}])},osvEcosystem:"RubyGems",compareVersions:B,updateType:C};var Hz=[[/^\[dependencies\]/m,"dependencies"],[/^\[dev-dependencies\]/m,"devDependencies"],[/^\[build-dependencies\]/m,"buildDependencies"],[/^\[workspace\.dependencies\]/m,"workspaceDependencies"]],T={name:"rust",manifestPatterns:["Cargo.toml"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[];for(let[X,Z]of Hz){let J=X.exec(H);if(!J)continue;let K=J.index+J[0].length,G=H.slice(K).search(/\n\[/),V=G===-1?H.slice(K):H.slice(K,K+G);for(let Q of V.matchAll(/^\s*([\w-]+)\s*=\s*(.+)$/gm)){let j=Q[1],q=Q[2].trim(),Y=/version\s*=\s*["']([^"']+)["']/.exec(q),F=/^["']([^"']+)["']/.exec(q),_=Y?.[1]??F?.[1];if(!_||/\b(?:path|git)\s*=/.test(q))continue;$.push({name:j,currentVersion:_,section:Z,file:z})}}return $},async latest(z,H={}){let $=H.registryUrl??"https://crates.io",X=await U(`${$}/api/v1/crates/${encodeURIComponent(z.name)}`,{headers:{"User-Agent":"buddy (https://buddy.sh)",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Z?.crate)return null;let J=H.includePrerelease?Z.crate.newest_version??Z.crate.max_stable_version:Z.crate.max_stable_version??Z.crate.newest_version;if(!J)return null;let K=Z.versions?.find((G)=>G.num===J);if(K?.yanked)return null;return{latest:J,...K?.created_at?{publishedAt:new Date(K.created_at)}:{},...Z.crate.repository?{releaseNotesUrl:`${Z.crate.repository}/releases`}:{},...Z.crate.homepage?{homepage:Z.crate.homepage}:{}}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion);return z.replace(new RegExp(`^(\\s*${$}\\s*=\\s*["'])${X}(["'])`,"gm"),`$1${H.newVersion}$2`).replace(new RegExp(`^(\\s*${$}\\s*=\\s*\\{[^}]*?version\\s*=\\s*["'])${X}(["'])`,"gm"),`$1${H.newVersion}$2`)},async postWrite(z){return M(z,[{lockfile:"Cargo.lock",command:["cargo","update","--workspace"]}])},osvEcosystem:"crates.io",compareVersions:B,updateType:C};import{join as Xz}from"path";async function Zz(z){let H=z.logger??f(),$=z.adapters??k,X=new Set(z.ignore??[]),Z=[],J={},K=[];return await Promise.all($.map(async(G)=>{let V;try{V=await G.detect(z.dir)}catch(Q){H.warn(`\u26A0\uFE0F ${G.name}: could not look for manifests: ${Q}`);return}if(V.length===0)return;K.push({ecosystem:G.name,files:V}),H.debug(`\uD83D\uDCE6 ${G.name}: ${V.length} manifest(s)`);for(let Q of V){let j;try{j=await G.parse(Q,await Bun.file(Xz(z.dir,Q)).text())}catch(Y){H.warn(`\u26A0\uFE0F ${G.name}: could not parse ${Q}: ${Y}`);continue}J[G.name]=(J[G.name]??0)+j.length;let q=await Promise.all(j.map(async(Y)=>{if(X.has(Y.name))return null;try{let F=await G.latest(Y,{...z.includePrerelease!==void 0?{includePrerelease:z.includePrerelease}:{},logger:H});if(!F)return null;let _=y(Y.currentVersion);if(G.compareVersions(F.latest,_)<=0)return null;return{name:Y.name,currentVersion:Y.currentVersion,newVersion:F.latest,updateType:G.updateType(_,F.latest),dependencyType:G.name,file:Q,...F.releaseNotesUrl?{releaseNotesUrl:F.releaseNotesUrl}:{},...F.homepage?{homepage:F.homepage}:{}}}catch(F){return H.debug(`${G.name}: could not resolve ${Y.name}: ${F}`),null}}));Z.push(...q.filter((Y)=>Y!==null))}})),{updates:Z,dependenciesByEcosystem:J,manifests:K}}function y(z){let H=/(\d[\w.!+-]*)/.exec(z);return H?H[1]:z.trim()}async function $z(z,H,$=k){let X=[],Z=[];for(let J of $){if(!H.includes(J.name)||!J.postWrite)continue;let K=await J.postWrite(z).catch(()=>({regenerated:[],note:void 0}));if(X.push(...K.regenerated),K.note)Z.push(K.note)}return{regenerated:X,notes:Z}}var k=[w,T,I,x];function Ez(z,H=k){let $=z.split("/").pop()??z;for(let X of H)if(X.manifestPatterns.some((Z)=>h($,Z)||h(z,Z)))return X;return null}function h(z,H){if(!H.includes("*"))return z===H;let $=H.split("*").map((X)=>X.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join("[^/]*");return new RegExp(`^${$}$`).test(z)}function Rz(z,H=k){return H.find(($)=>$.name===z)??null}
6
- export{W as oc,L as pc,M as qc,E as rc,B as sc,C as tc,I as uc,S as vc,A as wc,g as xc,D as yc,N as zc,w as Ac,x as Bc,T as Cc,k as Dc,Ez as Ec,Rz as Fc,Zz as Gc,y as Hc,$z as Ic};
6
+ export{W as qc,L as rc,M as sc,E as tc,B as uc,C as vc,I as wc,S as xc,A as yc,g as zc,D as Ac,N as Bc,w as Cc,x as Dc,T as Ec,k as Fc,Ez as Gc,Rz as Hc,Zz as Ic,y as Jc,$z as Kc};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ta as a,Ua as b,Va as c,Wa as d,Xa as e}from"./chunk-6njk0m4a.js";import"./chunk-fanj4t6c.js";import"./chunk-zqrgvftj.js";import"./chunk-me7y4rd3.js";import"./chunk-7khgke9n.js";import"./chunk-91gpxfta.js";import"./chunk-xmqv24zr.js";export{b as verifyChanges,c as stackedBranchName,d as runStackedTouch,e as detectChangedFiles,a as TEST_COMMANDS};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ac as m,Bc as n,Cc as o,Dc as p,Ec as q,Fc as r,Gc as s,Hc as t,Ic as u,oc as a,pc as b,qc as c,rc as d,sc as e,tc as f,uc as g,vc as h,wc as i,xc as j,yc as k,zc as l}from"./chunk-vx23zjwq.js";import"./chunk-kqwdg3nw.js";import"./chunk-56t2za4k.js";import"./chunk-eaz23nsf.js";export{t as stripOperators,l as splitConstraint,s as scanEcosystems,o as rustAdapter,n as rubyAdapter,c as regenerateWith,u as regenerateLockfiles,m as pythonAdapter,k as pep440UpdateType,h as parsePep440,f as numericUpdateType,j as isPep440Prerelease,g as goAdapter,a as escapeRegex,b as detectFiles,i as comparePep440,e as compareNumeric,d as commandAvailable,r as adapterNamed,q as adapterFor,p as BUILTIN_ADAPTERS};
2
+ import{Ac as k,Bc as l,Cc as m,Dc as n,Ec as o,Fc as p,Gc as q,Hc as r,Ic as s,Jc as t,Kc as u,qc as a,rc as b,sc as c,tc as d,uc as e,vc as f,wc as g,xc as h,yc as i,zc as j}from"./chunk-2qwk5xfp.js";import"./chunk-kfn6xbc6.js";import"./chunk-91gpxfta.js";import"./chunk-xmqv24zr.js";export{t as stripOperators,l as splitConstraint,s as scanEcosystems,o as rustAdapter,n as rubyAdapter,c as regenerateWith,u as regenerateLockfiles,m as pythonAdapter,k as pep440UpdateType,h as parsePep440,f as numericUpdateType,j as isPep440Prerelease,g as goAdapter,a as escapeRegex,b as detectFiles,i as comparePep440,e as compareNumeric,d as commandAvailable,r as adapterNamed,q as adapterFor,p as BUILTIN_ADAPTERS};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{fc as _}from"./chunk-97857d8t.js";import{Th as X}from"./chunk-56t2za4k.js";import{il as M}from"./chunk-eaz23nsf.js";var K={review:"review","full-review":"full-review",full:"full-review",summary:"summary",resolve:"resolve",pause:"pause",resume:"resume",ignore:"ignore",rebase:"rebase",retry:"rebase",merge:"merge",plan:"plan","fix-ci":"fix-ci",fix:"fix-ci",remember:"remember",help:"help"},Q=["help","summary"];function V(H){return H.replace(/```[\s\S]*?```/g," ").replace(/~~~[\s\S]*?~~~/g," ").replace(/`[^`\n]*`/g," ").split(`
2
+ import{hc as _}from"./chunk-b1ng5aqx.js";import{Yh as X}from"./chunk-91gpxfta.js";import{nl as M}from"./chunk-xmqv24zr.js";var K={review:"review","full-review":"full-review",full:"full-review",summary:"summary",resolve:"resolve",pause:"pause",resume:"resume",ignore:"ignore",rebase:"rebase",retry:"rebase",merge:"merge",plan:"plan","fix-ci":"fix-ci",fix:"fix-ci",remember:"remember",help:"help"},Q=["help","summary"];function V(H){return H.replace(/```[\s\S]*?```/g," ").replace(/~~~[\s\S]*?~~~/g," ").replace(/`[^`\n]*`/g," ").split(`
3
3
  `).filter((C)=>!C.trimStart().startsWith(">")).join(`
4
- `)}function $(H,C="@buddy"){if(!H)return null;let B=V(H),O=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`(?:^|\\s)${O}\\b[ \\t]*(.*)`,"i"),z=B.match(j);if(!z)return null;let A=(z[1]??"").trim();if(!A)return{name:"help",args:"",raw:z[0].trim()};let[D,...E]=A.split(/\s+/),J=K[D.toLowerCase()];if(!J)return{name:"chat",args:A,raw:z[0].trim()};return{name:J,args:E.join(" "),raw:z[0].trim()}}function G(H){return Q.includes(H)}function F(H,C="@buddy"){return Boolean(H?.toLowerCase().includes(C.toLowerCase()))}var Y="**Buddy commands**\n\n| Command | What it does |\n|---|---|\n| `@buddy review` | Review new changes since the last review |\n| `@buddy full-review` | Review the whole diff again, ignoring previous findings |\n| `@buddy summary` | Post a fresh summary without inline findings |\n| `@buddy pause` / `resume` | Stop or restart reviewing this pull request |\n| `@buddy rebase` | Rebase a dependency update pull request |\n| `@buddy merge` | Re-check auto-merge conditions now |\n| `@buddy fix-ci` | Diagnose the failing checks, and retry a flake |\n| `@buddy plan` | Research the repository and write an implementation plan |\n| `@buddy resolve` | Close the review threads Buddy opened |\n| `@buddy remember <text>` | Record a durable note for future runs |\n| `@buddy help` | Show this table |\n\nAnything else after the mention is treated as a question.";function Z(H){if(H.actor.isBot)return"comment was written by a bot";if(G(H.command.name))return null;if(!H.actor.canWrite)return`@${H.actor.login} does not have write access`;return null}async function L(H,C){let B=H.logger??X(),O=Z(H);if(O)return B.info(`\uD83D\uDEAB Ignoring \`${H.command.name}\`: ${O}`),{handled:!1,refusal:O};if(H.command.name==="help")return{handled:!0,reply:Y};let j=C[H.command.name];if(!j)return{handled:!1,refusal:`no handler for ${H.command.name}`,reply:`I don't know how to \`${H.command.name}\` yet. Try \`@buddy help\`.`};return B.info(`\uD83E\uDD16 Running \`${H.command.name}\` for @${H.actor.login}`),await j(H)}function T(H){return{async review(C){if(!C.isPullRequest)return{handled:!1,reply:"There is nothing to review \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.review(C.number,{})}},async "full-review"(C){if(!C.isPullRequest)return{handled:!1,reply:"There is nothing to review \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.review(C.number,{full:!0})}},async summary(C){if(!C.isPullRequest)return{handled:!1,reply:"There is nothing to summarize \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.review(C.number,{summaryOnly:!0})}},async pause(C){return await I(H,C.number,!0),{handled:!0,reply:"Paused. I will not review this pull request again until you say `@buddy resume`."}},async resume(C){return await I(H,C.number,!1),{handled:!0,reply:"Resumed. I will review the next push."}},async ignore(C){return await I(H,C.number,!0),{handled:!0,reply:"Understood \u2014 I will leave this pull request alone."}},async rebase(C){return{handled:!0,reply:await H.rebase(C.number)}},async merge(C){return{handled:!0,reply:(await H.merge()).includes(C.number)?"Merged.":"This pull request does not currently qualify for auto-merge. Check the conditions in your config and whether its checks have passed."}},async "fix-ci"(C){if(!C.isPullRequest)return{handled:!1,reply:"There are no checks to look at \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.fixCi(C.number)}},async remember(C){let B=C.command.args.trim();if(!B)return{handled:!1,reply:"Tell me what to remember, e.g. `@buddy remember we pin react to 17`."};return{handled:!0,reply:await H.remember(B,C)}},async resolve(C){if(!C.isPullRequest)return{handled:!1,reply:"There are no review threads here \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.resolve(C.number)}},async plan(C){return{handled:!0,reply:await H.plan(C.number,C.isPullRequest,C.command.args.trim())}},async chat(C){let B=_(H.config,C.logger);if(!B)return{handled:!1,reply:"I need an AI provider configured to answer questions. See https://buddy.sh/ai/providers"};return{handled:!0,reply:(await B.complete({system:"You are Buddy, answering a question in a pull request or issue thread. Be brief and concrete. If you do not know, say so rather than guessing.",messages:[{role:"user",content:C.command.args}]})).text}}}}async function I(H,C,B){let j=(await H.provider.getPullRequests("open")).find((E)=>E.number===C);if(!j)return;let{parseReviewState:z,upsertReviewState:A}=await import("./chunk-7rdqaj9g.js"),D=z(j.body);await H.provider.updatePullRequest(C,{body:A(j.body,{reviewedSha:D?.reviewedSha??"",fingerprints:D?.fingerprints??[],reviewedAt:D?.reviewedAt??new Date().toISOString(),...B?{paused:!0}:{}})})}export{K as db,Q as eb,V as fb,$ as gb,G as hb,F as ib,Y as jb,Z as kb,L as lb,T as mb};
4
+ `)}function $(H,C="@buddy"){if(!H)return null;let B=V(H),O=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`(?:^|\\s)${O}\\b[ \\t]*(.*)`,"i"),z=B.match(j);if(!z)return null;let A=(z[1]??"").trim();if(!A)return{name:"help",args:"",raw:z[0].trim()};let[D,...E]=A.split(/\s+/),J=K[D.toLowerCase()];if(!J)return{name:"chat",args:A,raw:z[0].trim()};return{name:J,args:E.join(" "),raw:z[0].trim()}}function G(H){return Q.includes(H)}function F(H,C="@buddy"){return Boolean(H?.toLowerCase().includes(C.toLowerCase()))}var Y="**Buddy commands**\n\n| Command | What it does |\n|---|---|\n| `@buddy review` | Review new changes since the last review |\n| `@buddy full-review` | Review the whole diff again, ignoring previous findings |\n| `@buddy summary` | Post a fresh summary without inline findings |\n| `@buddy pause` / `resume` | Stop or restart reviewing this pull request |\n| `@buddy rebase` | Rebase a dependency update pull request |\n| `@buddy merge` | Re-check auto-merge conditions now |\n| `@buddy fix-ci` | Diagnose the failing checks, and retry a flake |\n| `@buddy plan` | Research the repository and write an implementation plan |\n| `@buddy resolve` | Close the review threads Buddy opened |\n| `@buddy remember <text>` | Record a durable note for future runs |\n| `@buddy help` | Show this table |\n\nAnything else after the mention is treated as a question.";function Z(H){if(H.actor.isBot)return"comment was written by a bot";if(G(H.command.name))return null;if(!H.actor.canWrite)return`@${H.actor.login} does not have write access`;return null}async function L(H,C){let B=H.logger??X(),O=Z(H);if(O)return B.info(`\uD83D\uDEAB Ignoring \`${H.command.name}\`: ${O}`),{handled:!1,refusal:O};if(H.command.name==="help")return{handled:!0,reply:Y};let j=C[H.command.name];if(!j)return{handled:!1,refusal:`no handler for ${H.command.name}`,reply:`I don't know how to \`${H.command.name}\` yet. Try \`@buddy help\`.`};return B.info(`\uD83E\uDD16 Running \`${H.command.name}\` for @${H.actor.login}`),await j(H)}function T(H){return{async review(C){if(!C.isPullRequest)return{handled:!1,reply:"There is nothing to review \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.review(C.number,{})}},async "full-review"(C){if(!C.isPullRequest)return{handled:!1,reply:"There is nothing to review \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.review(C.number,{full:!0})}},async summary(C){if(!C.isPullRequest)return{handled:!1,reply:"There is nothing to summarize \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.review(C.number,{summaryOnly:!0})}},async pause(C){return await I(H,C.number,!0),{handled:!0,reply:"Paused. I will not review this pull request again until you say `@buddy resume`."}},async resume(C){return await I(H,C.number,!1),{handled:!0,reply:"Resumed. I will review the next push."}},async ignore(C){return await I(H,C.number,!0),{handled:!0,reply:"Understood \u2014 I will leave this pull request alone."}},async rebase(C){return{handled:!0,reply:await H.rebase(C.number)}},async merge(C){return{handled:!0,reply:(await H.merge()).includes(C.number)?"Merged.":"This pull request does not currently qualify for auto-merge. Check the conditions in your config and whether its checks have passed."}},async "fix-ci"(C){if(!C.isPullRequest)return{handled:!1,reply:"There are no checks to look at \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.fixCi(C.number)}},async remember(C){let B=C.command.args.trim();if(!B)return{handled:!1,reply:"Tell me what to remember, e.g. `@buddy remember we pin react to 17`."};return{handled:!0,reply:await H.remember(B,C)}},async resolve(C){if(!C.isPullRequest)return{handled:!1,reply:"There are no review threads here \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.resolve(C.number)}},async plan(C){return{handled:!0,reply:await H.plan(C.number,C.isPullRequest,C.command.args.trim())}},async chat(C){let B=_(H.config,C.logger);if(!B)return{handled:!1,reply:"I need an AI provider configured to answer questions. See https://buddy.sh/ai/providers"};return{handled:!0,reply:(await B.complete({system:"You are Buddy, answering a question in a pull request or issue thread. Be brief and concrete. If you do not know, say so rather than guessing.",messages:[{role:"user",content:C.command.args}]})).text}}}}async function I(H,C,B){let j=(await H.provider.getPullRequests("open")).find((E)=>E.number===C);if(!j)return;let{parseReviewState:z,upsertReviewState:A}=await import("./chunk-ve9xvyez.js"),D=z(j.body);await H.provider.updatePullRequest(C,{body:A(j.body,{reviewedSha:D?.reviewedSha??"",fingerprints:D?.fingerprints??[],reviewedAt:D?.reviewedAt??new Date().toISOString(),...B?{paused:!0}:{}})})}export{K as fb,Q as gb,V as hb,$ as ib,G as jb,F as kb,Y as lb,Z as mb,L as nb,T as ob};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ga as a,ha as b}from"./chunk-7vk0vrwm.js";import"./chunk-b1ng5aqx.js";import"./chunk-nrm7vjmv.js";import"./chunk-yzyqkwsc.js";import"./chunk-9g0am1m2.js";import"./chunk-n7hbbha7.js";import"./chunk-cf5czw9m.js";import"./chunk-cbzc9ggs.js";import"./chunk-9rvapdmv.js";import"./chunk-7h8qjayv.js";import"./chunk-zqrgvftj.js";import"./chunk-me7y4rd3.js";import"./chunk-kfn6xbc6.js";import"./chunk-91gpxfta.js";import"./chunk-xmqv24zr.js";export{b as renderDoctorReport,a as diagnose};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$a as b,_a as a,ab as c,bb as d,cb as e,db as f,eb as g}from"./chunk-n8zfts91.js";import"./chunk-9g0am1m2.js";import"./chunk-n7hbbha7.js";import"./chunk-9rvapdmv.js";import"./chunk-016ce171.js";import"./chunk-fanj4t6c.js";import"./chunk-zqrgvftj.js";import"./chunk-me7y4rd3.js";import"./chunk-7khgke9n.js";import"./chunk-kfn6xbc6.js";import"./chunk-91gpxfta.js";import"./chunk-xmqv24zr.js";export{g as runFixCi,e as latestFailurePerWorkflow,d as failsOnBaseBranch,b as extractErrorLines,c as describeFailure,a as classifyFailure,f as attemptFix};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Nc as v,Oc as F,Pc as B,Qc as k}from"./chunk-339ae7vn.js";import{$f as I,_f as y,ag as W}from"./chunk-cj4d5ad7.js";import{zh as T}from"./chunk-yh13j2af.js";import{Ih as R}from"./chunk-wkjv03yr.js";import{Nh as U}from"./chunk-kqwdg3nw.js";import{Ph as L,Qh as x,Th as D}from"./chunk-56t2za4k.js";import{Buffer as S}from"buffer";import{spawn as w}from"child_process";import j from"process";var g=/\b(?:gh[pousr]_[A-Z0-9_]{20,}|github_pat_[A-Z0-9_]{20,}|[A-Z0-9]{40,})\b/gi;function N(Q){return Q==="completed"||Q==="in_progress"?Q:"queued"}function f(Q){if(typeof Q!=="string")return null;if(Q==="success"||Q==="cancelled")return Q;if(Q==="failure"||Q==="timed_out"||Q==="action_required")return"failure";return"skipped"}function d(Q,X){let Y=Q.replace(g,"[REDACTED]");if(X&&X.length>=8)Y=Y.split(X).join("[REDACTED]");return Y}class P extends Error{constructor(Q){super(Q);this.name="LockfileRegenerationError"}}function h(Q,X){let Y=`http.${Q.replace(/\/+$/,"")}/.extraheader`,Z=S.from(`x-access-token:${X}`).toString("base64");return["-c",`${Y}=`,"-c",`${Y}=AUTHORIZATION: basic ${Z}`]}class E extends Error{constructor(Q){super(Q);this.name="WorkflowPermissionError"}}function l(Q){let X=`${x(Q)} ${Q?.message??""}`;return/refusing to allow (?:a GitHub App|an OAuth App|a Personal Access Token)[^\n]*workflow/i.test(X)}function m(Q){let X=`${x(Q)} ${Q?.message??""}`;return/not permitted to create or approve pull requests/i.test(X)||Q?.status===403&&/pull/i.test(X)}class b{token;owner;repo;hasWorkflowPermissions;workflowToken;apiUrl;cache={pullRequests:new Map,issues:new Map};cacheTTL=120000;logger;constructor(Q,X,Y,Z=!1,$,J,G){this.token=Q;this.owner=X;this.repo=Y;this.hasWorkflowPermissions=Z;this.workflowToken=$;this.apiUrl=J?J.replace(/\/+$/,""):T(),this.logger=G??D()}capabilities(){return{pinIssues:!0,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!0,nativeAutoMerge:!0,commentReactions:!0,ciLogs:!0,ciRuns:!0,reviewThreads:!0,teamReviewers:!0,draftPullRequests:!0,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!0,labels:!0}}isCacheValid(Q){return Date.now()-Q<this.cacheTTL}clearCache(){this.cache.pullRequests.clear(),this.cache.issues.clear()}async branchExists(Q){try{return await this.apiRequest(`GET /repos/${this.owner}/${this.repo}/git/ref/heads/${Q}`),!0}catch(X){if(X.message?.includes("404"))return!1;return this.logger.warn(`\u26A0\uFE0F Error checking branch ${Q}: ${x(X)}`),!1}}async createBranch(Q,X){try{let Z=(await this.apiRequest(`GET /repos/${this.owner}/${this.repo}/git/ref/heads/${X}`)).object.sha;await this.apiRequest(`POST /repos/${this.owner}/${this.repo}/git/refs`,{ref:`refs/heads/${Q}`,sha:Z}),this.logger.info(`\u2705 Created branch ${Q} from ${X}`)}catch(Y){throw this.logger.error(`\u274C Failed to create branch ${Q}: ${x(Y)}`),Y}}async commitChanges(Q,X,Y,Z="main"){try{await this.commitChangesWithGit(Q,X,Y,Z)}catch($){if($ instanceof P||$ instanceof y)throw $;if(l($)){let J=Y.filter((_)=>!_.path.includes(".github/workflows/")),G=Y.length-J.length;if(J.length===0)throw new E(`The token may not update workflow files (${G} in this change). Grant the GitHub App the Workflows permission, or use a PAT with the workflow scope as BUDDY_TOKEN.`);this.logger.warn(`\u26A0\uFE0F The token may not update workflow files; committing the ${J.length} other file(s) without the ${G} workflow file(s)`),await this.commitChangesWithGit(Q,X,J,Z);return}this.logger.warn(`\u26A0\uFE0F Git CLI commit failed, falling back to GitHub API: ${$}`),await this.commitChangesWithAPI(Q,X,Y,Z)}}async commitChangesWithGit(Q,X,Y,Z="main"){try{let $=Y.filter((V)=>V.path.includes(".github/workflows/")),J=Y.filter((V)=>!V.path.includes(".github/workflows/"));if($.length>0&&!this.hasWorkflowPermissions)if(this.logger.warn(`\u26A0\uFE0F Detected ${$.length} workflow file(s). These require elevated permissions.`),this.logger.warn(`\u26A0\uFE0F Workflow files: ${$.map((V)=>V.path).join(", ")}`),this.logger.warn("\u2139\uFE0F Workflow files will be skipped in this commit. BUDDY_TOKEN not detected or lacks workflow permissions."),J.length>0)this.logger.info(`\uD83D\uDCDD Committing ${J.length} non-workflow files...`),Y=J;else{this.logger.warn("\u26A0\uFE0F All files are workflow files. No files will be committed in this PR."),this.logger.warn("\uD83D\uDCA1 To update workflow files, ensure BUDDY_TOKEN is set with workflow:write permissions."),this.logger.info('\uD83D\uDCDD Creating empty commit to avoid "No commits between branches" error...');try{await this.runCommand("git",["commit","--allow-empty","-m","Workflow files require elevated permissions - no changes committed"]),this.logger.info("\u2705 Created empty commit for workflow-only PR")}catch(V){this.logger.warn(`\u26A0\uFE0F Failed to create empty commit: ${V}`);try{let C=Bun.file("README.md");if(await C.exists()){let H=`${await C.text()}
2
+ import{Pc as v,Qc as F,Rc as B,Sc as k}from"./chunk-tf0mb8m0.js";import{bg as y,cg as I,dg as W}from"./chunk-7khgke9n.js";import{Eh as T}from"./chunk-gt3m1eqn.js";import{Nh as R}from"./chunk-rad9rc2j.js";import{Sh as U}from"./chunk-kfn6xbc6.js";import{Uh as L,Vh as x,Yh as D}from"./chunk-91gpxfta.js";import{Buffer as S}from"buffer";import{spawn as w}from"child_process";import j from"process";var g=/\b(?:gh[pousr]_[A-Z0-9_]{20,}|github_pat_[A-Z0-9_]{20,}|[A-Z0-9]{40,})\b/gi;function N(Q){return Q==="completed"||Q==="in_progress"?Q:"queued"}function f(Q){if(typeof Q!=="string")return null;if(Q==="success"||Q==="cancelled")return Q;if(Q==="failure"||Q==="timed_out"||Q==="action_required")return"failure";return"skipped"}function d(Q,X){let Y=Q.replace(g,"[REDACTED]");if(X&&X.length>=8)Y=Y.split(X).join("[REDACTED]");return Y}class P extends Error{constructor(Q){super(Q);this.name="LockfileRegenerationError"}}function h(Q,X){let Y=`http.${Q.replace(/\/+$/,"")}/.extraheader`,Z=S.from(`x-access-token:${X}`).toString("base64");return["-c",`${Y}=`,"-c",`${Y}=AUTHORIZATION: basic ${Z}`]}class E extends Error{constructor(Q){super(Q);this.name="WorkflowPermissionError"}}function l(Q){let X=`${x(Q)} ${Q?.message??""}`;return/refusing to allow (?:a GitHub App|an OAuth App|a Personal Access Token)[^\n]*workflow/i.test(X)}function m(Q){let X=`${x(Q)} ${Q?.message??""}`;return/not permitted to create or approve pull requests/i.test(X)||Q?.status===403&&/pull/i.test(X)}class b{token;owner;repo;hasWorkflowPermissions;workflowToken;apiUrl;cache={pullRequests:new Map,issues:new Map};cacheTTL=120000;logger;constructor(Q,X,Y,Z=!1,$,J,G){this.token=Q;this.owner=X;this.repo=Y;this.hasWorkflowPermissions=Z;this.workflowToken=$;this.apiUrl=J?J.replace(/\/+$/,""):T(),this.logger=G??D()}capabilities(){return{pinIssues:!0,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!0,nativeAutoMerge:!0,commentReactions:!0,ciLogs:!0,ciRuns:!0,reviewThreads:!0,teamReviewers:!0,draftPullRequests:!0,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!0,labels:!0}}isCacheValid(Q){return Date.now()-Q<this.cacheTTL}clearCache(){this.cache.pullRequests.clear(),this.cache.issues.clear()}async branchExists(Q){try{return await this.apiRequest(`GET /repos/${this.owner}/${this.repo}/git/ref/heads/${Q}`),!0}catch(X){if(X.message?.includes("404"))return!1;return this.logger.warn(`\u26A0\uFE0F Error checking branch ${Q}: ${x(X)}`),!1}}async createBranch(Q,X){try{let Z=(await this.apiRequest(`GET /repos/${this.owner}/${this.repo}/git/ref/heads/${X}`)).object.sha;await this.apiRequest(`POST /repos/${this.owner}/${this.repo}/git/refs`,{ref:`refs/heads/${Q}`,sha:Z}),this.logger.info(`\u2705 Created branch ${Q} from ${X}`)}catch(Y){throw this.logger.error(`\u274C Failed to create branch ${Q}: ${x(Y)}`),Y}}async commitChanges(Q,X,Y,Z="main"){try{await this.commitChangesWithGit(Q,X,Y,Z)}catch($){if($ instanceof P||$ instanceof y)throw $;if(l($)){let J=Y.filter((_)=>!_.path.includes(".github/workflows/")),G=Y.length-J.length;if(J.length===0)throw new E(`The token may not update workflow files (${G} in this change). Grant the GitHub App the Workflows permission, or use a PAT with the workflow scope as BUDDY_TOKEN.`);this.logger.warn(`\u26A0\uFE0F The token may not update workflow files; committing the ${J.length} other file(s) without the ${G} workflow file(s)`),await this.commitChangesWithGit(Q,X,J,Z);return}this.logger.warn(`\u26A0\uFE0F Git CLI commit failed, falling back to GitHub API: ${$}`),await this.commitChangesWithAPI(Q,X,Y,Z)}}async commitChangesWithGit(Q,X,Y,Z="main"){try{let $=Y.filter((V)=>V.path.includes(".github/workflows/")),J=Y.filter((V)=>!V.path.includes(".github/workflows/"));if($.length>0&&!this.hasWorkflowPermissions)if(this.logger.warn(`\u26A0\uFE0F Detected ${$.length} workflow file(s). These require elevated permissions.`),this.logger.warn(`\u26A0\uFE0F Workflow files: ${$.map((V)=>V.path).join(", ")}`),this.logger.warn("\u2139\uFE0F Workflow files will be skipped in this commit. BUDDY_TOKEN not detected or lacks workflow permissions."),J.length>0)this.logger.info(`\uD83D\uDCDD Committing ${J.length} non-workflow files...`),Y=J;else{this.logger.warn("\u26A0\uFE0F All files are workflow files. No files will be committed in this PR."),this.logger.warn("\uD83D\uDCA1 To update workflow files, ensure BUDDY_TOKEN is set with workflow:write permissions."),this.logger.info('\uD83D\uDCDD Creating empty commit to avoid "No commits between branches" error...');try{await this.runCommand("git",["commit","--allow-empty","-m","Workflow files require elevated permissions - no changes committed"]),this.logger.info("\u2705 Created empty commit for workflow-only PR")}catch(V){this.logger.warn(`\u26A0\uFE0F Failed to create empty commit: ${V}`);try{let C=Bun.file("README.md");if(await C.exists()){let H=`${await C.text()}
3
3
 
4
4
  <!-- Updated by Buddy -->
5
5
  `;await Bun.write("README.md",H),await this.runCommand("git",["add","README.md"]),await this.runCommand("git",["commit","-m","Update README for workflow-only PR"]),this.logger.info("\u2705 Created README update for workflow-only PR")}}catch(K){this.logger.error(`\u274C Failed to create any commit: ${K}`)}}return}else if($.length>0)this.logger.info(`\u2705 Including ${$.length} workflow file(s) with elevated permissions`);try{await this.runCommand("git",["config","user.name","github-actions[bot]"]),await this.runCommand("git",["config","user.email","41898282+github-actions[bot]@users.noreply.github.com"]),this.logger.info("\u2705 Git identity configured for github-actions[bot]")}catch(V){this.logger.warn("\u26A0\uFE0F Failed to configure Git identity:",V)}await this.runCommand("git",["fetch","origin"]),this.logger.info(`\uD83D\uDD04 Recreating ${Q} from origin/${Z} (Renovate-style)...`);try{await this.runCommand("git",["checkout",Q])}catch{try{await this.runCommand("git",["checkout","-b",Q,`origin/${Q}`])}catch{await this.runCommand("git",["checkout","-b",Q])}}await this.runCommand("git",["reset","--hard",`origin/${Z}`]),await this.runCommand("git",["clean","-fd"]),this.logger.info(`\u2705 Reset ${Q} to origin/${Z}`),await W(Y,async(V)=>{try{return await this.runCommand("git",["cat-file","-e",`origin/${Z}:${V}`]),!0}catch{return!1}});for(let V of Y){let K=I(V.path);if(j.env.NODE_ENV==="test"||j.env.BUN_ENV==="test"){if(["package.json","bun.lock","bun.lockb","package-lock.json","yarn.lock"].includes(K)&&V.content==='{"name":"x"}'){this.logger.warn(`\u26A0\uFE0F Skipping test file write to ${K} to prevent overwriting project files`);continue}}if(V.type==="delete")try{await this.runCommand("git",["rm",K])}catch{}else await Bun.write(K,V.content),await this.runCommand("git",["add",K])}if(!(j.env.NODE_ENV==="test"||j.env.BUN_ENV==="test")){let V=Y.map((C)=>C.path.replace(/^\.\//,"").replace(/^\/+/,"")),K=B(V);if(K.length>0){this.logger.info(`\uD83D\uDD12 Regenerating lock files for: ${K.join(", ")}`);let C=j.cwd(),M=[];for(let H of K)try{let z=await F(H,C);if(z.success)for(let q of v())try{await this.runCommand("git",["add",q])}catch{}else M.push(`${H}: ${z.message}`)}catch(z){M.push(`${H}: ${z instanceof Error?z.message:String(z)}`)}for(let H of k(V,C))try{let z=await F(H.manager,`${C}/${H.dir}`);if(z.success)await this.runCommand("git",["add",H.lockFile]);else M.push(`${H.dir} (${H.manager}): ${z.message}`)}catch(z){M.push(`${H.dir} (${H.manager}): ${z instanceof Error?z.message:String(z)}`)}if(M.length>0){let H=M.map((z)=>` - ${z}`).join(`
@@ -35,4 +35,4 @@ ${H}`)}}}if((await this.runCommand("git",["status","--porcelain"])).trim()){awai
35
35
  Auth: ${M}
36
36
  Repo: ${this.owner}/${this.repo}
37
37
  ${C}`,K.status,$,G,`${this.owner}/${this.repo}`,C)}if(K.headers.get("content-type")?.includes("application/json"))return K.json();return K.text()}async apiRequestWithRetry(Q,X,Y=3){return this.apiRequest(Q,X,void 0,Math.max(0,Y-1))}async createIssue(Q){this.cache.issues.clear();try{let X=await this.apiRequestWithRetry(`POST /repos/${this.owner}/${this.repo}/issues`,{title:Q.title,body:Q.body,assignees:Q.assignees||[],labels:Q.labels||[],milestone:Q.milestone});return this.logger.info(`\u2705 Created issue #${X.number}: ${Q.title}`),{number:X.number,title:X.title,body:X.body,state:X.state,url:X.html_url,createdAt:new Date(X.created_at),updatedAt:new Date(X.updated_at),closedAt:X.closed_at?new Date(X.closed_at):void 0,author:X.user.login,assignees:X.assignees?.map((Y)=>Y.login)||[],labels:X.labels?.map((Y)=>typeof Y==="string"?Y:Y.name)||[],pinned:!1}}catch(X){throw this.logger.error(`\u274C Failed to create issue: ${Q.title}: ${x(X)}`),X}}async getIssues(Q="open"){let X=`${Q}`,Y=this.cache.issues.get(X);if(Y&&this.isCacheValid(Y.timestamp))return this.logger.info(`\uD83D\uDCE6 Using cached issues (state: ${Q}, ${Y.data.length} issues)`),Y.data;try{let J=[];for(let _=1;_<=20;_++){let V=await this.apiRequestWithRetry(`GET /repos/${this.owner}/${this.repo}/issues?state=${Q}&sort=updated&direction=desc&per_page=100&page=${_}`);if(!Array.isArray(V)||V.length===0)break;if(J.push(...V),V.length<100)break}let G=J.filter((_)=>!_.pull_request).map((_)=>({number:_.number,title:_.title,body:_.body||"",state:_.state,url:_.html_url,createdAt:new Date(_.created_at),updatedAt:new Date(_.updated_at),closedAt:_.closed_at?new Date(_.closed_at):void 0,author:_.user.login,assignees:_.assignees?.map((V)=>V.login)||[],labels:_.labels?.map((V)=>typeof V==="string"?V:V.name)||[],pinned:!1}));return this.cache.issues.set(X,{data:G,timestamp:Date.now()}),this.logger.info(`\u2705 Fetched and cached ${G.length} issues (state: ${Q})`),G}catch(Z){throw this.logger.error("\u274C Failed to get issues:",Z),Z}}async updateIssue(Q,X){this.cache.issues.clear();try{let Y={};if(X.title!==void 0)Y.title=X.title;if(X.body!==void 0)Y.body=X.body;if(X.assignees!==void 0)Y.assignees=X.assignees;if(X.labels!==void 0)Y.labels=X.labels;if(X.milestone!==void 0)Y.milestone=X.milestone;let Z=await this.apiRequestWithRetry(`PATCH /repos/${this.owner}/${this.repo}/issues/${Q}`,Y);return this.logger.info(`\u2705 Updated issue #${Q}: ${Z.title}`),{number:Z.number,title:Z.title,body:Z.body,state:Z.state,url:Z.html_url,createdAt:new Date(Z.created_at),updatedAt:new Date(Z.updated_at),closedAt:Z.closed_at?new Date(Z.closed_at):void 0,author:Z.user.login,assignees:Z.assignees?.map(($)=>$.login)||[],labels:Z.labels?.map(($)=>typeof $==="string"?$:$.name)||[],pinned:!1}}catch(Y){throw this.logger.error(`\u274C Failed to update issue #${Q}: ${x(Y)}`),Y}}async closeIssue(Q){this.cache.issues.clear();try{await this.apiRequestWithRetry(`PATCH /repos/${this.owner}/${this.repo}/issues/${Q}`,{state:"closed"}),this.logger.info(`\u2705 Closed issue #${Q}`)}catch(X){throw this.logger.error(`\u274C Failed to close issue #${Q}: ${x(X)}`),X}}async pinIssue(Q){return await this.setIssuePinned(Q,!0)}async unpinIssue(Q){return await this.setIssuePinned(Q,!1)}async setIssuePinned(Q,X){let Y=X?"pin":"unpin";try{let Z=await this.apiRequest(`GET /repos/${this.owner}/${this.repo}/issues/${Q}`),$=X?"mutation($issueId: ID!) { pinIssue(input: { issueId: $issueId }) { issue { number } } }":"mutation($issueId: ID!) { unpinIssue(input: { issueId: $issueId }) { issue { number } } }",J=await this.graphqlRequest($,{issueId:Z.node_id});if(J.errors?.length){let G=J.errors.map((_)=>_.message).join("; ");return this.logger.info(`\u26A0\uFE0F Failed to ${Y} issue #${Q}: ${G}`),!1}return this.logger.info(`\uD83D\uDCCC ${X?"Pinned":"Unpinned"} issue #${Q}`),!0}catch(Z){return this.logger.info(`\u26A0\uFE0F Failed to ${Y} issue #${Q}: ${x(Z)}`),!1}}}
38
- export{h as Jc,E as Kc,l as Lc,b as Mc};
38
+ export{h as Lc,E as Mc,l as Nc,b as Oc};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ih as V}from"./chunk-wkjv03yr.js";import{Nh as P}from"./chunk-kqwdg3nw.js";import{Qh as M,Th as Q}from"./chunk-56t2za4k.js";function X(z){if(z==="running")return"in_progress";if(z==="success"||z==="failed"||z==="canceled"||z==="skipped"||z==="manual")return"completed";return"queued"}function Y(z){switch(z){case"success":return"success";case"failed":return"failure";case"canceled":return"cancelled";case"skipped":case"manual":return"skipped";default:return null}}class Z{token;apiUrl;logger;projectId;constructor(z,A,F,G,H){this.token=z;this.apiUrl=(G??"https://gitlab.com/api/v4").replace(/\/+$/,""),this.logger=H??Q(),this.projectId=encodeURIComponent(`${A}/${F}`)}capabilities(){return{pinIssues:!1,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!0,nativeAutoMerge:!0,commentReactions:!0,ciLogs:!0,ciRuns:!0,reviewThreads:!0,teamReviewers:!1,draftPullRequests:!0,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!0,labels:!0}}async request(z,A,F,G={}){let H=await P(`${this.apiUrl}${A}`,{method:z,headers:{"PRIVATE-TOKEN":this.token,Accept:G.raw?"text/plain":"application/json","User-Agent":"buddy",...F?{"Content-Type":"application/json"}:{}},...F?{body:JSON.stringify(F)}:{}});if(!H.ok){let K=await H.text().catch(()=>"");throw Error(`GitLab ${z} ${A} failed: ${H.status} ${K.slice(0,200)}`)}let J=await H.text();if(G.raw)return J;return J.trim()?JSON.parse(J):void 0}async optional(z,A,F={}){try{return await this.request(z,A,void 0,F)}catch(G){if(String(G).includes("404"))return null;throw G}}async branchExists(z){return await this.optional("GET",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)!==null}async createBranch(z,A){await this.request("POST",`/projects/${this.projectId}/repository/branches`,{branch:z,ref:A})}async deleteBranch(z){await this.request("DELETE",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)}async commitChanges(z,A,F,G="main"){if(F.length===0)return;if(await this.branchExists(z))await this.deleteBranch(z);await this.createBranch(z,G);let J=await Promise.all(F.map(async(K)=>{if(K.type==="delete")return{action:"delete",file_path:K.path};return{action:await this.getFileContent(K.path,G)!==null?"update":"create",file_path:K.path,content:K.content}}));await this.request("POST",`/projects/${this.projectId}/repository/commits`,{branch:z,commit_message:A,actions:J})}async getFileContent(z,A){let F=await this.optional("GET",`/projects/${this.projectId}/repository/files/${encodeURIComponent(z)}?ref=${encodeURIComponent(A)}`);if(!F?.content)return null;return F.encoding==="base64"?Buffer.from(F.content,"base64").toString("utf-8"):F.content}async createPullRequest(z){let A=await this.request("POST",`/projects/${this.projectId}/merge_requests`,{source_branch:z.head,target_branch:z.base,title:z.draft?`Draft: ${z.title}`:z.title,description:z.body,...z.labels?.length?{labels:z.labels.join(",")}:{},remove_source_branch:!0});return await this.assignPeople(A.iid,z),this.toPullRequest(A)}async assignPeople(z,A){let F=async(J=[])=>{return(await Promise.all(J.map(async(O)=>{return(await this.optional("GET",`/users?username=${encodeURIComponent(O)}`))?.[0]?.id??null}))).filter((O)=>O!==null)},[G,H]=await Promise.all([F(A.reviewers),F(A.assignees)]);if(G.length===0&&H.length===0)return;try{await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...G.length?{reviewer_ids:G}:{},...H.length?{assignee_ids:H}:{}})}catch(J){this.logger.warn(`\u26A0\uFE0F Could not assign reviewers on !${z}: ${M(J)}`)}}async getPullRequests(z="open"){let A=z==="all"?"state=all":z==="open"?"state=opened":"state=all",G=(await this.request("GET",`/projects/${this.projectId}/merge_requests?${A}&per_page=100`)).map((H)=>this.toPullRequest(H));return z==="closed"?G.filter((H)=>H.state!=="open"):G}async updatePullRequest(z,A){let F=await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...A.title!==void 0?{title:A.draft?`Draft: ${A.title}`:A.title}:{},...A.body!==void 0?{description:A.body}:{},...A.base!==void 0?{target_branch:A.base}:{},...A.labels!==void 0?{labels:A.labels.join(",")}:{}});return this.toPullRequest(F)}async closePullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"close"})}async reopenPullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"reopen"})}async mergePullRequest(z,A="squash"){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/merge`,{squash:A==="squash",should_remove_source_branch:!0})}async getPullRequestDiff(z){return((await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}/changes`)).changes??[]).map((F)=>[`diff --git a/${F.old_path} b/${F.new_path}`,`--- a/${F.old_path}`,`+++ b/${F.new_path}`,F.diff.replace(/\n$/,"")].join(`
2
+ import{Nh as V}from"./chunk-rad9rc2j.js";import{Sh as P}from"./chunk-kfn6xbc6.js";import{Vh as M,Yh as Q}from"./chunk-91gpxfta.js";function X(z){if(z==="running")return"in_progress";if(z==="success"||z==="failed"||z==="canceled"||z==="skipped"||z==="manual")return"completed";return"queued"}function Y(z){switch(z){case"success":return"success";case"failed":return"failure";case"canceled":return"cancelled";case"skipped":case"manual":return"skipped";default:return null}}class Z{token;apiUrl;logger;projectId;constructor(z,A,F,G,H){this.token=z;this.apiUrl=(G??"https://gitlab.com/api/v4").replace(/\/+$/,""),this.logger=H??Q(),this.projectId=encodeURIComponent(`${A}/${F}`)}capabilities(){return{pinIssues:!1,checkRuns:!0,inlineReviewComments:!0,reviewSuggestions:!0,nativeAutoMerge:!0,commentReactions:!0,ciLogs:!0,ciRuns:!0,reviewThreads:!0,teamReviewers:!1,draftPullRequests:!0,permissionLookup:!0,branchHousekeeping:!0,reopenPullRequests:!0,labels:!0}}async request(z,A,F,G={}){let H=await P(`${this.apiUrl}${A}`,{method:z,headers:{"PRIVATE-TOKEN":this.token,Accept:G.raw?"text/plain":"application/json","User-Agent":"buddy",...F?{"Content-Type":"application/json"}:{}},...F?{body:JSON.stringify(F)}:{}});if(!H.ok){let K=await H.text().catch(()=>"");throw Error(`GitLab ${z} ${A} failed: ${H.status} ${K.slice(0,200)}`)}let J=await H.text();if(G.raw)return J;return J.trim()?JSON.parse(J):void 0}async optional(z,A,F={}){try{return await this.request(z,A,void 0,F)}catch(G){if(String(G).includes("404"))return null;throw G}}async branchExists(z){return await this.optional("GET",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)!==null}async createBranch(z,A){await this.request("POST",`/projects/${this.projectId}/repository/branches`,{branch:z,ref:A})}async deleteBranch(z){await this.request("DELETE",`/projects/${this.projectId}/repository/branches/${encodeURIComponent(z)}`)}async commitChanges(z,A,F,G="main"){if(F.length===0)return;if(await this.branchExists(z))await this.deleteBranch(z);await this.createBranch(z,G);let J=await Promise.all(F.map(async(K)=>{if(K.type==="delete")return{action:"delete",file_path:K.path};return{action:await this.getFileContent(K.path,G)!==null?"update":"create",file_path:K.path,content:K.content}}));await this.request("POST",`/projects/${this.projectId}/repository/commits`,{branch:z,commit_message:A,actions:J})}async getFileContent(z,A){let F=await this.optional("GET",`/projects/${this.projectId}/repository/files/${encodeURIComponent(z)}?ref=${encodeURIComponent(A)}`);if(!F?.content)return null;return F.encoding==="base64"?Buffer.from(F.content,"base64").toString("utf-8"):F.content}async createPullRequest(z){let A=await this.request("POST",`/projects/${this.projectId}/merge_requests`,{source_branch:z.head,target_branch:z.base,title:z.draft?`Draft: ${z.title}`:z.title,description:z.body,...z.labels?.length?{labels:z.labels.join(",")}:{},remove_source_branch:!0});return await this.assignPeople(A.iid,z),this.toPullRequest(A)}async assignPeople(z,A){let F=async(J=[])=>{return(await Promise.all(J.map(async(O)=>{return(await this.optional("GET",`/users?username=${encodeURIComponent(O)}`))?.[0]?.id??null}))).filter((O)=>O!==null)},[G,H]=await Promise.all([F(A.reviewers),F(A.assignees)]);if(G.length===0&&H.length===0)return;try{await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...G.length?{reviewer_ids:G}:{},...H.length?{assignee_ids:H}:{}})}catch(J){this.logger.warn(`\u26A0\uFE0F Could not assign reviewers on !${z}: ${M(J)}`)}}async getPullRequests(z="open"){let A=z==="all"?"state=all":z==="open"?"state=opened":"state=all",G=(await this.request("GET",`/projects/${this.projectId}/merge_requests?${A}&per_page=100`)).map((H)=>this.toPullRequest(H));return z==="closed"?G.filter((H)=>H.state!=="open"):G}async updatePullRequest(z,A){let F=await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{...A.title!==void 0?{title:A.draft?`Draft: ${A.title}`:A.title}:{},...A.body!==void 0?{description:A.body}:{},...A.base!==void 0?{target_branch:A.base}:{},...A.labels!==void 0?{labels:A.labels.join(",")}:{}});return this.toPullRequest(F)}async closePullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"close"})}async reopenPullRequest(z){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}`,{state_event:"reopen"})}async mergePullRequest(z,A="squash"){await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/merge`,{squash:A==="squash",should_remove_source_branch:!0})}async getPullRequestDiff(z){return((await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}/changes`)).changes??[]).map((F)=>[`diff --git a/${F.old_path} b/${F.new_path}`,`--- a/${F.old_path}`,`+++ b/${F.new_path}`,F.diff.replace(/\n$/,"")].join(`
3
3
  `)).join(`
4
4
  `)}async getPullRequestHeadSha(z){return(await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}`)).sha??""}async createComment(z,A){try{await this.request("POST",`/projects/${this.projectId}/merge_requests/${z}/notes`,{body:A})}catch(F){if(!String(F).includes("404"))throw F;await this.request("POST",`/projects/${this.projectId}/issues/${z}/notes`,{body:A})}}async createIssue(z){let A=await this.request("POST",`/projects/${this.projectId}/issues`,{title:z.title,description:z.body,...z.labels?.length?{labels:z.labels.join(",")}:{}});return this.toIssue(A)}async getIssues(z="open"){let A=z==="all"?"state=all":`state=${z==="open"?"opened":"closed"}`;return(await this.request("GET",`/projects/${this.projectId}/issues?${A}&per_page=100`)).map((G)=>this.toIssue(G))}async updateIssue(z,A){let F=await this.request("PUT",`/projects/${this.projectId}/issues/${z}`,{...A.title!==void 0?{title:A.title}:{},...A.body!==void 0?{description:A.body}:{},...A.labels!==void 0?{labels:A.labels.join(",")}:{}});return this.toIssue(F)}async closeIssue(z){await this.request("PUT",`/projects/${this.projectId}/issues/${z}`,{state_event:"close"})}async unpinIssue(z){return!1}async enableAutoMerge(z,A="squash"){try{return await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/merge`,{merge_when_pipeline_succeeds:!0,squash:A==="squash",should_remove_source_branch:!0}),!0}catch(F){return this.logger.debug(`Could not queue !${z} for auto-merge: ${M(F)}`),!1}}async getPullRequestChecksState(z){let F=(await this.optional("GET",`/projects/${this.projectId}/merge_requests/${z}/pipelines`))?.[0]?.status;if(!F)return"none";if(F==="success")return"success";if(["failed","canceled"].includes(F))return"failure";if(["running","pending","created","waiting_for_resource","preparing","scheduled"].includes(F))return"pending";return"none"}async createReview(z,A){if(await this.request("POST",`/projects/${this.projectId}/merge_requests/${z}/notes`,{body:A.body}),!A.comments?.length)return{posted:!0,inlineComments:0};let G=(await this.optional("GET",`/projects/${this.projectId}/merge_requests/${z}/versions`))?.[0];if(!G)return this.logger.warn("\u26A0\uFE0F Could not resolve diff positions; inline comments were not posted"),{posted:!0,inlineComments:0};let H=0;for(let J of A.comments)try{await this.request("POST",`/projects/${this.projectId}/merge_requests/${z}/discussions`,{body:J.body,position:{position_type:"text",base_sha:G.base_commit_sha,start_sha:G.start_commit_sha,head_sha:G.head_commit_sha,new_path:J.path,old_path:J.path,...J.side==="RIGHT"?{new_line:J.line}:{old_line:J.line}}}),H++}catch(K){this.logger.debug(`Could not place a comment on ${J.path}:${J.line}: ${M(K)}`)}return{posted:!0,inlineComments:H}}async createCheckRun(z,A,F){try{await this.request("POST",`/projects/${this.projectId}/statuses/${A}`,{state:F.conclusion==="failure"?"failed":"success",name:z,description:F.title.slice(0,140)})}catch(G){this.logger.warn(`\u26A0\uFE0F Could not report status ${z}: ${M(G)}`)}}async reactToComment(z,A){let F={eyes:"eyes","+1":"thumbsup","-1":"thumbsdown",rocket:"rocket",confused:"confused"};try{await this.request("POST",`/projects/${this.projectId}/notes/${z}/award_emoji`,{name:F[A]??"eyes"})}catch(G){this.logger.debug(`Could not react to note ${z}: ${M(G)}`)}}async hasWriteAccess(z){return(await this.optional("GET",`/projects/${this.projectId}/members/all?query=${encodeURIComponent(z)}`)??[]).some((F)=>F.username===z&&F.access_level>=30)}async getWorkflowRunLogs(z){return this.optional("GET",`/projects/${this.projectId}/jobs/${z}/trace`,{raw:!0}).catch((A)=>{return this.logger.debug(`Could not read the trace for job ${z}: ${M(A)}`),null})}async listWorkflowRuns(z,A={}){let F=A.limit??20;try{return(await this.request("GET",`/projects/${this.projectId}/jobs?per_page=${Math.min(F*5,100)}`)??[]).filter((H)=>H.ref===z).map((H)=>({id:H.id,name:H.name??"",headSha:H.commit?.id??"",headBranch:H.ref??z,status:X(H.status),conclusion:Y(H.status),createdAt:new Date(H.created_at??new Date().toISOString())})).filter((H)=>!A.status||H.status===A.status).slice(0,F)}catch(G){return this.logger.debug(`Could not list CI jobs for ${z}: ${M(G)}`),[]}}async rerunWorkflowRun(z){try{return await this.request("POST",`/projects/${this.projectId}/jobs/${z}/retry`),!0}catch(A){return this.logger.warn(`Could not retry job ${z}: ${M(A)}`),!1}}async listReviewThreads(z){try{return(await this.request("GET",`/projects/${this.projectId}/merge_requests/${z}/discussions?per_page=100`)??[]).filter((F)=>(F.notes??[]).some((G)=>G.resolvable)).map((F)=>({id:F.id,isResolved:(F.notes??[]).every((G)=>!G.resolvable||G.resolved),...F.notes?.[0]?.position?.new_path?{path:F.notes[0].position.new_path}:{},authorLogins:(F.notes??[]).map((G)=>G.author?.username).filter((G)=>typeof G==="string")}))}catch(A){return this.logger.debug(`Could not read discussions on !${z}: ${M(A)}`),[]}}async resolveReviewThread(z,A){try{return await this.request("PUT",`/projects/${this.projectId}/merge_requests/${z}/discussions/${encodeURIComponent(A)}`,{resolved:!0}),!0}catch(F){return this.logger.warn(`Could not resolve discussion ${A}: ${M(F)}`),!1}}async getBuddyBranches(){return(await this.request("GET",`/projects/${this.projectId}/repository/branches?search=buddy&per_page=100`)).filter((A)=>V(A.name)).map((A)=>({name:A.name,sha:A.commit?.id??"",lastCommitDate:A.commit?.committed_date?new Date(A.commit.committed_date):new Date(0)}))}async getOrphanedBuddyBranches(){let[z,A]=await Promise.all([this.getBuddyBranches(),this.getPullRequests("open")]),F=new Set(A.map((G)=>G.head));return z.filter((G)=>!F.has(G.name))}async cleanupStaleBranches(z=7,A=!1){let F=new Date(Date.now()-z*24*60*60*1000),G=(await this.getOrphanedBuddyBranches()).filter((K)=>K.lastCommitDate<F);if(A)return{deleted:G.map((K)=>K.name),failed:[]};let H=[],J=[];for(let K of G)try{await this.deleteBranch(K.name),H.push(K.name)}catch{J.push(K.name)}return{deleted:H,failed:J}}toPullRequest(z){let A=Boolean(z.draft??z.work_in_progress)||/^(?:draft|wip):/i.test(z.title);return{number:z.iid,title:z.title.replace(/^(?:draft|wip):\s*/i,""),body:z.description??"",head:z.source_branch,base:z.target_branch,state:z.state==="merged"?"merged":z.state==="opened"?"open":"closed",url:z.web_url,createdAt:new Date(z.created_at),updatedAt:new Date(z.updated_at),...z.merged_at?{mergedAt:new Date(z.merged_at)}:{},author:z.author?.username??"",reviewers:(z.reviewers??[]).map((F)=>F.username),assignees:(z.assignees??[]).map((F)=>F.username),labels:z.labels??[],draft:A}}toIssue(z){return{number:z.iid,title:z.title,body:z.description??"",state:z.state==="closed"?"closed":"open",url:z.web_url,createdAt:new Date(z.created_at),updatedAt:new Date(z.updated_at),...z.closed_at?{closedAt:new Date(z.closed_at)}:{},author:z.author?.username??"",assignees:(z.assignees??[]).map((A)=>A.username),labels:z.labels??[]}}}
5
- export{Z as Gh};
5
+ export{Z as Lh};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"./chunk-eaz23nsf.js";import{spawn as E}from"child_process";async function y(z,A){return new Promise((k,x)=>{let q=E("git",z,{stdio:"pipe",cwd:A}),C="",D="";q.stdout?.on("data",(B)=>C+=B.toString()),q.stderr?.on("data",(B)=>D+=B.toString()),q.on("close",(B)=>{if(B===0)k(C);else x(Error(D||`git exited with code ${B}`))}),q.on("error",x)})}async function H(z,A,k){for(let x of z){let q=x.path.replace(/^\.\//,"").replace(/^\/+/,"");try{if(await y(["show",`${A}:${q}`],k)!==x.content)return!0;continue}catch{}try{if(await y(["show",`origin/${A}:${q}`],k)!==x.content)return!0;continue}catch{return!0}}return!1}async function I(z,A,k){if(z.length===0)return!1;if(await y(["add","--",...z],k),!(await y(["diff","--cached","--name-only"],k)).trim())return!1;await y(["commit","-m",A],k);let q=(await y(["rev-parse","--abbrev-ref","HEAD"],k)).trim();return await y(["push","origin",`HEAD:${q}`],k),!0}export{H as hasBranchDifferences,I as commitAndPush};
2
+ import"./chunk-xmqv24zr.js";import{spawn as E}from"child_process";async function y(z,A){return new Promise((k,x)=>{let q=E("git",z,{stdio:"pipe",cwd:A}),C="",D="";q.stdout?.on("data",(B)=>C+=B.toString()),q.stderr?.on("data",(B)=>D+=B.toString()),q.on("close",(B)=>{if(B===0)k(C);else x(Error(D||`git exited with code ${B}`))}),q.on("error",x)})}async function H(z,A,k){for(let x of z){let q=x.path.replace(/^\.\//,"").replace(/^\/+/,"");try{if(await y(["show",`${A}:${q}`],k)!==x.content)return!0;continue}catch{}try{if(await y(["show",`origin/${A}:${q}`],k)!==x.content)return!0;continue}catch{return!0}}return!1}async function I(z,A,k){if(z.length===0)return!1;if(await y(["add","--",...z],k),!(await y(["diff","--cached","--name-only"],k)).trim())return!1;await y(["commit","-m",A],k);let q=(await y(["rev-parse","--abbrev-ref","HEAD"],k)).trim();return await y(["push","origin",`HEAD:${q}`],k),!0}export{H as hasBranchDifferences,I as commitAndPush};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import{Rf as Z}from"./chunk-rb6gzts6.js";import{Th as Y}from"./chunk-56t2za4k.js";import W from"process";var $=[["bun","test"],["npm","test","--silent"]];async function E(G,H){let I=H?[H]:await L(G);for(let z of I){let j=Bun.spawn(z,{cwd:G,stdout:"pipe",stderr:"pipe",env:{PATH:W.env.PATH??"",HOME:W.env.HOME??"",CI:"1"}}),[J,K,Q]=await Promise.all([new Response(j.stdout).text(),new Response(j.stderr).text(),j.exited]);return{ran:!0,passed:Q===0,output:`${J}
2
+ import{Uf as Z}from"./chunk-fanj4t6c.js";import{Yh as Y}from"./chunk-91gpxfta.js";import W from"process";var $=[["bun","test"],["npm","test","--silent"]];async function E(G,H){let I=H?[H]:await L(G);for(let z of I){let j=Bun.spawn(z,{cwd:G,stdout:"pipe",stderr:"pipe",env:{PATH:W.env.PATH??"",HOME:W.env.HOME??"",CI:"1"}}),[J,K,Q]=await Promise.all([new Response(j.stdout).text(),new Response(j.stderr).text(),j.exited]);return{ran:!0,passed:Q===0,output:`${J}
3
3
  ${K}`.trim().slice(-4000)}}return{ran:!1,passed:!1,output:""}}async function L(G){let H=Bun.file(`${G}/package.json`);if(!await H.exists())return[];try{return(await H.json()).scripts?.test?$:[]}catch{return[]}}function O(G,H){return`${G.head}/buddy-${H}`}async function N(G){let H=G.logger??Y(),{provider:I,pullRequest:z,touch:j}=G;H.info(`\u2728 Running finishing touch '${j.name}' on PR #${z.number}`);let J=await Z(G.ai,{mode:j.mode,task:j.buildTask({summary:z.title,files:G.files??[]}),context:{workspace:G.workspace,baseBranch:z.base,branch:z.head},logger:H}),K=await _(G.workspace);if(K.length===0)return{mode:"none",changedFiles:[],verified:!1,comment:J.stopReason==="completed"?`**${j.description}** \u2014 nothing to change.`:`**${j.description}** \u2014 stopped before finishing (${J.stopReason}), and left nothing behind.`};let Q=J.stopReason==="completed",P=await E(G.workspace,G.testCommand);if(!(Q&&j.defaultOutput!=="suggestion"&&(P.passed||!P.ran)))return{mode:"suggestions",changedFiles:K,verified:P.passed,comment:X(j,K,P,J.stopReason)};let V=O(z,j.name);try{await I.createBranch(V,z.head),await I.commitChanges(V,`chore: ${j.description.toLowerCase()} for #${z.number}`,await x(G.workspace,K),z.head);let U=await I.createPullRequest({title:`${j.description} for #${z.number}`,body:y(j,z,K,P),head:V,base:z.head,labels:["buddy","finishing-touch"]});return{mode:"stacked-pr",pullRequest:U,changedFiles:K,verified:P.passed,comment:`**${j.description}** \u2014 opened [#${U.number}](${U.url}) targeting this branch.`+(P.ran?"":" No test script was found, so this is unverified.")}}catch(U){return H.warn(`\u26A0\uFE0F Could not open a stacked pull request: ${U}`),{mode:"suggestions",changedFiles:K,verified:P.passed,comment:X(j,K,P,J.stopReason)}}}async function _(G){let H=Bun.spawn(["git","status","--porcelain"],{cwd:G,stdout:"pipe",stderr:"ignore"}),[I,z]=await Promise.all([new Response(H.stdout).text(),H.exited]);if(z!==0)return[];let j=[];for(let J of I.split(`
4
4
  `)){if(!J.trim())continue;let K=J.slice(0,2),Q=J.slice(3).trim();if(K.includes("D"))continue;j.push(Q.includes(" -> ")?Q.split(" -> ")[1]:Q)}return j}async function x(G,H){let I=[];for(let z of H){let j=Bun.file(`${G}/${z}`);if(await j.exists())I.push({path:z,content:await j.text(),type:"update"})}return I}function y(G,H,I,z){return[`${G.description}, requested on #${H.number}.`,"",`This targets \`${H.head}\` rather than \`${H.base}\`, so merging it`,"adds these changes to that pull request.","",z.ran?z.passed?"\u2705 The repository's tests pass with these changes.":"\u26A0\uFE0F The repository's tests do **not** pass with these changes.":"\u2139\uFE0F No test script was found, so these changes are unverified.","","### Files changed","",...I.map((j)=>`- \`${j}\``)].join(`
5
5
  `)}function X(G,H,I,z){let j=[`**${G.description}**`,""];if(z&&z!=="completed")j.push(`The agent stopped before finishing (${z}), so what follows is`,"partial work rather than a complete change.","");if(I.ran&&!I.passed)j.push("The repository's tests do not pass with these changes, so no branch was","opened. Treat what follows as a starting point rather than a result.","");if(j.push("Files that would change:","",...H.map((J)=>`- \`${J}\``)),I.output)j.push("","<details><summary>Test output</summary>","","```",I.output,"```","","</details>");return j.join(`
6
6
  `)}
7
- export{$ as Ra,E as Sa,O as Ta,N as Ua,_ as Va};
7
+ export{$ as Ta,E as Ua,O as Va,N as Wa,_ as Xa};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var{semver:B}=globalThis.Bun;function G(j){return[...j].sort((q,k)=>B.order(k,q))}function D(j,q){let k=j.trim();if(!k||k==="*"||k==="latest")return!0;if(/^(?:workspace|file|link|git|github|npm):/i.test(k)||k.includes("/"))return!0;try{return B.satisfies(q,k)}catch{return!0}}function H(j){let q=G(j.available);if(q.length===0)return null;let k=q[0],z=q.find((A)=>j.declared.every((E)=>D(E.range,A)));if(!z)return null;let C=j.declared.filter((A)=>!D(A.range,k)).filter((A)=>A.by!==I);if(B.order(j.installed,z)<0)return{name:j.name,kind:"lockfile",installed:j.installed,reachable:z,latest:k,capping:C};if(C.length>0&&B.order(z,k)<0)return{name:j.name,kind:"capped",installed:j.installed,reachable:z,latest:k,capping:C};return null}var I="root";function L(j){let q=[];for(let k of j){let z=H(k);if(z)q.push(z)}return q.sort((k,z)=>{if(k.kind!==z.kind)return k.kind==="capped"?-1:1;return B.order(z.latest,k.latest)})}function M(j){let q=`${j.name} ${j.installed} is installed, ${j.reachable} is reachable`;if(j.kind==="lockfile")return`${q}. Nothing is capping it - the lockfile is behind.`;let k=j.capping.map((z)=>`${z.by} (${z.range})`).join(", ");return j.reachable===j.latest?`${q}, and ${j.latest} exists but is capped by ${k}.`:`${q}. ${j.latest} exists but is capped by ${k}.`}
3
- export{H as Mb,I as Nb,L as Ob,M as Pb};
3
+ export{H as Ob,I as Pb,L as Qb,M as Rb};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Lh as a}from"./chunk-6evq4y1q.js";import"./chunk-rad9rc2j.js";import"./chunk-kfn6xbc6.js";import"./chunk-91gpxfta.js";import"./chunk-xmqv24zr.js";export{a as GitLabProvider};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{uf as k,yf as b}from"./chunk-vna64r40.js";import{Af as C}from"./chunk-1pecmenc.js";import{Rf as x}from"./chunk-rb6gzts6.js";import{vg as v}from"./chunk-x9vpk4kk.js";import{Th as D}from"./chunk-56t2za4k.js";var T={type:"object",properties:{changes:{type:"array",items:{type:"object",properties:{description:{type:"string",description:"What upstream changed"},version:{type:"string",description:"Version the change landed in"},affectedFiles:{type:"array",items:{type:"string"}},action:{type:"string",description:"What must be done in this repository"},automatable:{type:"boolean",description:"Whether the fix is mechanical"}},required:["description","affectedFiles","action","automatable"],additionalProperties:!1}},codemod:{type:"object",properties:{command:{type:"string",description:"Command that applies the official codemod"},source:{type:"string",description:"Where the codemod is documented"}},required:["command","source"],additionalProperties:!1},confidence:{type:"string",enum:["high","medium","low"]},effort:{type:"integer",description:"1 (trivial) to 5 (demanding)"},risks:{type:"array",items:{type:"string"}}},required:["changes","confidence","effort","risks"],additionalProperties:!1},f=[/^(?:bunx|npx|pnpm dlx|yarn dlx)\s+[\w@/.-]+(?:\s+[\w@/.:=-]+)*$/];function y(J){let Y=J.trim();if(/[;&|`$><\n]/.test(Y))return!1;return f.some((Q)=>Q.test(Y))}function R(J){let Y=J.usage.slice(0,100).map((Q)=>`${Q.path}:${Q.line} (${Q.kind}) ${Q.text}`).join(`
2
+ import{Bf as b,xf as k}from"./chunk-qeg388qq.js";import{Df as C}from"./chunk-016ce171.js";import{Uf as x}from"./chunk-fanj4t6c.js";import{yg as v}from"./chunk-x496v9vb.js";import{Yh as D}from"./chunk-91gpxfta.js";var T={type:"object",properties:{changes:{type:"array",items:{type:"object",properties:{description:{type:"string",description:"What upstream changed"},version:{type:"string",description:"Version the change landed in"},affectedFiles:{type:"array",items:{type:"string"}},action:{type:"string",description:"What must be done in this repository"},automatable:{type:"boolean",description:"Whether the fix is mechanical"}},required:["description","affectedFiles","action","automatable"],additionalProperties:!1}},codemod:{type:"object",properties:{command:{type:"string",description:"Command that applies the official codemod"},source:{type:"string",description:"Where the codemod is documented"}},required:["command","source"],additionalProperties:!1},confidence:{type:"string",enum:["high","medium","low"]},effort:{type:"integer",description:"1 (trivial) to 5 (demanding)"},risks:{type:"array",items:{type:"string"}}},required:["changes","confidence","effort","risks"],additionalProperties:!1},f=[/^(?:bunx|npx|pnpm dlx|yarn dlx)\s+[\w@/.-]+(?:\s+[\w@/.:=-]+)*$/];function y(J){let Y=J.trim();if(/[;&|`$><\n]/.test(Y))return!1;return f.some((Q)=>Q.test(Y))}function R(J){let Y=J.usage.slice(0,100).map((Q)=>`${Q.path}:${Q.line} (${Q.kind}) ${Q.text}`).join(`
3
3
  `);return[`Analyse upgrading \`${J.packageName}\` from ${J.fromVersion} to ${J.toVersion}.`,"","Report only breaking changes that affect THIS repository, judged against the","usage sites below. A breaking change in a feature this repository does not use","is not worth reporting, and listing it makes the real ones harder to find.","","Mark a change automatable only when the fix is a mechanical edit you could write","exactly. Anything needing judgement is not automatable.","","If the package publishes an official codemod for this upgrade, report the command.","","Set confidence honestly: high when every change is understood and mechanical,","low when the notes are unclear or the change touches something subtle. A low","confidence plan is more useful than a wrong high confidence one.","","--- Release notes across the version span ---",J.releaseNotes||"(none available)","",`--- Usage in this repository (${J.usage.length} site(s)) ---`,Y||"(no direct usage found)"].join(`
4
4
  `)}function A(J,Y){let Q=J??{},Z=new Set(Y.knownFiles),K=(Array.isArray(Q.changes)?Q.changes:[]).filter(($)=>Boolean($&&typeof $.description==="string"&&typeof $.action==="string")).map(($)=>({description:$.description,...$.version?{version:$.version}:{},affectedFiles:(Array.isArray($.affectedFiles)?$.affectedFiles:[]).filter((j)=>Z.has(j)),action:$.action,automatable:$.automatable===!0})),H=Q.codemod&&y(Q.codemod.command)?Q.codemod:void 0;return{packageName:Y.packageName,fromVersion:Y.fromVersion,toVersion:Y.toVersion,changes:K,...H?{codemod:H}:{},confidence:h(Q.confidence,K),effort:m(Q.effort),risks:(Array.isArray(Q.risks)?Q.risks:[]).filter(($)=>typeof $==="string")}}function E(J,Y="high"){let Q={low:0,medium:1,high:2};return Q[J.confidence]<Q[Y]}function h(J,Y){let Q=J==="high"||J==="medium"||J==="low"?J:"low";if(Q==="high"&&Y.some((Z)=>!Z.automatable))return"medium";return Q}function m(J){let Y=Number(J);if(!Number.isFinite(Y))return 3;return Math.min(5,Math.max(1,Math.round(Y)))}import{resolve as g}from"path";var c=/\.(?:[cm]?[jt]sx?|vue|svelte)$/,u=/(?:^|\/)(?:[\w.-]*\.config\.[cm]?[jt]s|\.?[\w-]*rc(?:\.\w+)?|tsconfig\.json|vite\.config\.[cm]?[jt]s)$/;async function N(J,Y,Q){let Z=J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),K=`${Z}(?:/[^'"\`]*)?`,H=new RegExp(`(?:^|\\s)import\\s[^'"\`]*['"\`]${K}['"\`]|from\\s*['"\`]${K}['"\`]`),$=new RegExp(`require\\s*\\(\\s*['"\`]${K}['"\`]\\s*\\)`),j=new RegExp(`import\\s*\\(\\s*['"\`]${K}['"\`]\\s*\\)`),W=new RegExp(`(?:^|[^\\w@/.-])${Z}(?![\\w/.-])`),q=[];for(let X of Y){let B=c.test(X),_=u.test(X);if(!B&&!_)continue;let U;try{let z=Bun.file(g(Q,X));if(!await z.exists())continue;U=await z.text()}catch{continue}if(!U.includes(J))continue;for(let[z,G]of U.split(`
5
5
  `).entries()){let F=null;if(H.test(G)||j.test(G))F="import";else if($.test(G))F="require";else if(_&&W.test(G))F="config";if(F)q.push({path:X,line:z+1,text:G.trim().slice(0,200),kind:F})}}return q}function V(J){let Y=new Map;for(let Q of J)Y.set(Q.path,(Y.get(Q.path)??0)+1);return[...Y.entries()].map(([Q,Z])=>({path:Q,count:Z})).sort((Q,Z)=>Z.count-Q.count)}var d={high:"\uD83D\uDFE2 high",medium:"\uD83D\uDFE1 medium",low:"\uD83D\uDD34 low"};function L(J,Y,Q=[]){let Z=`## \uD83D\uDD27 Migration report
@@ -89,4 +89,4 @@ ${K.result.report}`);if(Q.length===0&&Y.length===0)return"";let Z=["## Major upg
89
89
  ---
90
90
 
91
91
  ${Y}${Z}`}
92
- export{T as df,y as ef,R as ff,A as gf,E as hf,N as if,V as jf,L as kf,S as lf,BJ as mf,w as nf,M as of,a as pf,_J as qf,GJ as rf};
92
+ export{T as gf,y as hf,R as if,A as jf,E as kf,N as lf,V as mf,L as nf,S as of,BJ as pf,w as qf,M as rf,a as sf,_J as tf,GJ as uf};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Th as O}from"./chunk-56t2za4k.js";import{Ij as A}from"./chunk-drn3hq53.js";import{il as x}from"./chunk-eaz23nsf.js";function T(z){let G=z.split("/").pop()||"";if(["deps.yaml","dependencies.yaml","pkgx.yaml",".deps.yaml"].includes(G))return!0;let j=G.replace(/\.(yaml|yml)$/,"");return["deps","dependencies","pkgx",".deps"].includes(j)}async function V(z,G){try{if(!T(z))return null;let J=[];try{let H=await A(z);if(H&&typeof H==="object"){if(H.allDependencies&&Array.isArray(H.allDependencies)){for(let K of H.allDependencies)if(K.name&&K.constraint)J.push({name:K.name,currentVersion:K.constraint,type:"dependencies",file:z})}}}catch(H){O().warn(`ts-pantry failed to parse ${z}, attempting fallback YAML parsing:`,H)}if(J.length===0)try{J=await B(G,z)}catch(H){O().warn(`Fallback YAML parsing failed for ${z}:`,H),J=[]}let j=z.split("/").pop()||"";return{path:z,type:j,content:G,dependencies:J}}catch(J){return O().warn(`Failed to parse dependency file ${z}:`,J),null}}async function B(z,G){let J=[],j=z.split(`
2
+ import{Yh as O}from"./chunk-91gpxfta.js";import{Nj as A}from"./chunk-nqgn0drz.js";import{nl as x}from"./chunk-xmqv24zr.js";function T(z){let G=z.split("/").pop()||"";if(["deps.yaml","dependencies.yaml","pkgx.yaml",".deps.yaml"].includes(G))return!0;let j=G.replace(/\.(yaml|yml)$/,"");return["deps","dependencies","pkgx",".deps"].includes(j)}async function V(z,G){try{if(!T(z))return null;let J=[];try{let H=await A(z);if(H&&typeof H==="object"){if(H.allDependencies&&Array.isArray(H.allDependencies)){for(let K of H.allDependencies)if(K.name&&K.constraint)J.push({name:K.name,currentVersion:K.constraint,type:"dependencies",file:z})}}}catch(H){O().warn(`ts-pantry failed to parse ${z}, attempting fallback YAML parsing:`,H)}if(J.length===0)try{J=await B(G,z)}catch(H){O().warn(`Fallback YAML parsing failed for ${z}:`,H),J=[]}let j=z.split("/").pop()||"";return{path:z,type:j,content:G,dependencies:J}}catch(J){return O().warn(`Failed to parse dependency file ${z}:`,J),null}}async function B(z,G){let J=[],j=z.split(`
3
3
  `),H=!1;for(let K of j){let Q=K.trim();if(Q==="dependencies:"){H=!0;continue}if(H){if(Q&&!K.startsWith(" ")&&!K.startsWith("\t")){H=!1;continue}let X=Q.match(/^([\w@/-]+):\s*(.+)$/);if(X){let[,Z,$]=X;J.push({name:Z.trim(),currentVersion:$.trim(),type:"dependencies",file:G})}}}return J}function b(z){try{return Bun.YAML.parse(z),!0}catch{return!1}}async function S(z,G,J){try{if(!T(z))return O().info(`\u26A0\uFE0F updateDependencyFile: ${z} is not a dependency file, returning original content`),G;if(G.trim().startsWith("{")&&G.includes('"require"'))return O().info(`\u26A0\uFE0F updateDependencyFile: Content appears to be JSON (composer.json), but file is ${z}`),O().info(`Content preview: ${G.substring(0,200)}`),G;let j=G;for(let H of J){let K=H.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),Q=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=new RegExp(`^([ \\t]*)("${Q}"|'${Q}'|${Q})([ \\t]*:[ \\t]*)(["']?)([^\\s#"']+)\\4([ \\t]*#[^\\r\\n]*)?`,"gm");j=j.replace(X,(Z,$,w,E,W,_,R)=>{if(["latest","*","main","master","develop","dev"].includes(_.toLowerCase().trim()))return O().info(`\u26A0\uFE0F Skipping update for ${K} - version "${_}" should be respected`),Z;if(U(_))return Z;let Y=_.match(/^(\D*)/)?.[1]??"",q=/^[\^~>=<]/.test(H.newVersion)?H.newVersion:`${Y}${H.newVersion}`;return`${$}${w}${E}${W}${q}${W}${R??""}`})}if(j!==G&&b(G)&&!b(j))return O().warn(`\u26A0\uFE0F Skipping updates for ${z}: the rewrite no longer parses as YAML, so the file is left unchanged`),G;return j}catch(j){return O().warn(`Failed to update dependency file ${z}:`,j),G}}async function v(z){let G=[],J=new Map;for(let j of z)if(T(j.file)){if(!J.has(j.file))J.set(j.file,[]);J.get(j.file).push(j)}for(let[j,H]of J)try{let K=await import("fs");if(K.existsSync(j)){let Q=K.readFileSync(j,"utf-8"),X=await S(j,Q,H);if(X!==Q)G.push({path:j,content:X,type:"update"}),O().info(`\u2705 Generated update for ${j} with ${H.length} package changes`);else O().info(`\u2139\uFE0F No changes needed for ${j} - versions already up to date`)}else O().warn(`\u26A0\uFE0F Dependency file ${j} does not exist`)}catch(K){O().warn(`Failed to generate updates for dependency file ${j}:`,K)}return G}function U(z){return/^(?:workspace|file|link|portal|git|github|gitlab|bitbucket|https?|git\+[a-z]+):/i.test(z.trim())}
4
- export{T as Ag,V as Bg,S as Cg,v as Dg,U as Eg};
4
+ export{T as Dg,V as Eg,S as Fg,v as Gg,U as Hg};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{rd as a}from"./chunk-s8apaa3h.js";import"./chunk-n5mvfhd0.js";import"./chunk-zbk3g5vf.js";import"./chunk-yknz94wd.js";import"./chunk-ep7hn1za.js";import"./chunk-yzyqkwsc.js";import"./chunk-m7v1dba6.js";import"./chunk-n7hbbha7.js";import"./chunk-9rvapdmv.js";import"./chunk-q31cbz9d.js";import"./chunk-g0ttytab.js";import"./chunk-dmqptf7k.js";import"./chunk-dz2e81v7.js";import"./chunk-we0x722x.js";import"./chunk-7523xqb9.js";import"./chunk-qeg388qq.js";import"./chunk-016ce171.js";import"./chunk-fanj4t6c.js";import"./chunk-7h8qjayv.js";import"./chunk-zqrgvftj.js";import"./chunk-me7y4rd3.js";import"./chunk-7khgke9n.js";import"./chunk-038mdwdf.js";import"./chunk-x496v9vb.js";import"./chunk-75rj89c2.js";import"./chunk-0cqhy9qh.js";import"./chunk-gt3m1eqn.js";import"./chunk-rad9rc2j.js";import"./chunk-kfn6xbc6.js";import"./chunk-91gpxfta.js";import"./chunk-nqgn0drz.js";import"./chunk-xmqv24zr.js";export{a as Buddy};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var{Glob:F}=globalThis.Bun;function K(k){if(!k||k.length===0)return{matches:()=>!0};let q=k.map((j)=>{let B=j.startsWith("!"),C=B?j.slice(1):j;return{negated:B,glob:new F(C),pattern:C}}),D=q.some((j)=>!j.negated);return{matches(j){let B=j.replace(/^\.\//,""),C=!D;for(let E of q){if(!H(E.glob,B))continue;C=!E.negated}return C}}}function L(k,q){if(!q?.length)return[];let D=k.replace(/^\.\//,"");return q.filter((j)=>H(new F(j.path),D)).sort((j,B)=>j.path.length-B.path.length).map((j)=>j.instructions)}function H(k,q){try{return k.match(q)}catch{return!1}}
3
- export{K as Sf,L as Tf};
3
+ export{K as Vf,L as Wf};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  import{posix as G}from"path";class v extends Error{constructor(q){super(q);this.name="FileChangeValidationError"}}function H(q){let j=G.normalize(q.replaceAll("\\","/").replace(/^\.\/+/,""));if(!j||j==="."||j===".."||j.startsWith("../")||G.isAbsolute(j))throw new v(`Refusing unsafe repository path: ${JSON.stringify(q)}`);return j}async function J(q,j){for(let B of q){let D=H(B.path);if(B.type==="update"&&!await j(D))throw new v(`Refusing to create missing update target: ${D}. Use change type "create" for intentional new files.`)}}
3
- export{v as _f,H as $f,J as ag};
3
+ export{v as bg,H as cg,J as dg};