Files
reverse-engineering-anything/tests/fixtures/managedComparisonCommand.ts
T
Ysopwnableandgensokyo-dev 62014b566d refactor(cli)!: dispatch commands through REA-owned execution
Run ordinary CLI commands through REA's registry, argv parser and result owner.
Remove Incur, the second admission parse, SDK error middleware, output capture
and redundant command traversal. Preserve explicit redaction, publication
receipts, incremental output, terminal notice eligibility and drain ownership.
Migrate fixtures to real registrations and retain the derived-source notices.

Validation includes unchanged public parity goldens, public and lifecycle
regressions, repaired fixture consumers, real TTY base comparisons, exports
beyond the engine string limit, four schema catalogs and final static/docs
checks. Native provider and optional validator coverage limits are in the PR.

Fixes #11654. Fixes #10583. Refs #11682, #11476 and #10511.

BREAKING CHANGE: Markdown argument diagnostics use REA's literal escaping,
table widths and token counts. Flag-shaped unknown MCP subcommands honor the
selected format. Completion --schema/--version routes use the canonical
REA-owned hook rather than the retired SDK generator. Refresh affected literal
snapshots and regenerate completion hooks with rea completions <shell>.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-16 13:56:34 +00:00

49 lines
1.8 KiB
TypeScript

import { registerManagedCommands } from "../../src/cli/managedCommands.js";
import { cliCommand } from "../../src/cli/commandRegistry.js";
import { cliCommandFor } from "../../src/contracts/cliCommandNames.js";
import { createDirectAnalysis } from "../../src/composition/directAnalysis.js";
import type { DirectAnalysis } from "../../src/composition/directAnalysis.js";
import { silentLogger } from "../../src/logger.js";
import { isRecord } from "../../src/kernel/isRecord.js";
import { createCommandCli } from "../support/cli/commandCli.js";
type ManagedEvidenceRunner = DirectAnalysis["runManagedProviderEvidence"];
/**
* The registered compare-managed-members command, run in this process with
* the production managed Evidence runner unless a test supplies one.
*/
export const managedComparisonCommand = (
runManagedProviderEvidence: ManagedEvidenceRunner = createDirectAnalysis({})
.runManagedProviderEvidence,
) => {
const cli = createCommandCli();
registerManagedCommands(cli, silentLogger, {
runProviderAnalysis: () => {
throw new Error("Comparison runs only managed Evidence");
},
runManagedProviderEvidence,
});
const command = cliCommand(
cli,
cliCommandFor("compare_managed_members"),
)?.definition;
if (command === undefined)
throw new Error("compare-managed-members is not registered");
/** Run the command as argv would select it, returning its JSON output. */
return async (
leftPath: string,
rightPath: string,
options: Readonly<Record<string, unknown>> = {},
): Promise<Record<string, unknown>> => {
const value = await command.run({
args: { leftPath, rightPath },
options,
formatExplicit: false,
});
if (!isRecord(value))
throw new Error("Managed comparison did not return a document");
return value;
};
};