@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,30 @@
1
+ /**
2
+ * Mask anything that looks like a credential.
3
+ *
4
+ * Applied to every log line, error message and transcript entry the AI layer
5
+ * produces — a provider error often echoes the request headers back, and those
6
+ * carry the key.
7
+ *
8
+ * @param value - Text that may contain credentials
9
+ * @returns The same text with credentials replaced
10
+ * @example
11
+ * ```ts
12
+ * redact('failed with key sk-ant-api03-abcdefghijklmnop')
13
+ * // => 'failed with key [redacted]'
14
+ * ```
15
+ */
16
+ export declare function redact(value: string): string;
17
+ /**
18
+ * Mask credentials anywhere inside an arbitrary value.
19
+ *
20
+ * @param value - Value to sanitize; objects and arrays are walked
21
+ */
22
+ export declare function redactDeep(value: unknown): unknown;
23
+ /**
24
+ * Format an unknown error for logging, with credentials masked.
25
+ *
26
+ * @param error - Thrown value
27
+ */
28
+ export declare function redactError(error: unknown): string;
29
+ /** Replacement written in place of a detected secret. */
30
+ export declare const REDACTED: '[redacted]';
@@ -0,0 +1,75 @@
1
+ /** A conversation turn. */
2
+ export declare interface AiMessage {
3
+ role: 'user' | 'assistant'
4
+ content: string
5
+ }
6
+ /** A tool the model may call. */
7
+ export declare interface AiTool {
8
+ name: string
9
+ description: string
10
+ parameters: Record<string, unknown>
11
+ }
12
+ /** A tool call the model asked for. */
13
+ export declare interface AiToolCall {
14
+ id: string
15
+ name: string
16
+ input: Record<string, unknown>
17
+ }
18
+ /** Normalized token accounting, in the shape every provider is mapped onto. */
19
+ export declare interface AiUsage {
20
+ inputTokens: number
21
+ outputTokens: number
22
+ cachedInputTokens?: number
23
+ }
24
+ /** What a completion returned. */
25
+ export declare interface AiResponse {
26
+ text: string
27
+ toolCalls: AiToolCall[]
28
+ json?: unknown
29
+ stopReason: 'end' | 'tool_use' | 'max_tokens' | 'refusal' | 'other'
30
+ usage: AiUsage
31
+ model: string
32
+ }
33
+ /** A completion request, in provider-neutral form. */
34
+ export declare interface AiCompletionRequest {
35
+ system?: string
36
+ messages: AiMessage[]
37
+ tools?: AiTool[]
38
+ maxTokens?: number
39
+ effort?: AiEffort
40
+ jsonSchema?: Record<string, unknown>
41
+ model?: string
42
+ }
43
+ /** A configured connection to one provider. */
44
+ export declare interface AiClient {
45
+ readonly provider: AiProviderName
46
+ readonly model: string
47
+ readonly tokensUsed: number
48
+ complete: (request: AiCompletionRequest) => Promise<AiResponse>
49
+ }
50
+ /** The provider-specific half of a client, before budget and retry wrapping. */
51
+ export declare interface AiProvider {
52
+ readonly name: AiProviderName
53
+ complete: (request: AiCompletionRequest, model: string) => Promise<AiResponse>
54
+ }
55
+ /** Providers buddy can talk to. */
56
+ export type AiProviderName = 'anthropic' | 'openai' | 'google' | 'openrouter' | 'openai-compatible';
57
+ /**
58
+ * How much reasoning depth to spend on a request.
59
+ *
60
+ * Mapped per provider: an effort level on Anthropic, a reasoning setting on
61
+ * providers that expose one, and ignored where the concept has no equivalent.
62
+ */
63
+ export type AiEffort = 'low' | 'medium' | 'high';
64
+ /** Raised when a run exceeds its configured token budget. */
65
+ export declare class AiBudgetExceededError extends Error {
66
+ public readonly spent: number;
67
+ public readonly budget: number;
68
+ constructor(spent: number, budget: number);
69
+ }
70
+ /** Raised when a provider rejects a request or returns an unusable response. */
71
+ export declare class AiProviderError extends Error {
72
+ public readonly provider: AiProviderName;
73
+ public readonly status?: number;
74
+ constructor(message: string, provider: AiProviderName, status?: number);
75
+ }
@@ -0,0 +1,11 @@
1
+ import type { Analyzer } from '../types';
2
+ /**
3
+ * actionlint, for GitHub Actions workflows.
4
+ *
5
+ * Complements the native workflow audit rather than duplicating it: those six
6
+ * rules are security properties buddy cares about specifically (unpinned
7
+ * actions, `pull_request_target` misuse, script injection), while actionlint
8
+ * type-checks expressions, `runs-on` labels, matrix shapes and shell syntax
9
+ * inside `run:` blocks — everything that only fails once the workflow runs.
10
+ */
11
+ export declare const actionlintAnalyzer: Analyzer;
@@ -0,0 +1,57 @@
1
+ import type { FindingSeverity } from '../../review/findings';
2
+ /**
3
+ * Run an external analyzer.
4
+ *
5
+ * Arguments are passed as an array and never through a shell, so a file path
6
+ * containing shell metacharacters is an argument rather than a command. That
7
+ * matters here more than usual: the paths come from a pull request's diff,
8
+ * which is to say from whoever opened it.
9
+ *
10
+ * A non-zero exit is normal — linters exit non-zero when they find something —
11
+ * so the caller inspects the output rather than the status.
12
+ *
13
+ * @param command - Executable name
14
+ * @param args - Arguments, each passed literally
15
+ * @param cwd - Working directory
16
+ * @returns Captured output and exit status
17
+ */
18
+ export declare function runTool(command: string, args: string[], cwd: string): Promise<ToolRun>;
19
+ /**
20
+ * Map a tool's severity vocabulary onto buddy's.
21
+ *
22
+ * Everything a linter calls "style" lands on `nit`, so a formatting opinion
23
+ * cannot outrank a correctness finding in the review's ordering.
24
+ *
25
+ * @param level - The tool's own severity word
26
+ * @returns The corresponding review severity
27
+ */
28
+ export declare function mapSeverity(level: string | number | undefined): FindingSeverity;
29
+ /**
30
+ * Parse JSON a tool wrote to stdout.
31
+ *
32
+ * Tools sometimes print a banner or a deprecation notice before their JSON, so
33
+ * the parse starts at the first bracket rather than at byte zero.
34
+ *
35
+ * @param stdout - Raw tool output
36
+ * @returns The parsed value, or null when there is no usable JSON
37
+ */
38
+ export declare function parseToolJson<T>(stdout: string): T | null;
39
+ /** Normalize a tool's path back to repository-relative. */
40
+ export declare function relativize(path: string, root: string): string;
41
+ /**
42
+ * Whether a command exists on this runner.
43
+ *
44
+ * Shared by external-tool analyzers so each does not reimplement the probe.
45
+ *
46
+ * @param command - Executable name
47
+ * @returns Whether the command can be resolved on PATH
48
+ */
49
+ export declare function commandExists(command: string): Promise<boolean>;
50
+ /** How long a single analyzer invocation may take. */
51
+ export declare const TOOL_TIMEOUT_MS: unknown;
52
+ /** What running an external tool produced. */
53
+ export declare interface ToolRun {
54
+ stdout: string
55
+ stderr: string
56
+ exitCode: number
57
+ }
@@ -0,0 +1,9 @@
1
+ import type { Analyzer } from '../types';
2
+ /**
3
+ * The existing GitHub Actions workflow auditor, as an analyzer.
4
+ *
5
+ * Wrapping rather than reimplementing: the six workflow rules already exist
6
+ * and are tested, and this exposes them through the same path as every other
7
+ * analyzer so their findings land as review comments alongside the rest.
8
+ */
9
+ export declare const githubActionsAnalyzer: Analyzer;
@@ -0,0 +1,9 @@
1
+ import type { Analyzer } from '../types';
2
+ /**
3
+ * Hadolint, for Dockerfiles.
4
+ *
5
+ * Pairs with buddy's Docker base-image updates: the bot proposes the new
6
+ * tag, and this catches the pinning and layer mistakes that make that tag not
7
+ * mean what the Dockerfile thinks it means.
8
+ */
9
+ export declare const hadolintAnalyzer: Analyzer;
@@ -0,0 +1,53 @@
1
+ import type { Analyzer } from '../types';
2
+ import type { ReviewFinding } from '../../review/findings';
3
+ /**
4
+ * Convert a byte offset into a 1-based line number.
5
+ *
6
+ * Biome reports spans rather than lines, so the file has to be read to place a
7
+ * diagnostic. Returns null when the offset falls outside the file, since a
8
+ * finding on the wrong line is worse than one that was skipped — the review
9
+ * would anchor it to unrelated code.
10
+ */
11
+ export declare function offsetToLine(content: string, offset: number): number | null;
12
+ /**
13
+ * Find the linter this repository actually uses.
14
+ *
15
+ * Two signals, either of which is a deliberate choice: a config file, or a
16
+ * package script that invokes the tool. The script matters because several of
17
+ * these linters run happily with no config at all — detecting only config
18
+ * files would miss a repository whose `lint` script is the whole setup.
19
+ *
20
+ * A bare dependency is *not* a signal: a linter in `devDependencies` that
21
+ * nothing invokes is a transitive artifact rather than a decision.
22
+ *
23
+ * @param root - Repository root
24
+ * @returns The matching spec, or null when no linter is configured
25
+ */
26
+ export declare function detectLinter(root: string): Promise<LinterSpec | null>;
27
+ /**
28
+ * Linters buddy can drive, in detection order.
29
+ *
30
+ * Detection is by config file rather than by dependency, because a repository
31
+ * with a linter in `devDependencies` but no config is one where the linter is
32
+ * a transitive artifact rather than a decision.
33
+ */
34
+ export declare const LINTER_SPECS: LinterSpec[];
35
+ /**
36
+ * The repository's own JS/TS linter.
37
+ *
38
+ * Runs whatever the repository already configured rather than imposing a
39
+ * ruleset: a review that reports violations of rules the project does not hold
40
+ * is noise, and one that reports violations of rules it does hold is exactly
41
+ * the feedback a maintainer would have given.
42
+ *
43
+ * The linter is invoked through the package runner, so a project-local install
44
+ * is used without requiring a global one.
45
+ */
46
+ export declare const linterAnalyzer: Analyzer;
47
+ /** A JS/TS linter buddy knows how to drive. */
48
+ declare interface LinterSpec {
49
+ name: string
50
+ configFiles: string[]
51
+ args: string[]
52
+ parse: (stdout: string, root: string) => Promise<ReviewFinding[]>
53
+ }
@@ -0,0 +1,11 @@
1
+ import type { Analyzer } from '../types';
2
+ /**
3
+ * markdownlint, for documentation.
4
+ *
5
+ * Filtered hard on purpose. Most of markdownlint's rules are formatting
6
+ * conventions a formatter should fix silently, and a review that spends its
7
+ * first ten comments on list indentation is one nobody reads to the end of.
8
+ * What survives is the set that means a reader hits something broken: a dead
9
+ * link fragment, an image with no alt text, reversed link syntax.
10
+ */
11
+ export declare const markdownlintAnalyzer: Analyzer;
@@ -0,0 +1,23 @@
1
+ import type { Analyzer } from '../types';
2
+ /**
3
+ * Credential shapes with low false-positive rates.
4
+ *
5
+ * Deliberately narrow: a secret scanner that cries wolf gets muted, and a
6
+ * muted scanner catches nothing. Broad entropy heuristics are left out for
7
+ * that reason — these are patterns that are almost never anything else.
8
+ */
9
+ export declare const SECRET_RULES: SecretRule[];
10
+ /**
11
+ * Native secret scanner.
12
+ *
13
+ * Runs with no external tool and no API key, which makes it the one analyzer
14
+ * guaranteed to be available — a committed credential is the finding least
15
+ * affordable to miss because a toolchain was absent.
16
+ */
17
+ export declare const secretsAnalyzer: Analyzer;
18
+ /** A credential shape worth blocking a commit over. */
19
+ declare interface SecretRule {
20
+ id: string
21
+ pattern: RegExp
22
+ description: string
23
+ }
@@ -0,0 +1,8 @@
1
+ import type { Analyzer } from '../types';
2
+ /**
3
+ * ShellCheck, for shell scripts.
4
+ *
5
+ * Shell is where a subtly wrong quote becomes a command injection, and it is
6
+ * the one language in most repositories with no compiler and usually no tests.
7
+ */
8
+ export declare const shellcheckAnalyzer: Analyzer;
@@ -0,0 +1,13 @@
1
+ import type { Analyzer } from '../types';
2
+ /**
3
+ * YAML and JSON syntax validation.
4
+ *
5
+ * Native, so it needs no tool on the runner and always runs. It is also the
6
+ * cheapest finding buddy can produce that a human would certainly have
7
+ * caught eventually: a malformed workflow or lockfile does not fail at review
8
+ * time, it fails on the next run in a job whose logs nobody is watching.
9
+ *
10
+ * Only genuine parse failures are reported. Schema opinions belong to the
11
+ * tools that own each format.
12
+ */
13
+ export declare const syntaxAnalyzer: Analyzer;
@@ -0,0 +1,38 @@
1
+ import { commandExists } from './analyzers/external';
2
+ import type { Analyzer, AnalysisResult } from './types';
3
+ import type { Logger } from '../utils/logger';
4
+ /**
5
+ * Run every analyzer whose file types the change touches.
6
+ *
7
+ * Selection is by changed file rather than by repository content, so a change
8
+ * that touches no workflows never pays for the workflow auditor.
9
+ *
10
+ * @param options - Files, root and analyzer configuration
11
+ * @returns Findings, plus which analyzers ran and which were skipped
12
+ * @example
13
+ * ```ts
14
+ * const result = await runAnalyzers({ files: ['src/app.ts'], root: process.cwd() })
15
+ * console.log(result.findings.length, result.skipped)
16
+ * ```
17
+ */
18
+ export declare function runAnalyzers(options: AnalysisOptions): Promise<AnalysisResult>;
19
+ /**
20
+ * Analyzers registered by default, most consequential first.
21
+ *
22
+ * Native analyzers lead because they always run; the external ones follow and
23
+ * report themselves as skipped when their tool is absent, so a thin runner
24
+ * degrades coverage with a note rather than silently reading as clean.
25
+ */
26
+ export declare const BUILTIN_ANALYZERS: Analyzer[];
27
+ /** Options for an analysis pass. */
28
+ export declare interface AnalysisOptions {
29
+ files: string[]
30
+ root: string
31
+ analyzers?: Analyzer[]
32
+ enabled?: Record<string, boolean>
33
+ logger?: Logger
34
+ }
35
+ // Re-exported from its home beside the other external-tool helpers, so an
36
+ // analyzer can probe for its binary without importing the engine that
37
+ // registers it — which would be a cycle.
38
+ export { commandExists };
@@ -0,0 +1,13 @@
1
+ export type { ToolRun } from './analyzers/external';
2
+ export type { AnalysisOptions } from './engine';
3
+ export type { Analyzer, AnalysisResult } from './types';
4
+ export { actionlintAnalyzer } from './analyzers/actionlint';
5
+ export { mapSeverity, parseToolJson, relativize, runTool, TOOL_TIMEOUT_MS } from './analyzers/external';
6
+ export { githubActionsAnalyzer } from './analyzers/github-actions';
7
+ export { hadolintAnalyzer } from './analyzers/hadolint';
8
+ export { detectLinter, LINTER_SPECS, linterAnalyzer, offsetToLine } from './analyzers/linter';
9
+ export { markdownlintAnalyzer } from './analyzers/markdownlint';
10
+ export { SECRET_RULES, secretsAnalyzer } from './analyzers/secrets';
11
+ export { shellcheckAnalyzer } from './analyzers/shellcheck';
12
+ export { syntaxAnalyzer } from './analyzers/syntax';
13
+ export { BUILTIN_ANALYZERS, commandExists, runAnalyzers } from './engine';
@@ -0,0 +1,14 @@
1
+ import type { ReviewFinding } from '../review/findings';
2
+ /** A source of findings over a set of files. */
3
+ export declare interface Analyzer {
4
+ name: string
5
+ filePatterns: string[]
6
+ available: (root: string) => Promise<boolean>
7
+ run: (files: string[], root: string) => Promise<ReviewFinding[]>
8
+ }
9
+ /** What an analysis pass produced. */
10
+ export declare interface AnalysisResult {
11
+ findings: ReviewFinding[]
12
+ ran: Array<{ name: string, findings: number }>
13
+ skipped: Array<{ name: string, reason: string }>
14
+ }
@@ -0,0 +1,17 @@
1
+ import type { BuddyConfig, Issue, PackageUpdate, UpdateScanResult } from './types';
2
+ import type { GitProvider } from './git/provider';
3
+ export declare class Buddy {
4
+ constructor(config: BuddyConfig, projectPath?: string);
5
+ scanForUpdates(): Promise<UpdateScanResult>;
6
+ createPullRequests(scanResult: UpdateScanResult): Promise<void>;
7
+ generateAllFileUpdates(updates: PackageUpdate[]): Promise<Array<{ path: string, content: string, type: 'update' }>>;
8
+ run(): Promise<UpdateScanResult>;
9
+ checkPackages(packageNames: string[]): Promise<PackageUpdate[]>;
10
+ checkPackagesWithPattern(pattern: string): Promise<PackageUpdate[]>;
11
+ mergeEligiblePullRequests(dryRun?: boolean): Promise<number[]>;
12
+ getConfig(): BuddyConfig;
13
+ getProjectPath(): string;
14
+ checkAndCloseObsoletePRs(gitProvider: GitProvider, dryRun?: boolean): Promise<void>;
15
+ checkAndCloseSatisfiedPRs(gitProvider: GitProvider, dryRun?: boolean): Promise<void>;
16
+ createOrUpdateDashboard(): Promise<Issue>;
17
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Classify a CI failure from its log.
3
+ *
4
+ * Classification runs before any model call so the failures with a known
5
+ * mechanical fix — a stale lock file, a network blip — never spend tokens at
6
+ * all. That is also what lets fix-ci deliver value with no AI configured.
7
+ *
8
+ * @param log - Captured job log
9
+ * @returns The failure kind, whether it is mechanically fixable, and evidence
10
+ * @example
11
+ * ```ts
12
+ * const failure = classifyFailure(log)
13
+ * if (failure.mechanical)
14
+ * await regenerateLockfile()
15
+ * ```
16
+ */
17
+ export declare function classifyFailure(log: string): ClassifiedFailure;
18
+ /**
19
+ * Pull the lines most likely to explain a failure.
20
+ *
21
+ * Logs are mostly setup noise, so an unclassified failure still hands the
22
+ * model the error lines rather than tens of thousands of tokens of output.
23
+ *
24
+ * @param lines - Log lines
25
+ * @param limit - Maximum lines to return
26
+ */
27
+ export declare function extractErrorLines(lines: string[], limit?: number): string[];
28
+ /** A short human-readable description of a classified failure. */
29
+ export declare function describeFailure(failure: ClassifiedFailure): string;
30
+ /** A classified failure with the evidence behind it. */
31
+ export declare interface ClassifiedFailure {
32
+ kind: FailureKind
33
+ mechanical: boolean
34
+ evidence: string[]
35
+ }
36
+ /** What kind of failure a CI log describes. */
37
+ export type FailureKind = | 'lockfile-drift'
38
+ /** Network, rate limit or runner flake; worth one retry */
39
+ | 'flake'
40
+ /** Type or compile error in the changed code */
41
+ | 'type-error'
42
+ /** A test assertion failed */
43
+ | 'test-failure'
44
+ /** Lint or format violation */
45
+ | 'lint'
46
+ /** Dependency could not be resolved or installed */
47
+ | 'install'
48
+ /** Nothing recognisable */
49
+ | 'unknown';
@@ -0,0 +1,42 @@
1
+ import type { AiClient } from '../ai/types';
2
+ import type { ClassifiedFailure } from './classify';
3
+ import type { Logger } from '../utils/logger';
4
+ /**
5
+ * Diagnose a failing CI run and repair it when the fix is clear.
6
+ *
7
+ * Ordered cheapest-first: a failure that also happens on the base branch is
8
+ * not this change's to fix, a known-mechanical failure is fixed without a
9
+ * model, and only what remains reaches the agent. This is also why fix-ci is
10
+ * useful with no AI configured at all.
11
+ *
12
+ * @param options - Log, repository context and repair hooks
13
+ * @returns What was done and a report ready to post
14
+ * @example
15
+ * ```ts
16
+ * const outcome = await attemptFix({ log, workspace, baseBranch: 'main' })
17
+ * await provider.createComment(pr, outcome.report)
18
+ * ```
19
+ */
20
+ export declare function attemptFix(options: FixOptions): Promise<FixOutcome>;
21
+ /** Render a failure and its outcome as a comment body. */
22
+ declare function report(failure: ClassifiedFailure, conclusion: string): string;
23
+ /** What a fix attempt concluded. */
24
+ export declare interface FixOutcome {
25
+ failure: ClassifiedFailure
26
+ action: 'mechanical-fix' | 'retry' | 'agent-fix' | 'reported' | 'skipped'
27
+ fixed: boolean
28
+ report: string
29
+ }
30
+ /** Inputs to a fix attempt. */
31
+ export declare interface FixOptions {
32
+ log: string
33
+ failsOnBase?: boolean
34
+ workspace: string
35
+ branch?: string
36
+ baseBranch: string
37
+ priorAttempts?: number
38
+ maxAttempts?: number
39
+ ai?: AiClient | null
40
+ regenerateLockfile?: () => Promise<boolean>
41
+ logger?: Logger
42
+ }
@@ -0,0 +1,8 @@
1
+ export type { ClassifiedFailure, FailureKind } from './classify';
2
+ export type { FixOptions, FixOutcome } from './fix';
3
+ export {
4
+ classifyFailure,
5
+ describeFailure,
6
+ extractErrorLines,
7
+ } from './classify';
8
+ export { attemptFix } from './fix';
@@ -0,0 +1,49 @@
1
+ import type { Logger } from '../utils/logger';
2
+ import type { ParsedCommand } from './parser';
3
+ /**
4
+ * Decide whether a command may run, without running it.
5
+ *
6
+ * Separated from execution so the permission rule is testable on its own and
7
+ * cannot be bypassed by a handler that forgets to check.
8
+ *
9
+ * @param context - Command, actor and target
10
+ * @returns `null` when allowed, or the refusal reason
11
+ */
12
+ export declare function checkPermission(context: CommandContext): string | null;
13
+ /**
14
+ * Route a command to its handler.
15
+ *
16
+ * @param context - Command, actor and target
17
+ * @param handlers - Handlers by canonical command name
18
+ * @returns The outcome, including a refusal when permission was denied
19
+ * @example
20
+ * ```ts
21
+ * const outcome = await dispatchCommand(context, { review: runReview })
22
+ * ```
23
+ */
24
+ export declare function dispatchCommand(context: CommandContext, handlers: Record<string, CommandHandler>): Promise<CommandOutcome>;
25
+ /** Text for `@buddy help`. */
26
+ export declare const HELP_TEXT: string;
27
+ /** Who triggered a command and what they may do. */
28
+ export declare interface CommandActor {
29
+ login: string
30
+ canWrite: boolean
31
+ isBot: boolean
32
+ }
33
+ /** Everything a handler needs to act. */
34
+ export declare interface CommandContext {
35
+ command: ParsedCommand
36
+ actor: CommandActor
37
+ number: number
38
+ isPullRequest: boolean
39
+ commentId?: number
40
+ logger: Logger
41
+ }
42
+ /** What a handler produced. */
43
+ export declare interface CommandOutcome {
44
+ handled: boolean
45
+ reply?: string
46
+ refusal?: string
47
+ }
48
+ /** A command implementation. */
49
+ export type CommandHandler = (context: CommandContext) => Promise<CommandOutcome>;
@@ -0,0 +1,23 @@
1
+ import type { BuddyConfig } from '../types';
2
+ import type { CommandContext, CommandHandler } from './dispatcher';
3
+ import type { GitProvider } from '../git/provider';
4
+ /**
5
+ * Build the built-in command handlers.
6
+ *
7
+ * Handlers are thin: each routes to machinery that already exists and is
8
+ * tested on its own, so the command layer stays a dispatch concern rather than
9
+ * a second implementation of every feature.
10
+ *
11
+ * @param deps - Configuration, provider and the operations to route to
12
+ * @returns Handlers keyed by canonical command name
13
+ */
14
+ export declare function createHandlers(deps: HandlerDeps): Record<string, CommandHandler>;
15
+ /** Everything the built-in handlers need to act. */
16
+ export declare interface HandlerDeps {
17
+ config: BuddyConfig
18
+ provider: GitProvider
19
+ review: (prNumber: number, options: { full?: boolean, summaryOnly?: boolean }) => Promise<string>
20
+ rebase: (prNumber: number) => Promise<string>
21
+ merge: () => Promise<number[]>
22
+ remember: (text: string, context: CommandContext) => Promise<string>
23
+ }
@@ -0,0 +1,22 @@
1
+ export type {
2
+ CommandActor,
3
+ CommandContext,
4
+ CommandHandler,
5
+ CommandOutcome,
6
+ } from './dispatcher';
7
+ export type { HandlerDeps } from './handlers';
8
+ export type { ParsedCommand } from './parser';
9
+ export {
10
+ checkPermission,
11
+ dispatchCommand,
12
+ HELP_TEXT,
13
+ } from './dispatcher';
14
+ export { createHandlers } from './handlers';
15
+ export {
16
+ COMMAND_ALIASES,
17
+ isReadOnlyCommand,
18
+ mentionsBot,
19
+ parseCommand,
20
+ READ_ONLY_COMMANDS,
21
+ stripNonCommandContext,
22
+ } from './parser';