Files
reverse-engineering-anything/src/cli/processCommands.ts
T
morlutoandNianze Wu 6b2f991808 fix(ci): restore lifecycle ownership coverage (#10147)
* fix(process): retain CLI input cleanup ownership

* test(ci): align lifecycle fixtures with typed ownership contracts

---------

Co-authored-by: Nianze Wu <wunianze666@gmail.com>
2026-11-11 18:37:28 -05:00

56 lines
1.9 KiB
TypeScript

import { Cli, z } from "incur";
import {
captureProcessScenarioFile,
compareProcessEvidenceFiles,
projectProcessCliInputCleanupError,
} from "../application/process/ProcessCli.js";
import { logCliCommand } from "../cliLogging.js";
import type { Logger } from "pino";
import { CLI_COMMANDS } from "../cliCommandNames.js";
import { localPathStringSchema } from "../domain/localPath.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: localPathStringSchema.describe("Scenario JSON path"),
}),
run: ({ args }) =>
withCommandCancellation((signal) =>
logCliCommand(logger, "capture-process", () =>
captureProcessScenarioFile(args.scenario, environment, signal).catch(
projectProcessCliInputCleanupError,
),
),
),
});
cli.command(CLI_COMMANDS.compareProcessCaptures, {
description: "Compare two process capture Evidence JSON files",
args: z.object({
left: localPathStringSchema.describe("Left capture Evidence JSON path"),
right: localPathStringSchema.describe("Right capture Evidence JSON path"),
traceSpec: localPathStringSchema
.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,
).catch(projectProcessCliInputCleanupError),
),
),
});
};