@buddysh/buddy 0.11.0

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 (278) hide show
  1. package/CHANGELOG.md +1633 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +1087 -0
  4. package/bin/cli.ts +3401 -0
  5. package/dist/bin/cli.d.ts +1 -0
  6. package/dist/bin/cli.js +188 -0
  7. package/dist/chunk-0j7z87kh.js +3 -0
  8. package/dist/chunk-0r8zt3d7.js +2 -0
  9. package/dist/chunk-16yqbccr.js +3 -0
  10. package/dist/chunk-1a53wj0h.js +1 -0
  11. package/dist/chunk-1c1gznm9.js +3 -0
  12. package/dist/chunk-1h3ey7k5.js +3 -0
  13. package/dist/chunk-1stt2whn.js +62 -0
  14. package/dist/chunk-1wjnd24b.js +24 -0
  15. package/dist/chunk-1xe07hzm.js +2 -0
  16. package/dist/chunk-2bp7tqca.js +2 -0
  17. package/dist/chunk-2dbkpfy9.js +2 -0
  18. package/dist/chunk-3q6czqs4.js +6 -0
  19. package/dist/chunk-3zdcekfj.js +5 -0
  20. package/dist/chunk-49ey79p0.js +5 -0
  21. package/dist/chunk-4c9m61yd.js +5 -0
  22. package/dist/chunk-4efbxdjr.js +4 -0
  23. package/dist/chunk-4f7panqj.js +21 -0
  24. package/dist/chunk-4hd3rre0.js +2 -0
  25. package/dist/chunk-4xsq18p3.js +9 -0
  26. package/dist/chunk-52x8mvh4.js +15 -0
  27. package/dist/chunk-54sc18p8.js +2 -0
  28. package/dist/chunk-56q4pwb5.js +3 -0
  29. package/dist/chunk-5c3qf34r.js +2 -0
  30. package/dist/chunk-5k40mwd4.js +4 -0
  31. package/dist/chunk-5kt03hx5.js +2 -0
  32. package/dist/chunk-63ept76v.js +2 -0
  33. package/dist/chunk-65b3vq52.js +2 -0
  34. package/dist/chunk-6d9hmjt8.js +3 -0
  35. package/dist/chunk-6g1y9yqh.js +3 -0
  36. package/dist/chunk-6k653r8w.js +2 -0
  37. package/dist/chunk-6md7qf2g.js +4 -0
  38. package/dist/chunk-6patq6bw.js +2 -0
  39. package/dist/chunk-6sgh49z1.js +2 -0
  40. package/dist/chunk-74pxb991.js +7 -0
  41. package/dist/chunk-7mgec8kb.js +7 -0
  42. package/dist/chunk-7tfrww3v.js +2 -0
  43. package/dist/chunk-7xk28xrv.js +2 -0
  44. package/dist/chunk-82dv4p13.js +2 -0
  45. package/dist/chunk-8661pvb8.js +3 -0
  46. package/dist/chunk-887s0w81.js +2 -0
  47. package/dist/chunk-8rc6042h.js +4 -0
  48. package/dist/chunk-9750tenz.js +3 -0
  49. package/dist/chunk-978wtejw.js +44 -0
  50. package/dist/chunk-9eqpaxfz.js +2 -0
  51. package/dist/chunk-9h04nskh.js +8 -0
  52. package/dist/chunk-9p1xkmjy.js +2 -0
  53. package/dist/chunk-agdesgzv.js +2 -0
  54. package/dist/chunk-akffynkc.js +3 -0
  55. package/dist/chunk-ar01x04a.js +2 -0
  56. package/dist/chunk-ay43f085.js +2 -0
  57. package/dist/chunk-bk9bqd5j.js +2 -0
  58. package/dist/chunk-bm8d40j0.js +69 -0
  59. package/dist/chunk-bxfc4g2x.js +73 -0
  60. package/dist/chunk-c3fczawt.js +2 -0
  61. package/dist/chunk-c9r9nd4t.js +1 -0
  62. package/dist/chunk-ctsz0ynx.js +3 -0
  63. package/dist/chunk-czremqk7.js +2 -0
  64. package/dist/chunk-da3wbh04.js +2 -0
  65. package/dist/chunk-dat582cg.js +2 -0
  66. package/dist/chunk-dfesffnr.js +3 -0
  67. package/dist/chunk-djntbp7a.js +105 -0
  68. package/dist/chunk-eagjp0dh.js +3 -0
  69. package/dist/chunk-eht72nnj.js +2 -0
  70. package/dist/chunk-f4nv5x3z.js +2 -0
  71. package/dist/chunk-fdfk918n.js +2 -0
  72. package/dist/chunk-fdj0tewy.js +20 -0
  73. package/dist/chunk-fm8ckj9b.js +2 -0
  74. package/dist/chunk-fqj7e6xa.js +2 -0
  75. package/dist/chunk-frm8zz31.js +2 -0
  76. package/dist/chunk-fvpr07dn.js +16 -0
  77. package/dist/chunk-g0nv8psv.js +2 -0
  78. package/dist/chunk-g0w8n555.js +19 -0
  79. package/dist/chunk-gkmvxjbe.js +2 -0
  80. package/dist/chunk-gngwjf70.js +7 -0
  81. package/dist/chunk-h7hs95wn.js +5 -0
  82. package/dist/chunk-hfvezfxh.js +3 -0
  83. package/dist/chunk-hw70wbzg.js +3 -0
  84. package/dist/chunk-j8asz4hb.js +15 -0
  85. package/dist/chunk-k62w2v03.js +2 -0
  86. package/dist/chunk-mcrfxphm.js +5 -0
  87. package/dist/chunk-mh3x7j6h.js +2 -0
  88. package/dist/chunk-naq32yx3.js +86 -0
  89. package/dist/chunk-nsmcjkas.js +2 -0
  90. package/dist/chunk-p1xm1jvz.js +2 -0
  91. package/dist/chunk-p3wsm8kz.js +2 -0
  92. package/dist/chunk-p4zwy518.js +4 -0
  93. package/dist/chunk-p7zgy37f.js +2 -0
  94. package/dist/chunk-ph1b3vbp.js +315 -0
  95. package/dist/chunk-pkjm2r0a.js +2 -0
  96. package/dist/chunk-pkkwb0n0.js +4 -0
  97. package/dist/chunk-pnpx1kqn.js +6 -0
  98. package/dist/chunk-q9n79dd3.js +3 -0
  99. package/dist/chunk-qpz9k66h.js +2 -0
  100. package/dist/chunk-qvn1rtgp.js +2 -0
  101. package/dist/chunk-qyf90zz3.js +2 -0
  102. package/dist/chunk-r06ce5g6.js +2 -0
  103. package/dist/chunk-r2sbprdb.js +49 -0
  104. package/dist/chunk-r3zyw8x0.js +3 -0
  105. package/dist/chunk-rb1fh9vd.js +1 -0
  106. package/dist/chunk-rqdep14r.js +2 -0
  107. package/dist/chunk-s1km8cyq.js +2 -0
  108. package/dist/chunk-s4ms8zag.js +2 -0
  109. package/dist/chunk-sp818c27.js +9 -0
  110. package/dist/chunk-tb5y0350.js +3 -0
  111. package/dist/chunk-thaxgm5p.js +2 -0
  112. package/dist/chunk-tn8prpny.js +503 -0
  113. package/dist/chunk-ts35hc5t.js +3 -0
  114. package/dist/chunk-tzs22es2.js +3 -0
  115. package/dist/chunk-vagxqhef.js +13 -0
  116. package/dist/chunk-vh504tcv.js +6 -0
  117. package/dist/chunk-vkctfqpm.js +3 -0
  118. package/dist/chunk-vyapg8ca.js +186 -0
  119. package/dist/chunk-wdwvt7gb.js +43 -0
  120. package/dist/chunk-wtjhehz9.js +4 -0
  121. package/dist/chunk-x0ya2r4r.js +3 -0
  122. package/dist/chunk-x3kragh9.js +12 -0
  123. package/dist/chunk-x9ctz1qc.js +1 -0
  124. package/dist/chunk-xakpdqaq.js +3 -0
  125. package/dist/chunk-xqx460y2.js +3 -0
  126. package/dist/chunk-xvptf9jy.js +3 -0
  127. package/dist/chunk-yk23nc4t.js +2 -0
  128. package/dist/chunk-yncea6ty.js +2 -0
  129. package/dist/chunk-yq0gxtzv.js +2 -0
  130. package/dist/chunk-yqhs08ky.js +2 -0
  131. package/dist/chunk-zb62jhwm.js +31 -0
  132. package/dist/chunk-zs3jaj0g.js +1023 -0
  133. package/dist/chunk-zve5d96e.js +2 -0
  134. package/dist/src/agent/index.d.ts +44 -0
  135. package/dist/src/agent/modes.d.ts +33 -0
  136. package/dist/src/agent/runner.d.ts +44 -0
  137. package/dist/src/agent/stacked.d.ts +83 -0
  138. package/dist/src/agent/tasks.d.ts +41 -0
  139. package/dist/src/agent/toolbelt.d.ts +19 -0
  140. package/dist/src/agent/tools/fs.d.ts +26 -0
  141. package/dist/src/agent/tools/shell.d.ts +32 -0
  142. package/dist/src/agent/types.d.ts +56 -0
  143. package/dist/src/ai/aliases.d.ts +62 -0
  144. package/dist/src/ai/client.d.ts +42 -0
  145. package/dist/src/ai/index.d.ts +35 -0
  146. package/dist/src/ai/learnings.d.ts +78 -0
  147. package/dist/src/ai/providers/anthropic.d.ts +12 -0
  148. package/dist/src/ai/providers/google.d.ts +12 -0
  149. package/dist/src/ai/providers/openai.d.ts +15 -0
  150. package/dist/src/ai/redact.d.ts +30 -0
  151. package/dist/src/ai/types.d.ts +75 -0
  152. package/dist/src/analysis/analyzers/actionlint.d.ts +11 -0
  153. package/dist/src/analysis/analyzers/external.d.ts +57 -0
  154. package/dist/src/analysis/analyzers/github-actions.d.ts +9 -0
  155. package/dist/src/analysis/analyzers/hadolint.d.ts +9 -0
  156. package/dist/src/analysis/analyzers/linter.d.ts +53 -0
  157. package/dist/src/analysis/analyzers/markdownlint.d.ts +11 -0
  158. package/dist/src/analysis/analyzers/secrets.d.ts +23 -0
  159. package/dist/src/analysis/analyzers/shellcheck.d.ts +8 -0
  160. package/dist/src/analysis/analyzers/syntax.d.ts +13 -0
  161. package/dist/src/analysis/engine.d.ts +38 -0
  162. package/dist/src/analysis/index.d.ts +13 -0
  163. package/dist/src/analysis/types.d.ts +14 -0
  164. package/dist/src/buddy.d.ts +17 -0
  165. package/dist/src/ci/classify.d.ts +49 -0
  166. package/dist/src/ci/fix.d.ts +42 -0
  167. package/dist/src/ci/index.d.ts +8 -0
  168. package/dist/src/commands/dispatcher.d.ts +49 -0
  169. package/dist/src/commands/handlers.d.ts +23 -0
  170. package/dist/src/commands/index.d.ts +22 -0
  171. package/dist/src/commands/parser.d.ts +71 -0
  172. package/dist/src/config-validation.d.ts +38 -0
  173. package/dist/src/config.d.ts +22 -0
  174. package/dist/src/dashboard/dashboard-generator.d.ts +10 -0
  175. package/dist/src/doctor.d.ts +44 -0
  176. package/dist/src/ecosystems/go.d.ts +10 -0
  177. package/dist/src/ecosystems/index.d.ts +60 -0
  178. package/dist/src/ecosystems/pep440.d.ts +57 -0
  179. package/dist/src/ecosystems/python.d.ts +12 -0
  180. package/dist/src/ecosystems/ruby.d.ts +9 -0
  181. package/dist/src/ecosystems/rust.d.ts +8 -0
  182. package/dist/src/ecosystems/scan.d.ts +49 -0
  183. package/dist/src/ecosystems/shared.d.ts +45 -0
  184. package/dist/src/ecosystems/types.d.ts +58 -0
  185. package/dist/src/events/bus.d.ts +41 -0
  186. package/dist/src/events/index.d.ts +11 -0
  187. package/dist/src/events/sinks.d.ts +33 -0
  188. package/dist/src/gates/ai-checks.d.ts +77 -0
  189. package/dist/src/gates/checks.d.ts +84 -0
  190. package/dist/src/gates/index.d.ts +17 -0
  191. package/dist/src/gates/post-merge.d.ts +56 -0
  192. package/dist/src/git/bitbucket-provider.d.ts +50 -0
  193. package/dist/src/git/github-provider.d.ts +50 -0
  194. package/dist/src/git/gitlab-provider.d.ts +51 -0
  195. package/dist/src/git/provider.d.ts +210 -0
  196. package/dist/src/headless/run.d.ts +78 -0
  197. package/dist/src/index.d.ts +243 -0
  198. package/dist/src/index.js +2 -0
  199. package/dist/src/issues/enrichment.d.ts +76 -0
  200. package/dist/src/issues/index.d.ts +16 -0
  201. package/dist/src/issues/quick-links.d.ts +55 -0
  202. package/dist/src/pr/auto-merge.d.ts +75 -0
  203. package/dist/src/pr/pr-generator.d.ts +9 -0
  204. package/dist/src/pr/pr-manifest.d.ts +82 -0
  205. package/dist/src/pr/templates.d.ts +44 -0
  206. package/dist/src/registry/docker-tags.d.ts +56 -0
  207. package/dist/src/registry/eol.d.ts +87 -0
  208. package/dist/src/registry/oci-client.d.ts +98 -0
  209. package/dist/src/registry/registry-client.d.ts +39 -0
  210. package/dist/src/reports/history.d.ts +51 -0
  211. package/dist/src/reports/index.d.ts +23 -0
  212. package/dist/src/reports/metrics.d.ts +89 -0
  213. package/dist/src/reports/render.d.ts +33 -0
  214. package/dist/src/review/diff.d.ts +50 -0
  215. package/dist/src/review/engine.d.ts +49 -0
  216. package/dist/src/review/findings.d.ts +102 -0
  217. package/dist/src/review/guidelines.d.ts +46 -0
  218. package/dist/src/review/index.d.ts +48 -0
  219. package/dist/src/review/local.d.ts +81 -0
  220. package/dist/src/review/marker.d.ts +34 -0
  221. package/dist/src/review/poster.d.ts +39 -0
  222. package/dist/src/review/run.d.ts +24 -0
  223. package/dist/src/rules/engine.d.ts +108 -0
  224. package/dist/src/rules/index.d.ts +9 -0
  225. package/dist/src/rules/renovate.d.ts +25 -0
  226. package/dist/src/rules/schedule.d.ts +44 -0
  227. package/dist/src/scanner/catalog-scan.d.ts +39 -0
  228. package/dist/src/scanner/package-json-extras.d.ts +101 -0
  229. package/dist/src/scanner/package-scanner.d.ts +17 -0
  230. package/dist/src/scanner/resolution-drift.d.ts +81 -0
  231. package/dist/src/scanner/workspace-catalog.d.ts +53 -0
  232. package/dist/src/scheduler/scheduler.d.ts +27 -0
  233. package/dist/src/security/engine.d.ts +12 -0
  234. package/dist/src/security/loader.d.ts +7 -0
  235. package/dist/src/security/parser.d.ts +15 -0
  236. package/dist/src/security/rules/bash-injection.d.ts +18 -0
  237. package/dist/src/security/rules/dangerous-pull-request-target.d.ts +18 -0
  238. package/dist/src/security/rules/excessive-permissions.d.ts +14 -0
  239. package/dist/src/security/rules/index.d.ts +16 -0
  240. package/dist/src/security/rules/missing-timeout.d.ts +9 -0
  241. package/dist/src/security/rules/self-hosted-exposure.d.ts +13 -0
  242. package/dist/src/security/rules/unpinned-action.d.ts +10 -0
  243. package/dist/src/security/rules/walk.d.ts +13 -0
  244. package/dist/src/security/types.d.ts +64 -0
  245. package/dist/src/services/deprecated-dependencies-checker.d.ts +16 -0
  246. package/dist/src/services/release-notes-fetcher.d.ts +70 -0
  247. package/dist/src/services/security-advisories.d.ts +59 -0
  248. package/dist/src/setup.d.ts +162 -0
  249. package/dist/src/setup.js +2 -0
  250. package/dist/src/templates/github-actions.d.ts +31 -0
  251. package/dist/src/templates/gitlab-ci.d.ts +46 -0
  252. package/dist/src/types.d.ts +449 -0
  253. package/dist/src/upgrades/index.d.ts +18 -0
  254. package/dist/src/upgrades/migrate.d.ts +45 -0
  255. package/dist/src/upgrades/plan.d.ts +112 -0
  256. package/dist/src/upgrades/report.d.ts +22 -0
  257. package/dist/src/upgrades/span.d.ts +47 -0
  258. package/dist/src/upgrades/usage.d.ts +30 -0
  259. package/dist/src/upgrades/wire.d.ts +61 -0
  260. package/dist/src/utils/concurrency.d.ts +50 -0
  261. package/dist/src/utils/dependency-file-parser.d.ts +17 -0
  262. package/dist/src/utils/dockerfile-parser.d.ts +69 -0
  263. package/dist/src/utils/endpoints.d.ts +58 -0
  264. package/dist/src/utils/errors.d.ts +35 -0
  265. package/dist/src/utils/file-changes.d.ts +14 -0
  266. package/dist/src/utils/github-actions-parser.d.ts +21 -0
  267. package/dist/src/utils/globs.d.ts +22 -0
  268. package/dist/src/utils/helpers.d.ts +73 -0
  269. package/dist/src/utils/http.d.ts +81 -0
  270. package/dist/src/utils/lock-file.d.ts +28 -0
  271. package/dist/src/utils/logger.d.ts +45 -0
  272. package/dist/src/utils/package-paths.d.ts +6 -0
  273. package/dist/src/utils/pantry-parser.d.ts +30 -0
  274. package/dist/src/utils/repository.d.ts +41 -0
  275. package/dist/src/utils/security-format.d.ts +18 -0
  276. package/dist/src/utils/zig-parser.d.ts +18 -0
  277. package/dist/src/version/version-resolver.d.ts +9 -0
  278. package/package.json +115 -0
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{gd as a}from"./chunk-3q6czqs4.js";import"./chunk-tb5y0350.js";import"./chunk-16yqbccr.js";import"./chunk-978wtejw.js";import"./chunk-pkkwb0n0.js";import"./chunk-ph1b3vbp.js";import"./chunk-0j7z87kh.js";import"./chunk-7mgec8kb.js";import"./chunk-5k40mwd4.js";import"./chunk-1h3ey7k5.js";import"./chunk-akffynkc.js";import"./chunk-x3kragh9.js";import"./chunk-wdwvt7gb.js";import"./chunk-8661pvb8.js";import"./chunk-ctsz0ynx.js";import"./chunk-vkctfqpm.js";import"./chunk-6g1y9yqh.js";export{a as RegistryClient};
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import{Rj as K}from"./chunk-akffynkc.js";var U=".buddy/reports.jsonl",Z=52;function $(M){if(!M?.trim())return[];let E=[];for(let j of M.split(`
3
+ `)){if(!j.trim())continue;try{let N=JSON.parse(j);if(N?.period&&N.generatedAt&&N.health&&N.activity)E.push(N)}catch{continue}}return E}function W(M,E){return`${[...M,E].slice(-Z).map((N)=>JSON.stringify(N)).join(`
4
+ `)}
5
+ `}function _(M,E){for(let j=M.length-1;j>=0;j--)if(M[j].period===E)return M[j];return null}async function k(M,E,j=K()){try{return $(await M.getFileContent(U,E))}catch(N){return j.debug(`No report history at ${U}: ${N}`),[]}}var A=["7d","30d","90d"],O={"7d":7,"30d":30,"90d":90};function B(M){let E=new Date(M.now.getTime()-O[M.period]*24*60*60*1000),j=M.branchPrefix??"buddy/",N=M.pullRequests.filter((q)=>q.head.startsWith(j)),C=N.filter((q)=>q.createdAt>=E),z=N.filter((q)=>q.mergedAt!==void 0&&q.mergedAt>=E),F=N.filter((q)=>q.state==="closed"&&q.mergedAt===void 0&&q.updatedAt>=E),J=z.map((q)=>(q.mergedAt.getTime()-q.createdAt.getTime())/3600000).sort((q,Q)=>q-Q),G=Object.values(M.dependenciesByEcosystem).reduce((q,Q)=>q+Q,0),X=M.updates.length;return{period:M.period,generatedAt:M.now.toISOString(),health:{byEcosystem:{...M.dependenciesByEcosystem},total:G,outdated:X,outdatedPercent:G>0?Math.round(X/G*100):0,majorBehind:M.updates.filter((q)=>q.updateType==="major").length,vulnerable:M.updates.filter((q)=>(q.securityAdvisories?.length??0)>0).length,deprecated:M.deprecated??0,drifted:M.drifted??0},activity:{opened:C.length,merged:z.length,closed:F.length,open:N.filter((q)=>q.state==="open").length,medianHoursToMerge:L(J),mergeRate:C.length>0?Math.round(z.length/C.length*100):0}}}function L(M){if(M.length===0)return null;let E=Math.floor(M.length/2),j=M.length%2===0?(M[E-1]+M[E])/2:M[E];return Math.round(j*10)/10}function S(M,E){if(!E)return{};let j=new Set(["merged","mergeRate"]),N=[["outdated",M.health.outdated,E.health.outdated],["majorBehind",M.health.majorBehind,E.health.majorBehind],["vulnerable",M.health.vulnerable,E.health.vulnerable],["deprecated",M.health.deprecated,E.health.deprecated],["opened",M.activity.opened,E.activity.opened],["merged",M.activity.merged,E.activity.merged],["mergeRate",M.activity.mergeRate,E.activity.mergeRate]],C={};for(let[z,F,J]of N){let G=F-J;C[z]={current:F,previous:J,change:G,improved:j.has(z)?G>=0:G<=0}}return C}var R="<!-- buddy:report -->";function H(M){if(!M||M.change===0)return"\u2014";let E=M.change>0?"\u25B2":"\u25BC",j=M.change>0?"+":"";return`${E} ${j}${M.change}${M.improved?"":" \u26A0\uFE0F"}`}function T(M,E={}){let j=O[M.period],N=[R,"",`## Dependency report \u2014 last ${j} days`,"",`Generated ${M.generatedAt.slice(0,10)}.`,"","### Dependency health","","| Metric | Value | Change |","| --- | --- | --- |",`| Total dependencies | ${M.health.total} | |`,`| Outdated | ${M.health.outdated} (${M.health.outdatedPercent}%) | ${H(E.outdated)} |`,`| A major behind | ${M.health.majorBehind} | ${H(E.majorBehind)} |`,`| With known advisories | ${M.health.vulnerable} | ${H(E.vulnerable)} |`,`| Deprecated | ${M.health.deprecated} | ${H(E.deprecated)} |`];if(M.health.drifted>0)N.push(`| Held back by a dependant | ${M.health.drifted} | |`);N.push("","### By ecosystem","");let C=Object.entries(M.health.byEcosystem).filter(([,z])=>z>0).sort(([,z],[,F])=>F-z);if(C.length===0)N.push("No dependencies detected.");else{N.push("| Ecosystem | Dependencies |","| --- | --- |");for(let[z,F]of C)N.push(`| ${z} | ${F} |`)}if(N.push("","### Bot activity","","| Metric | Value | Change |","| --- | --- | --- |",`| Pull requests opened | ${M.activity.opened} | ${H(E.opened)} |`,`| Merged | ${M.activity.merged} | ${H(E.merged)} |`,`| Closed without merging | ${M.activity.closed} | |`,`| Currently open | ${M.activity.open} | |`),M.activity.medianHoursToMerge!==null)N.push(`| Median time to merge | ${x(M.activity.medianHoursToMerge)} | |`);if(N.push(`| Merged vs opened | ${M.activity.mergeRate}% | ${H(E.mergeRate)} |`),N.push("",`_"Merged vs opened" compares both counts within the same ${j}-day window, so`,"recently opened pull requests depress it by definition._"),Object.keys(E).length===0)N.push("","_No previous report to compare against; this is the baseline._");return N.join(`
6
+ `)}async function Y(M,E,j,N,C=K()){if(!j)return M;try{let F=(await j.complete({system:"You write short factual summaries of dependency-health metrics. Interpret the numbers you are given; never invent figures, and never restate a table that already appears in the report. Three sentences at most.",messages:[{role:"user",content:[N?`Focus: ${N}`:"Focus: what changed and what needs attention.","","Metrics:",JSON.stringify(E,null,2)].join(`
7
+ `)}]})).text.trim();if(!F)return M;return M.replace("### Dependency health",`${F}
8
+
9
+ ### Dependency health`)}catch(z){return C.warn(`\u26A0\uFE0F Could not write the report narrative: ${z}`),M}}function x(M){if(M<24)return`${M}h`;return`${Math.round(M/24*10)/10}d`}export{U as I,Z as J,$ as K,W as L,_ as M,k as N,A as O,O as P,B as Q,S as R,R as S,T,Y as U};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ var c=new Set(["bower_components","node_modules","pantry","ts-pantry","vendor"]),f=new Set([".cache",".idea",".next",".nuxt",".nyc_output",".vscode","build","coverage","dist","temp","tmp"]);function g(b){return b.startsWith(".")||c.has(b)||f.has(b)}
3
+ export{g as ae};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Aj as M}from"./chunk-5k40mwd4.js";import{Lj as K}from"./chunk-1h3ey7k5.js";import{Rj as J}from"./chunk-akffynkc.js";import"./chunk-6g1y9yqh.js";function Q(j){let q=j.match(/github\.com\/([^/]+)\/([^/]+)\/(?:archive|releases\/download)\/(?:refs\/tags\/)?v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i);if(!q)return null;return{owner:q[1],repo:q[2].replace(/\.git$/,""),version:q[3],hasVPrefix:/\/v\d/.test(j)}}async function S(j,q){let y=J();try{let B={Accept:"application/vnd.github.v3+json","User-Agent":"buddy"};if(q)B.Authorization=`Bearer ${q}`;let E=await K(`${M()}/repos/${j.owner}/${j.repo}/releases/latest`,{headers:B});if(!E.ok)return y.debug(`No latest release for ${j.owner}/${j.repo}: ${E.status}`),null;let F=await E.json();if(!F.tag_name)return null;let I=F.tag_name.replace(/^v/,"");return/^\d+\.\d+\.\d+/.test(I)?I:null}catch(B){return y.debug(`Failed to fetch latest Zig version for ${j.owner}/${j.repo}: ${B}`),null}}function X(j,q){return j.replace(/\/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/i,(y)=>y.startsWith("/v")?`/v${q}`:`/${q}`)}async function Y(){try{return await Bun.spawn(["zig","version"],{stdout:"pipe",stderr:"pipe"}).exited===0}catch{return!1}}async function _(j){let q=J();try{let y=Bun.spawn(["zig","fetch",j],{stdout:"pipe",stderr:"pipe"}),[B,E]=await Promise.all([new Response(y.stdout).text(),y.exited]);if(E!==0){let I=await new Response(y.stderr).text();return q.warn(`\u26A0\uFE0F zig fetch failed for ${j}: ${I.trim()}`),null}let F=B.trim();return F.length>0?F:null}catch(y){return q.warn(`\u26A0\uFE0F Could not run zig fetch for ${j}: ${y}`),null}}export{X as zigUrlForVersion,Q as parseZigSource,Y as isZigAvailable,_ as fetchZigHash,S as fetchLatestZigVersion};
@@ -0,0 +1,503 @@
1
+ // @bun
2
+ import*as B from"fs";class J{static needsComposerSupport(){return B.existsSync("composer.json")}static generateComposerSetupSteps(){return`
3
+ - name: Setup PHP and Composer (if needed)
4
+ if: \${{ hashFiles('composer.json') != '' }}
5
+ uses: shivammathur/setup-php@v2
6
+ with:
7
+ php-version: '8.4'
8
+ tools: composer
9
+ coverage: none
10
+
11
+ - name: Install Composer dependencies (if needed)
12
+ if: \${{ hashFiles('composer.json') != '' }}
13
+ run: composer install --prefer-dist --optimize-autoloader
14
+ `}static getStandardSetupSteps(){return` - name: Checkout repository
15
+ uses: actions/checkout@v4
16
+ with:
17
+ token: \${{ secrets.GITHUB_TOKEN }}
18
+
19
+ - name: Setup Bun
20
+ uses: oven-sh/setup-bun@v2
21
+
22
+ - name: Install dependencies
23
+ run: bun install
24
+
25
+ - name: Build buddy
26
+ run: bun run build`}static generateWorkflow(j){return`name: ${j.name}
27
+
28
+ on:
29
+ schedule:
30
+ - cron: '${j.schedule}'
31
+ workflow_dispatch: # Allow manual triggering
32
+ inputs:
33
+ strategy:
34
+ description: 'Update strategy'
35
+ required: false
36
+ default: '${j.strategy||"all"}'
37
+ type: choice
38
+ options:
39
+ - all
40
+ - major
41
+ - minor
42
+ - patch
43
+ dry_run:
44
+ description: 'Dry run (preview only)'
45
+ required: false
46
+ default: false
47
+ type: boolean
48
+
49
+ env:
50
+ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
51
+
52
+ permissions:
53
+ contents: write
54
+ pull-requests: write
55
+ issues: write
56
+ actions: read
57
+ checks: read
58
+ statuses: read
59
+
60
+ concurrency:
61
+ group: buddy-\${{ github.ref }}
62
+ cancel-in-progress: false
63
+
64
+ jobs:
65
+ dependency-updates:
66
+ runs-on: ubuntu-latest
67
+ timeout-minutes: 30
68
+
69
+ steps:
70
+ - name: Checkout repository
71
+ uses: actions/checkout@v4
72
+ with:
73
+ token: \${{ secrets.GITHUB_TOKEN }}
74
+
75
+ - name: Setup Bun
76
+ uses: oven-sh/setup-bun@v2
77
+ \${GitHubActionsTemplate.generateComposerSetupSteps()}
78
+ - name: Install dependencies
79
+ run: bun install
80
+
81
+ - name: Build buddy
82
+ run: bun run build
83
+
84
+ - name: Run Buddy dependency updates
85
+ run: |
86
+ STRATEGY="\${{ github.event.inputs.strategy || '${j.strategy||"all"}' }}"
87
+ DRY_RUN="\${{ github.event.inputs.dry_run || 'false' }}"
88
+
89
+ if [ "$DRY_RUN" = "true" ]; then
90
+ ./buddy update --strategy "$STRATEGY" --dry-run --verbose
91
+ else
92
+ ./buddy update --strategy "$STRATEGY" --verbose
93
+ fi
94
+
95
+ - name: Auto-merge eligible PRs
96
+ if: \${{ ${j.autoMerge?"true":"false"} }}
97
+ run: ./buddy update-check --verbose
98
+ env:
99
+ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
100
+ `}static generateScheduledWorkflows(j){let q=j?.pullRequest?.autoMerge,z=j?.pullRequest?.reviewers||[],x=j?.pullRequest?.labels||[],E=q?.enabled&&q.conditions?.includes("patch-only")?q:q?.enabled??!0,F=q?.enabled&&!q.conditions?.includes("patch-only")?q:!1,K=!1;return{"dependency-updates-daily.yml":this.generateWorkflow({name:"Daily Dependency Updates",schedule:j?.schedule?.cron||"0 2 * * *",strategy:"patch",autoMerge:E,reviewers:z,labels:x}),"dependency-updates-weekly.yml":this.generateWorkflow({name:"Weekly Dependency Updates",schedule:"0 2 * * 1",strategy:"minor",autoMerge:F,reviewers:z,labels:x}),"dependency-updates-monthly.yml":this.generateWorkflow({name:"Monthly Dependency Updates",schedule:"0 2 1 * *",strategy:"major",autoMerge:!1,reviewers:z,labels:x})}}static generateComprehensiveWorkflow(j){return`name: Buddy Dependency Updates
101
+
102
+ on:
103
+ schedule:
104
+ # Patch updates daily at 2 AM
105
+ - cron: '0 2 * * *'
106
+ # Minor updates twice weekly at 2 AM (Monday, Thursday)
107
+ - cron: '0 2 * * 1,4'
108
+ # Major updates monthly at 2 AM (first of month)
109
+ - cron: '0 2 1 * *'
110
+
111
+ workflow_dispatch:
112
+ inputs:
113
+ strategy:
114
+ description: 'Update strategy'
115
+ required: true
116
+ default: 'all'
117
+ type: choice
118
+ options:
119
+ - all
120
+ - major
121
+ - minor
122
+ - patch
123
+ dry_run:
124
+ description: 'Dry run (preview only)'
125
+ required: false
126
+ default: false
127
+ type: boolean
128
+ packages:
129
+ description: 'Specific packages (comma-separated)'
130
+ required: false
131
+ type: string
132
+
133
+ env:
134
+ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
135
+
136
+ permissions:
137
+ contents: write
138
+ pull-requests: write
139
+ issues: write
140
+ actions: read
141
+ checks: read
142
+ statuses: read
143
+
144
+ concurrency:
145
+ group: buddy-\${{ github.ref }}
146
+ cancel-in-progress: false
147
+
148
+ jobs:
149
+ determine-strategy:
150
+ runs-on: ubuntu-latest
151
+ timeout-minutes: 5
152
+ outputs:
153
+ strategy: \${{ steps.strategy.outputs.strategy }}
154
+ auto_merge: \${{ steps.strategy.outputs.auto_merge }}
155
+ steps:
156
+ - name: Determine update strategy
157
+ id: strategy
158
+ run: |
159
+ if [ "\${{ github.event_name }}" = "workflow_dispatch" ]; then
160
+ echo "strategy=\${{ github.event.inputs.strategy }}" >> $GITHUB_OUTPUT
161
+ echo "auto_merge=false" >> $GITHUB_OUTPUT
162
+ elif [ "\${{ github.event.schedule }}" = "0 2 * * *" ]; then
163
+ echo "strategy=patch" >> $GITHUB_OUTPUT
164
+ echo "auto_merge=true" >> $GITHUB_OUTPUT
165
+ elif [ "\${{ github.event.schedule }}" = "0 2 * * 1,4" ]; then
166
+ echo "strategy=minor" >> $GITHUB_OUTPUT
167
+ echo "auto_merge=false" >> $GITHUB_OUTPUT
168
+ else
169
+ echo "strategy=major" >> $GITHUB_OUTPUT
170
+ echo "auto_merge=false" >> $GITHUB_OUTPUT
171
+ fi
172
+
173
+ dependency-updates:
174
+ runs-on: ubuntu-latest
175
+ timeout-minutes: 30
176
+ needs: determine-strategy
177
+
178
+ steps:
179
+ - name: Checkout repository
180
+ uses: actions/checkout@v4
181
+ with:
182
+ token: \${{ secrets.GITHUB_TOKEN }}
183
+
184
+ - name: Setup Bun
185
+ uses: oven-sh/setup-bun@v2
186
+ \${GitHubActionsTemplate.generateComposerSetupSteps()}
187
+ - name: Install dependencies
188
+ run: bun install
189
+
190
+ - name: Build buddy
191
+ run: bun run build
192
+
193
+ - name: Scan for updates
194
+ run: |
195
+ STRATEGY="\${{ needs.determine-strategy.outputs.strategy }}"
196
+ PACKAGES="\${{ github.event.inputs.packages || '' }}"
197
+
198
+ if [ "$PACKAGES" != "" ]; then
199
+ ./buddy scan --packages "$PACKAGES" --verbose
200
+ else
201
+ ./buddy scan --strategy "$STRATEGY" --verbose
202
+ fi
203
+
204
+ - name: Apply updates
205
+ if: \${{ github.event.inputs.dry_run != 'true' }}
206
+ run: |
207
+ STRATEGY="\${{ needs.determine-strategy.outputs.strategy }}"
208
+ PACKAGES="\${{ github.event.inputs.packages || '' }}"
209
+
210
+ if [ "$PACKAGES" != "" ]; then
211
+ ./buddy update --packages "$PACKAGES" --verbose
212
+ else
213
+ ./buddy update --strategy "$STRATEGY" --verbose
214
+ fi
215
+
216
+ - name: Dry run mode
217
+ if: \${{ github.event.inputs.dry_run == 'true' }}
218
+ run: |
219
+ echo "\uD83D\uDD0D Dry run mode - showing what would be updated"
220
+ STRATEGY="\${{ needs.determine-strategy.outputs.strategy }}"
221
+ PACKAGES="\${{ github.event.inputs.packages || '' }}"
222
+
223
+ if [ "$PACKAGES" != "" ]; then
224
+ ./buddy update --packages "$PACKAGES" --dry-run --verbose
225
+ else
226
+ ./buddy update --strategy "$STRATEGY" --dry-run --verbose
227
+ fi
228
+
229
+ - name: Auto-merge eligible updates
230
+ if: \${{ needs.determine-strategy.outputs.auto_merge == 'true' && github.event.inputs.dry_run != 'true' }}
231
+ run: |
232
+ echo "\uD83E\uDD16 Auto-merge enabled for patch updates"
233
+ echo "This feature will be implemented in future versions"
234
+ `}static generateDockerWorkflow(j){return`name: Buddy Dependencies (Docker)
235
+
236
+ on:
237
+ schedule:
238
+ - cron: '0 2 * * 1' # Weekly on Monday
239
+ workflow_dispatch:
240
+
241
+ concurrency:
242
+ group: buddy-\${{ github.ref }}
243
+ cancel-in-progress: false
244
+
245
+ jobs:
246
+ dependency-updates:
247
+ runs-on: ubuntu-latest
248
+ timeout-minutes: 30
249
+ container:
250
+ image: oven/bun:latest
251
+
252
+ steps:
253
+ - name: Checkout
254
+ uses: actions/checkout@v4
255
+
256
+ - name: Install dependencies
257
+ run: bun install
258
+
259
+ - name: Run Buddy updates
260
+ run: bunx @buddysh/buddy update --verbose
261
+ env:
262
+ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
263
+ `}static generateMonorepoWorkflow(j){return`name: Buddy Monorepo Updates
264
+
265
+ on:
266
+ schedule:
267
+ - cron: '0 2 * * 1'
268
+ workflow_dispatch:
269
+ inputs:
270
+ workspace:
271
+ description: 'Workspace to update'
272
+ required: false
273
+ type: string
274
+
275
+ concurrency:
276
+ group: buddy-\${{ github.ref }}
277
+ cancel-in-progress: false
278
+
279
+ jobs:
280
+ find-workspaces:
281
+ runs-on: ubuntu-latest
282
+ timeout-minutes: 5
283
+ outputs:
284
+ workspaces: \${{ steps.workspaces.outputs.workspaces }}
285
+ steps:
286
+ - uses: actions/checkout@v4
287
+ - name: Find workspaces
288
+ id: workspaces
289
+ run: |
290
+ if [ "\${{ github.event.inputs.workspace }}" != "" ]; then
291
+ echo "workspaces=["\${{ github.event.inputs.workspace }}"]" >> $GITHUB_OUTPUT
292
+ else
293
+ # Find all package.json files
294
+ WORKSPACES=$(find . -name "package.json" -not -path "./node_modules/*" | sed 's|/package.json||' | sed 's|^./||' | jq -R . | jq -s .)
295
+ echo "workspaces=$WORKSPACES" >> $GITHUB_OUTPUT
296
+ fi
297
+
298
+ update-workspace:
299
+ needs: find-workspaces
300
+ runs-on: ubuntu-latest
301
+ timeout-minutes: 30
302
+ strategy:
303
+ matrix:
304
+ workspace: \${{ fromJson(needs.find-workspaces.outputs.workspaces) }}
305
+
306
+ steps:
307
+ - uses: actions/checkout@v4
308
+ - uses: oven-sh/setup-bun@v2
309
+
310
+ - name: Install dependencies
311
+ run: bun install
312
+
313
+ - name: Update workspace dependencies
314
+ run: |
315
+ cd \${{ matrix.workspace }}
316
+ bunx @buddysh/buddy update --verbose
317
+ env:
318
+ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
319
+ `}static generateTestingWorkflow(j){return`name: Buddy Update
320
+
321
+ on:
322
+ schedule:
323
+ - cron: '*/20 * * * *' # Every 20 minutes for testing
324
+ workflow_dispatch: # Manual triggering for development
325
+ inputs:
326
+ strategy:
327
+ description: 'Update strategy'
328
+ required: false
329
+ default: 'patch'
330
+ type: choice
331
+ options:
332
+ - all
333
+ - major
334
+ - minor
335
+ - patch
336
+ dry_run:
337
+ description: 'Dry run (preview only)'
338
+ required: false
339
+ default: true
340
+ type: boolean
341
+ packages:
342
+ description: 'Specific packages (comma-separated)'
343
+ required: false
344
+ type: string
345
+ verbose:
346
+ description: 'Enable verbose logging'
347
+ required: false
348
+ default: true
349
+ type: boolean
350
+
351
+ env:
352
+ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
353
+
354
+ permissions:
355
+ contents: write
356
+ pull-requests: write
357
+ issues: write
358
+ actions: read
359
+ checks: read
360
+ statuses: read
361
+
362
+ concurrency:
363
+ group: buddy-\${{ github.ref }}
364
+ cancel-in-progress: false
365
+
366
+ jobs:
367
+ dependency-update:
368
+ runs-on: ubuntu-latest
369
+ timeout-minutes: 30
370
+
371
+ steps:
372
+ - name: Checkout repository
373
+ uses: actions/checkout@v4
374
+ with:
375
+ token: \${{ secrets.GITHUB_TOKEN }}
376
+
377
+ - name: Setup Bun
378
+ uses: oven-sh/setup-bun@v2
379
+ \${GitHubActionsTemplate.generateComposerSetupSteps()}
380
+ - name: Install dependencies
381
+ run: bun install
382
+
383
+ - name: Build buddy
384
+ run: bun run build
385
+
386
+ - name: Display test configuration
387
+ run: |
388
+ echo "\uD83E\uDDEA **Buddy Testing Mode**"
389
+ echo "Strategy: \${{ github.event.inputs.strategy || 'patch' }}"
390
+ echo "Dry Run: \${{ github.event.inputs.dry_run || 'true' }}"
391
+ echo "Packages: \${{ github.event.inputs.packages || 'all' }}"
392
+ echo "Verbose: \${{ github.event.inputs.verbose || 'true' }}"
393
+ echo "Triggered by: \${{ github.event_name }}"
394
+ echo "Repository: \${{ github.repository }}"
395
+ echo "Branch: \${{ github.ref_name }}"
396
+
397
+ - name: Run Buddy dependency scan
398
+ run: |
399
+ STRATEGY="\${{ github.event.inputs.strategy || 'patch' }}"
400
+ PACKAGES="\${{ github.event.inputs.packages }}"
401
+ VERBOSE="\${{ github.event.inputs.verbose || 'true' }}"
402
+
403
+ echo "\uD83D\uDD0D Scanning for dependency updates..."
404
+
405
+ if [ "$PACKAGES" != "" ]; then
406
+ if [ "$VERBOSE" = "true" ]; then
407
+ ./buddy scan --packages "$PACKAGES" --verbose
408
+ else
409
+ ./buddy scan --packages "$PACKAGES"
410
+ fi
411
+ else
412
+ if [ "$VERBOSE" = "true" ]; then
413
+ ./buddy scan --strategy "$STRATEGY" --verbose
414
+ else
415
+ ./buddy scan --strategy "$STRATEGY"
416
+ fi
417
+ fi
418
+
419
+ - name: Run Buddy dependency updates
420
+ if: \${{ github.event.inputs.dry_run != 'true' }}
421
+ run: |
422
+ STRATEGY="\${{ github.event.inputs.strategy || 'patch' }}"
423
+ PACKAGES="\${{ github.event.inputs.packages }}"
424
+ VERBOSE="\${{ github.event.inputs.verbose || 'true' }}"
425
+
426
+ echo "\uD83D\uDE80 Running dependency updates..."
427
+
428
+ if [ "$PACKAGES" != "" ]; then
429
+ if [ "$VERBOSE" = "true" ]; then
430
+ ./buddy update --packages "$PACKAGES" --verbose
431
+ else
432
+ ./buddy update --packages "$PACKAGES"
433
+ fi
434
+ else
435
+ if [ "$VERBOSE" = "true" ]; then
436
+ ./buddy update --strategy "$STRATEGY" --verbose
437
+ else
438
+ ./buddy update --strategy "$STRATEGY"
439
+ fi
440
+ fi
441
+
442
+ - name: Dry run notification
443
+ if: \${{ github.event.inputs.dry_run == 'true' }}
444
+ run: |
445
+ echo "\u2139\uFE0F **Dry Run Mode** - No changes were made"
446
+ echo "To apply updates, run this workflow again with 'Dry run' set to false"
447
+
448
+ - name: Create test summary
449
+ if: always()
450
+ run: |
451
+ echo "## \uD83E\uDDEA Buddy Testing Summary" >> $GITHUB_STEP_SUMMARY
452
+ echo "" >> $GITHUB_STEP_SUMMARY
453
+ echo "- **Strategy**: \${{ github.event.inputs.strategy || 'patch' }}" >> $GITHUB_STEP_SUMMARY
454
+ echo "- **Triggered by**: \${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
455
+ echo "- **Dry run**: \${{ github.event.inputs.dry_run || 'true' }}" >> $GITHUB_STEP_SUMMARY
456
+ echo "- **Packages**: \${{ github.event.inputs.packages || 'all' }}" >> $GITHUB_STEP_SUMMARY
457
+ echo "- **Verbose**: \${{ github.event.inputs.verbose || 'true' }}" >> $GITHUB_STEP_SUMMARY
458
+ echo "- **Time**: $(date)" >> $GITHUB_STEP_SUMMARY
459
+ echo "" >> $GITHUB_STEP_SUMMARY
460
+
461
+ if [ "\${{ github.event_name }}" = "schedule" ]; then
462
+ echo "\u23F0 **Scheduled Run**: This was triggered automatically every 20 minutes" >> $GITHUB_STEP_SUMMARY
463
+ echo "\uD83D\uDCA1 **Tip**: Use 'Actions' tab to manually trigger with custom settings" >> $GITHUB_STEP_SUMMARY
464
+ else
465
+ echo "\uD83D\uDDB1\uFE0F **Manual Trigger**: This was triggered manually from the Actions tab" >> $GITHUB_STEP_SUMMARY
466
+ echo "\u23F0 **Auto-Schedule**: This workflow also runs every 20 minutes for testing" >> $GITHUB_STEP_SUMMARY
467
+ fi
468
+
469
+ echo "" >> $GITHUB_STEP_SUMMARY
470
+ echo "\uD83D\uDCCA View detailed logs above for scan and update results." >> $GITHUB_STEP_SUMMARY
471
+ `}static generateCustomWorkflow(j,q){let z=!1;if(j.autoMerge!==void 0)z=j.autoMerge;else if(q?.pullRequest?.autoMerge){let x=q.pullRequest.autoMerge;if(x.enabled){if(x.conditions?.includes("patch-only")&&j.strategy==="patch")z=x;else if(!x.conditions?.includes("patch-only"))z=x}}return this.generateWorkflow({name:j.name,schedule:j.schedule,strategy:j.strategy||"all",autoMerge:z,reviewers:j.reviewers||q?.pullRequest?.reviewers||[],labels:j.labels||q?.pullRequest?.labels||[]})}static generateSecurityAuditWorkflow(){return`name: GH Actions Security Audit
472
+
473
+ on:
474
+ push:
475
+ branches: [main]
476
+ paths:
477
+ - '.github/workflows/**'
478
+ pull_request:
479
+ paths:
480
+ - '.github/workflows/**'
481
+ schedule:
482
+ - cron: '0 6 * * 1' # Monday 06:00 UTC \u2014 weekly drift check
483
+ workflow_dispatch:
484
+
485
+ permissions:
486
+ contents: read
487
+
488
+ jobs:
489
+ audit:
490
+ name: Audit GitHub Actions workflows
491
+ runs-on: ubuntu-latest
492
+ timeout-minutes: 5
493
+ steps:
494
+ - name: Checkout repository
495
+ uses: actions/checkout@v4
496
+
497
+ - name: Setup Bun
498
+ uses: oven-sh/setup-bun@v2
499
+
500
+ - name: Run buddy security
501
+ run: bunx --bun @buddysh/buddy security
502
+ `}}
503
+ export{J as zj};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{Fk as Z}from"./chunk-6g1y9yqh.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,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-s1km8cyq.js");return new Q(X,j.owner,j.name,j.apiUrl,z.logger)}case"bitbucket":{let{BitbucketProvider:Q}=await import("./chunk-yq0gxtzv.js");return new Q(X,j.owner,j.name,j.apiUrl,z.logger)}case"github":{let{GitHubProvider:Q}=await import("./chunk-qpz9k66h.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 Gd,$ as Hd,H as Id,L as Jd,Y as Kd,B as Ld,A as Md,C as Nd,M as Od,W as Pd,S as Qd};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ var L=[/\bsk-[a-z0-9-]*[a-z0-9]{16,}\b/gi,/\bAIza[\w-]{20,}\b/g,/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g,/\b(bearer\s+)[\w.\-~+/]{20,}=*/gi,/\b([\w-]*(?:token|secret|password|api[_-]?key|credential)[\w-]*\s*[=:]\s*)([\u0022\u0027]?)[^\s\u0022\u0027,}]{8,}\2/gi],U="[redacted]";function I(z){let B=z;for(let G of L)B=B.replace(G,(Q,H,J)=>{if(typeof H==="string"&&H.length>0)return`${H}${J??""}[redacted]${J??""}`;return"[redacted]"});return B}function K(z){if(typeof z==="string")return I(z);if(Array.isArray(z))return z.map(K);if(z&&typeof z==="object")return Object.fromEntries(Object.entries(z).map(([B,G])=>[B,K(G)]));return z}function V(z){if(z instanceof Error)return I(z.message);return I(String(z))}class M extends Error{spent;budget;constructor(z,B){super(`AI token budget exceeded: ${z} of ${B} output tokens used`);this.spent=z;this.budget=B;this.name="AiBudgetExceededError"}}class O extends Error{provider;status;constructor(z,B,G){super(z);this.provider=B;this.status=G;this.name="AiProviderError"}}
3
+ export{U as Ii,I as Ji,K as Ki,V as Li,M as Mi,O as Ni};
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ import{Ed as N}from"./chunk-xqx460y2.js";import{Be as E}from"./chunk-q9n79dd3.js";import{Rj as v}from"./chunk-akffynkc.js";import U from"process";var x=60000;async function D(q,K,$){let G=Bun.spawn([q,...K],{cwd:$,stdout:"pipe",stderr:"pipe",env:{PATH:U.env.PATH??"",HOME:U.env.HOME??"",LANG:"C"}}),Q=setTimeout(()=>G.kill(),x);try{let[W,V,X]=await Promise.all([new Response(G.stdout).text(),new Response(G.stderr).text(),G.exited]);return{stdout:W,stderr:V,exitCode:X}}finally{clearTimeout(Q)}}function F(q){switch(String(q??"").toLowerCase()){case"error":case"fatal":case"2":return"major";case"warning":case"warn":case"1":return"minor";default:return"nit"}}function j(q){let K=q.search(/[[{]/);if(K===-1)return null;try{return JSON.parse(q.slice(K))}catch{return null}}function H(q,K){let $=K.endsWith("/")?K:`${K}/`;return q.startsWith($)?q.slice($.length):q.replace(/^\.\//,"")}async function B(q){try{return await Bun.spawn(["which",q],{stdout:"ignore",stderr:"ignore",env:{PATH:U.env.PATH??""}}).exited===0}catch{return!1}}var y=/^(.+?):(\d+):(\d+):\s*(.*?)\s*\[([\w-]+)\]$/,I={name:"actionlint",filePatterns:[".github/workflows/*.yml",".github/workflows/*.yaml"],async available(){return B("actionlint")},async run(q,K){let{stdout:$}=await D("actionlint",["-oneline","-no-color",...q],K),G=[];for(let Q of $.split(`
3
+ `)){let W=y.exec(Q.trim());if(!W)continue;let[,V,X,,Z,Y]=W;G.push({path:H(V,K),line:Number(X),severity:"major",category:"workflow",message:`${Z} (${Y})`,tool:"actionlint"})}return G}};function u(q){switch(q){case"error":return"major";case"warning":return"minor";default:return"nit"}}var O={name:"workflow-audit",filePatterns:[".github/workflows/*.yml",".github/workflows/*.yaml"],async available(){return!0},async run(q,K){if(q.length===0)return[];let $=await N(K),G=new Set(q);return $.findings.filter((Q)=>G.has(Q.file)).map((Q)=>({path:Q.file,line:Q.line??1,severity:u(Q.severity),category:Q.ruleId,message:Q.fix?`${Q.message}
4
+
5
+ ${Q.fix}`:Q.message,tool:"workflow-audit"}))}};var _={name:"hadolint",filePatterns:["**/Dockerfile","**/Dockerfile.*","**/*.dockerfile","**/Containerfile"],async available(){return B("hadolint")},async run(q,K){let{stdout:$}=await D("hadolint",["--format","json","--no-fail",...q],K),G=j($);if(!Array.isArray(G))return[];return G.filter((Q)=>Q.level==="error"||Q.level==="warning").map((Q)=>({path:H(Q.file,K),line:Math.max(1,Q.line),severity:F(Q.level),category:"docker",message:`${Q.message} (${Q.code})`,tool:"hadolint"}))}};import{join as b}from"path";import h from"process";async function J(q,K){let $=j(q);if(!Array.isArray($))return[];let G=[];for(let Q of $)for(let W of Q.messages??[]){if(!W.line)continue;G.push({path:H(Q.filePath,K),line:W.line,severity:F(W.severity),category:"lint",message:W.ruleId?`${W.message} (${W.ruleId})`:W.message})}return G}function f(q,K){if(K<0||K>q.length)return null;let $=1;for(let G=0;G<K;G++)if(q[G]===`
6
+ `)$++;return $}async function g(q,K){let $=j(q);if(!$?.issues)return[];return $.issues.filter((G)=>Boolean(G.line)).map((G)=>({path:H(G.filePath,K),line:G.line,severity:F(G.severity),category:"lint",message:[G.ruleId?`${G.message} (${G.ruleId})`:G.message,G.help].filter(Boolean).join(" \u2014 ")}))}async function p(q,K){let $=j(q);if(!$?.diagnostics)return[];let G=[],Q=new Map;for(let W of $.diagnostics){let V=typeof W.location?.path==="string"?W.location.path:W.location?.path?.file;if(!V||!W.location?.span)continue;let X=H(V,K);if(!Q.has(X)){let C=Bun.file(b(K,X));Q.set(X,await C.exists()?await C.text():null)}let Z=Q.get(X);if(Z==null)continue;let Y=f(Z,W.location.span[0]);if(Y===null)continue;let M=typeof W.message==="string"?W.message:W.message?.map((C)=>C.content??"").join("")||W.description;G.push({path:X,line:Y,severity:F(W.severity),category:"lint",message:W.category?`${M} (${W.category})`:String(M)})}return G}var P=[{name:"pickier",configFiles:["pickier.config.ts","pickier.config.js","pickier.config.mjs"],args:["--reporter","json"],parse:g},{name:"biome",configFiles:["biome.json","biome.jsonc"],args:["check","--reporter=json"],parse:p},{name:"oxlint",configFiles:[".oxlintrc.json"],args:["--format=json"],parse:J},{name:"eslint",configFiles:["eslint.config.ts","eslint.config.js","eslint.config.mjs",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc"],args:["--format","json"],parse:J}];async function R(q){for(let $ of P)for(let G of $.configFiles)if(await Bun.file(b(q,G)).exists())return $;let K=await m(b(q,"package.json"));for(let $ of P){let G=new RegExp(`(?:^|[\\s/])${$.name}(?:$|[\\s@])`);if(Object.values(K).some((Q)=>G.test(Q)))return $}return null}async function m(q){let K=Bun.file(q);if(!await K.exists())return{};try{return(await K.json()).scripts??{}}catch{return{}}}var k={name:"linter",filePatterns:["**/*.ts","**/*.tsx","**/*.js","**/*.jsx","**/*.mjs","**/*.cjs"],async available(q){return await R(q||h.cwd())!==null},async run(q,K){let $=await R(K);if(!$)return[];let{stdout:G}=await D("bunx",["--bun",$.name,...$.args,...q],K);return(await $.parse(G,K)).map((W)=>({...W,tool:$.name}))}};var d=/^(.+?):(\d+)(?::\d+)?\s+(MD\d+)\/(\S+)\s+(.*)$/,c=new Set(["MD011","MD034","MD039","MD042","MD045","MD051","MD052","MD053"]),A={name:"markdownlint",filePatterns:["**/*.md","**/*.markdown"],async available(){return await B("markdownlint")||await B("markdownlint-cli2")},async run(q,K){let $=await B("markdownlint")?"markdownlint":"markdownlint-cli2",{stdout:G,stderr:Q}=await D($,q,K),W=[];for(let V of`${G}
7
+ ${Q}`.split(`
8
+ `)){let X=d.exec(V.trim());if(!X)continue;let[,Z,Y,M,C,z]=X;if(!c.has(M))continue;W.push({path:H(Z,K),line:Number(Y),severity:"minor",category:"docs",message:`${z} (${M}/${C})`,tool:"markdownlint"})}return W}};import{resolve as l}from"path";var a=[{id:"aws-access-key",pattern:/\bAKIA[0-9A-Z]{16}\b/,description:"AWS access key ID"},{id:"github-token",pattern:/\bgh[pousr]_[A-Za-z0-9]{36,}\b/,description:"GitHub token"},{id:"anthropic-key",pattern:/\bsk-ant-[A-Za-z0-9-]{20,}\b/,description:"Anthropic API key"},{id:"openai-key",pattern:/\bsk-(?:proj-)?[A-Za-z0-9]{32,}\b/,description:"OpenAI API key"},{id:"google-key",pattern:/\bAIza[\w-]{35}\b/,description:"Google API key"},{id:"slack-token",pattern:/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/,description:"Slack token"},{id:"private-key",pattern:/-----BEGIN (?:RSA |EC |OPENSSH |PGP )?PRIVATE KEY-----/,description:"Private key"},{id:"npm-token",pattern:/\bnpm_[A-Za-z0-9]{36}\b/,description:"npm access token"}],r=/(?:^|\/)(?:.*\.example|.*\.sample|.*fixtures?\/|.*__(?:mocks|fixtures)__\/)/,i=/\b(?:example|placeholder|dummy|fake|redacted|xxx+|your[_-]?key)\b/i,L={name:"secret-scan",filePatterns:["**/*"],async available(){return!0},async run(q,K){let $=[];for(let G of q){if(r.test(G))continue;let Q;try{let V=Bun.file(l(K,G));if(!await V.exists())continue;Q=await V.text()}catch{continue}let W=Q.split(`
9
+ `);for(let[V,X]of W.entries()){if(i.test(X))continue;for(let Z of a){if(!Z.pattern.test(X))continue;$.push({path:G,line:V+1,severity:"critical",category:Z.id,message:`Possible ${Z.description} committed to the repository. `+"If this is a live credential, rotate it \u2014 removing the line does not "+"remove it from git history.",tool:"secret-scan"});break}}}return $}};var w={name:"shellcheck",filePatterns:["**/*.sh","**/*.bash","**/*.ksh"],async available(){return B("shellcheck")},async run(q,K){let{stdout:$}=await D("shellcheck",["--format=json","--severity=warning",...q],K),G=j($);if(!Array.isArray(G))return[];return G.map((Q)=>({path:H(Q.file,K),line:Q.line,severity:F(Q.level),category:"shell",message:`${Q.message} (SC${Q.code}: https://www.shellcheck.net/wiki/SC${Q.code})`,tool:"shellcheck",...s(Q)}))}};function s(q){let K=q.fix?.replacements;if(K?.length!==1)return{};return{suggestion:K[0].replacement}}import{join as o}from"path";function n(q){let K=[/line (\d+)/i,/at line (\d+)/i,/\((\d+):\d+\)/,/:(\d+):\d+/];for(let $ of K){let G=$.exec(q);if(G){let Q=Number(G[1]);if(Number.isInteger(Q)&&Q>0)return Q}}return null}function t(q){return q.replace(/^\s*(?:JSON|YAML)\s*(?:Parse\s*)?(?:error|Error)?:?\s*/i,"").trim()}var T={name:"syntax",filePatterns:["**/*.json","**/*.jsonc","**/*.yml","**/*.yaml"],async available(){return!0},async run(q,K){let $=[];for(let G of q){let Q=Bun.file(o(K,G));if(!await Q.exists())continue;let W=await Q.text();if(!W.trim())continue;let V=G.endsWith(".json")||G.endsWith(".jsonc")?S(()=>JSON.parse(e(W,G))):S(()=>Bun.YAML.parse(W));if(!V)continue;$.push({path:G,line:n(V)??1,severity:"major",category:"syntax",message:`This file does not parse: ${t(V)}`,tool:"syntax"})}return $}};function S(q){try{return q(),null}catch(K){return K instanceof Error?K.message:String(K)}}function e(q,K){if(!K.endsWith(".jsonc"))return q;let $="",G=!1,Q=!1,W=0;while(W<q.length){let V=q[W];if(G){if($+=V,Q)Q=!1;else if(V==="\\")Q=!0;else if(V==='"')G=!1;W++;continue}if(V==='"'){G=!0,$+=V,W++;continue}if(V==="/"&&q[W+1]==="/"){while(W<q.length&&q[W]!==`
10
+ `)W++;continue}if(V==="/"&&q[W+1]==="*"){W+=2;while(W<q.length&&!(q[W]==="*"&&q[W+1]==="/")){if(q[W]===`
11
+ `)$+=`
12
+ `;W++}W+=2;continue}$+=V,W++}return $}var qq=[L,O,T,k,I,w,_,A];async function vq(q){let K=q.logger??v(),$=q.analyzers??qq,G=[],Q=[],W=[];for(let V of $){if(q.enabled?.[V.name]===!1)continue;let X=E(V.filePatterns),Z=q.files.filter((Y)=>X.matches(Y));if(Z.length===0)continue;if(!await V.available(q.root)){W.push({name:V.name,reason:"tool not available on this runner"}),K.debug(`\u23ED\uFE0F Skipping ${V.name}: not available`);continue}try{let Y=await V.run(Z,q.root);G.push(...Y),Q.push({name:V.name,findings:Y.length}),K.debug(`\uD83D\uDD0E ${V.name}: ${Y.length} finding(s) over ${Z.length} file(s)`)}catch(Y){W.push({name:V.name,reason:Y instanceof Error?Y.message:String(Y)}),K.warn(`\u26A0\uFE0F ${V.name} failed: ${Y}`)}}return{findings:G,ran:Q,skipped:W}}
13
+ export{x as kd,D as ld,F as md,j as nd,H as od,B as pd,I as qd,O as rd,_ as sd,f as td,P as ud,R as vd,k as wd,A as xd,a as yd,L as zd,w as Ad,T as Bd,qq as Cd,vq as Dd};
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ import{Lj as U}from"./chunk-1h3ey7k5.js";import{Rj as f}from"./chunk-akffynkc.js";var{Glob:u}=globalThis.Bun;import{readdir as m}from"fs/promises";import{join as P,relative as l}from"path";import O from"process";var c=new Set(["node_modules","vendor","target",".git",".venv","venv","dist","build","__pycache__",".next",".cache"]);function W(z){return z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function L(z,H,$=4){let X=H.map((K)=>new u(K)),Z=[];async function J(K,G){if(G>$)return;let V=await m(K,{withFileTypes:!0}).catch(()=>[]);for(let Q of V){let j=P(K,Q.name);if(Q.isDirectory()){if(!c.has(Q.name)&&!Q.name.startsWith("."))await J(j,G+1);continue}let q=l(z,j);if(X.some((Y)=>Y.match(Q.name)||Y.match(q)))Z.push(q)}}return await J(z,0),Z.sort()}async function M(z,H){let $=[],X=[];for(let Z of H){if(!await Bun.file(P(z,Z.lockfile)).exists())continue;let[J]=Z.command;if(!await E(J)){X.push(`${Z.lockfile} (needs \`${Z.command.join(" ")}\`)`);continue}if(await Bun.spawn(Z.command,{cwd:z,stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??"",HOME:O.env.HOME??""}}).exited===0)$.push(Z.lockfile);else X.push(`${Z.lockfile} (\`${Z.command.join(" ")}\` failed)`)}return{regenerated:$,...X.length>0?{note:`These lockfiles were not regenerated and need updating locally: ${X.join(", ")}.`}:{}}}async function E(z){try{return await Bun.spawn(["which",z],{stdout:"ignore",stderr:"ignore",env:{PATH:O.env.PATH??""}}).exited===0}catch{return!1}}function B(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);for(let J=0;J<Math.max(X.length,Z.length);J++){let K=(X[J]??0)-(Z[J]??0);if(K!==0)return K}return 0}function C(z,H){let $=(J)=>J.replace(/^[^\d]*/,"").split(/[.-]/).map((K)=>Number.parseInt(K,10)||0),X=$(z),Z=$(H);if((X[0]??0)!==(Z[0]??0))return"major";if((X[1]??0)!==(Z[1]??0))return"minor";return"patch"}var p=/^\s*(?:require\s+)?([\w.~-]+(?:\.[\w.~-]+)*\/[^\s]+)\s+(v[\w.+-]+)\s*(\/\/.*)?$/,R=/^v\d+\.\d+\.\d+-\d{14}-[a-f0-9]{12}$/,I={name:"go",manifestPatterns:["go.mod"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=!1;for(let Z of H.split(`
3
+ `)){let J=Z.trim();if(/^require\s*\($/.test(J)){X=!0;continue}if(X&&J===")"){X=!1;continue}if(!X&&!J.startsWith("require "))continue;let K=p.exec(Z);if(!K)continue;let[,G,V,Q]=K;if(Q?.includes("indirect"))continue;if(R.test(V))continue;$.push({name:G,currentVersion:V,section:"require",file:z})}return $},async latest(z,H={}){let $=H.registryUrl??"https://proxy.golang.org",X=z.name.replace(/[A-Z]/g,(K)=>`!${K.toLowerCase()}`),Z=await U(`${$}/${X}/@latest`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!Z?.ok)return null;let J=await Z.json().catch(()=>null);if(!J?.Version)return null;if(R.test(J.Version))return null;return{latest:J.Version,...J.Time?{publishedAt:new Date(J.Time)}:{},releaseNotesUrl:`https://pkg.go.dev/${z.name}@${J.Version}`,homepage:`https://pkg.go.dev/${z.name}`}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion);return z.replace(new RegExp(`^(\\s*(?:require\\s+)?${$}\\s+)${X}(\\s|$)`,"gm"),`$1${H.newVersion}$2`)},async postWrite(z){return M(z,[{lockfile:"go.sum",command:["go","mod","tidy"]}])},osvEcosystem:"Go",compareVersions:B,updateType:C};var s=/^\s*v?(?:(\d+)!)?(\d+(?:\.\d+)*)((?:[-_.]?(?:a|b|c|rc|alpha|beta|pre|preview)[-_.]?\d*)?)((?:[-_.]?(?:post|rev|r)[-_.]?\d*|-\d+)?)((?:[-_.]?dev[-_.]?\d*)?)(?:\+([a-z0-9]+(?:[-_.][a-z0-9]+)*))?\s*$/i,i={a:"a",alpha:"a",b:"b",beta:"b",c:"rc",rc:"rc",pre:"rc",preview:"rc"},v={a:0,b:1,rc:2};function S(z){let H=s.exec(z);if(!H)return null;let[,$,X,Z,J,K,G]=H,V={epoch:$?Number($):0,release:X.split(".").map(Number)};if(Z){let Q=/([a-z]+)[-_.]?(\d*)/i.exec(Z);if(Q){let j=i[Q[1].toLowerCase()];if(j)V.pre=[j,Q[2]?Number(Q[2]):0]}}if(J){let Q=/(\d+)/.exec(J);V.post=Q?Number(Q[1]):0}if(K){let Q=/(\d+)/.exec(K);V.dev=Q?Number(Q[1]):0}if(G)V.local=G.toLowerCase();return V}function d(z,H){for(let $=0;$<Math.max(z.length,H.length);$++){let X=(z[$]??0)-(H[$]??0);if(X!==0)return X}return 0}function A(z,H){let $=S(z),X=S(H);if(!$||!X)return z===H?0:z<H?-1:1;if($.epoch!==X.epoch)return $.epoch-X.epoch;let Z=d($.release,X.release);if(Z!==0)return Z;let J=(Q)=>{if(Q.dev!==void 0&&Q.pre===void 0&&Q.post===void 0)return 0;if(Q.pre!==void 0)return 1;if(Q.post!==void 0)return 3;return 2},K=J($)-J(X);if(K!==0)return K;if($.pre&&X.pre){let Q=v[$.pre[0]]-v[X.pre[0]];if(Q!==0)return Q;if($.pre[1]!==X.pre[1])return $.pre[1]-X.pre[1]}if(($.post??0)!==(X.post??0))return($.post??0)-(X.post??0);let G=$.dev??Number.POSITIVE_INFINITY,V=X.dev??Number.POSITIVE_INFINITY;if(G!==V)return G<V?-1:1;return 0}function g(z){let H=S(z);return Boolean(H&&(H.pre!==void 0||H.dev!==void 0))}function D(z,H){let $=S(z),X=S(H);if(!$||!X)return"patch";if($.epoch!==X.epoch||($.release[0]??0)!==(X.release[0]??0))return"major";if(($.release[1]??0)!==(X.release[1]??0))return"minor";return"patch"}function N(z){let H=/^\s*(~=|===|==|!=|<=|>=|<|>|\^)?\s*(.*)$/.exec(z.trim());if(!H)return{operator:"",version:z.trim()};return{operator:H[1]??"",version:H[2].trim()}}var b=/^\s*([A-Z0-9][\w.-]*)\s*(\[[^\]]*\])?\s*([<>=!~^].*?)?\s*(?:;.*)?$/i,o=/^\s*(?:-|#|$)/;function r(z,H){let $=[];return H.split(`
4
+ `).forEach((X)=>{let Z=X.split("#")[0];if(o.test(Z))return;let J=b.exec(Z);if(!J?.[1]||!J[3])return;$.push({name:J[1],currentVersion:J[3].trim(),section:"dependencies",file:z,...J[2]?{metadata:{extras:J[2]}}:{}})}),$}var a=[[/^\s*dependencies\s*=\s*\[/m,"dependencies"],[/^\s*(?:dev-dependencies|dev)\s*=\s*\[/m,"devDependencies"]];function n(z,H){let $=[],X=new Set,Z=(K,G,V)=>{let Q=`${V}:${K}`;if(!G.trim()||G.trim()==="*"||X.has(Q))return;X.add(Q),$.push({name:K,currentVersion:G.trim(),section:V,file:z})};for(let[K,G]of a){let V=K.exec(H);if(!V)continue;let Q=V.index+V[0].length,j=H.indexOf("]",Q);if(j===-1)continue;for(let q of H.slice(Q,j).matchAll(/["']([^"']+)["']/g)){let Y=b.exec(q[1]);if(Y?.[1]&&Y[3])Z(Y[1],Y[3],G)}}let J=H.matchAll(/\[tool\.poetry\.(?:group\.[\w-]+\.)?(dependencies|dev-dependencies)\]([\s\S]*?)(?=\n\[|$)/g);for(let K of J){let G=K[1]==="dependencies"?"dependencies":"devDependencies";for(let V of K[2].matchAll(/^\s*([A-Z0-9][\w.-]*)\s*=\s*(.+)$/gim)){let Q=V[1];if(Q.toLowerCase()==="python")continue;let j=V[2].trim(),q=/version\s*=\s*["']([^"']+)["']/.exec(j),Y=/^["']([^"']+)["']/.exec(j),F=q?.[1]??Y?.[1];if(F)Z(Q,F,G)}}return $}var w={name:"python",manifestPatterns:["pyproject.toml","requirements.txt","requirements-*.txt","requirements/*.txt"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){return z.endsWith(".toml")?n(z,H):r(z,H)},async latest(z,H={}){let $=H.registryUrl??"https://pypi.org",X=await U(`${$}/pypi/${encodeURIComponent(z.name)}/json`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Z?.info?.version)return null;let J=Z.info.version;if(H.includePrerelease&&Z.releases){let V=Object.keys(Z.releases).filter((Q)=>!Z.releases[Q]?.every((j)=>j.yanked)).sort(A);J=V[V.length-1]??J}let G=Z.releases?.[J]?.find((V)=>V.upload_time_iso_8601)?.upload_time_iso_8601;return{latest:J,...G?{publishedAt:new Date(G)}:{},...Z.info.yanked?{deprecated:!0}:{},...Z.info.project_urls?.Changelog?{releaseNotesUrl:Z.info.project_urls.Changelog}:{},...Z.info.home_page?{homepage:Z.info.home_page}:{}}},applyUpdate(z,H){let{operator:$}=N(H.currentVersion),X=W(H.name),Z=W(H.currentVersion),J=N(H.newVersion).version,K=$?`${$}${J}`:J;return z.replace(new RegExp(`(^|["'\\s])(${X})(\\[[^\\]]*\\])?\\s*${Z}`,"gim"),(G,V,Q,j)=>`${V}${Q}${j??""}${K}`).replace(new RegExp(`^(\\s*${X}\\s*=\\s*["'])${Z}(["'])`,"gim"),`$1${K}$2`).replace(new RegExp(`^(\\s*${X}\\s*=\\s*\\{[^}]*version\\s*=\\s*["'])${Z}(["'])`,"gim"),`$1${K}$2`)},async postWrite(z){return M(z,[{lockfile:"uv.lock",command:["uv","lock"]},{lockfile:"poetry.lock",command:["poetry","lock","--no-update"]}])},osvEcosystem:"PyPI",compareVersions:A,updateType:D};var t=/^\s*gem\s+["']([\w-]+)["']\s*(?:,\s*["']([^"']+)["'])?/,e=/^\s*group\s+(.+?)\s+do\s*$/,zz=/^\s*end\s*$/,x={name:"ruby",manifestPatterns:["Gemfile","*.gemspec"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[],X=[];for(let Z of H.split(`
5
+ `)){let J=Z.replace(/#.*$/,""),K=e.exec(J);if(K){X.push(K[1].replace(/[:'",\s]/g,"")||"default");continue}if(zz.test(J)){X.pop();continue}let G=t.exec(J);if(!G?.[1])continue;if(!G[2])continue;if(/\b(?:path|git|github|branch):/.test(J))continue;$.push({name:G[1],currentVersion:G[2],section:X.length>0?X[X.length-1]:"dependencies",file:z})}return $},async latest(z,H={}){let $=H.registryUrl??"https://rubygems.org",X=await U(`${$}/api/v1/versions/${encodeURIComponent(z.name)}.json`,{headers:{"User-Agent":"buddy",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Array.isArray(Z)||Z.length===0)return null;let J=Z.filter((G)=>G.number&&!G.yanked).filter((G)=>H.includePrerelease?!0:!G.prerelease).sort((G,V)=>B(G.number,V.number)),K=J[J.length-1];if(!K?.number)return null;return{latest:K.number,...K.created_at?{publishedAt:new Date(K.created_at)}:{},homepage:`${$}/gems/${z.name}`}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion),Z=/^\s*(~>|>=|<=|>|<|=)?\s*/.exec(H.currentVersion)?.[1]??"",J=Z?`${Z} ${H.newVersion}`:H.newVersion;return z.replace(new RegExp(`^(\\s*gem\\s+["']${$}["']\\s*,\\s*["'])${X}(["'])`,"gm"),`$1${J}$2`)},async postWrite(z){return M(z,[{lockfile:"Gemfile.lock",command:["bundle","lock","--update"]}])},osvEcosystem:"RubyGems",compareVersions:B,updateType:C};var Hz=[[/^\[dependencies\]/m,"dependencies"],[/^\[dev-dependencies\]/m,"devDependencies"],[/^\[build-dependencies\]/m,"buildDependencies"],[/^\[workspace\.dependencies\]/m,"workspaceDependencies"]],T={name:"rust",manifestPatterns:["Cargo.toml"],async detect(z){return L(z,this.manifestPatterns)},async parse(z,H){let $=[];for(let[X,Z]of Hz){let J=X.exec(H);if(!J)continue;let K=J.index+J[0].length,G=H.slice(K).search(/\n\[/),V=G===-1?H.slice(K):H.slice(K,K+G);for(let Q of V.matchAll(/^\s*([\w-]+)\s*=\s*(.+)$/gm)){let j=Q[1],q=Q[2].trim(),Y=/version\s*=\s*["']([^"']+)["']/.exec(q),F=/^["']([^"']+)["']/.exec(q),_=Y?.[1]??F?.[1];if(!_||/\b(?:path|git)\s*=/.test(q))continue;$.push({name:j,currentVersion:_,section:Z,file:z})}}return $},async latest(z,H={}){let $=H.registryUrl??"https://crates.io",X=await U(`${$}/api/v1/crates/${encodeURIComponent(z.name)}`,{headers:{"User-Agent":"buddy (https://buddy.sh)",Accept:"application/json"}}).catch(()=>null);if(!X?.ok)return null;let Z=await X.json().catch(()=>null);if(!Z?.crate)return null;let J=H.includePrerelease?Z.crate.newest_version??Z.crate.max_stable_version:Z.crate.max_stable_version??Z.crate.newest_version;if(!J)return null;let K=Z.versions?.find((G)=>G.num===J);if(K?.yanked)return null;return{latest:J,...K?.created_at?{publishedAt:new Date(K.created_at)}:{},...Z.crate.repository?{releaseNotesUrl:`${Z.crate.repository}/releases`}:{},...Z.crate.homepage?{homepage:Z.crate.homepage}:{}}},applyUpdate(z,H){let $=W(H.name),X=W(H.currentVersion);return z.replace(new RegExp(`^(\\s*${$}\\s*=\\s*["'])${X}(["'])`,"gm"),`$1${H.newVersion}$2`).replace(new RegExp(`^(\\s*${$}\\s*=\\s*\\{[^}]*?version\\s*=\\s*["'])${X}(["'])`,"gm"),`$1${H.newVersion}$2`)},async postWrite(z){return M(z,[{lockfile:"Cargo.lock",command:["cargo","update","--workspace"]}])},osvEcosystem:"crates.io",compareVersions:B,updateType:C};import{join as Xz}from"path";async function Zz(z){let H=z.logger??f(),$=z.adapters??k,X=new Set(z.ignore??[]),Z=[],J={},K=[];return await Promise.all($.map(async(G)=>{let V;try{V=await G.detect(z.dir)}catch(Q){H.warn(`\u26A0\uFE0F ${G.name}: could not look for manifests: ${Q}`);return}if(V.length===0)return;K.push({ecosystem:G.name,files:V}),H.debug(`\uD83D\uDCE6 ${G.name}: ${V.length} manifest(s)`);for(let Q of V){let j;try{j=await G.parse(Q,await Bun.file(Xz(z.dir,Q)).text())}catch(Y){H.warn(`\u26A0\uFE0F ${G.name}: could not parse ${Q}: ${Y}`);continue}J[G.name]=(J[G.name]??0)+j.length;let q=await Promise.all(j.map(async(Y)=>{if(X.has(Y.name))return null;try{let F=await G.latest(Y,{...z.includePrerelease!==void 0?{includePrerelease:z.includePrerelease}:{},logger:H});if(!F)return null;let _=y(Y.currentVersion);if(G.compareVersions(F.latest,_)<=0)return null;return{name:Y.name,currentVersion:Y.currentVersion,newVersion:F.latest,updateType:G.updateType(_,F.latest),dependencyType:G.name,file:Q,...F.releaseNotesUrl?{releaseNotesUrl:F.releaseNotesUrl}:{},...F.homepage?{homepage:F.homepage}:{}}}catch(F){return H.debug(`${G.name}: could not resolve ${Y.name}: ${F}`),null}}));Z.push(...q.filter((Y)=>Y!==null))}})),{updates:Z,dependenciesByEcosystem:J,manifests:K}}function y(z){let H=/(\d[\w.!+-]*)/.exec(z);return H?H[1]:z.trim()}async function $z(z,H,$=k){let X=[],Z=[];for(let J of $){if(!H.includes(J.name)||!J.postWrite)continue;let K=await J.postWrite(z).catch(()=>({regenerated:[],note:void 0}));if(X.push(...K.regenerated),K.note)Z.push(K.note)}return{regenerated:X,notes:Z}}var k=[w,T,I,x];function Ez(z,H=k){let $=z.split("/").pop()??z;for(let X of H)if(X.manifestPatterns.some((Z)=>h($,Z)||h(z,Z)))return X;return null}function h(z,H){if(!H.includes("*"))return z===H;let $=H.split("*").map((X)=>X.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join("[^/]*");return new RegExp(`^${$}$`).test(z)}function Rz(z,H=k){return H.find(($)=>$.name===z)??null}
6
+ export{W as bc,L as cc,M as dc,E as ec,B as fc,C as gc,I as hc,S as ic,A as jc,g as kc,D as lc,N as mc,w as nc,x as oc,T as pc,k as qc,Ez as rc,Rz as sc,Zz as tc,y as uc,$z as vc};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{createRequire as a}from"module";var{defineProperty:o,getOwnPropertyNames:f,getOwnPropertyDescriptor:u}=Object,p=Object.prototype.hasOwnProperty;function c(e){return this[e]}var m=(e)=>{var r=(i??=new WeakMap).get(e),t;if(r)return r;if(r=o({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var n of f(e))if(!p.call(r,n))o(r,n,{get:c.bind(e,n),enumerable:!(t=u(e,n))||t.enumerable})}return i.set(e,r),r},i,s=(e)=>e;function l(e,r){this[e]=s.bind(null,r)}var b=(e,r)=>{for(var t in r)o(e,t,{get:r[t],enumerable:!0,configurable:!0,set:l.bind(r,t)})},g=(e,r)=>()=>(e&&(r=e(e=0)),r),y=a(import.meta.url);
3
+ export{m as Ak,b as Bk,g as Ck};