@buddysh/buddy 0.11.0 → 0.11.2

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 (246) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +54 -43
  3. package/bin/cli.ts +282 -135
  4. package/dist/bin/cli.d.ts +5 -1
  5. package/dist/bin/cli.js +84 -91
  6. package/dist/chunk-05me15qw.js +2 -0
  7. package/dist/{chunk-bxfc4g2x.js → chunk-08x5b93v.js} +2 -13
  8. package/dist/chunk-0eg3kxb5.js +5 -0
  9. package/dist/chunk-0hc97k0t.js +44 -0
  10. package/dist/chunk-0paakbpj.js +2 -0
  11. package/dist/{chunk-hfvezfxh.js → chunk-0scz1dv5.js} +1 -1
  12. package/dist/{chunk-sp818c27.js → chunk-0w695m54.js} +5 -5
  13. package/dist/{chunk-vyapg8ca.js → chunk-11hdrnf6.js} +3 -3
  14. package/dist/{chunk-1stt2whn.js → chunk-15r904nz.js} +2 -2
  15. package/dist/{chunk-5k40mwd4.js → chunk-193abzy6.js} +1 -1
  16. package/dist/chunk-19zyq15p.js +2 -0
  17. package/dist/chunk-1c4690h9.js +79 -0
  18. package/dist/{chunk-q9n79dd3.js → chunk-1cpdz49v.js} +1 -1
  19. package/dist/{chunk-thaxgm5p.js → chunk-1qgr52wx.js} +1 -1
  20. package/dist/chunk-24c2ab29.js +2 -0
  21. package/dist/chunk-25sz1y7j.js +16 -0
  22. package/dist/chunk-2et8yavs.js +3 -0
  23. package/dist/chunk-2wj5xtdn.js +2 -0
  24. package/dist/{chunk-7mgec8kb.js → chunk-3901s7h9.js} +1 -1
  25. package/dist/{chunk-xvptf9jy.js → chunk-3cvng2nz.js} +2 -2
  26. package/dist/chunk-3fzbvs2p.js +2 -0
  27. package/dist/chunk-3pqra420.js +2 -0
  28. package/dist/{chunk-yk23nc4t.js → chunk-40znfg3x.js} +1 -1
  29. package/dist/chunk-428c5652.js +2 -0
  30. package/dist/chunk-49znmbh8.js +2 -0
  31. package/dist/chunk-5044y9en.js +5 -0
  32. package/dist/chunk-5yfaptmp.js +7 -0
  33. package/dist/{chunk-h7hs95wn.js → chunk-61xecp1z.js} +2 -2
  34. package/dist/{chunk-x0ya2r4r.js → chunk-657nbbp7.js} +2 -2
  35. package/dist/chunk-68fw3ma0.js +2 -0
  36. package/dist/{chunk-9h04nskh.js → chunk-69qyr9ef.js} +1 -1
  37. package/dist/chunk-6bd8ghkz.js +27 -0
  38. package/dist/{chunk-vh504tcv.js → chunk-6p4qz8qv.js} +2 -2
  39. package/dist/chunk-847g7jde.js +2 -0
  40. package/dist/{chunk-r3zyw8x0.js → chunk-8fw0v7bv.js} +2 -2
  41. package/dist/chunk-8hjvthz4.js +92 -0
  42. package/dist/chunk-90zmqn5k.js +2 -0
  43. package/dist/{chunk-3zdcekfj.js → chunk-929h6hhp.js} +2 -2
  44. package/dist/chunk-96ht6hwd.js +4 -0
  45. package/dist/chunk-97qf7mdt.js +2 -0
  46. package/dist/chunk-a4hzzn28.js +2 -0
  47. package/dist/chunk-aa277p5r.js +2 -0
  48. package/dist/chunk-b357cgb0.js +2 -0
  49. package/dist/chunk-b9escac0.js +4 -0
  50. package/dist/{chunk-56q4pwb5.js → chunk-be629jhq.js} +2 -2
  51. package/dist/chunk-bffxf4xy.js +2 -0
  52. package/dist/chunk-brfyymhf.js +2 -0
  53. package/dist/{chunk-zs3jaj0g.js → chunk-bymwaezh.js} +165 -119
  54. package/dist/chunk-c3es7pgf.js +2 -0
  55. package/dist/{chunk-9750tenz.js → chunk-c8rzx3a1.js} +1 -1
  56. package/dist/{chunk-tzs22es2.js → chunk-cgvt98pd.js} +1 -1
  57. package/dist/chunk-cwfkm7h9.js +3 -0
  58. package/dist/chunk-cwqhxqv7.js +2 -0
  59. package/dist/chunk-dgfb8k0h.js +2 -0
  60. package/dist/chunk-dqbk3kcj.js +104 -0
  61. package/dist/chunk-ds4stft2.js +2 -0
  62. package/dist/{chunk-1h3ey7k5.js → chunk-e68nf7cm.js} +1 -1
  63. package/dist/chunk-emyvrx5t.js +2 -0
  64. package/dist/{chunk-16yqbccr.js → chunk-eseshkd0.js} +1 -1
  65. package/dist/chunk-f53y8ans.js +3 -0
  66. package/dist/chunk-fjp3a7hp.js +26 -0
  67. package/dist/chunk-fpnjpgrb.js +2 -0
  68. package/dist/chunk-fr5c326k.js +2 -0
  69. package/dist/chunk-g24hav8e.js +370 -0
  70. package/dist/{chunk-6md7qf2g.js → chunk-g30dr44w.js} +2 -2
  71. package/dist/chunk-gkpd5nw2.js +2 -0
  72. package/dist/chunk-hbhmns7s.js +2 -0
  73. package/dist/chunk-hd5j9e3c.js +2 -0
  74. package/dist/{chunk-akffynkc.js → chunk-hfjywbbc.js} +1 -1
  75. package/dist/chunk-hmskwy76.js +2 -0
  76. package/dist/chunk-hns85dqw.js +2 -0
  77. package/dist/{chunk-wtjhehz9.js → chunk-hptfq3rg.js} +1 -1
  78. package/dist/{chunk-54sc18p8.js → chunk-hsa07n7c.js} +1 -1
  79. package/dist/chunk-hwxmhkxp.js +2 -0
  80. package/dist/{chunk-52x8mvh4.js → chunk-jnb80k2x.js} +2 -2
  81. package/dist/chunk-jtxcr5yw.js +4 -0
  82. package/dist/{chunk-tn8prpny.js → chunk-k26wnmzk.js} +7 -7
  83. package/dist/{chunk-2bp7tqca.js → chunk-kprtsn8c.js} +1 -1
  84. package/dist/chunk-m4p7cnvk.js +2 -0
  85. package/dist/chunk-mcwxpdg9.js +2 -0
  86. package/dist/chunk-mkzmjg3f.js +4 -0
  87. package/dist/chunk-ncrq3fvv.js +2 -0
  88. package/dist/chunk-ng7px8gx.js +2 -0
  89. package/dist/{chunk-vagxqhef.js → chunk-nrr8z2z7.js} +2 -2
  90. package/dist/{chunk-g0w8n555.js → chunk-p6qbqsyp.js} +2 -2
  91. package/dist/chunk-p8tmms5h.js +3 -0
  92. package/dist/{chunk-hw70wbzg.js → chunk-phfmnnne.js} +2 -2
  93. package/dist/{chunk-tb5y0350.js → chunk-pkr6905p.js} +1 -1
  94. package/dist/chunk-ppmabn5h.js +2 -0
  95. package/dist/chunk-pskqrv5r.js +2 -0
  96. package/dist/{chunk-4xsq18p3.js → chunk-q2tjkhez.js} +1 -1
  97. package/dist/{chunk-6g1y9yqh.js → chunk-q4t568hv.js} +1 -1
  98. package/dist/chunk-qd2s51gc.js +2 -0
  99. package/dist/chunk-r763e19p.js +6 -0
  100. package/dist/{chunk-74pxb991.js → chunk-rc2mk5x6.js} +2 -2
  101. package/dist/{chunk-zb62jhwm.js → chunk-s4zb0fcj.js} +13 -9
  102. package/dist/chunk-s6z3gm2s.js +5 -0
  103. package/dist/chunk-sc7emb71.js +2 -0
  104. package/dist/chunk-sw2538r0.js +49 -0
  105. package/dist/chunk-t25apff9.js +2 -0
  106. package/dist/{chunk-p4zwy518.js → chunk-tjc2vgwn.js} +2 -2
  107. package/dist/{chunk-gngwjf70.js → chunk-tw047td6.js} +2 -2
  108. package/dist/chunk-tws3npt7.js +38 -0
  109. package/dist/{chunk-6d9hmjt8.js → chunk-txtrpypt.js} +2 -2
  110. package/dist/chunk-v1wfa758.js +2 -0
  111. package/dist/{chunk-dfesffnr.js → chunk-vckhctmr.js} +1 -1
  112. package/dist/chunk-vdd1cghr.js +2 -0
  113. package/dist/{chunk-fvpr07dn.js → chunk-vgtmrd4c.js} +1 -1
  114. package/dist/chunk-vj1sdxpp.js +2 -0
  115. package/dist/{chunk-fm8ckj9b.js → chunk-vqa6vte3.js} +1 -1
  116. package/dist/{chunk-82dv4p13.js → chunk-wn6pbyzn.js} +1 -1
  117. package/dist/chunk-x23a6szw.js +2 -0
  118. package/dist/{chunk-xqx460y2.js → chunk-xs12dtf1.js} +1 -1
  119. package/dist/chunk-xznnmhyt.js +2 -0
  120. package/dist/chunk-y3dd8v85.js +2 -0
  121. package/dist/chunk-yk183r6z.js +2 -0
  122. package/dist/{chunk-1c1gznm9.js → chunk-yngahb11.js} +2 -2
  123. package/dist/{chunk-qyf90zz3.js → chunk-yp1tgdh3.js} +1 -1
  124. package/dist/chunk-ys1qqcpp.js +2 -0
  125. package/dist/{chunk-8rc6042h.js → chunk-ytmxd5fk.js} +2 -2
  126. package/dist/chunk-zgkrhymn.js +2 -0
  127. package/dist/chunk-zxgkp71x.js +2 -0
  128. package/dist/src/agent/index.d.ts +6 -1
  129. package/dist/src/agent/modes.d.ts +0 -8
  130. package/dist/src/agent/plan.d.ts +28 -0
  131. package/dist/src/agent/tasks.d.ts +20 -0
  132. package/dist/src/agent/tools/issue.d.ts +19 -0
  133. package/dist/src/ci/attempts.d.ts +36 -0
  134. package/dist/src/ci/base.d.ts +55 -0
  135. package/dist/src/ci/fix.d.ts +27 -18
  136. package/dist/src/ci/index.d.ts +5 -1
  137. package/dist/src/ci/run.d.ts +28 -0
  138. package/dist/src/commands/handlers.d.ts +3 -0
  139. package/dist/src/dashboard/dashboard-generator.d.ts +4 -0
  140. package/dist/src/events/index.d.ts +12 -0
  141. package/dist/src/gates/checks.d.ts +10 -0
  142. package/dist/src/gates/index.d.ts +1 -0
  143. package/dist/src/gates/post-merge.d.ts +13 -1
  144. package/dist/src/git/github-provider.d.ts +5 -1
  145. package/dist/src/git/gitlab-provider.d.ts +5 -1
  146. package/dist/src/git/provider.d.ts +40 -0
  147. package/dist/src/index.d.ts +3 -0
  148. package/dist/src/index.js +1 -1
  149. package/dist/src/registry/registry-client.d.ts +1 -1
  150. package/dist/src/reports/index.d.ts +1 -0
  151. package/dist/src/reports/publish-gate.d.ts +22 -0
  152. package/dist/src/review/filters.d.ts +36 -0
  153. package/dist/src/review/index.d.ts +4 -1
  154. package/dist/src/review/marker.d.ts +18 -0
  155. package/dist/src/review/poster.d.ts +11 -1
  156. package/dist/src/review/resolve.d.ts +20 -0
  157. package/dist/src/review/run.d.ts +35 -0
  158. package/dist/src/rules/engine.d.ts +19 -0
  159. package/dist/src/scanner/package-json-extras.d.ts +34 -1
  160. package/dist/src/setup.d.ts +49 -17
  161. package/dist/src/setup.js +1 -1
  162. package/dist/src/templates/github-actions.d.ts +2 -0
  163. package/dist/src/types.d.ts +4 -1
  164. package/dist/src/upgrades/migrate.d.ts +3 -0
  165. package/dist/src/upgrades/report.d.ts +1 -0
  166. package/dist/src/utils/dockerfile-parser.d.ts +2 -2
  167. package/dist/src/utils/helpers.d.ts +10 -1
  168. package/dist/src/version/version-resolver.d.ts +1 -0
  169. package/package.json +12 -10
  170. package/dist/chunk-0j7z87kh.js +0 -3
  171. package/dist/chunk-0r8zt3d7.js +0 -2
  172. package/dist/chunk-1a53wj0h.js +0 -1
  173. package/dist/chunk-1wjnd24b.js +0 -24
  174. package/dist/chunk-1xe07hzm.js +0 -2
  175. package/dist/chunk-2dbkpfy9.js +0 -2
  176. package/dist/chunk-3q6czqs4.js +0 -6
  177. package/dist/chunk-49ey79p0.js +0 -5
  178. package/dist/chunk-4c9m61yd.js +0 -5
  179. package/dist/chunk-4efbxdjr.js +0 -4
  180. package/dist/chunk-4f7panqj.js +0 -21
  181. package/dist/chunk-4hd3rre0.js +0 -2
  182. package/dist/chunk-5c3qf34r.js +0 -2
  183. package/dist/chunk-5kt03hx5.js +0 -2
  184. package/dist/chunk-63ept76v.js +0 -2
  185. package/dist/chunk-65b3vq52.js +0 -2
  186. package/dist/chunk-6k653r8w.js +0 -2
  187. package/dist/chunk-6patq6bw.js +0 -2
  188. package/dist/chunk-6sgh49z1.js +0 -2
  189. package/dist/chunk-7tfrww3v.js +0 -2
  190. package/dist/chunk-7xk28xrv.js +0 -2
  191. package/dist/chunk-8661pvb8.js +0 -3
  192. package/dist/chunk-887s0w81.js +0 -2
  193. package/dist/chunk-978wtejw.js +0 -44
  194. package/dist/chunk-9eqpaxfz.js +0 -2
  195. package/dist/chunk-9p1xkmjy.js +0 -2
  196. package/dist/chunk-agdesgzv.js +0 -2
  197. package/dist/chunk-ar01x04a.js +0 -2
  198. package/dist/chunk-ay43f085.js +0 -2
  199. package/dist/chunk-bk9bqd5j.js +0 -2
  200. package/dist/chunk-bm8d40j0.js +0 -69
  201. package/dist/chunk-c3fczawt.js +0 -2
  202. package/dist/chunk-c9r9nd4t.js +0 -1
  203. package/dist/chunk-ctsz0ynx.js +0 -3
  204. package/dist/chunk-czremqk7.js +0 -2
  205. package/dist/chunk-da3wbh04.js +0 -2
  206. package/dist/chunk-dat582cg.js +0 -2
  207. package/dist/chunk-djntbp7a.js +0 -105
  208. package/dist/chunk-eagjp0dh.js +0 -3
  209. package/dist/chunk-eht72nnj.js +0 -2
  210. package/dist/chunk-f4nv5x3z.js +0 -2
  211. package/dist/chunk-fdfk918n.js +0 -2
  212. package/dist/chunk-fdj0tewy.js +0 -20
  213. package/dist/chunk-fqj7e6xa.js +0 -2
  214. package/dist/chunk-frm8zz31.js +0 -2
  215. package/dist/chunk-g0nv8psv.js +0 -2
  216. package/dist/chunk-gkmvxjbe.js +0 -2
  217. package/dist/chunk-j8asz4hb.js +0 -15
  218. package/dist/chunk-k62w2v03.js +0 -2
  219. package/dist/chunk-mcrfxphm.js +0 -5
  220. package/dist/chunk-mh3x7j6h.js +0 -2
  221. package/dist/chunk-naq32yx3.js +0 -86
  222. package/dist/chunk-nsmcjkas.js +0 -2
  223. package/dist/chunk-p1xm1jvz.js +0 -2
  224. package/dist/chunk-p3wsm8kz.js +0 -2
  225. package/dist/chunk-p7zgy37f.js +0 -2
  226. package/dist/chunk-ph1b3vbp.js +0 -315
  227. package/dist/chunk-pkjm2r0a.js +0 -2
  228. package/dist/chunk-pkkwb0n0.js +0 -4
  229. package/dist/chunk-pnpx1kqn.js +0 -6
  230. package/dist/chunk-qpz9k66h.js +0 -2
  231. package/dist/chunk-qvn1rtgp.js +0 -2
  232. package/dist/chunk-r06ce5g6.js +0 -2
  233. package/dist/chunk-r2sbprdb.js +0 -49
  234. package/dist/chunk-rqdep14r.js +0 -2
  235. package/dist/chunk-s1km8cyq.js +0 -2
  236. package/dist/chunk-s4ms8zag.js +0 -2
  237. package/dist/chunk-ts35hc5t.js +0 -3
  238. package/dist/chunk-vkctfqpm.js +0 -3
  239. package/dist/chunk-wdwvt7gb.js +0 -43
  240. package/dist/chunk-x3kragh9.js +0 -12
  241. package/dist/chunk-x9ctz1qc.js +0 -1
  242. package/dist/chunk-xakpdqaq.js +0 -3
  243. package/dist/chunk-yncea6ty.js +0 -2
  244. package/dist/chunk-yq0gxtzv.js +0 -2
  245. package/dist/chunk-yqhs08ky.js +0 -2
  246. package/dist/chunk-zve5d96e.js +0 -2
@@ -0,0 +1,92 @@
1
+ // @bun
2
+ import{lf as k,pf as b}from"./chunk-yngahb11.js";import{rf as C}from"./chunk-08x5b93v.js";import{If as x}from"./chunk-p6qbqsyp.js";import{mg as v}from"./chunk-3901s7h9.js";import{Fh as D}from"./chunk-hfjywbbc.js";var T={type:"object",properties:{changes:{type:"array",items:{type:"object",properties:{description:{type:"string",description:"What upstream changed"},version:{type:"string",description:"Version the change landed in"},affectedFiles:{type:"array",items:{type:"string"}},action:{type:"string",description:"What must be done in this repository"},automatable:{type:"boolean",description:"Whether the fix is mechanical"}},required:["description","affectedFiles","action","automatable"],additionalProperties:!1}},codemod:{type:"object",properties:{command:{type:"string",description:"Command that applies the official codemod"},source:{type:"string",description:"Where the codemod is documented"}},required:["command","source"],additionalProperties:!1},confidence:{type:"string",enum:["high","medium","low"]},effort:{type:"integer",description:"1 (trivial) to 5 (demanding)"},risks:{type:"array",items:{type:"string"}}},required:["changes","confidence","effort","risks"],additionalProperties:!1},f=[/^(?:bunx|npx|pnpm dlx|yarn dlx)\s+[\w@/.-]+(?:\s+[\w@/.:=-]+)*$/];function y(J){let Y=J.trim();if(/[;&|`$><\n]/.test(Y))return!1;return f.some((Q)=>Q.test(Y))}function R(J){let Y=J.usage.slice(0,100).map((Q)=>`${Q.path}:${Q.line} (${Q.kind}) ${Q.text}`).join(`
3
+ `);return[`Analyse upgrading \`${J.packageName}\` from ${J.fromVersion} to ${J.toVersion}.`,"","Report only breaking changes that affect THIS repository, judged against the","usage sites below. A breaking change in a feature this repository does not use","is not worth reporting, and listing it makes the real ones harder to find.","","Mark a change automatable only when the fix is a mechanical edit you could write","exactly. Anything needing judgement is not automatable.","","If the package publishes an official codemod for this upgrade, report the command.","","Set confidence honestly: high when every change is understood and mechanical,","low when the notes are unclear or the change touches something subtle. A low","confidence plan is more useful than a wrong high confidence one.","","--- Release notes across the version span ---",J.releaseNotes||"(none available)","",`--- Usage in this repository (${J.usage.length} site(s)) ---`,Y||"(no direct usage found)"].join(`
4
+ `)}function A(J,Y){let Q=J??{},Z=new Set(Y.knownFiles),K=(Array.isArray(Q.changes)?Q.changes:[]).filter(($)=>Boolean($&&typeof $.description==="string"&&typeof $.action==="string")).map(($)=>({description:$.description,...$.version?{version:$.version}:{},affectedFiles:(Array.isArray($.affectedFiles)?$.affectedFiles:[]).filter((j)=>Z.has(j)),action:$.action,automatable:$.automatable===!0})),H=Q.codemod&&y(Q.codemod.command)?Q.codemod:void 0;return{packageName:Y.packageName,fromVersion:Y.fromVersion,toVersion:Y.toVersion,changes:K,...H?{codemod:H}:{},confidence:h(Q.confidence,K),effort:m(Q.effort),risks:(Array.isArray(Q.risks)?Q.risks:[]).filter(($)=>typeof $==="string")}}function E(J,Y="high"){let Q={low:0,medium:1,high:2};return Q[J.confidence]<Q[Y]}function h(J,Y){let Q=J==="high"||J==="medium"||J==="low"?J:"low";if(Q==="high"&&Y.some((Z)=>!Z.automatable))return"medium";return Q}function m(J){let Y=Number(J);if(!Number.isFinite(Y))return 3;return Math.min(5,Math.max(1,Math.round(Y)))}import{resolve as g}from"path";var c=/\.(?:[cm]?[jt]sx?|vue|svelte)$/,u=/(?:^|\/)(?:[\w.-]*\.config\.[cm]?[jt]s|\.?[\w-]*rc(?:\.\w+)?|tsconfig\.json|vite\.config\.[cm]?[jt]s)$/;async function N(J,Y,Q){let Z=J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),K=`${Z}(?:/[^'"\`]*)?`,H=new RegExp(`(?:^|\\s)import\\s[^'"\`]*['"\`]${K}['"\`]|from\\s*['"\`]${K}['"\`]`),$=new RegExp(`require\\s*\\(\\s*['"\`]${K}['"\`]\\s*\\)`),j=new RegExp(`import\\s*\\(\\s*['"\`]${K}['"\`]\\s*\\)`),W=new RegExp(`(?:^|[^\\w@/.-])${Z}(?![\\w/.-])`),q=[];for(let X of Y){let B=c.test(X),_=u.test(X);if(!B&&!_)continue;let U;try{let z=Bun.file(g(Q,X));if(!await z.exists())continue;U=await z.text()}catch{continue}if(!U.includes(J))continue;for(let[z,G]of U.split(`
5
+ `).entries()){let F=null;if(H.test(G)||j.test(G))F="import";else if($.test(G))F="require";else if(_&&W.test(G))F="config";if(F)q.push({path:X,line:z+1,text:G.trim().slice(0,200),kind:F})}}return q}function V(J){let Y=new Map;for(let Q of J)Y.set(Q.path,(Y.get(Q.path)??0)+1);return[...Y.entries()].map(([Q,Z])=>({path:Q,count:Z})).sort((Q,Z)=>Z.count-Q.count)}var d={high:"\uD83D\uDFE2 high",medium:"\uD83D\uDFE1 medium",low:"\uD83D\uDD34 low"};function L(J,Y,Q=[]){let Z=`## \uD83D\uDD27 Migration report
6
+
7
+ `;if(Z+=`Upgrading \`${J.packageName}\` from \`${J.fromVersion}\` to \`${J.toVersion}\`.
8
+
9
+ `,Z+=`**Confidence:** ${d[J.confidence]} \xB7 **Effort:** ${"\u25CF".repeat(J.effort)}${"\u25CB".repeat(5-J.effort)} (${J.effort}/5)
10
+
11
+ `,J.changes.length===0)Z+=`No breaking changes in this span affect how this repository uses the package.
12
+
13
+ `;else{Z+=`### Breaking changes affecting this repository
14
+
15
+ `;for(let H of J.changes){let $=H.version?` _(${H.version})_`:"",j=H.automatable?"\uD83D\uDD27":"\u270B";if(Z+=`- ${j} **${I(H.description)}**${$}
16
+ `,Z+=` - ${I(H.action)}
17
+ `,H.affectedFiles.length>0)Z+=` - Affects: ${H.affectedFiles.map((W)=>`\`${W}\``).join(", ")}
18
+ `}Z+=`
19
+ \uD83D\uDD27 applied automatically \xB7 \u270B needs a person
20
+
21
+ `}if(J.codemod)Z+=`### Codemod
22
+
23
+ Ran \`${I(J.codemod.command)}\` (${I(J.codemod.source)}).
24
+
25
+ `;if(Y){if(Z+=`### What was done
26
+
27
+ `,!Y.applied)Z+=`No code changes were made \u2014 this is analysis only.
28
+
29
+ `;else if(Z+=`Changed ${Y.changedFiles.length} file(s):
30
+
31
+ `,Z+=`${Y.changedFiles.map((H)=>`- \`${H}\``).join(`
32
+ `)}
33
+
34
+ `,Z+=Y.verified?`\u2705 The repository's own tests pass with these changes.
35
+
36
+ `:`\u274C Verification did **not** pass. Treat these changes as a starting point, not a finished migration.
37
+
38
+ `,Y.verificationOutput&&!Y.verified)Z+=`<details><summary>Verification output</summary>
39
+
40
+ \`\`\`
41
+ ${Y.verificationOutput.slice(0,3000)}
42
+ \`\`\`
43
+
44
+ </details>
45
+
46
+ `;if(Y.unresolved.length>0)Z+=`### Still to do
47
+
48
+ `,Z+=`${Y.unresolved.map((H)=>`- [ ] ${I(H)}`).join(`
49
+ `)}
50
+
51
+ `}if(J.risks.length>0)Z+=`### Risks
52
+
53
+ ${J.risks.map((H)=>`- ${I(H)}`).join(`
54
+ `)}
55
+
56
+ `;let K=V(Q);if(K.length>0)Z+=`<details><summary>Where this package is used (${Q.length} site(s))</summary>
57
+
58
+ `,Z+=`${K.slice(0,40).map((H)=>`- \`${H.path}\` \u2014 ${H.count} reference(s)`).join(`
59
+ `)}
60
+
61
+ `,Z+=`</details>
62
+
63
+ `;return Z}function I(J){return J.replace(/\|/g,"\\|").replace(/\n/g," ").replace(/#(\d)/g,"#\u200B$1")}async function S(J){let Y=J.logger??D(),{update:Q}=J;if(!J.ai)return Y.debug("\uD83D\uDD27 Major upgrade analysis skipped: no AI provider configured"),{plan:null,report:"",draft:!1,status:"skipped"};let Z=await N(Q.name,J.files,J.workspace);Y.info(`\uD83D\uDD27 Analysing ${Q.name} ${Q.currentVersion} \u2192 ${Q.newVersion} (${Z.length} usage site(s))`);let K=[...new Set(Z.map((F)=>F.path))],H=await J.ai.complete({system:"You analyse major dependency upgrades. Report only what affects the repository "+"you are shown, and state confidence honestly \u2014 a low-confidence plan is more useful "+"than a wrong high-confidence one.",messages:[{role:"user",content:R({packageName:Q.name,fromVersion:Q.currentVersion,toVersion:Q.newVersion,releaseNotes:J.releaseNotes,usage:Z})}],jsonSchema:T}),$=A(H.json,{packageName:Q.name,fromVersion:Q.currentVersion,toVersion:Q.newVersion,knownFiles:K}),j=E($,J.draftBelowConfidence??"high");if(J.autoMigrate!==!0)return{plan:$,report:L($,void 0,Z),draft:j,status:"analysis-only"};if($.changes.length===0)return Y.info("\uD83D\uDD27 No breaking changes affect this repository; nothing to migrate"),{plan:$,report:L($,void 0,Z),draft:!1,status:"analysis-only"};let W=J.agent??x,q=Math.max(1,Math.floor(J.maxAttempts??1)),X=l($),B=await W(J.ai,{mode:C,task:X,context:{workspace:J.workspace,baseBranch:J.baseBranch,...J.branch?{branch:J.branch}:{}},logger:Y}),_=1,U=B.toolCalls>0;while(B.stopReason!=="completed"&&_<q)_++,Y.info(`\uD83D\uDD27 Migration attempt ${_} of ${q} (previous run ended: ${B.stopReason})`),B=await W(J.ai,{mode:C,task:`${X}
64
+
65
+ A previous attempt ended (${B.stopReason}) with this output:
66
+
67
+ ${B.output||"(no output)"}
68
+
69
+ Continue from the workspace as it stands now. Do not redo work that is already done.`,context:{workspace:J.workspace,baseBranch:J.baseBranch,...J.branch?{branch:J.branch}:{}},logger:Y}),U=U||B.toolCalls>0;let z=B.stopReason==="completed",G={applied:U,verified:z,attempts:_,changedFiles:K,unresolved:z?[]:$.changes.filter((F)=>!F.automatable).map((F)=>F.action),...z?{}:{verificationOutput:B.output}};return{plan:$,outcome:G,report:L($,G,Z),draft:j||!z,status:z?"migrated":"migration-failed"}}function l(J){let Y=J.changes.map((Q,Z)=>`${Z+1}. ${Q.description}
70
+ Action: ${Q.action}
71
+ Files: ${Q.affectedFiles.join(", ")||"(none identified)"}`);return[`Migrate this repository for the ${J.packageName} upgrade from ${J.fromVersion} to ${J.toVersion}.`,"",J.codemod?`An official codemod exists. Run it first:
72
+ ${J.codemod.command}
73
+ `:"","Breaking changes to address:","",Y.join(`
74
+
75
+ `),"","Change only what these require. A migration commit that also refactors","surrounding code is one a reviewer has to disentangle.","","Run the repository's tests when you are done. If they fail and you cannot fix it,","stop and report what failed \u2014 do not report success you have not verified."].filter(Boolean).join(`
76
+ `)}var BJ=24000,r=/^v?(\d+)\.(\d+)\.(\d+)/;function P(J){let Y=r.exec(J.trim());return Y?[Number(Y[1]),Number(Y[2]),Number(Y[3])]:null}function O(J,Y){return J[0]-Y[0]||J[1]-Y[1]||J[2]-Y[2]}function i(J,Y,Q){let[Z,K,H]=[P(J),P(Y),P(Q)];if(!Z||!K||!H)return!1;return O(Z,K)>0&&O(Z,H)<=0}function p(J){return P(J)?.[2]===0}function w(J,Y,Q,Z=24000){let K=J.filter((X)=>!X.isPrerelease&&i(X.version,Y,Q)),H=[],$=[];for(let X of K){let B=P(X.version)!==null&&P(Q)!==null&&O(P(X.version),P(Q))===0;if(p(X.version)||B)$.push(X);else H.push({version:X.version,reason:"patch-release"})}$.sort((X,B)=>O(P(B.version)??[0,0,0],P(X.version)??[0,0,0]));let j=[],W=[],q=0;for(let X of $){let B=s(X);if(q+B.length>Z){H.push({version:X.version,reason:"budget"});continue}j.push(B),W.push(X.version),q+=B.length}return{notes:j.join(`
77
+
78
+ ---
79
+
80
+ `),included:W,omitted:H,truncated:K.length===0&&Y!==Q}}function s(J){return`${J.htmlUrl?`## [${J.version}](${J.htmlUrl})`:`## ${J.version}`}
81
+
82
+ ${J.body.trim()}`.trim()}function M(J){if(J.truncated)return"\u26A0\uFE0F No release notes were found for this version span; the analysis below is based on usage sites alone.";let Y=J.omitted.filter((Q)=>Q.reason==="budget");if(Y.length===0)return"";return`\u26A0\uFE0F ${Y.length} release(s) in this span were omitted for length: ${Y.map((Q)=>Q.version).join(", ")}.`}function a(J,Y){if(!Y?.length)return!0;return Y.some((Q)=>{let Z=Q.split("*").map((K)=>K.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${Z}$`).test(J)})}async function _J(J){let Y=J.logger??D(),Q=J.config.ai?.majorUpgrades,Z={report:"",draft:!1,results:[],skipped:[]};if(!Q?.enabled||!J.ai)return Z;let K=J.updates.filter((W)=>W.updateType==="major");if(K.length===0)return Z;let H=[],$=[],j=[...b(J.config.packages?.groups),...J.config.packages?.rules??[]];for(let W of K){if(!a(W.name,Q.packages)){$.push({name:W.name,reason:"not matched by ai.majorUpgrades.packages"});continue}try{let q=await J.fetchReleases(W.name,W.currentVersion,W.newVersion),X=w(q,W.currentVersion,W.newVersion),B=M(X),U=(j.length>0?k(W,j).autoMigrate:void 0)??Q.autoMigrate,z=await S({update:W,releaseNotes:X.notes,files:J.files,workspace:J.workspace,baseBranch:J.baseBranch,ai:J.ai,...U!==void 0?{autoMigrate:U}:{},...Q.maxAttempts!==void 0?{maxAttempts:Q.maxAttempts}:{},...Q.draftBelowConfidence?{draftBelowConfidence:Q.draftBelowConfidence}:{},logger:Y});H.push({update:W,result:B?{...z,report:`${B}
83
+
84
+ ${z.report}`}:z})}catch(q){Y.warn(`\u26A0\uFE0F Could not analyse the ${W.name} major upgrade: ${q}`),$.push({name:W.name,reason:"analysis failed"})}}return{report:n(H,$),draft:H.some((W)=>W.result.draft),results:H,skipped:$}}function n(J,Y){let Q=J.filter((K)=>K.result.report).map((K)=>`### ${K.update.name} ${K.update.currentVersion} \u2192 ${K.update.newVersion}
85
+
86
+ ${K.result.report}`);if(Q.length===0&&Y.length===0)return"";let Z=["## Major upgrade analysis","",...Q];if(Y.length>0)Z.push("",`Not analysed: ${Y.map((K)=>`\`${K.name}\` (${K.reason})`).join(", ")}.`);return Z.join(`
87
+ `)}function GJ(J,Y){if(!Y.trim())return J;let Q=v(J),Z=J.slice(Q.length);return`${Q}
88
+
89
+ ---
90
+
91
+ ${Y}${Z}`}
92
+ export{T as We,y as Xe,R as Ye,A as Ze,E as _e,N as $e,V as af,L as bf,S as cf,BJ as df,w as ef,M as ff,a as gf,_J as hf,GJ as if};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{hb as a,ib as b,jb as c,kb as d,lb as e}from"./chunk-tw047td6.js";import"./chunk-p6qbqsyp.js";import"./chunk-cgvt98pd.js";import"./chunk-c8rzx3a1.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{b as verifyChanges,c as stackedBranchName,d as runStackedTouch,e as detectChangedFiles,a as TEST_COMMANDS};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Tb as Z}from"./chunk-p4zwy518.js";import{Fc as X}from"./chunk-mcrfxphm.js";import{Cd as V,pd as x}from"./chunk-vagxqhef.js";import{Ld as U,Md as Y}from"./chunk-ts35hc5t.js";import H from"process";var K=[["actionlint","actionlint"],["shellcheck","shellcheck"],["hadolint","hadolint"],["markdownlint","markdownlint"]];async function T(j,J={}){let W=J.env??H.env,Q=J.cwd??H.cwd(),F=J.hasCommand??x,G=[];G.push({name:"bun",status:"ok",detail:`Bun ${Bun.version}`});let C=await Bun.file(`${Q}/.git/HEAD`).exists();G.push(C?{name:"git repository",status:"ok",detail:Q}:{name:"git repository",status:"fail",detail:`${Q} is not a git repository`,remediation:"Run buddy from inside a repository, or run `git init`."});let $=X(j);G.push($.length===0?{name:"configuration",status:"ok",detail:"valid"}:{name:"configuration",status:"fail",detail:`${$.length} problem(s): ${$.slice(0,3).map((q)=>`${q.path} ${q.message}`).join("; ")}`,remediation:"Fix the paths reported above in buddy.config.ts."});let P=Boolean(j.repository?.owner&&j.repository.name);G.push(P?{name:"repository config",status:"ok",detail:`${j.repository.owner}/${j.repository.name}`}:{name:"repository config",status:"warn",detail:"owner and name are not set",remediation:"Set repository.owner and repository.name, or run in Actions where GITHUB_REPOSITORY is available. Local review works without them."});let B=j.repository?.provider??"github",D=j.repository?.token?{token:j.repository.token,source:"repository.token"}:Y(B,W);G.push(D?{name:"git token",status:"ok",detail:`found in ${D.source}`}:{name:"git token",status:"warn",detail:"no token found",remediation:`Set one of ${(U[B]??[]).join(", ")}. Local review does not need one.`});let b=Z(j,W);G.push(b?{name:"ai provider",status:"ok",detail:`${b.provider} via ${b.apiKeyEnv}`}:{name:"ai provider",status:"warn",detail:"no API key found",remediation:"Set ANTHROPIC_API_KEY (or OPENAI_API_KEY / GOOGLE_API_KEY). Dependency updates and static analysis work without one."});for(let[q,M]of K){let I=await F(M);G.push(I?{name:`analyzer: ${q}`,status:"ok",detail:`${M} found`}:{name:`analyzer: ${q}`,status:"warn",detail:`${M} not installed`,remediation:`Install ${M} to enable the ${q} analyzer. Reviews run without it and report it as skipped.`})}let w=V.filter((q)=>!K.some(([M])=>M===q.name)).map((q)=>q.name);return G.push({name:"native analyzers",status:"ok",detail:`${w.join(", ")} \u2014 always available`}),{checks:G,healthy:!G.some((q)=>q.status==="fail")}}var S={ok:"\u2705",warn:"\u26A0\uFE0F ",fail:"\u274C"};function E(j){let J=["","Buddy environment",""];for(let F of j.checks)if(J.push(`${S[F.status]} ${F.name}: ${F.detail}`),F.remediation)J.push(` \u2192 ${F.remediation}`);let W=j.checks.filter((F)=>F.status==="fail").length,Q=j.checks.filter((F)=>F.status==="warn").length;return J.push(""),J.push(j.healthy?`Ready. ${Q} optional capability/capabilities unavailable.`:`${W} problem(s) must be fixed before buddy can run.`),`${J.join(`
2
+ import{ec as Z}from"./chunk-tjc2vgwn.js";import{Sc as X}from"./chunk-0eg3kxb5.js";import{Nd as x,_d as V}from"./chunk-nrr8z2z7.js";import{he as U,ie as Y}from"./chunk-p8tmms5h.js";import H from"process";var K=[["actionlint","actionlint"],["shellcheck","shellcheck"],["hadolint","hadolint"],["markdownlint","markdownlint"]];async function T(j,J={}){let W=J.env??H.env,Q=J.cwd??H.cwd(),F=J.hasCommand??x,G=[];G.push({name:"bun",status:"ok",detail:`Bun ${Bun.version}`});let C=await Bun.file(`${Q}/.git/HEAD`).exists();G.push(C?{name:"git repository",status:"ok",detail:Q}:{name:"git repository",status:"fail",detail:`${Q} is not a git repository`,remediation:"Run buddy from inside a repository, or run `git init`."});let $=X(j);G.push($.length===0?{name:"configuration",status:"ok",detail:"valid"}:{name:"configuration",status:"fail",detail:`${$.length} problem(s): ${$.slice(0,3).map((q)=>`${q.path} ${q.message}`).join("; ")}`,remediation:"Fix the paths reported above in buddy.config.ts."});let P=Boolean(j.repository?.owner&&j.repository.name);G.push(P?{name:"repository config",status:"ok",detail:`${j.repository.owner}/${j.repository.name}`}:{name:"repository config",status:"warn",detail:"owner and name are not set",remediation:"Set repository.owner and repository.name, or run in Actions where GITHUB_REPOSITORY is available. Local review works without them."});let B=j.repository?.provider??"github",D=j.repository?.token?{token:j.repository.token,source:"repository.token"}:Y(B,W);G.push(D?{name:"git token",status:"ok",detail:`found in ${D.source}`}:{name:"git token",status:"warn",detail:"no token found",remediation:`Set one of ${(U[B]??[]).join(", ")}. Local review does not need one.`});let b=Z(j,W);G.push(b?{name:"ai provider",status:"ok",detail:`${b.provider} via ${b.apiKeyEnv}`}:{name:"ai provider",status:"warn",detail:"no API key found",remediation:"Set ANTHROPIC_API_KEY (or OPENAI_API_KEY / GOOGLE_API_KEY). Dependency updates and static analysis work without one."});for(let[q,M]of K){let I=await F(M);G.push(I?{name:`analyzer: ${q}`,status:"ok",detail:`${M} found`}:{name:`analyzer: ${q}`,status:"warn",detail:`${M} not installed`,remediation:`Install ${M} to enable the ${q} analyzer. Reviews run without it and report it as skipped.`})}let w=V.filter((q)=>!K.some(([M])=>M===q.name)).map((q)=>q.name);return G.push({name:"native analyzers",status:"ok",detail:`${w.join(", ")} \u2014 always available`}),{checks:G,healthy:!G.some((q)=>q.status==="fail")}}var S={ok:"\u2705",warn:"\u26A0\uFE0F ",fail:"\u274C"};function E(j){let J=["","Buddy environment",""];for(let F of j.checks)if(J.push(`${S[F.status]} ${F.name}: ${F.detail}`),F.remediation)J.push(` \u2192 ${F.remediation}`);let W=j.checks.filter((F)=>F.status==="fail").length,Q=j.checks.filter((F)=>F.status==="warn").length;return J.push(""),J.push(j.healthy?`Ready. ${Q} optional capability/capabilities unavailable.`:`${W} problem(s) must be fixed before buddy can run.`),`${J.join(`
3
3
  `)}
4
4
  `}
5
- export{T as V,E as W};
5
+ export{T as W,E as X};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{fc as _}from"./chunk-tjc2vgwn.js";import{Fh as X}from"./chunk-hfjywbbc.js";import{Wk as M}from"./chunk-q4t568hv.js";var K={review:"review","full-review":"full-review",full:"full-review",summary:"summary",resolve:"resolve",pause:"pause",resume:"resume",ignore:"ignore",rebase:"rebase",retry:"rebase",merge:"merge",plan:"plan","fix-ci":"fix-ci",fix:"fix-ci",remember:"remember",help:"help"},Q=["help","summary"];function V(H){return H.replace(/```[\s\S]*?```/g," ").replace(/~~~[\s\S]*?~~~/g," ").replace(/`[^`\n]*`/g," ").split(`
3
+ `).filter((C)=>!C.trimStart().startsWith(">")).join(`
4
+ `)}function $(H,C="@buddy"){if(!H)return null;let B=V(H),O=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),j=new RegExp(`(?:^|\\s)${O}\\b[ \\t]*(.*)`,"i"),z=B.match(j);if(!z)return null;let A=(z[1]??"").trim();if(!A)return{name:"help",args:"",raw:z[0].trim()};let[D,...E]=A.split(/\s+/),J=K[D.toLowerCase()];if(!J)return{name:"chat",args:A,raw:z[0].trim()};return{name:J,args:E.join(" "),raw:z[0].trim()}}function G(H){return Q.includes(H)}function F(H,C="@buddy"){return Boolean(H?.toLowerCase().includes(C.toLowerCase()))}var Y="**Buddy commands**\n\n| Command | What it does |\n|---|---|\n| `@buddy review` | Review new changes since the last review |\n| `@buddy full-review` | Review the whole diff again, ignoring previous findings |\n| `@buddy summary` | Post a fresh summary without inline findings |\n| `@buddy pause` / `resume` | Stop or restart reviewing this pull request |\n| `@buddy rebase` | Rebase a dependency update pull request |\n| `@buddy merge` | Re-check auto-merge conditions now |\n| `@buddy fix-ci` | Diagnose the failing checks, and retry a flake |\n| `@buddy plan` | Research the repository and write an implementation plan |\n| `@buddy resolve` | Close the review threads Buddy opened |\n| `@buddy remember <text>` | Record a durable note for future runs |\n| `@buddy help` | Show this table |\n\nAnything else after the mention is treated as a question.";function Z(H){if(H.actor.isBot)return"comment was written by a bot";if(G(H.command.name))return null;if(!H.actor.canWrite)return`@${H.actor.login} does not have write access`;return null}async function L(H,C){let B=H.logger??X(),O=Z(H);if(O)return B.info(`\uD83D\uDEAB Ignoring \`${H.command.name}\`: ${O}`),{handled:!1,refusal:O};if(H.command.name==="help")return{handled:!0,reply:Y};let j=C[H.command.name];if(!j)return{handled:!1,refusal:`no handler for ${H.command.name}`,reply:`I don't know how to \`${H.command.name}\` yet. Try \`@buddy help\`.`};return B.info(`\uD83E\uDD16 Running \`${H.command.name}\` for @${H.actor.login}`),await j(H)}function T(H){return{async review(C){if(!C.isPullRequest)return{handled:!1,reply:"There is nothing to review \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.review(C.number,{})}},async "full-review"(C){if(!C.isPullRequest)return{handled:!1,reply:"There is nothing to review \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.review(C.number,{full:!0})}},async summary(C){if(!C.isPullRequest)return{handled:!1,reply:"There is nothing to summarize \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.review(C.number,{summaryOnly:!0})}},async pause(C){return await I(H,C.number,!0),{handled:!0,reply:"Paused. I will not review this pull request again until you say `@buddy resume`."}},async resume(C){return await I(H,C.number,!1),{handled:!0,reply:"Resumed. I will review the next push."}},async ignore(C){return await I(H,C.number,!0),{handled:!0,reply:"Understood \u2014 I will leave this pull request alone."}},async rebase(C){return{handled:!0,reply:await H.rebase(C.number)}},async merge(C){return{handled:!0,reply:(await H.merge()).includes(C.number)?"Merged.":"This pull request does not currently qualify for auto-merge. Check the conditions in your config and whether its checks have passed."}},async "fix-ci"(C){if(!C.isPullRequest)return{handled:!1,reply:"There are no checks to look at \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.fixCi(C.number)}},async remember(C){let B=C.command.args.trim();if(!B)return{handled:!1,reply:"Tell me what to remember, e.g. `@buddy remember we pin react to 17`."};return{handled:!0,reply:await H.remember(B,C)}},async resolve(C){if(!C.isPullRequest)return{handled:!1,reply:"There are no review threads here \u2014 this is an issue, not a pull request."};return{handled:!0,reply:await H.resolve(C.number)}},async plan(C){return{handled:!0,reply:await H.plan(C.number,C.isPullRequest,C.command.args.trim())}},async chat(C){let B=_(H.config,C.logger);if(!B)return{handled:!1,reply:"I need an AI provider configured to answer questions. See https://buddy.sh/ai/providers"};return{handled:!0,reply:(await B.complete({system:"You are Buddy, answering a question in a pull request or issue thread. Be brief and concrete. If you do not know, say so rather than guessing.",messages:[{role:"user",content:C.command.args}]})).text}}}}async function I(H,C,B){let j=(await H.provider.getPullRequests("open")).find((E)=>E.number===C);if(!j)return;let{parseReviewState:z,upsertReviewState:A}=await import("./chunk-bffxf4xy.js"),D=z(j.body);await H.provider.updatePullRequest(C,{body:A(j.body,{reviewedSha:D?.reviewedSha??"",fingerprints:D?.fingerprints??[],reviewedAt:D?.reviewedAt??new Date().toISOString(),...B?{paused:!0}:{}})})}export{K as La,Q as Ma,V as Na,$ as Oa,G as Pa,F as Qa,Y as Ra,Z as Sa,L as Ta,T as Ua};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Gh as s,Hh as o,Ih as p,Jh as a}from"./chunk-g24hav8e.js";import"./chunk-q4t568hv.js";a();export{o as pantry,p as packages,s as aliases};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./chunk-rb1fh9vd.js";import{$d as t,Id as a,Jd as b,Kd as c,Ld as d,Md as e,Nd as f,Od as g,Pd as h,Qd as i,Rd as j,Sd as k,Td as l,Ud as m,Vd as n,Wd as o,Xd as p,Yd as q,Zd as r,_d as s}from"./chunk-nrr8z2z7.js";import"./chunk-xs12dtf1.js";import"./chunk-1cpdz49v.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{r as syntaxAnalyzer,q as shellcheckAnalyzer,p as secretsAnalyzer,b as runTool,t as runAnalyzers,e as relativize,d as parseToolJson,j as offsetToLine,n as markdownlintAnalyzer,c as mapSeverity,m as linterAnalyzer,i as hadolintAnalyzer,h as githubActionsAnalyzer,l as detectLinter,f as commandExists,g as actionlintAnalyzer,a as TOOL_TIMEOUT_MS,o as SECRET_RULES,k as LINTER_SPECS,s as BUILTIN_ANALYZERS};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./chunk-q4t568hv.js";import{spawn as E}from"child_process";async function y(z,A){return new Promise((k,x)=>{let q=E("git",z,{stdio:"pipe",cwd:A}),C="",D="";q.stdout?.on("data",(B)=>C+=B.toString()),q.stderr?.on("data",(B)=>D+=B.toString()),q.on("close",(B)=>{if(B===0)k(C);else x(Error(D||`git exited with code ${B}`))}),q.on("error",x)})}async function H(z,A,k){for(let x of z){let q=x.path.replace(/^\.\//,"").replace(/^\/+/,"");try{if(await y(["show",`${A}:${q}`],k)!==x.content)return!0;continue}catch{}try{if(await y(["show",`origin/${A}:${q}`],k)!==x.content)return!0;continue}catch{return!0}}return!1}async function I(z,A,k){if(z.length===0)return!1;if(await y(["add","--",...z],k),!(await y(["diff","--cached","--name-only"],k)).trim())return!1;await y(["commit","-m",A],k);let q=(await y(["rev-parse","--abbrev-ref","HEAD"],k)).trim();return await y(["push","origin",`HEAD:${q}`],k),!0}export{H as hasBranchDifferences,I as commitAndPush};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{nh as a}from"./chunk-k26wnmzk.js";import"./chunk-q4t568hv.js";export{a as GitHubActionsTemplate};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{zh as O}from"./chunk-e68nf7cm.js";import{Fh as q}from"./chunk-hfjywbbc.js";import{Wk as p}from"./chunk-q4t568hv.js";var T=/(?:^|[-_.])(?:rc|alpha|beta|pre|dev|nightly|canary|snapshot|edge|next)\d*(?:$|[-_.])/i;function B(j){let z=/^v?(\d+(?:\.\d+)*)(.*)$/.exec(j.trim());if(!z)return null;let[,G,Q]=z,J=T.test(Q),Y=Q.replace(T,(Z)=>{return Z.endsWith("-")||Z.endsWith("_")||Z.endsWith(".")?"-":""}).replace(/^[-_.]/,"").toLowerCase();return{raw:j,version:G.split(".").map(Number),suffix:Y,prerelease:J}}function x(j,z){for(let G=0;G<Math.max(j.length,z.length);G++){let Q=(j[G]??0)-(z[G]??0);if(Q!==0)return Q}return j.length-z.length}function k(j,z){let G=(Q)=>/^[a-z]+/.exec(Q)?.[0]??Q;return G(j)===G(z)}function b(j,z,G={}){let Q=B(j);if(!Q)return null;let J=z.map(B).filter((Y)=>Y!==null).filter((Y)=>G.includePrerelease?!0:!Y.prerelease).filter((Y)=>k(Y.suffix,Q.suffix)).filter((Y)=>Y.version.length===Q.version.length).filter((Y)=>x(Y.version,Q.version)>0);if(J.length===0)return null;return J.sort((Y,Z)=>x(Z.version,Y.version)),J[0].raw}function l(j,z){let G=B(j),Q=B(z);if(!G||!Q)return"patch";if((Q.version[0]??0)!==(G.version[0]??0))return"major";if((Q.version[1]??0)!==(G.version[1]??0))return"minor";return"patch"}import P from"process";var v="registry-1.docker.io";function U(j){let z=j.trim(),G,Q=z.indexOf("@");if(Q!==-1)G=z.slice(Q+1),z=z.slice(0,Q);let J=z.indexOf("/"),Y=J===-1?"":z.slice(0,J),Z=Y==="localhost"||Y.includes(".")||Y.includes(":"),X=Z?Y:"docker.io",$=Z?z.slice(J+1):z,K="latest",S=$.lastIndexOf("/"),W=$.indexOf(":",S+1);if(W!==-1)K=$.slice(W+1),$=$.slice(0,W);let M=X==="docker.io"&&!$.includes("/")?`library/${$}`:$;return{registry:X,repository:M,tag:K,...G?{digest:G}:{}}}function i(j){let z=j.registry==="docker.io"?j.repository.replace(/^library\//,""):`${j.registry}/${j.repository}`;return j.digest?`${z}:${j.tag}@${j.digest}`:`${z}:${j.tag}`}function C(j){return j==="docker.io"?v:j}function y(j,z,G=P.env){let Q=z?.[j];if(Q?.tokenEnv){let J=G[Q.tokenEnv]?.trim();if(J)return{token:J}}if(Q?.username&&Q.passwordEnv){let J=G[Q.passwordEnv]?.trim();if(J)return{username:Q.username,password:J}}if(j==="ghcr.io"){let J=G.GITHUB_TOKEN?.trim()||G.BUDDY_TOKEN?.trim();if(J)return{username:"buddy",password:J}}if(j==="docker.io"){let J=G.DOCKERHUB_TOKEN?.trim()||G.DOCKER_TOKEN?.trim();if(J)return{username:G.DOCKERHUB_USERNAME?.trim()||"buddy",password:J}}return null}function R(j){if(!j?.toLowerCase().startsWith("bearer "))return null;let z={};for(let G of j.slice(7).matchAll(/(\w+)="([^"]*)"/g))z[G[1]]=G[2];return z.realm?{realm:z.realm,...z.service?{service:z.service}:{},...z.scope?{scope:z.scope}:{}}:null}function u(j,z){let G=new URL(j.realm);if(j.service)G.searchParams.set("service",j.service);return G.searchParams.set("scope",j.scope??`repository:${z}:pull`),G.toString()}class H{options;logger;tokens=new Map;constructor(j={}){this.options=j;this.logger=j.logger??q()}async listTags(j){let z=C(j.registry),G=this.options.maxPages??10,Q=[],J=`https://${z}/v2/${j.repository}/tags/list?n=100`;for(let Y=0;Y<G&&J;Y++){let Z=await this.authorizedFetch(J,j);if(!Z?.ok){if(Y===0)this.logger.debug(`Could not list tags for ${j.repository} on ${j.registry}: ${Z?.status??"no response"}`);break}let X=await Z.json().catch(()=>null);if(Array.isArray(X?.tags))Q.push(...X.tags);J=h(Z.headers.get("link"),z)}return Q}async resolveDigest(j){let G=`https://${C(j.registry)}/v2/${j.repository}/manifests/${j.tag}`,Q=await this.authorizedFetch(G,j,{method:"HEAD",headers:{Accept:["application/vnd.oci.image.index.v1+json","application/vnd.oci.image.manifest.v1+json","application/vnd.docker.distribution.manifest.list.v2+json","application/vnd.docker.distribution.manifest.v2+json"].join(", ")}});return Q?.ok?Q.headers.get("docker-content-digest"):null}async authorizedFetch(j,z,G={}){let Q={"User-Agent":"buddy",...G.headers},J=this.tokens.get(I(z));if(J)Q.Authorization=`Bearer ${J}`;let Y=()=>O(j,{...G,headers:Q}).catch(()=>null),Z=await Y();if(Z?.status!==401||J!==void 0)return Z;let X=R(Z.headers.get("www-authenticate"));if(!X)return Z;let $=await this.fetchToken(X,z);if(!$)return Z;return this.tokens.set(I(z),$),Q.Authorization=`Bearer ${$}`,Z=await Y(),Z}async fetchToken(j,z){let G=y(z.registry,this.options.registries,this.options.env);if(G&&"token"in G)return G.token;let Q={"User-Agent":"buddy"};if(G){let Z=Buffer.from(`${G.username}:${G.password}`).toString("base64");Q.Authorization=`Basic ${Z}`}let J=await O(u(j,z.repository),{headers:Q}).catch(()=>null);if(!J?.ok)return this.logger.debug(`Token exchange failed for ${z.registry}/${z.repository}: ${J?.status??"no response"}`),null;let Y=await J.json().catch(()=>null);return Y?.token??Y?.access_token??null}}function I(j){return`${j.registry}/${j.repository}`}function h(j,z){if(!j)return null;let G=/<([^>]+)>\s*;\s*rel="?next"?/i.exec(j);if(!G)return null;let Q=G[1];return Q.startsWith("http")?Q:`https://${z}${Q}`}var m=[".md",".txt",".log",".bak",".orig",".example",".sample",".tmpl",".template"];function F(j){let z=(j.split("/").pop()||"").toLowerCase();if(!z)return!1;if(m.some((G)=>z.endsWith(G)))return!1;if(z==="containerfile"||z.startsWith("containerfile."))return!0;if(z==="dockerfile"||z.startsWith("dockerfile."))return!0;return z.endsWith(".dockerfile")||z.endsWith(".containerfile")}async function jj(j,z){try{if(!F(j))return null;let G=[],Q=z.split(`
3
+ `);for(let J=0;J<Q.length;J++){let Y=Q[J].trim();if(!Y||Y.startsWith("#"))continue;let Z=Y.match(/^FROM\s+(\S+)(?:\s+as\s+\w+)?$/i);if(Z){let X=Z[1];if(X==="scratch"||X.startsWith("$"))continue;let $=c(X);if($)G.push({name:$.name,currentVersion:$.version,type:"docker-image",file:j})}}return{path:j,type:"Dockerfile",content:z,dependencies:G}}catch(G){return q().warn(`Failed to parse Dockerfile ${j}:`,G),null}}function c(j){try{let z,G,Q=j.indexOf("@"),J=Q===-1?void 0:j.slice(Q+1);if(Q!==-1)j=j.slice(0,Q);if(J&&!j.includes(":"))return null;if(j.includes(":")){let Y=j.lastIndexOf(":"),Z=j.substring(0,Y),X=j.substring(Y+1);if(/^\d+\//.test(X))z=j,G="latest";else z=Z,G=X}else z=j,G="latest";if(G.includes("$")||G.startsWith("sha256:"))return null;return{name:z,version:G,...J?{digest:J}:{}}}catch(z){return q().warn(`Failed to parse image reference ${j}:`,z),null}}async function zj(j,z,G={}){try{let Q=j.replace(/\s*\(.*\)$/,""),J=U(z?`${Q}:${z}`:Q),Z=await new H({...G.registries?{registries:G.registries}:{},logger:q()}).listTags(J);if(Z.length===0)return null;return b(J.tag,Z,{includePrerelease:G.includePrerelease??!1})}catch(Q){return q().warn(`Failed to fetch latest version for Docker image ${j}:`,Q),null}}async function d(j,z,G){let Q=U(`${j.replace(/\s*\(.*\)$/,"")}:${z}`);return new H({...G?{registries:G}:{},logger:q()}).resolveDigest(Q)}async function f(j,z,G,Q){try{if(!F(j))return q().info(`\u26A0\uFE0F updateDockerfile: ${j} is not a Dockerfile, returning original content`),z;let J=z;for(let Y of G){if(Y.dependencyType!=="docker-image")continue;let Z=Y.name.replace(/\s*\(.*\)$/,""),X=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$=new RegExp(`(FROM\\s+${X})(:)([^\\s@]+)(@sha256:[a-f0-9]+)?([ \\t].*)?$`,"gim"),K=(W)=>{let M=["latest","main","master","develop","dev","stable"],w=W.toLowerCase().trim();return M.includes(w)},S=J.matchAll($);for(let W of S){let M=W[0],w=W[1],L=W[2],_=W[3],V=W[4]||"",D=W[5]||"";if(K(_)){q().info(`\u26A0\uFE0F Skipping update for ${Z} - version "${_}" should be respected`);continue}let A=V;if(V){let E=await d(Z,Y.newVersion,Q);if(!E){q().warn(`\u26A0\uFE0F Leaving ${Z} pinned at ${_}: could not resolve the digest for ${Y.newVersion}`);continue}A=`@${E}`}let N=`${w}${L}${Y.newVersion}${A}${D}`;J=J.replace(M,N),q().info(`\uD83D\uDCDD Updated ${Z}: ${_} \u2192 ${Y.newVersion}${A?" (digest re-resolved)":""}`)}}return J}catch(J){return q().warn(`Failed to update Dockerfile ${j}:`,J),z}}async function Gj(j,z){let G=[],Q=new Map;for(let J of j)if(J.dependencyType==="docker-image"&&F(J.file)){if(!Q.has(J.file))Q.set(J.file,[]);Q.get(J.file).push(J)}for(let[J,Y]of Q)try{let Z=await import("fs");if(Z.existsSync(J)){let X=Z.readFileSync(J,"utf-8"),$=await f(J,X,Y,z);if($!==X)G.push({path:J,content:$,type:"update"}),q().info(`\u2705 Generated update for ${J} with ${Y.length} image changes`);else q().info(`\u2139\uFE0F No changes needed for ${J} - versions already up to date`)}else q().warn(`\u26A0\uFE0F Dockerfile ${J} does not exist`)}catch(Z){q().warn(`Failed to generate updates for Dockerfile ${J}:`,Z)}return G}
4
+ export{B as se,x as te,k as ue,b as ve,l as we,U as xe,i as ye,C as ze,y as Ae,R as Be,H as Ce,F as De,jj as Ee,zj as Fe,d as Ge,f as He,Gj as Ie};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{ae as J}from"./chunk-tb5y0350.js";import{be as Y}from"./chunk-16yqbccr.js";import{fe as x,ge as w}from"./chunk-8rc6042h.js";import{ve as z,we as M}from"./chunk-4efbxdjr.js";import{Fe as N}from"./chunk-eagjp0dh.js";import{Le as _}from"./chunk-6d9hmjt8.js";import{af as L,bf as S}from"./chunk-pkkwb0n0.js";import{Rj as G}from"./chunk-akffynkc.js";import{Fk as j}from"./chunk-6g1y9yqh.js";var{Glob:D}=globalThis.Bun;import{readdir as A,readFile as U,stat as Z}from"fs/promises";import{join as R,relative as E,sep as H}from"path";async function I(q,K){try{let O=JSON.parse(K),V=[];if(O.packages){for(let Q of Object.values(O.packages))if(Q.name&&Q.version)V.push({name:Q.name,currentVersion:Q.version,type:"dependencies",file:q})}return{path:q,type:"pantry.lock",content:K,dependencies:V}}catch(O){return G().warn(`Failed to parse pantry.lock file ${q}:`,O),null}}class m{projectPath;logger;ignoreGlobs=[];constructor(q,K,O){this.projectPath=q;this.logger=K;if(O&&O.length>0)this.ignoreGlobs=O.map((V)=>new D(V)),this.logger.info(`Initialized ${this.ignoreGlobs.length} ignore patterns: ${O.join(", ")}`)}async scanProject(){this.logger.info("Scanning project for package files...");let q=Date.now(),K=[];try{let O=await this.findFiles("package.json");for(let X of O){if(this.shouldIgnorePath(X))continue;let $=await this.parsePackageJsonFile(X);if($)K.push($)}let V=await this.findDependencyFiles();for(let X of V){if(this.shouldIgnorePath(X))continue;let $=await this.parseDependencyFile(X);if($)K.push($)}let Q=await this.findLockFiles();for(let X of Q){if(this.shouldIgnorePath(X))continue;let $=await this.parseLockFile(X);if($)K.push($)}let W=await this.findComposerFiles();for(let X of W){if(this.shouldIgnorePath(X))continue;let $=await this.parseComposerFile(X);if($)K.push($)}let B=await this.findGitHubActionsFiles();for(let X of B){if(this.shouldIgnorePath(X))continue;let $=await this.parseGitHubActionsFile(X);if($)K.push($)}let C=await this.findDockerfiles();this.logger.info(`\uD83D\uDD0D Found ${C.length} Dockerfile(s): ${C.join(", ")}`);for(let X of C){if(this.shouldIgnorePath(X))continue;let $=await this.parseDockerfile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Dockerfile: ${X} with ${$.dependencies.length} dependencies`)}let T=await this.findZigManifests();this.logger.info(`\uD83D\uDD0D Found ${T.length} Zig manifest(s): ${T.join(", ")}`);for(let X of T){if(this.shouldIgnorePath(X))continue;let $=await this.parseZigManifestFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Zig manifest: ${X} with ${$.dependencies.length} dependencies`)}let b=await this.findFiles("pantry.lock");for(let X of b){if(this.shouldIgnorePath(X))continue;let $=await this.parsePantryLockFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed pantry.lock: ${X} with ${$.dependencies.length} dependencies`)}let v=Date.now()-q;return this.logger.success(`Found ${K.length} package files in ${v}ms`),K}catch(O){throw this.logger.error("Failed to scan project:",O),new Y(`Failed to scan project: ${O instanceof Error?O.message:"Unknown error"}`)}}async parsePackageJsonFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=JSON.parse(O),Q=[];return this.extractDependencies(V.dependencies,"dependencies",q,Q),this.extractDependencies(V.devDependencies,"devDependencies",q,Q),this.extractDependencies(V.peerDependencies,"peerDependencies",q,Q),this.extractDependencies(V.optionalDependencies,"optionalDependencies",q,Q),Q.push(...N(V.engines,q)),{path:q,type:"package.json",content:O,dependencies:Q}}catch(K){return this.logger.warn(`Failed to parse package.json file ${q}:`,K),null}}async parseLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=q.split("/").pop()||"",Q;if(V==="bun.lockb")Q="bun.lockb";else if(V==="package-lock.json")Q="package-lock.json";else if(V==="yarn.lock")Q="yarn.lock";else if(V==="pnpm-lock.yaml")Q="pnpm-lock.yaml";else return null;let W=await this.extractLockFileDependencies(O,Q,q);return{path:q,type:Q,content:O,dependencies:W}}catch(K){return this.logger.warn(`Failed to parse lock file ${q}:`,K),null}}async parseDependencyFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await S(q,O)}catch(K){return this.logger.warn(`Failed to parse dependency file ${q}:`,K),null}}async findDependencyFiles(){let q=[],K=["deps.yaml","deps.yml","dependencies.yaml","dependencies.yml","pkgx.yaml","pkgx.yml",".deps.yaml",".deps.yml"];for(let Q of K){let W=await this.findFiles(Q);q.push(...W)}let O=await this.findFilesByPattern("*.yaml"),V=await this.findFilesByPattern("*.yml");for(let Q of[...O,...V])if(L(Q)&&!q.includes(Q))q.push(Q);return q}async findGitHubActionsFiles(){let q=[];try{let O=R(this.projectPath,".github","workflows");if((await Z(O).catch(()=>null))?.isDirectory()){let Q=await this.findFilesByPatternInDir("*.yaml",O),W=await this.findFilesByPatternInDir("*.yml",O);for(let B of[...Q,...W])if(x(B))q.push(B)}}catch{}return q}async findDockerfiles(){return this.findFilesMatching(z)}async findFilesMatching(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isFile()){if(q(Q))O.push(E(this.projectPath,W).split(H).join("/"))}else if(B.isDirectory()&&!J(Q))O.push(...await this.findFilesMatching(q,W))}catch{continue}}}catch{}return O}async parseGitHubActionsFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await w(q,O)}catch(K){return this.logger.warn(`Failed to parse GitHub Actions file ${q}:`,K),null}}async parseDockerfile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await M(q,O)}catch(K){return this.logger.warn(`Failed to parse Dockerfile ${q}:`,K),null}}async findZigManifests(){let q=[];try{let K=await this.findFiles("build.zig.zon");q.push(...K)}catch{}return q}async parseZigManifestFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await _(q,O)}catch(K){return this.logger.warn(`Failed to parse Zig manifest ${q}:`,K),null}}async findComposerFiles(){let q=[];try{let K=await this.findFiles("composer.json");q.push(...K);let O=await this.findFiles("composer.lock");q.push(...O)}catch{}return q}async parseComposerFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),{parseComposerFile:V}=await import("./chunk-fm8ckj9b.js");return await V(q,O)}catch(K){return this.logger.warn(`Failed to parse Composer file ${q}:`,K),null}}async parsePantryLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await I(q,O)}catch(K){return this.logger.warn(`Failed to parse pantry.lock file ${q}:`,K),null}}extractDependencies(q,K,O,V){if(!q)return;for(let[Q,W]of Object.entries(q))V.push({name:Q,currentVersion:W,type:K,file:this.getRelativePath(O)})}async extractLockFileDependencies(q,K,O){let V=[];if(K==="package-lock.json")try{let Q=JSON.parse(q);if(Q.packages){for(let[W,B]of Object.entries(Q.packages))if(W&&W!==""&&B&&typeof B==="object"){let C=B;if(C.version){let T=W.startsWith("node_modules/")?W.replace("node_modules/",""):W;V.push({name:T,currentVersion:C.version,type:C.dev?"devDependencies":"dependencies",file:this.getRelativePath(O)})}}}}catch(Q){this.logger.warn("Failed to parse package-lock.json:",Q)}return V}async findFiles(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isDirectory()){if(!J(Q)){let C=await this.findFiles(q,W);O.push(...C)}}else if(B.isFile()&&Q===q){let C=E(this.projectPath,W);O.push(C.split(H).join("/"))}}catch{continue}}}catch{}return O}async findLockFiles(){let q=["bun.lock","bun.lockb","package-lock.json","yarn.lock","pnpm-lock.yaml"],K=[];for(let O of q){let V=await this.findFiles(O);K.push(...V)}return K}async findFilesByPattern(q){let K=[],O=q.replace("*.","");try{let V=await A(this.projectPath);for(let Q of V){let W=R(this.projectPath,Q),B=await Z(W);if(B.isFile()&&Q.endsWith(`.${O}`)){let C=E(this.projectPath,W);K.push(C.split(H).join("/"))}else if(B.isDirectory()&&!J(Q)){let C=await this.findFilesByPatternInDir(q,W);K.push(...C)}}}catch{}return K}async findFilesByPatternInDir(q,K){let O=[],V=q.replace("*.","");try{let Q=await A(K);for(let W of Q){let B=R(K,W),C=await Z(B);if(C.isFile()&&W.endsWith(`.${V}`)){let T=E(this.projectPath,B);O.push(T.split(H).join("/"))}else if(C.isDirectory()&&!J(W)){let T=await this.findFilesByPatternInDir(q,B);O.push(...T)}}}catch{}return O}shouldIgnorePath(q){if(this.ignoreGlobs.length===0)return!1;let K=q;if(q.startsWith("/")||q.includes(":"))K=this.getRelativePath(q);for(let O of this.ignoreGlobs)if(O.match(K))return this.logger.debug(`Ignoring path: ${K} (matched pattern)`),!0;return!1}getRelativePath(q){return E(this.projectPath,q).split(H).join("/")}async getDependencyCount(){return(await this.scanProject()).reduce((K,O)=>K+O.dependencies.length,0)}async getUniqueDependencies(){return(await this.scanProject()).flatMap((V)=>V.dependencies).filter((V,Q,W)=>Q===W.findIndex((B)=>B.name===V.name))}}
3
- export{m as $d};
2
+ import{gd as J}from"./chunk-pkr6905p.js";import{hd as Y}from"./chunk-eseshkd0.js";import{ne as x,oe as w}from"./chunk-ytmxd5fk.js";import{De as z,Ee as M}from"./chunk-b9escac0.js";import{Le as N}from"./chunk-2et8yavs.js";import{Te as _}from"./chunk-txtrpypt.js";import{qg as L,rg as S}from"./chunk-jtxcr5yw.js";import{Fh as G}from"./chunk-hfjywbbc.js";import{Wk as j}from"./chunk-q4t568hv.js";var{Glob:D}=globalThis.Bun;import{readdir as A,readFile as U,stat as Z}from"fs/promises";import{join as R,relative as E,sep as H}from"path";async function I(q,K){try{let O=JSON.parse(K),V=[];if(O.packages){for(let Q of Object.values(O.packages))if(Q.name&&Q.version)V.push({name:Q.name,currentVersion:Q.version,type:"dependencies",file:q})}return{path:q,type:"pantry.lock",content:K,dependencies:V}}catch(O){return G().warn(`Failed to parse pantry.lock file ${q}:`,O),null}}class m{projectPath;logger;ignoreGlobs=[];constructor(q,K,O){this.projectPath=q;this.logger=K;if(O&&O.length>0)this.ignoreGlobs=O.map((V)=>new D(V)),this.logger.info(`Initialized ${this.ignoreGlobs.length} ignore patterns: ${O.join(", ")}`)}async scanProject(){this.logger.info("Scanning project for package files...");let q=Date.now(),K=[];try{let O=await this.findFiles("package.json");for(let X of O){if(this.shouldIgnorePath(X))continue;let $=await this.parsePackageJsonFile(X);if($)K.push($)}let V=await this.findDependencyFiles();for(let X of V){if(this.shouldIgnorePath(X))continue;let $=await this.parseDependencyFile(X);if($)K.push($)}let Q=await this.findLockFiles();for(let X of Q){if(this.shouldIgnorePath(X))continue;let $=await this.parseLockFile(X);if($)K.push($)}let W=await this.findComposerFiles();for(let X of W){if(this.shouldIgnorePath(X))continue;let $=await this.parseComposerFile(X);if($)K.push($)}let B=await this.findGitHubActionsFiles();for(let X of B){if(this.shouldIgnorePath(X))continue;let $=await this.parseGitHubActionsFile(X);if($)K.push($)}let C=await this.findDockerfiles();this.logger.info(`\uD83D\uDD0D Found ${C.length} Dockerfile(s): ${C.join(", ")}`);for(let X of C){if(this.shouldIgnorePath(X))continue;let $=await this.parseDockerfile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Dockerfile: ${X} with ${$.dependencies.length} dependencies`)}let T=await this.findZigManifests();this.logger.info(`\uD83D\uDD0D Found ${T.length} Zig manifest(s): ${T.join(", ")}`);for(let X of T){if(this.shouldIgnorePath(X))continue;let $=await this.parseZigManifestFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed Zig manifest: ${X} with ${$.dependencies.length} dependencies`)}let b=await this.findFiles("pantry.lock");for(let X of b){if(this.shouldIgnorePath(X))continue;let $=await this.parsePantryLockFile(X);if($)K.push($),this.logger.info(`\uD83D\uDCE6 Parsed pantry.lock: ${X} with ${$.dependencies.length} dependencies`)}let v=Date.now()-q;return this.logger.success(`Found ${K.length} package files in ${v}ms`),K}catch(O){throw this.logger.error("Failed to scan project:",O),new Y(`Failed to scan project: ${O instanceof Error?O.message:"Unknown error"}`)}}async parsePackageJsonFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=JSON.parse(O),Q=[];return this.extractDependencies(V.dependencies,"dependencies",q,Q),this.extractDependencies(V.devDependencies,"devDependencies",q,Q),this.extractDependencies(V.peerDependencies,"peerDependencies",q,Q),this.extractDependencies(V.optionalDependencies,"optionalDependencies",q,Q),Q.push(...N(V.engines,q)),{path:q,type:"package.json",content:O,dependencies:Q}}catch(K){return this.logger.warn(`Failed to parse package.json file ${q}:`,K),null}}async parseLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),V=q.split("/").pop()||"",Q;if(V==="bun.lockb")Q="bun.lockb";else if(V==="package-lock.json")Q="package-lock.json";else if(V==="yarn.lock")Q="yarn.lock";else if(V==="pnpm-lock.yaml")Q="pnpm-lock.yaml";else return null;let W=await this.extractLockFileDependencies(O,Q,q);return{path:q,type:Q,content:O,dependencies:W}}catch(K){return this.logger.warn(`Failed to parse lock file ${q}:`,K),null}}async parseDependencyFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await S(q,O)}catch(K){return this.logger.warn(`Failed to parse dependency file ${q}:`,K),null}}async findDependencyFiles(){let q=[],K=["deps.yaml","deps.yml","dependencies.yaml","dependencies.yml","pkgx.yaml","pkgx.yml",".deps.yaml",".deps.yml"];for(let Q of K){let W=await this.findFiles(Q);q.push(...W)}let O=await this.findFilesByPattern("*.yaml"),V=await this.findFilesByPattern("*.yml");for(let Q of[...O,...V])if(L(Q)&&!q.includes(Q))q.push(Q);return q}async findGitHubActionsFiles(){let q=[];try{let O=R(this.projectPath,".github","workflows");if((await Z(O).catch(()=>null))?.isDirectory()){let Q=await this.findFilesByPatternInDir("*.yaml",O),W=await this.findFilesByPatternInDir("*.yml",O);for(let B of[...Q,...W])if(x(B))q.push(B)}}catch{}return q}async findDockerfiles(){return this.findFilesMatching(z)}async findFilesMatching(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isFile()){if(q(Q))O.push(E(this.projectPath,W).split(H).join("/"))}else if(B.isDirectory()&&!J(Q))O.push(...await this.findFilesMatching(q,W))}catch{continue}}}catch{}return O}async parseGitHubActionsFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await w(q,O)}catch(K){return this.logger.warn(`Failed to parse GitHub Actions file ${q}:`,K),null}}async parseDockerfile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await M(q,O)}catch(K){return this.logger.warn(`Failed to parse Dockerfile ${q}:`,K),null}}async findZigManifests(){let q=[];try{let K=await this.findFiles("build.zig.zon");q.push(...K)}catch{}return q}async parseZigManifestFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await _(q,O)}catch(K){return this.logger.warn(`Failed to parse Zig manifest ${q}:`,K),null}}async findComposerFiles(){let q=[];try{let K=await this.findFiles("composer.json");q.push(...K);let O=await this.findFiles("composer.lock");q.push(...O)}catch{}return q}async parseComposerFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8"),{parseComposerFile:V}=await import("./chunk-vqa6vte3.js");return await V(q,O)}catch(K){return this.logger.warn(`Failed to parse Composer file ${q}:`,K),null}}async parsePantryLockFile(q){try{let K=R(this.projectPath,q),O=await U(K,"utf-8");return await I(q,O)}catch(K){return this.logger.warn(`Failed to parse pantry.lock file ${q}:`,K),null}}extractDependencies(q,K,O,V){if(!q)return;for(let[Q,W]of Object.entries(q))V.push({name:Q,currentVersion:W,type:K,file:this.getRelativePath(O)})}async extractLockFileDependencies(q,K,O){let V=[];if(K==="package-lock.json")try{let Q=JSON.parse(q);if(Q.packages){for(let[W,B]of Object.entries(Q.packages))if(W&&W!==""&&B&&typeof B==="object"){let C=B;if(C.version){let T=W.startsWith("node_modules/")?W.replace("node_modules/",""):W;V.push({name:T,currentVersion:C.version,type:C.dev?"devDependencies":"dependencies",file:this.getRelativePath(O)})}}}}catch(Q){this.logger.warn("Failed to parse package-lock.json:",Q)}return V}async findFiles(q,K=this.projectPath){let O=[];try{let V=await A(K);for(let Q of V){let W=R(K,Q);try{let B=await Z(W);if(B.isDirectory()){if(!J(Q)){let C=await this.findFiles(q,W);O.push(...C)}}else if(B.isFile()&&Q===q){let C=E(this.projectPath,W);O.push(C.split(H).join("/"))}}catch{continue}}}catch{}return O}async findLockFiles(){let q=["bun.lock","bun.lockb","package-lock.json","yarn.lock","pnpm-lock.yaml"],K=[];for(let O of q){let V=await this.findFiles(O);K.push(...V)}return K}async findFilesByPattern(q){let K=[],O=q.replace("*.","");try{let V=await A(this.projectPath);for(let Q of V){let W=R(this.projectPath,Q),B=await Z(W);if(B.isFile()&&Q.endsWith(`.${O}`)){let C=E(this.projectPath,W);K.push(C.split(H).join("/"))}else if(B.isDirectory()&&!J(Q)){let C=await this.findFilesByPatternInDir(q,W);K.push(...C)}}}catch{}return K}async findFilesByPatternInDir(q,K){let O=[],V=q.replace("*.","");try{let Q=await A(K);for(let W of Q){let B=R(K,W),C=await Z(B);if(C.isFile()&&W.endsWith(`.${V}`)){let T=E(this.projectPath,B);O.push(T.split(H).join("/"))}else if(C.isDirectory()&&!J(W)){let T=await this.findFilesByPatternInDir(q,B);O.push(...T)}}}catch{}return O}shouldIgnorePath(q){if(this.ignoreGlobs.length===0)return!1;let K=q;if(q.startsWith("/")||q.includes(":"))K=this.getRelativePath(q);for(let O of this.ignoreGlobs)if(O.match(K))return this.logger.debug(`Ignoring path: ${K} (matched pattern)`),!0;return!1}getRelativePath(q){return E(this.projectPath,q).split(H).join("/")}async getDependencyCount(){return(await this.scanProject()).reduce((K,O)=>K+O.dependencies.length,0)}async getUniqueDependencies(){return(await this.scanProject()).flatMap((V)=>V.dependencies).filter((V,Q,W)=>Q===W.findIndex((B)=>B.name===V.name))}}
3
+ export{m as fd};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Lb as a,Mb as b,Nb as c,Ob as d,Pb as e}from"./chunk-5yfaptmp.js";import"./chunk-q4t568hv.js";export{d as upsertReviewState,b as serializeReviewState,c as parseReviewState,e as needsReview,a as REVIEW_STATE_VERSION};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{uh as a}from"./chunk-f53y8ans.js";import"./chunk-e68nf7cm.js";import"./chunk-hfjywbbc.js";import"./chunk-q4t568hv.js";export{a as BitbucketProvider};