@h-rig/bundle-default-lifecycle 0.0.6-alpha.136 → 0.0.6-alpha.138
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 +3 -8
- package/dist/src/defaultPipeline.js +6 -16
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +125 -29
- package/dist/src/pipelineCloseout.d.ts +3 -6
- package/dist/src/pipelineCloseout.js +180 -12
- package/dist/src/plugin.d.ts +7 -6
- package/dist/src/plugin.js +172 -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 +3 -3
- package/dist/src/stages/merge-gate.js +1 -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 +5 -5
package/dist/src/plugin.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// packages/bundle-default-lifecycle/src/plugin.ts
|
|
3
|
+
import { definePlugin } from "@rig/core";
|
|
4
|
+
|
|
2
5
|
// packages/bundle-default-lifecycle/src/defaultPipeline.ts
|
|
3
6
|
import { resolveKernelStages } from "@rig/kernel/resolver";
|
|
4
7
|
import { createDefaultKernelPlugin } from "@rig/kernel/default-kernel";
|
|
@@ -10,7 +13,6 @@ import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automa
|
|
|
10
13
|
function defineDefaultLifecycleStage(input) {
|
|
11
14
|
return {
|
|
12
15
|
...input,
|
|
13
|
-
protected: input.protected ?? false,
|
|
14
16
|
priority: input.priority ?? 0
|
|
15
17
|
};
|
|
16
18
|
}
|
|
@@ -38,8 +40,7 @@ var isolationStage = defineDefaultLifecycleStage({
|
|
|
38
40
|
id: "isolation",
|
|
39
41
|
kind: "transform",
|
|
40
42
|
description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
|
|
41
|
-
calls: ["ensureAgentRuntime"]
|
|
42
|
-
protected: true
|
|
43
|
+
calls: ["ensureAgentRuntime"]
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
// packages/bundle-default-lifecycle/src/stages/journal-append.ts
|
|
@@ -47,8 +48,7 @@ var journalAppendStage = defineDefaultLifecycleStage({
|
|
|
47
48
|
id: "journal-append",
|
|
48
49
|
kind: "observe",
|
|
49
50
|
description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
|
|
50
|
-
calls: ["journalCapability.append"]
|
|
51
|
-
protected: true
|
|
51
|
+
calls: ["journalCapability.append"]
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
// packages/bundle-default-lifecycle/src/stages/merge-gate.ts
|
|
@@ -59,8 +59,7 @@ var mergeGateStage = defineDefaultLifecycleStage({
|
|
|
59
59
|
id: "merge-gate",
|
|
60
60
|
kind: "gate",
|
|
61
61
|
description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
|
|
62
|
-
calls: ["runStrictPrMergeGate"]
|
|
63
|
-
protected: true
|
|
62
|
+
calls: ["runStrictPrMergeGate"]
|
|
64
63
|
});
|
|
65
64
|
|
|
66
65
|
// packages/bundle-default-lifecycle/src/stages/open-pr.ts
|
|
@@ -134,18 +133,180 @@ var defaultLifecycleStages = [
|
|
|
134
133
|
isolationStage,
|
|
135
134
|
journalAppendStage
|
|
136
135
|
].map(withDefaultAnchors);
|
|
136
|
+
function resolveDefaultLifecycle(input = {}) {
|
|
137
|
+
return resolveKernelStages(defaultLifecycleStages, input.mutations ?? []);
|
|
138
|
+
}
|
|
139
|
+
function defaultPipelineShowData(input = {}) {
|
|
140
|
+
const resolved = resolveDefaultLifecycle(input);
|
|
141
|
+
const orderIndex = new Map(resolved.order.map((id, index) => [id, index + 1]));
|
|
142
|
+
const stages = resolved.record.map((entry) => ({
|
|
143
|
+
index: orderIndex.get(entry.stageId) ?? null,
|
|
144
|
+
id: entry.stageId,
|
|
145
|
+
contributedBy: entry.contributedBy,
|
|
146
|
+
...entry.removedBy !== undefined ? { removedBy: entry.removedBy } : {},
|
|
147
|
+
...entry.replacedBy !== undefined ? { replacedBy: entry.replacedBy } : {},
|
|
148
|
+
wrappedBy: entry.wrappedBy ?? [],
|
|
149
|
+
droppedAnchors: entry.droppedAnchors ?? []
|
|
150
|
+
}));
|
|
151
|
+
return {
|
|
152
|
+
title: `resolved run pipeline (${resolved.order.length} stages)`,
|
|
153
|
+
stageCount: resolved.order.length,
|
|
154
|
+
stages,
|
|
155
|
+
droppedAnchors: stages.flatMap((stage) => stage.droppedAnchors.map((anchor) => `${stage.id}:${anchor}`)),
|
|
156
|
+
cycles: resolved.cycles,
|
|
157
|
+
...resolved.resolvedAt !== undefined ? { resolvedAt: resolved.resolvedAt } : {}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function defaultKernelStatusData() {
|
|
161
|
+
const plugin = createDefaultKernelPlugin();
|
|
162
|
+
const resolved = resolveDefaultLifecycle();
|
|
163
|
+
const capabilities = {};
|
|
164
|
+
for (const capability of plugin.provides)
|
|
165
|
+
capabilities[capability] = plugin.meta.id;
|
|
166
|
+
return {
|
|
167
|
+
kernelProviderId: plugin.meta.id,
|
|
168
|
+
kernelVersion: plugin.meta.version,
|
|
169
|
+
capabilities,
|
|
170
|
+
pipelineStageCount: resolved.order.length,
|
|
171
|
+
stageOrder: [...resolved.order]
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function formatKernelStatus(data = defaultKernelStatusData()) {
|
|
175
|
+
const lines = [
|
|
176
|
+
`kernel: ${data.kernelProviderId} v${data.kernelVersion}`,
|
|
177
|
+
"capabilities (resolved provider):",
|
|
178
|
+
...Object.entries(data.capabilities).map(([cap, provider]) => ` ${cap.padEnd(14)} ${provider}`),
|
|
179
|
+
`lifecycle stages: mutable`,
|
|
180
|
+
`resolved pipeline (${data.pipelineStageCount} stages): ${data.stageOrder.join(" -> ")}`
|
|
181
|
+
];
|
|
182
|
+
return lines.join(`
|
|
183
|
+
`);
|
|
184
|
+
}
|
|
185
|
+
function formatDefaultPipelineShow(input = {}) {
|
|
186
|
+
const data = defaultPipelineShowData(input);
|
|
187
|
+
const lines = [`${data.title}:`];
|
|
188
|
+
for (const stage of data.stages) {
|
|
189
|
+
if (stage.removedBy) {
|
|
190
|
+
lines.push(` - ${stage.id.padEnd(20)} [${stage.contributedBy}] removed by [${stage.removedBy}]`);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const ordinal = stage.index === null ? " -." : `${String(stage.index).padStart(2)}.`;
|
|
194
|
+
const annotations = [
|
|
195
|
+
stage.replacedBy ? `replaced by [${stage.replacedBy}]` : "",
|
|
196
|
+
stage.wrappedBy.length > 0 ? `wrapped by [${stage.wrappedBy.join(", ")}]` : ""
|
|
197
|
+
].filter(Boolean);
|
|
198
|
+
lines.push(` ${ordinal} ${stage.id.padEnd(20)} [${stage.contributedBy}]${annotations.length > 0 ? ` ${annotations.join(" ")}` : ""}`);
|
|
199
|
+
}
|
|
200
|
+
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"}`);
|
|
201
|
+
return lines.join(`
|
|
202
|
+
`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// packages/bundle-default-lifecycle/src/cli.ts
|
|
206
|
+
var DEFAULT_PIPELINE_CLI_ID = "default-lifecycle.pipeline";
|
|
207
|
+
var DEFAULT_KERNEL_CLI_ID = "default-lifecycle.kernel";
|
|
208
|
+
function printJson(value) {
|
|
209
|
+
console.log(JSON.stringify(value, null, 2));
|
|
210
|
+
}
|
|
211
|
+
function takeFlag(args, flag) {
|
|
212
|
+
const rest = [...args];
|
|
213
|
+
const index = rest.indexOf(flag);
|
|
214
|
+
if (index < 0)
|
|
215
|
+
return { value: false, rest };
|
|
216
|
+
rest.splice(index, 1);
|
|
217
|
+
return { value: true, rest };
|
|
218
|
+
}
|
|
219
|
+
function requireNoExtraArgs(args, usage) {
|
|
220
|
+
if (args.length > 0)
|
|
221
|
+
throw new Error(`Unexpected argument: ${args[0]}
|
|
222
|
+
Usage: ${usage}`);
|
|
223
|
+
}
|
|
224
|
+
async function executePipeline(context, args) {
|
|
225
|
+
const [first = "show", ...rest] = args;
|
|
226
|
+
const command = first.startsWith("-") ? "show" : first;
|
|
227
|
+
const commandArgs = first.startsWith("-") ? args : rest;
|
|
228
|
+
if (command !== "show")
|
|
229
|
+
throw new Error(`Unknown pipeline command: ${command}`);
|
|
230
|
+
const json = takeFlag(commandArgs, "--json");
|
|
231
|
+
requireNoExtraArgs(json.rest, "rig pipeline show [--json]");
|
|
232
|
+
const details = defaultPipelineShowData();
|
|
233
|
+
if (context.outputMode === "text") {
|
|
234
|
+
if (json.value)
|
|
235
|
+
printJson(details);
|
|
236
|
+
else
|
|
237
|
+
console.log(formatDefaultPipelineShow());
|
|
238
|
+
}
|
|
239
|
+
return { ok: true, group: "pipeline", command: "show", details };
|
|
240
|
+
}
|
|
241
|
+
async function executeKernel(context, args) {
|
|
242
|
+
const [first = "status", ...rest] = args;
|
|
243
|
+
const command = first.startsWith("-") ? "status" : first;
|
|
244
|
+
const commandArgs = first.startsWith("-") ? args : rest;
|
|
245
|
+
if (command !== "status")
|
|
246
|
+
throw new Error(`Unknown kernel command: ${command}`);
|
|
247
|
+
const json = takeFlag(commandArgs, "--json");
|
|
248
|
+
requireNoExtraArgs(json.rest, "rig kernel status [--json]");
|
|
249
|
+
const details = defaultKernelStatusData();
|
|
250
|
+
if (context.outputMode === "text") {
|
|
251
|
+
if (json.value)
|
|
252
|
+
printJson(details);
|
|
253
|
+
else
|
|
254
|
+
console.log(formatKernelStatus(details));
|
|
255
|
+
}
|
|
256
|
+
return { ok: true, group: "kernel", command: "status", details };
|
|
257
|
+
}
|
|
258
|
+
var defaultLifecycleCliCommands = [
|
|
259
|
+
{
|
|
260
|
+
id: DEFAULT_PIPELINE_CLI_ID,
|
|
261
|
+
family: "pipeline",
|
|
262
|
+
command: "rig pipeline show [--json]",
|
|
263
|
+
description: "Show the resolved default lifecycle pipeline.",
|
|
264
|
+
usage: "rig pipeline show [--json]",
|
|
265
|
+
run: executePipeline
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: DEFAULT_KERNEL_CLI_ID,
|
|
269
|
+
family: "kernel",
|
|
270
|
+
command: "rig kernel status [--json]",
|
|
271
|
+
description: "Show default kernel provider and lifecycle status.",
|
|
272
|
+
usage: "rig kernel status [--json]",
|
|
273
|
+
run: executeKernel
|
|
274
|
+
}
|
|
275
|
+
];
|
|
137
276
|
|
|
138
277
|
// packages/bundle-default-lifecycle/src/plugin.ts
|
|
139
278
|
var DEFAULT_LIFECYCLE_PLUGIN_ID = "@rig/bundle-default-lifecycle";
|
|
140
|
-
function createDefaultLifecyclePlugin() {
|
|
279
|
+
function createDefaultLifecyclePlugin(stages = {}) {
|
|
280
|
+
const plugin = definePlugin({
|
|
281
|
+
name: DEFAULT_LIFECYCLE_PLUGIN_ID,
|
|
282
|
+
version: "0.0.0-alpha.1",
|
|
283
|
+
provides: [],
|
|
284
|
+
contributes: {
|
|
285
|
+
stages: defaultLifecycleStages,
|
|
286
|
+
capabilities: [
|
|
287
|
+
{ id: "default-lifecycle.pipeline", title: "Default lifecycle pipeline", commandId: DEFAULT_PIPELINE_CLI_ID },
|
|
288
|
+
{ id: "default-lifecycle.kernel-status", title: "Default kernel status", commandId: DEFAULT_KERNEL_CLI_ID }
|
|
289
|
+
],
|
|
290
|
+
cliCommands: defaultLifecycleCliCommands.map(({ run: _run, ...metadata }) => metadata)
|
|
291
|
+
}
|
|
292
|
+
}, {
|
|
293
|
+
stages,
|
|
294
|
+
featureCapabilities: [
|
|
295
|
+
{ id: "default-lifecycle.pipeline", title: "Default lifecycle pipeline", commandId: DEFAULT_PIPELINE_CLI_ID },
|
|
296
|
+
{ id: "default-lifecycle.kernel-status", title: "Default kernel status", commandId: DEFAULT_KERNEL_CLI_ID }
|
|
297
|
+
],
|
|
298
|
+
cliCommands: defaultLifecycleCliCommands
|
|
299
|
+
});
|
|
141
300
|
return {
|
|
301
|
+
...plugin,
|
|
142
302
|
meta: { id: DEFAULT_LIFECYCLE_PLUGIN_ID, name: "Default Rig Lifecycle", version: "0.0.0-alpha.1" },
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
runtime: { stages: defaultLifecycleStages }
|
|
303
|
+
contributes: { ...plugin.contributes ?? {}, stages: defaultLifecycleStages },
|
|
304
|
+
runtime: { stages }
|
|
146
305
|
};
|
|
147
306
|
}
|
|
307
|
+
var defaultLifecyclePlugin = createDefaultLifecyclePlugin();
|
|
148
308
|
export {
|
|
309
|
+
defaultLifecyclePlugin,
|
|
149
310
|
createDefaultLifecyclePlugin,
|
|
150
311
|
DEFAULT_LIFECYCLE_PLUGIN_ID
|
|
151
312
|
};
|
|
@@ -6,7 +6,6 @@ import { ensureAgentRuntime } from "@rig/runtime/control-plane/runtime/isolation
|
|
|
6
6
|
function defineDefaultLifecycleStage(input) {
|
|
7
7
|
return {
|
|
8
8
|
...input,
|
|
9
|
-
protected: input.protected ?? false,
|
|
10
9
|
priority: input.priority ?? 0
|
|
11
10
|
};
|
|
12
11
|
}
|
|
@@ -16,8 +15,7 @@ var isolationStage = defineDefaultLifecycleStage({
|
|
|
16
15
|
id: "isolation",
|
|
17
16
|
kind: "transform",
|
|
18
17
|
description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
|
|
19
|
-
calls: ["ensureAgentRuntime"]
|
|
20
|
-
protected: true
|
|
18
|
+
calls: ["ensureAgentRuntime"]
|
|
21
19
|
});
|
|
22
20
|
async function runIsolationStage(input) {
|
|
23
21
|
return await ensureAgentRuntime(input);
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
function defineDefaultLifecycleStage(input) {
|
|
4
4
|
return {
|
|
5
5
|
...input,
|
|
6
|
-
protected: input.protected ?? false,
|
|
7
6
|
priority: input.priority ?? 0
|
|
8
7
|
};
|
|
9
8
|
}
|
|
@@ -13,8 +12,7 @@ var journalAppendStage = defineDefaultLifecycleStage({
|
|
|
13
12
|
id: "journal-append",
|
|
14
13
|
kind: "observe",
|
|
15
14
|
description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
|
|
16
|
-
calls: ["journalCapability.append"]
|
|
17
|
-
protected: true
|
|
15
|
+
calls: ["journalCapability.append"]
|
|
18
16
|
});
|
|
19
17
|
async function runJournalAppendStage(input) {
|
|
20
18
|
await input.journal.append(input.event);
|
|
@@ -15,9 +15,9 @@ export type MergeGateStageInput = {
|
|
|
15
15
|
};
|
|
16
16
|
export declare const mergeGateStage: import("./types").DefaultLifecycleStageDescriptor;
|
|
17
17
|
/**
|
|
18
|
-
* Executable for the
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Executable for the `merge-gate` stage. Wraps the runtime's strict merge gate
|
|
19
|
+
* (`runStrictPrMergeGate`) so the gate runs as a discrete resolved pipeline
|
|
20
|
+
* stage rather than only as logic embedded inside `runPrAutomation`.
|
|
21
21
|
* Returns the full {@link StrictPrMergeGateResult}; the caller maps it to a
|
|
22
22
|
* gate allow/block from `result.approved` / `result.pending`.
|
|
23
23
|
*/
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
function defineDefaultLifecycleStage(input) {
|
|
9
9
|
return {
|
|
10
10
|
...input,
|
|
11
|
-
protected: input.protected ?? false,
|
|
12
11
|
priority: input.priority ?? 0
|
|
13
12
|
};
|
|
14
13
|
}
|
|
@@ -18,8 +17,7 @@ var mergeGateStage = defineDefaultLifecycleStage({
|
|
|
18
17
|
id: "merge-gate",
|
|
19
18
|
kind: "gate",
|
|
20
19
|
description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
|
|
21
|
-
calls: ["runStrictPrMergeGate"]
|
|
22
|
-
protected: true
|
|
20
|
+
calls: ["runStrictPrMergeGate"]
|
|
23
21
|
});
|
|
24
22
|
async function runMergeGateStage(input) {
|
|
25
23
|
return await runStrictPrMergeGate({
|
package/dist/src/stages/push.js
CHANGED
|
@@ -6,7 +6,6 @@ export type DefaultLifecycleStageDescriptor = Stage & {
|
|
|
6
6
|
readonly kind: StageKind;
|
|
7
7
|
readonly description: string;
|
|
8
8
|
readonly calls: readonly RuntimeCloseoutFunctionName[];
|
|
9
|
-
readonly protected: boolean;
|
|
10
9
|
readonly priority: number;
|
|
11
10
|
};
|
|
12
11
|
export type DefaultLifecycleStageInput = {
|
|
@@ -14,7 +13,6 @@ export type DefaultLifecycleStageInput = {
|
|
|
14
13
|
readonly kind: StageKind;
|
|
15
14
|
readonly description: string;
|
|
16
15
|
readonly calls: readonly RuntimeCloseoutFunctionName[];
|
|
17
|
-
readonly protected?: boolean;
|
|
18
16
|
readonly priority?: number;
|
|
19
17
|
};
|
|
20
18
|
export declare function defineDefaultLifecycleStage(input: DefaultLifecycleStageInput): DefaultLifecycleStageDescriptor;
|
package/dist/src/stages/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/bundle-default-lifecycle",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.138",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Default Rig run lifecycle stage bundle wrapping the existing closeout runtime.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"module": "./dist/src/index.js",
|
|
42
42
|
"types": "./dist/src/index.d.ts",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.
|
|
45
|
-
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.
|
|
46
|
-
"@rig/kernel": "npm:@h-rig/kernel@0.0.6-alpha.
|
|
47
|
-
"@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.
|
|
44
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.138",
|
|
45
|
+
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.138",
|
|
46
|
+
"@rig/kernel": "npm:@h-rig/kernel@0.0.6-alpha.138",
|
|
47
|
+
"@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.138"
|
|
48
48
|
}
|
|
49
49
|
}
|