mirror of
https://github.com/morluto/rea.git
synced 2026-11-14 10:43:30 +00:00
* refactor(cli): run one-shot commands through one shared owner scripts/rea.mjs and the test CLI session worker each implemented the one-shot command sequence: argument normalization, output admission, configuration errors, version documents, the Amp scope refusal, and result delivery. The worker copy had drifted: it never rendered formatted version reports or the Amp refusal. Move the sequence into src/cliOneShot.ts. Both callers supply a host for their streams, exit and resource ownership. The launcher keeps closed-pipe status, worker shutdown and process exit; the session worker captures output per command. The cliOutput bundle entry is superseded and removed. The dispatcher test now replaces only the command runtime, so output admission runs production code. A new parity test compares the file session with a fresh process. * test(cli): bundle the one-shot entry in the runtime bundle fixture
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { expect } from "vitest";
|
|
|
|
import { cliTest, runFileCli } from "../../support/cli/cliFixture.js";
|
|
|
|
// The file session and the executable run one shared one-shot owner. These
|
|
// commands are answered before the command runtime loads, which is where a
|
|
// separate session implementation previously diverged.
|
|
cliTest.for([
|
|
{ name: "a formatted version report", arguments: ["--version", "--json"] },
|
|
{
|
|
name: "a project-scoped Amp registration refusal",
|
|
arguments: ["mcp", "add", "--no-global", "--agent", "amp", "--json"],
|
|
},
|
|
{
|
|
name: "a rejected output combination",
|
|
arguments: ["capabilities", "--json", "--token-limit", "5"],
|
|
},
|
|
])(
|
|
"the file session reports $name exactly as a fresh process does",
|
|
async ({ arguments: arguments_ }, { cli }) => {
|
|
const environment = { REA_LOG_LEVEL: "silent" };
|
|
const fresh = await cli.run({ arguments: arguments_, environment });
|
|
const shared = await runFileCli(cli, {
|
|
arguments: arguments_,
|
|
environment,
|
|
});
|
|
expect(fresh.stdout).not.toBe("");
|
|
expect({
|
|
exitCode: shared.exitCode,
|
|
stdout: shared.stdout,
|
|
stderr: shared.stderr,
|
|
}).toEqual({
|
|
exitCode: fresh.exitCode,
|
|
stdout: fresh.stdout,
|
|
stderr: fresh.stderr,
|
|
});
|
|
},
|
|
);
|