Files
reverse-engineering-anything/tests/fixtures/managedComparisonCommand.ts
T
morlutoandCursor Agent 2bf347dee6 fix(cli): reject invalid inline values and honor requested output on terminals (#14763)
* fix(cli): reject invalid inline values and honor requested output on terminals

- Reject inline boolean and empty number values the schema cannot accept
  instead of coercing --skill=yes to false or --limit= to 0.
- Give captured mcp add output the terminal presentation of every other
  command through one shared result destination.
- Show the unapproved setup plan whose remediation asks a terminal reader to
  review it, and open the setup rail once when a scoped run starts at approval.
- Treat --full-output and --token-count as requesting the result document, so
  setup and argument errors no longer add terminal presentation beside it.
- Answer --schema for an unknown command in the selected format, and set the
  exit code instead of exiting so piped stdout drains.

* fix(cli): keep rejected boolean and number literals across repeated flags

Binding stored one scalar value, so a later valid flag replaced an earlier
literal before the schema could reject it. Boolean and number literals the
field rejects now stay bound, including decimal unions and count options,
while repeated valid flags still use the last value. --dry-run keeps its
own error.

* test(cli): assert the terminal full-output failure envelope

The terminal --full-output regression only checked that usage text was
absent. Decode the default document and the --json envelope and require
VALIDATION_ERROR with the skill field's invalid_type error.

* test(cli): accept a counted setup approval prompt

A scoped terminal plan names every eligible action, so a Linux host that
can install Hopper asks "Apply these N changes?" rather than the singular
question. The consent helper now answers either prompt, and the rail test
finds that question before checking the intro was rendered once.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-26 12:15:17 -05: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,
structuredOutput: false,
});
if (!isRecord(value))
throw new Error("Managed comparison did not return a document");
return value;
};
};