@vite-hub/presets 0.1.0 → 0.3.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-CjX3PSqM.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,71 @@ 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
+ * Merge a ready pull request into its parent's branch when its base is the head branch of another
75
+ * open pull request in the same repository, so the stack lands with the parent. Default `true`.
76
+ */
77
+ foldStacks?: boolean;
50
78
  };
51
79
  //#endregion
80
+ //#region src/babysitter/main-repair.d.ts
81
+ /**
82
+ * Opens a pull request that repairs the default branch when one of its watched workflows fails. PR
83
+ * checks often run only fast suites while the full suites run on the default branch, so pull requests
84
+ * that each pass can break it together. The repair PR's head branch starts with
85
+ * `mainRepairBranchPrefix`, so the queue claims it first.
86
+ */
87
+ interface BabysitterMainRepair {
88
+ /** GitHub Actions workflow names to watch on the default branch, such as `["ci"]`. */
89
+ workflows: string[];
90
+ /** Repositories to watch, as `owner/name`. Defaults to every repository the Babysitter serves. */
91
+ repositories?: string[];
92
+ /**
93
+ * Minutes after which a running job of a watched push run on the default branch counts as stuck;
94
+ * its run is force-cancelled so later runs can start. `false` never cancels. Defaults to 90.
95
+ */
96
+ stuckJobMinutes?: number | false;
97
+ }
98
+ //#endregion
99
+ //#region src/babysitter/placement.d.ts
100
+ /**
101
+ * Thrown by `placement.place()` when no host can take the pass now. The pull request waits
102
+ * `retryAfterMs` and is claimed again, without a failure or a no-progress strike.
103
+ */
104
+ export declare class BabysitterPlacementCapacityError extends Diagnostic {
105
+ readonly retryAfterMs: number;
106
+ constructor(reason: string, retryAfterMs?: number);
107
+ }
108
+ //#endregion
52
109
  //#region src/babysitter.d.ts
53
110
  export interface BabysitterLifecycleLabels {
54
111
  /** At least one of these labels must be present for the PR to be eligible. */
@@ -68,30 +125,61 @@ export interface BabysitterPlacementLease {
68
125
  }
69
126
  /** Chooses a host for each pass before the Babysitter installs dependencies on this one. */
70
127
  export interface BabysitterPlacement {
128
+ /** Throw `BabysitterPlacementCapacityError` when no host can take the pass now; the PR waits and is claimed again. */
71
129
  place(pullRequest: {
72
130
  repository: string;
73
131
  number: number;
74
132
  }): BabysitterPlacementLease | Promise<BabysitterPlacementLease>;
75
133
  /** Passes currently placed on other hosts. They hold a concurrency slot but no local memory. */
76
134
  remoteActive?(): number;
135
+ /**
136
+ * Slots that hosts admit now, counting passes already running. A reconcile claims at most this
137
+ * many PRs minus the active owners, so it never claims work that `place` must turn away.
138
+ */
139
+ admitted?(): number | Promise<number>;
140
+ }
141
+ /** Where the Babysitter reports its state on each PR. Both need a verified GitHub App identity. */
142
+ export interface BabysitterStatusOptions {
143
+ /** Keep the activity comment on the PR up to date. Defaults to `true`. */
144
+ comment?: boolean;
145
+ /**
146
+ * Mirror the state as a check run named `babysitter` on the PR head: queued, in progress, neutral
147
+ * while waiting, success when done and failure when a pass failed. Its details link opens the
148
+ * Console session. Needs the App's `checks: write` permission; a repository that answers 403 is
149
+ * reported once and skipped. The Babysitter leaves this check out of its own CI and merge decisions,
150
+ * so do not make it a required check. Defaults to `true`.
151
+ */
152
+ checkRun?: boolean;
77
153
  }
78
154
  export interface BabysitterOptions {
79
155
  /** Process admission policy. Concurrency remains the preset hard maximum. */
80
- capacity?: Pick<import("@vite-hub/agent/runtime/process").ProcessAgentCapacityOptions, "memory" | "cpu" | "fallbackConcurrency">;
156
+ capacity?: Pick<import("@vite-hub/agent/process").ProcessAgentCapacityOptions, "memory" | "cpu" | "fallbackConcurrency">;
81
157
  /**
82
158
  * Places each pass on this host or in a Sandbox before host dependency installation. Sandbox passes
83
159
  * skip the host install; the Sandbox installs through `refreshDependencies` when it provides one.
84
160
  */
85
161
  placement?: BabysitterPlacement;
86
- /** Select PRs with the same rules as the GitHub Channel. */
162
+ /**
163
+ * Select PRs with the same rules as the GitHub Channel, with two differences. A PR passes when it
164
+ * matches either `author.allow` or `authorAssociation.allow`; a match on either deny list rejects it.
165
+ * Logins match case-insensitively and in either bot spelling, so `renovate[bot]` also matches `renovate`.
166
+ * Without `repository.allow`, the Babysitter serves every repository that its GitHub App installations
167
+ * can access, except archived ones and those in `repository.deny`, so installing the App on a repository enrolls it.
168
+ * Without `author` or `authorAssociation` rules, only PRs whose author is an owner, member or collaborator are selected.
169
+ */
87
170
  filter: GitHubPullRequestFilter;
88
- /** Additional lifecycle admission rules. Use labels to pause or resume a PR without changing the filter. */
171
+ /**
172
+ * Additional lifecycle admission rules. Use labels to pause or resume a PR without changing the filter.
173
+ * Without these labels or `filter.labels`, a PR labelled `babysitter:skip` is skipped. `{ labels: {} }` turns that off.
174
+ */
89
175
  lifecycle: BabysitterLifecycleOptions;
90
176
  /** Provider Driver that repairs each PR in its checkout. Defaults to `"codex"`. Set the model with `driver.model`. */
91
177
  driver: BuiltInAgentDriverName;
92
178
  /**
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.
179
+ * Merge policy. Defaults to `"direct"`. `false` never merges, and `"auto"` lets the worker request
180
+ * GitHub native auto-merge. `"direct"` merges a ready PR into its default branch before any model
181
+ * pass, and holds a PR from someone without write access until a reviewer with write access approves
182
+ * its current head. Pass `{ strategy: "direct", ready }` with another callback to change that gate.
95
183
  */
96
184
  merge: BabysitterMerge;
97
185
  /**
@@ -105,8 +193,9 @@ export interface BabysitterOptions {
105
193
  */
106
194
  noFindingsReviews: string[];
107
195
  /**
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.
196
+ * Logins whose comments and reviews never need an assessment. Their items do not block a direct
197
+ * merge or wake a waiting PR. Defaults to the deployment preview bots `pkg-pr-new[bot]`,
198
+ * `vercel[bot]`, `cloudflare-workers-and-pages[bot]` and `netlify[bot]`. A list replaces them.
110
199
  */
111
200
  ignoreFeedbackAuthors: string[];
112
201
  /**
@@ -122,13 +211,61 @@ export interface BabysitterOptions {
122
211
  * the reason. `false` disables the budget. Defaults to 3.
123
212
  */
124
213
  reviewPushBudget: number | false;
214
+ /**
215
+ * Heads in a row whose automated review has no valid finding above P2 before automated review settles
216
+ * as if `reviewPushBudget` were spent. Each pass reports the highest class (P0 to P3) in the
217
+ * automated reviews of its head; a P0 or P1 starts the count again. Needs `reviewPushBudget`.
218
+ * `false` disables it. Defaults to `false`.
219
+ */
220
+ minorReviewRounds: number | false;
221
+ /**
222
+ * Review-driven pushes after which each pass is asked to fix a recurring class of review finding at
223
+ * its root instead of patching one more case, or to decline the remaining minor cases. `false`
224
+ * disables it. Defaults to `false`.
225
+ */
226
+ reviewConvergencePushes: number | false;
227
+ /**
228
+ * Unresolved review threads with only bot comments stop blocking a direct merge and stop waking a
229
+ * waiting PR once a pass assessed their comments. A new bot comment still needs a pass, and a thread
230
+ * with a person's comment still blocks. Defaults to `false`; such threads then stop blocking only
231
+ * once automated review settles.
232
+ */
233
+ ignoreAssessedBotThreads: boolean;
125
234
  /**
126
235
  * Model passes on one PR in a rolling 24 hours. After that many, the PR parks until the oldest pass
127
236
  * 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.
237
+ * first failing required check on a head, a merge conflict, and one assessment of a head whose required
238
+ * checks pass still start a pass, and count. A pass that the provider fails within 10 minutes does not
239
+ * count. `false` disables the budget. Defaults to 16.
130
240
  */
131
241
  dailyPassBudget: number | false;
242
+ /**
243
+ * Repair pushes on one PR in a rolling 24 hours. Past it, `pushRepair` refuses a push until the
244
+ * oldest is 24 hours old, and a pass that could only push parks until then. A conflict repair still
245
+ * pushes, and a PR whose required checks fail may push once every two hours. `false` disables the
246
+ * budget. Defaults to `false`.
247
+ */
248
+ dailyPushBudget: number | false;
249
+ /**
250
+ * PR labels that put a PR first in the claim order, after main repairs. A labelled PR is exempt from
251
+ * `dailyPassBudget` and `dailyPushBudget`; checks, reviews and merge gates still apply. Matched
252
+ * case-insensitively. Defaults to none.
253
+ */
254
+ priorityLabels: string[];
255
+ /**
256
+ * Head branch prefix of PRs that repair the base branch, such as `"repair-main-"`. These PRs are
257
+ * claimed before every other PR, and `noProgressBudget` never stops them. Defaults to none.
258
+ */
259
+ mainRepairBranchPrefix?: string;
260
+ /**
261
+ * Open a PR that repairs the default branch when one of `workflows` fails on it. The check runs every
262
+ * 10 minutes per repository, and at once when a failed push run of a watched workflow is delivered.
263
+ * The PR starts with an empty commit on a branch named `mainRepairBranchPrefix` and the red commit's
264
+ * short SHA, so the queue claims it first. One repair PR is open at a time, and a red commit gets
265
+ * one repair branch. Running jobs of watched push runs older than `stuckJobMinutes` are force-cancelled
266
+ * first. Needs `mainRepairBranchPrefix`. Defaults to `false`.
267
+ */
268
+ mainRepair: BabysitterMainRepair | false;
132
269
  /**
133
270
  * Wait for running required checks and review checks before a pass, unless a failure or conflict
134
271
  * already needs repair. One pass then handles CI and review results together. Defaults to `true`.
@@ -143,11 +280,33 @@ export interface BabysitterOptions {
143
280
  install: BabysitterInstall;
144
281
  /** Rerun failed GitHub Actions runs once before a model pass repairs them. Defaults to `true`. */
145
282
  ciRecovery: boolean;
283
+ /**
284
+ * Keep one workspace per open PR under `<dataDir>/pr-workspaces` instead of cloning, copying and
285
+ * installing for every pass. A pass on the head the previous pass pushed or left, after a pass that
286
+ * finished, on a clean tree, keeps node_modules and build caches and skips a current install. Any
287
+ * other pass empties the workspace and checks the head out again. Entries go when the PR closes,
288
+ * after `idleDays` without a pass, and least recently used first above `budgetGb` or below
289
+ * `minFreePercent` free disk. `resumeThreads` also continues the previous pass's provider thread.
290
+ * Passes placed in a Sandbox keep using their own workspace. Defaults to `false`.
291
+ */
292
+ warmWorkspaces: boolean | BabysitterWarmWorkspaces;
293
+ /**
294
+ * Repair a PR whose base is another open PR's branch in parallel with its parent: checks, conflicts
295
+ * and feedback. It never merges into the parent's branch and waits for the parent once its reviewed
296
+ * head has nothing left to repair. Requires `merge: "direct"`. Defaults to `false`, which leaves a
297
+ * stack child unclaimed until its parent merges.
298
+ */
299
+ repairStackChildren: boolean;
146
300
  /**
147
301
  * Model passes that run at the same time. Set it to what the provider accounts can serve; host
148
302
  * work such as merges and stack retargets still uses `concurrency`. Defaults to `concurrency`.
149
303
  */
150
304
  modelConcurrency?: number;
305
+ /**
306
+ * Retries of a provider rate limit, 10 seconds apart, before the pass opens the provider cooldown.
307
+ * Set `0` when the provider already retries, as Codex does. Defaults to 3.
308
+ */
309
+ providerRetries: number;
151
310
  /**
152
311
  * First cooldown after a pass runs out of provider rate-limit retries. Model passes pause; host work
153
312
  * continues. Each further cooldown doubles, up to one hour, and halves model concurrency. A
@@ -164,6 +323,8 @@ export interface BabysitterOptions {
164
323
  * and 4096 MiB of free temporary space.
165
324
  */
166
325
  admission: BabysitterAdmissionOptions;
326
+ /** How the Babysitter reports its state on the PR. Defaults to `{ comment: true, checkRun: true }`. */
327
+ status: BabysitterStatusOptions;
167
328
  }
168
329
  /**
169
330
  * Dependency install before each pass. `true` detects the package manager from the lockfile;
@@ -196,6 +357,12 @@ export type BabysitterInstall = boolean | {
196
357
  * its inputs change. Defaults to `false`.
197
358
  */
198
359
  required?: boolean;
360
+ /**
361
+ * `refreshDependencies` calls per pass. Further calls return a tool error that tells the model to
362
+ * commit its dependency fixes and let hosted CI validate them. Retryable install failures do not
363
+ * count. Defaults to no limit.
364
+ */
365
+ refreshes?: number;
199
366
  };
200
367
  export type BabysitterPassWake = {
201
368
  kind: "checks";
@@ -223,10 +390,12 @@ export interface BabysitterPassResult {
223
390
  reviewedHead?: string;
224
391
  /** Legacy explicit check checkpoint, accepted while existing provider output migrates. */
225
392
  waitForChecksHead?: string;
393
+ /** Highest class of valid finding in the automated reviews of the head the pass started on. Read with `minorReviewRounds`. */
394
+ automatedReview?: AutomatedReviewClass;
226
395
  }
227
396
  export declare const babysitterPassResultSchema: ReturnType<typeof createBabysitterPassResultSchema>;
228
397
  /** A repair workflow. Connections, provider settings and host resources stay in the application. */
229
- type BabysitterDefinition = AgentDefinition<AgentRuntimeConfig, unknown, AgentInvokerProfile, AgentInvocationContextValues, BabysitterPassResult> & {
398
+ type BabysitterDefinition = AgentDefinition<AgentRuntimeConfig, unknown, AgentInvoker, AgentInvocationContextValues, BabysitterPassResult> & {
230
399
  reviewChecks: string[];
231
400
  noFindingsReviews: string[];
232
401
  ignoreFeedbackAuthors: string[];
@@ -239,8 +408,12 @@ type BabysitterDefinition = AgentDefinition<AgentRuntimeConfig, unknown, AgentIn
239
408
  lifecycle: BabysitterLifecycleOptions;
240
409
  };
241
410
  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;
411
+ /**
412
+ * Combines explicit lifecycle labels with the shared GitHub PR filter. A filter without author rules
413
+ * selects only PRs from people with write access, and one without label rules skips PRs labelled
414
+ * `babysitter:skip`.
415
+ */
416
+ export declare function resolveBabysitterLifecycleFilter(configured: GitHubPullRequestFilter, lifecycle: BabysitterLifecycleOptions | undefined): GitHubPullRequestFilter;
244
417
  export declare const babysitter: BabysitterAgent;
245
418
  //#endregion
246
- export type { BabysitterAdmissionOptions, BabysitterAdmissionPause, BabysitterMerge, BabysitterMergeMethod, BabysitterMergeReadinessInput, BabysitterMergeReady };
419
+ 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-C71pgjkv.js";
2
+ export { BabysitterPlacementCapacityError, babysitter, babysitterPassResultSchema, resolveBabysitterLifecycleFilter };