@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.
- package/CHANGELOG.md +1633 -0
- package/LICENSE.md +21 -0
- package/README.md +1087 -0
- package/bin/cli.ts +3401 -0
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +188 -0
- package/dist/chunk-0j7z87kh.js +3 -0
- package/dist/chunk-0r8zt3d7.js +2 -0
- package/dist/chunk-16yqbccr.js +3 -0
- package/dist/chunk-1a53wj0h.js +1 -0
- package/dist/chunk-1c1gznm9.js +3 -0
- package/dist/chunk-1h3ey7k5.js +3 -0
- package/dist/chunk-1stt2whn.js +62 -0
- package/dist/chunk-1wjnd24b.js +24 -0
- package/dist/chunk-1xe07hzm.js +2 -0
- package/dist/chunk-2bp7tqca.js +2 -0
- package/dist/chunk-2dbkpfy9.js +2 -0
- package/dist/chunk-3q6czqs4.js +6 -0
- package/dist/chunk-3zdcekfj.js +5 -0
- package/dist/chunk-49ey79p0.js +5 -0
- package/dist/chunk-4c9m61yd.js +5 -0
- package/dist/chunk-4efbxdjr.js +4 -0
- package/dist/chunk-4f7panqj.js +21 -0
- package/dist/chunk-4hd3rre0.js +2 -0
- package/dist/chunk-4xsq18p3.js +9 -0
- package/dist/chunk-52x8mvh4.js +15 -0
- package/dist/chunk-54sc18p8.js +2 -0
- package/dist/chunk-56q4pwb5.js +3 -0
- package/dist/chunk-5c3qf34r.js +2 -0
- package/dist/chunk-5k40mwd4.js +4 -0
- package/dist/chunk-5kt03hx5.js +2 -0
- package/dist/chunk-63ept76v.js +2 -0
- package/dist/chunk-65b3vq52.js +2 -0
- package/dist/chunk-6d9hmjt8.js +3 -0
- package/dist/chunk-6g1y9yqh.js +3 -0
- package/dist/chunk-6k653r8w.js +2 -0
- package/dist/chunk-6md7qf2g.js +4 -0
- package/dist/chunk-6patq6bw.js +2 -0
- package/dist/chunk-6sgh49z1.js +2 -0
- package/dist/chunk-74pxb991.js +7 -0
- package/dist/chunk-7mgec8kb.js +7 -0
- package/dist/chunk-7tfrww3v.js +2 -0
- package/dist/chunk-7xk28xrv.js +2 -0
- package/dist/chunk-82dv4p13.js +2 -0
- package/dist/chunk-8661pvb8.js +3 -0
- package/dist/chunk-887s0w81.js +2 -0
- package/dist/chunk-8rc6042h.js +4 -0
- package/dist/chunk-9750tenz.js +3 -0
- package/dist/chunk-978wtejw.js +44 -0
- package/dist/chunk-9eqpaxfz.js +2 -0
- package/dist/chunk-9h04nskh.js +8 -0
- package/dist/chunk-9p1xkmjy.js +2 -0
- package/dist/chunk-agdesgzv.js +2 -0
- package/dist/chunk-akffynkc.js +3 -0
- package/dist/chunk-ar01x04a.js +2 -0
- package/dist/chunk-ay43f085.js +2 -0
- package/dist/chunk-bk9bqd5j.js +2 -0
- package/dist/chunk-bm8d40j0.js +69 -0
- package/dist/chunk-bxfc4g2x.js +73 -0
- package/dist/chunk-c3fczawt.js +2 -0
- package/dist/chunk-c9r9nd4t.js +1 -0
- package/dist/chunk-ctsz0ynx.js +3 -0
- package/dist/chunk-czremqk7.js +2 -0
- package/dist/chunk-da3wbh04.js +2 -0
- package/dist/chunk-dat582cg.js +2 -0
- package/dist/chunk-dfesffnr.js +3 -0
- package/dist/chunk-djntbp7a.js +105 -0
- package/dist/chunk-eagjp0dh.js +3 -0
- package/dist/chunk-eht72nnj.js +2 -0
- package/dist/chunk-f4nv5x3z.js +2 -0
- package/dist/chunk-fdfk918n.js +2 -0
- package/dist/chunk-fdj0tewy.js +20 -0
- package/dist/chunk-fm8ckj9b.js +2 -0
- package/dist/chunk-fqj7e6xa.js +2 -0
- package/dist/chunk-frm8zz31.js +2 -0
- package/dist/chunk-fvpr07dn.js +16 -0
- package/dist/chunk-g0nv8psv.js +2 -0
- package/dist/chunk-g0w8n555.js +19 -0
- package/dist/chunk-gkmvxjbe.js +2 -0
- package/dist/chunk-gngwjf70.js +7 -0
- package/dist/chunk-h7hs95wn.js +5 -0
- package/dist/chunk-hfvezfxh.js +3 -0
- package/dist/chunk-hw70wbzg.js +3 -0
- package/dist/chunk-j8asz4hb.js +15 -0
- package/dist/chunk-k62w2v03.js +2 -0
- package/dist/chunk-mcrfxphm.js +5 -0
- package/dist/chunk-mh3x7j6h.js +2 -0
- package/dist/chunk-naq32yx3.js +86 -0
- package/dist/chunk-nsmcjkas.js +2 -0
- package/dist/chunk-p1xm1jvz.js +2 -0
- package/dist/chunk-p3wsm8kz.js +2 -0
- package/dist/chunk-p4zwy518.js +4 -0
- package/dist/chunk-p7zgy37f.js +2 -0
- package/dist/chunk-ph1b3vbp.js +315 -0
- package/dist/chunk-pkjm2r0a.js +2 -0
- package/dist/chunk-pkkwb0n0.js +4 -0
- package/dist/chunk-pnpx1kqn.js +6 -0
- package/dist/chunk-q9n79dd3.js +3 -0
- package/dist/chunk-qpz9k66h.js +2 -0
- package/dist/chunk-qvn1rtgp.js +2 -0
- package/dist/chunk-qyf90zz3.js +2 -0
- package/dist/chunk-r06ce5g6.js +2 -0
- package/dist/chunk-r2sbprdb.js +49 -0
- package/dist/chunk-r3zyw8x0.js +3 -0
- package/dist/chunk-rb1fh9vd.js +1 -0
- package/dist/chunk-rqdep14r.js +2 -0
- package/dist/chunk-s1km8cyq.js +2 -0
- package/dist/chunk-s4ms8zag.js +2 -0
- package/dist/chunk-sp818c27.js +9 -0
- package/dist/chunk-tb5y0350.js +3 -0
- package/dist/chunk-thaxgm5p.js +2 -0
- package/dist/chunk-tn8prpny.js +503 -0
- package/dist/chunk-ts35hc5t.js +3 -0
- package/dist/chunk-tzs22es2.js +3 -0
- package/dist/chunk-vagxqhef.js +13 -0
- package/dist/chunk-vh504tcv.js +6 -0
- package/dist/chunk-vkctfqpm.js +3 -0
- package/dist/chunk-vyapg8ca.js +186 -0
- package/dist/chunk-wdwvt7gb.js +43 -0
- package/dist/chunk-wtjhehz9.js +4 -0
- package/dist/chunk-x0ya2r4r.js +3 -0
- package/dist/chunk-x3kragh9.js +12 -0
- package/dist/chunk-x9ctz1qc.js +1 -0
- package/dist/chunk-xakpdqaq.js +3 -0
- package/dist/chunk-xqx460y2.js +3 -0
- package/dist/chunk-xvptf9jy.js +3 -0
- package/dist/chunk-yk23nc4t.js +2 -0
- package/dist/chunk-yncea6ty.js +2 -0
- package/dist/chunk-yq0gxtzv.js +2 -0
- package/dist/chunk-yqhs08ky.js +2 -0
- package/dist/chunk-zb62jhwm.js +31 -0
- package/dist/chunk-zs3jaj0g.js +1023 -0
- package/dist/chunk-zve5d96e.js +2 -0
- package/dist/src/agent/index.d.ts +44 -0
- package/dist/src/agent/modes.d.ts +33 -0
- package/dist/src/agent/runner.d.ts +44 -0
- package/dist/src/agent/stacked.d.ts +83 -0
- package/dist/src/agent/tasks.d.ts +41 -0
- package/dist/src/agent/toolbelt.d.ts +19 -0
- package/dist/src/agent/tools/fs.d.ts +26 -0
- package/dist/src/agent/tools/shell.d.ts +32 -0
- package/dist/src/agent/types.d.ts +56 -0
- package/dist/src/ai/aliases.d.ts +62 -0
- package/dist/src/ai/client.d.ts +42 -0
- package/dist/src/ai/index.d.ts +35 -0
- package/dist/src/ai/learnings.d.ts +78 -0
- package/dist/src/ai/providers/anthropic.d.ts +12 -0
- package/dist/src/ai/providers/google.d.ts +12 -0
- package/dist/src/ai/providers/openai.d.ts +15 -0
- package/dist/src/ai/redact.d.ts +30 -0
- package/dist/src/ai/types.d.ts +75 -0
- package/dist/src/analysis/analyzers/actionlint.d.ts +11 -0
- package/dist/src/analysis/analyzers/external.d.ts +57 -0
- package/dist/src/analysis/analyzers/github-actions.d.ts +9 -0
- package/dist/src/analysis/analyzers/hadolint.d.ts +9 -0
- package/dist/src/analysis/analyzers/linter.d.ts +53 -0
- package/dist/src/analysis/analyzers/markdownlint.d.ts +11 -0
- package/dist/src/analysis/analyzers/secrets.d.ts +23 -0
- package/dist/src/analysis/analyzers/shellcheck.d.ts +8 -0
- package/dist/src/analysis/analyzers/syntax.d.ts +13 -0
- package/dist/src/analysis/engine.d.ts +38 -0
- package/dist/src/analysis/index.d.ts +13 -0
- package/dist/src/analysis/types.d.ts +14 -0
- package/dist/src/buddy.d.ts +17 -0
- package/dist/src/ci/classify.d.ts +49 -0
- package/dist/src/ci/fix.d.ts +42 -0
- package/dist/src/ci/index.d.ts +8 -0
- package/dist/src/commands/dispatcher.d.ts +49 -0
- package/dist/src/commands/handlers.d.ts +23 -0
- package/dist/src/commands/index.d.ts +22 -0
- package/dist/src/commands/parser.d.ts +71 -0
- package/dist/src/config-validation.d.ts +38 -0
- package/dist/src/config.d.ts +22 -0
- package/dist/src/dashboard/dashboard-generator.d.ts +10 -0
- package/dist/src/doctor.d.ts +44 -0
- package/dist/src/ecosystems/go.d.ts +10 -0
- package/dist/src/ecosystems/index.d.ts +60 -0
- package/dist/src/ecosystems/pep440.d.ts +57 -0
- package/dist/src/ecosystems/python.d.ts +12 -0
- package/dist/src/ecosystems/ruby.d.ts +9 -0
- package/dist/src/ecosystems/rust.d.ts +8 -0
- package/dist/src/ecosystems/scan.d.ts +49 -0
- package/dist/src/ecosystems/shared.d.ts +45 -0
- package/dist/src/ecosystems/types.d.ts +58 -0
- package/dist/src/events/bus.d.ts +41 -0
- package/dist/src/events/index.d.ts +11 -0
- package/dist/src/events/sinks.d.ts +33 -0
- package/dist/src/gates/ai-checks.d.ts +77 -0
- package/dist/src/gates/checks.d.ts +84 -0
- package/dist/src/gates/index.d.ts +17 -0
- package/dist/src/gates/post-merge.d.ts +56 -0
- package/dist/src/git/bitbucket-provider.d.ts +50 -0
- package/dist/src/git/github-provider.d.ts +50 -0
- package/dist/src/git/gitlab-provider.d.ts +51 -0
- package/dist/src/git/provider.d.ts +210 -0
- package/dist/src/headless/run.d.ts +78 -0
- package/dist/src/index.d.ts +243 -0
- package/dist/src/index.js +2 -0
- package/dist/src/issues/enrichment.d.ts +76 -0
- package/dist/src/issues/index.d.ts +16 -0
- package/dist/src/issues/quick-links.d.ts +55 -0
- package/dist/src/pr/auto-merge.d.ts +75 -0
- package/dist/src/pr/pr-generator.d.ts +9 -0
- package/dist/src/pr/pr-manifest.d.ts +82 -0
- package/dist/src/pr/templates.d.ts +44 -0
- package/dist/src/registry/docker-tags.d.ts +56 -0
- package/dist/src/registry/eol.d.ts +87 -0
- package/dist/src/registry/oci-client.d.ts +98 -0
- package/dist/src/registry/registry-client.d.ts +39 -0
- package/dist/src/reports/history.d.ts +51 -0
- package/dist/src/reports/index.d.ts +23 -0
- package/dist/src/reports/metrics.d.ts +89 -0
- package/dist/src/reports/render.d.ts +33 -0
- package/dist/src/review/diff.d.ts +50 -0
- package/dist/src/review/engine.d.ts +49 -0
- package/dist/src/review/findings.d.ts +102 -0
- package/dist/src/review/guidelines.d.ts +46 -0
- package/dist/src/review/index.d.ts +48 -0
- package/dist/src/review/local.d.ts +81 -0
- package/dist/src/review/marker.d.ts +34 -0
- package/dist/src/review/poster.d.ts +39 -0
- package/dist/src/review/run.d.ts +24 -0
- package/dist/src/rules/engine.d.ts +108 -0
- package/dist/src/rules/index.d.ts +9 -0
- package/dist/src/rules/renovate.d.ts +25 -0
- package/dist/src/rules/schedule.d.ts +44 -0
- package/dist/src/scanner/catalog-scan.d.ts +39 -0
- package/dist/src/scanner/package-json-extras.d.ts +101 -0
- package/dist/src/scanner/package-scanner.d.ts +17 -0
- package/dist/src/scanner/resolution-drift.d.ts +81 -0
- package/dist/src/scanner/workspace-catalog.d.ts +53 -0
- package/dist/src/scheduler/scheduler.d.ts +27 -0
- package/dist/src/security/engine.d.ts +12 -0
- package/dist/src/security/loader.d.ts +7 -0
- package/dist/src/security/parser.d.ts +15 -0
- package/dist/src/security/rules/bash-injection.d.ts +18 -0
- package/dist/src/security/rules/dangerous-pull-request-target.d.ts +18 -0
- package/dist/src/security/rules/excessive-permissions.d.ts +14 -0
- package/dist/src/security/rules/index.d.ts +16 -0
- package/dist/src/security/rules/missing-timeout.d.ts +9 -0
- package/dist/src/security/rules/self-hosted-exposure.d.ts +13 -0
- package/dist/src/security/rules/unpinned-action.d.ts +10 -0
- package/dist/src/security/rules/walk.d.ts +13 -0
- package/dist/src/security/types.d.ts +64 -0
- package/dist/src/services/deprecated-dependencies-checker.d.ts +16 -0
- package/dist/src/services/release-notes-fetcher.d.ts +70 -0
- package/dist/src/services/security-advisories.d.ts +59 -0
- package/dist/src/setup.d.ts +162 -0
- package/dist/src/setup.js +2 -0
- package/dist/src/templates/github-actions.d.ts +31 -0
- package/dist/src/templates/gitlab-ci.d.ts +46 -0
- package/dist/src/types.d.ts +449 -0
- package/dist/src/upgrades/index.d.ts +18 -0
- package/dist/src/upgrades/migrate.d.ts +45 -0
- package/dist/src/upgrades/plan.d.ts +112 -0
- package/dist/src/upgrades/report.d.ts +22 -0
- package/dist/src/upgrades/span.d.ts +47 -0
- package/dist/src/upgrades/usage.d.ts +30 -0
- package/dist/src/upgrades/wire.d.ts +61 -0
- package/dist/src/utils/concurrency.d.ts +50 -0
- package/dist/src/utils/dependency-file-parser.d.ts +17 -0
- package/dist/src/utils/dockerfile-parser.d.ts +69 -0
- package/dist/src/utils/endpoints.d.ts +58 -0
- package/dist/src/utils/errors.d.ts +35 -0
- package/dist/src/utils/file-changes.d.ts +14 -0
- package/dist/src/utils/github-actions-parser.d.ts +21 -0
- package/dist/src/utils/globs.d.ts +22 -0
- package/dist/src/utils/helpers.d.ts +73 -0
- package/dist/src/utils/http.d.ts +81 -0
- package/dist/src/utils/lock-file.d.ts +28 -0
- package/dist/src/utils/logger.d.ts +45 -0
- package/dist/src/utils/package-paths.d.ts +6 -0
- package/dist/src/utils/pantry-parser.d.ts +30 -0
- package/dist/src/utils/repository.d.ts +41 -0
- package/dist/src/utils/security-format.d.ts +18 -0
- package/dist/src/utils/zig-parser.d.ts +18 -0
- package/dist/src/version/version-resolver.d.ts +9 -0
- package/package.json +115 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip fenced blocks, inline code and blockquotes.
|
|
3
|
+
*
|
|
4
|
+
* A mention inside a code fence is almost always someone documenting the bot
|
|
5
|
+
* rather than invoking it, and a mention inside a quote is someone replying to
|
|
6
|
+
* a message that contained one. Acting on either turns a discussion about the
|
|
7
|
+
* bot into a command from it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function stripNonCommandContext(body: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Find a command addressed to the bot in a comment body.
|
|
12
|
+
*
|
|
13
|
+
* @param body - Comment body
|
|
14
|
+
* @param mention - Mention that addresses the bot (default: `@buddy`)
|
|
15
|
+
* @returns The command, or `null` when the comment does not address the bot
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* parseCommand('@buddy review please') // => { name: 'review', args: 'please' }
|
|
19
|
+
* parseCommand('use `@buddy review`') // => null (documentation, not a command)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseCommand(body: string | null | undefined, mention?: string): ParsedCommand | null;
|
|
23
|
+
/**
|
|
24
|
+
* Whether a command may be run by someone without write access.
|
|
25
|
+
*
|
|
26
|
+
* @param name - Canonical command name
|
|
27
|
+
*/
|
|
28
|
+
export declare function isReadOnlyCommand(name: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether a comment could possibly contain a command.
|
|
31
|
+
*
|
|
32
|
+
* Used as a cheap pre-filter before a workflow checks out the repository, so
|
|
33
|
+
* ordinary conversation costs nothing.
|
|
34
|
+
*
|
|
35
|
+
* @param body - Comment body
|
|
36
|
+
* @param mention - Mention that addresses the bot
|
|
37
|
+
*/
|
|
38
|
+
export declare function mentionsBot(body: string | null | undefined, mention?: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Commands the dispatcher understands, with their aliases.
|
|
41
|
+
* @defaultValue
|
|
42
|
+
* ```ts
|
|
43
|
+
* {
|
|
44
|
+
* 'review': 'review',
|
|
45
|
+
* 'full-review': 'full-review',
|
|
46
|
+
* 'full': 'full-review',
|
|
47
|
+
* 'summary': 'summary',
|
|
48
|
+
* 'resolve': 'resolve',
|
|
49
|
+
* 'pause': 'pause',
|
|
50
|
+
* 'resume': 'resume',
|
|
51
|
+
* 'ignore': 'ignore',
|
|
52
|
+
* 'rebase': 'rebase',
|
|
53
|
+
* 'retry': 'rebase',
|
|
54
|
+
* 'merge': 'merge',
|
|
55
|
+
* 'plan': 'plan',
|
|
56
|
+
* 'fix-ci': 'fix-ci',
|
|
57
|
+
* 'fix': 'fix-ci',
|
|
58
|
+
* 'remember': 'remember',
|
|
59
|
+
* 'help': 'help'
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare const COMMAND_ALIASES: Record<string, string>;
|
|
64
|
+
/** Commands anyone may run; the rest require write access. */
|
|
65
|
+
export declare const READ_ONLY_COMMANDS: string[];
|
|
66
|
+
/** A command a maintainer addressed to the bot. */
|
|
67
|
+
export declare interface ParsedCommand {
|
|
68
|
+
name: string
|
|
69
|
+
args: string
|
|
70
|
+
raw: string
|
|
71
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BuddyConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Check a loaded configuration for values that would otherwise fail silently.
|
|
4
|
+
*
|
|
5
|
+
* The loader merges user config over defaults without any schema, so a typo
|
|
6
|
+
* like `strategy: 'minr'` or `groups: { … }` instead of an array produces a
|
|
7
|
+
* run that quietly does the wrong thing. This surfaces those as errors before
|
|
8
|
+
* any network or git work happens.
|
|
9
|
+
*
|
|
10
|
+
* @param config - Configuration to check
|
|
11
|
+
* @returns Every problem found, empty when the config is valid
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const issues = validateConfig(config)
|
|
15
|
+
* if (issues.length > 0)
|
|
16
|
+
* console.error(formatConfigIssues(issues))
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateConfig(config: BuddyConfig): ConfigIssue[];
|
|
20
|
+
/**
|
|
21
|
+
* Render validation issues as a single multi-line, human-readable block.
|
|
22
|
+
*
|
|
23
|
+
* @param issues - Issues from {@link validateConfig}
|
|
24
|
+
* @returns Formatted message, one issue per line
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatConfigIssues(issues: readonly ConfigIssue[]): string;
|
|
27
|
+
/**
|
|
28
|
+
* Validate a configuration and throw when anything is wrong.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Configuration to check
|
|
31
|
+
* @throws {ConfigurationError} Listing every issue found
|
|
32
|
+
*/
|
|
33
|
+
export declare function assertValidConfig(config: BuddyConfig): void;
|
|
34
|
+
/** A single problem found in a loaded configuration. */
|
|
35
|
+
export declare interface ConfigIssue {
|
|
36
|
+
path: string
|
|
37
|
+
message: string
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BuddyConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Load and validate the buddy configuration.
|
|
4
|
+
*
|
|
5
|
+
* The result is memoized so repeated calls within a run see one config. An
|
|
6
|
+
* explicit `configPath` bypasses the cache, since a caller naming a file is
|
|
7
|
+
* asking for that file rather than whatever was loaded earlier.
|
|
8
|
+
*
|
|
9
|
+
* @param configPath - Path to a specific config file, overriding discovery
|
|
10
|
+
* @returns The validated configuration
|
|
11
|
+
* @throws {Error} When the configuration fails validation
|
|
12
|
+
*/
|
|
13
|
+
export declare function getConfig(configPath?: string): Promise<BuddyConfig>;
|
|
14
|
+
/**
|
|
15
|
+
* Reset the memoized configuration.
|
|
16
|
+
*
|
|
17
|
+
* Only useful in tests, which load different fixtures from the same process.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resetConfigCache(): void;
|
|
20
|
+
export declare const defaultConfig: BuddyConfig;
|
|
21
|
+
// For backwards compatibility - synchronous access with default fallback
|
|
22
|
+
export declare const config: BuddyConfig;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DashboardData } from '../types';
|
|
2
|
+
export declare class DashboardGenerator {
|
|
3
|
+
generateDashboard(data: DashboardData, options?: {
|
|
4
|
+
showOpenPRs?: boolean
|
|
5
|
+
showDetectedDependencies?: boolean
|
|
6
|
+
showDeprecatedDependencies?: boolean
|
|
7
|
+
showVulnerableDependencies?: boolean
|
|
8
|
+
bodyTemplate?: string
|
|
9
|
+
}): { title: string, body: string };
|
|
10
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BuddyConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Diagnose this environment.
|
|
4
|
+
*
|
|
5
|
+
* Written to answer the question a support thread actually opens with — "why
|
|
6
|
+
* did nothing happen?" — so every failing check carries the command or the
|
|
7
|
+
* setting that fixes it. A check that reports a problem without saying what to
|
|
8
|
+
* do about it has moved the question rather than answered it.
|
|
9
|
+
*
|
|
10
|
+
* @param config - Loaded configuration
|
|
11
|
+
* @param environment - Environment overrides, defaulting to the real one
|
|
12
|
+
* @returns Every check, and whether anything is actually broken
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const report = await diagnose(config)
|
|
16
|
+
* console.log(renderDoctorReport(report))
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function diagnose(config: BuddyConfig, environment?: Partial<DoctorEnvironment>): Promise<DoctorReport>;
|
|
20
|
+
/**
|
|
21
|
+
* Render a diagnosis for a terminal.
|
|
22
|
+
*
|
|
23
|
+
* @param report - The diagnosis
|
|
24
|
+
* @returns Human-readable output
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderDoctorReport(report: DoctorReport): string;
|
|
27
|
+
/** One thing that was checked. */
|
|
28
|
+
export declare interface DoctorCheck {
|
|
29
|
+
name: string
|
|
30
|
+
status: 'ok' | 'warn' | 'fail'
|
|
31
|
+
detail: string
|
|
32
|
+
remediation?: string
|
|
33
|
+
}
|
|
34
|
+
/** Everything that was checked, grouped. */
|
|
35
|
+
export declare interface DoctorReport {
|
|
36
|
+
checks: DoctorCheck[]
|
|
37
|
+
healthy: boolean
|
|
38
|
+
}
|
|
39
|
+
/** Environment the diagnosis reads; injectable so it can be tested. */
|
|
40
|
+
export declare interface DoctorEnvironment {
|
|
41
|
+
env: Record<string, string | undefined>
|
|
42
|
+
cwd: string
|
|
43
|
+
hasCommand: (command: string) => Promise<boolean>
|
|
44
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EcosystemAdapter } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Go modules, from `go.mod`.
|
|
4
|
+
*
|
|
5
|
+
* The major-version suffix (`/v2`) is part of the module path, so a v1→v2
|
|
6
|
+
* upgrade means editing the path as well as the version — which is a source
|
|
7
|
+
* change, not a dependency bump. This adapter proposes updates within a major
|
|
8
|
+
* version and leaves the path alone.
|
|
9
|
+
*/
|
|
10
|
+
export declare const goAdapter: EcosystemAdapter;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { goAdapter } from './go';
|
|
2
|
+
import { pythonAdapter } from './python';
|
|
3
|
+
import { rubyAdapter } from './ruby';
|
|
4
|
+
import { rustAdapter } from './rust';
|
|
5
|
+
import type { EcosystemAdapter } from './types';
|
|
6
|
+
export type { Pep440Version } from './pep440';
|
|
7
|
+
export type { AdapterScanOptions, AdapterScanResult } from './scan';
|
|
8
|
+
export type { LockfileCommand } from './shared';
|
|
9
|
+
export type {
|
|
10
|
+
EcosystemAdapter,
|
|
11
|
+
EcosystemDependency,
|
|
12
|
+
EcosystemUpdate,
|
|
13
|
+
LatestOptions,
|
|
14
|
+
VersionInfo,
|
|
15
|
+
} from './types';
|
|
16
|
+
/**
|
|
17
|
+
* Find the adapter for a manifest path.
|
|
18
|
+
*
|
|
19
|
+
* @param file - Repository-relative path
|
|
20
|
+
* @param adapters - Adapters to consider
|
|
21
|
+
* @returns The adapter that claims the file, or null
|
|
22
|
+
*/
|
|
23
|
+
export declare function adapterFor(file: string, adapters?: EcosystemAdapter[]): EcosystemAdapter | null;
|
|
24
|
+
/**
|
|
25
|
+
* Look an adapter up by name.
|
|
26
|
+
*
|
|
27
|
+
* @param name - Ecosystem name
|
|
28
|
+
* @param adapters - Adapters to consider
|
|
29
|
+
*/
|
|
30
|
+
export declare function adapterNamed(name: string, adapters?: EcosystemAdapter[]): EcosystemAdapter | null;
|
|
31
|
+
/**
|
|
32
|
+
* Adapters registered by default.
|
|
33
|
+
*
|
|
34
|
+
* These are the ecosystems that reach the scanner through the adapter
|
|
35
|
+
* interface. The older ecosystems (npm, Composer, Actions, Docker, pkgx) still
|
|
36
|
+
* run through their own paths and migrate incrementally — rewriting all of
|
|
37
|
+
* them at once would mean re-testing every existing behaviour to add four new
|
|
38
|
+
* ones.
|
|
39
|
+
*/
|
|
40
|
+
export declare const BUILTIN_ADAPTERS: EcosystemAdapter[];
|
|
41
|
+
export { goAdapter } from './go';
|
|
42
|
+
export {
|
|
43
|
+
comparePep440,
|
|
44
|
+
isPep440Prerelease,
|
|
45
|
+
parsePep440,
|
|
46
|
+
pep440UpdateType,
|
|
47
|
+
splitConstraint,
|
|
48
|
+
} from './pep440';
|
|
49
|
+
export { pythonAdapter } from './python';
|
|
50
|
+
export { rubyAdapter } from './ruby';
|
|
51
|
+
export { rustAdapter } from './rust';
|
|
52
|
+
export { regenerateLockfiles, scanEcosystems, stripOperators } from './scan';
|
|
53
|
+
export {
|
|
54
|
+
commandAvailable,
|
|
55
|
+
compareNumeric,
|
|
56
|
+
detectFiles,
|
|
57
|
+
escapeRegex,
|
|
58
|
+
numericUpdateType,
|
|
59
|
+
regenerateWith,
|
|
60
|
+
} from './shared';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a PEP 440 version.
|
|
3
|
+
*
|
|
4
|
+
* @param version - Version string
|
|
5
|
+
* @returns The parsed version, or null when it is not PEP 440
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* parsePep440('1.2.3rc1')
|
|
9
|
+
* // { epoch: 0, release: [1, 2, 3], pre: ['rc', 1] }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function parsePep440(version: string): Pep440Version | null;
|
|
13
|
+
/**
|
|
14
|
+
* Compare two PEP 440 versions.
|
|
15
|
+
*
|
|
16
|
+
* The ordering rules that differ from semver and are easy to get wrong:
|
|
17
|
+
* a `.post` release *follows* the release it post-dates, a `.dev` release
|
|
18
|
+
* *precedes* everything with the same release number including its own
|
|
19
|
+
* pre-releases, and an epoch dominates everything else. `1.0.post1` being
|
|
20
|
+
* newer than `1.0` is the one that matters most in practice — treating it as
|
|
21
|
+
* older would keep proposing a downgrade.
|
|
22
|
+
*
|
|
23
|
+
* @param a - First version
|
|
24
|
+
* @param b - Second version
|
|
25
|
+
* @returns Negative when a precedes b, positive when it follows, 0 when equal
|
|
26
|
+
*/
|
|
27
|
+
export declare function comparePep440(a: string, b: string): number;
|
|
28
|
+
/** Whether a version is a pre-release or development build. */
|
|
29
|
+
export declare function isPep440Prerelease(version: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Classify a version change.
|
|
32
|
+
*
|
|
33
|
+
* @param from - Current version
|
|
34
|
+
* @param to - Proposed version
|
|
35
|
+
*/
|
|
36
|
+
export declare function pep440UpdateType(from: string, to: string): 'major' | 'minor' | 'patch';
|
|
37
|
+
/**
|
|
38
|
+
* Split a Python requirement into its operator and version.
|
|
39
|
+
*
|
|
40
|
+
* Operators are preserved on write so an update never quietly widens or
|
|
41
|
+
* narrows a constraint a maintainer chose — `~=1.4` staying `~=` rather than
|
|
42
|
+
* becoming `==` is the difference between a compatible-release pin and an
|
|
43
|
+
* exact one.
|
|
44
|
+
*
|
|
45
|
+
* @param constraint - Constraint such as `>=1.2,<2.0` or `~=1.4.2`
|
|
46
|
+
* @returns The leading operator and the version it applies to
|
|
47
|
+
*/
|
|
48
|
+
export declare function splitConstraint(constraint: string): { operator: string, version: string };
|
|
49
|
+
/** A PEP 440 version, broken into its ordered components. */
|
|
50
|
+
export declare interface Pep440Version {
|
|
51
|
+
epoch: number
|
|
52
|
+
release: number[]
|
|
53
|
+
pre?: [string, number]
|
|
54
|
+
post?: number
|
|
55
|
+
dev?: number
|
|
56
|
+
local?: string
|
|
57
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isPep440Prerelease } from './pep440';
|
|
2
|
+
import type { EcosystemAdapter } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Python packages, from `pyproject.toml` and `requirements*.txt`.
|
|
5
|
+
*
|
|
6
|
+
* Versions are compared with PEP 440 rather than semver: `1.0.post1` is newer
|
|
7
|
+
* than `1.0`, and treating Python versions as semver would keep proposing a
|
|
8
|
+
* downgrade for every post-release on PyPI.
|
|
9
|
+
*/
|
|
10
|
+
export declare const pythonAdapter: EcosystemAdapter;
|
|
11
|
+
/** Whether a version string is a Python pre-release. */
|
|
12
|
+
export { isPep440Prerelease };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EcosystemAdapter } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Ruby gems, from a `Gemfile`.
|
|
4
|
+
*
|
|
5
|
+
* The pessimistic operator (`~>`) is preserved on write: it is the whole of a
|
|
6
|
+
* Gemfile's version policy, and replacing it with an exact version would turn
|
|
7
|
+
* a deliberately flexible constraint into a pin.
|
|
8
|
+
*/
|
|
9
|
+
export declare const rubyAdapter: EcosystemAdapter;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EcosystemAdapter } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Rust crates, from `Cargo.toml`.
|
|
4
|
+
*
|
|
5
|
+
* Cargo's default caret semantics match semver closely enough that the shared
|
|
6
|
+
* numeric comparator is correct here, unlike Python.
|
|
7
|
+
*/
|
|
8
|
+
export declare const rustAdapter: EcosystemAdapter;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { EcosystemAdapter } from './types';
|
|
2
|
+
import type { Logger } from '../utils/logger';
|
|
3
|
+
import type { PackageUpdate } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Scan every registered ecosystem for updates.
|
|
6
|
+
*
|
|
7
|
+
* Adapters run concurrently and independently: a registry outage in one
|
|
8
|
+
* ecosystem must not lose the updates another already found, which is why each
|
|
9
|
+
* failure is logged and skipped rather than raised.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Root directory and adapter configuration
|
|
12
|
+
* @returns Updates, plus the dependency inventory the report needs
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const { updates } = await scanEcosystems({ dir: process.cwd() })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function scanEcosystems(options: AdapterScanOptions): Promise<AdapterScanResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Strip constraint operators to get a comparable version.
|
|
21
|
+
*
|
|
22
|
+
* A constraint is not a version and cannot be compared against one. Taking the
|
|
23
|
+
* first version in the constraint is the conventional reading of "what this
|
|
24
|
+
* repository is on" — the floor of the allowed range.
|
|
25
|
+
*/
|
|
26
|
+
export declare function stripOperators(constraint: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Run every adapter's lockfile regeneration.
|
|
29
|
+
*
|
|
30
|
+
* @param dir - Repository root
|
|
31
|
+
* @param ecosystems - Ecosystem names whose manifests changed
|
|
32
|
+
* @param adapters - Adapters to consider
|
|
33
|
+
* @returns Regenerated lockfiles and notes about any that could not be
|
|
34
|
+
*/
|
|
35
|
+
export declare function regenerateLockfiles(dir: string, ecosystems: string[], adapters?: EcosystemAdapter[]): Promise<{ regenerated: string[], notes: string[] }>;
|
|
36
|
+
/** What an adapter-driven scan found. */
|
|
37
|
+
export declare interface AdapterScanResult {
|
|
38
|
+
updates: PackageUpdate[]
|
|
39
|
+
dependenciesByEcosystem: Record<string, number>
|
|
40
|
+
manifests: Array<{ ecosystem: string, files: string[] }>
|
|
41
|
+
}
|
|
42
|
+
/** Options for an adapter-driven scan. */
|
|
43
|
+
export declare interface AdapterScanOptions {
|
|
44
|
+
dir: string
|
|
45
|
+
adapters?: EcosystemAdapter[]
|
|
46
|
+
includePrerelease?: boolean
|
|
47
|
+
ignore?: string[]
|
|
48
|
+
logger?: Logger
|
|
49
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Escape a string for use inside a regular expression. */
|
|
2
|
+
export declare function escapeRegex(value: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Find files matching an adapter's manifest patterns.
|
|
5
|
+
*
|
|
6
|
+
* Depth-limited and skipping build output, because a repository with a
|
|
7
|
+
* `node_modules` or a Rust `target/` contains thousands of manifests that
|
|
8
|
+
* belong to dependencies rather than to the project — proposing updates for
|
|
9
|
+
* those would be proposing to edit vendored code.
|
|
10
|
+
*
|
|
11
|
+
* @param dir - Directory to search
|
|
12
|
+
* @param patterns - Filenames or globs to match against the base name
|
|
13
|
+
* @param maxDepth - How deep to walk (default: 4)
|
|
14
|
+
* @returns Repository-relative paths
|
|
15
|
+
*/
|
|
16
|
+
export declare function detectFiles(dir: string, patterns: string[], maxDepth?: number): Promise<string[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Regenerate whichever lockfiles are present and whose tool is installed.
|
|
19
|
+
*
|
|
20
|
+
* Best-effort by design: a runner without `cargo` should still produce a pull
|
|
21
|
+
* request, with a note saying the lockfile needs regenerating. Producing no
|
|
22
|
+
* pull request at all because a toolchain is missing would hide the update
|
|
23
|
+
* entirely, which is strictly worse than an incomplete one that says so.
|
|
24
|
+
*
|
|
25
|
+
* @param dir - Repository root
|
|
26
|
+
* @param candidates - Lockfiles to try, in order
|
|
27
|
+
* @returns Which lockfiles were regenerated, and a note about any that were not
|
|
28
|
+
*/
|
|
29
|
+
export declare function regenerateWith(dir: string, candidates: LockfileCommand[]): Promise<{ regenerated: string[], note?: string }>;
|
|
30
|
+
/** Whether a command exists on this runner. */
|
|
31
|
+
export declare function commandAvailable(command: string): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Compare two dot-separated numeric versions.
|
|
34
|
+
*
|
|
35
|
+
* Shared by the ecosystems whose ordering really is plain semver, so each
|
|
36
|
+
* adapter does not reimplement it and get a different answer.
|
|
37
|
+
*/
|
|
38
|
+
export declare function compareNumeric(a: string, b: string): number;
|
|
39
|
+
/** Classify a change between two dot-separated numeric versions. */
|
|
40
|
+
export declare function numericUpdateType(from: string, to: string): 'major' | 'minor' | 'patch';
|
|
41
|
+
/** A lockfile and the command that regenerates it. */
|
|
42
|
+
export declare interface LockfileCommand {
|
|
43
|
+
lockfile: string
|
|
44
|
+
command: string[]
|
|
45
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Logger } from '../utils/logger';
|
|
2
|
+
/** A dependency an adapter found in a manifest. */
|
|
3
|
+
export declare interface EcosystemDependency {
|
|
4
|
+
name: string
|
|
5
|
+
currentVersion: string
|
|
6
|
+
section: string
|
|
7
|
+
file: string
|
|
8
|
+
metadata?: Record<string, string>
|
|
9
|
+
}
|
|
10
|
+
/** What a registry reported about a package. */
|
|
11
|
+
export declare interface VersionInfo {
|
|
12
|
+
latest: string
|
|
13
|
+
publishedAt?: Date
|
|
14
|
+
deprecated?: boolean
|
|
15
|
+
releaseNotesUrl?: string
|
|
16
|
+
homepage?: string
|
|
17
|
+
}
|
|
18
|
+
/** An update an adapter is asked to write. */
|
|
19
|
+
export declare interface EcosystemUpdate {
|
|
20
|
+
name: string
|
|
21
|
+
currentVersion: string
|
|
22
|
+
newVersion: string
|
|
23
|
+
section: string
|
|
24
|
+
metadata?: Record<string, string>
|
|
25
|
+
}
|
|
26
|
+
/** Options a registry lookup honours. */
|
|
27
|
+
export declare interface LatestOptions {
|
|
28
|
+
includePrerelease?: boolean
|
|
29
|
+
registryUrl?: string
|
|
30
|
+
logger?: Logger
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* One dependency ecosystem, as a pluggable module.
|
|
34
|
+
*
|
|
35
|
+
* Each ecosystem owns its own manifest discovery, parsing, version comparison
|
|
36
|
+
* and formatting-preserving writes. That last part is why the write is the
|
|
37
|
+
* adapter's job rather than a shared one: every manifest format has its own
|
|
38
|
+
* quoting, its own operator vocabulary, and a maintainer's formatting that a
|
|
39
|
+
* naive rewrite would destroy.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const files = await adapter.detect(process.cwd())
|
|
44
|
+
* const deps = await adapter.parse(files[0], await Bun.file(files[0]).text())
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare interface EcosystemAdapter {
|
|
48
|
+
name: string
|
|
49
|
+
manifestPatterns: string[]
|
|
50
|
+
detect: (dir: string) => Promise<string[]>
|
|
51
|
+
parse: (file: string, content: string) => Promise<EcosystemDependency[]>
|
|
52
|
+
latest: (dependency: EcosystemDependency, options?: LatestOptions) => Promise<VersionInfo | null>
|
|
53
|
+
applyUpdate: (content: string, update: EcosystemUpdate) => string
|
|
54
|
+
postWrite?: (dir: string) => Promise<{ regenerated: string[], note?: string }>
|
|
55
|
+
osvEcosystem?: string
|
|
56
|
+
compareVersions: (a: string, b: string) => number
|
|
57
|
+
updateType: (from: string, to: string) => 'major' | 'minor' | 'patch'
|
|
58
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Logger } from '../utils/logger';
|
|
2
|
+
/** Human-readable one-liner for an event, shared by every sink. */
|
|
3
|
+
export declare function describeEvent<K extends keyof BuddyEvents>(event: K, payload: BuddyEvents[K]): string;
|
|
4
|
+
/**
|
|
5
|
+
* Every event name, for config validation and subscription lists.
|
|
6
|
+
* @defaultValue `[ 'scan.completed', 'pr.created', 'pr.updated', 'pr.closed', 'pr.merged', 'security.advisories', 'dashboard.updated', 'review.completed', 'fixci.completed', 'gate.failed', 'run.failed', ]`
|
|
7
|
+
*/
|
|
8
|
+
export declare const EVENT_NAMES: Array<keyof BuddyEvents>;
|
|
9
|
+
/** Events emitted from buddy's real code paths. */
|
|
10
|
+
export declare interface BuddyEvents {
|
|
11
|
+
'scan.completed': { total: number, major: number, minor: number, patch: number }
|
|
12
|
+
'pr.created': { number: number, title: string, url: string, packages: string[] }
|
|
13
|
+
'pr.updated': { number: number, title: string, url: string }
|
|
14
|
+
'pr.closed': { number: number, title: string, reason: string }
|
|
15
|
+
'pr.merged': { number: number, title: string, strategy: string }
|
|
16
|
+
'security.advisories': { packages: Array<{ name: string, severity: string }> }
|
|
17
|
+
'dashboard.updated': { number: number, url: string }
|
|
18
|
+
'review.completed': { number: number, findings: number }
|
|
19
|
+
'fixci.completed': { number?: number, action: string, fixed: boolean }
|
|
20
|
+
'gate.failed': { number: number, checks: string[] }
|
|
21
|
+
'run.failed': { command: string, error: string }
|
|
22
|
+
}
|
|
23
|
+
/** A destination for events. */
|
|
24
|
+
export declare interface EventSink {
|
|
25
|
+
name: string
|
|
26
|
+
events?: Array<keyof BuddyEvents>
|
|
27
|
+
deliver: <K extends keyof BuddyEvents>(event: K, payload: BuddyEvents[K]) => Promise<void>
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Fan events out to configured sinks.
|
|
31
|
+
*
|
|
32
|
+
* Delivery failures are contained per sink: a Slack outage must not fail the
|
|
33
|
+
* dependency update that triggered the notification, and one broken webhook
|
|
34
|
+
* must not stop the others from firing.
|
|
35
|
+
*/
|
|
36
|
+
export declare class EventBus {
|
|
37
|
+
constructor(logger?: Logger);
|
|
38
|
+
register(sink: EventSink): void;
|
|
39
|
+
get size(): number;
|
|
40
|
+
emit<K extends keyof BuddyEvents>(event: K, payload: BuddyEvents[K]): Promise<void>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { BuddyEvents, EventSink } from './bus';
|
|
2
|
+
export type { NotificationConfig } from './sinks';
|
|
3
|
+
export { describeEvent, EVENT_NAMES, EventBus } from './bus';
|
|
4
|
+
export {
|
|
5
|
+
createDiscordSink,
|
|
6
|
+
createSinks,
|
|
7
|
+
createSlackSink,
|
|
8
|
+
createWebhookSink,
|
|
9
|
+
sign,
|
|
10
|
+
WEBHOOK_PAYLOAD_VERSION,
|
|
11
|
+
} from './sinks';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BuddyEvents, EventSink } from './bus';
|
|
2
|
+
/**
|
|
3
|
+
* Build sinks from configuration.
|
|
4
|
+
*
|
|
5
|
+
* Secrets are referenced by environment variable name rather than inlined, so
|
|
6
|
+
* a notification target can be committed to the repository without committing
|
|
7
|
+
* the credential that reaches it.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Notification configuration
|
|
10
|
+
* @returns Sinks for every destination whose credential is present
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSinks(config: NotificationConfig | undefined): EventSink[];
|
|
13
|
+
/** Slack sink, rendering events as block messages. */
|
|
14
|
+
export declare function createSlackSink(url: string, events?: Array<keyof BuddyEvents>): EventSink;
|
|
15
|
+
/** Discord sink, rendering events as embeds. */
|
|
16
|
+
export declare function createDiscordSink(url: string, events?: Array<keyof BuddyEvents>): EventSink;
|
|
17
|
+
/**
|
|
18
|
+
* Generic webhook sink, signed so a receiver can verify the sender.
|
|
19
|
+
*
|
|
20
|
+
* The signature is what makes this usable as an integration point rather than
|
|
21
|
+
* an unauthenticated POST anyone could forge.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createWebhookSink(webhook: { url: string, secretEnv?: string, events?: Array<keyof BuddyEvents> }, index?: number): EventSink;
|
|
24
|
+
/** HMAC-SHA256 of a payload, as a receiver would recompute it. */
|
|
25
|
+
export declare function sign(body: string, secret: string): string;
|
|
26
|
+
/** Payload schema version, so a webhook consumer can branch on shape changes. */
|
|
27
|
+
export declare const WEBHOOK_PAYLOAD_VERSION: 1;
|
|
28
|
+
/** Notification destinations, as configured. */
|
|
29
|
+
export declare interface NotificationConfig {
|
|
30
|
+
slack?: { webhookEnv?: string, events?: Array<keyof BuddyEvents> }
|
|
31
|
+
discord?: { webhookEnv?: string, events?: Array<keyof BuddyEvents> }
|
|
32
|
+
webhooks?: Array<{ url: string, secretEnv?: string, events?: Array<keyof BuddyEvents> }>
|
|
33
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { AiClient } from '../ai/types';
|
|
2
|
+
import type { GateMode, GateResult } from './checks';
|
|
3
|
+
import type { Logger } from '../utils/logger';
|
|
4
|
+
/**
|
|
5
|
+
* Check whether a change addresses the issue it claims to close.
|
|
6
|
+
*
|
|
7
|
+
* The most common failure this catches is a pull request that closes an issue
|
|
8
|
+
* it only partly implements — the issue disappears from the backlog and the
|
|
9
|
+
* remaining half is never done.
|
|
10
|
+
*
|
|
11
|
+
* Both the diff and the issue text are untrusted: they come from whoever
|
|
12
|
+
* opened them. They are given to the model as clearly delimited data with an
|
|
13
|
+
* instruction not to follow anything inside, and the verdict is constrained to
|
|
14
|
+
* a boolean and a reason so a crafted issue body cannot turn the gate into
|
|
15
|
+
* something else.
|
|
16
|
+
*
|
|
17
|
+
* @param ai - Client, absent to skip with a neutral result
|
|
18
|
+
* @param input - The pull request and its linked issues
|
|
19
|
+
* @param mode - How a failure behaves
|
|
20
|
+
* @param logger - Where to report failures
|
|
21
|
+
* @returns A gate result
|
|
22
|
+
*/
|
|
23
|
+
export declare function checkLinkedIssue(ai: AiClient | null, input: AiGateInput, mode: GateMode, logger?: Logger): Promise<GateResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Evaluate a repository's own natural-language assertions.
|
|
26
|
+
*
|
|
27
|
+
* Each assertion is checked separately rather than batched, so one
|
|
28
|
+
* unanswerable assertion cannot take the others down with it and each result
|
|
29
|
+
* names the assertion it belongs to.
|
|
30
|
+
*
|
|
31
|
+
* @param ai - Client, absent to skip with neutral results
|
|
32
|
+
* @param input - The pull request
|
|
33
|
+
* @param assertions - Assertions from configuration
|
|
34
|
+
* @param logger - Where to report failures
|
|
35
|
+
* @returns One result per assertion
|
|
36
|
+
*/
|
|
37
|
+
export declare function checkCustomAssertions(ai: AiClient | null, input: AiGateInput, assertions?: CustomAssertion[], logger?: Logger): Promise<GateResult[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Run every configured AI gate.
|
|
40
|
+
*
|
|
41
|
+
* @param ai - Client, absent to skip everything neutrally
|
|
42
|
+
* @param input - The pull request
|
|
43
|
+
* @param config - Which gates to run
|
|
44
|
+
* @param logger - Where to report failures
|
|
45
|
+
* @returns Results in the same shape the deterministic gates use
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const results = [...runGates(input, config), ...await runAiGates(ai, aiInput, config.ai)]
|
|
49
|
+
* const summary = summarizeGates(results)
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function runAiGates(ai: AiClient | null, input: AiGateInput, config?: AiGateConfig, logger?: Logger): Promise<GateResult[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Find the issues a pull request body says it closes.
|
|
55
|
+
*
|
|
56
|
+
* @param body - Pull request body
|
|
57
|
+
* @returns Issue numbers, deduplicated, in order of appearance
|
|
58
|
+
*/
|
|
59
|
+
export declare function findLinkedIssues(body: string): number[];
|
|
60
|
+
/** A natural-language assertion a pull request must satisfy. */
|
|
61
|
+
export declare interface CustomAssertion {
|
|
62
|
+
name: string
|
|
63
|
+
assertion: string
|
|
64
|
+
mode?: GateMode
|
|
65
|
+
}
|
|
66
|
+
/** Configuration for the AI-backed gates. */
|
|
67
|
+
export declare interface AiGateConfig {
|
|
68
|
+
linkedIssue?: GateMode
|
|
69
|
+
custom?: CustomAssertion[]
|
|
70
|
+
}
|
|
71
|
+
/** Everything an AI gate reads. */
|
|
72
|
+
export declare interface AiGateInput {
|
|
73
|
+
title: string
|
|
74
|
+
body: string
|
|
75
|
+
diff: string
|
|
76
|
+
linkedIssues?: Array<{ number: number, title: string, body: string }>
|
|
77
|
+
}
|