Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions packages/opencode/test/command/command-resilience.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
32 changes: 32 additions & 0 deletions packages/opencode/test/command/hints.test.ts
Original file line number Diff line number Diff line change
@@ -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"])
})
})
Loading