import { describe, expect, it, vi } from "vitest";
import { PROMPT_COMMANDS } from "./prompt-commands.js";
describe("prompt commands", () => {
    it("no longer defines the /goal command", () => {
        expect(PROMPT_COMMANDS.find((command) => command.name === "goal")).toBeUndefined();
        expect(PROMPT_COMMANDS.find((command) => command.aliases.includes("g"))).toBeUndefined();
    });
    it("hands bullet-proof fixes off to the tasks tool, not a Goal", () => {
        const bulletProof = PROMPT_COMMANDS.find((command) => command.name === "bullet-proof");
        expect(bulletProof?.prompt).toContain("`tasks` tool");
        expect(bulletProof?.prompt).toContain("Press Ctrl+T to open the task list");
        expect(bulletProof?.prompt).not.toContain("Create a Goal");
        expect(bulletProof?.prompt).not.toContain("Press CTRL + G");
    });
    it("tells commands that name kencode tools how to unlock deferred MCP", () => {
        // `deferredMcpTools` defaults to true, so `mcp__kencode-search__*` sits in
        // the tool_search catalog until promoted. A command that hard-names it must
        // say how to unlock it, or the call fails on a default install.
        for (const name of ["compare", "expand"]) {
            const cmd = PROMPT_COMMANDS.find((command) => command.name === name);
            expect(cmd?.prompt, name).toContain("mcp__kencode-search__");
            expect(cmd?.prompt, name).toContain("call `tool_search`");
        }
    });
    it("frames bullet-proof as an authorized defensive review with no exploit output", () => {
        const bulletProof = PROMPT_COMMANDS.find((command) => command.name === "bullet-proof");
        expect(bulletProof?.prompt).toContain("authorized defensive security review");
        expect(bulletProof?.prompt).toContain("Never produce working exploit code");
        expect(bulletProof?.prompt).toContain("data-flow level");
        // Subagents never see the command prompt — the handoff must say so.
        expect(bulletProof?.prompt).toContain("Subagents cannot see this prompt.");
        // Skeptic verification is batched to keep fan-out cost bounded.
        expect(bulletProof?.prompt).toContain("batching 3–5 surviving findings per skeptic");
        expect(bulletProof?.prompt).not.toContain("<specific payload>");
    });
    it("points at the app's Tasks button / New Session instead of CLI keybinds when run under gg-app", async () => {
        const previous = process.env.GG_APP_PORT;
        process.env.GG_APP_PORT = "0";
        vi.resetModules();
        try {
            const { PROMPT_COMMANDS: appPromptCommands } = await import("./prompt-commands.js");
            const bulletProof = appPromptCommands.find((command) => command.name === "bullet-proof");
            const init = appPromptCommands.find((command) => command.name === "init");
            expect(bulletProof?.prompt).toContain('Click the "Tasks" button');
            expect(bulletProof?.prompt).not.toContain("Ctrl+T");
            expect(init?.prompt).toContain("New Session");
            expect(init?.prompt).toContain('click "+ New"');
            expect(init?.prompt).not.toContain("restart ggcoder");
            expect(init?.prompt).not.toContain("/quit");
        }
        finally {
            if (previous === undefined)
                delete process.env.GG_APP_PORT;
            else
                process.env.GG_APP_PORT = previous;
            vi.resetModules();
        }
    });
    it("removes retired prompt-template commands", () => {
        const removedCommandNames = [
            "scan",
            "verify",
            "source",
            "simplify",
            "batch",
            "research",
            "setup",
            "setup-lint",
            `setup-${"tests"}`,
            "setup-update",
        ];
        const removedAliases = ["depcheck", "depsource", "setup-project"];
        for (const name of removedCommandNames) {
            expect(PROMPT_COMMANDS.find((command) => command.name === name)).toBeUndefined();
        }
        for (const alias of removedAliases) {
            expect(PROMPT_COMMANDS.find((command) => command.aliases.includes(alias))).toBeUndefined();
        }
    });
    it("defines /expand as a fresh, repo-validated, feature-first plan-mode command", () => {
        const expand = PROMPT_COMMANDS.find((command) => command.name === "expand");
        expect(expand).toBeDefined();
        expect(expand?.prompt).toContain("Spawn exactly 5 sub-agents in parallel");
        expect(expand?.prompt).toContain("updated within the last 6 months");
        expect(expand?.prompt).toContain("validate it yourself before reporting");
        expect(expand?.prompt).toContain("The table must have exactly 3 columns");
        expect(expand?.prompt).toContain("Do not start implementing until the user chooses");
        expect(expand?.prompt).toContain("A) Build all of these features in plan mode");
        expect(expand?.prompt).toContain("B) Build only the top priority ones in plan mode");
        expect(expand?.prompt).toContain("C) Other");
        expect(expand?.prompt).toContain("call the enter_plan tool");
        expect(expand?.prompt).toContain("call exit_plan with the plan path");
        expect(expand?.prompt).not.toContain("Create a Goal");
        expect(expand?.prompt).not.toContain("planning-only Goal tasks");
    });
    it("keeps /init focused on project-specific CLAUDE.md content", () => {
        const init = PROMPT_COMMANDS.find((command) => command.name === "init");
        expect(init).toBeDefined();
        expect(init?.prompt).toContain("project-specific context only");
        expect(init?.prompt).toContain("Do NOT add generic agent behavior");
        expect(init?.prompt).toContain("Remove generic guidance");
        expect(init?.prompt).toContain("Never add guidance that requires running checks");
        expect(init?.prompt).toContain("mandatory after-every-edit requirements");
        expect(init?.prompt).toContain("After editing ANY file");
        expect(init?.prompt).toContain("Do not duplicate language style packs, generic verification rules");
        expect(init?.prompt).toContain("Do NOT embed generated symbol maps");
        expect(init?.prompt).toContain("auto-generated project inventories");
        expect(init?.prompt).toContain("CLAUDE.md must remain durable, agent-focused project context");
        expect(init?.prompt).not.toContain("human-authored");
        expect(init?.prompt).not.toContain("one file per component");
        expect(init?.prompt).not.toContain("single responsibility");
        expect(init?.prompt).not.toContain("zero-tolerance code quality checks");
        expect(init?.prompt).not.toContain("run full quality suite after every edit");
    });
});
//# sourceMappingURL=prompt-commands.test.js.map