@vite-hub/presets 0.1.0 → 0.4.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.
@@ -1,7 +1,7 @@
1
- import { a as Snapshot, n as BabysitterAdmissionPause, t as BabysitterAdmissionOptions } from "./admission-DBJdt-CX.js";
2
- import { AgentDefinition, AgentInvocationContextValues, AgentInvokerProfile, AgentRuntimeConfig, AgentSandboxDefinition, BuiltInAgentDriverName, ConfiguredAgentDefinition } from "@vite-hub/agent";
1
+ import { T as AutomatedReviewClass, i as BabysitterAdmissionPause, l as GitHubRequiredCheckState, r as BabysitterAdmissionOptions, s as Snapshot, t as BabysitterWarmWorkspaces } from "./pr-workspaces-CMdQ9U15.js";
2
+ import { AgentDefinition, AgentInvocationContextValues, AgentInvoker, AgentRuntimeConfig, AgentSandboxDefinition, BuiltInAgentDriverName, ConfiguredAgentDefinition } from "@vite-hub/agent";
3
3
  import { GitHubPullRequestFilter } from "@vite-hub/agent/channels";
4
- import { GitHubRequiredCheckState } from "@vite-hub/agent/server/github";
4
+ import { Diagnostic } from "nostics";
5
5
  //#region src/babysitter/result.d.ts
6
6
  interface BabysitterResultDiagnostic {
7
7
  code: "invalid-wait" | "invalid-wake" | "invalid-reviewed-head" | "invalid-check-head";
@@ -41,14 +41,79 @@ type BabysitterMergeReady = (input: BabysitterMergeReadinessInput) => true | str
41
41
  /**
42
42
  * - `false`: never merge.
43
43
  * - `"auto"`: the worker may request GitHub native auto-merge.
44
- * - `"direct"`: the host merges a ready PR before any model pass.
44
+ * - `"direct"`: the host merges a ready PR before any model pass, with the `"approved-if-outside"` gate.
45
+ * - `{ strategy: "direct", ready }`: a direct merge with another gate. `ready` is a
46
+ * {@link BabysitterMergeReady} callback or `"approved-if-outside"`, the default: a PR whose author
47
+ * is not an owner, member or collaborator of the repository merges only after a reviewer with write
48
+ * access approves its current head, and while no such reviewer's latest review requests changes.
49
+ * A push after the approval needs a new one. `ready: () => true` merges every ready PR.
50
+ * `trustedAuthors` lets more authors through the default gate, such as dependency bots.
45
51
  */
46
52
  type BabysitterMerge = false | "auto" | "direct" | {
47
53
  strategy: "direct";
48
54
  method?: BabysitterMergeMethod;
49
- ready?: BabysitterMergeReady;
55
+ ready?: BabysitterMergeReady | "approved-if-outside";
56
+ /**
57
+ * Logins whose PRs the `"approved-if-outside"` gate merges without an approval, like an author with
58
+ * write access, such as `renovate[bot]`. Write a bot with its `[bot]` suffix: an entry with it matches
59
+ * only a bot account, and one without it matches only a user. Not allowed with a `ready` callback.
60
+ */
61
+ trustedAuthors?: readonly string[];
62
+ /**
63
+ * Required checks, by repository (`owner/name`), that the host may merge past when they fail only
64
+ * because the same check fails the same way on the base branch tip. The merge bypasses branch
65
+ * rules, so the GitHub App must be allowed to bypass them, and every other rule must be satisfied.
66
+ */
67
+ bypassInheritedChecks?: Record<string, readonly string[]>;
68
+ /**
69
+ * Logins whose reviewed drafts the host marks ready for review. Only drafts whose head
70
+ * branch is in the repository itself qualify, so a fork's draft stays a draft.
71
+ */
72
+ markDraftsReady?: readonly string[];
73
+ /**
74
+ * A branch, by repository (`owner/name`), that receives a fork PR's head when a required check never
75
+ * reported on it, such as `{ "acme/app": "preview/pr-{number}" }`. Checks that run only on pushes to
76
+ * the repository itself, like pkg.pr.new, then report on the head. `{number}` is the PR number. The
77
+ * host pushes only a head that a reviewer with write access approved and whose `.github` folder is the
78
+ * base branch's, because a push runs the pushed commit's workflows with the repository's permissions.
79
+ */
80
+ forkHeadBranches?: Record<string, string>;
81
+ /**
82
+ * Merge a ready pull request into its parent's branch when its base is the head branch of another
83
+ * open pull request in the same repository, so the stack lands with the parent. Default `true`.
84
+ */
85
+ foldStacks?: boolean;
50
86
  };
51
87
  //#endregion
88
+ //#region src/babysitter/main-repair.d.ts
89
+ /**
90
+ * Opens a pull request that repairs the default branch when one of its watched workflows fails. PR
91
+ * checks often run only fast suites while the full suites run on the default branch, so pull requests
92
+ * that each pass can break it together. The repair PR's head branch starts with
93
+ * `mainRepairBranchPrefix`, so the queue claims it first.
94
+ */
95
+ interface BabysitterMainRepair {
96
+ /** GitHub Actions workflow names to watch on the default branch, such as `["ci"]`. */
97
+ workflows: string[];
98
+ /** Repositories to watch, as `owner/name`. Defaults to every repository the Babysitter serves. */
99
+ repositories?: string[];
100
+ /**
101
+ * Minutes after which a running job of a watched push run on the default branch counts as stuck;
102
+ * its run is force-cancelled so later runs can start. `false` never cancels. Defaults to 90.
103
+ */
104
+ stuckJobMinutes?: number | false;
105
+ }
106
+ //#endregion
107
+ //#region src/babysitter/placement.d.ts
108
+ /**
109
+ * Thrown by `placement.place()` when no host can take the pass now. The pull request waits
110
+ * `retryAfterMs` and is claimed again, without a failure or a no-progress strike.
111
+ */
112
+ export declare class BabysitterPlacementCapacityError extends Diagnostic {
113
+ readonly retryAfterMs: number;
114
+ constructor(reason: string, retryAfterMs?: number);
115
+ }
116
+ //#endregion
52
117
  //#region src/babysitter.d.ts
53
118
  export interface BabysitterLifecycleLabels {
54
119
  /** At least one of these labels must be present for the PR to be eligible. */
@@ -68,30 +133,62 @@ export interface BabysitterPlacementLease {
68
133
  }
69
134
  /** Chooses a host for each pass before the Babysitter installs dependencies on this one. */
70
135
  export interface BabysitterPlacement {
136
+ /** Throw `BabysitterPlacementCapacityError` when no host can take the pass now; the PR waits and is claimed again. */
71
137
  place(pullRequest: {
72
138
  repository: string;
73
139
  number: number;
74
140
  }): BabysitterPlacementLease | Promise<BabysitterPlacementLease>;
75
141
  /** Passes currently placed on other hosts. They hold a concurrency slot but no local memory. */
76
142
  remoteActive?(): number;
143
+ /**
144
+ * Slots that hosts admit now, counting passes already running. A reconcile claims at most this
145
+ * many PRs minus the active owners, so it never claims work that `place` must turn away.
146
+ * Stop the capacity check and discard a pending shared probe when the signal aborts.
147
+ */
148
+ admitted?(signal?: AbortSignal): number | Promise<number>;
149
+ }
150
+ /** Where the Babysitter reports its state on each PR. Both need a verified GitHub App identity. */
151
+ export interface BabysitterStatusOptions {
152
+ /** Keep the activity comment on the PR up to date. Defaults to `true`. */
153
+ comment?: boolean;
154
+ /**
155
+ * Mirror the state as a check run named `babysitter` on the PR head: queued, in progress, neutral
156
+ * while waiting, success when done and failure when a pass failed. Its details link opens the
157
+ * Console session. Needs the App's `checks: write` permission; a repository that answers 403 is
158
+ * reported once and skipped. The Babysitter leaves this check out of its own CI and merge decisions,
159
+ * so do not make it a required check. Defaults to `true`.
160
+ */
161
+ checkRun?: boolean;
77
162
  }
78
163
  export interface BabysitterOptions {
79
164
  /** Process admission policy. Concurrency remains the preset hard maximum. */
80
- capacity?: Pick<import("@vite-hub/agent/runtime/process").ProcessAgentCapacityOptions, "memory" | "cpu" | "fallbackConcurrency">;
165
+ capacity?: Pick<import("@vite-hub/agent/process").ProcessAgentCapacityOptions, "memory" | "cpu" | "fallbackConcurrency">;
81
166
  /**
82
167
  * Places each pass on this host or in a Sandbox before host dependency installation. Sandbox passes
83
168
  * skip the host install; the Sandbox installs through `refreshDependencies` when it provides one.
84
169
  */
85
170
  placement?: BabysitterPlacement;
86
- /** Select PRs with the same rules as the GitHub Channel. */
171
+ /**
172
+ * Select PRs with the same rules as the GitHub Channel, with two differences. A PR passes when it
173
+ * matches either `author.allow` or `authorAssociation.allow`; a match on either deny list rejects it.
174
+ * Logins match case-insensitively and in either bot spelling, so `renovate[bot]` also matches `renovate`.
175
+ * Without `repository.allow`, the Babysitter serves every repository that its GitHub App installations
176
+ * can access, except archived ones and those in `repository.deny`, so installing the App on a repository enrolls it.
177
+ * Without `author` or `authorAssociation` rules, only PRs whose author is an owner, member or collaborator are selected.
178
+ */
87
179
  filter: GitHubPullRequestFilter;
88
- /** Additional lifecycle admission rules. Use labels to pause or resume a PR without changing the filter. */
180
+ /**
181
+ * Additional lifecycle admission rules. Use labels to pause or resume a PR without changing the filter.
182
+ * Without these labels or `filter.labels`, a PR labelled `babysitter:skip` is skipped. `{ labels: {} }` turns that off.
183
+ */
89
184
  lifecycle: BabysitterLifecycleOptions;
90
185
  /** Provider Driver that repairs each PR in its checkout. Defaults to `"codex"`. Set the model with `driver.model`. */
91
186
  driver: BuiltInAgentDriverName;
92
187
  /**
93
- * Merge policy. Defaults to `false`. `"auto"` lets the worker request GitHub native auto-merge.
94
- * `"direct"` merges a ready PR into its default branch before any model pass.
188
+ * Merge policy. Defaults to `"direct"`. `false` never merges, and `"auto"` lets the worker request
189
+ * GitHub native auto-merge. `"direct"` merges a ready PR into its default branch before any model
190
+ * pass, and holds a PR from someone without write access until a reviewer with write access approves
191
+ * its current head. Pass `{ strategy: "direct", ready }` with another callback to change that gate.
95
192
  */
96
193
  merge: BabysitterMerge;
97
194
  /**
@@ -105,8 +202,9 @@ export interface BabysitterOptions {
105
202
  */
106
203
  noFindingsReviews: string[];
107
204
  /**
108
- * Logins whose comments and reviews never need an assessment, such as deployment preview bots.
109
- * Their items do not block a direct merge or wake a waiting PR. Defaults to none.
205
+ * Logins whose comments and reviews never need an assessment. Their items do not block a direct
206
+ * merge or wake a waiting PR. Defaults to the deployment preview bots `pkg-pr-new[bot]`,
207
+ * `vercel[bot]`, `cloudflare-workers-and-pages[bot]` and `netlify[bot]`. A list replaces them.
110
208
  */
111
209
  ignoreFeedbackAuthors: string[];
112
210
  /**
@@ -122,13 +220,61 @@ export interface BabysitterOptions {
122
220
  * the reason. `false` disables the budget. Defaults to 3.
123
221
  */
124
222
  reviewPushBudget: number | false;
223
+ /**
224
+ * Heads in a row whose automated review has no valid finding above P2 before automated review settles
225
+ * as if `reviewPushBudget` were spent. Each pass reports the highest class (P0 to P3) in the
226
+ * automated reviews of its head; a P0 or P1 starts the count again. Needs `reviewPushBudget`.
227
+ * `false` disables it. Defaults to `false`.
228
+ */
229
+ minorReviewRounds: number | false;
230
+ /**
231
+ * Review-driven pushes after which each pass is asked to fix a recurring class of review finding at
232
+ * its root instead of patching one more case, or to decline the remaining minor cases. `false`
233
+ * disables it. Defaults to `false`.
234
+ */
235
+ reviewConvergencePushes: number | false;
236
+ /**
237
+ * Unresolved review threads with only bot comments stop blocking a direct merge and stop waking a
238
+ * waiting PR once a pass assessed their comments. A new bot comment still needs a pass, and a thread
239
+ * with a person's comment still blocks. Defaults to `false`; such threads then stop blocking only
240
+ * once automated review settles.
241
+ */
242
+ ignoreAssessedBotThreads: boolean;
125
243
  /**
126
244
  * Model passes on one PR in a rolling 24 hours. After that many, the PR parks until the oldest pass
127
245
  * is 24 hours old; its result and the health route show that time. A person's comment or review, the
128
- * first failing required check on a head and a merge conflict on a PR without failing checks or open
129
- * threads still start a pass, and count. `false` disables the budget. Defaults to 16.
246
+ * first failing required check on a head, a merge conflict, and one assessment of a head whose required
247
+ * checks pass still start a pass, and count. A pass that the provider fails within 10 minutes does not
248
+ * count. `false` disables the budget. Defaults to 16.
130
249
  */
131
250
  dailyPassBudget: number | false;
251
+ /**
252
+ * Repair pushes on one PR in a rolling 24 hours. Past it, `pushRepair` refuses a push until the
253
+ * oldest is 24 hours old, and a pass that could only push parks until then. A conflict repair still
254
+ * pushes, and a PR whose required checks fail may push once every two hours. `false` disables the
255
+ * budget. Defaults to `false`.
256
+ */
257
+ dailyPushBudget: number | false;
258
+ /**
259
+ * PR labels that put a PR first in the claim order, after main repairs. A labelled PR is exempt from
260
+ * `dailyPassBudget` and `dailyPushBudget`; checks, reviews and merge gates still apply. Matched
261
+ * case-insensitively. Defaults to none.
262
+ */
263
+ priorityLabels: string[];
264
+ /**
265
+ * Head branch prefix of PRs that repair the base branch, such as `"repair-main-"`. These PRs are
266
+ * claimed before every other PR, and `noProgressBudget` never stops them. Defaults to none.
267
+ */
268
+ mainRepairBranchPrefix?: string;
269
+ /**
270
+ * Open a PR that repairs the default branch when one of `workflows` fails on it. The check runs every
271
+ * 10 minutes per repository, and at once when a failed push run of a watched workflow is delivered.
272
+ * The PR starts with an empty commit on a branch named `mainRepairBranchPrefix` and the red commit's
273
+ * short SHA, so the queue claims it first. One repair PR is open at a time, and a red commit gets
274
+ * one repair branch. Running jobs of watched push runs older than `stuckJobMinutes` are force-cancelled
275
+ * first. Needs `mainRepairBranchPrefix`. Defaults to `false`.
276
+ */
277
+ mainRepair: BabysitterMainRepair | false;
132
278
  /**
133
279
  * Wait for running required checks and review checks before a pass, unless a failure or conflict
134
280
  * already needs repair. One pass then handles CI and review results together. Defaults to `true`.
@@ -143,11 +289,33 @@ export interface BabysitterOptions {
143
289
  install: BabysitterInstall;
144
290
  /** Rerun failed GitHub Actions runs once before a model pass repairs them. Defaults to `true`. */
145
291
  ciRecovery: boolean;
292
+ /**
293
+ * Keep one workspace per open PR under `<dataDir>/pr-workspaces` instead of cloning, copying and
294
+ * installing for every pass. A pass on the head the previous pass pushed or left, after a pass that
295
+ * finished, on a clean tree, keeps node_modules and build caches and skips a current install. Any
296
+ * other pass empties the workspace and checks the head out again. Entries go when the PR closes,
297
+ * after `idleDays` without a pass, and least recently used first above `budgetGb` or below
298
+ * `minFreePercent` free disk. `resumeThreads` also continues the previous pass's provider thread.
299
+ * Passes placed in a Sandbox keep using their own workspace. Defaults to `false`.
300
+ */
301
+ warmWorkspaces: boolean | BabysitterWarmWorkspaces;
302
+ /**
303
+ * Repair a PR whose base is another open PR's branch in parallel with its parent: checks, conflicts
304
+ * and feedback. It never merges into the parent's branch and waits for the parent once its reviewed
305
+ * head has nothing left to repair. Requires `merge: "direct"`. Defaults to `false`, which leaves a
306
+ * stack child unclaimed until its parent merges.
307
+ */
308
+ repairStackChildren: boolean;
146
309
  /**
147
310
  * Model passes that run at the same time. Set it to what the provider accounts can serve; host
148
311
  * work such as merges and stack retargets still uses `concurrency`. Defaults to `concurrency`.
149
312
  */
150
313
  modelConcurrency?: number;
314
+ /**
315
+ * Retries of a provider rate limit, 10 seconds apart, before the pass opens the provider cooldown.
316
+ * Set `0` when the provider already retries, as Codex does. Defaults to 3.
317
+ */
318
+ providerRetries: number;
151
319
  /**
152
320
  * First cooldown after a pass runs out of provider rate-limit retries. Model passes pause; host work
153
321
  * continues. Each further cooldown doubles, up to one hour, and halves model concurrency. A
@@ -164,6 +332,8 @@ export interface BabysitterOptions {
164
332
  * and 4096 MiB of free temporary space.
165
333
  */
166
334
  admission: BabysitterAdmissionOptions;
335
+ /** How the Babysitter reports its state on the PR. Defaults to `{ comment: true, checkRun: true }`. */
336
+ status: BabysitterStatusOptions;
167
337
  }
168
338
  /**
169
339
  * Dependency install before each pass. `true` detects the package manager from the lockfile;
@@ -196,6 +366,12 @@ export type BabysitterInstall = boolean | {
196
366
  * its inputs change. Defaults to `false`.
197
367
  */
198
368
  required?: boolean;
369
+ /**
370
+ * `refreshDependencies` calls per pass. Further calls return a tool error that tells the model to
371
+ * commit its dependency fixes and let hosted CI validate them. Retryable install failures do not
372
+ * count. Defaults to no limit.
373
+ */
374
+ refreshes?: number;
199
375
  };
200
376
  export type BabysitterPassWake = {
201
377
  kind: "checks";
@@ -223,10 +399,12 @@ export interface BabysitterPassResult {
223
399
  reviewedHead?: string;
224
400
  /** Legacy explicit check checkpoint, accepted while existing provider output migrates. */
225
401
  waitForChecksHead?: string;
402
+ /** Highest class of valid finding in the automated reviews of the head the pass started on. Read with `minorReviewRounds`. */
403
+ automatedReview?: AutomatedReviewClass;
226
404
  }
227
405
  export declare const babysitterPassResultSchema: ReturnType<typeof createBabysitterPassResultSchema>;
228
406
  /** A repair workflow. Connections, provider settings and host resources stay in the application. */
229
- type BabysitterDefinition = AgentDefinition<AgentRuntimeConfig, unknown, AgentInvokerProfile, AgentInvocationContextValues, BabysitterPassResult> & {
407
+ type BabysitterDefinition = AgentDefinition<AgentRuntimeConfig, unknown, AgentInvoker, AgentInvocationContextValues, BabysitterPassResult> & {
230
408
  reviewChecks: string[];
231
409
  noFindingsReviews: string[];
232
410
  ignoreFeedbackAuthors: string[];
@@ -239,8 +417,12 @@ type BabysitterDefinition = AgentDefinition<AgentRuntimeConfig, unknown, AgentIn
239
417
  lifecycle: BabysitterLifecycleOptions;
240
418
  };
241
419
  export type BabysitterAgent = ConfiguredAgentDefinition<BabysitterOptions, BabysitterDefinition>;
242
- /** Combines explicit lifecycle labels with the shared GitHub PR filter. */
243
- export declare function resolveBabysitterLifecycleFilter(filter: GitHubPullRequestFilter, lifecycle: BabysitterLifecycleOptions | undefined): GitHubPullRequestFilter;
420
+ /**
421
+ * Combines explicit lifecycle labels with the shared GitHub PR filter. A filter without author rules
422
+ * selects only PRs from people with write access, and one without label rules skips PRs labelled
423
+ * `babysitter:skip`.
424
+ */
425
+ export declare function resolveBabysitterLifecycleFilter(configured: GitHubPullRequestFilter, lifecycle: BabysitterLifecycleOptions | undefined): GitHubPullRequestFilter;
244
426
  export declare const babysitter: BabysitterAgent;
245
427
  //#endregion
246
- export type { BabysitterAdmissionOptions, BabysitterAdmissionPause, BabysitterMerge, BabysitterMergeMethod, BabysitterMergeReadinessInput, BabysitterMergeReady };
428
+ export type { AutomatedReviewClass, BabysitterAdmissionOptions, BabysitterAdmissionPause, BabysitterMainRepair, BabysitterMerge, BabysitterMergeMethod, BabysitterMergeReadinessInput, BabysitterMergeReady, BabysitterWarmWorkspaces };
@@ -1,2 +1,2 @@
1
- import { n as babysitterPassResultSchema, r as resolveBabysitterLifecycleFilter, t as babysitter } from "./babysitter-B4D1zeYf.js";
2
- export { babysitter, babysitterPassResultSchema, resolveBabysitterLifecycleFilter };
1
+ import { i as BabysitterPlacementCapacityError, n as babysitterPassResultSchema, r as resolveBabysitterLifecycleFilter, t as babysitter } from "./babysitter-DQeA81N0.js";
2
+ export { BabysitterPlacementCapacityError, babysitter, babysitterPassResultSchema, resolveBabysitterLifecycleFilter };