mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
Read CLI catalogs and registrar ownership from the REA command records, type-check the catalog helper and consolidate registrar types. Preserve the generated catalogs, mapping and CLI parity. Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { z } from "zod";
|
|
|
|
import { createCli } from "../../../src/cli.js";
|
|
import { cliCommands } from "../../../src/cli/commandRegistry.js";
|
|
import { createCliInventory } from "../../../scripts/lib/catalog-cli.mjs";
|
|
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
|
import {
|
|
CLI_COMMAND_NAMES,
|
|
cliCommandNames,
|
|
} from "../../../src/contracts/catalog/catalogIdentity.js";
|
|
import { describeContractCommand } from "../../../src/cli/contractCliDescription.js";
|
|
|
|
import { CLI_COMMAND_TOOL_ALIASES } from "./cliContractAliases.js";
|
|
|
|
describe("CLI canonical tool coverage", () => {
|
|
it("registers every derived command and every alias of an MCP tool", () => {
|
|
const registered = createCliInventory(cliCommands(createCli()));
|
|
expect(registered.primary).toEqual([...CLI_COMMAND_NAMES].sort());
|
|
const names = new Set<string>(TOOL_CONTRACTS.map(({ name }) => name));
|
|
for (const [command, tools] of Object.entries(CLI_COMMAND_TOOL_ALIASES)) {
|
|
expect(registered.primary).toContain(command);
|
|
for (const tool of tools) expect(names.has(tool)).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("names a contract's command from its declaration alone", () => {
|
|
const contract = {
|
|
name: "inspect_synthetic_probe",
|
|
cli: true,
|
|
inputSchema: z.strictObject({ path: z.string() }),
|
|
} as const;
|
|
expect(cliCommandNames([contract])).toContain("inspect-synthetic-probe");
|
|
expect(
|
|
describeContractCommand(contract, {
|
|
description: "Probe",
|
|
positionals: ["path"],
|
|
}).command,
|
|
).toBe("inspect-synthetic-probe");
|
|
const { cli: _undeclared, ...mcpOnly } = contract;
|
|
expect(cliCommandNames([mcpOnly])).not.toContain("inspect-synthetic-probe");
|
|
expect(() =>
|
|
describeContractCommand(mcpOnly, { description: "Probe" }),
|
|
).toThrow("inspect_synthetic_probe does not declare its CLI command");
|
|
});
|
|
});
|