@h-rig/bundle-default-lifecycle 0.0.6-alpha.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -0
  2. package/dist/src/closeoutEquivalence.d.ts +37 -0
  3. package/dist/src/closeoutEquivalence.js +78 -0
  4. package/dist/src/closeoutShadowHarness.d.ts +27 -0
  5. package/dist/src/closeoutShadowHarness.js +29 -0
  6. package/dist/src/defaultPipeline.d.ts +32 -0
  7. package/dist/src/defaultPipeline.js +191 -0
  8. package/dist/src/index.d.ts +16 -0
  9. package/dist/src/index.js +535 -0
  10. package/dist/src/plugin.d.ts +18 -0
  11. package/dist/src/plugin.js +132 -0
  12. package/dist/src/stagedCloseout.d.ts +7 -0
  13. package/dist/src/stagedCloseout.js +325 -0
  14. package/dist/src/stages/auto-merge.d.ts +11 -0
  15. package/dist/src/stages/auto-merge.js +27 -0
  16. package/dist/src/stages/commit.d.ts +11 -0
  17. package/dist/src/stages/commit.js +27 -0
  18. package/dist/src/stages/isolation.d.ts +11 -0
  19. package/dist/src/stages/isolation.js +28 -0
  20. package/dist/src/stages/journal-append.d.ts +7 -0
  21. package/dist/src/stages/journal-append.js +25 -0
  22. package/dist/src/stages/merge-gate.d.ts +1 -0
  23. package/dist/src/stages/merge-gate.js +21 -0
  24. package/dist/src/stages/open-pr.d.ts +9 -0
  25. package/dist/src/stages/open-pr.js +41 -0
  26. package/dist/src/stages/push.d.ts +8 -0
  27. package/dist/src/stages/push.js +27 -0
  28. package/dist/src/stages/source-closeout.d.ts +18 -0
  29. package/dist/src/stages/source-closeout.js +36 -0
  30. package/dist/src/stages/types.d.ts +20 -0
  31. package/dist/src/stages/types.js +12 -0
  32. package/dist/src/stages/validate.d.ts +3 -0
  33. package/dist/src/stages/validate.js +24 -0
  34. package/dist/src/stages/verify.d.ts +7 -0
  35. package/dist/src/stages/verify.js +24 -0
  36. package/package.json +49 -0
@@ -0,0 +1,325 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/stagedCloseout.ts
3
+ import { resolve } from "path";
4
+ import { loadConfig } from "@rig/core/load-config";
5
+ import { buildPluginHostContext } from "@rig/runtime/control-plane/plugin-host-context";
6
+ import { CloseoutValidationError } from "@rig/runtime/control-plane/native/in-process-closeout";
7
+ import { taskValidate } from "@rig/runtime/control-plane/native/task-ops";
8
+
9
+ // packages/bundle-default-lifecycle/src/defaultPipeline.ts
10
+ import { resolveKernelStages } from "@rig/kernel/resolver";
11
+
12
+ // packages/bundle-default-lifecycle/src/stages/auto-merge.ts
13
+ import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automation";
14
+
15
+ // packages/bundle-default-lifecycle/src/stages/types.ts
16
+ function defineDefaultLifecycleStage(input) {
17
+ return {
18
+ ...input,
19
+ protected: input.protected ?? false,
20
+ priority: input.priority ?? 0
21
+ };
22
+ }
23
+
24
+ // packages/bundle-default-lifecycle/src/stages/auto-merge.ts
25
+ var autoMergeStage = defineDefaultLifecycleStage({
26
+ id: "auto-merge",
27
+ kind: "transform",
28
+ description: "Merge an approved PR using the repository default merge method through the runtime helper.",
29
+ calls: ["runRepoDefaultMerge"]
30
+ });
31
+
32
+ // packages/bundle-default-lifecycle/src/stages/commit.ts
33
+ import { commitRunChanges } from "@rig/runtime/control-plane/native/pr-automation";
34
+ var commitStage = defineDefaultLifecycleStage({
35
+ id: "commit",
36
+ kind: "transform",
37
+ description: "Commit the agent worktree changes using the runtime git closeout helper.",
38
+ calls: ["commitRunChanges"]
39
+ });
40
+ async function runCommitStage(input) {
41
+ return await commitRunChanges(input);
42
+ }
43
+
44
+ // packages/bundle-default-lifecycle/src/stages/isolation.ts
45
+ import { ensureAgentRuntime } from "@rig/runtime/control-plane/runtime/isolation";
46
+ var isolationStage = defineDefaultLifecycleStage({
47
+ id: "isolation",
48
+ kind: "transform",
49
+ description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
50
+ calls: ["ensureAgentRuntime"],
51
+ protected: true
52
+ });
53
+
54
+ // packages/bundle-default-lifecycle/src/stages/journal-append.ts
55
+ var journalAppendStage = defineDefaultLifecycleStage({
56
+ id: "journal-append",
57
+ kind: "observe",
58
+ description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
59
+ calls: ["journalCapability.append"],
60
+ protected: true
61
+ });
62
+
63
+ // packages/bundle-default-lifecycle/src/stages/merge-gate.ts
64
+ var mergeGateStage = defineDefaultLifecycleStage({
65
+ id: "merge-gate",
66
+ kind: "gate",
67
+ description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
68
+ calls: ["runStrictPrMergeGate"],
69
+ protected: true
70
+ });
71
+
72
+ // packages/bundle-default-lifecycle/src/stages/open-pr.ts
73
+ import { runPrAutomation } from "@rig/runtime/control-plane/native/pr-automation";
74
+ var openPrStage = defineDefaultLifecycleStage({
75
+ id: "open-pr",
76
+ kind: "transform",
77
+ description: "Open or reuse the closeout PR through the existing runtime PR automation seam.",
78
+ calls: ["runPrAutomation"]
79
+ });
80
+ async function runOpenPrStage(input) {
81
+ return await runPrAutomation({
82
+ projectRoot: input.workspace,
83
+ taskId: input.taskId,
84
+ runId: input.runId,
85
+ branch: input.branch,
86
+ sourceTask: input.sourceTask ? { title: typeof input.sourceTask.title === "string" ? input.sourceTask.title : null } : null,
87
+ command: input.command,
88
+ gitCommand: input.gitCommand,
89
+ steerPi: input.steerPi,
90
+ ...input.config ? { config: input.config } : {},
91
+ ...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
92
+ ...input.greptileApi !== undefined ? { greptileApi: input.greptileApi } : {},
93
+ ...input.lifecycle !== undefined ? { lifecycle: input.lifecycle } : {},
94
+ ...input.uploadedSnapshot !== undefined ? { uploadedSnapshot: input.uploadedSnapshot } : {}
95
+ });
96
+ }
97
+
98
+ // packages/bundle-default-lifecycle/src/stages/push.ts
99
+ import { pushBranchSyncedWithOrigin } from "@rig/runtime/control-plane/native/pr-automation";
100
+ var pushStage = defineDefaultLifecycleStage({
101
+ id: "push",
102
+ kind: "transform",
103
+ description: "Synchronize and push the task branch using the runtime closeout git helper.",
104
+ calls: ["pushBranchSyncedWithOrigin"]
105
+ });
106
+ async function runPushStage(input) {
107
+ await pushBranchSyncedWithOrigin(input);
108
+ }
109
+
110
+ // packages/bundle-default-lifecycle/src/stages/source-closeout.ts
111
+ import { closeIssueAfterMergedPr } from "@rig/runtime/control-plane/native/pr-automation";
112
+ var sourceCloseoutStage = defineDefaultLifecycleStage({
113
+ id: "source-closeout",
114
+ kind: "transform",
115
+ description: "Reflect the merged PR into the task source using the existing runtime closeout helper.",
116
+ calls: ["closeIssueAfterMergedPr"]
117
+ });
118
+ async function runSourceCloseoutStage(input) {
119
+ if (input.pr.status !== "merged" || !input.pr.prUrl)
120
+ return;
121
+ await closeIssueAfterMergedPr({
122
+ projectRoot: input.projectRoot,
123
+ taskId: input.taskId,
124
+ runId: input.runId,
125
+ prUrl: input.pr.prUrl,
126
+ updateTaskSource: input.updateTaskSource,
127
+ ...input.sourceTask !== undefined ? { sourceTask: input.sourceTask } : {}
128
+ });
129
+ }
130
+
131
+ // packages/bundle-default-lifecycle/src/stages/validate.ts
132
+ var validateStage = defineDefaultLifecycleStage({
133
+ id: "validate",
134
+ kind: "transform",
135
+ description: "Run plugin-host validators against the isolated worktree before closeout side effects.",
136
+ calls: ["taskValidate"]
137
+ });
138
+ async function runValidateStage(input, runner) {
139
+ return await runner(input);
140
+ }
141
+
142
+ // packages/bundle-default-lifecycle/src/stages/verify.ts
143
+ var verifyStage = defineDefaultLifecycleStage({
144
+ id: "verify",
145
+ kind: "gate",
146
+ description: "Run the local verifier preflight and block closeout when it rejects the worktree.",
147
+ calls: ["verifierPreflight"]
148
+ });
149
+
150
+ // packages/bundle-default-lifecycle/src/defaultPipeline.ts
151
+ var defaultLifecycleStages = [
152
+ validateStage,
153
+ verifyStage,
154
+ commitStage,
155
+ pushStage,
156
+ openPrStage,
157
+ mergeGateStage,
158
+ autoMergeStage,
159
+ sourceCloseoutStage,
160
+ isolationStage,
161
+ journalAppendStage
162
+ ];
163
+ function resolveDefaultLifecycle(input = {}) {
164
+ const grants = { protectedStageGrants: input.protectedStageGrants ?? [] };
165
+ return resolveKernelStages(defaultLifecycleStages, input.mutations ?? [], grants);
166
+ }
167
+
168
+ // packages/bundle-default-lifecycle/src/stagedCloseout.ts
169
+ function cleanString(value) {
170
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
171
+ }
172
+ function closeoutOutcome(status) {
173
+ switch (status) {
174
+ case "completed":
175
+ return "completed";
176
+ case "failed":
177
+ case "needs-attention":
178
+ return "failed";
179
+ case "pending":
180
+ case "running":
181
+ return "started";
182
+ }
183
+ }
184
+ function normalizePrStatus(status) {
185
+ return status === "needs_attention" ? "needs-attention" : status;
186
+ }
187
+ async function loadRigAutomationConfig(projectRoot) {
188
+ try {
189
+ return await loadConfig(projectRoot);
190
+ } catch {
191
+ return null;
192
+ }
193
+ }
194
+ async function runRigProjectValidation({ projectRoot, taskId }) {
195
+ const pluginHostCtx = await buildPluginHostContext(projectRoot);
196
+ return taskValidate(projectRoot, taskId, pluginHostCtx?.validatorRegistry ?? undefined);
197
+ }
198
+ async function executeStagedCloseout(input) {
199
+ const taskId = cleanString(input.taskId);
200
+ if (!taskId) {
201
+ throw new Error("Staged closeout requires a task id.");
202
+ }
203
+ const loadedConfig = input.config ?? await loadRigAutomationConfig(input.projectRoot);
204
+ const prMode = loadedConfig?.pr?.mode ?? "off";
205
+ const reviewProvider = loadedConfig?.review?.provider ?? "github";
206
+ const effectiveConfig = {
207
+ ...loadedConfig ?? {},
208
+ pr: {
209
+ ...loadedConfig?.pr ?? {},
210
+ mode: prMode
211
+ },
212
+ review: {
213
+ ...loadedConfig?.review ?? {},
214
+ provider: reviewProvider
215
+ }
216
+ };
217
+ const workspace = input.workspace;
218
+ const artifactRoot = input.artifactRoot ?? resolve(input.projectRoot, "artifacts", taskId);
219
+ let branch = input.branch;
220
+ let currentPhase = "queued";
221
+ const journal = async (phase, status, detail) => {
222
+ currentPhase = phase;
223
+ await input.journalPhase(phase, closeoutOutcome(status), detail ?? null);
224
+ };
225
+ const complete = async (result, detail) => {
226
+ await journal("completed", "completed", detail);
227
+ return result;
228
+ };
229
+ try {
230
+ if (prMode === "off" || prMode === "ask") {
231
+ const reason = prMode === "ask" ? "PR creation awaits operator approval." : "PR automation disabled.";
232
+ await input.reflect("under_review", reason);
233
+ return await complete({ status: "skipped", iterations: 0, feedback: [] }, reason);
234
+ }
235
+ await input.onValidationStart?.();
236
+ await journal("queued", "running", `Validating task ${taskId} before closeout.`);
237
+ let validationPassed = false;
238
+ try {
239
+ validationPassed = await runValidateStage({ projectRoot: input.projectRoot, taskId }, input.runValidation ?? runRigProjectValidation);
240
+ } catch (error) {
241
+ const detail2 = `Rig validation failed before closeout: ${error instanceof Error ? error.message : String(error)}`;
242
+ await input.reflect("needs_attention", "Rig validation failed before closeout; commit/push/PR automation is blocked.", { errorText: detail2 });
243
+ throw new CloseoutValidationError(detail2);
244
+ }
245
+ if (!validationPassed) {
246
+ const detail2 = `Rig validation failed for task ${taskId}; closeout blocked before commit.`;
247
+ await input.reflect("needs_attention", "Rig validation failed before closeout; commit/push/PR automation is blocked.", { errorText: detail2 });
248
+ throw new CloseoutValidationError(detail2);
249
+ }
250
+ await journal("queued", "completed", `Validation passed for task ${taskId}.`);
251
+ const workspaceBranch = await input.gitCommand(["rev-parse", "--abbrev-ref", "HEAD"], { cwd: workspace });
252
+ const currentWorkspaceBranch = workspaceBranch.exitCode === 0 ? cleanString(workspaceBranch.stdout) : null;
253
+ if (currentWorkspaceBranch && currentWorkspaceBranch !== "HEAD" && currentWorkspaceBranch !== branch) {
254
+ branch = currentWorkspaceBranch;
255
+ }
256
+ await journal("commit", "running", `Committing changes in ${workspace}.`);
257
+ await runCommitStage({ cwd: workspace, message: `rig: complete task ${taskId}`, command: input.gitCommand });
258
+ await journal("push", "running", `Pushing branch ${branch}.`);
259
+ await runPushStage({ projectRoot: workspace, branch, gitCommand: input.gitCommand });
260
+ await journal("pr-review-merge", "running", `Opening and merging a pull request for ${branch}.`);
261
+ const pr = await runOpenPrStage({
262
+ ...input,
263
+ taskId,
264
+ branch,
265
+ artifactRoot,
266
+ config: effectiveConfig,
267
+ sourceTask: { title: cleanString(input.sourceTask?.title) },
268
+ lifecycle: {
269
+ onPrOpened: async ({ prUrl }) => {
270
+ await journal("pr-opened", "running", prUrl);
271
+ await input.reflect("under_review", "Rig opened a pull request for this task.");
272
+ },
273
+ onFeedback: async ({ feedback }) => {
274
+ await input.reflect("ci_fixing", "Rig is fixing CI/review feedback for this task.", { errorText: feedback.join(`
275
+ `) || null });
276
+ },
277
+ onMergeStarted: async ({ prUrl }) => {
278
+ await journal("merge", "running", prUrl);
279
+ await input.reflect("merging", "Rig is merging the pull request for this task.");
280
+ },
281
+ onMerged: async ({ prUrl }) => {
282
+ await journal("close-source", "running", prUrl);
283
+ }
284
+ }
285
+ });
286
+ if (pr.status === "merged" && pr.prUrl) {
287
+ await runSourceCloseoutStage({
288
+ projectRoot: input.projectRoot,
289
+ taskId,
290
+ runId: input.runId,
291
+ pr,
292
+ ...input.sourceTask !== undefined ? { sourceTask: input.sourceTask } : {},
293
+ updateTaskSource: async () => {
294
+ await input.reflect("closed", "Rig merged the pull request and closed this task source.");
295
+ return { updated: true, taskId, status: "closed", source: "runtime", sourceKind: "runtime" };
296
+ }
297
+ });
298
+ return await complete({ status: "merged", prUrl: pr.prUrl, iterations: pr.iterations, feedback: pr.actionableFeedback }, `PR merged and issue closed: ${pr.prUrl}`);
299
+ }
300
+ if (pr.status === "opened" && pr.prUrl) {
301
+ return await complete({ status: "opened", prUrl: pr.prUrl, iterations: pr.iterations, feedback: pr.actionableFeedback }, `PR ready without merge: ${pr.prUrl}`);
302
+ }
303
+ const detail = pr.actionableFeedback.join(`
304
+ `) || "PR automation did not merge the PR.";
305
+ await input.reflect("needs_attention", "Rig needs operator attention before this task can proceed.", { errorText: detail });
306
+ await journal("pr-review-merge", "needs-attention", detail);
307
+ return { status: normalizePrStatus(pr.status), ...pr.prUrl ? { prUrl: pr.prUrl } : {}, iterations: pr.iterations, feedback: pr.actionableFeedback };
308
+ } catch (error) {
309
+ const detail = error instanceof Error ? error.message : String(error);
310
+ await journal(currentPhase, "failed", detail);
311
+ throw error;
312
+ }
313
+ }
314
+ async function runStagedCloseout(input) {
315
+ const resolved = resolveDefaultLifecycle();
316
+ const result = await executeStagedCloseout(input);
317
+ return {
318
+ mode: "staged",
319
+ pipelineStageIds: [...resolved.order],
320
+ result
321
+ };
322
+ }
323
+ export {
324
+ runStagedCloseout
325
+ };
@@ -0,0 +1,11 @@
1
+ import { type GitHubCommandRunner, type RigAutomationConfig } from "@rig/runtime/control-plane/native/pr-automation";
2
+ import type { StrictPrMergeGateResult } from "@rig/runtime/control-plane/native/pr-review-gate";
3
+ export type AutoMergeStageInput = {
4
+ readonly prUrl: string;
5
+ readonly config?: RigAutomationConfig;
6
+ readonly command: GitHubCommandRunner;
7
+ readonly cwd?: string;
8
+ readonly strictGate: StrictPrMergeGateResult;
9
+ };
10
+ export declare const autoMergeStage: import("./types").DefaultLifecycleStageDescriptor;
11
+ export declare function runAutoMergeStage(input: AutoMergeStageInput): Promise<void>;
@@ -0,0 +1,27 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/stages/auto-merge.ts
3
+ import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automation";
4
+
5
+ // packages/bundle-default-lifecycle/src/stages/types.ts
6
+ function defineDefaultLifecycleStage(input) {
7
+ return {
8
+ ...input,
9
+ protected: input.protected ?? false,
10
+ priority: input.priority ?? 0
11
+ };
12
+ }
13
+
14
+ // packages/bundle-default-lifecycle/src/stages/auto-merge.ts
15
+ var autoMergeStage = defineDefaultLifecycleStage({
16
+ id: "auto-merge",
17
+ kind: "transform",
18
+ description: "Merge an approved PR using the repository default merge method through the runtime helper.",
19
+ calls: ["runRepoDefaultMerge"]
20
+ });
21
+ async function runAutoMergeStage(input) {
22
+ await runRepoDefaultMerge(input);
23
+ }
24
+ export {
25
+ runAutoMergeStage,
26
+ autoMergeStage
27
+ };
@@ -0,0 +1,11 @@
1
+ import { type GitCommandRunner } from "@rig/runtime/control-plane/native/pr-automation";
2
+ export type CommitStageInput = {
3
+ readonly cwd: string;
4
+ readonly message: string;
5
+ readonly command: GitCommandRunner;
6
+ };
7
+ export declare const commitStage: import("./types").DefaultLifecycleStageDescriptor;
8
+ export declare function runCommitStage(input: CommitStageInput): Promise<{
9
+ readonly committed: boolean;
10
+ readonly status: string;
11
+ }>;
@@ -0,0 +1,27 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/stages/commit.ts
3
+ import { commitRunChanges } from "@rig/runtime/control-plane/native/pr-automation";
4
+
5
+ // packages/bundle-default-lifecycle/src/stages/types.ts
6
+ function defineDefaultLifecycleStage(input) {
7
+ return {
8
+ ...input,
9
+ protected: input.protected ?? false,
10
+ priority: input.priority ?? 0
11
+ };
12
+ }
13
+
14
+ // packages/bundle-default-lifecycle/src/stages/commit.ts
15
+ var commitStage = defineDefaultLifecycleStage({
16
+ id: "commit",
17
+ kind: "transform",
18
+ description: "Commit the agent worktree changes using the runtime git closeout helper.",
19
+ calls: ["commitRunChanges"]
20
+ });
21
+ async function runCommitStage(input) {
22
+ return await commitRunChanges(input);
23
+ }
24
+ export {
25
+ runCommitStage,
26
+ commitStage
27
+ };
@@ -0,0 +1,11 @@
1
+ import { type AgentRuntime, type IsolationMode } from "@rig/runtime/control-plane/runtime/isolation";
2
+ export type IsolationStageInput = {
3
+ readonly projectRoot: string;
4
+ readonly id: string;
5
+ readonly taskId: string;
6
+ readonly mode: IsolationMode;
7
+ readonly provider?: "pi";
8
+ readonly preserveTaskArtifacts?: boolean;
9
+ };
10
+ export declare const isolationStage: import("./types").DefaultLifecycleStageDescriptor;
11
+ export declare function runIsolationStage(input: IsolationStageInput): Promise<AgentRuntime>;
@@ -0,0 +1,28 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/stages/isolation.ts
3
+ import { ensureAgentRuntime } from "@rig/runtime/control-plane/runtime/isolation";
4
+
5
+ // packages/bundle-default-lifecycle/src/stages/types.ts
6
+ function defineDefaultLifecycleStage(input) {
7
+ return {
8
+ ...input,
9
+ protected: input.protected ?? false,
10
+ priority: input.priority ?? 0
11
+ };
12
+ }
13
+
14
+ // packages/bundle-default-lifecycle/src/stages/isolation.ts
15
+ var isolationStage = defineDefaultLifecycleStage({
16
+ id: "isolation",
17
+ kind: "transform",
18
+ description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
19
+ calls: ["ensureAgentRuntime"],
20
+ protected: true
21
+ });
22
+ async function runIsolationStage(input) {
23
+ return await ensureAgentRuntime(input);
24
+ }
25
+ export {
26
+ runIsolationStage,
27
+ isolationStage
28
+ };
@@ -0,0 +1,7 @@
1
+ import type { JournalCapability, RunJournalEventInit } from "@rig/contracts";
2
+ export type JournalAppendStageInput = {
3
+ readonly journal: JournalCapability;
4
+ readonly event: RunJournalEventInit;
5
+ };
6
+ export declare const journalAppendStage: import("./types").DefaultLifecycleStageDescriptor;
7
+ export declare function runJournalAppendStage(input: JournalAppendStageInput): Promise<void>;
@@ -0,0 +1,25 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/stages/types.ts
3
+ function defineDefaultLifecycleStage(input) {
4
+ return {
5
+ ...input,
6
+ protected: input.protected ?? false,
7
+ priority: input.priority ?? 0
8
+ };
9
+ }
10
+
11
+ // packages/bundle-default-lifecycle/src/stages/journal-append.ts
12
+ var journalAppendStage = defineDefaultLifecycleStage({
13
+ id: "journal-append",
14
+ kind: "observe",
15
+ description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
16
+ calls: ["journalCapability.append"],
17
+ protected: true
18
+ });
19
+ async function runJournalAppendStage(input) {
20
+ await input.journal.append(input.event);
21
+ }
22
+ export {
23
+ runJournalAppendStage,
24
+ journalAppendStage
25
+ };
@@ -0,0 +1 @@
1
+ export declare const mergeGateStage: import("./types").DefaultLifecycleStageDescriptor;
@@ -0,0 +1,21 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/stages/types.ts
3
+ function defineDefaultLifecycleStage(input) {
4
+ return {
5
+ ...input,
6
+ protected: input.protected ?? false,
7
+ priority: input.priority ?? 0
8
+ };
9
+ }
10
+
11
+ // packages/bundle-default-lifecycle/src/stages/merge-gate.ts
12
+ var mergeGateStage = defineDefaultLifecycleStage({
13
+ id: "merge-gate",
14
+ kind: "gate",
15
+ description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
16
+ calls: ["runStrictPrMergeGate"],
17
+ protected: true
18
+ });
19
+ export {
20
+ mergeGateStage
21
+ };
@@ -0,0 +1,9 @@
1
+ import { type PrAutomationLifecycle, type PrAutomationResult, type RigAutomationConfig } from "@rig/runtime/control-plane/native/pr-automation";
2
+ import type { InProcessCloseoutInput } from "@rig/runtime/control-plane/native/in-process-closeout";
3
+ export type OpenPrStageInput = Omit<InProcessCloseoutInput, "config"> & {
4
+ readonly config?: RigAutomationConfig;
5
+ readonly lifecycle?: PrAutomationLifecycle;
6
+ readonly uploadedSnapshot?: boolean;
7
+ };
8
+ export declare const openPrStage: import("./types").DefaultLifecycleStageDescriptor;
9
+ export declare function runOpenPrStage(input: OpenPrStageInput): Promise<PrAutomationResult>;
@@ -0,0 +1,41 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/stages/open-pr.ts
3
+ import { runPrAutomation } from "@rig/runtime/control-plane/native/pr-automation";
4
+
5
+ // packages/bundle-default-lifecycle/src/stages/types.ts
6
+ function defineDefaultLifecycleStage(input) {
7
+ return {
8
+ ...input,
9
+ protected: input.protected ?? false,
10
+ priority: input.priority ?? 0
11
+ };
12
+ }
13
+
14
+ // packages/bundle-default-lifecycle/src/stages/open-pr.ts
15
+ var openPrStage = defineDefaultLifecycleStage({
16
+ id: "open-pr",
17
+ kind: "transform",
18
+ description: "Open or reuse the closeout PR through the existing runtime PR automation seam.",
19
+ calls: ["runPrAutomation"]
20
+ });
21
+ async function runOpenPrStage(input) {
22
+ return await runPrAutomation({
23
+ projectRoot: input.workspace,
24
+ taskId: input.taskId,
25
+ runId: input.runId,
26
+ branch: input.branch,
27
+ sourceTask: input.sourceTask ? { title: typeof input.sourceTask.title === "string" ? input.sourceTask.title : null } : null,
28
+ command: input.command,
29
+ gitCommand: input.gitCommand,
30
+ steerPi: input.steerPi,
31
+ ...input.config ? { config: input.config } : {},
32
+ ...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
33
+ ...input.greptileApi !== undefined ? { greptileApi: input.greptileApi } : {},
34
+ ...input.lifecycle !== undefined ? { lifecycle: input.lifecycle } : {},
35
+ ...input.uploadedSnapshot !== undefined ? { uploadedSnapshot: input.uploadedSnapshot } : {}
36
+ });
37
+ }
38
+ export {
39
+ runOpenPrStage,
40
+ openPrStage
41
+ };
@@ -0,0 +1,8 @@
1
+ import { type GitCommandRunner } from "@rig/runtime/control-plane/native/pr-automation";
2
+ export type PushStageInput = {
3
+ readonly projectRoot: string;
4
+ readonly branch: string;
5
+ readonly gitCommand: GitCommandRunner;
6
+ };
7
+ export declare const pushStage: import("./types").DefaultLifecycleStageDescriptor;
8
+ export declare function runPushStage(input: PushStageInput): Promise<void>;
@@ -0,0 +1,27 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/stages/push.ts
3
+ import { pushBranchSyncedWithOrigin } from "@rig/runtime/control-plane/native/pr-automation";
4
+
5
+ // packages/bundle-default-lifecycle/src/stages/types.ts
6
+ function defineDefaultLifecycleStage(input) {
7
+ return {
8
+ ...input,
9
+ protected: input.protected ?? false,
10
+ priority: input.priority ?? 0
11
+ };
12
+ }
13
+
14
+ // packages/bundle-default-lifecycle/src/stages/push.ts
15
+ var pushStage = defineDefaultLifecycleStage({
16
+ id: "push",
17
+ kind: "transform",
18
+ description: "Synchronize and push the task branch using the runtime closeout git helper.",
19
+ calls: ["pushBranchSyncedWithOrigin"]
20
+ });
21
+ async function runPushStage(input) {
22
+ await pushBranchSyncedWithOrigin(input);
23
+ }
24
+ export {
25
+ runPushStage,
26
+ pushStage
27
+ };
@@ -0,0 +1,18 @@
1
+ import { type PrAutomationResult } from "@rig/runtime/control-plane/native/pr-automation";
2
+ export type SourceCloseoutStageInput = {
3
+ readonly projectRoot: string;
4
+ readonly taskId: string;
5
+ readonly runId: string;
6
+ readonly pr: PrAutomationResult;
7
+ readonly sourceTask?: Record<string, unknown> | null;
8
+ readonly updateTaskSource: (projectRoot: string, input: {
9
+ readonly taskId: string;
10
+ readonly sourceTask?: Record<string, unknown> | null;
11
+ readonly update: {
12
+ readonly status: "closed";
13
+ readonly comment: string;
14
+ };
15
+ }) => Promise<unknown>;
16
+ };
17
+ export declare const sourceCloseoutStage: import("./types").DefaultLifecycleStageDescriptor;
18
+ export declare function runSourceCloseoutStage(input: SourceCloseoutStageInput): Promise<void>;
@@ -0,0 +1,36 @@
1
+ // @bun
2
+ // packages/bundle-default-lifecycle/src/stages/source-closeout.ts
3
+ import { closeIssueAfterMergedPr } from "@rig/runtime/control-plane/native/pr-automation";
4
+
5
+ // packages/bundle-default-lifecycle/src/stages/types.ts
6
+ function defineDefaultLifecycleStage(input) {
7
+ return {
8
+ ...input,
9
+ protected: input.protected ?? false,
10
+ priority: input.priority ?? 0
11
+ };
12
+ }
13
+
14
+ // packages/bundle-default-lifecycle/src/stages/source-closeout.ts
15
+ var sourceCloseoutStage = defineDefaultLifecycleStage({
16
+ id: "source-closeout",
17
+ kind: "transform",
18
+ description: "Reflect the merged PR into the task source using the existing runtime closeout helper.",
19
+ calls: ["closeIssueAfterMergedPr"]
20
+ });
21
+ async function runSourceCloseoutStage(input) {
22
+ if (input.pr.status !== "merged" || !input.pr.prUrl)
23
+ return;
24
+ await closeIssueAfterMergedPr({
25
+ projectRoot: input.projectRoot,
26
+ taskId: input.taskId,
27
+ runId: input.runId,
28
+ prUrl: input.pr.prUrl,
29
+ updateTaskSource: input.updateTaskSource,
30
+ ...input.sourceTask !== undefined ? { sourceTask: input.sourceTask } : {}
31
+ });
32
+ }
33
+ export {
34
+ sourceCloseoutStage,
35
+ runSourceCloseoutStage
36
+ };