Files
rea/src/cli/processCommands.ts
T
morluto faf219e90b refactor(application): use current Evidence and CLI contracts
Require the immutable Evidence read APIs already implemented by production owners. Remove the detached-only compatibility fallbacks and forwarding helpers, and bind consumers directly to their owner. Preserve editable detached exports and existing snapshot semantics.

Use the shared canonical CLI error classifier for process commands instead of reinterpreting their projection. Validation: 172 focused application and process tests, build, static checks and documentation checks passed using local fixtures.
2026-10-25 02:44:21 +08:00

51 lines
1.7 KiB
TypeScript

import { Cli, z } from "incur";
import {
captureProcessScenarioFile,
compareProcessEvidenceFiles,
} from "../application/process/ProcessCli.js";
import { logCliCommand } from "../cliLogging.js";
import type { Logger } from "pino";
import { CLI_COMMANDS } from "../cliCommandNames.js";
import { withCommandCancellation } from "./commandCancellation.js";
/** Register direct process capture and comparison commands. */
export const registerProcessCommands = (
cli: ReturnType<typeof Cli.create>,
logger: Logger,
environment: Readonly<Record<string, string | undefined>>,
): void => {
cli.command(CLI_COMMANDS.captureProcess, {
description: "Capture one caller-selected process scenario",
args: z.object({ scenario: z.string().describe("Scenario JSON path") }),
run: ({ args }) =>
withCommandCancellation((signal) =>
logCliCommand(logger, "capture-process", () =>
captureProcessScenarioFile(args.scenario, environment, signal),
),
),
});
cli.command(CLI_COMMANDS.compareProcessCaptures, {
description: "Compare two process capture Evidence JSON files",
args: z.object({
left: z.string().describe("Left capture Evidence JSON path"),
right: z.string().describe("Right capture Evidence JSON path"),
traceSpec: z
.string()
.optional()
.describe("Optional partial-order or finite-trace specification path"),
}),
run: ({ args }) =>
withCommandCancellation((signal) =>
logCliCommand(logger, "compare-process-captures", () =>
compareProcessEvidenceFiles(
args.left,
args.right,
args.traceSpec,
signal,
),
),
),
});
};