mirror of
https://github.com/morluto/rea.git
synced 2026-11-17 04:04:25 +00:00
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>
124 lines
2.8 KiB
TypeScript
124 lines
2.8 KiB
TypeScript
import { it, expect } from "vitest";
|
|
import {
|
|
parseCliGlobalArguments,
|
|
productionMcpDoctorArguments,
|
|
} from "../../../src/cliBuiltinArguments.js";
|
|
|
|
// Observed with Incur 0.6.1 before removing the dependency.
|
|
it.each([
|
|
{
|
|
input: [],
|
|
rest: [],
|
|
enabled: false,
|
|
},
|
|
{
|
|
input: ["--timings"],
|
|
rest: [],
|
|
enabled: true,
|
|
},
|
|
{
|
|
input: ["--no-timings"],
|
|
rest: [],
|
|
enabled: false,
|
|
},
|
|
{
|
|
input: ["--timings=false"],
|
|
rest: [],
|
|
enabled: false,
|
|
},
|
|
{
|
|
input: ["--timings=true"],
|
|
rest: [],
|
|
enabled: true,
|
|
},
|
|
{
|
|
input: ["--timings=other"],
|
|
rest: [],
|
|
enabled: false,
|
|
},
|
|
{
|
|
input: ["--timings="],
|
|
rest: [],
|
|
enabled: false,
|
|
},
|
|
{
|
|
input: ["--timings", "--no-timings"],
|
|
rest: [],
|
|
enabled: false,
|
|
},
|
|
{
|
|
input: ["--no-timings", "--timings=true"],
|
|
rest: [],
|
|
enabled: true,
|
|
},
|
|
{
|
|
input: ["--timings=false", "--timings"],
|
|
rest: [],
|
|
enabled: true,
|
|
},
|
|
{
|
|
input: ["--", "--timings"],
|
|
rest: ["--", "--timings"],
|
|
enabled: false,
|
|
},
|
|
])(
|
|
"preserves the recorded boolean global grammar for %j",
|
|
({ input, rest, enabled }) => {
|
|
const actual = parseCliGlobalArguments(input);
|
|
expect({ arguments: actual.command, enabled: actual.timings }).toEqual({
|
|
arguments: rest,
|
|
enabled,
|
|
});
|
|
},
|
|
);
|
|
|
|
it.each([
|
|
"--timings",
|
|
"--no-timings",
|
|
"--timings=false",
|
|
"--timings=true",
|
|
"--timings=other",
|
|
"--timings=",
|
|
])("preserves output values and root alias with %s", (flag) => {
|
|
expect(
|
|
productionMcpDoctorArguments(["mcp", "doctor", "--format", flag]),
|
|
).toEqual({ arguments: ["--format", flag], timings: false });
|
|
expect(
|
|
parseCliGlobalArguments([flag, "--update", "--json"]).arguments,
|
|
).toEqual(["update", flag, "--json"]);
|
|
expect(
|
|
parseCliGlobalArguments(["--update", flag, "--json"]).arguments,
|
|
).toEqual(["update", flag, "--json"]);
|
|
expect(parseCliGlobalArguments([flag, "mcp", "doctor"]).command).toEqual([
|
|
"mcp",
|
|
"doctor",
|
|
]);
|
|
});
|
|
it("retains the separator and its following timing-shaped data", () => {
|
|
expect(
|
|
parseCliGlobalArguments(["--", "--update", "--timings=false"]).arguments,
|
|
).toEqual(["--", "--update", "--timings=false"]);
|
|
expect(
|
|
productionMcpDoctorArguments([
|
|
"mcp",
|
|
"doctor",
|
|
"--format",
|
|
"--",
|
|
"--timings=true",
|
|
]),
|
|
).toEqual({ arguments: ["--format", "--"], timings: true });
|
|
});
|
|
it("takes the doctor words and timing global out of the doctor's arguments", () => {
|
|
expect(
|
|
productionMcpDoctorArguments([
|
|
"--timings",
|
|
"mcp",
|
|
"--format=json",
|
|
"doctor",
|
|
"--no-timings",
|
|
"--verbose",
|
|
]),
|
|
).toEqual({ arguments: ["--format", "json", "--verbose"], timings: false });
|
|
expect(productionMcpDoctorArguments(["mcp", "add"])).toBeUndefined();
|
|
});
|