@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/index.js CHANGED
@@ -105,7 +105,6 @@ import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automa
105
105
  function defineDefaultLifecycleStage(input) {
106
106
  return {
107
107
  ...input,
108
- protected: input.protected ?? false,
109
108
  priority: input.priority ?? 0
110
109
  };
111
110
  }
@@ -139,8 +138,7 @@ var isolationStage = defineDefaultLifecycleStage({
139
138
  id: "isolation",
140
139
  kind: "transform",
141
140
  description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
142
- calls: ["ensureAgentRuntime"],
143
- protected: true
141
+ calls: ["ensureAgentRuntime"]
144
142
  });
145
143
  async function runIsolationStage(input) {
146
144
  return await ensureAgentRuntime(input);
@@ -151,8 +149,7 @@ var journalAppendStage = defineDefaultLifecycleStage({
151
149
  id: "journal-append",
152
150
  kind: "observe",
153
151
  description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
154
- calls: ["journalCapability.append"],
155
- protected: true
152
+ calls: ["journalCapability.append"]
156
153
  });
157
154
  async function runJournalAppendStage(input) {
158
155
  await input.journal.append(input.event);
@@ -166,8 +163,7 @@ var mergeGateStage = defineDefaultLifecycleStage({
166
163
  id: "merge-gate",
167
164
  kind: "gate",
168
165
  description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
169
- calls: ["runStrictPrMergeGate"],
170
- protected: true
166
+ calls: ["runStrictPrMergeGate"]
171
167
  });
172
168
  async function runMergeGateStage(input) {
173
169
  return await runStrictPrMergeGate({
@@ -279,7 +275,6 @@ var DEFAULT_LIFECYCLE_STAGE_IDS = [
279
275
  "isolation",
280
276
  "journal-append"
281
277
  ];
282
- var PROTECTED_DEFAULT_LIFECYCLE_STAGE_IDS = ["merge-gate", "isolation", "journal-append"];
283
278
  var DEFAULT_STAGE_AFTER = {
284
279
  verify: ["validate"],
285
280
  commit: ["verify"],
@@ -314,8 +309,7 @@ function defaultLifecycleStageById(id) {
314
309
  return stage;
315
310
  }
316
311
  function resolveDefaultLifecycle(input = {}) {
317
- const grants = { protectedStageGrants: input.protectedStageGrants ?? [] };
318
- return resolveKernelStages(defaultLifecycleStages, input.mutations ?? [], grants);
312
+ return resolveKernelStages(defaultLifecycleStages, input.mutations ?? []);
319
313
  }
320
314
  function defaultPipelineShowData(input = {}) {
321
315
  const resolved = resolveDefaultLifecycle(input);
@@ -324,7 +318,6 @@ function defaultPipelineShowData(input = {}) {
324
318
  index: orderIndex.get(entry.stageId) ?? null,
325
319
  id: entry.stageId,
326
320
  contributedBy: entry.contributedBy,
327
- protected: entry.isProtected,
328
321
  ...entry.removedBy !== undefined ? { removedBy: entry.removedBy } : {},
329
322
  ...entry.replacedBy !== undefined ? { replacedBy: entry.replacedBy } : {},
330
323
  wrappedBy: entry.wrappedBy ?? [],
@@ -349,7 +342,6 @@ function defaultKernelStatusData() {
349
342
  kernelProviderId: plugin.meta.id,
350
343
  kernelVersion: plugin.meta.version,
351
344
  capabilities,
352
- protectedStages: [...PROTECTED_DEFAULT_LIFECYCLE_STAGE_IDS],
353
345
  pipelineStageCount: resolved.order.length,
354
346
  stageOrder: [...resolved.order]
355
347
  };
@@ -359,7 +351,7 @@ function formatKernelStatus(data = defaultKernelStatusData()) {
359
351
  `kernel: ${data.kernelProviderId} v${data.kernelVersion}`,
360
352
  "capabilities (resolved provider):",
361
353
  ...Object.entries(data.capabilities).map(([cap, provider]) => ` ${cap.padEnd(14)} ${provider}`),
362
- `protected stages: ${data.protectedStages.join(", ")}`,
354
+ `lifecycle stages: mutable`,
363
355
  `resolved pipeline (${data.pipelineStageCount} stages): ${data.stageOrder.join(" -> ")}`
364
356
  ];
365
357
  return lines.join(`
@@ -370,12 +362,11 @@ function formatDefaultPipelineShow(input = {}) {
370
362
  const lines = [`${data.title}:`];
371
363
  for (const stage of data.stages) {
372
364
  if (stage.removedBy) {
373
- lines.push(` - ${stage.id.padEnd(20)} [${stage.contributedBy}] removed by [${stage.removedBy}]${stage.protected ? " PROTECTED" : ""}`);
365
+ lines.push(` - ${stage.id.padEnd(20)} [${stage.contributedBy}] removed by [${stage.removedBy}]`);
374
366
  continue;
375
367
  }
376
368
  const ordinal = stage.index === null ? " -." : `${String(stage.index).padStart(2)}.`;
377
369
  const annotations = [
378
- stage.protected ? "PROTECTED" : "",
379
370
  stage.replacedBy ? `replaced by [${stage.replacedBy}]` : "",
380
371
  stage.wrappedBy.length > 0 ? `wrapped by [${stage.wrappedBy.join(", ")}]` : ""
381
372
  ].filter(Boolean);
@@ -395,6 +386,115 @@ import {
395
386
  CloseoutValidationError
396
387
  } from "@rig/runtime/control-plane/native/in-process-closeout";
397
388
  import { taskValidate } from "@rig/runtime/control-plane/native/task-ops";
389
+
390
+ // packages/bundle-default-lifecycle/src/plugin.ts
391
+ import { definePlugin } from "@rig/core";
392
+
393
+ // packages/bundle-default-lifecycle/src/cli.ts
394
+ var DEFAULT_PIPELINE_CLI_ID = "default-lifecycle.pipeline";
395
+ var DEFAULT_KERNEL_CLI_ID = "default-lifecycle.kernel";
396
+ function printJson(value) {
397
+ console.log(JSON.stringify(value, null, 2));
398
+ }
399
+ function takeFlag(args, flag) {
400
+ const rest = [...args];
401
+ const index = rest.indexOf(flag);
402
+ if (index < 0)
403
+ return { value: false, rest };
404
+ rest.splice(index, 1);
405
+ return { value: true, rest };
406
+ }
407
+ function requireNoExtraArgs(args, usage) {
408
+ if (args.length > 0)
409
+ throw new Error(`Unexpected argument: ${args[0]}
410
+ Usage: ${usage}`);
411
+ }
412
+ async function executePipeline(context, args) {
413
+ const [first = "show", ...rest] = args;
414
+ const command = first.startsWith("-") ? "show" : first;
415
+ const commandArgs = first.startsWith("-") ? args : rest;
416
+ if (command !== "show")
417
+ throw new Error(`Unknown pipeline command: ${command}`);
418
+ const json = takeFlag(commandArgs, "--json");
419
+ requireNoExtraArgs(json.rest, "rig pipeline show [--json]");
420
+ const details = defaultPipelineShowData();
421
+ if (context.outputMode === "text") {
422
+ if (json.value)
423
+ printJson(details);
424
+ else
425
+ console.log(formatDefaultPipelineShow());
426
+ }
427
+ return { ok: true, group: "pipeline", command: "show", details };
428
+ }
429
+ async function executeKernel(context, args) {
430
+ const [first = "status", ...rest] = args;
431
+ const command = first.startsWith("-") ? "status" : first;
432
+ const commandArgs = first.startsWith("-") ? args : rest;
433
+ if (command !== "status")
434
+ throw new Error(`Unknown kernel command: ${command}`);
435
+ const json = takeFlag(commandArgs, "--json");
436
+ requireNoExtraArgs(json.rest, "rig kernel status [--json]");
437
+ const details = defaultKernelStatusData();
438
+ if (context.outputMode === "text") {
439
+ if (json.value)
440
+ printJson(details);
441
+ else
442
+ console.log(formatKernelStatus(details));
443
+ }
444
+ return { ok: true, group: "kernel", command: "status", details };
445
+ }
446
+ var defaultLifecycleCliCommands = [
447
+ {
448
+ id: DEFAULT_PIPELINE_CLI_ID,
449
+ family: "pipeline",
450
+ command: "rig pipeline show [--json]",
451
+ description: "Show the resolved default lifecycle pipeline.",
452
+ usage: "rig pipeline show [--json]",
453
+ run: executePipeline
454
+ },
455
+ {
456
+ id: DEFAULT_KERNEL_CLI_ID,
457
+ family: "kernel",
458
+ command: "rig kernel status [--json]",
459
+ description: "Show default kernel provider and lifecycle status.",
460
+ usage: "rig kernel status [--json]",
461
+ run: executeKernel
462
+ }
463
+ ];
464
+
465
+ // packages/bundle-default-lifecycle/src/plugin.ts
466
+ var DEFAULT_LIFECYCLE_PLUGIN_ID = "@rig/bundle-default-lifecycle";
467
+ function createDefaultLifecyclePlugin(stages = {}) {
468
+ const plugin = definePlugin({
469
+ name: DEFAULT_LIFECYCLE_PLUGIN_ID,
470
+ version: "0.0.0-alpha.1",
471
+ provides: [],
472
+ contributes: {
473
+ stages: defaultLifecycleStages,
474
+ capabilities: [
475
+ { id: "default-lifecycle.pipeline", title: "Default lifecycle pipeline", commandId: DEFAULT_PIPELINE_CLI_ID },
476
+ { id: "default-lifecycle.kernel-status", title: "Default kernel status", commandId: DEFAULT_KERNEL_CLI_ID }
477
+ ],
478
+ cliCommands: defaultLifecycleCliCommands.map(({ run: _run, ...metadata }) => metadata)
479
+ }
480
+ }, {
481
+ stages,
482
+ featureCapabilities: [
483
+ { id: "default-lifecycle.pipeline", title: "Default lifecycle pipeline", commandId: DEFAULT_PIPELINE_CLI_ID },
484
+ { id: "default-lifecycle.kernel-status", title: "Default kernel status", commandId: DEFAULT_KERNEL_CLI_ID }
485
+ ],
486
+ cliCommands: defaultLifecycleCliCommands
487
+ });
488
+ return {
489
+ ...plugin,
490
+ meta: { id: DEFAULT_LIFECYCLE_PLUGIN_ID, name: "Default Rig Lifecycle", version: "0.0.0-alpha.1" },
491
+ contributes: { ...plugin.contributes ?? {}, stages: defaultLifecycleStages },
492
+ runtime: { stages }
493
+ };
494
+ }
495
+ var defaultLifecyclePlugin = createDefaultLifecyclePlugin();
496
+
497
+ // packages/bundle-default-lifecycle/src/pipelineCloseout.ts
398
498
  function cleanString(value) {
399
499
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
400
500
  }
@@ -615,14 +715,15 @@ async function runPipelineCloseout(input) {
615
715
  },
616
716
  "journal-append": (ctx2) => cont(ctx2)
617
717
  };
718
+ const defaultLifecyclePlugin2 = createDefaultLifecyclePlugin(executors);
618
719
  const pluginStages = await loadPluginStageContributions(input.projectRoot);
619
- const kernel = createDefaultKernel({ stageExecutors: { ...executors, ...pluginStages.executors } });
620
- const resolved = kernel.stageRunner.resolve(defaultLifecycleStages, pluginStages.mutations);
720
+ const kernel = createDefaultKernel({ ...input.kernelJournal ? { journal: input.kernelJournal } : {}, stageExecutors: { ...defaultLifecyclePlugin2.runtime.stages, ...pluginStages.executors } });
721
+ const resolved = kernel.stageRunner.resolve(defaultLifecyclePlugin2.contributes.stages, pluginStages.mutations);
621
722
  const ctx = {
622
723
  runId: input.runId,
623
724
  taskId,
624
725
  state,
625
- metadata: { projectRoot: input.projectRoot, workspace }
726
+ metadata: { projectRoot: input.projectRoot, workspace, closeoutState: state }
626
727
  };
627
728
  await kernel.stageRunner.runPipeline(input.runId, resolved, ctx);
628
729
  const result = mapStateToResult(state);
@@ -648,16 +749,6 @@ function mapStateToResult(state) {
648
749
  }
649
750
  return { status: "needs-attention", ...state.prUrl ? { prUrl: state.prUrl } : {}, iterations: state.iterations, feedback: state.feedback };
650
751
  }
651
- // packages/bundle-default-lifecycle/src/plugin.ts
652
- var DEFAULT_LIFECYCLE_PLUGIN_ID = "@rig/bundle-default-lifecycle";
653
- function createDefaultLifecyclePlugin() {
654
- return {
655
- meta: { id: DEFAULT_LIFECYCLE_PLUGIN_ID, name: "Default Rig Lifecycle", version: "0.0.0-alpha.1" },
656
- provides: new Set,
657
- contributes: { stages: defaultLifecycleStages },
658
- runtime: { stages: defaultLifecycleStages }
659
- };
660
- }
661
752
  export {
662
753
  verifyStage,
663
754
  validateStage,
@@ -682,10 +773,14 @@ export {
682
773
  isolationStage,
683
774
  formatKernelStatus,
684
775
  formatDefaultPipelineShow,
776
+ executePipeline,
777
+ executeKernel,
685
778
  defineDefaultLifecycleStage,
686
779
  defaultPipelineShowData,
687
780
  defaultLifecycleStages,
688
781
  defaultLifecycleStageById,
782
+ defaultLifecyclePlugin,
783
+ defaultLifecycleCliCommands,
689
784
  defaultKernelStatusData,
690
785
  createDefaultLifecyclePlugin,
691
786
  compareCloseoutShadowRuns,
@@ -693,9 +788,10 @@ export {
693
788
  commitStage,
694
789
  autoMergeStage,
695
790
  assertCloseoutShadowEquivalent,
696
- PROTECTED_DEFAULT_LIFECYCLE_STAGE_IDS,
791
+ DEFAULT_PIPELINE_CLI_ID,
697
792
  DEFAULT_LIFECYCLE_STAGE_IDS,
698
793
  DEFAULT_LIFECYCLE_PLUGIN_ID,
794
+ DEFAULT_KERNEL_CLI_ID,
699
795
  CLOSEOUT_EQUIVALENCE_STATE_FILES,
700
796
  CLOSEOUT_EQUIVALENCE_ARTIFACTS
701
797
  };
@@ -7,11 +7,8 @@ export type PipelineCloseoutResult = {
7
7
  };
8
8
  /**
9
9
  * Run the default-lifecycle closeout as a resolved stage pipeline driven by the
10
- * kernel's stage runner. Each kernel stage executor invokes the corresponding
11
- * `run<Stage>` wrapper against the shared closeout state, so `open-pr`,
12
- * `merge-gate`, and `auto-merge` are discrete executed stages (the protected
13
- * `merge-gate` runs `runStrictPrMergeGate` as a real gate, blocking the
14
- * pipeline when the PR is not approved). This is the single closeout path; the
15
- * earlier parallel imperative `runStagedCloseout` copy is retired.
10
+ * kernel's stage runner. The lifecycle plugin contributes stage descriptors as
11
+ * metadata and the per-run executor map as runtime; plugin contributions can
12
+ * mutate and execute alongside those defaults.
16
13
  */
17
14
  export declare function runPipelineCloseout(input: InProcessCloseoutInput): Promise<PipelineCloseoutResult>;
@@ -21,7 +21,6 @@ import { runRepoDefaultMerge } from "@rig/runtime/control-plane/native/pr-automa
21
21
  function defineDefaultLifecycleStage(input) {
22
22
  return {
23
23
  ...input,
24
- protected: input.protected ?? false,
25
24
  priority: input.priority ?? 0
26
25
  };
27
26
  }
@@ -55,8 +54,7 @@ var isolationStage = defineDefaultLifecycleStage({
55
54
  id: "isolation",
56
55
  kind: "transform",
57
56
  description: "Provision the isolated runtime worktree through the runtime isolation subsystem.",
58
- calls: ["ensureAgentRuntime"],
59
- protected: true
57
+ calls: ["ensureAgentRuntime"]
60
58
  });
61
59
 
62
60
  // packages/bundle-default-lifecycle/src/stages/journal-append.ts
@@ -64,8 +62,7 @@ var journalAppendStage = defineDefaultLifecycleStage({
64
62
  id: "journal-append",
65
63
  kind: "observe",
66
64
  description: "Record resolved pipeline and per-stage outcome entries through the kernel journal capability.",
67
- calls: ["journalCapability.append"],
68
- protected: true
65
+ calls: ["journalCapability.append"]
69
66
  });
70
67
 
71
68
  // packages/bundle-default-lifecycle/src/stages/merge-gate.ts
@@ -76,8 +73,7 @@ var mergeGateStage = defineDefaultLifecycleStage({
76
73
  id: "merge-gate",
77
74
  kind: "gate",
78
75
  description: "Enforce GitHub review state, required checks, and configured review gates through runtime PR automation.",
79
- calls: ["runStrictPrMergeGate"],
80
- protected: true
76
+ calls: ["runStrictPrMergeGate"]
81
77
  });
82
78
  async function runMergeGateStage(input) {
83
79
  return await runStrictPrMergeGate({
@@ -202,9 +198,180 @@ var defaultLifecycleStages = [
202
198
  journalAppendStage
203
199
  ].map(withDefaultAnchors);
204
200
  function resolveDefaultLifecycle(input = {}) {
205
- const grants = { protectedStageGrants: input.protectedStageGrants ?? [] };
206
- return resolveKernelStages(defaultLifecycleStages, input.mutations ?? [], grants);
201
+ return resolveKernelStages(defaultLifecycleStages, input.mutations ?? []);
207
202
  }
203
+ function defaultPipelineShowData(input = {}) {
204
+ const resolved = resolveDefaultLifecycle(input);
205
+ const orderIndex = new Map(resolved.order.map((id, index) => [id, index + 1]));
206
+ const stages = resolved.record.map((entry) => ({
207
+ index: orderIndex.get(entry.stageId) ?? null,
208
+ id: entry.stageId,
209
+ contributedBy: entry.contributedBy,
210
+ ...entry.removedBy !== undefined ? { removedBy: entry.removedBy } : {},
211
+ ...entry.replacedBy !== undefined ? { replacedBy: entry.replacedBy } : {},
212
+ wrappedBy: entry.wrappedBy ?? [],
213
+ droppedAnchors: entry.droppedAnchors ?? []
214
+ }));
215
+ return {
216
+ title: `resolved run pipeline (${resolved.order.length} stages)`,
217
+ stageCount: resolved.order.length,
218
+ stages,
219
+ droppedAnchors: stages.flatMap((stage) => stage.droppedAnchors.map((anchor) => `${stage.id}:${anchor}`)),
220
+ cycles: resolved.cycles,
221
+ ...resolved.resolvedAt !== undefined ? { resolvedAt: resolved.resolvedAt } : {}
222
+ };
223
+ }
224
+ function defaultKernelStatusData() {
225
+ const plugin = createDefaultKernelPlugin();
226
+ const resolved = resolveDefaultLifecycle();
227
+ const capabilities = {};
228
+ for (const capability of plugin.provides)
229
+ capabilities[capability] = plugin.meta.id;
230
+ return {
231
+ kernelProviderId: plugin.meta.id,
232
+ kernelVersion: plugin.meta.version,
233
+ capabilities,
234
+ pipelineStageCount: resolved.order.length,
235
+ stageOrder: [...resolved.order]
236
+ };
237
+ }
238
+ function formatKernelStatus(data = defaultKernelStatusData()) {
239
+ const lines = [
240
+ `kernel: ${data.kernelProviderId} v${data.kernelVersion}`,
241
+ "capabilities (resolved provider):",
242
+ ...Object.entries(data.capabilities).map(([cap, provider]) => ` ${cap.padEnd(14)} ${provider}`),
243
+ `lifecycle stages: mutable`,
244
+ `resolved pipeline (${data.pipelineStageCount} stages): ${data.stageOrder.join(" -> ")}`
245
+ ];
246
+ return lines.join(`
247
+ `);
248
+ }
249
+ function formatDefaultPipelineShow(input = {}) {
250
+ const data = defaultPipelineShowData(input);
251
+ const lines = [`${data.title}:`];
252
+ for (const stage of data.stages) {
253
+ if (stage.removedBy) {
254
+ lines.push(` - ${stage.id.padEnd(20)} [${stage.contributedBy}] removed by [${stage.removedBy}]`);
255
+ continue;
256
+ }
257
+ const ordinal = stage.index === null ? " -." : `${String(stage.index).padStart(2)}.`;
258
+ const annotations = [
259
+ stage.replacedBy ? `replaced by [${stage.replacedBy}]` : "",
260
+ stage.wrappedBy.length > 0 ? `wrapped by [${stage.wrappedBy.join(", ")}]` : ""
261
+ ].filter(Boolean);
262
+ lines.push(` ${ordinal} ${stage.id.padEnd(20)} [${stage.contributedBy}]${annotations.length > 0 ? ` ${annotations.join(" ")}` : ""}`);
263
+ }
264
+ 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"}`);
265
+ return lines.join(`
266
+ `);
267
+ }
268
+
269
+ // packages/bundle-default-lifecycle/src/plugin.ts
270
+ import { definePlugin } from "@rig/core";
271
+
272
+ // packages/bundle-default-lifecycle/src/cli.ts
273
+ var DEFAULT_PIPELINE_CLI_ID = "default-lifecycle.pipeline";
274
+ var DEFAULT_KERNEL_CLI_ID = "default-lifecycle.kernel";
275
+ function printJson(value) {
276
+ console.log(JSON.stringify(value, null, 2));
277
+ }
278
+ function takeFlag(args, flag) {
279
+ const rest = [...args];
280
+ const index = rest.indexOf(flag);
281
+ if (index < 0)
282
+ return { value: false, rest };
283
+ rest.splice(index, 1);
284
+ return { value: true, rest };
285
+ }
286
+ function requireNoExtraArgs(args, usage) {
287
+ if (args.length > 0)
288
+ throw new Error(`Unexpected argument: ${args[0]}
289
+ Usage: ${usage}`);
290
+ }
291
+ async function executePipeline(context, args) {
292
+ const [first = "show", ...rest] = args;
293
+ const command = first.startsWith("-") ? "show" : first;
294
+ const commandArgs = first.startsWith("-") ? args : rest;
295
+ if (command !== "show")
296
+ throw new Error(`Unknown pipeline command: ${command}`);
297
+ const json = takeFlag(commandArgs, "--json");
298
+ requireNoExtraArgs(json.rest, "rig pipeline show [--json]");
299
+ const details = defaultPipelineShowData();
300
+ if (context.outputMode === "text") {
301
+ if (json.value)
302
+ printJson(details);
303
+ else
304
+ console.log(formatDefaultPipelineShow());
305
+ }
306
+ return { ok: true, group: "pipeline", command: "show", details };
307
+ }
308
+ async function executeKernel(context, args) {
309
+ const [first = "status", ...rest] = args;
310
+ const command = first.startsWith("-") ? "status" : first;
311
+ const commandArgs = first.startsWith("-") ? args : rest;
312
+ if (command !== "status")
313
+ throw new Error(`Unknown kernel command: ${command}`);
314
+ const json = takeFlag(commandArgs, "--json");
315
+ requireNoExtraArgs(json.rest, "rig kernel status [--json]");
316
+ const details = defaultKernelStatusData();
317
+ if (context.outputMode === "text") {
318
+ if (json.value)
319
+ printJson(details);
320
+ else
321
+ console.log(formatKernelStatus(details));
322
+ }
323
+ return { ok: true, group: "kernel", command: "status", details };
324
+ }
325
+ var defaultLifecycleCliCommands = [
326
+ {
327
+ id: DEFAULT_PIPELINE_CLI_ID,
328
+ family: "pipeline",
329
+ command: "rig pipeline show [--json]",
330
+ description: "Show the resolved default lifecycle pipeline.",
331
+ usage: "rig pipeline show [--json]",
332
+ run: executePipeline
333
+ },
334
+ {
335
+ id: DEFAULT_KERNEL_CLI_ID,
336
+ family: "kernel",
337
+ command: "rig kernel status [--json]",
338
+ description: "Show default kernel provider and lifecycle status.",
339
+ usage: "rig kernel status [--json]",
340
+ run: executeKernel
341
+ }
342
+ ];
343
+
344
+ // packages/bundle-default-lifecycle/src/plugin.ts
345
+ var DEFAULT_LIFECYCLE_PLUGIN_ID = "@rig/bundle-default-lifecycle";
346
+ function createDefaultLifecyclePlugin(stages = {}) {
347
+ const plugin = definePlugin({
348
+ name: DEFAULT_LIFECYCLE_PLUGIN_ID,
349
+ version: "0.0.0-alpha.1",
350
+ provides: [],
351
+ contributes: {
352
+ stages: defaultLifecycleStages,
353
+ capabilities: [
354
+ { id: "default-lifecycle.pipeline", title: "Default lifecycle pipeline", commandId: DEFAULT_PIPELINE_CLI_ID },
355
+ { id: "default-lifecycle.kernel-status", title: "Default kernel status", commandId: DEFAULT_KERNEL_CLI_ID }
356
+ ],
357
+ cliCommands: defaultLifecycleCliCommands.map(({ run: _run, ...metadata }) => metadata)
358
+ }
359
+ }, {
360
+ stages,
361
+ featureCapabilities: [
362
+ { id: "default-lifecycle.pipeline", title: "Default lifecycle pipeline", commandId: DEFAULT_PIPELINE_CLI_ID },
363
+ { id: "default-lifecycle.kernel-status", title: "Default kernel status", commandId: DEFAULT_KERNEL_CLI_ID }
364
+ ],
365
+ cliCommands: defaultLifecycleCliCommands
366
+ });
367
+ return {
368
+ ...plugin,
369
+ meta: { id: DEFAULT_LIFECYCLE_PLUGIN_ID, name: "Default Rig Lifecycle", version: "0.0.0-alpha.1" },
370
+ contributes: { ...plugin.contributes ?? {}, stages: defaultLifecycleStages },
371
+ runtime: { stages }
372
+ };
373
+ }
374
+ var defaultLifecyclePlugin = createDefaultLifecyclePlugin();
208
375
 
209
376
  // packages/bundle-default-lifecycle/src/pipelineCloseout.ts
210
377
  function cleanString(value) {
@@ -427,14 +594,15 @@ async function runPipelineCloseout(input) {
427
594
  },
428
595
  "journal-append": (ctx2) => cont(ctx2)
429
596
  };
597
+ const defaultLifecyclePlugin2 = createDefaultLifecyclePlugin(executors);
430
598
  const pluginStages = await loadPluginStageContributions(input.projectRoot);
431
- const kernel = createDefaultKernel({ stageExecutors: { ...executors, ...pluginStages.executors } });
432
- const resolved = kernel.stageRunner.resolve(defaultLifecycleStages, pluginStages.mutations);
599
+ const kernel = createDefaultKernel({ ...input.kernelJournal ? { journal: input.kernelJournal } : {}, stageExecutors: { ...defaultLifecyclePlugin2.runtime.stages, ...pluginStages.executors } });
600
+ const resolved = kernel.stageRunner.resolve(defaultLifecyclePlugin2.contributes.stages, pluginStages.mutations);
433
601
  const ctx = {
434
602
  runId: input.runId,
435
603
  taskId,
436
604
  state,
437
- metadata: { projectRoot: input.projectRoot, workspace }
605
+ metadata: { projectRoot: input.projectRoot, workspace, closeoutState: state }
438
606
  };
439
607
  await kernel.stageRunner.runPipeline(input.runId, resolved, ctx);
440
608
  const result = mapStateToResult(state);
@@ -1,18 +1,19 @@
1
- import type { CapabilityTag } from "@rig/contracts";
1
+ import { type RigPluginWithRuntime } from "@rig/core";
2
+ import type { StageRun } from "@rig/contracts";
2
3
  import { defaultLifecycleStages } from "./defaultPipeline";
3
4
  export declare const DEFAULT_LIFECYCLE_PLUGIN_ID = "@rig/bundle-default-lifecycle";
4
- export type DefaultLifecyclePlugin = {
5
+ export type DefaultLifecyclePlugin = RigPluginWithRuntime & {
5
6
  readonly meta: {
6
7
  readonly id: typeof DEFAULT_LIFECYCLE_PLUGIN_ID;
7
8
  readonly name: string;
8
9
  readonly version: string;
9
10
  };
10
- readonly provides: ReadonlySet<CapabilityTag>;
11
- readonly contributes: {
11
+ readonly contributes: NonNullable<RigPluginWithRuntime["contributes"]> & {
12
12
  readonly stages: typeof defaultLifecycleStages;
13
13
  };
14
14
  readonly runtime: {
15
- readonly stages: typeof defaultLifecycleStages;
15
+ readonly stages: Readonly<Record<string, StageRun>>;
16
16
  };
17
17
  };
18
- export declare function createDefaultLifecyclePlugin(): DefaultLifecyclePlugin;
18
+ export declare function createDefaultLifecyclePlugin(stages?: Readonly<Record<string, StageRun>>): DefaultLifecyclePlugin;
19
+ export declare const defaultLifecyclePlugin: DefaultLifecyclePlugin;