@buddysh/buddy 0.11.6 → 0.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/bin/cli.js +19 -19
  3. package/dist/{chunk-xj99g66b.js → chunk-03j2dx5h.js} +2 -2
  4. package/dist/chunk-06k6abjj.js +2 -0
  5. package/dist/{chunk-c64qrkpz.js → chunk-0ewzxzt3.js} +2 -2
  6. package/dist/{chunk-90x7e4ra.js → chunk-19n3wnxq.js} +5 -5
  7. package/dist/{chunk-2r5s586j.js → chunk-1n42ghef.js} +2 -2
  8. package/dist/chunk-1q6s6a5e.js +2 -0
  9. package/dist/{chunk-wsxy4w86.js → chunk-1szfwcst.js} +1 -1
  10. package/dist/{chunk-3nygvd78.js → chunk-1z4nhstx.js} +2 -2
  11. package/dist/{chunk-3f34dgnn.js → chunk-1z9a3hpe.js} +1 -1
  12. package/dist/chunk-23c6tfbw.js +2 -0
  13. package/dist/{chunk-rfvn4j6n.js → chunk-2egzc1fp.js} +1 -1
  14. package/dist/chunk-2ppt1rrx.js +2 -0
  15. package/dist/chunk-2pv5zwbm.js +38 -0
  16. package/dist/{chunk-kzgyhhtz.js → chunk-305184z3.js} +1 -1
  17. package/dist/{chunk-ge2r1zmq.js → chunk-39ne6m3w.js} +1 -1
  18. package/dist/{chunk-e6wny1pp.js → chunk-3d3rwmmj.js} +1 -1
  19. package/dist/{chunk-88k998tw.js → chunk-3d5pjrz7.js} +2 -2
  20. package/dist/chunk-3jw9d546.js +2 -0
  21. package/dist/{chunk-j8era2yj.js → chunk-3wy8fypy.js} +2 -2
  22. package/dist/{chunk-86kymmen.js → chunk-3z759ya5.js} +1 -1
  23. package/dist/{chunk-d84k4mek.js → chunk-3zk2ye6r.js} +1 -1
  24. package/dist/{chunk-zc7g037n.js → chunk-4b0p7kgk.js} +1 -1
  25. package/dist/chunk-4d13qb9f.js +2 -0
  26. package/dist/{chunk-bxdbf2kj.js → chunk-4gx2f1k6.js} +1 -1
  27. package/dist/{chunk-43p5vzvb.js → chunk-4mwgk0jh.js} +2 -2
  28. package/dist/{chunk-te6etc5c.js → chunk-4rvgatmm.js} +1 -1
  29. package/dist/{chunk-jhfkzveb.js → chunk-4wh0wryv.js} +2 -2
  30. package/dist/{chunk-nj38e2km.js → chunk-4ycesykg.js} +1 -1
  31. package/dist/chunk-52jcty4n.js +2 -0
  32. package/dist/{chunk-tvrz1xp5.js → chunk-55znd3yn.js} +1 -1
  33. package/dist/chunk-5ct11b1j.js +2 -0
  34. package/dist/{chunk-rp3ytb19.js → chunk-5gybfx14.js} +1 -1
  35. package/dist/chunk-5zs6jrpt.js +2 -0
  36. package/dist/{chunk-1zv0s60b.js → chunk-675c6ddc.js} +2 -2
  37. package/dist/{chunk-wkq57ssc.js → chunk-6k6dgwmy.js} +1 -1
  38. package/dist/{chunk-4sqwtry6.js → chunk-6sm15trq.js} +1 -1
  39. package/dist/chunk-6t1rb4tz.js +2 -0
  40. package/dist/{chunk-d7e6tqmr.js → chunk-7wk4px2k.js} +2 -2
  41. package/dist/{chunk-e3wax332.js → chunk-88j356ng.js} +1 -1
  42. package/dist/{chunk-5qssa20j.js → chunk-89s9f3mf.js} +1 -1
  43. package/dist/{chunk-9cnq8y3d.js → chunk-97cvp0t3.js} +1 -1
  44. package/dist/{chunk-kbkvw42w.js → chunk-9b2yfhzj.js} +1 -1
  45. package/dist/{chunk-nf9dfx4t.js → chunk-9b4z1bpx.js} +1 -1
  46. package/dist/{chunk-m1zp48mr.js → chunk-a1fkxmxq.js} +1 -1
  47. package/dist/chunk-a4m6bqpq.js +2 -0
  48. package/dist/{chunk-zpxg12ep.js → chunk-bggpgbdx.js} +1 -1
  49. package/dist/{chunk-3k62kevg.js → chunk-c87s8txp.js} +1 -1
  50. package/dist/{chunk-zhfrmseh.js → chunk-cbqg29zr.js} +1 -1
  51. package/dist/{chunk-ffp0mgf5.js → chunk-d2d5m2kx.js} +3 -3
  52. package/dist/{chunk-b4a5gw9c.js → chunk-ddmvjp0y.js} +1 -1
  53. package/dist/chunk-djdf848n.js +2 -0
  54. package/dist/chunk-dsep28r5.js +2 -0
  55. package/dist/chunk-e6sg7jg4.js +2 -0
  56. package/dist/{chunk-qzens4rg.js → chunk-efqnnrwq.js} +1 -1
  57. package/dist/{chunk-ej7gpg23.js → chunk-eftyxrxw.js} +2 -2
  58. package/dist/chunk-eme4fny7.js +2 -0
  59. package/dist/{chunk-yj6xx2b8.js → chunk-emygmh7r.js} +1 -1
  60. package/dist/{chunk-d73ympxb.js → chunk-f001yg2a.js} +3 -3
  61. package/dist/{chunk-bprmzg0p.js → chunk-f0z6kyqt.js} +1 -1
  62. package/dist/chunk-f298fv6p.js +2 -0
  63. package/dist/chunk-fjp4k18r.js +2 -0
  64. package/dist/{chunk-ak9s0vnr.js → chunk-fvhnza91.js} +2 -2
  65. package/dist/{chunk-abfyz98y.js → chunk-gvnsr72j.js} +1 -1
  66. package/dist/{chunk-1p9hgr6z.js → chunk-gw3t78fw.js} +1 -1
  67. package/dist/chunk-h4084ykd.js +2 -0
  68. package/dist/{chunk-e1cvrjf0.js → chunk-he97rsmj.js} +2 -2
  69. package/dist/{chunk-k8pnnyq1.js → chunk-hkb714k3.js} +1 -1
  70. package/dist/{chunk-k53ndvfv.js → chunk-j0bsva07.js} +2 -2
  71. package/dist/{chunk-t3340cv5.js → chunk-ja3rvd6y.js} +1 -1
  72. package/dist/chunk-jczf4z85.js +2 -0
  73. package/dist/{chunk-ffb50kwa.js → chunk-jpdd59fh.js} +1 -1
  74. package/dist/{chunk-f7aw9cr3.js → chunk-kpqez1ht.js} +1 -1
  75. package/dist/{chunk-56q8k98m.js → chunk-ktmgq0ja.js} +1 -1
  76. package/dist/{chunk-mfhwcnxr.js → chunk-m17kvr7m.js} +1 -1
  77. package/dist/chunk-m2qq154g.js +2 -0
  78. package/dist/chunk-m8kqe55k.js +2 -0
  79. package/dist/chunk-n42c80f3.js +2 -0
  80. package/dist/{chunk-27jza51d.js → chunk-na0b9r57.js} +1 -1
  81. package/dist/chunk-nfcyqj66.js +2 -0
  82. package/dist/{chunk-bjg4gxs4.js → chunk-nhe8axrf.js} +2 -2
  83. package/dist/{chunk-j3bzf5m0.js → chunk-njfbmhm4.js} +7 -7
  84. package/dist/{chunk-47ancrn1.js → chunk-p8azbpq6.js} +2 -2
  85. package/dist/{chunk-d1yhv10h.js → chunk-p96zq2zc.js} +2 -2
  86. package/dist/chunk-pvfavmy3.js +2 -0
  87. package/dist/{chunk-jaewrjw3.js → chunk-q0tve4cm.js} +1 -1
  88. package/dist/{chunk-pkcvytq6.js → chunk-q5pxt13t.js} +1 -1
  89. package/dist/{chunk-95je030a.js → chunk-qczzpthf.js} +1 -1
  90. package/dist/{chunk-qmhd1bgx.js → chunk-qk43d3vv.js} +1 -1
  91. package/dist/{chunk-5bedx7s3.js → chunk-qv1nvaha.js} +1 -1
  92. package/dist/{chunk-rpkwbqr8.js → chunk-qz5nqeza.js} +1 -1
  93. package/dist/chunk-rfgacg5h.js +2 -0
  94. package/dist/{chunk-8mrbvnae.js → chunk-sczx20gw.js} +2 -2
  95. package/dist/chunk-sf4p2t84.js +2 -0
  96. package/dist/chunk-sjk83y3d.js +2 -0
  97. package/dist/{chunk-8dq3gews.js → chunk-srznv36n.js} +2 -2
  98. package/dist/chunk-t0kvt1pm.js +2 -0
  99. package/dist/{chunk-erbqszzp.js → chunk-t3a1703q.js} +1 -1
  100. package/dist/{chunk-1zz8bd1c.js → chunk-tgh61e5e.js} +2 -2
  101. package/dist/{chunk-kqam9qmd.js → chunk-v6dephze.js} +2 -2
  102. package/dist/{chunk-2vmaeyh3.js → chunk-v8746363.js} +3 -3
  103. package/dist/{chunk-kypdeb29.js → chunk-vckn5ate.js} +1 -1
  104. package/dist/{chunk-y1hppm93.js → chunk-w16pwfh3.js} +1 -1
  105. package/dist/{chunk-6qb96bg0.js → chunk-wcjf072v.js} +1 -1
  106. package/dist/chunk-wfn702a2.js +2 -0
  107. package/dist/{chunk-pwa2tt2e.js → chunk-wr1q4k9e.js} +1 -1
  108. package/dist/{chunk-df75rm51.js → chunk-wts1sqw7.js} +1 -1
  109. package/dist/{chunk-mtp0aygy.js → chunk-x4ea69ek.js} +2 -2
  110. package/dist/{chunk-7g13yp3v.js → chunk-xe2xdg6z.js} +1 -1
  111. package/dist/{chunk-myswpb7z.js → chunk-xny4kgcc.js} +1 -1
  112. package/dist/chunk-xpsetmcw.js +2 -0
  113. package/dist/{chunk-pqbzatbq.js → chunk-xzhzvdcv.js} +1 -1
  114. package/dist/chunk-yd834q68.js +2 -0
  115. package/dist/{chunk-nr1c0dny.js → chunk-yke7v3gh.js} +1 -1
  116. package/dist/chunk-ymwjjyke.js +2 -0
  117. package/dist/{chunk-0xxqw1h6.js → chunk-ysp81zyt.js} +1 -1
  118. package/dist/{chunk-e4bcngja.js → chunk-z456ptfw.js} +1 -1
  119. package/dist/{chunk-0t8q4880.js → chunk-zkv7e2q2.js} +1 -1
  120. package/dist/{chunk-nz0ns7ah.js → chunk-ztw515ew.js} +2 -2
  121. package/dist/src/git/github-provider.d.ts +8 -0
  122. package/dist/src/index.js +1 -1
  123. package/dist/src/setup.js +1 -1
  124. package/package.json +1 -1
  125. package/dist/chunk-042211k4.js +0 -2
  126. package/dist/chunk-04sy4xt9.js +0 -2
  127. package/dist/chunk-0j7rmr49.js +0 -2
  128. package/dist/chunk-217bhn06.js +0 -2
  129. package/dist/chunk-2k4gkkc6.js +0 -2
  130. package/dist/chunk-2kkwhrfz.js +0 -2
  131. package/dist/chunk-4m1vgh1w.js +0 -38
  132. package/dist/chunk-9ychha5r.js +0 -2
  133. package/dist/chunk-az2vad31.js +0 -2
  134. package/dist/chunk-ba1t70ph.js +0 -2
  135. package/dist/chunk-dbawp9kg.js +0 -2
  136. package/dist/chunk-dh9dw57m.js +0 -2
  137. package/dist/chunk-dkhvqxrk.js +0 -2
  138. package/dist/chunk-ecs7b2kg.js +0 -2
  139. package/dist/chunk-edgg7wxb.js +0 -2
  140. package/dist/chunk-h82t0mnh.js +0 -2
  141. package/dist/chunk-k10hm62v.js +0 -2
  142. package/dist/chunk-mmc8tvbb.js +0 -2
  143. package/dist/chunk-p3qck29r.js +0 -2
  144. package/dist/chunk-qe63pqwy.js +0 -2
  145. package/dist/chunk-qxc77b08.js +0 -2
  146. package/dist/chunk-r9k5vnrw.js +0 -2
  147. package/dist/chunk-rnv477z3.js +0 -2
  148. package/dist/chunk-s7da3h7c.js +0 -2
  149. package/dist/chunk-swphrsyr.js +0 -2
  150. package/dist/chunk-sx8pyc83.js +0 -2
  151. package/dist/chunk-sy3h7j1x.js +0 -2
  152. package/dist/chunk-ttx1jk5b.js +0 -2
  153. package/dist/chunk-v5qn8kjd.js +0 -2
  154. package/dist/chunk-vj9stet1.js +0 -2
  155. package/dist/chunk-w6bd9r6p.js +0 -2
  156. package/dist/chunk-x59yras6.js +0 -2
  157. package/dist/chunk-xfmzts7d.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{dd as u0}from"./chunk-8mrbvnae.js";import{fd as w0,gd as T0,hd as F0,id as l0}from"./chunk-ffp0mgf5.js";import{jd as c0}from"./chunk-j8era2yj.js";import{pd as z0,qd as j0,rd as y0}from"./chunk-8dq3gews.js";import{ud as f0,xd as g0}from"./chunk-c64qrkpz.js";import{oe as X0,pe as p}from"./chunk-3nygvd78.js";import{pf as m0}from"./chunk-1zv0s60b.js";import{sf as c,tf as P0,uf as O0,vf as h0,wf as o}from"./chunk-d1yhv10h.js";import{gg as _0,hg as k0,ig as m}from"./chunk-d73ympxb.js";import{rg as l,vg as b0,wg as v0}from"./chunk-abfyz98y.js";import{wh as d}from"./chunk-wkq57ssc.js";import{Gh as Z0}from"./chunk-b4a5gw9c.js";import{Ih as x0,Jh as $0,Kh as R0,Lh as U0}from"./chunk-bprmzg0p.js";import{bl as G}from"./chunk-4sqwtry6.js";import N0 from"fs";import{join as e}from"path";import y from"process";var p0={critical:"\uD83D\uDD34 Critical",high:"\uD83D\uDFE0 High",moderate:"\uD83D\uDFE1 Moderate",low:"\u26AA Low"};class K0{generateDashboard($,X={}){let{showOpenPRs:Q=!0,showDetectedDependencies:K=!0,showDeprecatedDependencies:Z=!0,showVulnerableDependencies:Y=!0,includePackageJson:W=!0,includeDependencyFiles:_=!0,includeGitHubActions:z=!0,bodyTemplate:L}=X,O="Dependency Dashboard";if(L)return{title:"Dependency Dashboard",body:this.applyTemplate(L,$)};let H=this.generateDefaultHeader($);if(Y&&$.vulnerableDependencies&&$.vulnerableDependencies.length>0)H+=this.generateVulnerableDependenciesSection($.vulnerableDependencies);if(Z&&$.deprecatedDependencies&&$.deprecatedDependencies.length>0)H+=this.generateDeprecatedDependenciesSection($.deprecatedDependencies);if(Q&&$.openPRs.length>0)H+=this.generateOpenPRsSection($.openPRs);if($.cappedDependencies&&$.cappedDependencies.length>0)H+=this.generateCappedDependenciesSection($.cappedDependencies);if(K)H+=this.generateDetectedDependenciesSection({packageJson:W?$.detectedDependencies.packageJson:[],dependencyFiles:_?$.detectedDependencies.dependencyFiles:[],githubActions:z?$.detectedDependencies.githubActions:[]});return H+=this.generateFooter(),{title:"Dependency Dashboard",body:H}}generateDefaultHeader($){return`This issue lists Buddy updates and detected dependencies. Read the [Dependency Dashboard](https://buddy.sh/features/dependency-dashboard) docs to learn more.
2
+ import{ed as u0}from"./chunk-sczx20gw.js";import{gd as w0,hd as T0,id as F0,jd as l0}from"./chunk-d2d5m2kx.js";import{kd as c0}from"./chunk-3wy8fypy.js";import{qd as z0,rd as j0,sd as y0}from"./chunk-srznv36n.js";import{vd as f0,yd as g0}from"./chunk-0ewzxzt3.js";import{pe as X0,qe as p}from"./chunk-1z4nhstx.js";import{qf as m0}from"./chunk-675c6ddc.js";import{tf as c,uf as P0,vf as O0,wf as h0,xf as o}from"./chunk-p96zq2zc.js";import{hg as _0,ig as k0,jg as m}from"./chunk-f001yg2a.js";import{sg as l,wg as b0,xg as v0}from"./chunk-gvnsr72j.js";import{xh as d}from"./chunk-6k6dgwmy.js";import{Hh as Z0}from"./chunk-ddmvjp0y.js";import{Jh as x0,Kh as $0,Lh as R0,Mh as U0}from"./chunk-f0z6kyqt.js";import{cl as G}from"./chunk-6sm15trq.js";import N0 from"fs";import{join as e}from"path";import y from"process";var p0={critical:"\uD83D\uDD34 Critical",high:"\uD83D\uDFE0 High",moderate:"\uD83D\uDFE1 Moderate",low:"\u26AA Low"};class K0{generateDashboard($,X={}){let{showOpenPRs:Q=!0,showDetectedDependencies:K=!0,showDeprecatedDependencies:Z=!0,showVulnerableDependencies:Y=!0,includePackageJson:W=!0,includeDependencyFiles:_=!0,includeGitHubActions:z=!0,bodyTemplate:L}=X,O="Dependency Dashboard";if(L)return{title:"Dependency Dashboard",body:this.applyTemplate(L,$)};let H=this.generateDefaultHeader($);if(Y&&$.vulnerableDependencies&&$.vulnerableDependencies.length>0)H+=this.generateVulnerableDependenciesSection($.vulnerableDependencies);if(Z&&$.deprecatedDependencies&&$.deprecatedDependencies.length>0)H+=this.generateDeprecatedDependenciesSection($.deprecatedDependencies);if(Q&&$.openPRs.length>0)H+=this.generateOpenPRsSection($.openPRs);if($.cappedDependencies&&$.cappedDependencies.length>0)H+=this.generateCappedDependenciesSection($.cappedDependencies);if(K)H+=this.generateDetectedDependenciesSection({packageJson:W?$.detectedDependencies.packageJson:[],dependencyFiles:_?$.detectedDependencies.dependencyFiles:[],githubActions:z?$.detectedDependencies.githubActions:[]});return H+=this.generateFooter(),{title:"Dependency Dashboard",body:H}}generateDefaultHeader($){return`This issue lists Buddy updates and detected dependencies. Read the [Dependency Dashboard](https://buddy.sh/features/dependency-dashboard) docs to learn more.
3
3
 
4
4
  `}sanitizeReferences($){return $.replace(/(?<![`\w])#(\d+)(?!\d)/g,"`#$1`")}toRelativePrUrl($,X){try{let Q=new URL($);if(Q.hostname!=="github.com")return null;let K=Q.pathname.match(/^\/[^/]+\/[^/]+\/pull\/(\d+)$/);if(!K||Number(K[1])!==X)return null;return`../pull/${X}`}catch{return null}}generateCappedDependenciesSection($){let X=`## Capped dependencies
5
5
 
@@ -84,9 +84,9 @@ The following updates have all been created. To force a retry/rebase of any, cli
84
84
 
85
85
  - [ ] <!-- manual job -->Check this box to trigger a request for Buddy to run again on this repository
86
86
  `}extractPackageInfo($){let X=[],Q=[/update.*?dependency\s+(\S+)/i,/update\s+require(?:-dev)?\s+(\S+)\s+to\s+v?\d+/i,/update\s+(\S+)\s+to\s+v?\d+/i,/bump\s+(\S+)\s+from/i,/chore\(deps\):\s*update\s+dependency\s+(\S+)/i];for(let Z of Q){let Y=$.title.match(Z);if(Y&&Y[1]&&!X.includes(Y[1]))X.push(Y[1])}let K=[{name:"npm",pattern:/### npm Dependencies[\s\S]*?(?=###|\n\n---|z)/i},{name:"pkgx",pattern:/### Launchpad\/pkgx Dependencies[\s\S]*?(?=###|\n\n---|z)/i},{name:"actions",pattern:/### GitHub Actions[\s\S]*?(?=###|\n\n---|z)/i}];for(let Z of K){let Y=$.body.match(Z.pattern);if(Y){let _=Y[0].match(/\|\s*\[([^\]]+)\]\([^)]+\)\s*\|/g);if(_)for(let z of _){let L=z.match(/\|\s*\[([^\]]+)\]/);if(L&&L[1]){let O=L[1].trim();if(O.includes("`")&&O.includes("->")){let H=z.match(/\]\(([^)]+)\)/);if(H&&H[1]){let j=H[1].match(/\/diffs\/npm\/([^/]+)\//);if(j&&j[1]){let q=decodeURIComponent(j[1]);if(q&&q.length>1&&!X.includes(q))X.push(q)}}continue}if(!O.includes("://")&&!O.includes("Compare Source")&&!O.includes("badge")&&!O.includes("!")&&!O.startsWith("[![")&&!O.includes("`")&&!O.includes("->")&&!O.includes(" -> ")&&!O.match(/^\d+\.\d+/)&&!O.includes(" ")&&O.length>0&&!X.includes(O))X.push(O)}}}}if(X.length<3){let Z=$.body.match(/`([^`]+)`/g);if(Z)for(let Y of Z){let W=Y.replace(/`/g,"").trim();if(W.includes("->")||W.includes(" -> ")||W.includes("` -> `")||W.match(/^\d+\.\d+/)||W.match(/^v\d+/)||W.match(/[\d.]+\s*->\s*[\d.]+/)||W.match(/^[\d.]+$/)||W.match(/^\d+\.\d+\.\d+/)||W.match(/^\d+\.\d+\.\d+\./)||W.match(/^\^?\d+\.\d+/)||W.match(/^~\d+\.\d+/)||W.includes("://")||W.includes("Compare Source")||W.includes("badge")||W.includes(" "))continue;if(W=W.split(",")[0].trim(),W&&W.length>1&&!X.includes(W)&&(W.startsWith("@")||W.includes("/")||W.match(/^[a-z][a-z0-9.-]*$/i)))X.push(W)}}return X}applyTemplate($,X){return $.replace(/\{\{repository\.owner\}\}/g,X.repository.owner).replace(/\{\{repository\.name\}\}/g,X.repository.name).replace(/\{\{openPRs\.count\}\}/g,X.openPRs.length.toString()).replace(/\{\{lastUpdated\}\}/g,X.lastUpdated.toISOString()).replace(/\{\{detectedDependencies\.packageJson\.count\}\}/g,X.detectedDependencies.packageJson.length.toString()).replace(/\{\{detectedDependencies\.githubActions\.count\}\}/g,X.detectedDependencies.githubActions.length.toString()).replace(/\{\{detectedDependencies\.dependencyFiles\.count\}\}/g,X.detectedDependencies.dependencyFiles.length.toString())}}var i0="buddy/",s0="no-auto-merge";function n($){let X=$.pullRequest?.autoMerge;return{enabled:X?.enabled??!1,strategy:X?.strategy??"squash",conditions:X?.conditions??[],requireGreenCI:X?.requireGreenCI??!0,optOutLabel:X?.optOutLabel??s0,securityLabel:$.security?.label??"security"}}function I0($,X,Q){let K=n(X);if(!K.enabled)return{eligible:!1,reason:"auto-merge is disabled by config"};if(K.conditions.length===0)return{eligible:!1,reason:"no auto-merge conditions configured (set conditions to at least one of patch-only, minor-only, security-only, all)"};if(!$.head.startsWith(i0))return{eligible:!1,reason:`PR #${$.number} is not a buddy PR (branch: ${$.head})`};if($.draft)return{eligible:!1,reason:`PR #${$.number} is a draft`};let Z=$.labels??[];if(Z.includes(K.optOutLabel))return{eligible:!1,reason:`PR #${$.number} carries the ${K.optOutLabel} label`};if(K.requireGreenCI&&Q===!1)return{eligible:!1,reason:`PR #${$.number} has failing or pending checks`};let Y=l($.body);if(!Y)return{eligible:!1,reason:`PR #${$.number} has no metadata manifest to verify update types against`};if(Y.truncated)return{eligible:!1,reason:`PR #${$.number} has a truncated manifest, so its full update set cannot be verified`};let W=V0(Y,X);if(W)return W;return A0(Y,Z,K)}function V0($,X){let Q=[...o(X.packages?.groups),...X.packages?.rules??[]];if(Q.length===0||$.updates.length===0)return null;if(!$.updates.every((Y)=>Y.type&&Y.dependencyType))return null;let Z=$.updates.map((Y)=>c(r0(Y),Q));if(Z.some((Y)=>Y.autoMerge===!1))return{eligible:!1,reason:"a package rule holds one of these updates back from auto-merge"};if(Z.every((Y)=>Y.autoMerge===!0))return{eligible:!0,reason:"every update is covered by a package rule that enables auto-merge"};return null}function r0($){return{name:$.name,currentVersion:$.current,newVersion:$.target,updateType:$.type,file:$.file,dependencyType:$.dependencyType}}function A0($,X,Q){for(let Z of Q.conditions)switch(Z){case"all":return{eligible:!0,reason:"all updates qualify (condition: all)"};case"patch-only":if($.updates.length>0&&$.updates.every((Y)=>Y0(Y)==="patch"))return{eligible:!0,reason:"every update is a patch"};break;case"minor-only":if($.updates.length>0&&$.updates.every((Y)=>Y0(Y)!=="major"))return{eligible:!0,reason:"every update is minor or patch"};break;case"security-only":if(X.includes(Q.securityLabel))return{eligible:!0,reason:"PR resolves a security advisory"};break}return{eligible:!1,reason:`update types (${[...new Set($.updates.map(Y0))].join(", ")||"none"}) do not satisfy conditions (${Q.conditions.join(", ")})`}}function Y0($){if($.type==="major"||$.type==="minor"||$.type==="patch")return $.type;let X=G0($.current),Q=G0($.target);if(!X||!Q)return"major";if(X[0]!==Q[0])return"major";if(X[1]!==Q[1])return"minor";return"patch"}function G0($){let X=$.trim().match(/(\d+)\.(\d+)\.(\d+)/);if(!X)return null;return[Number(X[1]),Number(X[2]),Number(X[3])]}function M0($,X,Q){let K=n(Q);if(!K.enabled)return{eligible:!1,reason:"auto-merge is disabled by config"};if(K.conditions.length===0)return{eligible:!1,reason:"no auto-merge conditions configured"};if(X.includes(K.optOutLabel))return{eligible:!1,reason:`PR carries the ${K.optOutLabel} label`};let Z={schemaVersion:1,updates:$.map((W)=>({name:W.name,current:W.currentVersion,target:W.newVersion,type:W.updateType,file:W.file,dependencyType:W.dependencyType}))},Y=V0(Z,Q);if(Y)return Y;return A0(Z,X,K)}var S0="https://api.osv.dev",t0=1000,r={low:0,moderate:1,high:2,critical:3};function H0($){switch($){case"dependencies":case"devDependencies":case"peerDependencies":case"optionalDependencies":return"npm";case"require":case"require-dev":return"Packagist";case"python":return"PyPI";case"rust":return"crates.io";case"go":return"Go";case"ruby":return"RubyGems";case"github-actions":return"GitHub Actions";default:return null}}function a0($){let X=$.database_specific?.severity?.toLowerCase();if(X==="low"||X==="moderate"||X==="high"||X==="critical")return X;if(X==="medium")return"moderate";let Q=$.severity?.find((K)=>K.type?.startsWith("CVSS"))?.score;if(Q){let K=e0(Q);if(K!==null){if(K>=9)return"critical";if(K>=7)return"high";if(K>=4)return"moderate";return"low"}}return"moderate"}function e0($){let X=Number($);if(Number.isFinite(X))return X;let Q=$.match(/\/([0-9](?:\.[0-9])?)$/);if(Q){let K=Number(Q[1]);return Number.isFinite(K)?K:null}return null}function $1($,X){for(let Q of $.affected??[]){if(Q.package?.name!==X)continue;for(let K of Q.ranges??[])for(let Z of K.events??[])if(Z.fixed)return Z.fixed}return}class a{logger;concurrency;detailCache=new F0;constructor($,X=8){this.logger=$;this.concurrency=X}async findAdvisories($){let X=new Map;if($.length===0)return X;let Q=await this.queryBatch($),K=[...new Set([...Q.values()].flat())];if(K.length===0)return X;this.logger.debug(`Fetching details for ${K.length} advisory record(s)`);let Z=await w0(K,(W)=>this.fetchVulnerability(W),this.concurrency),Y=new Map;for(let W of Z)if(W)Y.set(W.id,W);for(let[W,_]of Q){let z=W.slice(W.indexOf(":")+1,W.lastIndexOf("@")),L=[];for(let O of _){let H=Y.get(O);if(!H)continue;L.push({id:H.id,aliases:H.aliases??[],summary:H.summary??H.details?.split(`
87
- `)[0]??"No summary provided",severity:a0(H),url:`https://osv.dev/vulnerability/${H.id}`,fixedVersion:$1(H,z)})}if(L.length>0)L.sort((O,H)=>r[H.severity]-r[O.severity]),X.set(W,L)}return X}async annotateUpdates($,X="low"){let Q=[],K=[];if($.forEach((_,z)=>{let L=H0(_.dependencyType);if(!L)return;let O=B0(_.currentVersion);if(!O)return;let H=L==="GitHub Actions"?O.replace(/^v/i,""):O;if(!H)return;Q.push({name:_.name,version:H,ecosystem:L}),K.push(z)}),Q.length===0)return $;let Z=await this.findAdvisories(Q),Y=r[X],W=0;if(Q.forEach((_,z)=>{let L=Z.get(t(_));if(!L?.length)return;let O=$[K[z]],H=L.filter((J)=>{if(r[J.severity]<Y)return!1;if(!J.fixedVersion)return!1;return X1(B0(O.newVersion),J.fixedVersion)});if(H.length>0)O.securityAdvisories=H,W++}),W>0)this.logger.info(`\uD83D\uDD12 ${W} update(s) resolve known security advisories`);return $}async queryBatch($){let X=new Map,Q=T0($,t0);for(let K of Q)try{let Z=await Z0(`${S0}/v1/querybatch`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":"buddy"},body:JSON.stringify({queries:K.map((W)=>({package:{name:W.name,ecosystem:W.ecosystem},version:W.version}))}),retryNonIdempotent:!0,onRetry:({delayMs:W,reason:_})=>this.logger.debug(`OSV batch retry in ${Math.round(W/1000)}s (${_})`)});if(!Z.ok){this.logger.warn(`OSV advisory lookup failed: HTTP ${Z.status}`);continue}(await Z.json()).results?.forEach((W,_)=>{let z=W.vulns?.map((L)=>L.id)??[];if(z.length>0)X.set(t(K[_]),z)})}catch(Z){this.logger.warn("OSV advisory lookup failed:",Z)}return X}async fetchVulnerability($){return this.detailCache.get($,async()=>{try{let X=await Z0(`${S0}/v1/vulns/${encodeURIComponent($)}`,{headers:{"User-Agent":"buddy"}});if(!X.ok)return null;return await X.json()}catch(X){return this.logger.debug(`Failed to fetch advisory ${$}:`,X),null}})}}function t($){return`${$.ecosystem}:${$.name}@${$.version}`}function B0($){return $.replace(/^[\^~>=<\s]*v?/,"").trim()}function X1($,X){if(!$||!X)return!1;try{return Bun.semver.order($,X)>=0}catch{return!1}}import Q1 from"process";function W1($){if(!$)return null;let X=$.split("/").filter(Boolean);if(X.length<2)return null;return{owner:X.slice(0,-1).join("/"),name:X[X.length-1]}}var K1=["GITHUB_REPOSITORY","CI_PROJECT_PATH","BITBUCKET_REPO_FULL_NAME"];function Y1($){for(let X of K1){let Q=W1($[X]);if(Q)return Q}return null}function C0($,X=Q1.env){if(!$.repository)return{source:"unresolved",overrodeConfig:!1};let Q=$.repository,K=Y1(X),Z=Boolean(Q.owner&&Q.name);if(!K)return Z?{owner:Q.owner,name:Q.name,source:"config",overrodeConfig:!1}:{source:"unresolved",overrodeConfig:!1};if(Z&&(Q.owner!==K.owner||Q.name!==K.name)){let _=`Configured repository ${`${Q.owner}/${Q.name}`} does not match the checked-out repository ${K.owner}/${K.name}. Using ${K.owner}/${K.name} \u2014 buddy `+"operates on the checked-out repository. Update repository.owner/repository.name in your buddy config to silence this warning.";if(Q.owner=K.owner,Q.name=K.name,$.dashboard?.issueNumber!==void 0)$.dashboard.issueNumber=void 0;return{owner:K.owner,name:K.name,source:"environment",overrodeConfig:!0,warning:_}}if(!Z)return Q.owner||=K.owner,Q.name||=K.name,{owner:K.owner,name:K.name,source:"environment",overrodeConfig:!1};return{owner:Q.owner,name:Q.name,source:"config",overrodeConfig:!1}}class Q0{config;projectPath;logger;scanner;registryClient;eventBus=null;dashboardGenerator;constructor($,X=y.cwd()){this.config=$;this.projectPath=X;this.logger=new R0($.verbose??!1,$.logLevel),U0(this.logger),this.resolveRepositoryConfig(),this.scanner=new c0(this.projectPath,this.logger,this.config.packages?.ignorePaths),this.registryClient=new l0(this.projectPath,this.logger,this.config),this.dashboardGenerator=new K0}async analyzeMajors($,X){if(!this.config.ai?.majorUpgrades?.enabled)return{report:"",draft:!1};let{analyzeGroupMajors:Q}=await import("./chunk-h82t0mnh.js"),{createAiClient:K}=await import("./chunk-0xxqw1h6.js"),{ReleaseNotesFetcher:Z}=await import("./chunk-9ychha5r.js"),Y=new Z(this.logger),W=await Q({updates:$,config:this.config,workspace:this.projectPath,baseBranch:this.config.repository?.baseBranch||"main",files:X,ai:K(this.config,this.logger),fetchReleases:(_,z,L)=>Y.fetchSpanReleases(_,z,L),logger:this.logger});return{report:W.report,draft:W.draft}}resolveRepositoryConfig(){let $=C0(this.config);if($.warning)this.logger.warn(`\u26A0\uFE0F ${$.warning}`);else if($.source==="environment")this.logger.info(`Auto-detected repository: ${$.owner}/${$.name} from GITHUB_REPOSITORY`)}async scanForUpdates(){let $=Date.now();this.logger.info("Starting dependency update scan...");try{let X=Date.now(),Q=await this.scanner.scanProject();this.logger.info(`\u23F1\uFE0F Package file scan took ${Date.now()-X}ms`);let K=Q.reduce((x,P)=>x+P.dependencies.length,0),Z=[],Y=Date.now();if(this.config.packages?.ignore&&this.config.packages.ignore.length>0)Z=(await this.registryClient.getOutdatedPackages()).filter((P)=>!this.config.packages.ignore.includes(P.name));else Z=await this.registryClient.getOutdatedPackages();this.logger.info(`\u23F1\uFE0F bun outdated check took ${Date.now()-Y}ms (found ${Z.length} updates)`);let W=Date.now(),_=await this.checkDependencyFilesForUpdates(Q);this.logger.info(`\u23F1\uFE0F Dependency file checks took ${Date.now()-W}ms (found ${_.length} updates)`);let z=Date.now(),L=await this.checkGitHubActionsForUpdates(Q);this.logger.info(`\u23F1\uFE0F GitHub Actions checks took ${Date.now()-z}ms (found ${L.length} updates)`);let O=Date.now(),H=await this.checkDockerfilesForUpdates(Q);this.logger.info(`\u23F1\uFE0F Docker image checks took ${Date.now()-O}ms (found ${H.length} updates)`);let J=Date.now(),j=await this.checkZigForUpdates(Q),q=this.config.packages?.engines===!0?await this.checkEnginesForUpdates(Q):[];this.logger.info(`\u23F1\uFE0F Zig dependency checks took ${Date.now()-J}ms (found ${j.length} updates)`);let{scanCatalogs:I}=await import("./chunk-sx8pyc83.js"),T=await I(this.projectPath,(x)=>this.registryClient.getLatestVersion(x),{...this.config.packages?.ignore?{ignore:this.config.packages.ignore}:{},logger:this.logger});if(T.entries.length>0)this.logger.info(`\uD83D\uDCE6 pnpm catalogs: ${T.updates.length} update(s) across ${T.entries.length} entr(ies)`);let M=Date.now(),{scanEcosystems:B}=await import("./chunk-mmc8tvbb.js"),C=await B({dir:this.projectPath,...this.config.packages?.includePrerelease!==void 0?{includePrerelease:this.config.packages.includePrerelease}:{},...this.config.packages?.ignore?{ignore:this.config.packages.ignore}:{},logger:this.logger});if(C.manifests.length>0)this.logger.info(`\u23F1\uFE0F Ecosystem checks took ${Date.now()-M}ms (found ${C.updates.length} updates across ${C.manifests.map((x)=>x.ecosystem).join(", ")})`);let D=[...Z,..._,...L,...H,...j,...q,...C.updates,...T.updates];if(this.config.packages?.ignore&&this.config.packages.ignore.length>0)D=D.filter((x)=>!this.config.packages.ignore.includes(x.name));let b=Date.now();if(this.config.packages?.strategy)D=this.filterUpdatesByStrategy(D,this.config.packages.strategy);this.logger.info(`\u23F1\uFE0F Strategy filtering took ${Date.now()-b}ms`);let R=Date.now();D=await this.filterUpdatesByMinimumReleaseAge(D),this.logger.info(`\u23F1\uFE0F Minimum release age filtering took ${Date.now()-R}ms`),D=this.applyPins(D),D=await this.dropOverriddenUpdates(D,Q),D=this.applyPackageRules(D);let f=Date.now();D=await this.annotateSecurityAdvisories(D),this.logger.info(`\u23F1\uFE0F Security advisory lookup took ${Date.now()-f}ms`);let g=this.config.security?.prioritize??!0,u=Date.now();D=k0(D,{prioritizeSecurity:g}),this.logger.info(`\u23F1\uFE0F Sorting took ${Date.now()-u}ms`);let V=Date.now(),N=this.config.packages?.groups?this.groupUpdatesByConfig(D):_0(D,{prioritizeSecurity:g});this.logger.info(`\u23F1\uFE0F Grouping took ${Date.now()-V}ms`);let W0=Date.now()-$,i={totalPackages:K,updates:D,groups:N,scannedAt:new Date,duration:W0};return this.logger.success(`Scan completed in ${W0}ms. Found ${D.length} updates.`),await this.events.emit("scan.completed",{total:D.length,major:D.filter((x)=>x.updateType==="major").length,minor:D.filter((x)=>x.updateType==="minor").length,patch:D.filter((x)=>x.updateType==="patch").length}),i}catch(X){throw this.logger.error("Failed to scan for updates:",X),X}}prTitleFor($){let X=this.config.pullRequest?.titleFormat;if(!X)return $.title;return z0(X,j0($,{title:$.title},this.config.packages?.strategy))}commitMessageFor($,X){let Q=this.config.pullRequest?.commitMessageFormat,K=Q?z0(Q,j0($,{message:$.title,title:$.title},this.config.packages?.strategy)):$.title;return X?`${K} ${X}`:K}applyPackageRules($){let X=this.config.packages?.rules??[],K=[...o(this.config.packages?.groups),...X];if(K.length===0)return $;let Z=P0($,K);if(Z.length<$.length)this.logger.info(`\uD83D\uDCCB Package rules dropped ${$.length-Z.length} update(s)`);return Z.map((Y)=>Y.update)}static mergeUnique($,X){let Q=[...new Set([...$??[],...X])];return Q.length>0?Q:void 0}labelsFor($,X){let Q=$.updates.some((K)=>(K.securityAdvisories?.length??0)>0);return[...new Set([...X.generateLabels($),...Q?[this.config.security?.label??"security"]:[],...this.config.pullRequest?.labels??[],...this.groupEffectsFor($.updates).labels])]}activeRules(){return[...o(this.config.packages?.groups),...this.config.packages?.rules??[]]}groupEffectsFor($){let X=this.activeRules();if(X.length===0)return O0([]);return O0($.map((Q)=>c(Q,X)))}orderGroupsByPriority($){if(this.activeRules().length===0)return $;return $.map((Q,K)=>({group:Q,index:K,priority:this.groupEffectsFor(Q.updates).prPriority})).sort((Q,K)=>K.priority-Q.priority||Q.index-K.index).map((Q)=>Q.group)}async dropOverriddenUpdates($,X){let Q=X.filter((W)=>W.type==="package.json");if(Q.length===0)return $;let{collectResolutionPins:K,pinBlocksUpdate:Z}=await import("./chunk-rpkwbqr8.js"),Y=new Map;for(let W of Q)try{for(let _ of K(JSON.parse(W.content)))Y.set(_.name,{version:_.version,field:_.field})}catch{continue}if(Y.size===0)return $;return $.filter((W)=>{let _=Y.get(W.name);if(!_)return!0;if(!Z({name:W.name,version:_.version,field:_.field},W.newVersion))return!0;return this.logger.info(`\uD83D\uDD12 Skipping ${W.name} \u2192 ${W.newVersion}: ${_.field} pins it to ${_.version}, which would win at install time`),!1})}applyPins($){let X=this.config.packages?.pin;if(!X||Object.keys(X).length===0)return $;let Q=[];for(let K of $){let Z=X[K.name];if(!Z){Q.push(K);continue}if(K.currentVersion===Z){this.logger.info(`\uD83D\uDCCC ${K.name} is pinned to ${Z}, skipping update to ${K.newVersion}`);continue}this.logger.info(`\uD83D\uDCCC ${K.name} is pinned to ${Z}, retargeting update from ${K.newVersion}`),Q.push({...K,newVersion:Z,updateType:m(K.currentVersion,Z)})}return Q}async annotateSecurityAdvisories($){if(this.config.security?.enabled===!1||$.length===0)return $;try{let Q=await new a(this.logger).annotateUpdates($,this.config.security?.minimumSeverity??"low"),K=Q.filter((Z)=>Z.securityAdvisories?.length);if(K.length>0)await this.events.emit("security.advisories",{packages:K.map((Z)=>({name:Z.name,severity:Z.securityAdvisories?.[0]?.severity??"unknown"}))});return Q}catch(X){return this.logger.warn("Security advisory lookup failed, continuing without it:",X),$}}async createPullRequests($){let X=Date.now();this.logger.info("Creating pull requests for updates...");try{if(!this.config.repository){this.logger.error("\u274C Repository configuration required for PR creation"),this.logger.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts");return}if(!this.config.repository.owner||!this.config.repository.name){this.logger.error("\u274C Repository owner and name are required for PR creation"),this.logger.info("Set them in buddy.config.ts or ensure GITHUB_REPOSITORY env var is available");return}let Q=y.env.GITHUB_TOKEN,K=y.env.BUDDY_TOKEN||y.env.BUDDY_BOT_TOKEN;if(!Q&&!K){this.logger.error("\u274C GITHUB_TOKEN or BUDDY_TOKEN environment variable required for PR creation");return}let Z=Q||K,Y=!!K;if(K)this.logger.info("\u2705 BUDDY_TOKEN detected - workflow file permissions enabled");else this.logger.info("\u2139\uFE0F No BUDDY_TOKEN \u2014 workflow file updates will be skipped");let W=await X0({provider:this.config.repository.provider,owner:this.config.repository.owner,name:this.config.repository.name,token:Z,...K?{workflowToken:K}:{},...this.config.repository.apiUrl?{apiUrl:this.config.repository.apiUrl}:{}},{logger:this.logger}),_=new y0(this.config),z=this.config.maxPRsPerRun??10,L=0,O=this.orderGroupsByPriority($.groups),H=[];for(let j of O)try{let q=Date.now();if(this.logger.info(`Creating PR for group: ${j.name} (${j.updates.length} updates)`),j.updates.length>0&&j.updates.every((E)=>E.file.includes(".github/workflows/"))&&!Y){this.logger.warn(`\u26A0\uFE0F Skipping group ${j.name} \u2014 workflow-file updates require BUDDY_TOKEN with the workflow scope`);continue}try{let{spawn:E}=await import("child_process"),w=(A,F)=>{return new Promise((k,U)=>{let v=E(A,F,{stdio:"pipe"});v.on("close",(s)=>s===0?k():U(Error(`Git command failed with code ${s}`))),v.on("error",U)})},S=this.config.repository.baseBranch||"main";await w("git",["checkout",S]),await w("git",["reset","--hard","HEAD"]),await w("git",["clean","-fd"])}catch(E){this.logger.warn("\u26A0\uFE0F Failed to reset to clean state for early file-change check, continuing anyway:",E)}let T=await this.generateAllFileUpdates(j.updates);if(T.length===0){this.logger.info(`\u2139\uFE0F No file changes for group ${j.name}, skipping \u2014 leaving branches untouched`);continue}let M=this.prTitleFor(j),B=Date.now(),C=await _.generateBody(j),D=Date.now()-B;this.logger.info(`\u23F1\uFE0F PR body generation took ${D}ms`);let b=await this.analyzeMajors(j.updates,T.map((E)=>E.path)),R=m0(C,b.report),f=await W.getPullRequests("open"),g=this.generateBranchName(j),u=`buddy/update-${j.name.toLowerCase().replace(/\s+/g,"-")}-`,V=f.find((E)=>(E.head===g||E.title===M||E.head.startsWith(u)||this.isSimilarPRTitle(E.title,M))&&(E.author==="github-actions[bot]"||E.author.includes("buddy")||E.head.startsWith("buddy/"))&&!E.head.includes("renovate/")&&!E.head.includes("dependabot/")&&!E.author.toLowerCase().includes("renovate")&&!E.author.toLowerCase().includes("dependabot"));if(V){if(this.logger.info(`\uD83D\uDD04 Found existing PR #${V.number}: ${V.title}`),this.shouldAutoClosePR(V,j.updates)){this.logger.info(`\uD83D\uDD12 Auto-closing PR #${V.number} due to config change`);try{let A=this.generateCloseReason(V);try{await W.createComment(V.number,A)}catch(F){this.logger.warn(`\u26A0\uFE0F Could not add close reason comment to PR #${V.number}:`,F)}await W.closePullRequest(V.number),await this.events.emit("pr.closed",{number:V.number,title:V.title,reason:"no longer produced by the current configuration"});try{await W.deleteBranch(V.head),this.logger.success(`\u2705 Auto-closed PR #${V.number} and deleted branch ${V.head}`)}catch(F){this.logger.warn(`\u26A0\uFE0F Auto-closed PR #${V.number} but could not delete ${V.head}:`,F)}continue}catch(A){this.logger.error(`\u274C Failed to auto-close PR #${V.number}:`,A)}}let w=this.checkIfUpdatesMatch(V.body,j.updates),S=[];if(w&&W.getPullRequestFiles)try{let{missingLockFiles:A}=await import("./chunk-dh9dw57m.js");S=A(await W.getPullRequestFiles(V.number))}catch(A){this.logger.warn(`\u26A0\uFE0F Could not list the files of PR #${V.number}; trusting it: ${$0(A)}`)}if(w&&S.length===0){this.logger.info("\u2705 Existing PR has the same updates, skipping creation");continue}else{if(S.length>0)this.logger.info(`\uD83D\uDD12 PR #${V.number} has the same updates but does not regenerate ${S.join(", ")}; refreshing it`);this.logger.info("\uD83D\uDD04 Updates differ, will update existing PR with new content");let A=V.head;try{let{spawn:U}=await import("child_process"),v=(s,n0)=>{return new Promise((d0,q0)=>{let D0=U(s,n0,{stdio:"pipe"});D0.on("close",(E0)=>{if(E0===0)d0();else q0(Error(`Git command failed with code ${E0}`))}),D0.on("error",q0)})};await v("git",["checkout","main"]),await v("git",["reset","--hard","HEAD"]),await v("git",["clean","-fd"]),this.logger.info(`\uD83E\uDDF9 Reset to clean main state before updating existing PR ${V.number}`)}catch(U){this.logger.warn("\u26A0\uFE0F Failed to reset to clean state, continuing anyway:",U)}let F=await this.generateAllFileUpdates(j.updates);if(F.length===0)this.logger.warn(`\u2139\uFE0F No file changes generated for existing PR ${V.number}, updating metadata only`);else{this.logger.info(`\uD83D\uDCDD Regenerated ${F.length} file changes for existing PR ${V.number}`);try{let{hasBranchDifferences:U}=await import("./chunk-d84k4mek.js");if(!await U(F,A))this.logger.info(`\u2139\uFE0F No content differences for ${A}; recreating from ${this.config.repository.baseBranch||"main"} with same dependency changes to keep branch up-to-date`),await W.commitChanges(A,this.commitMessageFor(j,"(rebased)"),F,this.config.repository.baseBranch||"main"),this.logger.success(`\u2705 Recreated ${A} from ${this.config.repository.baseBranch||"main"} (dependency versions unchanged)`);else await W.commitChanges(A,this.commitMessageFor(j,"(updated)"),F,this.config.repository.baseBranch||"main"),this.logger.success(`\u2705 Recreated branch ${A} with latest dependency versions`)}catch(U){this.logger.warn("\u26A0\uFE0F Failed to compare branch content, proceeding with commit:",U),await W.commitChanges(A,this.commitMessageFor(j,"(updated)"),F,this.config.repository.baseBranch||"main"),this.logger.success(`\u2705 Recreated branch ${A} with latest dependency versions`)}}let k=this.labelsFor(j,_);await W.updatePullRequest(V.number,{title:M,body:R,labels:k,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:V.number,title:M,url:V.url}),this.logger.success(`\u2705 Updated existing PR #${V.number}: ${M}`),this.logger.info(`\uD83D\uDD17 ${V.url}`);continue}}if(L>=z){this.logger.warn(`\u26A0\uFE0F Rate limit reached: already created ${L} PRs this run (max: ${z}). Skipping remaining groups.`);break}let N=this.generateBranchName(j);if(await W.branchExists(N)){this.logger.info(`\uD83D\uDD04 Branch ${N} already exists, checking for associated PR...`);let E=f.find((S)=>S.head===N);if(E){this.logger.info(`\u2705 Found existing PR #${E.number} for branch ${N}, updating it...`);let S=await this.generateAllFileUpdates(j.updates);if(S.length>0)await W.commitChanges(N,this.commitMessageFor(j,"(updated)"),S,this.config.repository.baseBranch||"main");let A=this.labelsFor(j,_);await W.updatePullRequest(E.number,{title:M,body:R,labels:A,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:E.number,title:M,url:E.url}),this.logger.success(`\u2705 Updated existing PR #${E.number}: ${M}`),this.logger.info(`\uD83D\uDD17 ${E.url}`);continue}let w=!1;try{let A=(p(W,"reopenPullRequests","reopenPullRequest")?await W.getPullRequests("closed"):[]).find((F)=>{if(F.head!==N)return!1;if(F.mergedAt)return!1;return Date.now()-(F.updatedAt?.getTime()??0)<86400000});if(A){this.logger.info(`\uD83D\uDD04 Found recently-closed PR #${A.number} for branch ${N}, reopening...`);let F=await this.generateAllFileUpdates(j.updates);if(F.length>0)await W.commitChanges(N,this.commitMessageFor(j,"(reopened)"),F,this.config.repository.baseBranch||"main");await W.reopenPullRequest(A.number);let k=this.labelsFor(j,_);await W.updatePullRequest(A.number,{title:M,body:R,labels:k,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:A.number,title:M,url:A.url}),this.logger.success(`\u2705 Reopened and updated PR #${A.number}: ${M}`),this.logger.info(`\uD83D\uDD17 ${A.url}`),w=!0}}catch(S){this.logger.warn("\u26A0\uFE0F Failed to check/reopen closed PRs:",S)}if(w)continue;this.logger.info(`\uD83E\uDDF9 Branch ${N} exists but has no open PR, cleaning up...`);try{await W.deleteBranch(N)}catch(S){this.logger.warn(`\u26A0\uFE0F Failed to delete orphaned branch ${N}:`,S)}}let i=!1;try{let w=(p(W,"reopenPullRequests","reopenPullRequest")?await W.getPullRequests("closed"):[]).find((S)=>{if(S.head!==N&&!this.isSimilarPRTitle(S.title,M))return!1;if(!S.head.startsWith("buddy/")&&S.author!=="github-actions[bot]")return!1;if(S.mergedAt)return!1;return Date.now()-(S.updatedAt?.getTime()??0)<604800000});if(w){this.logger.info(`\uD83D\uDD04 Found recently-closed PR #${w.number} (branch may have been deleted), recreating branch and reopening...`),await W.createBranch(N,this.config.repository.baseBranch||"main");let S=await this.generateAllFileUpdates(j.updates);if(S.length>0)await W.commitChanges(N,this.commitMessageFor(j,"(reopened)"),S,this.config.repository.baseBranch||"main");await W.reopenPullRequest(w.number);let A=this.labelsFor(j,_);await W.updatePullRequest(w.number,{title:M,body:R,labels:A,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:w.number,title:M,url:w.url}),this.logger.success(`\u2705 Reopened and updated PR #${w.number}: ${M}`),this.logger.info(`\uD83D\uDD17 ${w.url}`),i=!0}}catch(E){this.logger.warn("\u26A0\uFE0F Failed to check/reopen closed PRs:",E)}if(i)continue;await W.createBranch(N,this.config.repository.baseBranch||"main");try{let{spawn:E}=await import("child_process"),w=(S,A)=>{return new Promise((F,k)=>{let U=E(S,A,{stdio:"pipe"});U.on("close",(v)=>{if(v===0)F();else k(Error(`Git command failed with code ${v}`))}),U.on("error",k)})};await w("git",["checkout","main"]),await w("git",["reset","--hard","HEAD"]),await w("git",["clean","-fd"]),this.logger.info(`\uD83E\uDDF9 Reset to clean main state before generating updates for ${j.name}`)}catch(E){this.logger.warn("\u26A0\uFE0F Failed to reset to clean state, continuing anyway:",E)}let x=await this.generateAllFileUpdates(j.updates);if(x.length===0){this.logger.warn(`\u2139\uFE0F No file changes generated for group ${j.name}, skipping PR creation`);continue}let P=!1;for(let E of x)try{let w=await import("fs");if(w.existsSync(E.path)){if(w.readFileSync(E.path,"utf-8")!==E.content){P=!0;break}}else{P=!0;break}}catch{P=!0;break}if(!P){this.logger.warn(`\u2139\uFE0F No actual content changes for group ${j.name}, skipping PR creation`);continue}this.logger.info(`\uD83D\uDCDD Generated ${x.length} file changes for ${j.name}`),await W.commitChanges(N,this.commitMessageFor(j),x,this.config.repository.baseBranch||"main");let J0=this.groupEffectsFor(j.updates),L0=this.labelsFor(j,_),h=await W.createPullRequest({title:M,body:R,head:N,base:this.config.repository.baseBranch||"main",draft:b.draft,reviewers:Q0.mergeUnique(this.config.pullRequest?.reviewers,J0.reviewers),teamReviewers:this.config.pullRequest?.teamReviewers,assignees:Q0.mergeUnique(this.config.pullRequest?.assignees,J0.assignees),labels:L0});L++,this.logger.success(`\u2705 Created PR #${h.number}: ${h.title} (${L}/${z} this run)`),this.logger.info(`\uD83D\uDD17 ${h.url}`),await this.events.emit("pr.created",{number:h.number,title:h.title,url:h.url,packages:j.updates.map((E)=>E.name)}),await this.queueAutoMerge(W,h,j.updates,L0);let o0=Date.now()-q;this.logger.info(`\u23F1\uFE0F Total group processing took ${o0}ms`)}catch(q){if(q instanceof Error&&q.name==="WorkflowPermissionError"){this.logger.warn(`\u26A0\uFE0F Skipping group ${j.name}: ${q.message}`);continue}this.logger.error(`\u274C Failed to create PR for group ${j.name}:`,q),H.push({name:j.name,error:q})}let J=Date.now()-X;if(H.length>0){let j=H.map((q)=>`${q.name}: ${$0(q.error)}`).join(`
87
+ `)[0]??"No summary provided",severity:a0(H),url:`https://osv.dev/vulnerability/${H.id}`,fixedVersion:$1(H,z)})}if(L.length>0)L.sort((O,H)=>r[H.severity]-r[O.severity]),X.set(W,L)}return X}async annotateUpdates($,X="low"){let Q=[],K=[];if($.forEach((_,z)=>{let L=H0(_.dependencyType);if(!L)return;let O=B0(_.currentVersion);if(!O)return;let H=L==="GitHub Actions"?O.replace(/^v/i,""):O;if(!H)return;Q.push({name:_.name,version:H,ecosystem:L}),K.push(z)}),Q.length===0)return $;let Z=await this.findAdvisories(Q),Y=r[X],W=0;if(Q.forEach((_,z)=>{let L=Z.get(t(_));if(!L?.length)return;let O=$[K[z]],H=L.filter((J)=>{if(r[J.severity]<Y)return!1;if(!J.fixedVersion)return!1;return X1(B0(O.newVersion),J.fixedVersion)});if(H.length>0)O.securityAdvisories=H,W++}),W>0)this.logger.info(`\uD83D\uDD12 ${W} update(s) resolve known security advisories`);return $}async queryBatch($){let X=new Map,Q=T0($,t0);for(let K of Q)try{let Z=await Z0(`${S0}/v1/querybatch`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":"buddy"},body:JSON.stringify({queries:K.map((W)=>({package:{name:W.name,ecosystem:W.ecosystem},version:W.version}))}),retryNonIdempotent:!0,onRetry:({delayMs:W,reason:_})=>this.logger.debug(`OSV batch retry in ${Math.round(W/1000)}s (${_})`)});if(!Z.ok){this.logger.warn(`OSV advisory lookup failed: HTTP ${Z.status}`);continue}(await Z.json()).results?.forEach((W,_)=>{let z=W.vulns?.map((L)=>L.id)??[];if(z.length>0)X.set(t(K[_]),z)})}catch(Z){this.logger.warn("OSV advisory lookup failed:",Z)}return X}async fetchVulnerability($){return this.detailCache.get($,async()=>{try{let X=await Z0(`${S0}/v1/vulns/${encodeURIComponent($)}`,{headers:{"User-Agent":"buddy"}});if(!X.ok)return null;return await X.json()}catch(X){return this.logger.debug(`Failed to fetch advisory ${$}:`,X),null}})}}function t($){return`${$.ecosystem}:${$.name}@${$.version}`}function B0($){return $.replace(/^[\^~>=<\s]*v?/,"").trim()}function X1($,X){if(!$||!X)return!1;try{return Bun.semver.order($,X)>=0}catch{return!1}}import Q1 from"process";function W1($){if(!$)return null;let X=$.split("/").filter(Boolean);if(X.length<2)return null;return{owner:X.slice(0,-1).join("/"),name:X[X.length-1]}}var K1=["GITHUB_REPOSITORY","CI_PROJECT_PATH","BITBUCKET_REPO_FULL_NAME"];function Y1($){for(let X of K1){let Q=W1($[X]);if(Q)return Q}return null}function C0($,X=Q1.env){if(!$.repository)return{source:"unresolved",overrodeConfig:!1};let Q=$.repository,K=Y1(X),Z=Boolean(Q.owner&&Q.name);if(!K)return Z?{owner:Q.owner,name:Q.name,source:"config",overrodeConfig:!1}:{source:"unresolved",overrodeConfig:!1};if(Z&&(Q.owner!==K.owner||Q.name!==K.name)){let _=`Configured repository ${`${Q.owner}/${Q.name}`} does not match the checked-out repository ${K.owner}/${K.name}. Using ${K.owner}/${K.name} \u2014 buddy `+"operates on the checked-out repository. Update repository.owner/repository.name in your buddy config to silence this warning.";if(Q.owner=K.owner,Q.name=K.name,$.dashboard?.issueNumber!==void 0)$.dashboard.issueNumber=void 0;return{owner:K.owner,name:K.name,source:"environment",overrodeConfig:!0,warning:_}}if(!Z)return Q.owner||=K.owner,Q.name||=K.name,{owner:K.owner,name:K.name,source:"environment",overrodeConfig:!1};return{owner:Q.owner,name:Q.name,source:"config",overrodeConfig:!1}}class Q0{config;projectPath;logger;scanner;registryClient;eventBus=null;dashboardGenerator;constructor($,X=y.cwd()){this.config=$;this.projectPath=X;this.logger=new R0($.verbose??!1,$.logLevel),U0(this.logger),this.resolveRepositoryConfig(),this.scanner=new c0(this.projectPath,this.logger,this.config.packages?.ignorePaths),this.registryClient=new l0(this.projectPath,this.logger,this.config),this.dashboardGenerator=new K0}async analyzeMajors($,X){if(!this.config.ai?.majorUpgrades?.enabled)return{report:"",draft:!1};let{analyzeGroupMajors:Q}=await import("./chunk-ymwjjyke.js"),{createAiClient:K}=await import("./chunk-ysp81zyt.js"),{ReleaseNotesFetcher:Z}=await import("./chunk-m2qq154g.js"),Y=new Z(this.logger),W=await Q({updates:$,config:this.config,workspace:this.projectPath,baseBranch:this.config.repository?.baseBranch||"main",files:X,ai:K(this.config,this.logger),fetchReleases:(_,z,L)=>Y.fetchSpanReleases(_,z,L),logger:this.logger});return{report:W.report,draft:W.draft}}resolveRepositoryConfig(){let $=C0(this.config);if($.warning)this.logger.warn(`\u26A0\uFE0F ${$.warning}`);else if($.source==="environment")this.logger.info(`Auto-detected repository: ${$.owner}/${$.name} from GITHUB_REPOSITORY`)}async scanForUpdates(){let $=Date.now();this.logger.info("Starting dependency update scan...");try{let X=Date.now(),Q=await this.scanner.scanProject();this.logger.info(`\u23F1\uFE0F Package file scan took ${Date.now()-X}ms`);let K=Q.reduce((x,P)=>x+P.dependencies.length,0),Z=[],Y=Date.now();if(this.config.packages?.ignore&&this.config.packages.ignore.length>0)Z=(await this.registryClient.getOutdatedPackages()).filter((P)=>!this.config.packages.ignore.includes(P.name));else Z=await this.registryClient.getOutdatedPackages();this.logger.info(`\u23F1\uFE0F bun outdated check took ${Date.now()-Y}ms (found ${Z.length} updates)`);let W=Date.now(),_=await this.checkDependencyFilesForUpdates(Q);this.logger.info(`\u23F1\uFE0F Dependency file checks took ${Date.now()-W}ms (found ${_.length} updates)`);let z=Date.now(),L=await this.checkGitHubActionsForUpdates(Q);this.logger.info(`\u23F1\uFE0F GitHub Actions checks took ${Date.now()-z}ms (found ${L.length} updates)`);let O=Date.now(),H=await this.checkDockerfilesForUpdates(Q);this.logger.info(`\u23F1\uFE0F Docker image checks took ${Date.now()-O}ms (found ${H.length} updates)`);let J=Date.now(),j=await this.checkZigForUpdates(Q),q=this.config.packages?.engines===!0?await this.checkEnginesForUpdates(Q):[];this.logger.info(`\u23F1\uFE0F Zig dependency checks took ${Date.now()-J}ms (found ${j.length} updates)`);let{scanCatalogs:I}=await import("./chunk-a4m6bqpq.js"),T=await I(this.projectPath,(x)=>this.registryClient.getLatestVersion(x),{...this.config.packages?.ignore?{ignore:this.config.packages.ignore}:{},logger:this.logger});if(T.entries.length>0)this.logger.info(`\uD83D\uDCE6 pnpm catalogs: ${T.updates.length} update(s) across ${T.entries.length} entr(ies)`);let M=Date.now(),{scanEcosystems:B}=await import("./chunk-wfn702a2.js"),C=await B({dir:this.projectPath,...this.config.packages?.includePrerelease!==void 0?{includePrerelease:this.config.packages.includePrerelease}:{},...this.config.packages?.ignore?{ignore:this.config.packages.ignore}:{},logger:this.logger});if(C.manifests.length>0)this.logger.info(`\u23F1\uFE0F Ecosystem checks took ${Date.now()-M}ms (found ${C.updates.length} updates across ${C.manifests.map((x)=>x.ecosystem).join(", ")})`);let D=[...Z,..._,...L,...H,...j,...q,...C.updates,...T.updates];if(this.config.packages?.ignore&&this.config.packages.ignore.length>0)D=D.filter((x)=>!this.config.packages.ignore.includes(x.name));let b=Date.now();if(this.config.packages?.strategy)D=this.filterUpdatesByStrategy(D,this.config.packages.strategy);this.logger.info(`\u23F1\uFE0F Strategy filtering took ${Date.now()-b}ms`);let R=Date.now();D=await this.filterUpdatesByMinimumReleaseAge(D),this.logger.info(`\u23F1\uFE0F Minimum release age filtering took ${Date.now()-R}ms`),D=this.applyPins(D),D=await this.dropOverriddenUpdates(D,Q),D=this.applyPackageRules(D);let f=Date.now();D=await this.annotateSecurityAdvisories(D),this.logger.info(`\u23F1\uFE0F Security advisory lookup took ${Date.now()-f}ms`);let g=this.config.security?.prioritize??!0,u=Date.now();D=k0(D,{prioritizeSecurity:g}),this.logger.info(`\u23F1\uFE0F Sorting took ${Date.now()-u}ms`);let V=Date.now(),N=this.config.packages?.groups?this.groupUpdatesByConfig(D):_0(D,{prioritizeSecurity:g});this.logger.info(`\u23F1\uFE0F Grouping took ${Date.now()-V}ms`);let W0=Date.now()-$,i={totalPackages:K,updates:D,groups:N,scannedAt:new Date,duration:W0};return this.logger.success(`Scan completed in ${W0}ms. Found ${D.length} updates.`),await this.events.emit("scan.completed",{total:D.length,major:D.filter((x)=>x.updateType==="major").length,minor:D.filter((x)=>x.updateType==="minor").length,patch:D.filter((x)=>x.updateType==="patch").length}),i}catch(X){throw this.logger.error("Failed to scan for updates:",X),X}}prTitleFor($){let X=this.config.pullRequest?.titleFormat;if(!X)return $.title;return z0(X,j0($,{title:$.title},this.config.packages?.strategy))}commitMessageFor($,X){let Q=this.config.pullRequest?.commitMessageFormat,K=Q?z0(Q,j0($,{message:$.title,title:$.title},this.config.packages?.strategy)):$.title;return X?`${K} ${X}`:K}applyPackageRules($){let X=this.config.packages?.rules??[],K=[...o(this.config.packages?.groups),...X];if(K.length===0)return $;let Z=P0($,K);if(Z.length<$.length)this.logger.info(`\uD83D\uDCCB Package rules dropped ${$.length-Z.length} update(s)`);return Z.map((Y)=>Y.update)}static mergeUnique($,X){let Q=[...new Set([...$??[],...X])];return Q.length>0?Q:void 0}labelsFor($,X){let Q=$.updates.some((K)=>(K.securityAdvisories?.length??0)>0);return[...new Set([...X.generateLabels($),...Q?[this.config.security?.label??"security"]:[],...this.config.pullRequest?.labels??[],...this.groupEffectsFor($.updates).labels])]}activeRules(){return[...o(this.config.packages?.groups),...this.config.packages?.rules??[]]}groupEffectsFor($){let X=this.activeRules();if(X.length===0)return O0([]);return O0($.map((Q)=>c(Q,X)))}orderGroupsByPriority($){if(this.activeRules().length===0)return $;return $.map((Q,K)=>({group:Q,index:K,priority:this.groupEffectsFor(Q.updates).prPriority})).sort((Q,K)=>K.priority-Q.priority||Q.index-K.index).map((Q)=>Q.group)}async dropOverriddenUpdates($,X){let Q=X.filter((W)=>W.type==="package.json");if(Q.length===0)return $;let{collectResolutionPins:K,pinBlocksUpdate:Z}=await import("./chunk-qz5nqeza.js"),Y=new Map;for(let W of Q)try{for(let _ of K(JSON.parse(W.content)))Y.set(_.name,{version:_.version,field:_.field})}catch{continue}if(Y.size===0)return $;return $.filter((W)=>{let _=Y.get(W.name);if(!_)return!0;if(!Z({name:W.name,version:_.version,field:_.field},W.newVersion))return!0;return this.logger.info(`\uD83D\uDD12 Skipping ${W.name} \u2192 ${W.newVersion}: ${_.field} pins it to ${_.version}, which would win at install time`),!1})}applyPins($){let X=this.config.packages?.pin;if(!X||Object.keys(X).length===0)return $;let Q=[];for(let K of $){let Z=X[K.name];if(!Z){Q.push(K);continue}if(K.currentVersion===Z){this.logger.info(`\uD83D\uDCCC ${K.name} is pinned to ${Z}, skipping update to ${K.newVersion}`);continue}this.logger.info(`\uD83D\uDCCC ${K.name} is pinned to ${Z}, retargeting update from ${K.newVersion}`),Q.push({...K,newVersion:Z,updateType:m(K.currentVersion,Z)})}return Q}async annotateSecurityAdvisories($){if(this.config.security?.enabled===!1||$.length===0)return $;try{let Q=await new a(this.logger).annotateUpdates($,this.config.security?.minimumSeverity??"low"),K=Q.filter((Z)=>Z.securityAdvisories?.length);if(K.length>0)await this.events.emit("security.advisories",{packages:K.map((Z)=>({name:Z.name,severity:Z.securityAdvisories?.[0]?.severity??"unknown"}))});return Q}catch(X){return this.logger.warn("Security advisory lookup failed, continuing without it:",X),$}}async createPullRequests($){let X=Date.now();this.logger.info("Creating pull requests for updates...");try{if(!this.config.repository){this.logger.error("\u274C Repository configuration required for PR creation"),this.logger.info("Configure repository.provider, repository.owner, repository.name in buddy.config.ts");return}if(!this.config.repository.owner||!this.config.repository.name){this.logger.error("\u274C Repository owner and name are required for PR creation"),this.logger.info("Set them in buddy.config.ts or ensure GITHUB_REPOSITORY env var is available");return}let Q=y.env.GITHUB_TOKEN,K=y.env.BUDDY_TOKEN||y.env.BUDDY_BOT_TOKEN;if(!Q&&!K){this.logger.error("\u274C GITHUB_TOKEN or BUDDY_TOKEN environment variable required for PR creation");return}let Z=Q||K,Y=!!K;if(K)this.logger.info("\u2705 BUDDY_TOKEN detected - workflow file permissions enabled");else this.logger.info("\u2139\uFE0F No BUDDY_TOKEN \u2014 workflow file updates will be skipped");let W=await X0({provider:this.config.repository.provider,owner:this.config.repository.owner,name:this.config.repository.name,token:Z,...K?{workflowToken:K}:{},...this.config.repository.apiUrl?{apiUrl:this.config.repository.apiUrl}:{}},{logger:this.logger}),_=new y0(this.config),z=this.config.maxPRsPerRun??10,L=0,O=this.orderGroupsByPriority($.groups),H=[];for(let j of O)try{let q=Date.now();if(this.logger.info(`Creating PR for group: ${j.name} (${j.updates.length} updates)`),j.updates.length>0&&j.updates.every((E)=>E.file.includes(".github/workflows/"))&&!Y){this.logger.warn(`\u26A0\uFE0F Skipping group ${j.name} \u2014 workflow-file updates require BUDDY_TOKEN with the workflow scope`);continue}try{let{spawn:E}=await import("child_process"),w=(A,F)=>{return new Promise((k,U)=>{let v=E(A,F,{stdio:"pipe"});v.on("close",(s)=>s===0?k():U(Error(`Git command failed with code ${s}`))),v.on("error",U)})},S=this.config.repository.baseBranch||"main";await w("git",["checkout",S]),await w("git",["reset","--hard","HEAD"]),await w("git",["clean","-fd"])}catch(E){this.logger.warn("\u26A0\uFE0F Failed to reset to clean state for early file-change check, continuing anyway:",E)}let T=await this.generateAllFileUpdates(j.updates);if(T.length===0){this.logger.info(`\u2139\uFE0F No file changes for group ${j.name}, skipping \u2014 leaving branches untouched`);continue}let M=this.prTitleFor(j),B=Date.now(),C=await _.generateBody(j),D=Date.now()-B;this.logger.info(`\u23F1\uFE0F PR body generation took ${D}ms`);let b=await this.analyzeMajors(j.updates,T.map((E)=>E.path)),R=m0(C,b.report),f=await W.getPullRequests("open"),g=this.generateBranchName(j),u=`buddy/update-${j.name.toLowerCase().replace(/\s+/g,"-")}-`,V=f.find((E)=>(E.head===g||E.title===M||E.head.startsWith(u)||this.isSimilarPRTitle(E.title,M))&&(E.author==="github-actions[bot]"||E.author.includes("buddy")||E.head.startsWith("buddy/"))&&!E.head.includes("renovate/")&&!E.head.includes("dependabot/")&&!E.author.toLowerCase().includes("renovate")&&!E.author.toLowerCase().includes("dependabot"));if(V){if(this.logger.info(`\uD83D\uDD04 Found existing PR #${V.number}: ${V.title}`),this.shouldAutoClosePR(V,j.updates)){this.logger.info(`\uD83D\uDD12 Auto-closing PR #${V.number} due to config change`);try{let A=this.generateCloseReason(V);try{await W.createComment(V.number,A)}catch(F){this.logger.warn(`\u26A0\uFE0F Could not add close reason comment to PR #${V.number}:`,F)}await W.closePullRequest(V.number),await this.events.emit("pr.closed",{number:V.number,title:V.title,reason:"no longer produced by the current configuration"});try{await W.deleteBranch(V.head),this.logger.success(`\u2705 Auto-closed PR #${V.number} and deleted branch ${V.head}`)}catch(F){this.logger.warn(`\u26A0\uFE0F Auto-closed PR #${V.number} but could not delete ${V.head}:`,F)}continue}catch(A){this.logger.error(`\u274C Failed to auto-close PR #${V.number}:`,A)}}let w=this.checkIfUpdatesMatch(V.body,j.updates),S=[];if(w&&W.getPullRequestFiles)try{let{missingLockFiles:A}=await import("./chunk-fjp4k18r.js");S=A(await W.getPullRequestFiles(V.number))}catch(A){this.logger.warn(`\u26A0\uFE0F Could not list the files of PR #${V.number}; trusting it: ${$0(A)}`)}if(w&&S.length===0){this.logger.info("\u2705 Existing PR has the same updates, skipping creation");continue}else{if(S.length>0)this.logger.info(`\uD83D\uDD12 PR #${V.number} has the same updates but does not regenerate ${S.join(", ")}; refreshing it`);this.logger.info("\uD83D\uDD04 Updates differ, will update existing PR with new content");let A=V.head;try{let{spawn:U}=await import("child_process"),v=(s,n0)=>{return new Promise((d0,q0)=>{let D0=U(s,n0,{stdio:"pipe"});D0.on("close",(E0)=>{if(E0===0)d0();else q0(Error(`Git command failed with code ${E0}`))}),D0.on("error",q0)})};await v("git",["checkout","main"]),await v("git",["reset","--hard","HEAD"]),await v("git",["clean","-fd"]),this.logger.info(`\uD83E\uDDF9 Reset to clean main state before updating existing PR ${V.number}`)}catch(U){this.logger.warn("\u26A0\uFE0F Failed to reset to clean state, continuing anyway:",U)}let F=await this.generateAllFileUpdates(j.updates);if(F.length===0)this.logger.warn(`\u2139\uFE0F No file changes generated for existing PR ${V.number}, updating metadata only`);else{this.logger.info(`\uD83D\uDCDD Regenerated ${F.length} file changes for existing PR ${V.number}`);try{let{hasBranchDifferences:U}=await import("./chunk-3zk2ye6r.js");if(!await U(F,A))this.logger.info(`\u2139\uFE0F No content differences for ${A}; recreating from ${this.config.repository.baseBranch||"main"} with same dependency changes to keep branch up-to-date`),await W.commitChanges(A,this.commitMessageFor(j,"(rebased)"),F,this.config.repository.baseBranch||"main"),this.logger.success(`\u2705 Recreated ${A} from ${this.config.repository.baseBranch||"main"} (dependency versions unchanged)`);else await W.commitChanges(A,this.commitMessageFor(j,"(updated)"),F,this.config.repository.baseBranch||"main"),this.logger.success(`\u2705 Recreated branch ${A} with latest dependency versions`)}catch(U){this.logger.warn("\u26A0\uFE0F Failed to compare branch content, proceeding with commit:",U),await W.commitChanges(A,this.commitMessageFor(j,"(updated)"),F,this.config.repository.baseBranch||"main"),this.logger.success(`\u2705 Recreated branch ${A} with latest dependency versions`)}}let k=this.labelsFor(j,_);await W.updatePullRequest(V.number,{title:M,body:R,labels:k,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:V.number,title:M,url:V.url}),this.logger.success(`\u2705 Updated existing PR #${V.number}: ${M}`),this.logger.info(`\uD83D\uDD17 ${V.url}`);continue}}if(L>=z){this.logger.warn(`\u26A0\uFE0F Rate limit reached: already created ${L} PRs this run (max: ${z}). Skipping remaining groups.`);break}let N=this.generateBranchName(j);if(await W.branchExists(N)){this.logger.info(`\uD83D\uDD04 Branch ${N} already exists, checking for associated PR...`);let E=f.find((S)=>S.head===N);if(E){this.logger.info(`\u2705 Found existing PR #${E.number} for branch ${N}, updating it...`);let S=await this.generateAllFileUpdates(j.updates);if(S.length>0)await W.commitChanges(N,this.commitMessageFor(j,"(updated)"),S,this.config.repository.baseBranch||"main");let A=this.labelsFor(j,_);await W.updatePullRequest(E.number,{title:M,body:R,labels:A,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:E.number,title:M,url:E.url}),this.logger.success(`\u2705 Updated existing PR #${E.number}: ${M}`),this.logger.info(`\uD83D\uDD17 ${E.url}`);continue}let w=!1;try{let A=(p(W,"reopenPullRequests","reopenPullRequest")?await W.getPullRequests("closed"):[]).find((F)=>{if(F.head!==N)return!1;if(F.mergedAt)return!1;return Date.now()-(F.updatedAt?.getTime()??0)<86400000});if(A){this.logger.info(`\uD83D\uDD04 Found recently-closed PR #${A.number} for branch ${N}, reopening...`);let F=await this.generateAllFileUpdates(j.updates);if(F.length>0)await W.commitChanges(N,this.commitMessageFor(j,"(reopened)"),F,this.config.repository.baseBranch||"main");await W.reopenPullRequest(A.number);let k=this.labelsFor(j,_);await W.updatePullRequest(A.number,{title:M,body:R,labels:k,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:A.number,title:M,url:A.url}),this.logger.success(`\u2705 Reopened and updated PR #${A.number}: ${M}`),this.logger.info(`\uD83D\uDD17 ${A.url}`),w=!0}}catch(S){this.logger.warn("\u26A0\uFE0F Failed to check/reopen closed PRs:",S)}if(w)continue;this.logger.info(`\uD83E\uDDF9 Branch ${N} exists but has no open PR, cleaning up...`);try{await W.deleteBranch(N)}catch(S){this.logger.warn(`\u26A0\uFE0F Failed to delete orphaned branch ${N}:`,S)}}let i=!1;try{let w=(p(W,"reopenPullRequests","reopenPullRequest")?await W.getPullRequests("closed"):[]).find((S)=>{if(S.head!==N&&!this.isSimilarPRTitle(S.title,M))return!1;if(!S.head.startsWith("buddy/")&&S.author!=="github-actions[bot]")return!1;if(S.mergedAt)return!1;return Date.now()-(S.updatedAt?.getTime()??0)<604800000});if(w){this.logger.info(`\uD83D\uDD04 Found recently-closed PR #${w.number} (branch may have been deleted), recreating branch and reopening...`),await W.createBranch(N,this.config.repository.baseBranch||"main");let S=await this.generateAllFileUpdates(j.updates);if(S.length>0)await W.commitChanges(N,this.commitMessageFor(j,"(reopened)"),S,this.config.repository.baseBranch||"main");await W.reopenPullRequest(w.number);let A=this.labelsFor(j,_);await W.updatePullRequest(w.number,{title:M,body:R,labels:A,reviewers:this.config.pullRequest?.reviewers,teamReviewers:this.config.pullRequest?.teamReviewers,assignees:this.config.pullRequest?.assignees}),await this.events.emit("pr.updated",{number:w.number,title:M,url:w.url}),this.logger.success(`\u2705 Reopened and updated PR #${w.number}: ${M}`),this.logger.info(`\uD83D\uDD17 ${w.url}`),i=!0}}catch(E){this.logger.warn("\u26A0\uFE0F Failed to check/reopen closed PRs:",E)}if(i)continue;await W.createBranch(N,this.config.repository.baseBranch||"main");try{let{spawn:E}=await import("child_process"),w=(S,A)=>{return new Promise((F,k)=>{let U=E(S,A,{stdio:"pipe"});U.on("close",(v)=>{if(v===0)F();else k(Error(`Git command failed with code ${v}`))}),U.on("error",k)})};await w("git",["checkout","main"]),await w("git",["reset","--hard","HEAD"]),await w("git",["clean","-fd"]),this.logger.info(`\uD83E\uDDF9 Reset to clean main state before generating updates for ${j.name}`)}catch(E){this.logger.warn("\u26A0\uFE0F Failed to reset to clean state, continuing anyway:",E)}let x=await this.generateAllFileUpdates(j.updates);if(x.length===0){this.logger.warn(`\u2139\uFE0F No file changes generated for group ${j.name}, skipping PR creation`);continue}let P=!1;for(let E of x)try{let w=await import("fs");if(w.existsSync(E.path)){if(w.readFileSync(E.path,"utf-8")!==E.content){P=!0;break}}else{P=!0;break}}catch{P=!0;break}if(!P){this.logger.warn(`\u2139\uFE0F No actual content changes for group ${j.name}, skipping PR creation`);continue}this.logger.info(`\uD83D\uDCDD Generated ${x.length} file changes for ${j.name}`),await W.commitChanges(N,this.commitMessageFor(j),x,this.config.repository.baseBranch||"main");let J0=this.groupEffectsFor(j.updates),L0=this.labelsFor(j,_),h=await W.createPullRequest({title:M,body:R,head:N,base:this.config.repository.baseBranch||"main",draft:b.draft,reviewers:Q0.mergeUnique(this.config.pullRequest?.reviewers,J0.reviewers),teamReviewers:this.config.pullRequest?.teamReviewers,assignees:Q0.mergeUnique(this.config.pullRequest?.assignees,J0.assignees),labels:L0});L++,this.logger.success(`\u2705 Created PR #${h.number}: ${h.title} (${L}/${z} this run)`),this.logger.info(`\uD83D\uDD17 ${h.url}`),await this.events.emit("pr.created",{number:h.number,title:h.title,url:h.url,packages:j.updates.map((E)=>E.name)}),await this.queueAutoMerge(W,h,j.updates,L0);let o0=Date.now()-q;this.logger.info(`\u23F1\uFE0F Total group processing took ${o0}ms`)}catch(q){if(q instanceof Error&&q.name==="WorkflowPermissionError"){this.logger.warn(`\u26A0\uFE0F Skipping group ${j.name}: ${q.message}`);continue}this.logger.error(`\u274C Failed to create PR for group ${j.name}:`,q),H.push({name:j.name,error:q})}let J=Date.now()-X;if(H.length>0){let j=H.map((q)=>`${q.name}: ${$0(q.error)}`).join(`
88
88
  `);throw Error(`Could not create pull requests for ${H.length} of ${O.length} group(s):
89
- ${j}`)}this.logger.success(`\u2705 Completed PR creation for ${$.groups.length} group(s) in ${J}ms`)}catch(Q){throw this.logger.error("Failed to create pull requests:",Q),Q}}shouldRespectVersion($){if(!(this.config.packages?.respectLatest??!0))return!1;let Q=["latest","*","main","master","develop","dev"],K=$.toLowerCase().trim();return Q.includes(K)}async checkDependencyFilesForUpdates($){let{isDependencyFile:X}=await import("./chunk-ecs7b2kg.js"),{resolveDependencyFile:Q}=await import("./chunk-9cnq8y3d.js"),K=[],Z=$.filter((_)=>X(_.path));this.logger.info(`\u26A1 Checking ${Z.length} dependency files in parallel...`);let Y=Z.map(async(_)=>{try{this.logger.info(`Checking dependency file: ${_.path}`);let z=await Q(_.path),L=[];for(let O of z.allDependencies||[]){if(this.shouldRespectVersion(O.constraint)){this.logger.debug(`Skipping ${O.name} - version "${O.constraint}" should be respected`);continue}if(O.constraint!==O.version&&O.version){let H=O.constraint.replace(/^[\^~>=<]+/,"");if(!this.isNewerVersion(H,O.version)){this.logger.debug(`Skipping ${O.name} - latest (${O.version}) is not newer than constraint (${H})`);continue}let J=m(H,O.version),j=O.version;L.push({name:O.name,currentVersion:O.constraint,newVersion:j,updateType:J,dependencyType:"dependencies",file:_.path,metadata:void 0,releaseNotesUrl:void 0,changelogUrl:void 0,homepage:void 0})}}return L}catch(z){return this.logger.error(`Failed to check dependency file ${_.path}:`,z),[]}}),W=await Promise.all(Y);return K.push(...W.flat()),K}async checkZigForUpdates($){let{isZigManifest:X}=await import("./chunk-w6bd9r6p.js"),{fetchLatestZigVersion:Q,fetchZigHash:K,isZigAvailable:Z,parseZigSource:Y,zigUrlForVersion:W}=await import("./chunk-te6etc5c.js"),_=$.filter((H)=>X(H.path));if(_.length===0)return[];if(!await Z())return this.logger.warn("\u26A0\uFE0F Found Zig manifests but the zig toolchain is not available. "+"Skipping Zig updates: their content-addressed hashes cannot be recomputed without `zig fetch`."),[];let z=y.env.GITHUB_TOKEN||y.env.BUDDY_TOKEN||y.env.BUDDY_BOT_TOKEN,L=_.flatMap((H)=>H.dependencies.filter((J)=>J.type==="zig-dependencies").map((J)=>({file:H,dep:J})));return this.logger.info(`\u26A1 Checking ${L.length} Zig dependencies...`),(await Promise.all(L.map(async({file:H,dep:J})=>{let j=J.metadata?.url;if(!j)return this.logger.debug(`Skipping ${J.name}: no URL recorded`),null;let q=Y(j);if(!q)return this.logger.debug(`Skipping ${J.name}: only GitHub-hosted Zig dependencies can be checked`),null;let I=await Q(q,z);if(!I||I===J.currentVersion)return null;let T=W(j,I),M=await K(T);if(!M)return this.logger.warn(`\u26A0\uFE0F Skipping ${J.name} ${J.currentVersion} \u2192 ${I}: could not compute its package hash`),null;return this.logger.info(`\uD83D\uDCE6 ${J.name}: ${J.currentVersion} \u2192 ${I}`),{name:J.name,currentVersion:J.currentVersion,newVersion:I,updateType:m(J.currentVersion,I),dependencyType:"zig-dependencies",file:H.path,resolved:{url:T,hash:M}}}))).filter((H)=>H!==null)}async checkGitHubActionsForUpdates($){let{fetchActionTagCommit:X,fetchLatestActionVersion:Q,isGitHubActionsFile:K,sameActionVersion:Z}=await import("./chunk-s7da3h7c.js"),Y=[],W=$.filter((J)=>K(J.path));this.logger.info(`\uD83D\uDD0D Found ${W.length} GitHub Actions workflow files`);let _=[];for(let J of W){let j=J.dependencies.filter((q)=>q.type==="github-actions");this.logger.info(`Found ${j.length} GitHub Actions in ${J.path}`),j.forEach((q)=>_.push({file:J,dep:q}))}this.logger.info(`\u26A1 Checking ${_.length} GitHub Actions in parallel...`);let z=_.map(async({file:J,dep:j})=>{try{this.logger.info(`Checking action: ${j.name}@${j.currentVersion}`);let q=await Q(j.name);if(q&&j.metadata?.pinnedSha){let I=j.metadata.pinnedVersion;if(!I)return this.logger.info(`Skipping ${j.name}@${j.currentVersion}: a SHA pin without a version comment cannot be compared`),null;if(Z(I,q))return this.logger.info(`No update needed for ${j.name}: already pinned to ${q}`),null;let T=await X(j.name,q);if(!T)return this.logger.warn(`Could not resolve ${j.name}@${q} to a commit; leaving the SHA pin alone`),null;let M=m(I,q);return this.logger.info(`Update available: ${j.name} ${I} \u2192 ${q} (${M}, pinned)`),{name:j.name,currentVersion:j.currentVersion,newVersion:q,updateType:M,dependencyType:"github-actions",file:J.path,metadata:void 0,resolved:{sha:T},releaseNotesUrl:`${d(this.config)}/${j.name}/releases`,changelogUrl:void 0,homepage:`${d(this.config)}/${j.name}`}}if(q)if(this.logger.info(`Latest version for ${j.name}: ${q}`),q!==j.currentVersion){let I=m(j.currentVersion,q);return this.logger.info(`Update available: ${j.name} ${j.currentVersion} \u2192 ${q} (${I})`),{name:j.name,currentVersion:j.currentVersion,newVersion:q,updateType:I,dependencyType:"github-actions",file:J.path,metadata:void 0,releaseNotesUrl:`${d(this.config)}/${j.name}/releases`,changelogUrl:void 0,homepage:`${d(this.config)}/${j.name}`}}else this.logger.info(`No update needed for ${j.name}: already at ${q}`);else this.logger.warn(`Could not fetch latest version for ${j.name}`);return null}catch(q){return this.logger.warn(`Failed to check version for action ${j.name}:`,q),null}}),O=(await Promise.all(z)).filter((J)=>J!==null);Y.push(...O),this.logger.info(`Generated ${Y.length} GitHub Actions updates`);let H=Y.reduce((J,j)=>{if(!J.find((I)=>I.name===j.name&&I.currentVersion===j.currentVersion&&I.newVersion===j.newVersion&&I.file===j.file))J.push(j);return J},[]);return this.logger.info(`After deduplication: ${H.length} unique GitHub Actions updates`),H}async checkEnginesForUpdates($){let{bumpEngineConstraint:X,engineUpdateType:Q,resolveEngineVersion:K}=await import("./chunk-rpkwbqr8.js"),{fetchLatestActionVersion:Z}=await import("./chunk-s7da3h7c.js"),Y=$.flatMap((z)=>z.dependencies.filter((L)=>L.type==="engines").map((L)=>({file:z,dep:L})));if(Y.length===0)return[];this.logger.info(`\u26A1 Checking ${Y.length} engine constraint(s)...`);let W={npm:(z)=>this.registryClient.getLatestVersion(z),github:(z)=>Z(z)},_=Y.map(async({file:z,dep:L})=>{try{let O=await K(L.name,W);if(!O)return null;let H=X(L.currentVersion,O);if(!H)return this.logger.debug(`${L.name} ${L.currentVersion} already admits ${O}`),null;return this.logger.info(`Update available: ${L.name} ${L.currentVersion} \u2192 ${H}`),{name:L.name,currentVersion:L.currentVersion,newVersion:H,updateType:Q(L.currentVersion,H),dependencyType:"engines",file:z.path}}catch(O){return this.logger.warn(`Could not check engine ${L.name}:`,O),null}});return(await Promise.all(_)).filter((z)=>z!==null)}async checkDockerfilesForUpdates($){let{isDockerfile:X}=await import("./chunk-sy3h7j1x.js"),{fetchLatestDockerImageVersion:Q}=await import("./chunk-sy3h7j1x.js"),K=[],Z=$.filter((O)=>X(O.path));this.logger.info(`\uD83D\uDD0D Found ${Z.length} Dockerfile(s)`);let Y=[];for(let O of Z){let H=O.dependencies.filter((J)=>J.type==="docker-image");this.logger.info(`Found ${H.length} Docker images in ${O.path}`),H.forEach((J)=>Y.push({file:O,dep:J}))}this.logger.info(`\u26A1 Checking ${Y.length} Docker images in parallel...`);let W=Y.map(async({file:O,dep:H})=>{try{if(this.logger.info(`Checking Docker image: ${H.name}:${H.currentVersion}`),this.shouldRespectVersion(H.currentVersion))return this.logger.debug(`Skipping ${H.name} - version "${H.currentVersion}" should be respected`),null;let J=await Q(H.name,H.currentVersion,{...this.config.registries?.docker?{registries:this.config.registries.docker}:{},...this.config.packages?.includePrerelease!==void 0?{includePrerelease:this.config.packages.includePrerelease}:{}});if(J)if(this.logger.info(`Latest version for ${H.name}: ${J}`),J!==H.currentVersion){let j=m(H.currentVersion,J);return this.logger.info(`Update available: ${H.name} ${H.currentVersion} \u2192 ${J} (${j})`),{name:H.name,currentVersion:H.currentVersion,newVersion:J,updateType:j,dependencyType:"docker-image",file:O.path,metadata:void 0,releaseNotesUrl:`https://hub.docker.com/r/${H.name}/tags`,changelogUrl:void 0,homepage:`https://hub.docker.com/r/${H.name}`}}else this.logger.info(`No update needed for ${H.name}: already at ${J}`);else this.logger.warn(`Could not fetch latest version for Docker image ${H.name}`);return null}catch(J){return this.logger.warn(`Failed to check version for Docker image ${H.name}:`,J),null}}),z=(await Promise.all(W)).filter((O)=>O!==null);K.push(...z),this.logger.info(`Generated ${K.length} Docker image updates`);let L=K.reduce((O,H)=>{if(!O.find((j)=>j.name===H.name&&j.currentVersion===H.currentVersion&&j.newVersion===H.newVersion&&j.file===H.file))O.push(H);return O},[]);return this.logger.info(`After deduplication: ${L.length} unique Docker image updates`),L}isNewerVersion($,X){try{return Bun.semver.order(X.replace(/^[v^~>=<@]+/,""),$.replace(/^[v^~>=<@]+/,""))>0}catch{return!1}}readDeclaredNpmVersions(){let $=new Map;try{let X=G("fs"),K=G("path").join(this.projectPath,"package.json");if(!X.existsSync(K))return $;let Z=JSON.parse(X.readFileSync(K,"utf8"));for(let Y of["dependencies","devDependencies","peerDependencies","optionalDependencies"])for(let[W,_]of Object.entries(Z[Y]??{}))if(typeof _==="string"&&!$.has(W))$.set(W,_)}catch(X){this.logger.debug("Could not read declared versions from package.json:",X)}return $}compareVersionsSafe($,X){try{let Q=X.replace(/^[v^~>=<@]+/,""),K=$.replace(/^[v^~>=<@]+/,"");if(!/^\d+\.\d+/.test(Q)||!/^\d+\.\d+/.test(K))return"failed";return Bun.semver.order(Q,K)>0?"behind":"at-or-beyond"}catch{return"failed"}}async generateAllFileUpdates($){let X=[],Q=$.filter((H)=>H.file.endsWith("package.json")&&H.dependencyType!=="engines"&&!H.file.includes(".yaml")&&!H.file.includes(".yml")&&!H.file.includes(".github/workflows/")),K=$.filter((H)=>H.dependencyType==="engines");if(K.length>0){let{applyEngineUpdates:H}=await import("./chunk-rpkwbqr8.js"),J=new Map;for(let j of K)J.set(j.file,[...J.get(j.file)??[],j]);for(let[j,q]of J)try{let I=N0.readFileSync(j,"utf-8"),T=H(I,q);if(T===I){this.logger.warn(`\u26A0\uFE0F No engine changes written to ${j}`);continue}X.push({path:j,content:T,type:"update"})}catch(I){this.logger.warn(`Failed to update engines in ${j}:`,I)}}let Z=new Map;for(let H of Q){if(!Z.has(H.file))Z.set(H.file,[]);Z.get(H.file).push(H)}for(let[H,J]of Z)try{let j=N0.readFileSync(H,"utf-8"),q=JSON.parse(j);for(let I of J){let T=!1,M=I.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),B=["dependencies","devDependencies","peerDependencies","optionalDependencies"];for(let C of B)if(q[C]&&q[C][M]){let b=q[C][M].match(/^(\D*)/),R=b?b[1]:"",f=M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=new RegExp(`("${g}"\\s*:\\s*\\{[^}]*?)("${f}"\\s*:\\s*")([^"]+)(")([^}]*?\\})`,"gs"),V=`${R}${I.newVersion}`;j=j.replace(u,`$1$2${V}$4$5`),T=!0;break}if(!T)this.logger.warn(`Package ${M} not found in ${H}`)}X.push({path:H,content:j,type:"update"})}catch(j){this.logger.warn(`Failed to update ${H}:`,j)}let Y=$.filter((H)=>{let J=H.file.toLowerCase();return(J.endsWith("deps.yaml")||J.endsWith("deps.yml")||J.endsWith("dependencies.yaml")||J.endsWith("dependencies.yml"))&&!H.file.includes(".github/workflows/")});if(Y.length>0)try{let{generateDependencyFileUpdates:H}=await import("./chunk-ecs7b2kg.js"),J=await H(Y);X.push(...J)}catch(H){this.logger.error("Failed to generate dependency file updates:",H)}let W=$.filter((H)=>H.file.endsWith("composer.json")||H.file.endsWith("composer.lock"));if(W.length>0)try{let{generateComposerUpdates:H}=await import("./chunk-e4bcngja.js"),J=await H(W);X.push(...J)}catch(H){this.logger.error("Failed to generate Composer updates:",H)}let _=$.filter((H)=>H.file.includes(".github/workflows/"));if(_.length>0)try{let{generateGitHubActionsUpdates:H}=await import("./chunk-s7da3h7c.js"),J=await H(_);X.push(...J)}catch(H){this.logger.error("Failed to generate GitHub Actions updates:",H)}let z=$.filter((H)=>H.dependencyType==="docker-image");if(z.length>0)try{let{generateDockerfileUpdates:H}=await import("./chunk-sy3h7j1x.js"),J=await H(z,this.config.registries?.docker);X.push(...J)}catch(H){this.logger.error("Failed to generate Dockerfile updates:",H)}let L=$.filter((H)=>H.dependencyType==="zig-dependencies");if(L.length>0)try{let{generateZigManifestUpdates:H}=await import("./chunk-w6bd9r6p.js"),J=await H(L);X.push(...J)}catch(H){this.logger.error("Failed to generate Zig manifest updates:",H)}let O=$.filter((H)=>H.dependencyType==="catalog");if(O.length>0)try{let{applyCatalogUpdates:H}=await import("./chunk-sx8pyc83.js"),J=O[0].file,j=await Bun.file(e(this.projectPath,J)).text(),q=H(j,O);if(q===j)this.logger.warn(`\u26A0\uFE0F No catalog changes written to ${J}`);else X.push({path:J,content:q,type:"update"})}catch(H){this.logger.error("Failed to generate pnpm catalog updates:",H)}return X.push(...await this.generateAdapterFileUpdates($)),X}async generateAdapterFileUpdates($){let{adapterNamed:X}=await import("./chunk-kzgyhhtz.js"),Q=new Map;for(let Y of $){if(!X(Y.dependencyType))continue;let W=Q.get(Y.file);if(W)W.push(Y);else Q.set(Y.file,[Y])}let K=[],Z=new Set;for(let[Y,W]of Q){let _=X(W[0].dependencyType);if(!_)continue;Z.add(_.name);try{let z=e(this.projectPath,Y),L=await Bun.file(z).text(),O=L;for(let H of W)O=_.applyUpdate(O,{name:H.name,currentVersion:H.currentVersion,newVersion:H.newVersion,section:H.dependencyType});if(O===L){this.logger.warn(`\u26A0\uFE0F ${_.name}: no changes written to ${Y}`);continue}K.push({path:Y,content:O,type:"update"})}catch(z){this.logger.error(`Failed to write ${_.name} updates to ${Y}:`,z)}}return[...K,...await this.regenerateAdapterLockfiles(K,[...Z])]}async regenerateAdapterLockfiles($,X){if($.length===0||X.length===0)return[];let{regenerateLockfiles:Q}=await import("./chunk-kzgyhhtz.js");try{for(let W of $)await Bun.write(e(this.projectPath,W.path),W.content)}catch(W){return this.logger.warn(`\u26A0\uFE0F Could not stage manifests for lockfile regeneration: ${W}`),[]}let{regenerated:K,notes:Z}=await Q(this.projectPath,X);for(let W of Z)this.logger.info(`\u2139\uFE0F ${W}`);let Y=[];for(let W of K)try{Y.push({path:W,content:await Bun.file(e(this.projectPath,W)).text(),type:"update"}),this.logger.info(`\uD83D\uDD12 Regenerated ${W}`)}catch(_){this.logger.warn(`\u26A0\uFE0F Could not read the regenerated ${W}: ${_}`)}return Y}async run(){let $=await this.scanForUpdates();if($.updates.length===0)return this.logger.info("No updates available!"),$;if(this.config.pullRequest)await this.createPullRequests($);return $}async checkPackages($){return this.logger.info(`Checking specific packages: ${$.join(", ")}`),this.applyStrategy(await this.registryClient.getUpdatesForPackages($))}async checkPackagesWithPattern($){return this.logger.info(`Checking packages with pattern: ${$}`),this.applyStrategy(await this.registryClient.getUpdatesWithPattern($))}applyStrategy($){let X=this.config.packages?.strategy;return X?this.filterUpdatesByStrategy($,X):$}filterUpdatesByStrategy($,X){if(X==="all")return $;return $.filter((Q)=>h0(X,Q.updateType))}async filterUpdatesByMinimumReleaseAge($){let X=this.config.packages?.minimumReleaseAge??0,Q=this.activeRules(),K=Q.some((z)=>z.minimumReleaseAge!==void 0);if(X===0&&!K)return $;this.logger.info(`Applying minimum release age filter (global ${X} minutes${K?", with per-rule overrides":""}) in parallel...`);let Z=$.map(async(z)=>{try{let L=(Q.length>0?c(z,Q).minimumReleaseAge:void 0)??X;if(L===0)return z;if(await this.registryClient.meetsMinimumReleaseAge(z.name,z.newVersion,z.dependencyType,L))return z;else return this.logger.debug(`Filtered out ${z.name}@${z.newVersion} (${z.dependencyType}) \u2014 held for ${L} minutes after publication`),null}catch(L){return this.logger.warn(`Error checking release age for ${z.name}@${z.newVersion} (${z.dependencyType}), including update:`,L),z}}),W=(await Promise.all(Z)).filter((z)=>z!==null),_=$.length-W.length;if(_>0)this.logger.info(`Filtered out ${_} updates due to minimum release age requirement`);return W}groupUpdatesByConfig($){let X=[],{grouped:Q,remaining:K}=this.groupByRuleNames($);X.push(...Q);let Z=[...K];if(this.config.packages?.groups)for(let Y of this.config.packages.groups){let W=[],{Glob:_}=globalThis.Bun,z=new Set;for(let O of Y.patterns){let H;try{H=new _(O)}catch(J){this.logger.warn(`Invalid group pattern '${O}':`,J);continue}Z.forEach((J,j)=>{if(!z.has(j)&&H.match(J.name))W.push(J),z.add(j)})}if(z.size>0){for(let O=Z.length-1;O>=0;O--)if(z.has(O))Z.splice(O,1)}let L=W;if(Y.strategy)L=this.filterUpdatesByStrategy(W,Y.strategy);if(L.length>0)X.push({name:Y.name,updates:L,updateType:this.getHighestUpdateType(L),title:`chore(deps): update ${Y.name}`,body:`Update ${L.length} packages in ${Y.name} group`})}if(Z.length>0){let Y=_0(Z);X.push(...Y)}return X}groupByRuleNames($){let X=this.config.packages?.rules??[];if(X.length===0)return{grouped:[],remaining:$};let Q=new Map,K=[];for(let Y of $){let W=c(Y,X).groupName;if(!W){K.push(Y);continue}let _=Q.get(W);if(_)_.push(Y);else Q.set(W,[Y])}return{grouped:[...Q.entries()].map(([Y,W])=>({name:Y,updates:W,updateType:this.getHighestUpdateType(W),title:`chore(deps): update ${Y}`,body:`Update ${W.length} packages in ${Y} group`})),remaining:K}}getHighestUpdateType($){if($.some((X)=>X.updateType==="major"))return"major";if($.some((X)=>X.updateType==="minor"))return"minor";return"patch"}generateBranchName($){return`buddy/update-${$.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}`}isSimilarPRTitle($,X){if($.toLowerCase()===X.toLowerCase())return!0;let Q=$.toLowerCase(),K=X.toLowerCase(),Z=Q.includes("github actions"),Y=K.includes("github actions");if(Z&&Y)return!0;if(Z!==Y)return!1;let W=Q.includes("docker image"),_=K.includes("docker image");if(W&&_)return!0;if(W!==_)return!1;let z=[/update all non-major/i,/update \d+ dependenc(y|ies)/i,/update.*\(minor\)/i,/update.*\(patch\)/i,/update.*\(major\)/i],L=z.some((H)=>H.test($)),O=z.some((H)=>H.test(X));if(L&&O){let H=Q.includes("(major)")||Q.includes("major update"),J=K.includes("(major)")||K.includes("major update");return H===J}if(K.includes("update dependency ")){let H=X.match(/update dependency (\S+)/i),J=$.match(/update dependency (\S+)/i);if(H&&J)return H[1]===J[1]}if(L!==O)return!1;if(Q.includes("dependency ")&&K.includes("dependency "))return!1;return!1}checkIfUpdatesMatch($,X){if(!$)return!1;let Q=this.extractPackageUpdatesFromPRBody($),K=new Map;for(let Z of Q)K.set(Z.name,{from:Z.currentVersion,to:Z.newVersion});for(let Z of X){let Y=K.get(Z.name);if(!Y)return!1;let W=Y.to.replace(/^[v^~>=<]+/,""),_=Z.newVersion.replace(/^[v^~>=<]+/,"");if(W!==_)return!1}return K.size===X.length}shouldAutoClosePR($,X){if(this.shouldAutoCloseForRespectLatest($))return!0;if(this.shouldAutoCloseForIgnorePaths($))return!0;if(this.shouldAutoCloseForRemovedFiles($))return!0;return!1}shouldAutoCloseForRespectLatest($){if(!(this.config.packages?.respectLatest??!0))return!1;let Q=["latest","*","main","master","develop","dev"],K=this.extractPackageUpdatesFromPRBody($.body);if(K.length===0)return!1;return K.filter((Y)=>{let W=Y.currentVersion.toLowerCase().trim();return Q.includes(W)}).length>0}shouldAutoCloseForIgnorePaths($){let X=this.config.packages?.ignorePaths;if(!X||X.length===0)return!1;let Q=this.extractFilePathsFromPRBody($.body);if(Q.length===0)return!1;let{Glob:K}=globalThis.Bun,Z=Q.filter((Y)=>{let W=Y.replace(/^\.\//,"");return X.some((_)=>{try{return new K(_).match(W)}catch(z){return this.logger.debug(`Failed to match path ${W} against pattern ${_}: ${z}`),!1}})});if(Z.length>0)return this.logger.debug(`PR #${$.number} contains files now in ignorePaths: ${Z.join(", ")}`),!0;return!1}shouldAutoCloseForRemovedFiles($){try{let X=this.extractFilePathsFromPRBody($.body);if(X.length===0)return!1;let Q=G("fs"),K=G("path"),Z=X.filter((Y)=>{let W=K.join(this.projectPath,Y);return!Q.existsSync(W)});if(Z.length>0){if(this.logger.info(`PR #${$.number} references removed files: ${Z.join(", ")}`),this.config.packages?.ignorePaths&&this.config.packages.ignorePaths.length>0){let{Glob:O}=globalThis.Bun;if(Z.filter((J)=>{return!this.config.packages.ignorePaths.some((j)=>{try{return new O(j).match(J)}catch(q){return this.logger.warn(`Invalid glob pattern '${j}':`,q),!1}})}).length>0)return this.logger.info(`Some removed files are outside ignored paths - not auto-closing PR #${$.number}`),!1}if(Z.some((O)=>O.endsWith("composer.json")))return this.logger.info(`composer.json was removed - PR #${$.number} should be auto-closed`),!0;let W=$.body.toLowerCase(),_=W.includes("composer")||Z.some((O)=>O.includes("composer")),z=W.includes("package.json")||Z.some((O)=>O.includes("package.json")),L=Z.some((O)=>O.endsWith("deps.yaml")||O.endsWith("deps.yml")||O.endsWith("dependencies.yaml")||O.endsWith("dependencies.yml"));if(_||z||L)return this.logger.info(`PR #${$.number} is about removed dependency system - should be auto-closed`),!0}return!1}catch(X){return this.logger.debug(`Failed to check for removed files in PR #${$.number}: ${X}`),!1}}get events(){if(!this.eventBus){this.eventBus=new f0(this.logger);for(let $ of g0(this.config.notifications))this.eventBus.register($)}return this.eventBus}async createGitProvider(){let $=this.config.repository;if(!$?.owner||!$.name)return this.logger.warn("\u26A0\uFE0F Repository owner and name are required for pull request operations"),null;try{return await X0({provider:$.provider,owner:$.owner,name:$.name,...$.apiUrl?{apiUrl:$.apiUrl}:{}},{logger:this.logger})}catch(X){return this.logger.warn(`\u26A0\uFE0F ${$0(X)}`),null}}async queueAutoMerge($,X,Q,K){let Z=M0(Q,K,this.config);if(!Z.eligible){this.logger.debug(`\uD83D\uDD00 PR #${X.number} not auto-merged: ${Z.reason}`);return}let{strategy:Y}=n(this.config);if(!p($,"nativeAutoMerge","enableAutoMerge")){this.logger.info(`\uD83D\uDD00 PR #${X.number} qualifies for auto-merge but this provider has no merge queue; update-check will merge it once checks pass`);return}try{if(await $.enableAutoMerge(X.number,Y))this.logger.success(`\uD83D\uDD00 PR #${X.number} queued for auto-merge (${Z.reason})`);else this.logger.info(`\uD83D\uDD00 PR #${X.number} qualifies for auto-merge but the repository cannot queue it; update-check will merge it once checks pass`)}catch(W){this.logger.warn(`\u26A0\uFE0F Failed to queue auto-merge for PR #${X.number}: ${W}`)}}async mergeEligiblePullRequests($=!1){let X=n(this.config);if(!X.enabled)return[];let Q=await this.createGitProvider();if(!Q)return[];let K=[],Z=await Q.getPullRequests("open");for(let Y of Z.filter((W)=>W.head.startsWith("buddy/"))){let W=X.requireGreenCI&&Q.getPullRequestChecksState?await Q.getPullRequestChecksState(Y.number):"none",_=W==="success"||W==="none",z=I0({number:Y.number,title:Y.title,body:Y.body,head:Y.head,labels:Y.labels,draft:Y.draft},this.config,_);if(!z.eligible){this.logger.debug(`\uD83D\uDD00 PR #${Y.number} not merged: ${z.reason}`);continue}if($){this.logger.info(`\uD83D\uDD00 [DRY RUN] Would merge PR #${Y.number} (${z.reason})`),K.push(Y.number);continue}try{await Q.mergePullRequest(Y.number,X.strategy),this.logger.success(`\uD83D\uDD00 Merged PR #${Y.number}: ${z.reason}`),await this.events.emit("pr.merged",{number:Y.number,title:Y.title,strategy:X.strategy}),K.push(Y.number)}catch(L){this.logger.warn(`\u26A0\uFE0F Failed to merge PR #${Y.number}: ${L}`)}}return K}isPlausibleRepoPath($){if(!$||/[\s()[\]!`]|:\/\//.test($))return!1;return/^[\w@.-]+(?:\/[\w@.-]+)*$/.test($)}extractFilePathsFromPRBody($){let X=l($);if(X)return v0(X);let Q=[],K=/\|\s*\[[^\]]+\]\([^)]*\)\s*\|[^|]*\|\s*\*\*([^*]+)\*\*\s*\|/g,Z;while((Z=K.exec($))!==null){let z=Z[1].trim();if(this.isPlausibleRepoPath(z)&&!Q.includes(z))Q.push(z)}let Y=/\*\*([^*]+\.(?:json|yaml|yml|lock))\*\*/g;while((Z=Y.exec($))!==null){let z=Z[1].trim();if(this.isPlausibleRepoPath(z)&&!Q.includes(z))Q.push(z)}let W=/\|[^|]+\|[^|]+\|([^|]+)\|[^|]*\|/g;while((Z=W.exec($))!==null){let z=Z[1].trim();if(this.isPlausibleRepoPath(z)&&(z.includes("/")||/\.(?:json|yaml|yml|lock)$/.test(z))&&!Q.includes(z))Q.push(z)}let _=/(?:^|\s)([\w-]+(?:\/[\w.-]+)*\/[\w.-]+\.(?:json|yaml|yml|lock))(?:\s|$)/gm;while((Z=_.exec($))!==null){let z=Z[1].trim();if(this.isPlausibleRepoPath(z)&&!Q.includes(z))Q.push(z)}return Q}extractPackagesFromPRBody($){let X=l($);if(X)return[...new Set(X.updates.map((Y)=>Y.name))];let Q=[],K=$.match(/\|[^|]*\|[^|]*\|[^|]*\|[^|]*\|/g);if(K)for(let Y of K){let W=Y.match(/\[([^\]]+)\]\([^)]*\)/);if(W)Q.push(W[1])}let Z=$.match(/<summary>([^<]+)<\/summary>/g);if(Z)for(let Y of Z){let W=Y.replace(/<summary>/,"").replace(/<\/summary>/,"").trim();if(W&&!Q.includes(W))Q.push(W)}return Q}extractPackageUpdatesFromPRBody($){let X=l($);if(X)return b0(X);let Q=[],K=new Set,Z=/\|\s*\[([^\]]+)\][^|]*\|\s*\[?`?[v^~>=]*([^`|\s]+)`?\s*(?:->|\u2192)\s*`?[v^~>=]*([^`|\s]+)`?\]?/g,Y;while((Y=Z.exec($))!==null){let[,W,_,z]=Y;if(!K.has(W))K.add(W),Q.push({name:W,currentVersion:_,newVersion:z})}return Q}getConfig(){return this.config}getProjectPath(){return this.projectPath}async checkAndCloseObsoletePRs($,X=!1){try{this.logger.info("\uD83D\uDD0D Scanning for obsolete PRs due to removed dependency files...");let K=(await $.getPullRequests("open")).filter((Y)=>Y.head.startsWith("buddy/")||Y.author==="github-actions[bot]"&&Y.labels.includes("dependencies"));this.logger.info(`Found ${K.length} dependency-related PRs to check`);let Z=0;for(let Y of K)try{if(this.shouldAutoCloseForRemovedFiles(Y))if(this.logger.info(`\uD83D\uDD12 PR #${Y.number} should be auto-closed: ${Y.title}`),X)this.logger.info(`\uD83D\uDD0D [DRY RUN] Would auto-close PR #${Y.number}`),Z++;else try{let _=this.generateCloseReason(Y);try{await $.createComment(Y.number,_)}catch(z){this.logger.warn(`\u26A0\uFE0F Could not add close reason comment to PR #${Y.number}:`,z)}if(await $.closePullRequest(Y.number),await this.events.emit("pr.closed",{number:Y.number,title:Y.title,reason:"obsolete \u2014 its dependency files no longer exist"}),Y.head.startsWith("buddy/"))try{await $.deleteBranch(Y.head),this.logger.success(`\u2705 Auto-closed PR #${Y.number} and deleted branch ${Y.head}`)}catch(z){this.logger.warn(`\u26A0\uFE0F Auto-closed PR #${Y.number} but failed to delete branch: ${z}`)}else this.logger.success(`\u2705 Auto-closed PR #${Y.number}`);Z++}catch(_){this.logger.error(`\u274C Failed to auto-close PR #${Y.number}:`,_)}}catch(W){this.logger.warn(`\u26A0\uFE0F Error checking PR #${Y.number}:`,W)}if(Z>0)this.logger.success(`\u2705 ${X?"Would auto-close":"Auto-closed"} ${Z} obsolete PR(s)`);else this.logger.info("\uD83D\uDCCB No obsolete PRs found")}catch(Q){throw this.logger.error("Failed to check for obsolete PRs:",Q),Q}}async checkAndCloseSatisfiedPRs($,X=!1){try{this.logger.info("\uD83D\uDD0D Checking for PRs where dependencies are already at target version...");let K=(await $.getPullRequests("open")).filter((O)=>O.head.startsWith("buddy/")||O.author==="github-actions[bot]"&&O.labels.includes("dependencies"));if(this.logger.info(`Found ${K.length} buddy dependency PRs to validate`),K.length===0){this.logger.info("\uD83D\uDCCB No buddy PRs to check");return}let Z=0,Y={...this.config,packages:{...this.config.packages,strategy:"all"}},_=await new Q0(Y,this.projectPath).scanForUpdates(),z=new Map;for(let O of _.updates)z.set(O.name,O);let L=this.readDeclaredNpmVersions();if(_.updates.length===0){this.logger.warn("\u26A0\uFE0F Scan returned 0 updates \u2014 skipping satisfied PR check to avoid false-positive closures");return}for(let O of K)try{let H=this.extractPackageUpdatesFromPRBody(O.body);if(H.length===0){this.logger.debug(`PR #${O.number}: Could not extract package updates, skipping`);continue}let J=O.body.match(/\*\*Total\*\*\s*\|\s*\*\*(\d+)\*\*/),j=J?Number.parseInt(J[1],10):0;if(j>0&&H.length<j){this.logger.debug(`PR #${O.number}: Extracted ${H.length}/${j} updates \u2014 incomplete extraction, skipping satisfied check`);continue}let q=0,I=0,T=0;for(let B of H){let C=z.get(B.name);if(!C){let b=L.get(B.name);if(b){let R=this.compareVersionsSafe(b,B.newVersion);if(R==="at-or-beyond"){this.logger.debug(`PR #${O.number}: ${B.name} declared at ${b}, at or beyond ${B.newVersion}`),q++;continue}if(R==="behind"){this.logger.debug(`PR #${O.number}: ${B.name} declared at ${b}, still behind ${B.newVersion} \u2014 the scan missed it`),I++;continue}}this.logger.debug(`PR #${O.number}: ${B.name} not in current scan and not declared (unverifiable)`),T++;continue}if(C.newVersion===B.newVersion){this.logger.debug(`PR #${O.number}: ${B.name} still needs update to ${B.newVersion}`),I++;continue}let D=this.compareVersionsSafe(C.currentVersion,B.newVersion);if(D==="at-or-beyond")this.logger.debug(`PR #${O.number}: ${B.name} already at or beyond ${B.newVersion}`),q++;else if(D==="behind")this.logger.debug(`PR #${O.number}: ${B.name} still behind ${B.newVersion}`),I++;else this.logger.debug(`PR #${O.number}: ${B.name} version comparison inconclusive`),T++}let M=I===0&&T===0&&q>0;if(this.logger.debug(`PR #${O.number}: verified-satisfied=${q}, still-needed=${I}, unverifiable=${T} \u2192 ${M?"CLOSE":"KEEP"}`),M)if(this.logger.info(`\u2705 PR #${O.number} is satisfied (dependencies at target version): ${O.title}`),X)this.logger.info(`\uD83D\uDD0D [DRY RUN] Would close PR #${O.number}`),Z++;else try{let B=H.filter((D)=>{let R=z.get(D.name)?.currentVersion??L.get(D.name);if(!R)return!1;return this.compareVersionsSafe(R,D.newVersion)==="at-or-beyond"}),C=`\uD83E\uDD16 **Auto-closing satisfied PR**
89
+ ${j}`)}this.logger.success(`\u2705 Completed PR creation for ${$.groups.length} group(s) in ${J}ms`)}catch(Q){throw this.logger.error("Failed to create pull requests:",Q),Q}}shouldRespectVersion($){if(!(this.config.packages?.respectLatest??!0))return!1;let Q=["latest","*","main","master","develop","dev"],K=$.toLowerCase().trim();return Q.includes(K)}async checkDependencyFilesForUpdates($){let{isDependencyFile:X}=await import("./chunk-djdf848n.js"),{resolveDependencyFile:Q}=await import("./chunk-97cvp0t3.js"),K=[],Z=$.filter((_)=>X(_.path));this.logger.info(`\u26A1 Checking ${Z.length} dependency files in parallel...`);let Y=Z.map(async(_)=>{try{this.logger.info(`Checking dependency file: ${_.path}`);let z=await Q(_.path),L=[];for(let O of z.allDependencies||[]){if(this.shouldRespectVersion(O.constraint)){this.logger.debug(`Skipping ${O.name} - version "${O.constraint}" should be respected`);continue}if(O.constraint!==O.version&&O.version){let H=O.constraint.replace(/^[\^~>=<]+/,"");if(!this.isNewerVersion(H,O.version)){this.logger.debug(`Skipping ${O.name} - latest (${O.version}) is not newer than constraint (${H})`);continue}let J=m(H,O.version),j=O.version;L.push({name:O.name,currentVersion:O.constraint,newVersion:j,updateType:J,dependencyType:"dependencies",file:_.path,metadata:void 0,releaseNotesUrl:void 0,changelogUrl:void 0,homepage:void 0})}}return L}catch(z){return this.logger.error(`Failed to check dependency file ${_.path}:`,z),[]}}),W=await Promise.all(Y);return K.push(...W.flat()),K}async checkZigForUpdates($){let{isZigManifest:X}=await import("./chunk-3jw9d546.js"),{fetchLatestZigVersion:Q,fetchZigHash:K,isZigAvailable:Z,parseZigSource:Y,zigUrlForVersion:W}=await import("./chunk-4rvgatmm.js"),_=$.filter((H)=>X(H.path));if(_.length===0)return[];if(!await Z())return this.logger.warn("\u26A0\uFE0F Found Zig manifests but the zig toolchain is not available. "+"Skipping Zig updates: their content-addressed hashes cannot be recomputed without `zig fetch`."),[];let z=y.env.GITHUB_TOKEN||y.env.BUDDY_TOKEN||y.env.BUDDY_BOT_TOKEN,L=_.flatMap((H)=>H.dependencies.filter((J)=>J.type==="zig-dependencies").map((J)=>({file:H,dep:J})));return this.logger.info(`\u26A1 Checking ${L.length} Zig dependencies...`),(await Promise.all(L.map(async({file:H,dep:J})=>{let j=J.metadata?.url;if(!j)return this.logger.debug(`Skipping ${J.name}: no URL recorded`),null;let q=Y(j);if(!q)return this.logger.debug(`Skipping ${J.name}: only GitHub-hosted Zig dependencies can be checked`),null;let I=await Q(q,z);if(!I||I===J.currentVersion)return null;let T=W(j,I),M=await K(T);if(!M)return this.logger.warn(`\u26A0\uFE0F Skipping ${J.name} ${J.currentVersion} \u2192 ${I}: could not compute its package hash`),null;return this.logger.info(`\uD83D\uDCE6 ${J.name}: ${J.currentVersion} \u2192 ${I}`),{name:J.name,currentVersion:J.currentVersion,newVersion:I,updateType:m(J.currentVersion,I),dependencyType:"zig-dependencies",file:H.path,resolved:{url:T,hash:M}}}))).filter((H)=>H!==null)}async checkGitHubActionsForUpdates($){let{fetchActionTagCommit:X,fetchLatestActionVersion:Q,isGitHubActionsFile:K,sameActionVersion:Z}=await import("./chunk-06k6abjj.js"),Y=[],W=$.filter((J)=>K(J.path));this.logger.info(`\uD83D\uDD0D Found ${W.length} GitHub Actions workflow files`);let _=[];for(let J of W){let j=J.dependencies.filter((q)=>q.type==="github-actions");this.logger.info(`Found ${j.length} GitHub Actions in ${J.path}`),j.forEach((q)=>_.push({file:J,dep:q}))}this.logger.info(`\u26A1 Checking ${_.length} GitHub Actions in parallel...`);let z=_.map(async({file:J,dep:j})=>{try{this.logger.info(`Checking action: ${j.name}@${j.currentVersion}`);let q=await Q(j.name);if(q&&j.metadata?.pinnedSha){let I=j.metadata.pinnedVersion;if(!I)return this.logger.info(`Skipping ${j.name}@${j.currentVersion}: a SHA pin without a version comment cannot be compared`),null;if(Z(I,q))return this.logger.info(`No update needed for ${j.name}: already pinned to ${q}`),null;let T=await X(j.name,q);if(!T)return this.logger.warn(`Could not resolve ${j.name}@${q} to a commit; leaving the SHA pin alone`),null;let M=m(I,q);return this.logger.info(`Update available: ${j.name} ${I} \u2192 ${q} (${M}, pinned)`),{name:j.name,currentVersion:j.currentVersion,newVersion:q,updateType:M,dependencyType:"github-actions",file:J.path,metadata:void 0,resolved:{sha:T},releaseNotesUrl:`${d(this.config)}/${j.name}/releases`,changelogUrl:void 0,homepage:`${d(this.config)}/${j.name}`}}if(q)if(this.logger.info(`Latest version for ${j.name}: ${q}`),q!==j.currentVersion){let I=m(j.currentVersion,q);return this.logger.info(`Update available: ${j.name} ${j.currentVersion} \u2192 ${q} (${I})`),{name:j.name,currentVersion:j.currentVersion,newVersion:q,updateType:I,dependencyType:"github-actions",file:J.path,metadata:void 0,releaseNotesUrl:`${d(this.config)}/${j.name}/releases`,changelogUrl:void 0,homepage:`${d(this.config)}/${j.name}`}}else this.logger.info(`No update needed for ${j.name}: already at ${q}`);else this.logger.warn(`Could not fetch latest version for ${j.name}`);return null}catch(q){return this.logger.warn(`Failed to check version for action ${j.name}:`,q),null}}),O=(await Promise.all(z)).filter((J)=>J!==null);Y.push(...O),this.logger.info(`Generated ${Y.length} GitHub Actions updates`);let H=Y.reduce((J,j)=>{if(!J.find((I)=>I.name===j.name&&I.currentVersion===j.currentVersion&&I.newVersion===j.newVersion&&I.file===j.file))J.push(j);return J},[]);return this.logger.info(`After deduplication: ${H.length} unique GitHub Actions updates`),H}async checkEnginesForUpdates($){let{bumpEngineConstraint:X,engineUpdateType:Q,resolveEngineVersion:K}=await import("./chunk-qz5nqeza.js"),{fetchLatestActionVersion:Z}=await import("./chunk-06k6abjj.js"),Y=$.flatMap((z)=>z.dependencies.filter((L)=>L.type==="engines").map((L)=>({file:z,dep:L})));if(Y.length===0)return[];this.logger.info(`\u26A1 Checking ${Y.length} engine constraint(s)...`);let W={npm:(z)=>this.registryClient.getLatestVersion(z),github:(z)=>Z(z)},_=Y.map(async({file:z,dep:L})=>{try{let O=await K(L.name,W);if(!O)return null;let H=X(L.currentVersion,O);if(!H)return this.logger.debug(`${L.name} ${L.currentVersion} already admits ${O}`),null;return this.logger.info(`Update available: ${L.name} ${L.currentVersion} \u2192 ${H}`),{name:L.name,currentVersion:L.currentVersion,newVersion:H,updateType:Q(L.currentVersion,H),dependencyType:"engines",file:z.path}}catch(O){return this.logger.warn(`Could not check engine ${L.name}:`,O),null}});return(await Promise.all(_)).filter((z)=>z!==null)}async checkDockerfilesForUpdates($){let{isDockerfile:X}=await import("./chunk-1q6s6a5e.js"),{fetchLatestDockerImageVersion:Q}=await import("./chunk-1q6s6a5e.js"),K=[],Z=$.filter((O)=>X(O.path));this.logger.info(`\uD83D\uDD0D Found ${Z.length} Dockerfile(s)`);let Y=[];for(let O of Z){let H=O.dependencies.filter((J)=>J.type==="docker-image");this.logger.info(`Found ${H.length} Docker images in ${O.path}`),H.forEach((J)=>Y.push({file:O,dep:J}))}this.logger.info(`\u26A1 Checking ${Y.length} Docker images in parallel...`);let W=Y.map(async({file:O,dep:H})=>{try{if(this.logger.info(`Checking Docker image: ${H.name}:${H.currentVersion}`),this.shouldRespectVersion(H.currentVersion))return this.logger.debug(`Skipping ${H.name} - version "${H.currentVersion}" should be respected`),null;let J=await Q(H.name,H.currentVersion,{...this.config.registries?.docker?{registries:this.config.registries.docker}:{},...this.config.packages?.includePrerelease!==void 0?{includePrerelease:this.config.packages.includePrerelease}:{}});if(J)if(this.logger.info(`Latest version for ${H.name}: ${J}`),J!==H.currentVersion){let j=m(H.currentVersion,J);return this.logger.info(`Update available: ${H.name} ${H.currentVersion} \u2192 ${J} (${j})`),{name:H.name,currentVersion:H.currentVersion,newVersion:J,updateType:j,dependencyType:"docker-image",file:O.path,metadata:void 0,releaseNotesUrl:`https://hub.docker.com/r/${H.name}/tags`,changelogUrl:void 0,homepage:`https://hub.docker.com/r/${H.name}`}}else this.logger.info(`No update needed for ${H.name}: already at ${J}`);else this.logger.warn(`Could not fetch latest version for Docker image ${H.name}`);return null}catch(J){return this.logger.warn(`Failed to check version for Docker image ${H.name}:`,J),null}}),z=(await Promise.all(W)).filter((O)=>O!==null);K.push(...z),this.logger.info(`Generated ${K.length} Docker image updates`);let L=K.reduce((O,H)=>{if(!O.find((j)=>j.name===H.name&&j.currentVersion===H.currentVersion&&j.newVersion===H.newVersion&&j.file===H.file))O.push(H);return O},[]);return this.logger.info(`After deduplication: ${L.length} unique Docker image updates`),L}isNewerVersion($,X){try{return Bun.semver.order(X.replace(/^[v^~>=<@]+/,""),$.replace(/^[v^~>=<@]+/,""))>0}catch{return!1}}readDeclaredNpmVersions(){let $=new Map;try{let X=G("fs"),K=G("path").join(this.projectPath,"package.json");if(!X.existsSync(K))return $;let Z=JSON.parse(X.readFileSync(K,"utf8"));for(let Y of["dependencies","devDependencies","peerDependencies","optionalDependencies"])for(let[W,_]of Object.entries(Z[Y]??{}))if(typeof _==="string"&&!$.has(W))$.set(W,_)}catch(X){this.logger.debug("Could not read declared versions from package.json:",X)}return $}compareVersionsSafe($,X){try{let Q=X.replace(/^[v^~>=<@]+/,""),K=$.replace(/^[v^~>=<@]+/,"");if(!/^\d+\.\d+/.test(Q)||!/^\d+\.\d+/.test(K))return"failed";return Bun.semver.order(Q,K)>0?"behind":"at-or-beyond"}catch{return"failed"}}async generateAllFileUpdates($){let X=[],Q=$.filter((H)=>H.file.endsWith("package.json")&&H.dependencyType!=="engines"&&!H.file.includes(".yaml")&&!H.file.includes(".yml")&&!H.file.includes(".github/workflows/")),K=$.filter((H)=>H.dependencyType==="engines");if(K.length>0){let{applyEngineUpdates:H}=await import("./chunk-qz5nqeza.js"),J=new Map;for(let j of K)J.set(j.file,[...J.get(j.file)??[],j]);for(let[j,q]of J)try{let I=N0.readFileSync(j,"utf-8"),T=H(I,q);if(T===I){this.logger.warn(`\u26A0\uFE0F No engine changes written to ${j}`);continue}X.push({path:j,content:T,type:"update"})}catch(I){this.logger.warn(`Failed to update engines in ${j}:`,I)}}let Z=new Map;for(let H of Q){if(!Z.has(H.file))Z.set(H.file,[]);Z.get(H.file).push(H)}for(let[H,J]of Z)try{let j=N0.readFileSync(H,"utf-8"),q=JSON.parse(j);for(let I of J){let T=!1,M=I.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),B=["dependencies","devDependencies","peerDependencies","optionalDependencies"];for(let C of B)if(q[C]&&q[C][M]){let b=q[C][M].match(/^(\D*)/),R=b?b[1]:"",f=M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=new RegExp(`("${g}"\\s*:\\s*\\{[^}]*?)("${f}"\\s*:\\s*")([^"]+)(")([^}]*?\\})`,"gs"),V=`${R}${I.newVersion}`;j=j.replace(u,`$1$2${V}$4$5`),T=!0;break}if(!T)this.logger.warn(`Package ${M} not found in ${H}`)}X.push({path:H,content:j,type:"update"})}catch(j){this.logger.warn(`Failed to update ${H}:`,j)}let Y=$.filter((H)=>{let J=H.file.toLowerCase();return(J.endsWith("deps.yaml")||J.endsWith("deps.yml")||J.endsWith("dependencies.yaml")||J.endsWith("dependencies.yml"))&&!H.file.includes(".github/workflows/")});if(Y.length>0)try{let{generateDependencyFileUpdates:H}=await import("./chunk-djdf848n.js"),J=await H(Y);X.push(...J)}catch(H){this.logger.error("Failed to generate dependency file updates:",H)}let W=$.filter((H)=>H.file.endsWith("composer.json")||H.file.endsWith("composer.lock"));if(W.length>0)try{let{generateComposerUpdates:H}=await import("./chunk-z456ptfw.js"),J=await H(W);X.push(...J)}catch(H){this.logger.error("Failed to generate Composer updates:",H)}let _=$.filter((H)=>H.file.includes(".github/workflows/"));if(_.length>0)try{let{generateGitHubActionsUpdates:H}=await import("./chunk-06k6abjj.js"),J=await H(_);X.push(...J)}catch(H){this.logger.error("Failed to generate GitHub Actions updates:",H)}let z=$.filter((H)=>H.dependencyType==="docker-image");if(z.length>0)try{let{generateDockerfileUpdates:H}=await import("./chunk-1q6s6a5e.js"),J=await H(z,this.config.registries?.docker);X.push(...J)}catch(H){this.logger.error("Failed to generate Dockerfile updates:",H)}let L=$.filter((H)=>H.dependencyType==="zig-dependencies");if(L.length>0)try{let{generateZigManifestUpdates:H}=await import("./chunk-3jw9d546.js"),J=await H(L);X.push(...J)}catch(H){this.logger.error("Failed to generate Zig manifest updates:",H)}let O=$.filter((H)=>H.dependencyType==="catalog");if(O.length>0)try{let{applyCatalogUpdates:H}=await import("./chunk-a4m6bqpq.js"),J=O[0].file,j=await Bun.file(e(this.projectPath,J)).text(),q=H(j,O);if(q===j)this.logger.warn(`\u26A0\uFE0F No catalog changes written to ${J}`);else X.push({path:J,content:q,type:"update"})}catch(H){this.logger.error("Failed to generate pnpm catalog updates:",H)}return X.push(...await this.generateAdapterFileUpdates($)),X}async generateAdapterFileUpdates($){let{adapterNamed:X}=await import("./chunk-305184z3.js"),Q=new Map;for(let Y of $){if(!X(Y.dependencyType))continue;let W=Q.get(Y.file);if(W)W.push(Y);else Q.set(Y.file,[Y])}let K=[],Z=new Set;for(let[Y,W]of Q){let _=X(W[0].dependencyType);if(!_)continue;Z.add(_.name);try{let z=e(this.projectPath,Y),L=await Bun.file(z).text(),O=L;for(let H of W)O=_.applyUpdate(O,{name:H.name,currentVersion:H.currentVersion,newVersion:H.newVersion,section:H.dependencyType});if(O===L){this.logger.warn(`\u26A0\uFE0F ${_.name}: no changes written to ${Y}`);continue}K.push({path:Y,content:O,type:"update"})}catch(z){this.logger.error(`Failed to write ${_.name} updates to ${Y}:`,z)}}return[...K,...await this.regenerateAdapterLockfiles(K,[...Z])]}async regenerateAdapterLockfiles($,X){if($.length===0||X.length===0)return[];let{regenerateLockfiles:Q}=await import("./chunk-305184z3.js");try{for(let W of $)await Bun.write(e(this.projectPath,W.path),W.content)}catch(W){return this.logger.warn(`\u26A0\uFE0F Could not stage manifests for lockfile regeneration: ${W}`),[]}let{regenerated:K,notes:Z}=await Q(this.projectPath,X);for(let W of Z)this.logger.info(`\u2139\uFE0F ${W}`);let Y=[];for(let W of K)try{Y.push({path:W,content:await Bun.file(e(this.projectPath,W)).text(),type:"update"}),this.logger.info(`\uD83D\uDD12 Regenerated ${W}`)}catch(_){this.logger.warn(`\u26A0\uFE0F Could not read the regenerated ${W}: ${_}`)}return Y}async run(){let $=await this.scanForUpdates();if($.updates.length===0)return this.logger.info("No updates available!"),$;if(this.config.pullRequest)await this.createPullRequests($);return $}async checkPackages($){return this.logger.info(`Checking specific packages: ${$.join(", ")}`),this.applyStrategy(await this.registryClient.getUpdatesForPackages($))}async checkPackagesWithPattern($){return this.logger.info(`Checking packages with pattern: ${$}`),this.applyStrategy(await this.registryClient.getUpdatesWithPattern($))}applyStrategy($){let X=this.config.packages?.strategy;return X?this.filterUpdatesByStrategy($,X):$}filterUpdatesByStrategy($,X){if(X==="all")return $;return $.filter((Q)=>h0(X,Q.updateType))}async filterUpdatesByMinimumReleaseAge($){let X=this.config.packages?.minimumReleaseAge??0,Q=this.activeRules(),K=Q.some((z)=>z.minimumReleaseAge!==void 0);if(X===0&&!K)return $;this.logger.info(`Applying minimum release age filter (global ${X} minutes${K?", with per-rule overrides":""}) in parallel...`);let Z=$.map(async(z)=>{try{let L=(Q.length>0?c(z,Q).minimumReleaseAge:void 0)??X;if(L===0)return z;if(await this.registryClient.meetsMinimumReleaseAge(z.name,z.newVersion,z.dependencyType,L))return z;else return this.logger.debug(`Filtered out ${z.name}@${z.newVersion} (${z.dependencyType}) \u2014 held for ${L} minutes after publication`),null}catch(L){return this.logger.warn(`Error checking release age for ${z.name}@${z.newVersion} (${z.dependencyType}), including update:`,L),z}}),W=(await Promise.all(Z)).filter((z)=>z!==null),_=$.length-W.length;if(_>0)this.logger.info(`Filtered out ${_} updates due to minimum release age requirement`);return W}groupUpdatesByConfig($){let X=[],{grouped:Q,remaining:K}=this.groupByRuleNames($);X.push(...Q);let Z=[...K];if(this.config.packages?.groups)for(let Y of this.config.packages.groups){let W=[],{Glob:_}=globalThis.Bun,z=new Set;for(let O of Y.patterns){let H;try{H=new _(O)}catch(J){this.logger.warn(`Invalid group pattern '${O}':`,J);continue}Z.forEach((J,j)=>{if(!z.has(j)&&H.match(J.name))W.push(J),z.add(j)})}if(z.size>0){for(let O=Z.length-1;O>=0;O--)if(z.has(O))Z.splice(O,1)}let L=W;if(Y.strategy)L=this.filterUpdatesByStrategy(W,Y.strategy);if(L.length>0)X.push({name:Y.name,updates:L,updateType:this.getHighestUpdateType(L),title:`chore(deps): update ${Y.name}`,body:`Update ${L.length} packages in ${Y.name} group`})}if(Z.length>0){let Y=_0(Z);X.push(...Y)}return X}groupByRuleNames($){let X=this.config.packages?.rules??[];if(X.length===0)return{grouped:[],remaining:$};let Q=new Map,K=[];for(let Y of $){let W=c(Y,X).groupName;if(!W){K.push(Y);continue}let _=Q.get(W);if(_)_.push(Y);else Q.set(W,[Y])}return{grouped:[...Q.entries()].map(([Y,W])=>({name:Y,updates:W,updateType:this.getHighestUpdateType(W),title:`chore(deps): update ${Y}`,body:`Update ${W.length} packages in ${Y} group`})),remaining:K}}getHighestUpdateType($){if($.some((X)=>X.updateType==="major"))return"major";if($.some((X)=>X.updateType==="minor"))return"minor";return"patch"}generateBranchName($){return`buddy/update-${$.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}`}isSimilarPRTitle($,X){if($.toLowerCase()===X.toLowerCase())return!0;let Q=$.toLowerCase(),K=X.toLowerCase(),Z=Q.includes("github actions"),Y=K.includes("github actions");if(Z&&Y)return!0;if(Z!==Y)return!1;let W=Q.includes("docker image"),_=K.includes("docker image");if(W&&_)return!0;if(W!==_)return!1;let z=[/update all non-major/i,/update \d+ dependenc(y|ies)/i,/update.*\(minor\)/i,/update.*\(patch\)/i,/update.*\(major\)/i],L=z.some((H)=>H.test($)),O=z.some((H)=>H.test(X));if(L&&O){let H=Q.includes("(major)")||Q.includes("major update"),J=K.includes("(major)")||K.includes("major update");return H===J}if(K.includes("update dependency ")){let H=X.match(/update dependency (\S+)/i),J=$.match(/update dependency (\S+)/i);if(H&&J)return H[1]===J[1]}if(L!==O)return!1;if(Q.includes("dependency ")&&K.includes("dependency "))return!1;return!1}checkIfUpdatesMatch($,X){if(!$)return!1;let Q=this.extractPackageUpdatesFromPRBody($),K=new Map;for(let Z of Q)K.set(Z.name,{from:Z.currentVersion,to:Z.newVersion});for(let Z of X){let Y=K.get(Z.name);if(!Y)return!1;let W=Y.to.replace(/^[v^~>=<]+/,""),_=Z.newVersion.replace(/^[v^~>=<]+/,"");if(W!==_)return!1}return K.size===X.length}shouldAutoClosePR($,X){if(this.shouldAutoCloseForRespectLatest($))return!0;if(this.shouldAutoCloseForIgnorePaths($))return!0;if(this.shouldAutoCloseForRemovedFiles($))return!0;return!1}shouldAutoCloseForRespectLatest($){if(!(this.config.packages?.respectLatest??!0))return!1;let Q=["latest","*","main","master","develop","dev"],K=this.extractPackageUpdatesFromPRBody($.body);if(K.length===0)return!1;return K.filter((Y)=>{let W=Y.currentVersion.toLowerCase().trim();return Q.includes(W)}).length>0}shouldAutoCloseForIgnorePaths($){let X=this.config.packages?.ignorePaths;if(!X||X.length===0)return!1;let Q=this.extractFilePathsFromPRBody($.body);if(Q.length===0)return!1;let{Glob:K}=globalThis.Bun,Z=Q.filter((Y)=>{let W=Y.replace(/^\.\//,"");return X.some((_)=>{try{return new K(_).match(W)}catch(z){return this.logger.debug(`Failed to match path ${W} against pattern ${_}: ${z}`),!1}})});if(Z.length>0)return this.logger.debug(`PR #${$.number} contains files now in ignorePaths: ${Z.join(", ")}`),!0;return!1}shouldAutoCloseForRemovedFiles($){try{let X=this.extractFilePathsFromPRBody($.body);if(X.length===0)return!1;let Q=G("fs"),K=G("path"),Z=X.filter((Y)=>{let W=K.join(this.projectPath,Y);return!Q.existsSync(W)});if(Z.length>0){if(this.logger.info(`PR #${$.number} references removed files: ${Z.join(", ")}`),this.config.packages?.ignorePaths&&this.config.packages.ignorePaths.length>0){let{Glob:O}=globalThis.Bun;if(Z.filter((J)=>{return!this.config.packages.ignorePaths.some((j)=>{try{return new O(j).match(J)}catch(q){return this.logger.warn(`Invalid glob pattern '${j}':`,q),!1}})}).length>0)return this.logger.info(`Some removed files are outside ignored paths - not auto-closing PR #${$.number}`),!1}if(Z.some((O)=>O.endsWith("composer.json")))return this.logger.info(`composer.json was removed - PR #${$.number} should be auto-closed`),!0;let W=$.body.toLowerCase(),_=W.includes("composer")||Z.some((O)=>O.includes("composer")),z=W.includes("package.json")||Z.some((O)=>O.includes("package.json")),L=Z.some((O)=>O.endsWith("deps.yaml")||O.endsWith("deps.yml")||O.endsWith("dependencies.yaml")||O.endsWith("dependencies.yml"));if(_||z||L)return this.logger.info(`PR #${$.number} is about removed dependency system - should be auto-closed`),!0}return!1}catch(X){return this.logger.debug(`Failed to check for removed files in PR #${$.number}: ${X}`),!1}}get events(){if(!this.eventBus){this.eventBus=new f0(this.logger);for(let $ of g0(this.config.notifications))this.eventBus.register($)}return this.eventBus}async createGitProvider(){let $=this.config.repository;if(!$?.owner||!$.name)return this.logger.warn("\u26A0\uFE0F Repository owner and name are required for pull request operations"),null;try{return await X0({provider:$.provider,owner:$.owner,name:$.name,...$.apiUrl?{apiUrl:$.apiUrl}:{}},{logger:this.logger})}catch(X){return this.logger.warn(`\u26A0\uFE0F ${$0(X)}`),null}}async queueAutoMerge($,X,Q,K){let Z=M0(Q,K,this.config);if(!Z.eligible){this.logger.debug(`\uD83D\uDD00 PR #${X.number} not auto-merged: ${Z.reason}`);return}let{strategy:Y}=n(this.config);if(!p($,"nativeAutoMerge","enableAutoMerge")){this.logger.info(`\uD83D\uDD00 PR #${X.number} qualifies for auto-merge but this provider has no merge queue; update-check will merge it once checks pass`);return}try{if(await $.enableAutoMerge(X.number,Y))this.logger.success(`\uD83D\uDD00 PR #${X.number} queued for auto-merge (${Z.reason})`);else this.logger.info(`\uD83D\uDD00 PR #${X.number} qualifies for auto-merge but the repository cannot queue it; update-check will merge it once checks pass`)}catch(W){this.logger.warn(`\u26A0\uFE0F Failed to queue auto-merge for PR #${X.number}: ${W}`)}}async mergeEligiblePullRequests($=!1){let X=n(this.config);if(!X.enabled)return[];let Q=await this.createGitProvider();if(!Q)return[];let K=[],Z=await Q.getPullRequests("open");for(let Y of Z.filter((W)=>W.head.startsWith("buddy/"))){let W=X.requireGreenCI&&Q.getPullRequestChecksState?await Q.getPullRequestChecksState(Y.number):"none",_=W==="success"||W==="none",z=I0({number:Y.number,title:Y.title,body:Y.body,head:Y.head,labels:Y.labels,draft:Y.draft},this.config,_);if(!z.eligible){this.logger.debug(`\uD83D\uDD00 PR #${Y.number} not merged: ${z.reason}`);continue}if($){this.logger.info(`\uD83D\uDD00 [DRY RUN] Would merge PR #${Y.number} (${z.reason})`),K.push(Y.number);continue}try{await Q.mergePullRequest(Y.number,X.strategy),this.logger.success(`\uD83D\uDD00 Merged PR #${Y.number}: ${z.reason}`),await this.events.emit("pr.merged",{number:Y.number,title:Y.title,strategy:X.strategy}),K.push(Y.number)}catch(L){this.logger.warn(`\u26A0\uFE0F Failed to merge PR #${Y.number}: ${L}`)}}return K}isPlausibleRepoPath($){if(!$||/[\s()[\]!`]|:\/\//.test($))return!1;return/^[\w@.-]+(?:\/[\w@.-]+)*$/.test($)}extractFilePathsFromPRBody($){let X=l($);if(X)return v0(X);let Q=[],K=/\|\s*\[[^\]]+\]\([^)]*\)\s*\|[^|]*\|\s*\*\*([^*]+)\*\*\s*\|/g,Z;while((Z=K.exec($))!==null){let z=Z[1].trim();if(this.isPlausibleRepoPath(z)&&!Q.includes(z))Q.push(z)}let Y=/\*\*([^*]+\.(?:json|yaml|yml|lock))\*\*/g;while((Z=Y.exec($))!==null){let z=Z[1].trim();if(this.isPlausibleRepoPath(z)&&!Q.includes(z))Q.push(z)}let W=/\|[^|]+\|[^|]+\|([^|]+)\|[^|]*\|/g;while((Z=W.exec($))!==null){let z=Z[1].trim();if(this.isPlausibleRepoPath(z)&&(z.includes("/")||/\.(?:json|yaml|yml|lock)$/.test(z))&&!Q.includes(z))Q.push(z)}let _=/(?:^|\s)([\w-]+(?:\/[\w.-]+)*\/[\w.-]+\.(?:json|yaml|yml|lock))(?:\s|$)/gm;while((Z=_.exec($))!==null){let z=Z[1].trim();if(this.isPlausibleRepoPath(z)&&!Q.includes(z))Q.push(z)}return Q}extractPackagesFromPRBody($){let X=l($);if(X)return[...new Set(X.updates.map((Y)=>Y.name))];let Q=[],K=$.match(/\|[^|]*\|[^|]*\|[^|]*\|[^|]*\|/g);if(K)for(let Y of K){let W=Y.match(/\[([^\]]+)\]\([^)]*\)/);if(W)Q.push(W[1])}let Z=$.match(/<summary>([^<]+)<\/summary>/g);if(Z)for(let Y of Z){let W=Y.replace(/<summary>/,"").replace(/<\/summary>/,"").trim();if(W&&!Q.includes(W))Q.push(W)}return Q}extractPackageUpdatesFromPRBody($){let X=l($);if(X)return b0(X);let Q=[],K=new Set,Z=/\|\s*\[([^\]]+)\][^|]*\|\s*\[?`?[v^~>=]*([^`|\s]+)`?\s*(?:->|\u2192)\s*`?[v^~>=]*([^`|\s]+)`?\]?/g,Y;while((Y=Z.exec($))!==null){let[,W,_,z]=Y;if(!K.has(W))K.add(W),Q.push({name:W,currentVersion:_,newVersion:z})}return Q}getConfig(){return this.config}getProjectPath(){return this.projectPath}async checkAndCloseObsoletePRs($,X=!1){try{this.logger.info("\uD83D\uDD0D Scanning for obsolete PRs due to removed dependency files...");let K=(await $.getPullRequests("open")).filter((Y)=>Y.head.startsWith("buddy/")||Y.author==="github-actions[bot]"&&Y.labels.includes("dependencies"));this.logger.info(`Found ${K.length} dependency-related PRs to check`);let Z=0;for(let Y of K)try{if(this.shouldAutoCloseForRemovedFiles(Y))if(this.logger.info(`\uD83D\uDD12 PR #${Y.number} should be auto-closed: ${Y.title}`),X)this.logger.info(`\uD83D\uDD0D [DRY RUN] Would auto-close PR #${Y.number}`),Z++;else try{let _=this.generateCloseReason(Y);try{await $.createComment(Y.number,_)}catch(z){this.logger.warn(`\u26A0\uFE0F Could not add close reason comment to PR #${Y.number}:`,z)}if(await $.closePullRequest(Y.number),await this.events.emit("pr.closed",{number:Y.number,title:Y.title,reason:"obsolete \u2014 its dependency files no longer exist"}),Y.head.startsWith("buddy/"))try{await $.deleteBranch(Y.head),this.logger.success(`\u2705 Auto-closed PR #${Y.number} and deleted branch ${Y.head}`)}catch(z){this.logger.warn(`\u26A0\uFE0F Auto-closed PR #${Y.number} but failed to delete branch: ${z}`)}else this.logger.success(`\u2705 Auto-closed PR #${Y.number}`);Z++}catch(_){this.logger.error(`\u274C Failed to auto-close PR #${Y.number}:`,_)}}catch(W){this.logger.warn(`\u26A0\uFE0F Error checking PR #${Y.number}:`,W)}if(Z>0)this.logger.success(`\u2705 ${X?"Would auto-close":"Auto-closed"} ${Z} obsolete PR(s)`);else this.logger.info("\uD83D\uDCCB No obsolete PRs found")}catch(Q){throw this.logger.error("Failed to check for obsolete PRs:",Q),Q}}async checkAndCloseSatisfiedPRs($,X=!1){try{this.logger.info("\uD83D\uDD0D Checking for PRs where dependencies are already at target version...");let K=(await $.getPullRequests("open")).filter((O)=>O.head.startsWith("buddy/")||O.author==="github-actions[bot]"&&O.labels.includes("dependencies"));if(this.logger.info(`Found ${K.length} buddy dependency PRs to validate`),K.length===0){this.logger.info("\uD83D\uDCCB No buddy PRs to check");return}let Z=0,Y={...this.config,packages:{...this.config.packages,strategy:"all"}},_=await new Q0(Y,this.projectPath).scanForUpdates(),z=new Map;for(let O of _.updates)z.set(O.name,O);let L=this.readDeclaredNpmVersions();if(_.updates.length===0){this.logger.warn("\u26A0\uFE0F Scan returned 0 updates \u2014 skipping satisfied PR check to avoid false-positive closures");return}for(let O of K)try{let H=this.extractPackageUpdatesFromPRBody(O.body);if(H.length===0){this.logger.debug(`PR #${O.number}: Could not extract package updates, skipping`);continue}let J=O.body.match(/\*\*Total\*\*\s*\|\s*\*\*(\d+)\*\*/),j=J?Number.parseInt(J[1],10):0;if(j>0&&H.length<j){this.logger.debug(`PR #${O.number}: Extracted ${H.length}/${j} updates \u2014 incomplete extraction, skipping satisfied check`);continue}let q=0,I=0,T=0;for(let B of H){let C=z.get(B.name);if(!C){let b=L.get(B.name);if(b){let R=this.compareVersionsSafe(b,B.newVersion);if(R==="at-or-beyond"){this.logger.debug(`PR #${O.number}: ${B.name} declared at ${b}, at or beyond ${B.newVersion}`),q++;continue}if(R==="behind"){this.logger.debug(`PR #${O.number}: ${B.name} declared at ${b}, still behind ${B.newVersion} \u2014 the scan missed it`),I++;continue}}this.logger.debug(`PR #${O.number}: ${B.name} not in current scan and not declared (unverifiable)`),T++;continue}if(C.newVersion===B.newVersion){this.logger.debug(`PR #${O.number}: ${B.name} still needs update to ${B.newVersion}`),I++;continue}let D=this.compareVersionsSafe(C.currentVersion,B.newVersion);if(D==="at-or-beyond")this.logger.debug(`PR #${O.number}: ${B.name} already at or beyond ${B.newVersion}`),q++;else if(D==="behind")this.logger.debug(`PR #${O.number}: ${B.name} still behind ${B.newVersion}`),I++;else this.logger.debug(`PR #${O.number}: ${B.name} version comparison inconclusive`),T++}let M=I===0&&T===0&&q>0;if(this.logger.debug(`PR #${O.number}: verified-satisfied=${q}, still-needed=${I}, unverifiable=${T} \u2192 ${M?"CLOSE":"KEEP"}`),M)if(this.logger.info(`\u2705 PR #${O.number} is satisfied (dependencies at target version): ${O.title}`),X)this.logger.info(`\uD83D\uDD0D [DRY RUN] Would close PR #${O.number}`),Z++;else try{let B=H.filter((D)=>{let R=z.get(D.name)?.currentVersion??L.get(D.name);if(!R)return!1;return this.compareVersionsSafe(R,D.newVersion)==="at-or-beyond"}),C=`\uD83E\uDD16 **Auto-closing satisfied PR**
90
90
 
91
91
  `;if(B.length>0)C+=`The following packages are already at the target version or newer:
92
92
 
@@ -102,5 +102,5 @@ The following updates have all been created. To force a retry/rebase of any, cli
102
102
  ${Q.map((_)=>`- \`${_}\``).join(`
103
103
  `)}
104
104
 
105
- `;return W+="If this was closed in error, please reopen the PR and update the dependency files accordingly.",W}async createOrUpdateDashboard(){try{if(this.logger.info("Creating or updating dependency dashboard..."),!this.config.repository)throw Error("Repository configuration is required for dashboard");if(this.config.repository.provider!=="github")throw Error("Dashboard is currently only supported for GitHub repositories");if(!this.config.repository.owner||!this.config.repository.name)throw Error("Repository owner and name are required for dashboard. Set them in buddy.config.ts or ensure GITHUB_REPOSITORY env var is available.");let $=await X0({provider:this.config.repository.provider,owner:this.config.repository.owner,name:this.config.repository.name,...this.config.repository.token?{token:this.config.repository.token}:{},...this.config.repository.apiUrl?{apiUrl:this.config.repository.apiUrl}:{}},{logger:this.logger}),X=await this.collectDashboardData($),Q=this.config.dashboard||{},{title:K,body:Z}=this.dashboardGenerator.generateDashboard(X,{showOpenPRs:Q.showOpenPRs??!0,showDetectedDependencies:Q.showDetectedDependencies??!0,showDeprecatedDependencies:Q.showDeprecatedDependencies??!0,includePackageJson:Q.includePackageJson??!0,includeDependencyFiles:Q.includeDependencyFiles??!0,includeGitHubActions:Q.includeGitHubActions??!0,bodyTemplate:Q.bodyTemplate}),Y={title:Q.title||K,body:Z,labels:Q.labels||["dependencies","dashboard"],assignees:Q.assignees},W=await this.findExistingDashboard($,Q.issueNumber),_=null;if(W){if(this.logger.info(`Updating existing dashboard issue #${W.number}`),_=await this.updateDashboardIssue($,W.number,Y),_)this.logger.success(`\u2705 Successfully updated dashboard issue #${_.number}`)}if(!_){this.logger.info("Creating new dashboard issue"),this.logger.info("Performing final check for existing dashboards before creation...");let z=await this.findExistingDashboard($,Q.issueNumber);if(z&&z.number!==W?.number){if(this.logger.info(`Race condition detected! Found existing dashboard #${z.number} during final check`),_=await this.updateDashboardIssue($,z.number,Y),_)this.logger.success(`\u2705 Updated existing dashboard issue #${_.number} (race condition avoided)`)}if(!_)_=await $.createIssue(Y),this.logger.success(`\u2705 Successfully created new dashboard issue #${_.number}`)}if(Q.pin!==void 0)if(!Q.pin)await $.unpinIssue(_.number);else if(p($,"pinIssues","pinIssue"))await $.pinIssue(_.number);else this.logger.debug("\uD83D\uDCCC Provider does not support pinning issues; leaving the dashboard unpinned");return this.logger.success(`\u2705 Dashboard updated: ${_.url}`),await this.events.emit("dashboard.updated",{number:_.number,url:_.url}),_}catch($){throw this.logger.error("Failed to create or update dashboard:",$),$}}async collectDashboardData($){let[X,Q]=await Promise.all([this.scanner.scanProject(),$.getPullRequests("open")]),K=Q.filter((H)=>H.labels.includes("dependencies")||H.labels.includes("dependency")||H.labels.includes("deps")||H.title.toLowerCase().includes("update")||H.title.toLowerCase().includes("chore(deps)")||H.title.toLowerCase().includes("bump")||H.title.toLowerCase().includes("upgrade")||H.title.toLowerCase().includes("renovate")||H.head.includes("renovate/")||H.head.includes("dependabot/")||H.head.includes("buddy/")||H.head.includes("update-")||H.head.includes("bump-")),Z=X.filter((H)=>H.type==="package.json"),Y=X.filter((H)=>H.path.includes(".github/workflows/")&&(H.path.endsWith(".yml")||H.path.endsWith(".yaml"))),W=X.filter((H)=>!H.path.includes(".github/workflows/")&&H.type!=="package.json"),z=await new u0().checkDeprecatedDependencies(X),L=await this.findVulnerableDependencies(X),O=await this.findCappedDependencies(X);return{openPRs:K,detectedDependencies:{packageJson:Z,dependencyFiles:W,githubActions:Y},deprecatedDependencies:z,vulnerableDependencies:L,cappedDependencies:O,repository:{owner:this.config.repository.owner,name:this.config.repository.name,provider:this.config.repository.provider},lastUpdated:new Date}}async findCappedDependencies($){if(this.config.packages?.detectResolutionDrift===!1)return[];try{let{collectDriftInputs:X}=await import("./chunk-0t8q4880.js"),{findDrift:Q}=await import("./chunk-zc7g037n.js"),K=await X($,this.registryClient,this.projectPath,this.logger),Z=Q(K).filter((Y)=>Y.kind==="capped");if(Z.length>0)this.logger.info(`\uD83D\uDD17 ${Z.length} package(s) capped by a dependant's range`);return Z}catch(X){return this.logger.warn("Resolution drift analysis failed, continuing without it:",X),[]}}async findVulnerableDependencies($){if(this.config.security?.enabled===!1)return[];let X=[],Q=new Map;for(let K of $)for(let Z of K.dependencies){let Y=H0(Z.type);if(!Y)continue;let W=Z.currentVersion.replace(/^[\^~>=<\s]*v?/,"").trim();if(!W)continue;let _={name:Z.name,version:W,ecosystem:Y},z=t(_);if(Q.has(z))continue;Q.set(z,{name:Z.name,currentVersion:Z.currentVersion,ecosystem:Y,file:K.path}),X.push(_)}if(X.length===0)return[];try{let Z=await new a(this.logger).findAdvisories(X),Y=this.config.security?.minimumSeverity??"low",W={low:0,moderate:1,high:2,critical:3},_=[];for(let[z,L]of Z){let O=Q.get(z);if(!O)continue;let H=L.filter((J)=>W[J.severity]>=W[Y]);if(H.length>0)_.push({...O,advisories:H})}return _.sort((z,L)=>W[L.advisories[0].severity]-W[z.advisories[0].severity]),_}catch(K){return this.logger.warn("Vulnerability check failed, dashboard will omit it:",K),[]}}async updateDashboardIssue($,X,Q){try{return await $.updateIssue(X,Q)}catch(K){if(K instanceof x0&&K.isNotFound)return this.logger.warn(`Dashboard issue #${X} no longer exists in ${K.repository} (${K.status}); creating a replacement dashboard instead.`),null;throw K}}async findExistingDashboard($,X){try{if(this.logger.info("Searching for existing dashboard issue..."),X){this.logger.info(`Looking for specific dashboard issue #${X}`);let _=(await $.getIssues("open")).find((z)=>z.number===X);if(_)return this.logger.info(`Found specified dashboard issue #${_.number}: ${_.title}`),_;else return this.logger.warn(`Specified dashboard issue #${X} not found`),null}let Q=await $.getIssues("open");this.logger.info(`Found ${Q.length} open issues to search through`);for(let W of Q){let _=W.labels.includes("dashboard")&&W.labels.includes("dependencies"),z=W.title.toLowerCase().includes("dependency dashboard"),L=W.body.includes("This issue lists Buddy updates and detected dependencies");if(L||_&&z)return this.logger.info(`Found existing dashboard issue #${W.number}: ${W.title}`),this.logger.info(` - Labels: ${W.labels.join(", ")}`),this.logger.info(` - Title matches: ${z}`),this.logger.info(` - Body has marker: ${L}`),W}let K=Q.filter((W)=>W.labels.includes("dashboard")),Z=Q.filter((W)=>W.labels.includes("dependencies")),Y=Q.filter((W)=>W.title.toLowerCase().includes("dependency dashboard"));if(this.logger.info("Dashboard search results:"),this.logger.info(` - Issues with 'dashboard' label: ${K.length}`),this.logger.info(` - Issues with 'dependencies' label: ${Z.length}`),this.logger.info(` - Issues with 'dependency dashboard' in title: ${Y.length}`),K.length>0){this.logger.info("Issues with 'dashboard' label:");for(let W of K)this.logger.info(` - #${W.number}: ${W.title} (labels: ${W.labels.join(", ")})`)}return this.logger.info("No existing dashboard issue found"),null}catch(Q){throw this.logger.error(`Failed to search for existing dashboard: ${Q}`),Q}}}
106
- export{H0 as Zc,a0 as _c,a as $c,t as ad,C0 as bd,Q0 as cd};
105
+ `;return W+="If this was closed in error, please reopen the PR and update the dependency files accordingly.",W}async createOrUpdateDashboard(){try{if(this.logger.info("Creating or updating dependency dashboard..."),!this.config.repository)throw Error("Repository configuration is required for dashboard");if(this.config.repository.provider!=="github")throw Error("Dashboard is currently only supported for GitHub repositories");if(!this.config.repository.owner||!this.config.repository.name)throw Error("Repository owner and name are required for dashboard. Set them in buddy.config.ts or ensure GITHUB_REPOSITORY env var is available.");let $=await X0({provider:this.config.repository.provider,owner:this.config.repository.owner,name:this.config.repository.name,...this.config.repository.token?{token:this.config.repository.token}:{},...this.config.repository.apiUrl?{apiUrl:this.config.repository.apiUrl}:{}},{logger:this.logger}),X=await this.collectDashboardData($),Q=this.config.dashboard||{},{title:K,body:Z}=this.dashboardGenerator.generateDashboard(X,{showOpenPRs:Q.showOpenPRs??!0,showDetectedDependencies:Q.showDetectedDependencies??!0,showDeprecatedDependencies:Q.showDeprecatedDependencies??!0,includePackageJson:Q.includePackageJson??!0,includeDependencyFiles:Q.includeDependencyFiles??!0,includeGitHubActions:Q.includeGitHubActions??!0,bodyTemplate:Q.bodyTemplate}),Y={title:Q.title||K,body:Z,labels:Q.labels||["dependencies","dashboard"],assignees:Q.assignees},W=await this.findExistingDashboard($,Q.issueNumber),_=null;if(W){if(this.logger.info(`Updating existing dashboard issue #${W.number}`),_=await this.updateDashboardIssue($,W.number,Y),_)this.logger.success(`\u2705 Successfully updated dashboard issue #${_.number}`)}if(!_){this.logger.info("Creating new dashboard issue"),this.logger.info("Performing final check for existing dashboards before creation...");let z=await this.findExistingDashboard($,Q.issueNumber);if(z&&z.number!==W?.number){if(this.logger.info(`Race condition detected! Found existing dashboard #${z.number} during final check`),_=await this.updateDashboardIssue($,z.number,Y),_)this.logger.success(`\u2705 Updated existing dashboard issue #${_.number} (race condition avoided)`)}if(!_)_=await $.createIssue(Y),this.logger.success(`\u2705 Successfully created new dashboard issue #${_.number}`)}if(Q.pin!==void 0)if(!Q.pin)await $.unpinIssue(_.number);else if(p($,"pinIssues","pinIssue"))await $.pinIssue(_.number);else this.logger.debug("\uD83D\uDCCC Provider does not support pinning issues; leaving the dashboard unpinned");return this.logger.success(`\u2705 Dashboard updated: ${_.url}`),await this.events.emit("dashboard.updated",{number:_.number,url:_.url}),_}catch($){throw this.logger.error("Failed to create or update dashboard:",$),$}}async collectDashboardData($){let[X,Q]=await Promise.all([this.scanner.scanProject(),$.getPullRequests("open")]),K=Q.filter((H)=>H.labels.includes("dependencies")||H.labels.includes("dependency")||H.labels.includes("deps")||H.title.toLowerCase().includes("update")||H.title.toLowerCase().includes("chore(deps)")||H.title.toLowerCase().includes("bump")||H.title.toLowerCase().includes("upgrade")||H.title.toLowerCase().includes("renovate")||H.head.includes("renovate/")||H.head.includes("dependabot/")||H.head.includes("buddy/")||H.head.includes("update-")||H.head.includes("bump-")),Z=X.filter((H)=>H.type==="package.json"),Y=X.filter((H)=>H.path.includes(".github/workflows/")&&(H.path.endsWith(".yml")||H.path.endsWith(".yaml"))),W=X.filter((H)=>!H.path.includes(".github/workflows/")&&H.type!=="package.json"),z=await new u0().checkDeprecatedDependencies(X),L=await this.findVulnerableDependencies(X),O=await this.findCappedDependencies(X);return{openPRs:K,detectedDependencies:{packageJson:Z,dependencyFiles:W,githubActions:Y},deprecatedDependencies:z,vulnerableDependencies:L,cappedDependencies:O,repository:{owner:this.config.repository.owner,name:this.config.repository.name,provider:this.config.repository.provider},lastUpdated:new Date}}async findCappedDependencies($){if(this.config.packages?.detectResolutionDrift===!1)return[];try{let{collectDriftInputs:X}=await import("./chunk-zkv7e2q2.js"),{findDrift:Q}=await import("./chunk-4b0p7kgk.js"),K=await X($,this.registryClient,this.projectPath,this.logger),Z=Q(K).filter((Y)=>Y.kind==="capped");if(Z.length>0)this.logger.info(`\uD83D\uDD17 ${Z.length} package(s) capped by a dependant's range`);return Z}catch(X){return this.logger.warn("Resolution drift analysis failed, continuing without it:",X),[]}}async findVulnerableDependencies($){if(this.config.security?.enabled===!1)return[];let X=[],Q=new Map;for(let K of $)for(let Z of K.dependencies){let Y=H0(Z.type);if(!Y)continue;let W=Z.currentVersion.replace(/^[\^~>=<\s]*v?/,"").trim();if(!W)continue;let _={name:Z.name,version:W,ecosystem:Y},z=t(_);if(Q.has(z))continue;Q.set(z,{name:Z.name,currentVersion:Z.currentVersion,ecosystem:Y,file:K.path}),X.push(_)}if(X.length===0)return[];try{let Z=await new a(this.logger).findAdvisories(X),Y=this.config.security?.minimumSeverity??"low",W={low:0,moderate:1,high:2,critical:3},_=[];for(let[z,L]of Z){let O=Q.get(z);if(!O)continue;let H=L.filter((J)=>W[J.severity]>=W[Y]);if(H.length>0)_.push({...O,advisories:H})}return _.sort((z,L)=>W[L.advisories[0].severity]-W[z.advisories[0].severity]),_}catch(K){return this.logger.warn("Vulnerability check failed, dashboard will omit it:",K),[]}}async updateDashboardIssue($,X,Q){try{return await $.updateIssue(X,Q)}catch(K){if(K instanceof x0&&K.isNotFound)return this.logger.warn(`Dashboard issue #${X} no longer exists in ${K.repository} (${K.status}); creating a replacement dashboard instead.`),null;throw K}}async findExistingDashboard($,X){try{if(this.logger.info("Searching for existing dashboard issue..."),X){this.logger.info(`Looking for specific dashboard issue #${X}`);let _=(await $.getIssues("open")).find((z)=>z.number===X);if(_)return this.logger.info(`Found specified dashboard issue #${_.number}: ${_.title}`),_;else return this.logger.warn(`Specified dashboard issue #${X} not found`),null}let Q=await $.getIssues("open");this.logger.info(`Found ${Q.length} open issues to search through`);for(let W of Q){let _=W.labels.includes("dashboard")&&W.labels.includes("dependencies"),z=W.title.toLowerCase().includes("dependency dashboard"),L=W.body.includes("This issue lists Buddy updates and detected dependencies");if(L||_&&z)return this.logger.info(`Found existing dashboard issue #${W.number}: ${W.title}`),this.logger.info(` - Labels: ${W.labels.join(", ")}`),this.logger.info(` - Title matches: ${z}`),this.logger.info(` - Body has marker: ${L}`),W}let K=Q.filter((W)=>W.labels.includes("dashboard")),Z=Q.filter((W)=>W.labels.includes("dependencies")),Y=Q.filter((W)=>W.title.toLowerCase().includes("dependency dashboard"));if(this.logger.info("Dashboard search results:"),this.logger.info(` - Issues with 'dashboard' label: ${K.length}`),this.logger.info(` - Issues with 'dependencies' label: ${Z.length}`),this.logger.info(` - Issues with 'dependency dashboard' in title: ${Y.length}`),K.length>0){this.logger.info("Issues with 'dashboard' label:");for(let W of K)this.logger.info(` - #${W.number}: ${W.title} (labels: ${W.labels.join(", ")})`)}return this.logger.info("No existing dashboard issue found"),null}catch(Q){throw this.logger.error(`Failed to search for existing dashboard: ${Q}`),Q}}}
106
+ export{H0 as _c,a0 as $c,a as ad,t as bd,C0 as cd,Q0 as dd};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Gh as M}from"./chunk-b4a5gw9c.js";import{Jh as K,Mh as Q}from"./chunk-bprmzg0p.js";class V{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)=>z.name?.startsWith("buddy/")).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{V as Bh};
2
+ import{Hh as M}from"./chunk-ddmvjp0y.js";import{Kh as K,Nh as Q}from"./chunk-f0z6kyqt.js";class V{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)=>z.name?.startsWith("buddy/")).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{V as Ch};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Pe as a,Qe as b,Re as c,Se as d,Te as e,Ue as f}from"./chunk-v6dephze.js";import"./chunk-ddmvjp0y.js";import"./chunk-f0z6kyqt.js";import"./chunk-6sm15trq.js";export{e as updateDockerfile,d as resolveDockerDigest,b as parseDockerfile,a as isDockerfile,f as generateDockerfileUpdates,c as fetchLatestDockerImageVersion};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{xf as Q,yf as J}from"./chunk-ffb50kwa.js";var L=`Verify your work before reporting it done: run the project's
2
+ import{yf as Q,zf as J}from"./chunk-jpdd59fh.js";var L=`Verify your work before reporting it done: run the project's
3
3
  tests or build if one exists. If verification fails, report what failed rather
4
4
  than claiming success \u2014 a change that looks right and breaks the build costs
5
5
  more than no change at all.`,X={name:"docstrings",description:"Add missing doc comments to changed public APIs",mode:J,defaultOutput:"commit",buildTask:({files:j})=>["Add missing documentation comments to the public APIs changed on this branch.","","Follow the documentation style already used in the surrounding code \u2014 match its","density and conventions rather than importing a different house style.","Document what a caller needs: parameters, return value, thrown errors, and any","constraint the signature does not already show. Do not restate what the code says.","","Do not document code that was not changed, and do not modify behaviour.",j?.length?`
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{bl as Z}from"./chunk-4sqwtry6.js";import x from"process";var K=["github","gitlab","bitbucket"],$=["github","gitlab","bitbucket"],H={},L={pinIssues:!1,checkRuns:!1,inlineReviewComments:!1,reviewSuggestions:!1,nativeAutoMerge:!1,commentReactions:!1,ciLogs:!1,ciRuns:!1,reviewThreads:!1,teamReviewers:!1,draftPullRequests:!1,permissionLookup:!1,branchHousekeeping:!1,reopenPullRequests:!1,labels:!1};class Y extends Error{provider;trackingIssue;constructor(j,z,F){super(j);this.provider=z;this.trackingIssue=F;this.name="UnsupportedProviderError"}}var B={github:["GITHUB_TOKEN","BUDDY_TOKEN"],gitlab:["CI_JOB_TOKEN","GITLAB_TOKEN","BUDDY_TOKEN"],bitbucket:["BITBUCKET_TOKEN","BUDDY_TOKEN"]};function A(j,z=x.env){for(let F of B[j]??[]){let J=z[F]?.trim();if(J)return{token:J,source:F}}return null}function C(j){if($.includes(j))return;let z=H[j];if(z)throw new Y(`'${j}' support is not implemented yet \u2014 follow ${z}. Supported today: ${$.join(", ")}.`,j,z);throw new Y(`Unknown git provider '${j}'. Supported: ${$.join(", ")}.`,j)}async function M(j,z={}){let F=j.provider??"github";C(F);let J=z.env??x.env,X=j.token??A(F,J)?.token;if(!X)throw Error(`No token for ${F}. Set one of: ${B[F].join(", ")}.`);switch(F){case"gitlab":{let{GitLabProvider:Q}=await import("./chunk-qe63pqwy.js");return new Q(X,j.owner,j.name,j.apiUrl,z.logger)}case"bitbucket":{let{BitbucketProvider:Q}=await import("./chunk-r9k5vnrw.js");return new Q(X,j.owner,j.name,j.apiUrl,z.logger)}case"github":{let{GitHubProvider:Q}=await import("./chunk-vj9stet1.js"),q=j.workflowToken??J.BUDDY_TOKEN;return new Q(X,j.owner,j.name,Boolean(q),q,j.apiUrl,z.logger)}}}function W(j,z,F){return j.capabilities()[z]===!0&&typeof j[F]==="function"}function S(j,z,F,J){if(W(j,z,F))return;throw new Y(`This provider does not support ${J} (missing capability '${z}').`,"unknown")}
3
- export{K as ge,$ as he,H as ie,L as je,Y as ke,B as le,A as me,C as ne,M as oe,W as pe,S as qe};
2
+ import{cl as Z}from"./chunk-6sm15trq.js";import x from"process";var K=["github","gitlab","bitbucket"],$=["github","gitlab","bitbucket"],H={},L={pinIssues:!1,checkRuns:!1,inlineReviewComments:!1,reviewSuggestions:!1,nativeAutoMerge:!1,commentReactions:!1,ciLogs:!1,ciRuns:!1,reviewThreads:!1,teamReviewers:!1,draftPullRequests:!1,permissionLookup:!1,branchHousekeeping:!1,reopenPullRequests:!1,labels:!1};class Y extends Error{provider;trackingIssue;constructor(j,z,F){super(j);this.provider=z;this.trackingIssue=F;this.name="UnsupportedProviderError"}}var B={github:["GITHUB_TOKEN","BUDDY_TOKEN"],gitlab:["CI_JOB_TOKEN","GITLAB_TOKEN","BUDDY_TOKEN"],bitbucket:["BITBUCKET_TOKEN","BUDDY_TOKEN"]};function A(j,z=x.env){for(let F of B[j]??[]){let J=z[F]?.trim();if(J)return{token:J,source:F}}return null}function C(j){if($.includes(j))return;let z=H[j];if(z)throw new Y(`'${j}' support is not implemented yet \u2014 follow ${z}. Supported today: ${$.join(", ")}.`,j,z);throw new Y(`Unknown git provider '${j}'. Supported: ${$.join(", ")}.`,j)}async function M(j,z={}){let F=j.provider??"github";C(F);let J=z.env??x.env,X=j.token??A(F,J)?.token;if(!X)throw Error(`No token for ${F}. Set one of: ${B[F].join(", ")}.`);switch(F){case"gitlab":{let{GitLabProvider:Q}=await import("./chunk-eme4fny7.js");return new Q(X,j.owner,j.name,j.apiUrl,z.logger)}case"bitbucket":{let{BitbucketProvider:Q}=await import("./chunk-m8kqe55k.js");return new Q(X,j.owner,j.name,j.apiUrl,z.logger)}case"github":{let{GitHubProvider:Q}=await import("./chunk-yd834q68.js"),q=j.workflowToken??J.BUDDY_TOKEN;return new Q(X,j.owner,j.name,Boolean(q),q,j.apiUrl,z.logger)}}}function W(j,z,F){return j.capabilities()[z]===!0&&typeof j[F]==="function"}function S(j,z,F,J){if(W(j,z,F))return;throw new Y(`This provider does not support ${J} (missing capability '${z}').`,"unknown")}
3
+ export{K as he,$ as ie,H as je,L as ke,Y as le,B as me,A as ne,C as oe,M as pe,W as qe,S as re};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{La as a,Ma as b,Na as c,Oa as d,Pa as e,Qa as f,Ra as g,Sa as h,Ta as i,Ua as j}from"./chunk-43p5vzvb.js";import"./chunk-bxdbf2kj.js";import"./chunk-e6wny1pp.js";import"./chunk-yj6xx2b8.js";import"./chunk-f7aw9cr3.js";import"./chunk-b4a5gw9c.js";import"./chunk-bprmzg0p.js";import"./chunk-4sqwtry6.js";export{c as stripNonCommandContext,d as parseCommand,f as mentionsBot,e as isReadOnlyCommand,i as dispatchCommand,j as createHandlers,h as checkPermission,b as READ_ONLY_COMMANDS,g as HELP_TEXT,a as COMMAND_ALIASES};
2
+ import{La as a,Ma as b,Na as c,Oa as d,Pa as e,Qa as f,Ra as g,Sa as h,Ta as i,Ua as j}from"./chunk-4mwgk0jh.js";import"./chunk-4gx2f1k6.js";import"./chunk-3d3rwmmj.js";import"./chunk-emygmh7r.js";import"./chunk-kpqez1ht.js";import"./chunk-ddmvjp0y.js";import"./chunk-f0z6kyqt.js";import"./chunk-6sm15trq.js";export{c as stripNonCommandContext,d as parseCommand,f as mentionsBot,e as isReadOnlyCommand,i as dispatchCommand,j as createHandlers,h as checkPermission,b as READ_ONLY_COMMANDS,g as HELP_TEXT,a as COMMAND_ALIASES};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Cb as a,Db as b}from"./chunk-qk43d3vv.js";import"./chunk-q2tjkhez.js";import"./chunk-5yfaptmp.js";import"./chunk-4gx2f1k6.js";import"./chunk-3d3rwmmj.js";import"./chunk-j0bsva07.js";import"./chunk-xny4kgcc.js";import"./chunk-1z4nhstx.js";import"./chunk-emygmh7r.js";import"./chunk-kpqez1ht.js";import"./chunk-ddmvjp0y.js";import"./chunk-f0z6kyqt.js";import"./chunk-6sm15trq.js";export{b as runReviewForPR,a as reviewPullRequest};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{aa as a,ba as b,ca as c,da as d,ea as e,fa as f,ga as g,ha as h,ia as i,ja as j}from"./chunk-69qyr9ef.js";import"./chunk-4sqwtry6.js";export{d as similarity,j as renderQuickLinks,b as renderPackageContext,h as parseQuickSelection,a as findMentionedPackages,e as findDuplicates,c as constrainLabels,i as clearQuickSelection,f as QUICK_LINKS_MARKER,g as QUICK_ACTIONS};
2
+ import{aa as a,ba as b,ca as c,da as d,ea as e,fa as f,ga as g,ha as h,ia as i,ja as j}from"./chunk-69qyr9ef.js";import"./chunk-6sm15trq.js";export{d as similarity,j as renderQuickLinks,b as renderPackageContext,h as parseQuickSelection,a as findMentionedPackages,e as findDuplicates,c as constrainLabels,i as clearQuickSelection,f as QUICK_LINKS_MARKER,g as QUICK_ACTIONS};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Oh as s,Ph as o,Qh as p,Rh as a}from"./chunk-njfbmhm4.js";import"./chunk-6sm15trq.js";a();export{o as pantry,p as packages,s as aliases};