@h-rig/bundle-default-lifecycle 0.0.6-alpha.135 → 0.0.6-alpha.137
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/dist/src/cli.d.ts +27 -0
- package/dist/src/cli.js +279 -0
- package/dist/src/defaultPipeline.d.ts +16 -5
- package/dist/src/defaultPipeline.js +52 -15
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +387 -125
- package/dist/src/pipelineCloseout.d.ts +14 -0
- package/dist/src/pipelineCloseout.js +633 -0
- package/dist/src/plugin.d.ts +7 -6
- package/dist/src/plugin.js +191 -11
- package/dist/src/stages/auto-merge.js +0 -1
- package/dist/src/stages/commit.js +0 -1
- package/dist/src/stages/isolation.js +1 -3
- package/dist/src/stages/journal-append.js +1 -3
- package/dist/src/stages/merge-gate.d.ts +23 -0
- package/dist/src/stages/merge-gate.js +22 -3
- package/dist/src/stages/open-pr.js +0 -1
- package/dist/src/stages/push.js +0 -1
- package/dist/src/stages/source-closeout.js +0 -1
- package/dist/src/stages/types.d.ts +0 -2
- package/dist/src/stages/types.js +0 -1
- package/dist/src/stages/validate.js +0 -1
- package/dist/src/stages/verify.js +0 -1
- package/package.json +8 -8
- package/dist/src/stagedCloseout.d.ts +0 -7
- package/dist/src/stagedCloseout.js +0 -325
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RuntimeCliContext } from "@rig/core";
|
|
2
|
+
export declare const DEFAULT_PIPELINE_CLI_ID = "default-lifecycle.pipeline";
|
|
3
|
+
export declare const DEFAULT_KERNEL_CLI_ID = "default-lifecycle.kernel";
|
|
4
|
+
type CommandOutcome = {
|
|
5
|
+
readonly ok: boolean;
|
|
6
|
+
readonly group: string;
|
|
7
|
+
readonly command: string;
|
|
8
|
+
readonly details?: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
export declare function executePipeline(context: RuntimeCliContext, args: readonly string[]): Promise<CommandOutcome>;
|
|
11
|
+
export declare function executeKernel(context: RuntimeCliContext, args: readonly string[]): Promise<CommandOutcome>;
|
|
12
|
+
export declare const defaultLifecycleCliCommands: readonly [{
|
|
13
|
+
readonly id: "default-lifecycle.pipeline";
|
|
14
|
+
readonly family: "pipeline";
|
|
15
|
+
readonly command: "rig pipeline show [--json]";
|
|
16
|
+
readonly description: "Show the resolved default lifecycle pipeline.";
|
|
17
|
+
readonly usage: "rig pipeline show [--json]";
|
|
18
|
+
readonly run: typeof executePipeline;
|
|
19
|
+
}, {
|
|
20
|
+
readonly id: "default-lifecycle.kernel";
|
|
21
|
+
readonly family: "kernel";
|
|
22
|
+
readonly command: "rig kernel status [--json]";
|
|
23
|
+
readonly description: "Show default kernel provider and lifecycle status.";
|
|
24
|
+
readonly usage: "rig kernel status [--json]";
|
|
25
|
+
readonly run: typeof executeKernel;
|
|
26
|
+
}];
|
|
27
|
+
export {};
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/bundle-default-lifecycle/src/defaultPipeline.ts
|
|
3
|
+
import { resolveKernelStages } from "@rig/kernel/resolver";
|
|
4
|
+
import { createDefaultKernelPlugin } from "@rig/kernel/default-kernel";
|
|
5
|
+
|
|
6
|
+
// packages/bundle-default-lifecycle/src/stages/auto-merge.ts
|
|
7
|
+
import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automation";
|
|
8
|
+
|
|
9
|
+
// packages/bundle-default-lifecycle/src/stages/types.ts
|
|
10
|
+
function defineDefaultLifecycleStage(input) {
|
|
11
|
+
return {
|
|
12
|
+
...input,
|
|
13
|
+
priority: input.priority ?? 0
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// packages/bundle-default-lifecycle/src/stages/auto-merge.ts
|
|
18
|
+
var autoMergeStage = defineDefaultLifecycleStage({
|
|
19
|
+
id: "auto-merge",
|
|
20
|
+
kind: "transform",
|
|
21
|
+
description: "Merge an approved PR using the repository default merge method through the runtime helper.",
|
|
22
|
+
calls: ["runRepoDefaultMerge"]
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// packages/bundle-default-lifecycle/src/stages/commit.ts
|
|
26
|
+
import { commitRunChanges } from "@rig/runtime/control-plane/native/pr-automation";
|
|
27
|
+
var commitStage = defineDefaultLifecycleStage({
|
|
28
|
+
id: "commit",
|
|
29
|
+
kind: "transform",
|
|
30
|
+
description: "Commit the agent worktree changes using the runtime git closeout helper.",
|
|
31
|
+
calls: ["commitRunChanges"]
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// packages/bundle-default-lifecycle/src/stages/isolation.ts
|
|
35
|
+
import { ensureAgentRuntime } from "@rig/runtime/control-plane/runtime/isolation";
|
|
36
|
+
var isolationStage = defineDefaultLifecycleStage({
|
|
37
|
+
id: "isolation",
|
|
38
|
+
kind: "transform",
|
|
39
|
+
description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
|
|
40
|
+
calls: ["ensureAgentRuntime"]
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// packages/bundle-default-lifecycle/src/stages/journal-append.ts
|
|
44
|
+
var journalAppendStage = defineDefaultLifecycleStage({
|
|
45
|
+
id: "journal-append",
|
|
46
|
+
kind: "observe",
|
|
47
|
+
description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
|
|
48
|
+
calls: ["journalCapability.append"]
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// packages/bundle-default-lifecycle/src/stages/merge-gate.ts
|
|
52
|
+
import {
|
|
53
|
+
runStrictPrMergeGate
|
|
54
|
+
} from "@rig/runtime/control-plane/native/pr-review-gate";
|
|
55
|
+
var mergeGateStage = defineDefaultLifecycleStage({
|
|
56
|
+
id: "merge-gate",
|
|
57
|
+
kind: "gate",
|
|
58
|
+
description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
|
|
59
|
+
calls: ["runStrictPrMergeGate"]
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// packages/bundle-default-lifecycle/src/stages/open-pr.ts
|
|
63
|
+
import { runPrAutomation } from "@rig/runtime/control-plane/native/pr-automation";
|
|
64
|
+
var openPrStage = defineDefaultLifecycleStage({
|
|
65
|
+
id: "open-pr",
|
|
66
|
+
kind: "transform",
|
|
67
|
+
description: "Open or reuse the closeout PR through the existing runtime PR automation seam.",
|
|
68
|
+
calls: ["runPrAutomation"]
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// packages/bundle-default-lifecycle/src/stages/push.ts
|
|
72
|
+
import { pushBranchSyncedWithOrigin } from "@rig/runtime/control-plane/native/pr-automation";
|
|
73
|
+
var pushStage = defineDefaultLifecycleStage({
|
|
74
|
+
id: "push",
|
|
75
|
+
kind: "transform",
|
|
76
|
+
description: "Synchronize and push the task branch using the runtime closeout git helper.",
|
|
77
|
+
calls: ["pushBranchSyncedWithOrigin"]
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// packages/bundle-default-lifecycle/src/stages/source-closeout.ts
|
|
81
|
+
import { closeIssueAfterMergedPr } from "@rig/runtime/control-plane/native/pr-automation";
|
|
82
|
+
var sourceCloseoutStage = defineDefaultLifecycleStage({
|
|
83
|
+
id: "source-closeout",
|
|
84
|
+
kind: "transform",
|
|
85
|
+
description: "Reflect the merged PR into the task source using the existing runtime closeout helper.",
|
|
86
|
+
calls: ["closeIssueAfterMergedPr"]
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// packages/bundle-default-lifecycle/src/stages/validate.ts
|
|
90
|
+
var validateStage = defineDefaultLifecycleStage({
|
|
91
|
+
id: "validate",
|
|
92
|
+
kind: "transform",
|
|
93
|
+
description: "Run plugin-host validators against the isolated worktree before closeout side effects.",
|
|
94
|
+
calls: ["taskValidate"]
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// packages/bundle-default-lifecycle/src/stages/verify.ts
|
|
98
|
+
var verifyStage = defineDefaultLifecycleStage({
|
|
99
|
+
id: "verify",
|
|
100
|
+
kind: "gate",
|
|
101
|
+
description: "Run the local verifier preflight and block closeout when it rejects the worktree.",
|
|
102
|
+
calls: ["verifierPreflight"]
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// packages/bundle-default-lifecycle/src/defaultPipeline.ts
|
|
106
|
+
var DEFAULT_STAGE_AFTER = {
|
|
107
|
+
verify: ["validate"],
|
|
108
|
+
commit: ["verify"],
|
|
109
|
+
push: ["commit"],
|
|
110
|
+
"open-pr": ["push"],
|
|
111
|
+
"merge-gate": ["open-pr"],
|
|
112
|
+
"auto-merge": ["merge-gate"],
|
|
113
|
+
"source-closeout": ["auto-merge"],
|
|
114
|
+
isolation: ["source-closeout"],
|
|
115
|
+
"journal-append": ["isolation"]
|
|
116
|
+
};
|
|
117
|
+
function withDefaultAnchors(stage) {
|
|
118
|
+
const after = DEFAULT_STAGE_AFTER[stage.id];
|
|
119
|
+
return after ? { ...stage, after } : stage;
|
|
120
|
+
}
|
|
121
|
+
var defaultLifecycleStages = [
|
|
122
|
+
validateStage,
|
|
123
|
+
verifyStage,
|
|
124
|
+
commitStage,
|
|
125
|
+
pushStage,
|
|
126
|
+
openPrStage,
|
|
127
|
+
mergeGateStage,
|
|
128
|
+
autoMergeStage,
|
|
129
|
+
sourceCloseoutStage,
|
|
130
|
+
isolationStage,
|
|
131
|
+
journalAppendStage
|
|
132
|
+
].map(withDefaultAnchors);
|
|
133
|
+
function resolveDefaultLifecycle(input = {}) {
|
|
134
|
+
return resolveKernelStages(defaultLifecycleStages, input.mutations ?? []);
|
|
135
|
+
}
|
|
136
|
+
function defaultPipelineShowData(input = {}) {
|
|
137
|
+
const resolved = resolveDefaultLifecycle(input);
|
|
138
|
+
const orderIndex = new Map(resolved.order.map((id, index) => [id, index + 1]));
|
|
139
|
+
const stages = resolved.record.map((entry) => ({
|
|
140
|
+
index: orderIndex.get(entry.stageId) ?? null,
|
|
141
|
+
id: entry.stageId,
|
|
142
|
+
contributedBy: entry.contributedBy,
|
|
143
|
+
...entry.removedBy !== undefined ? { removedBy: entry.removedBy } : {},
|
|
144
|
+
...entry.replacedBy !== undefined ? { replacedBy: entry.replacedBy } : {},
|
|
145
|
+
wrappedBy: entry.wrappedBy ?? [],
|
|
146
|
+
droppedAnchors: entry.droppedAnchors ?? []
|
|
147
|
+
}));
|
|
148
|
+
return {
|
|
149
|
+
title: `resolved run pipeline (${resolved.order.length} stages)`,
|
|
150
|
+
stageCount: resolved.order.length,
|
|
151
|
+
stages,
|
|
152
|
+
droppedAnchors: stages.flatMap((stage) => stage.droppedAnchors.map((anchor) => `${stage.id}:${anchor}`)),
|
|
153
|
+
cycles: resolved.cycles,
|
|
154
|
+
...resolved.resolvedAt !== undefined ? { resolvedAt: resolved.resolvedAt } : {}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function defaultKernelStatusData() {
|
|
158
|
+
const plugin = createDefaultKernelPlugin();
|
|
159
|
+
const resolved = resolveDefaultLifecycle();
|
|
160
|
+
const capabilities = {};
|
|
161
|
+
for (const capability of plugin.provides)
|
|
162
|
+
capabilities[capability] = plugin.meta.id;
|
|
163
|
+
return {
|
|
164
|
+
kernelProviderId: plugin.meta.id,
|
|
165
|
+
kernelVersion: plugin.meta.version,
|
|
166
|
+
capabilities,
|
|
167
|
+
pipelineStageCount: resolved.order.length,
|
|
168
|
+
stageOrder: [...resolved.order]
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function formatKernelStatus(data = defaultKernelStatusData()) {
|
|
172
|
+
const lines = [
|
|
173
|
+
`kernel: ${data.kernelProviderId} v${data.kernelVersion}`,
|
|
174
|
+
"capabilities (resolved provider):",
|
|
175
|
+
...Object.entries(data.capabilities).map(([cap, provider]) => ` ${cap.padEnd(14)} ${provider}`),
|
|
176
|
+
`lifecycle stages: mutable`,
|
|
177
|
+
`resolved pipeline (${data.pipelineStageCount} stages): ${data.stageOrder.join(" -> ")}`
|
|
178
|
+
];
|
|
179
|
+
return lines.join(`
|
|
180
|
+
`);
|
|
181
|
+
}
|
|
182
|
+
function formatDefaultPipelineShow(input = {}) {
|
|
183
|
+
const data = defaultPipelineShowData(input);
|
|
184
|
+
const lines = [`${data.title}:`];
|
|
185
|
+
for (const stage of data.stages) {
|
|
186
|
+
if (stage.removedBy) {
|
|
187
|
+
lines.push(` - ${stage.id.padEnd(20)} [${stage.contributedBy}] removed by [${stage.removedBy}]`);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const ordinal = stage.index === null ? " -." : `${String(stage.index).padStart(2)}.`;
|
|
191
|
+
const annotations = [
|
|
192
|
+
stage.replacedBy ? `replaced by [${stage.replacedBy}]` : "",
|
|
193
|
+
stage.wrappedBy.length > 0 ? `wrapped by [${stage.wrappedBy.join(", ")}]` : ""
|
|
194
|
+
].filter(Boolean);
|
|
195
|
+
lines.push(` ${ordinal} ${stage.id.padEnd(20)} [${stage.contributedBy}]${annotations.length > 0 ? ` ${annotations.join(" ")}` : ""}`);
|
|
196
|
+
}
|
|
197
|
+
lines.push(`dropped anchors: ${data.droppedAnchors.length > 0 ? data.droppedAnchors.join(", ") : "none"} cycles: ${data.cycles.length > 0 ? data.cycles.map((cycle) => cycle.join(" -> ")).join(", ") : "none"}`);
|
|
198
|
+
return lines.join(`
|
|
199
|
+
`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// packages/bundle-default-lifecycle/src/cli.ts
|
|
203
|
+
var DEFAULT_PIPELINE_CLI_ID = "default-lifecycle.pipeline";
|
|
204
|
+
var DEFAULT_KERNEL_CLI_ID = "default-lifecycle.kernel";
|
|
205
|
+
function printJson(value) {
|
|
206
|
+
console.log(JSON.stringify(value, null, 2));
|
|
207
|
+
}
|
|
208
|
+
function takeFlag(args, flag) {
|
|
209
|
+
const rest = [...args];
|
|
210
|
+
const index = rest.indexOf(flag);
|
|
211
|
+
if (index < 0)
|
|
212
|
+
return { value: false, rest };
|
|
213
|
+
rest.splice(index, 1);
|
|
214
|
+
return { value: true, rest };
|
|
215
|
+
}
|
|
216
|
+
function requireNoExtraArgs(args, usage) {
|
|
217
|
+
if (args.length > 0)
|
|
218
|
+
throw new Error(`Unexpected argument: ${args[0]}
|
|
219
|
+
Usage: ${usage}`);
|
|
220
|
+
}
|
|
221
|
+
async function executePipeline(context, args) {
|
|
222
|
+
const [first = "show", ...rest] = args;
|
|
223
|
+
const command = first.startsWith("-") ? "show" : first;
|
|
224
|
+
const commandArgs = first.startsWith("-") ? args : rest;
|
|
225
|
+
if (command !== "show")
|
|
226
|
+
throw new Error(`Unknown pipeline command: ${command}`);
|
|
227
|
+
const json = takeFlag(commandArgs, "--json");
|
|
228
|
+
requireNoExtraArgs(json.rest, "rig pipeline show [--json]");
|
|
229
|
+
const details = defaultPipelineShowData();
|
|
230
|
+
if (context.outputMode === "text") {
|
|
231
|
+
if (json.value)
|
|
232
|
+
printJson(details);
|
|
233
|
+
else
|
|
234
|
+
console.log(formatDefaultPipelineShow());
|
|
235
|
+
}
|
|
236
|
+
return { ok: true, group: "pipeline", command: "show", details };
|
|
237
|
+
}
|
|
238
|
+
async function executeKernel(context, args) {
|
|
239
|
+
const [first = "status", ...rest] = args;
|
|
240
|
+
const command = first.startsWith("-") ? "status" : first;
|
|
241
|
+
const commandArgs = first.startsWith("-") ? args : rest;
|
|
242
|
+
if (command !== "status")
|
|
243
|
+
throw new Error(`Unknown kernel command: ${command}`);
|
|
244
|
+
const json = takeFlag(commandArgs, "--json");
|
|
245
|
+
requireNoExtraArgs(json.rest, "rig kernel status [--json]");
|
|
246
|
+
const details = defaultKernelStatusData();
|
|
247
|
+
if (context.outputMode === "text") {
|
|
248
|
+
if (json.value)
|
|
249
|
+
printJson(details);
|
|
250
|
+
else
|
|
251
|
+
console.log(formatKernelStatus(details));
|
|
252
|
+
}
|
|
253
|
+
return { ok: true, group: "kernel", command: "status", details };
|
|
254
|
+
}
|
|
255
|
+
var defaultLifecycleCliCommands = [
|
|
256
|
+
{
|
|
257
|
+
id: DEFAULT_PIPELINE_CLI_ID,
|
|
258
|
+
family: "pipeline",
|
|
259
|
+
command: "rig pipeline show [--json]",
|
|
260
|
+
description: "Show the resolved default lifecycle pipeline.",
|
|
261
|
+
usage: "rig pipeline show [--json]",
|
|
262
|
+
run: executePipeline
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
id: DEFAULT_KERNEL_CLI_ID,
|
|
266
|
+
family: "kernel",
|
|
267
|
+
command: "rig kernel status [--json]",
|
|
268
|
+
description: "Show default kernel provider and lifecycle status.",
|
|
269
|
+
usage: "rig kernel status [--json]",
|
|
270
|
+
run: executeKernel
|
|
271
|
+
}
|
|
272
|
+
];
|
|
273
|
+
export {
|
|
274
|
+
executePipeline,
|
|
275
|
+
executeKernel,
|
|
276
|
+
defaultLifecycleCliCommands,
|
|
277
|
+
DEFAULT_PIPELINE_CLI_ID,
|
|
278
|
+
DEFAULT_KERNEL_CLI_ID
|
|
279
|
+
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StageMutation } from "@rig/contracts";
|
|
2
2
|
import { type KernelStageResolverResult } from "@rig/kernel/resolver";
|
|
3
3
|
import type { DefaultLifecycleStageDescriptor, DefaultLifecycleStageId } from "./stages/types";
|
|
4
4
|
export declare const DEFAULT_LIFECYCLE_STAGE_IDS: readonly ["validate", "verify", "commit", "push", "open-pr", "merge-gate", "auto-merge", "source-closeout", "isolation", "journal-append"];
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const defaultLifecycleStages: readonly [DefaultLifecycleStageDescriptor, DefaultLifecycleStageDescriptor, DefaultLifecycleStageDescriptor, DefaultLifecycleStageDescriptor, DefaultLifecycleStageDescriptor, DefaultLifecycleStageDescriptor, DefaultLifecycleStageDescriptor, DefaultLifecycleStageDescriptor, DefaultLifecycleStageDescriptor, DefaultLifecycleStageDescriptor];
|
|
5
|
+
export declare const defaultLifecycleStages: readonly DefaultLifecycleStageDescriptor[];
|
|
7
6
|
export type ResolveDefaultLifecycleInput = {
|
|
8
7
|
readonly mutations?: readonly StageMutation[];
|
|
9
|
-
readonly protectedStageGrants?: readonly ProtectedStageGrant[];
|
|
10
8
|
};
|
|
11
9
|
export declare function defaultLifecycleStageById(id: DefaultLifecycleStageId): DefaultLifecycleStageDescriptor;
|
|
12
10
|
export declare function resolveDefaultLifecycle(input?: ResolveDefaultLifecycleInput): KernelStageResolverResult;
|
|
@@ -14,7 +12,6 @@ export type PipelineShowStage = {
|
|
|
14
12
|
readonly index: number | null;
|
|
15
13
|
readonly id: string;
|
|
16
14
|
readonly contributedBy: string;
|
|
17
|
-
readonly protected: boolean;
|
|
18
15
|
readonly removedBy?: string;
|
|
19
16
|
readonly replacedBy?: string;
|
|
20
17
|
readonly wrappedBy: readonly string[];
|
|
@@ -29,4 +26,18 @@ export type PipelineShowData = {
|
|
|
29
26
|
readonly resolvedAt?: string;
|
|
30
27
|
};
|
|
31
28
|
export declare function defaultPipelineShowData(input?: ResolveDefaultLifecycleInput): PipelineShowData;
|
|
29
|
+
export type KernelStatusData = {
|
|
30
|
+
readonly kernelProviderId: string;
|
|
31
|
+
readonly kernelVersion: string;
|
|
32
|
+
readonly capabilities: Readonly<Record<string, string>>;
|
|
33
|
+
readonly pipelineStageCount: number;
|
|
34
|
+
readonly stageOrder: readonly string[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Data backing `rig kernel status`: the resolved provider per kernel capability,
|
|
38
|
+
* the kernel version, and the resolved default pipeline. Derived from the
|
|
39
|
+
* default kernel plugin so it reflects what actually boots, not a hardcoded list.
|
|
40
|
+
*/
|
|
41
|
+
export declare function defaultKernelStatusData(): KernelStatusData;
|
|
42
|
+
export declare function formatKernelStatus(data?: KernelStatusData): string;
|
|
32
43
|
export declare function formatDefaultPipelineShow(input?: ResolveDefaultLifecycleInput): string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/bundle-default-lifecycle/src/defaultPipeline.ts
|
|
3
3
|
import { resolveKernelStages } from "@rig/kernel/resolver";
|
|
4
|
+
import { createDefaultKernelPlugin } from "@rig/kernel/default-kernel";
|
|
4
5
|
|
|
5
6
|
// packages/bundle-default-lifecycle/src/stages/auto-merge.ts
|
|
6
7
|
import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automation";
|
|
@@ -9,7 +10,6 @@ import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automa
|
|
|
9
10
|
function defineDefaultLifecycleStage(input) {
|
|
10
11
|
return {
|
|
11
12
|
...input,
|
|
12
|
-
protected: input.protected ?? false,
|
|
13
13
|
priority: input.priority ?? 0
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -37,8 +37,7 @@ var isolationStage = defineDefaultLifecycleStage({
|
|
|
37
37
|
id: "isolation",
|
|
38
38
|
kind: "transform",
|
|
39
39
|
description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
|
|
40
|
-
calls: ["ensureAgentRuntime"]
|
|
41
|
-
protected: true
|
|
40
|
+
calls: ["ensureAgentRuntime"]
|
|
42
41
|
});
|
|
43
42
|
|
|
44
43
|
// packages/bundle-default-lifecycle/src/stages/journal-append.ts
|
|
@@ -46,17 +45,18 @@ var journalAppendStage = defineDefaultLifecycleStage({
|
|
|
46
45
|
id: "journal-append",
|
|
47
46
|
kind: "observe",
|
|
48
47
|
description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
|
|
49
|
-
calls: ["journalCapability.append"]
|
|
50
|
-
protected: true
|
|
48
|
+
calls: ["journalCapability.append"]
|
|
51
49
|
});
|
|
52
50
|
|
|
53
51
|
// packages/bundle-default-lifecycle/src/stages/merge-gate.ts
|
|
52
|
+
import {
|
|
53
|
+
runStrictPrMergeGate
|
|
54
|
+
} from "@rig/runtime/control-plane/native/pr-review-gate";
|
|
54
55
|
var mergeGateStage = defineDefaultLifecycleStage({
|
|
55
56
|
id: "merge-gate",
|
|
56
57
|
kind: "gate",
|
|
57
58
|
description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
|
|
58
|
-
calls: ["runStrictPrMergeGate"]
|
|
59
|
-
protected: true
|
|
59
|
+
calls: ["runStrictPrMergeGate"]
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
// packages/bundle-default-lifecycle/src/stages/open-pr.ts
|
|
@@ -115,7 +115,21 @@ var DEFAULT_LIFECYCLE_STAGE_IDS = [
|
|
|
115
115
|
"isolation",
|
|
116
116
|
"journal-append"
|
|
117
117
|
];
|
|
118
|
-
var
|
|
118
|
+
var DEFAULT_STAGE_AFTER = {
|
|
119
|
+
verify: ["validate"],
|
|
120
|
+
commit: ["verify"],
|
|
121
|
+
push: ["commit"],
|
|
122
|
+
"open-pr": ["push"],
|
|
123
|
+
"merge-gate": ["open-pr"],
|
|
124
|
+
"auto-merge": ["merge-gate"],
|
|
125
|
+
"source-closeout": ["auto-merge"],
|
|
126
|
+
isolation: ["source-closeout"],
|
|
127
|
+
"journal-append": ["isolation"]
|
|
128
|
+
};
|
|
129
|
+
function withDefaultAnchors(stage) {
|
|
130
|
+
const after = DEFAULT_STAGE_AFTER[stage.id];
|
|
131
|
+
return after ? { ...stage, after } : stage;
|
|
132
|
+
}
|
|
119
133
|
var defaultLifecycleStages = [
|
|
120
134
|
validateStage,
|
|
121
135
|
verifyStage,
|
|
@@ -127,7 +141,7 @@ var defaultLifecycleStages = [
|
|
|
127
141
|
sourceCloseoutStage,
|
|
128
142
|
isolationStage,
|
|
129
143
|
journalAppendStage
|
|
130
|
-
];
|
|
144
|
+
].map(withDefaultAnchors);
|
|
131
145
|
function defaultLifecycleStageById(id) {
|
|
132
146
|
const stage = defaultLifecycleStages.find((candidate) => candidate.id === id);
|
|
133
147
|
if (!stage)
|
|
@@ -135,8 +149,7 @@ function defaultLifecycleStageById(id) {
|
|
|
135
149
|
return stage;
|
|
136
150
|
}
|
|
137
151
|
function resolveDefaultLifecycle(input = {}) {
|
|
138
|
-
|
|
139
|
-
return resolveKernelStages(defaultLifecycleStages, input.mutations ?? [], grants);
|
|
152
|
+
return resolveKernelStages(defaultLifecycleStages, input.mutations ?? []);
|
|
140
153
|
}
|
|
141
154
|
function defaultPipelineShowData(input = {}) {
|
|
142
155
|
const resolved = resolveDefaultLifecycle(input);
|
|
@@ -145,7 +158,6 @@ function defaultPipelineShowData(input = {}) {
|
|
|
145
158
|
index: orderIndex.get(entry.stageId) ?? null,
|
|
146
159
|
id: entry.stageId,
|
|
147
160
|
contributedBy: entry.contributedBy,
|
|
148
|
-
protected: entry.isProtected,
|
|
149
161
|
...entry.removedBy !== undefined ? { removedBy: entry.removedBy } : {},
|
|
150
162
|
...entry.replacedBy !== undefined ? { replacedBy: entry.replacedBy } : {},
|
|
151
163
|
wrappedBy: entry.wrappedBy ?? [],
|
|
@@ -160,17 +172,41 @@ function defaultPipelineShowData(input = {}) {
|
|
|
160
172
|
...resolved.resolvedAt !== undefined ? { resolvedAt: resolved.resolvedAt } : {}
|
|
161
173
|
};
|
|
162
174
|
}
|
|
175
|
+
function defaultKernelStatusData() {
|
|
176
|
+
const plugin = createDefaultKernelPlugin();
|
|
177
|
+
const resolved = resolveDefaultLifecycle();
|
|
178
|
+
const capabilities = {};
|
|
179
|
+
for (const capability of plugin.provides)
|
|
180
|
+
capabilities[capability] = plugin.meta.id;
|
|
181
|
+
return {
|
|
182
|
+
kernelProviderId: plugin.meta.id,
|
|
183
|
+
kernelVersion: plugin.meta.version,
|
|
184
|
+
capabilities,
|
|
185
|
+
pipelineStageCount: resolved.order.length,
|
|
186
|
+
stageOrder: [...resolved.order]
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function formatKernelStatus(data = defaultKernelStatusData()) {
|
|
190
|
+
const lines = [
|
|
191
|
+
`kernel: ${data.kernelProviderId} v${data.kernelVersion}`,
|
|
192
|
+
"capabilities (resolved provider):",
|
|
193
|
+
...Object.entries(data.capabilities).map(([cap, provider]) => ` ${cap.padEnd(14)} ${provider}`),
|
|
194
|
+
`lifecycle stages: mutable`,
|
|
195
|
+
`resolved pipeline (${data.pipelineStageCount} stages): ${data.stageOrder.join(" -> ")}`
|
|
196
|
+
];
|
|
197
|
+
return lines.join(`
|
|
198
|
+
`);
|
|
199
|
+
}
|
|
163
200
|
function formatDefaultPipelineShow(input = {}) {
|
|
164
201
|
const data = defaultPipelineShowData(input);
|
|
165
202
|
const lines = [`${data.title}:`];
|
|
166
203
|
for (const stage of data.stages) {
|
|
167
204
|
if (stage.removedBy) {
|
|
168
|
-
lines.push(` - ${stage.id.padEnd(20)} [${stage.contributedBy}] removed by [${stage.removedBy}]
|
|
205
|
+
lines.push(` - ${stage.id.padEnd(20)} [${stage.contributedBy}] removed by [${stage.removedBy}]`);
|
|
169
206
|
continue;
|
|
170
207
|
}
|
|
171
208
|
const ordinal = stage.index === null ? " -." : `${String(stage.index).padStart(2)}.`;
|
|
172
209
|
const annotations = [
|
|
173
|
-
stage.protected ? "PROTECTED" : "",
|
|
174
210
|
stage.replacedBy ? `replaced by [${stage.replacedBy}]` : "",
|
|
175
211
|
stage.wrappedBy.length > 0 ? `wrapped by [${stage.wrappedBy.join(", ")}]` : ""
|
|
176
212
|
].filter(Boolean);
|
|
@@ -182,10 +218,11 @@ function formatDefaultPipelineShow(input = {}) {
|
|
|
182
218
|
}
|
|
183
219
|
export {
|
|
184
220
|
resolveDefaultLifecycle,
|
|
221
|
+
formatKernelStatus,
|
|
185
222
|
formatDefaultPipelineShow,
|
|
186
223
|
defaultPipelineShowData,
|
|
187
224
|
defaultLifecycleStages,
|
|
188
225
|
defaultLifecycleStageById,
|
|
189
|
-
|
|
226
|
+
defaultKernelStatusData,
|
|
190
227
|
DEFAULT_LIFECYCLE_STAGE_IDS
|
|
191
228
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from "./closeoutEquivalence";
|
|
2
2
|
export * from "./closeoutShadowHarness";
|
|
3
3
|
export * from "./defaultPipeline";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./pipelineCloseout";
|
|
5
|
+
export * from "./cli";
|
|
5
6
|
export * from "./plugin";
|
|
6
7
|
export * from "./stages/auto-merge";
|
|
7
8
|
export * from "./stages/commit";
|