import { describe, expect, test } from "bun:test"; import { CliError, DEFAULT_SEED_BATCH_SIZE, MAX_DESCRIBE_ENTRIES, parse } from "./cli"; describe("cli parse", () => { test("parses search payload", () => { const command = parse(["search", '{"query":"browser automation"}']); expect(command).toEqual({ kind: "search", input: { query: "browser automation" }, }); }); test("rejects oversized describe batches", () => { const entries = Array.from({ length: MAX_DESCRIBE_ENTRIES + 1 }, (_, index) => ({ name: `tool-${index}`, description: "One sentence.", })); expect(() => parse(["describe", JSON.stringify({ entries })])).toThrow(CliError); }); test("parses seed export payload with default batch size", () => { const command = parse(["seed-export", '{"directory":"./seed"}']); expect(command).toEqual({ kind: "seed-export", input: { directory: "./seed", batch_size: DEFAULT_SEED_BATCH_SIZE }, }); }); test("parses seed import payload", () => { const command = parse(["seed-import", '{"directory":"./seed"}']); expect(command).toEqual({ kind: "seed-import", input: { directory: "./seed" }, }); }); });