@coderabbitai/config 1.1.6 → 1.2.1
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/README.md +71 -0
- package/dist/define-config.d.ts +19 -8
- package/dist/define-config.d.ts.map +1 -1
- package/dist/define-config.js +37 -85
- package/dist/define-config.js.map +1 -1
- package/dist/index.d.ts +583 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -194,6 +194,77 @@ shape.
|
|
|
194
194
|
`CodeRabbitInvocationContext`, `CodeRabbitInvocationSource`,
|
|
195
195
|
`ResolvedCodeRabbitContext`, `RemoteInclude`.
|
|
196
196
|
|
|
197
|
+
## Repository configuration directory
|
|
198
|
+
|
|
199
|
+
Automatic V2 directory loading is limited to the authenticated internal GitHub
|
|
200
|
+
Cloud preview while its cache and cold paths are qualified. It supports cascading
|
|
201
|
+
`.coderabbit/instructions/` and `.coderabbit/pre-merge-checks/` Markdown files,
|
|
202
|
+
including repositories without a YAML or TypeScript configuration entry. Each
|
|
203
|
+
file requires YAML front matter with a stable `id`. Files apply within their
|
|
204
|
+
containing directory and can narrow that scope with `paths` and `exclude`.
|
|
205
|
+
Omitted `report` uses a GitHub check run; set `report: coderabbit` for the native
|
|
206
|
+
walkthrough report.
|
|
207
|
+
|
|
208
|
+
Review admission and preparation use the YAML or TypeScript entry configuration.
|
|
209
|
+
The detailed review loads directory context inside `proReview()`, after admission,
|
|
210
|
+
from the existing trusted checkout or snapshot at the selected document commit,
|
|
211
|
+
or a complete private bundle cached for that exact commit. Settings needed before
|
|
212
|
+
that point must stay in the entry configuration. A directory-only change can
|
|
213
|
+
select PR documents without changing the YAML or TypeScript source.
|
|
214
|
+
|
|
215
|
+
Document loading never starts a clone solely for discovery, calls GitHub tree or
|
|
216
|
+
Contents APIs for directory discovery, or fetches missing Git objects. Immutable
|
|
217
|
+
bundles do not require ETag revalidation. Remote configuration fragments do not
|
|
218
|
+
add discovery roots.
|
|
219
|
+
|
|
220
|
+
A missing or incomplete bundle is unknown, not an empty directory. If neither the
|
|
221
|
+
selected local source nor a complete cached bundle is available, the activated
|
|
222
|
+
directory load fails explicitly. Reviews, commands and QA admission must not omit
|
|
223
|
+
instructions or clear checks on that basis. A skipped detailed review can still
|
|
224
|
+
run YAML checks, but cannot auto-approve while its directory context is unread.
|
|
225
|
+
A validated empty bundle proves that the selected commit has no documents in the
|
|
226
|
+
requested namespaces.
|
|
227
|
+
|
|
228
|
+
## Internal V3 preview
|
|
229
|
+
|
|
230
|
+
V2 remains the public configuration contract and the `CodeRabbitConfig` type.
|
|
231
|
+
`CodeRabbitConfigV3` and the `defineConfig` / `mergeConfig` overloads support an
|
|
232
|
+
explicit `version: 3` for the authenticated internal GitHub Cloud preview only.
|
|
233
|
+
Types do not grant runtime access: customer, self-hosted and central V3 entry
|
|
234
|
+
configurations remain unsupported. YAML still takes precedence over TypeScript.
|
|
235
|
+
QA definitions also default to platform reporting when `report` is omitted;
|
|
236
|
+
their existing QA run comment remains available.
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
import { defineConfig, mergeConfig } from "@coderabbitai/config"
|
|
240
|
+
|
|
241
|
+
export default defineConfig(ctx =>
|
|
242
|
+
mergeConfig(
|
|
243
|
+
{ version: 3, reviews: { behavior: { profile: "chill" } } },
|
|
244
|
+
{ fun: { in_progress_fortune: ctx.invocation.source === "review" } },
|
|
245
|
+
),
|
|
246
|
+
)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Start each V3 `mergeConfig` call with a V3 base, including nested calls:
|
|
250
|
+
`mergeConfig({ version: 3 }, canonical, legacy)`. A call with only versionless
|
|
251
|
+
fragments retains the V2 contract; an enclosing V3 merge cannot change how an
|
|
252
|
+
inner call has already combined its fragments.
|
|
253
|
+
|
|
254
|
+
For an admitted primary repository, directory documents use the selected immutable
|
|
255
|
+
configuration revision unless the trusted PR source policy admits a directory-only
|
|
256
|
+
change from the PR head. Imported fragments do not create additional directory
|
|
257
|
+
discovery roots. Use
|
|
258
|
+
`includeRemote<CodeRabbitConfigV3Fragment>({ path: "base.ts" })` to type a remote
|
|
259
|
+
V3 fragment; calls without a type argument retain their V2 return type. The
|
|
260
|
+
offline V2 migration CLI
|
|
261
|
+
still reads explicit YAML inputs; it does not execute TypeScript factories or
|
|
262
|
+
attest their inherited source graph. Use `--repository-root` with the local Git
|
|
263
|
+
root to qualify whether existing directory inputs are absent. Without that
|
|
264
|
+
inventory, or when it finds instructions, checks, QA definitions, or namespace
|
|
265
|
+
links, the YAML-only plan remains a draft and cannot qualify source replacement.
|
|
266
|
+
It makes no clone, provider, or database call.
|
|
267
|
+
|
|
197
268
|
## Building the SDK
|
|
198
269
|
|
|
199
270
|
From the repository root, run `pnpm build --filter=@coderabbitai/config`.
|
package/dist/define-config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
|
-
import type { getSchemaForExport } from "@coderabbitai/schemas";
|
|
2
|
+
import type { ConfigInputV3, getSchemaForExport } from "@coderabbitai/schemas";
|
|
3
3
|
/**
|
|
4
4
|
* The CodeRabbit configuration object, as authored in a `.coderabbit.config.ts`.
|
|
5
5
|
*
|
|
@@ -16,14 +16,15 @@ import type { getSchemaForExport } from "@coderabbitai/schemas";
|
|
|
16
16
|
* change. `import type` keeps this purely author-time: nothing from the schema
|
|
17
17
|
* package is pulled into the SDK's runtime bundle.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* paired marker in `pr-reviewer-saas/src/settings/yaml.ts`
|
|
23
|
-
* (`prepareSettingsFromTypeScriptConfig`), which pins runtime validation of the
|
|
24
|
-
* `.ts` path to the new schema version.
|
|
19
|
+
* This public type remains V2. Explicit V3 authoring uses
|
|
20
|
+
* {@link CodeRabbitConfigV3}, whose runtime admission is currently limited to
|
|
21
|
+
* the authenticated internal GitHub Cloud preview.
|
|
25
22
|
*/
|
|
26
23
|
export type CodeRabbitConfig = z.input<ReturnType<typeof getSchemaForExport>>;
|
|
24
|
+
/** Internal preview configuration; requires an explicit `version: 3`. */
|
|
25
|
+
export type CodeRabbitConfigV3 = ConfigInputV3;
|
|
26
|
+
/** A V3 override keeps the base's version when omitted. */
|
|
27
|
+
export type CodeRabbitConfigV3Fragment = Partial<CodeRabbitConfigV3>;
|
|
27
28
|
/** How CodeRabbit was invoked when evaluating a programmatic config. */
|
|
28
29
|
export type CodeRabbitInvocationSource = "cli" | "review";
|
|
29
30
|
/** Invocation metadata supplied when CodeRabbit evaluates a config factory. */
|
|
@@ -213,6 +214,8 @@ interface CodeRabbitConfigFactoryContext extends Omit<ResolvedCodeRabbitContext,
|
|
|
213
214
|
* pull request.
|
|
214
215
|
*/
|
|
215
216
|
export type CodeRabbitConfigFactory = (ctx: CodeRabbitConfigFactoryContext) => CodeRabbitConfig | Promise<CodeRabbitConfig>;
|
|
217
|
+
/** An internal preview factory; ordinary customer factories retain V2. */
|
|
218
|
+
export type CodeRabbitConfigV3Factory = (ctx: CodeRabbitConfigFactoryContext) => CodeRabbitConfigV3 | Promise<CodeRabbitConfigV3>;
|
|
216
219
|
/**
|
|
217
220
|
* Define a CodeRabbit configuration with full type-checking and autocomplete.
|
|
218
221
|
*
|
|
@@ -248,8 +251,12 @@ export type CodeRabbitConfigFactory = (ctx: CodeRabbitConfigFactoryContext) => C
|
|
|
248
251
|
* }))
|
|
249
252
|
* ```
|
|
250
253
|
*/
|
|
254
|
+
export declare function defineConfig(config: CodeRabbitConfigV3): CodeRabbitConfigV3;
|
|
255
|
+
export declare function defineConfig(config: CodeRabbitConfigV3Factory): CodeRabbitConfigV3Factory;
|
|
251
256
|
export declare function defineConfig(config: CodeRabbitConfig): CodeRabbitConfig;
|
|
252
|
-
export declare function defineConfig(config:
|
|
257
|
+
export declare function defineConfig<const T extends CodeRabbitConfig | Promise<CodeRabbitConfig>>(config: ((ctx: CodeRabbitConfigFactoryContext) => T) & (Awaited<NoInfer<T>> extends {
|
|
258
|
+
version: 3;
|
|
259
|
+
} ? never : unknown)): CodeRabbitConfigFactory;
|
|
253
260
|
/**
|
|
254
261
|
* Deep-merge CodeRabbit config objects left-to-right and return the combined
|
|
255
262
|
* config. Use it to layer overrides onto a base config — e.g. applying
|
|
@@ -281,6 +288,7 @@ export declare function defineConfig(config: CodeRabbitConfigFactory): CodeRabbi
|
|
|
281
288
|
* )
|
|
282
289
|
* ```
|
|
283
290
|
*/
|
|
291
|
+
export declare function mergeConfig(base: CodeRabbitConfigV3, ...overrides: CodeRabbitConfigV3Fragment[]): CodeRabbitConfigV3;
|
|
284
292
|
export declare function mergeConfig(...configs: CodeRabbitConfig[]): CodeRabbitConfig;
|
|
285
293
|
/**
|
|
286
294
|
* Location of a shared config file, for {@link includeRemote}. When `repo` is
|
|
@@ -328,7 +336,10 @@ export interface RemoteInclude {
|
|
|
328
336
|
* literal with string values (it is resolved before your config runs, so it
|
|
329
337
|
* cannot take computed/runtime values). CodeRabbit resolves the call during
|
|
330
338
|
* bundling; the runtime body below only executes if resolution was bypassed.
|
|
339
|
+
* Use `includeRemote<CodeRabbitConfigV3Fragment>(...)` for a V3 fragment in the
|
|
340
|
+
* authenticated internal preview; ordinary calls retain the V2 return type.
|
|
331
341
|
*/
|
|
342
|
+
export declare function includeRemote<Config extends CodeRabbitConfig | CodeRabbitConfigV3Fragment = CodeRabbitConfig>(spec: RemoteInclude): Config;
|
|
332
343
|
export declare function includeRemote(spec: RemoteInclude): CodeRabbitConfig;
|
|
333
344
|
export {};
|
|
334
345
|
//# sourceMappingURL=define-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../src/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"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AkB,EACxB,GAAG,SAAS,EAAE,0BAA0B,EAAE,GACxC,kBAAkB,CAAA;AACrB,wBAAgB,WAAW,CAAC,GAAG,OAAO,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,CAAA;AAgB7E;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAC5B,MAAM,SAAS,gBAAgB,GAAG,0BAA0B,GAC3D,gBAAgB,EAChB,IAAI,EAAE,aAAa,GAAG,MAAM,CAAA;AAC9B,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,gBAAgB,CAAA"}
|
package/dist/define-config.js
CHANGED
|
@@ -29,104 +29,56 @@ function deepMergeValues(a, b) {
|
|
|
29
29
|
}
|
|
30
30
|
return b;
|
|
31
31
|
}
|
|
32
|
-
function normalizeWorkflowAlias(config) {
|
|
32
|
+
function normalizeWorkflowAlias(config, version) {
|
|
33
33
|
const reviews = config.reviews;
|
|
34
|
-
if (!isPlainObject(reviews)
|
|
35
|
-
(typeof reviews.request_changes_workflow !== "boolean" &&
|
|
36
|
-
typeof reviews.allow_author_approval !== "boolean"))
|
|
34
|
+
if (!isPlainObject(reviews))
|
|
37
35
|
return config;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(reviews.allow_author_approval !== undefined &&
|
|
41
|
-
typeof reviews.allow_author_approval !== "boolean"))
|
|
36
|
+
const fields = version === 3 ? reviews["behavior"] : reviews;
|
|
37
|
+
if (!isPlainObject(fields))
|
|
42
38
|
return config;
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
const { request_changes_workflow: legacy, allow_author_approval: authorLegacy, auto_approvals: approvals, ...rest } = fields;
|
|
40
|
+
if (typeof legacy !== "boolean" && typeof authorLegacy !== "boolean")
|
|
41
|
+
return config;
|
|
42
|
+
if ((legacy !== undefined && typeof legacy !== "boolean") ||
|
|
43
|
+
(authorLegacy !== undefined && typeof authorLegacy !== "boolean"))
|
|
44
|
+
return config;
|
|
45
|
+
if (approvals !== undefined && !isPlainObject(approvals))
|
|
45
46
|
return config;
|
|
46
|
-
const { request_changes_workflow: legacy, allow_author_approval: authorLegacy, ...rest } = reviews;
|
|
47
47
|
if ((typeof legacy === "boolean" &&
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
approvals?.["enabled"] !== undefined &&
|
|
49
|
+
approvals["enabled"] !== legacy) ||
|
|
50
50
|
(typeof authorLegacy === "boolean" &&
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
approvals?.["allow_author_approval"] !== undefined &&
|
|
52
|
+
approvals["allow_author_approval"] !== authorLegacy))
|
|
53
53
|
return config;
|
|
54
|
+
const normalized = {
|
|
55
|
+
...rest,
|
|
56
|
+
auto_approvals: {
|
|
57
|
+
...approvals,
|
|
58
|
+
...(typeof legacy === "boolean"
|
|
59
|
+
? { enabled: approvals?.["enabled"] ?? legacy }
|
|
60
|
+
: {}),
|
|
61
|
+
...(typeof authorLegacy === "boolean"
|
|
62
|
+
? {
|
|
63
|
+
allow_author_approval: approvals?.["allow_author_approval"] ?? authorLegacy,
|
|
64
|
+
}
|
|
65
|
+
: {}),
|
|
66
|
+
},
|
|
67
|
+
};
|
|
54
68
|
return {
|
|
55
69
|
...config,
|
|
56
|
-
reviews: {
|
|
57
|
-
...rest,
|
|
58
|
-
auto_approvals: {
|
|
59
|
-
...reviews.auto_approvals,
|
|
60
|
-
...(typeof legacy === "boolean"
|
|
61
|
-
? { enabled: reviews.auto_approvals?.enabled ?? legacy }
|
|
62
|
-
: {}),
|
|
63
|
-
...(typeof authorLegacy === "boolean"
|
|
64
|
-
? {
|
|
65
|
-
allow_author_approval: reviews.auto_approvals?.allow_author_approval ?? authorLegacy,
|
|
66
|
-
}
|
|
67
|
-
: {}),
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
+
reviews: version === 3 ? { ...reviews, behavior: normalized } : normalized,
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Deep-merge CodeRabbit config objects left-to-right and return the combined
|
|
74
|
-
* config. Use it to layer overrides onto a base config — e.g. applying
|
|
75
|
-
* context-driven changes on top of shared defaults.
|
|
76
|
-
*
|
|
77
|
-
* Merge rules:
|
|
78
|
-
* - **Objects** are merged recursively, so setting one nested key does not wipe
|
|
79
|
-
* its siblings (e.g. adding `reviews.tools.osv_scanner` keeps
|
|
80
|
-
* `reviews.tools.gitleaks`).
|
|
81
|
-
* - **Scalars**: the later config wins.
|
|
82
|
-
* - **Arrays** are **concatenated**, so list fields like `path_instructions`
|
|
83
|
-
* and `labeling_instructions` accumulate rather than replacing each other.
|
|
84
|
-
* - An omitted key never clobbers an existing value (pass an empty object to
|
|
85
|
-
* contribute nothing, which makes `cond ? fragment : {}` safe).
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```ts
|
|
89
|
-
* import { defineConfig, mergeConfig } from "@coderabbitai/config"
|
|
90
|
-
*
|
|
91
|
-
* const base = { reviews: { profile: "chill", tools: { gitleaks: { enabled: true } } } }
|
|
92
|
-
*
|
|
93
|
-
* export default defineConfig((ctx) =>
|
|
94
|
-
* mergeConfig(
|
|
95
|
-
* base,
|
|
96
|
-
* ctx.pr?.baseBranch.startsWith("release/")
|
|
97
|
-
* ? { reviews: { profile: "assertive", auto_approvals: { enabled: true } } }
|
|
98
|
-
* : {},
|
|
99
|
-
* ),
|
|
100
|
-
* )
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
73
|
export function mergeConfig(...configs) {
|
|
104
|
-
return configs.reduce((acc, config) =>
|
|
105
|
-
|
|
106
|
-
|
|
74
|
+
return configs.reduce((acc, config) => {
|
|
75
|
+
if (config === undefined)
|
|
76
|
+
return acc;
|
|
77
|
+
const version = ("version" in config ? config.version : undefined) ??
|
|
78
|
+
("version" in acc ? acc.version : undefined);
|
|
79
|
+
return deepMergeValues(acc, normalizeWorkflowAlias(config, version));
|
|
80
|
+
}, {});
|
|
107
81
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Include a shared config from your organization's `coderabbit` repository,
|
|
110
|
-
* returning its config object to compose with {@link mergeConfig}:
|
|
111
|
-
*
|
|
112
|
-
* ```ts
|
|
113
|
-
* import { defineConfig, mergeConfig, includeRemote } from "@coderabbitai/config"
|
|
114
|
-
*
|
|
115
|
-
* const orgBase = includeRemote({ path: "base.ts" })
|
|
116
|
-
* export default defineConfig(mergeConfig(orgBase, { reviews: { profile: "assertive" } }))
|
|
117
|
-
* ```
|
|
118
|
-
*
|
|
119
|
-
* When `repo` is omitted, shared files are read from the `{owner}/coderabbit`
|
|
120
|
-
* repository (the same repo CodeRabbit uses for org-wide central config). A
|
|
121
|
-
* non-central repository is fetched only after CodeRabbit verifies the access
|
|
122
|
-
* required for the configuration source. The file is evaluated in the same
|
|
123
|
-
* sandbox as your config.
|
|
124
|
-
*
|
|
125
|
-
* **This is a bundle-time directive**: the argument must be an inline object
|
|
126
|
-
* literal with string values (it is resolved before your config runs, so it
|
|
127
|
-
* cannot take computed/runtime values). CodeRabbit resolves the call during
|
|
128
|
-
* bundling; the runtime body below only executes if resolution was bypassed.
|
|
129
|
-
*/
|
|
130
82
|
export function includeRemote(spec) {
|
|
131
83
|
void spec;
|
|
132
84
|
throw new Error("includeRemote() is resolved at build time by CodeRabbit and cannot be called at runtime.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-config.js","sourceRoot":"","sources":["../src/define-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"define-config.js","sourceRoot":"","sources":["../src/define-config.ts"],"names":[],"mappings":"AAsTA,MAAM,UAAU,YAAY,CAC3B,MAI4B;IAM5B,OAAO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