Files
reverse-engineering-anything/tests/boundary/cli/cliCommandRegistry.test.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

101 lines
3.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { createCli } from "../../../src/cli.js";
import { cliCommands } from "../../../src/cli/commandRegistry.js";
const cli = createCli({});
const entries = cliCommands(cli);
const entry = (name: string) => {
const found = entries.find((candidate) => candidate.name === name);
if (found === undefined) throw new Error(`${name} is not registered`);
return found;
};
describe("REA's CLI command table", () => {
it("names the operations a direct-analysis command runs and the flag of each field", () => {
expect(entry("function").operations).toEqual([
{ name: "analyze_function", flags: expect.any(Object) },
{
name: "open_binary",
flags: {
format: "--target-format",
architecture: "--architecture",
entry_point: "--entry-point",
provider_id: "--provider",
snapshot_path: "--snapshot",
},
},
]);
// `--kind procedures` chooses another operation.
expect(entry("search").operations.map(({ name }) => name)).toEqual([
"search_strings",
"open_binary",
"search_procedures",
]);
expect(entry("decompile").operations.map(({ name }) => name)).toEqual([
"procedure_pseudo_code",
"open_binary",
]);
// The overview route opens its target the same way.
expect(
entry("analyze").operations.find(({ name }) => name === "open_binary")
?.flags,
).toMatchObject({ snapshot_path: "--snapshot" });
});
it("records each route of a routed command and each contract command's own flags", () => {
expect(entry("analyze").operations.map(({ name }) => name)).toEqual([
"analyze_javascript_application",
"binary_overview",
"open_binary",
]);
expect(entry("analyze").source.kind).toBe("routed");
expect(entry("inspect-byte-entropy").operations).toEqual([
{
name: "inspect_byte_entropy",
flags: {
block_size: "--block-size",
offset: "--offset",
length: "--length",
},
},
]);
});
it("flags every contract field an option sets: grouped fields and named selectors", () => {
const flags = (command: string, operation: string) =>
entry(command).operations.find(({ name }) => name === operation)?.flags;
// One JSON option supplies each field of its group; the group's CLI key
// is not a contract field.
const jni = flags(
"inspect-android-jni-bindings",
"inspect_android_jni_bindings",
);
expect(jni).toMatchObject({
class_name: "--query",
method_names: "--query",
descriptors: "--query",
abis: "--query",
library_paths: "--query",
});
expect(jni).not.toHaveProperty("query");
// A positional selector is also set by its named option.
expect(flags("function", "analyze_function")).toMatchObject({
procedure: "--procedure",
});
expect(flags("decompile", "procedure_pseudo_code")).toMatchObject({
procedure: "--procedure",
});
expect(flags("search", "search_strings")).toMatchObject({
pattern: "--pattern",
});
});
it("lists host commands without operations", () => {
for (const name of ["setup", "doctor", "guidance", "capture-process"]) {
expect(entry(name).source).toEqual({ kind: "host" });
expect(entry(name).operations).toEqual([]);
}
});
});