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>
80 lines
2.7 KiB
TypeScript
80 lines
2.7 KiB
TypeScript
import { createCommandCli } from "../../support/cli/commandCli.js";
|
|
import pino from "pino";
|
|
import { readFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect, it, vi } from "vitest";
|
|
|
|
import { registerCoreNativeCommands } from "../../../src/cli/coreNativeCommands.js";
|
|
import {
|
|
createEvidence,
|
|
parseEvidence,
|
|
withEvidenceCallerInputPath,
|
|
} from "../../../src/domain/evidence.js";
|
|
import { parseEvidenceBundle } from "../../../src/domain/evidenceBundle.js";
|
|
import { inspectAnalysisView } from "../../../src/application/analysisView/AnalysisViewService.js";
|
|
import { nativeDosLoadImageFixture } from "../../fixtures/nativeLoadImage.js";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
|
|
it("preserves the relative request path in a load-image CLI summary and its complete bundle", async () => {
|
|
const directory = await createTestTempDirectory("rea-load-image-cli-path-");
|
|
const destination = join(directory, "complete.json");
|
|
const selectedPath = "./alias/../selected.exe";
|
|
const parent = withEvidenceCallerInputPath(
|
|
createEvidence(
|
|
{ path: "/selected.exe", sha256: "a".repeat(64), format: "dos-mz" },
|
|
{ id: "ghidra", name: "Ghidra", version: "12.1.4" },
|
|
{
|
|
operation: "inspect_native_load_image",
|
|
parameters: {},
|
|
result: nativeDosLoadImageFixture(),
|
|
},
|
|
),
|
|
selectedPath,
|
|
);
|
|
const run = vi.fn(async () => ({ ok: true as const, value: parent }));
|
|
const cli = createCommandCli();
|
|
registerCoreNativeCommands(cli, pino({ enabled: false }), run);
|
|
let stdout = "";
|
|
await cli.serve(
|
|
[
|
|
"inspect-native-load-image",
|
|
selectedPath,
|
|
"--detail",
|
|
"summary",
|
|
"--evidence_output",
|
|
destination,
|
|
"--json",
|
|
],
|
|
{
|
|
env: {},
|
|
stdout: (text) => {
|
|
stdout += text;
|
|
},
|
|
exit: () => undefined,
|
|
},
|
|
);
|
|
const receipt = JSON.parse(stdout);
|
|
const summary = parseEvidence(receipt.summary);
|
|
expect(summary.caller_input_path).toBe(selectedPath);
|
|
expect(run).toHaveBeenCalledExactlyOnceWith(
|
|
selectedPath,
|
|
"inspect_native_load_image",
|
|
{},
|
|
expect.any(Object),
|
|
);
|
|
const bundle = parseEvidenceBundle(
|
|
JSON.parse(await readFile(destination, "utf8")),
|
|
);
|
|
expect(bundle.records).toEqual([parent]);
|
|
expect(summary.normalized_result).toMatchObject({
|
|
parent_evidence_id: parent.evidence_id,
|
|
});
|
|
const later = await inspectAnalysisView({
|
|
source: { kind: "inline", evidence: parent },
|
|
view: { kind: "summary" },
|
|
});
|
|
if (!later.ok) throw later.error;
|
|
expect(later.value).not.toHaveProperty("caller_input_path");
|
|
expect(later.value.evidence_id).toBe(summary.evidence_id);
|
|
});
|