@h-rig/bundle-default-lifecycle 0.0.6-alpha.136 → 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.
@@ -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 {};
@@ -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 { ProtectedStageGrant, StageMutation } from "@rig/contracts";
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 PROTECTED_DEFAULT_LIFECYCLE_STAGE_IDS: readonly ["merge-gate", "isolation", "journal-append"];
6
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[];
@@ -33,15 +30,13 @@ export type KernelStatusData = {
33
30
  readonly kernelProviderId: string;
34
31
  readonly kernelVersion: string;
35
32
  readonly capabilities: Readonly<Record<string, string>>;
36
- readonly protectedStages: readonly string[];
37
33
  readonly pipelineStageCount: number;
38
34
  readonly stageOrder: readonly string[];
39
35
  };
40
36
  /**
41
37
  * Data backing `rig kernel status`: the resolved provider per kernel capability,
42
- * the kernel version, the protected-stage set, and the resolved default
43
- * pipeline. Derived from the default kernel plugin so it reflects what actually
44
- * boots, not a hardcoded list.
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.
45
40
  */
46
41
  export declare function defaultKernelStatusData(): KernelStatusData;
47
42
  export declare function formatKernelStatus(data?: KernelStatusData): string;
@@ -10,7 +10,6 @@ import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automa
10
10
  function defineDefaultLifecycleStage(input) {
11
11
  return {
12
12
  ...input,
13
- protected: input.protected ?? false,
14
13
  priority: input.priority ?? 0
15
14
  };
16
15
  }
@@ -38,8 +37,7 @@ var isolationStage = defineDefaultLifecycleStage({
38
37
  id: "isolation",
39
38
  kind: "transform",
40
39
  description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
41
- calls: ["ensureAgentRuntime"],
42
- protected: true
40
+ calls: ["ensureAgentRuntime"]
43
41
  });
44
42
 
45
43
  // packages/bundle-default-lifecycle/src/stages/journal-append.ts
@@ -47,8 +45,7 @@ var journalAppendStage = defineDefaultLifecycleStage({
47
45
  id: "journal-append",
48
46
  kind: "observe",
49
47
  description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
50
- calls: ["journalCapability.append"],
51
- protected: true
48
+ calls: ["journalCapability.append"]
52
49
  });
53
50
 
54
51
  // packages/bundle-default-lifecycle/src/stages/merge-gate.ts
@@ -59,8 +56,7 @@ var mergeGateStage = defineDefaultLifecycleStage({
59
56
  id: "merge-gate",
60
57
  kind: "gate",
61
58
  description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
62
- calls: ["runStrictPrMergeGate"],
63
- protected: true
59
+ calls: ["runStrictPrMergeGate"]
64
60
  });
65
61
 
66
62
  // packages/bundle-default-lifecycle/src/stages/open-pr.ts
@@ -119,7 +115,6 @@ var DEFAULT_LIFECYCLE_STAGE_IDS = [
119
115
  "isolation",
120
116
  "journal-append"
121
117
  ];
122
- var PROTECTED_DEFAULT_LIFECYCLE_STAGE_IDS = ["merge-gate", "isolation", "journal-append"];
123
118
  var DEFAULT_STAGE_AFTER = {
124
119
  verify: ["validate"],
125
120
  commit: ["verify"],
@@ -154,8 +149,7 @@ function defaultLifecycleStageById(id) {
154
149
  return stage;
155
150
  }
156
151
  function resolveDefaultLifecycle(input = {}) {
157
- const grants = { protectedStageGrants: input.protectedStageGrants ?? [] };
158
- return resolveKernelStages(defaultLifecycleStages, input.mutations ?? [], grants);
152
+ return resolveKernelStages(defaultLifecycleStages, input.mutations ?? []);
159
153
  }
160
154
  function defaultPipelineShowData(input = {}) {
161
155
  const resolved = resolveDefaultLifecycle(input);
@@ -164,7 +158,6 @@ function defaultPipelineShowData(input = {}) {
164
158
  index: orderIndex.get(entry.stageId) ?? null,
165
159
  id: entry.stageId,
166
160
  contributedBy: entry.contributedBy,
167
- protected: entry.isProtected,
168
161
  ...entry.removedBy !== undefined ? { removedBy: entry.removedBy } : {},
169
162
  ...entry.replacedBy !== undefined ? { replacedBy: entry.replacedBy } : {},
170
163
  wrappedBy: entry.wrappedBy ?? [],
@@ -189,7 +182,6 @@ function defaultKernelStatusData() {
189
182
  kernelProviderId: plugin.meta.id,
190
183
  kernelVersion: plugin.meta.version,
191
184
  capabilities,
192
- protectedStages: [...PROTECTED_DEFAULT_LIFECYCLE_STAGE_IDS],
193
185
  pipelineStageCount: resolved.order.length,
194
186
  stageOrder: [...resolved.order]
195
187
  };
@@ -199,7 +191,7 @@ function formatKernelStatus(data = defaultKernelStatusData()) {
199
191
  `kernel: ${data.kernelProviderId} v${data.kernelVersion}`,
200
192
  "capabilities (resolved provider):",
201
193
  ...Object.entries(data.capabilities).map(([cap, provider]) => ` ${cap.padEnd(14)} ${provider}`),
202
- `protected stages: ${data.protectedStages.join(", ")}`,
194
+ `lifecycle stages: mutable`,
203
195
  `resolved pipeline (${data.pipelineStageCount} stages): ${data.stageOrder.join(" -> ")}`
204
196
  ];
205
197
  return lines.join(`
@@ -210,12 +202,11 @@ function formatDefaultPipelineShow(input = {}) {
210
202
  const lines = [`${data.title}:`];
211
203
  for (const stage of data.stages) {
212
204
  if (stage.removedBy) {
213
- lines.push(` - ${stage.id.padEnd(20)} [${stage.contributedBy}] removed by [${stage.removedBy}]${stage.protected ? " PROTECTED" : ""}`);
205
+ lines.push(` - ${stage.id.padEnd(20)} [${stage.contributedBy}] removed by [${stage.removedBy}]`);
214
206
  continue;
215
207
  }
216
208
  const ordinal = stage.index === null ? " -." : `${String(stage.index).padStart(2)}.`;
217
209
  const annotations = [
218
- stage.protected ? "PROTECTED" : "",
219
210
  stage.replacedBy ? `replaced by [${stage.replacedBy}]` : "",
220
211
  stage.wrappedBy.length > 0 ? `wrapped by [${stage.wrappedBy.join(", ")}]` : ""
221
212
  ].filter(Boolean);
@@ -233,6 +224,5 @@ export {
233
224
  defaultLifecycleStages,
234
225
  defaultLifecycleStageById,
235
226
  defaultKernelStatusData,
236
- PROTECTED_DEFAULT_LIFECYCLE_STAGE_IDS,
237
227
  DEFAULT_LIFECYCLE_STAGE_IDS
238
228
  };
@@ -2,6 +2,7 @@ export * from "./closeoutEquivalence";
2
2
  export * from "./closeoutShadowHarness";
3
3
  export * from "./defaultPipeline";
4
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";