@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,56 @@
1
+ /**
2
+ * Parse a Docker tag.
3
+ *
4
+ * Docker tags are not semver and cannot be treated as such: `1.2`, `18`,
5
+ * `20.11.1-alpine3.19` and `bookworm` are all ordinary. What matters is the
6
+ * leading numeric run and whatever variant follows it.
7
+ *
8
+ * @param tag - The raw tag
9
+ * @returns The parsed tag, or null when it carries no version at all
10
+ */
11
+ export declare function parseTag(tag: string): ParsedTag | null;
12
+ /** Compare two version component arrays, longest-common-prefix style. */
13
+ export declare function compareVersions(a: number[], b: number[]): number;
14
+ /**
15
+ * Whether two suffixes name the same image variant.
16
+ *
17
+ * Compared by their leading word rather than exactly, so `alpine3.18` and
18
+ * `alpine3.19` are the same variant moving forward. Without this a
19
+ * `node:20-alpine3.18` image would never see an update, because every newer
20
+ * tag carries a different alpine version in its suffix.
21
+ */
22
+ export declare function sameVariant(a: string, b: string): boolean;
23
+ /**
24
+ * Find the newest tag that is an upgrade of the current one.
25
+ *
26
+ * Variant is preserved absolutely: an `-alpine` image must not be "updated"
27
+ * to a Debian one. That would swap the base distribution underneath a
28
+ * Dockerfile whose later `RUN apk add …` lines would then fail — a change
29
+ * nobody asked for, arriving as a dependency bump.
30
+ *
31
+ * @param currentTag - The tag in the file
32
+ * @param available - Tags the registry reported
33
+ * @param options - Whether to consider pre-releases
34
+ * @returns The newer tag, or null when there is nothing better
35
+ * @example
36
+ * ```ts
37
+ * selectLatestTag('20.10-alpine', ['20.11-alpine', '21.0', '20.11-slim'])
38
+ * // '20.11-alpine'
39
+ * ```
40
+ */
41
+ export declare function selectLatestTag(currentTag: string, available: string[], options?: { includePrerelease?: boolean }): string | null;
42
+ /**
43
+ * Classify a tag change, for grouping and strategy filtering.
44
+ *
45
+ * @param from - Current tag
46
+ * @param to - Proposed tag
47
+ * @returns The update type, defaulting to `patch` when unclear
48
+ */
49
+ export declare function tagUpdateType(from: string, to: string): 'major' | 'minor' | 'patch';
50
+ /** A tag parsed into the parts that decide whether it is an upgrade. */
51
+ export declare interface ParsedTag {
52
+ raw: string
53
+ version: number[]
54
+ suffix: string
55
+ prerelease: boolean
56
+ }
@@ -0,0 +1,87 @@
1
+ import type { Logger } from '../utils/logger';
2
+ /** The endoflife.date product slug for an image, when there is one. */
3
+ export declare function productFor(image: string): string | null;
4
+ /** The release cycle a tag belongs to, e.g. `20.11-alpine` → `20`. */
5
+ export declare function cycleFor(tag: string, cycles: EolCycle[]): EolCycle | null;
6
+ /**
7
+ * Look up whether a base image's release cycle is past end of life.
8
+ *
9
+ * Container advisories are thin in OSV, so the practical question for a base
10
+ * image is not "does it have a known CVE" but "is anyone still shipping
11
+ * security patches for it". An image on an EOL cycle stops receiving fixes
12
+ * entirely, which is a more consequential fact than any single advisory.
13
+ *
14
+ * @param image - Image name, with or without a registry
15
+ * @param tag - The tag in the file
16
+ * @param options - Clock and logger, injected so results are reproducible
17
+ * @returns The support status, or null when the product is not tracked
18
+ * @example
19
+ * ```ts
20
+ * const status = await checkEol('node', '18-alpine')
21
+ * if (status?.eol)
22
+ * findings.push(`node:18 reached end of life on ${status.date}`)
23
+ * ```
24
+ */
25
+ export declare function checkEol(image: string, tag: string, options?: { now?: Date, logger?: Logger, baseUrl?: string }): Promise<EolStatus | null>;
26
+ /**
27
+ * Describe a support status for a pull request or a gate.
28
+ *
29
+ * @param status - The status to describe
30
+ * @returns A sentence, or empty when there is nothing worth saying
31
+ */
32
+ export declare function describeEol(status: EolStatus | null): string;
33
+ /**
34
+ * Docker images whose support windows endoflife.date tracks.
35
+ *
36
+ * Mapped explicitly rather than guessed from the image name: `node` and
37
+ * `nodejs` are the same product under different names, and an image whose
38
+ * product slug is wrong would report a support window belonging to something
39
+ * else entirely.
40
+ * @defaultValue
41
+ * ```ts
42
+ * {
43
+ * 'node': 'nodejs',
44
+ * 'library/node': 'nodejs',
45
+ * 'python': 'python',
46
+ * 'library/python': 'python',
47
+ * 'debian': 'debian',
48
+ * 'library/debian': 'debian',
49
+ * 'ubuntu': 'ubuntu',
50
+ * 'library/ubuntu': 'ubuntu',
51
+ * 'alpine': 'alpine',
52
+ * 'library/alpine': 'alpine',
53
+ * 'php': 'php',
54
+ * 'library/php': 'php',
55
+ * 'ruby': 'ruby',
56
+ * 'library/ruby': 'ruby',
57
+ * 'golang': 'go',
58
+ * 'library/golang': 'go',
59
+ * 'postgres': 'postgresql',
60
+ * 'library/postgres': 'postgresql',
61
+ * 'mysql': 'mysql',
62
+ * 'library/mysql': 'mysql',
63
+ * 'redis': 'redis',
64
+ * 'library/redis': 'redis',
65
+ * 'nginx': 'nginx',
66
+ * 'library/nginx': 'nginx'
67
+ * }
68
+ * ```
69
+ */
70
+ export declare const EOL_PRODUCTS: Record<string, string>;
71
+ /** How soon an approaching end of life is worth mentioning. */
72
+ export declare const EOL_WARNING_DAYS: 90;
73
+ /** A release cycle, as endoflife.date reports it. */
74
+ export declare interface EolCycle {
75
+ cycle: string
76
+ eol: string | boolean
77
+ latest?: string
78
+ support?: string | boolean
79
+ }
80
+ /** What is known about a base image's support window. */
81
+ export declare interface EolStatus {
82
+ product: string
83
+ cycle: string
84
+ eol: boolean
85
+ date?: string
86
+ daysRemaining?: number
87
+ }
@@ -0,0 +1,98 @@
1
+ import type { Logger } from '../utils/logger';
2
+ /**
3
+ * Parse an image reference.
4
+ *
5
+ * Follows Docker's own rules, which are less obvious than they look: the first
6
+ * path segment is a registry only if it contains a dot, a colon, or is exactly
7
+ * `localhost`. Otherwise `alpine/git` is a Docker Hub org, not the host
8
+ * `alpine` — and treating it as a host would send credentials to a machine
9
+ * that does not exist.
10
+ *
11
+ * @param image - Reference such as `ghcr.io/org/app:1.2.3`
12
+ * @returns The parsed reference
13
+ * @example
14
+ * ```ts
15
+ * parseImageRef('alpine:3.19')
16
+ * // { registry: 'docker.io', repository: 'library/alpine', tag: '3.19' }
17
+ * ```
18
+ */
19
+ export declare function parseImageRef(image: string): ImageRef;
20
+ /** Render a reference back to the string a Dockerfile would contain. */
21
+ export declare function formatImageRef(ref: ImageRef): string;
22
+ /** The API host to talk to for a registry name. */
23
+ export declare function apiHostFor(registry: string): string;
24
+ /**
25
+ * Resolve credentials for a host.
26
+ *
27
+ * GHCR is special-cased to fall back to the ambient GitHub token, which makes
28
+ * private-package updates work in Actions with no configuration at all — the
29
+ * token is already there and already scoped correctly.
30
+ *
31
+ * @param registry - Registry host
32
+ * @param config - Configured per-host credentials
33
+ * @param env - Environment to read secrets from
34
+ * @returns A basic-auth pair or bearer token, or null when anonymous
35
+ */
36
+ export declare function resolveCredentials(registry: string, config: DockerRegistryConfig | undefined, env?: Record<string, string | undefined>): { username: string, password: string } | { token: string } | null;
37
+ /**
38
+ * Parse a registry's bearer challenge.
39
+ *
40
+ * This one function is what unlocks GHCR, Quay, GCR and most private
41
+ * registries: they all answer an anonymous request with a 401 naming where to
42
+ * get a token, and honouring it is the whole of the standard flow.
43
+ *
44
+ * @param header - The `WWW-Authenticate` header value
45
+ * @returns The challenge, or null when it is not a bearer challenge
46
+ */
47
+ export declare function parseAuthChallenge(header: string | null): AuthChallenge | null;
48
+ /** Build the token-endpoint URL for a challenge. */
49
+ export declare function tokenUrlFor(challenge: AuthChallenge, repository: string): string;
50
+ /** Follow a `Link: <…>; rel="next"` header, resolved against the host. */
51
+ export declare function nextPageUrl(link: string | null, host: string): string | null;
52
+ /** An image reference, broken into the parts the registry API needs. */
53
+ export declare interface ImageRef {
54
+ registry: string
55
+ repository: string
56
+ tag: string
57
+ digest?: string
58
+ }
59
+ /** Credentials for one registry host. */
60
+ export declare interface RegistryAuth {
61
+ username?: string
62
+ passwordEnv?: string
63
+ tokenEnv?: string
64
+ }
65
+ /** A parsed `WWW-Authenticate: Bearer …` challenge. */
66
+ export declare interface AuthChallenge {
67
+ realm: string
68
+ service?: string
69
+ scope?: string
70
+ }
71
+ /** Options shared by the client's requests. */
72
+ export declare interface OciClientOptions {
73
+ registries?: DockerRegistryConfig
74
+ env?: Record<string, string | undefined>
75
+ logger?: Logger
76
+ maxPages?: number
77
+ }
78
+ /** Per-host docker registry credentials, keyed by host. */
79
+ export type DockerRegistryConfig = Record<string, RegistryAuth>;
80
+ /**
81
+ * A client for any OCI-compliant registry.
82
+ *
83
+ * Implements the standard distribution flow — anonymous request, bearer
84
+ * challenge, token exchange, retry — rather than one vendor's bespoke API.
85
+ * That is what makes GHCR, Quay, GCR, Artifact Registry and self-hosted
86
+ * registries work without a per-vendor branch.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const client = new OciClient({ registries: config.registries?.docker })
91
+ * const tags = await client.listTags(parseImageRef('ghcr.io/org/app:1.0.0'))
92
+ * ```
93
+ */
94
+ export declare class OciClient {
95
+ constructor(options?: OciClientOptions);
96
+ listTags(ref: ImageRef): Promise<string[]>;
97
+ resolveDigest(ref: ImageRef): Promise<string | null>;
98
+ }
@@ -0,0 +1,39 @@
1
+ import type { BuddyConfig, PackageMetadata, PackageUpdate } from '../types';
2
+ import type { Logger } from '../utils/logger';
3
+ export declare interface BunOutdatedResult {
4
+ name: string
5
+ current: string
6
+ update: string
7
+ latest: string
8
+ workspace?: string
9
+ file?: string
10
+ }
11
+ export declare class RegistryClient {
12
+ readonly /** Maximum concurrent registry requests. */
13
+ private concurrency?: number;
14
+ constructor(projectPath: string, logger: Logger, config?: BuddyConfig | undefined);
15
+ clearCache(): void;
16
+ shouldRespectVersion(version: string): boolean;
17
+ getOutdatedPackages(filter?: string): Promise<PackageUpdate[]>;
18
+ getUpdatesForPackages(packageNames: string[]): Promise<PackageUpdate[]>;
19
+ getUpdatesWithPattern(pattern: string): Promise<PackageUpdate[]>;
20
+ getPackageMetadata(packageName: string): Promise<PackageMetadata | undefined>;
21
+ packageExists(packageName: string): Promise<boolean>;
22
+ getLatestVersion(packageName: string): Promise<string | null>;
23
+ getUpdatesForWorkspace(workspaceName: string): Promise<PackageUpdate[]>;
24
+ searchPackages(query: string, limit?: number): Promise<Array<{
25
+ name: string
26
+ version: string
27
+ description?: string
28
+ keywords?: string[]
29
+ }>>;
30
+ getComposerOutdatedPackages(): Promise<PackageUpdate[]>;
31
+ getComposerPackageMetadata(packageName: string): Promise<PackageMetadata | undefined>;
32
+ composerPackageExists(packageName: string): Promise<boolean>;
33
+ getComposerLatestVersion(packageName: string): Promise<string | null>;
34
+ getPackageVersionReleaseDate(packageName: string, version: string): Promise<Date | null>;
35
+ getGitHubActionReleaseDate(actionName: string, version: string): Promise<Date | null>;
36
+ getComposerPackageReleaseDate(packageName: string, version: string): Promise<Date | null>;
37
+ getDockerImageReleaseDate(imageName: string, version: string): Promise<Date | null>;
38
+ meetsMinimumReleaseAge(packageName: string, version: string, dependencyType?: string): Promise<boolean>;
39
+ }
@@ -0,0 +1,51 @@
1
+ import type { GitProvider } from '../git/provider';
2
+ import type { Logger } from '../utils/logger';
3
+ import type { ReportMetrics } from './metrics';
4
+ /**
5
+ * Parse a snapshot history.
6
+ *
7
+ * JSONL because it is append-friendly and a corrupt line loses one snapshot
8
+ * rather than the whole history. Unparseable lines are skipped for the same
9
+ * reason — a report should still render when one old entry is damaged.
10
+ *
11
+ * @param content - File content, absent when the file does not exist
12
+ * @returns Snapshots in file order, oldest first
13
+ */
14
+ export declare function parseHistory(content: string | null): ReportMetrics[];
15
+ /**
16
+ * Append a snapshot, trimming the history to its limit.
17
+ *
18
+ * @param existing - Snapshots already stored
19
+ * @param snapshot - The new snapshot
20
+ * @returns The file content to write
21
+ */
22
+ export declare function appendHistory(existing: ReportMetrics[], snapshot: ReportMetrics): string;
23
+ /**
24
+ * Find the snapshot to compare a new one against.
25
+ *
26
+ * Only snapshots covering the same period are comparable: a 7-day count next
27
+ * to a 30-day one is not a delta, it is a category error that would show as a
28
+ * dramatic improvement or regression that never happened.
29
+ *
30
+ * @param history - Stored snapshots
31
+ * @param period - The period being reported
32
+ * @returns The most recent comparable snapshot, or null
33
+ */
34
+ export declare function findPrevious(history: ReportMetrics[], period: string): ReportMetrics | null;
35
+ /**
36
+ * Read the stored history from the repository.
37
+ *
38
+ * Read from the base branch: the history is trusted input to the deltas a
39
+ * report publishes, and reading it from a feature branch would let that branch
40
+ * decide what the repository's dependency trend looks like.
41
+ *
42
+ * @param provider - Provider to read through
43
+ * @param baseRef - Branch to read from
44
+ * @param logger - Where to report failures
45
+ * @returns Stored snapshots, empty when there are none
46
+ */
47
+ export declare function loadHistory(provider: Pick<GitProvider, 'getFileContent'>, baseRef: string, logger?: Logger): Promise<ReportMetrics[]>;
48
+ /** Where report snapshots live in the repository. */
49
+ export declare const HISTORY_PATH: '.buddy/reports.jsonl';
50
+ /** How many snapshots to keep. */
51
+ export declare const HISTORY_LIMIT: 52;
@@ -0,0 +1,23 @@
1
+ export type {
2
+ ActivityMetrics,
3
+ Delta,
4
+ HealthMetrics,
5
+ MetricsInput,
6
+ ReportMetrics,
7
+ ReportPeriod,
8
+ } from './metrics';
9
+ export {
10
+ appendHistory,
11
+ findPrevious,
12
+ HISTORY_LIMIT,
13
+ HISTORY_PATH,
14
+ loadHistory,
15
+ parseHistory,
16
+ } from './history';
17
+ export {
18
+ computeDeltas,
19
+ computeMetrics,
20
+ PERIOD_DAYS,
21
+ REPORT_PERIODS,
22
+ } from './metrics';
23
+ export { REPORT_MARKER, renderReport, withNarrative } from './render';
@@ -0,0 +1,89 @@
1
+ import type { PullRequest } from '../types';
2
+ /**
3
+ * Compute a metrics snapshot.
4
+ *
5
+ * Everything here is arithmetic over data the scan already produced, so a
6
+ * report works with no AI provider and no external service. The AI narrative
7
+ * is a layer on top of these numbers, never a replacement for them — a report
8
+ * whose figures came from a language model is not a report.
9
+ *
10
+ * @param input - Scan results and pull request history
11
+ * @returns The snapshot
12
+ * @example
13
+ * ```ts
14
+ * const metrics = computeMetrics({ period: '30d', now: new Date(), pullRequests, updates, dependenciesByEcosystem })
15
+ * ```
16
+ */
17
+ export declare function computeMetrics(input: MetricsInput): ReportMetrics;
18
+ /**
19
+ * Compare a snapshot against an earlier one.
20
+ *
21
+ * Direction matters per metric and cannot be inferred: more merged pull
22
+ * requests is good, more vulnerable dependencies is not. Getting that backwards
23
+ * would produce a report that congratulates a repository for regressing.
24
+ *
25
+ * @param current - The new snapshot
26
+ * @param previous - The snapshot to compare against, absent on a first run
27
+ * @returns Deltas keyed by metric, empty when there is nothing to compare
28
+ */
29
+ export declare function computeDeltas(current: ReportMetrics, previous: ReportMetrics | null): Record<string, Delta>;
30
+ /** Every period the CLI accepts. */
31
+ export declare const REPORT_PERIODS: ReportPeriod[];
32
+ /**
33
+ * Days in each period.
34
+ * @defaultValue `{ '7d': 7, '30d': 30, '90d': 90 }`
35
+ */
36
+ export declare const PERIOD_DAYS: Record<ReportPeriod, number>;
37
+ /** Dependency counts, by state. */
38
+ export declare interface HealthMetrics {
39
+ byEcosystem: Record<string, number>
40
+ total: number
41
+ outdated: number
42
+ outdatedPercent: number
43
+ majorBehind: number
44
+ vulnerable: number
45
+ deprecated: number
46
+ drifted: number
47
+ }
48
+ /** What the bot did during the period. */
49
+ export declare interface ActivityMetrics {
50
+ opened: number
51
+ merged: number
52
+ closed: number
53
+ open: number
54
+ medianHoursToMerge: number | null
55
+ mergeRate: number
56
+ }
57
+ /** A full snapshot, comparable against an earlier one. */
58
+ export declare interface ReportMetrics {
59
+ period: ReportPeriod
60
+ generatedAt: string
61
+ health: HealthMetrics
62
+ activity: ActivityMetrics
63
+ }
64
+ /** The inputs a snapshot is computed from. */
65
+ export declare interface MetricsInput {
66
+ period: ReportPeriod
67
+ now: Date
68
+ pullRequests: PullRequest[]
69
+ branchPrefix?: string
70
+ updates: Array<{
71
+ name: string
72
+ updateType: 'major' | 'minor' | 'patch'
73
+ dependencyType: string
74
+ file: string
75
+ securityAdvisories?: unknown[]
76
+ }>
77
+ dependenciesByEcosystem: Record<string, number>
78
+ deprecated?: number
79
+ drifted?: number
80
+ }
81
+ /** A metric's movement between two snapshots. */
82
+ export declare interface Delta {
83
+ current: number
84
+ previous: number
85
+ change: number
86
+ improved: boolean
87
+ }
88
+ /** How far back a report looks. */
89
+ export type ReportPeriod = '7d' | '30d' | '90d';
@@ -0,0 +1,33 @@
1
+ import type { AiClient } from '../ai/types';
2
+ import type { Delta, ReportMetrics } from './metrics';
3
+ import type { Logger } from '../utils/logger';
4
+ /**
5
+ * Render a report from metrics alone.
6
+ *
7
+ * The deterministic baseline: no AI, no network, just the numbers and how they
8
+ * moved. This is the report — the narrative mode adds prose around it and never
9
+ * replaces it, because figures produced by a language model are not metrics.
10
+ *
11
+ * @param metrics - The current snapshot
12
+ * @param deltas - Movement since the previous snapshot
13
+ * @returns Markdown
14
+ */
15
+ export declare function renderReport(metrics: ReportMetrics, deltas?: Record<string, Delta>): string;
16
+ /**
17
+ * Add a narrative to a rendered report.
18
+ *
19
+ * The metrics are inlined into the prompt as trusted data — they are numbers
20
+ * this process computed, not content from a pull request — and the model is
21
+ * asked to interpret them, never to restate or recompute them. The tables stay
22
+ * exactly as rendered underneath.
23
+ *
24
+ * @param report - The deterministic report
25
+ * @param metrics - The snapshot behind it
26
+ * @param ai - Client, absent to leave the report as-is
27
+ * @param focus - What the narrative should emphasise
28
+ * @param logger - Where to report failures
29
+ * @returns The report, with a narrative prepended when one could be written
30
+ */
31
+ export declare function withNarrative(report: string, metrics: ReportMetrics, ai: AiClient | null, focus?: string, logger?: Logger): Promise<string>;
32
+ /** Marker identifying the report issue, so it is updated rather than duplicated. */
33
+ export declare const REPORT_MARKER: '<!-- buddy:report -->';
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Parse a unified diff into files and commentable line numbers.
3
+ *
4
+ * Written against the diff text rather than a provider's file list because the
5
+ * same parser then serves local review (`git diff`) and PR review (the API's
6
+ * patch field) without a second implementation.
7
+ *
8
+ * @param diff - Unified diff text
9
+ * @returns The changed files, each with the lines a comment may anchor to
10
+ * @example
11
+ * ```ts
12
+ * const parsed = parseUnifiedDiff(await gitDiff('main'))
13
+ * parsed.files[0].commentableLines.has(42)
14
+ * ```
15
+ */
16
+ export declare function parseUnifiedDiff(diff: string): ParsedDiff;
17
+ /**
18
+ * Render a diff for the model, dropping files it should not spend context on.
19
+ *
20
+ * Lockfiles and generated output are the bulk of a dependency PR's diff and
21
+ * carry no reviewable decisions, so excluding them is what makes reviewing a
22
+ * large update PR affordable at all.
23
+ *
24
+ * @param diff - Parsed diff
25
+ * @param options - Per-file and total size caps
26
+ * @returns Diff text to hand to the model, and the files that survived
27
+ */
28
+ export declare function renderDiffForReview(diff: ParsedDiff, options?: { maxCharsPerFile?: number, maxTotalChars?: number, include?: (path: string) => boolean }): { text: string, files: DiffFile[], omitted: string[] };
29
+ /**
30
+ * Collect a unified diff between two refs using local git.
31
+ *
32
+ * @param base - Ref to diff against
33
+ * @param head - Ref to diff, defaulting to the working tree
34
+ * @param cwd - Repository directory
35
+ * @returns Unified diff text, empty when there are no changes
36
+ */
37
+ export declare function collectGitDiff(base: string, head?: string, cwd?: string): Promise<string>;
38
+ /** One changed file in a diff. */
39
+ export declare interface DiffFile {
40
+ path: string
41
+ previousPath?: string
42
+ status: 'added' | 'modified' | 'deleted' | 'renamed'
43
+ commentableLines: Set<number>
44
+ patch: string
45
+ }
46
+ /** A parsed unified diff. */
47
+ export declare interface ParsedDiff {
48
+ files: DiffFile[]
49
+ changedLines: number
50
+ }
@@ -0,0 +1,49 @@
1
+ import type { AiClient } from '../ai/types';
2
+ import type { Logger } from '../utils/logger';
3
+ import type { ParsedDiff } from './diff';
4
+ import type { ReviewFinding, ReviewResult } from './findings';
5
+ /**
6
+ * Review a diff and return validated findings.
7
+ *
8
+ * Findings are validated against the diff's own line map rather than trusted:
9
+ * a finding on a line the diff does not touch means the model misread it, and
10
+ * relocating the comment would present a guess as a located defect.
11
+ *
12
+ * @param ai - Configured AI client
13
+ * @param options - Diff and review settings
14
+ * @returns Summary, walkthrough and anchorable findings
15
+ * @example
16
+ * ```ts
17
+ * const result = await reviewDiff(ai, { diff: await collectGitDiff('main') })
18
+ * console.log(result.findings.length)
19
+ * ```
20
+ */
21
+ export declare function reviewDiff(ai: AiClient, options: ReviewOptions): Promise<ReviewResult>;
22
+ /** Commentable lines per path, for anchor validation. */
23
+ export declare function anchorMap(diff: ParsedDiff): Map<string, Set<number>>;
24
+ /**
25
+ * Whether a path is worth reviewing by default.
26
+ *
27
+ * Lock files and build output are most of a dependency PR's diff and contain
28
+ * no reviewable decisions.
29
+ */
30
+ export declare function defaultIncludePath(path: string): boolean;
31
+ /** Paths excluded from review unless a config says otherwise. */
32
+ export declare const DEFAULT_EXCLUDED_PATHS: RegExp[];
33
+ /** Inputs to a review. */
34
+ export declare interface ReviewOptions {
35
+ diff: string
36
+ profile?: ReviewProfile
37
+ instructions?: string
38
+ seenFingerprints?: string[]
39
+ summaryOnly?: boolean
40
+ context?: string
41
+ includePath?: (path: string) => boolean
42
+ pathFilters?: string[]
43
+ pathInstructions?: Array<{ path: string, instructions: string }>
44
+ learnings?: string
45
+ analyzerFindings?: ReviewFinding[]
46
+ logger?: Logger
47
+ }
48
+ /** How thorough a review to run. */
49
+ export type ReviewProfile = 'chill' | 'assertive';
@@ -0,0 +1,102 @@
1
+ /**
2
+ * A stable identity for a finding, used to avoid re-posting it.
3
+ *
4
+ * Deliberately excludes the line number: a finding that survives an unrelated
5
+ * edit above it moves line but stays the same finding, and re-posting it on
6
+ * every push is the fastest way to make a review bot ignorable.
7
+ *
8
+ * @param finding - Finding to identify
9
+ */
10
+ export declare function fingerprint(finding: ReviewFinding): string;
11
+ /**
12
+ * Drop findings that cannot be anchored, then order them by severity.
13
+ *
14
+ * A finding on a line the diff does not touch is rejected outright rather than
15
+ * relocated: the model has misread the diff, and moving the comment somewhere
16
+ * plausible would present a guess as a located defect.
17
+ *
18
+ * @param findings - Raw findings from the model or a tool
19
+ * @param anchors - Commentable lines per path
20
+ * @returns Anchorable findings, most severe first, and the count dropped
21
+ */
22
+ export declare function validateFindings(findings: ReviewFinding[], anchors: Map<string, Set<number>>): { valid: ReviewFinding[], dropped: ReviewFinding[] };
23
+ /**
24
+ * Remove findings that duplicate one already reported.
25
+ *
26
+ * @param findings - Candidate findings
27
+ * @param seen - Fingerprints already posted on this pull request
28
+ */
29
+ export declare function dedupeFindings(findings: ReviewFinding[], seen: Set<string>): ReviewFinding[];
30
+ /** Severities in descending order, for sorting and threshold checks. */
31
+ export declare const SEVERITY_ORDER: FindingSeverity[];
32
+ /**
33
+ * JSON Schema the model's review output is validated against.
34
+ *
35
+ * Constrained rather than free-form so a finding either anchors to a real file
36
+ * and line or fails validation — a review that renders as prose is impossible
37
+ * to post as inline comments.
38
+ * @defaultValue
39
+ * ```ts
40
+ * {
41
+ * type: 'object',
42
+ * properties: {
43
+ * summary: { type: 'string', description: 'One paragraph on what this change does' },
44
+ * effort: {
45
+ * type: 'integer',
46
+ * description: 'Reviewer effort, 1 (trivial) to 5 (demanding)'
47
+ * },
48
+ * walkthrough: {
49
+ * type: 'array',
50
+ * items: {
51
+ * type: 'object',
52
+ * properties: { path: { type: 'string' }, description: { type: 'string' } },
53
+ * required: ['path', 'description'],
54
+ * additionalProperties: false
55
+ * }
56
+ * },
57
+ * findings: {
58
+ * type: 'array',
59
+ * items: {
60
+ * type: 'object',
61
+ * properties: {
62
+ * path: { type: 'string', description: 'Repository-relative path' },
63
+ * line: { type: 'integer', description: 'Line number on the new side of the diff' },
64
+ * severity: { type: 'string' },
65
+ * category: { type: 'string', description: 'Short slug, e.g. correctness or security' },
66
+ * message: { type: 'string', description: 'What is wrong and why it matters' },
67
+ * suggestion: {
68
+ * type: 'string',
69
+ * description: 'Replacement code, only when the fix is mechanical'
70
+ * }
71
+ * },
72
+ * required: ['path', 'line', 'severity', 'category', 'message'],
73
+ * additionalProperties: false
74
+ * }
75
+ * }
76
+ * },
77
+ * required: ['summary', 'effort', 'walkthrough', 'findings'],
78
+ * additionalProperties: false
79
+ * }
80
+ * ```
81
+ */
82
+ export declare const REVIEW_SCHEMA: Record<string, unknown>;
83
+ /** A single reviewable issue. */
84
+ export declare interface ReviewFinding {
85
+ path: string
86
+ line: number
87
+ severity: FindingSeverity
88
+ category: string
89
+ message: string
90
+ suggestion?: string
91
+ tool?: string
92
+ }
93
+ /** What a review produced. */
94
+ export declare interface ReviewResult {
95
+ summary: string
96
+ walkthrough: Array<{ path: string, description: string }>
97
+ findings: ReviewFinding[]
98
+ effort: number
99
+ omittedFiles: string[]
100
+ }
101
+ /** How much a finding matters, ordered from most to least severe. */
102
+ export type FindingSeverity = 'critical' | 'major' | 'minor' | 'nit';