@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.
@@ -1,6 +1,10 @@
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";
7
+ import { createDefaultKernelPlugin } from "@rig/kernel/default-kernel";
4
8
 
5
9
  // packages/bundle-default-lifecycle/src/stages/auto-merge.ts
6
10
  import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automation";
@@ -9,7 +13,6 @@ import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automa
9
13
  function defineDefaultLifecycleStage(input) {
10
14
  return {
11
15
  ...input,
12
- protected: input.protected ?? false,
13
16
  priority: input.priority ?? 0
14
17
  };
15
18
  }
@@ -37,8 +40,7 @@ var isolationStage = defineDefaultLifecycleStage({
37
40
  id: "isolation",
38
41
  kind: "transform",
39
42
  description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
40
- calls: ["ensureAgentRuntime"],
41
- protected: true
43
+ calls: ["ensureAgentRuntime"]
42
44
  });
43
45
 
44
46
  // packages/bundle-default-lifecycle/src/stages/journal-append.ts
@@ -46,17 +48,18 @@ var journalAppendStage = defineDefaultLifecycleStage({
46
48
  id: "journal-append",
47
49
  kind: "observe",
48
50
  description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
49
- calls: ["journalCapability.append"],
50
- protected: true
51
+ calls: ["journalCapability.append"]
51
52
  });
52
53
 
53
54
  // packages/bundle-default-lifecycle/src/stages/merge-gate.ts
55
+ import {
56
+ runStrictPrMergeGate
57
+ } from "@rig/runtime/control-plane/native/pr-review-gate";
54
58
  var mergeGateStage = defineDefaultLifecycleStage({
55
59
  id: "merge-gate",
56
60
  kind: "gate",
57
61
  description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
58
- calls: ["runStrictPrMergeGate"],
59
- protected: true
62
+ calls: ["runStrictPrMergeGate"]
60
63
  });
61
64
 
62
65
  // packages/bundle-default-lifecycle/src/stages/open-pr.ts
@@ -103,6 +106,21 @@ var verifyStage = defineDefaultLifecycleStage({
103
106
  });
104
107
 
105
108
  // packages/bundle-default-lifecycle/src/defaultPipeline.ts
109
+ var DEFAULT_STAGE_AFTER = {
110
+ verify: ["validate"],
111
+ commit: ["verify"],
112
+ push: ["commit"],
113
+ "open-pr": ["push"],
114
+ "merge-gate": ["open-pr"],
115
+ "auto-merge": ["merge-gate"],
116
+ "source-closeout": ["auto-merge"],
117
+ isolation: ["source-closeout"],
118
+ "journal-append": ["isolation"]
119
+ };
120
+ function withDefaultAnchors(stage) {
121
+ const after = DEFAULT_STAGE_AFTER[stage.id];
122
+ return after ? { ...stage, after } : stage;
123
+ }
106
124
  var defaultLifecycleStages = [
107
125
  validateStage,
108
126
  verifyStage,
@@ -114,19 +132,181 @@ var defaultLifecycleStages = [
114
132
  sourceCloseoutStage,
115
133
  isolationStage,
116
134
  journalAppendStage
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
+ }
117
275
  ];
118
276
 
119
277
  // packages/bundle-default-lifecycle/src/plugin.ts
120
278
  var DEFAULT_LIFECYCLE_PLUGIN_ID = "@rig/bundle-default-lifecycle";
121
- 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
+ });
122
300
  return {
301
+ ...plugin,
123
302
  meta: { id: DEFAULT_LIFECYCLE_PLUGIN_ID, name: "Default Rig Lifecycle", version: "0.0.0-alpha.1" },
124
- provides: new Set,
125
- contributes: { stages: defaultLifecycleStages },
126
- runtime: { stages: defaultLifecycleStages }
303
+ contributes: { ...plugin.contributes ?? {}, stages: defaultLifecycleStages },
304
+ runtime: { stages }
127
305
  };
128
306
  }
307
+ var defaultLifecyclePlugin = createDefaultLifecyclePlugin();
129
308
  export {
309
+ defaultLifecyclePlugin,
130
310
  createDefaultLifecyclePlugin,
131
311
  DEFAULT_LIFECYCLE_PLUGIN_ID
132
312
  };
@@ -6,7 +6,6 @@ import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automa
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
  }
@@ -6,7 +6,6 @@ import { commitRunChanges } from "@rig/runtime/control-plane/native/pr-automatio
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
  }
@@ -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);
@@ -1 +1,24 @@
1
+ import { type StrictPrGreptileApiOptions, type StrictPrMergeGateResult } from "@rig/runtime/control-plane/native/pr-review-gate";
2
+ import type { GitHubCommandRunner } from "@rig/runtime/control-plane/native/pr-automation";
3
+ export type MergeGateStageInput = {
4
+ readonly projectRoot: string;
5
+ readonly prUrl: string;
6
+ readonly taskId: string;
7
+ readonly runId: string;
8
+ readonly cycle: number;
9
+ readonly command: GitHubCommandRunner;
10
+ readonly artifactRoot?: string | null;
11
+ readonly allowedFailures?: readonly string[];
12
+ readonly greptileApi?: StrictPrGreptileApiOptions;
13
+ readonly final?: boolean;
14
+ readonly requireGreptile?: boolean;
15
+ };
1
16
  export declare const mergeGateStage: import("./types").DefaultLifecycleStageDescriptor;
17
+ /**
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
+ * Returns the full {@link StrictPrMergeGateResult}; the caller maps it to a
22
+ * gate allow/block from `result.approved` / `result.pending`.
23
+ */
24
+ export declare function runMergeGateStage(input: MergeGateStageInput): Promise<StrictPrMergeGateResult>;
@@ -1,9 +1,13 @@
1
1
  // @bun
2
+ // packages/bundle-default-lifecycle/src/stages/merge-gate.ts
3
+ import {
4
+ runStrictPrMergeGate
5
+ } from "@rig/runtime/control-plane/native/pr-review-gate";
6
+
2
7
  // packages/bundle-default-lifecycle/src/stages/types.ts
3
8
  function defineDefaultLifecycleStage(input) {
4
9
  return {
5
10
  ...input,
6
- protected: input.protected ?? false,
7
11
  priority: input.priority ?? 0
8
12
  };
9
13
  }
@@ -13,9 +17,24 @@ var mergeGateStage = defineDefaultLifecycleStage({
13
17
  id: "merge-gate",
14
18
  kind: "gate",
15
19
  description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
16
- calls: ["runStrictPrMergeGate"],
17
- protected: true
20
+ calls: ["runStrictPrMergeGate"]
18
21
  });
22
+ async function runMergeGateStage(input) {
23
+ return await runStrictPrMergeGate({
24
+ projectRoot: input.projectRoot,
25
+ prUrl: input.prUrl,
26
+ taskId: input.taskId,
27
+ runId: input.runId,
28
+ cycle: input.cycle,
29
+ command: input.command,
30
+ ...input.artifactRoot !== undefined ? { artifactRoot: input.artifactRoot } : {},
31
+ ...input.allowedFailures !== undefined ? { allowedFailures: input.allowedFailures } : {},
32
+ ...input.greptileApi !== undefined ? { greptileApi: input.greptileApi } : {},
33
+ ...input.final !== undefined ? { final: input.final } : {},
34
+ ...input.requireGreptile !== undefined ? { requireGreptile: input.requireGreptile } : {}
35
+ });
36
+ }
19
37
  export {
38
+ runMergeGateStage,
20
39
  mergeGateStage
21
40
  };
@@ -6,7 +6,6 @@ import { runPrAutomation } from "@rig/runtime/control-plane/native/pr-automation
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
  }
@@ -6,7 +6,6 @@ import { pushBranchSyncedWithOrigin } from "@rig/runtime/control-plane/native/pr
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
  }
@@ -6,7 +6,6 @@ import { closeIssueAfterMergedPr } from "@rig/runtime/control-plane/native/pr-au
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
  }
@@ -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;
@@ -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
  }
@@ -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
  }
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/bundle-default-lifecycle",
3
- "version": "0.0.6-alpha.135",
3
+ "version": "0.0.6-alpha.137",
4
4
  "type": "module",
5
5
  "description": "Default Rig run lifecycle stage bundle wrapping the existing closeout runtime.",
6
6
  "license": "UNLICENSED",
@@ -25,9 +25,9 @@
25
25
  "types": "./dist/src/defaultPipeline.d.ts",
26
26
  "import": "./dist/src/defaultPipeline.js"
27
27
  },
28
- "./staged-closeout": {
29
- "types": "./dist/src/stagedCloseout.d.ts",
30
- "import": "./dist/src/stagedCloseout.js"
28
+ "./pipeline-closeout": {
29
+ "types": "./dist/src/pipelineCloseout.d.ts",
30
+ "import": "./dist/src/pipelineCloseout.js"
31
31
  },
32
32
  "./plugin": {
33
33
  "types": "./dist/src/plugin.d.ts",
@@ -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.135",
45
- "@rig/core": "npm:@h-rig/core@0.0.6-alpha.135",
46
- "@rig/kernel": "npm:@h-rig/kernel@0.0.6-alpha.135",
47
- "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.135"
44
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.137",
45
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.137",
46
+ "@rig/kernel": "npm:@h-rig/kernel@0.0.6-alpha.137",
47
+ "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.137"
48
48
  }
49
49
  }
@@ -1,7 +0,0 @@
1
- import { type InProcessCloseoutInput, type InProcessCloseoutResult } from "@rig/runtime/control-plane/native/in-process-closeout";
2
- export type StagedCloseoutResult = {
3
- readonly mode: "staged";
4
- readonly pipelineStageIds: readonly string[];
5
- readonly result: InProcessCloseoutResult;
6
- };
7
- export declare function runStagedCloseout(input: InProcessCloseoutInput): Promise<StagedCloseoutResult>;