diff --git a/packages/opencode/test/command/command-resilience.test.ts b/packages/opencode/test/command/command-resilience.test.ts index 6c01fbe1b..c79c8ce3b 100644 --- a/packages/opencode/test/command/command-resilience.test.ts +++ b/packages/opencode/test/command/command-resilience.test.ts @@ -90,6 +90,63 @@ describe("Command module", () => { expect(cmd).toBeUndefined() }) }) + + test("all 7 default commands are present", async () => { + await withInstance(async () => { + const commands = await Command.list() + const names = commands.map((c) => c.name) + for (const expected of [ + "init", + "discover", + "review", + "feedback", + "configure-claude", + "configure-codex", + "discover-and-add-mcps", + ]) { + expect(names).toContain(expected) + } + }) + }) + + test("discover-and-add-mcps is registered with correct metadata", async () => { + await withInstance(async () => { + const cmd = await Command.get("discover-and-add-mcps") + expect(cmd).toBeDefined() + expect(cmd.name).toBe("discover-and-add-mcps") + expect(cmd.source).toBe("command") + expect(cmd.description).toBe("discover MCP servers from external AI tool configs and add them") + }) + }) + + test("configure-claude is registered with correct metadata", async () => { + await withInstance(async () => { + const cmd = await Command.get("configure-claude") + expect(cmd).toBeDefined() + expect(cmd.name).toBe("configure-claude") + expect(cmd.source).toBe("command") + expect(cmd.description).toBe("configure /altimate command in Claude Code") + }) + }) + + test("configure-codex is registered with correct metadata", async () => { + await withInstance(async () => { + const cmd = await Command.get("configure-codex") + expect(cmd).toBeDefined() + expect(cmd.name).toBe("configure-codex") + expect(cmd.source).toBe("command") + expect(cmd.description).toBe("configure altimate skill in Codex CLI") + }) + }) + + test("discover-and-add-mcps template references --scope for scope selection", async () => { + await withInstance(async () => { + const cmd = await Command.get("discover-and-add-mcps") + const template = await cmd.template + expect(template).toContain("--scope") + expect(template).toContain("mcp_discover") + }) + }) }) describe("user-defined commands from config", () => { diff --git a/packages/opencode/test/command/hints.test.ts b/packages/opencode/test/command/hints.test.ts new file mode 100644 index 000000000..4085b4b1f --- /dev/null +++ b/packages/opencode/test/command/hints.test.ts @@ -0,0 +1,32 @@ +import { describe, test, expect } from "bun:test" +import { Command } from "../../src/command/index" + +describe("Command.hints: template placeholder extraction", () => { + test("extracts sorted numbered placeholders", () => { + expect(Command.hints("Do $2 then $1 and $3")).toEqual(["$1", "$2", "$3"]) + }) + + test("extracts $ARGUMENTS", () => { + expect(Command.hints("Run something with $ARGUMENTS")).toEqual(["$ARGUMENTS"]) + }) + + test("extracts both numbered and $ARGUMENTS", () => { + expect(Command.hints("Do $1 with $ARGUMENTS")).toEqual(["$1", "$ARGUMENTS"]) + }) + + test("deduplicates repeated numbered placeholders", () => { + expect(Command.hints("$1 and $1 again")).toEqual(["$1"]) + }) + + test("returns empty for template with no placeholders", () => { + expect(Command.hints("Just a plain template")).toEqual([]) + }) + + test("returns empty for empty string", () => { + expect(Command.hints("")).toEqual([]) + }) + + test("handles non-sequential numbering", () => { + expect(Command.hints("$3 then $7")).toEqual(["$3", "$7"]) + }) +})