Skip to content

Commit 658e630

Browse files
committed
test: command — hints extraction and altimate builtin registration
Command.hints() parses template placeholders for TUI argument hints; zero tests existed. The 3 altimate-specific builtin commands (discover-and-add-mcps, configure-claude, configure-codex) shipped in recent PRs with no registration tests. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> https://claude.ai/code/session_0135nT8sg3re3D2Zgvo6ipc2
1 parent 544903f commit 658e630

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

‎packages/opencode/test/command/command-resilience.test.ts‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,63 @@ describe("Command module", () => {
9090
expect(cmd).toBeUndefined()
9191
})
9292
})
93+
94+
test("all 7 default commands are present", async () => {
95+
await withInstance(async () => {
96+
const commands = await Command.list()
97+
const names = commands.map((c) => c.name)
98+
for (const expected of [
99+
"init",
100+
"discover",
101+
"review",
102+
"feedback",
103+
"configure-claude",
104+
"configure-codex",
105+
"discover-and-add-mcps",
106+
]) {
107+
expect(names).toContain(expected)
108+
}
109+
})
110+
})
111+
112+
test("discover-and-add-mcps is registered with correct metadata", async () => {
113+
await withInstance(async () => {
114+
const cmd = await Command.get("discover-and-add-mcps")
115+
expect(cmd).toBeDefined()
116+
expect(cmd.name).toBe("discover-and-add-mcps")
117+
expect(cmd.source).toBe("command")
118+
expect(cmd.description).toBe("discover MCP servers from external AI tool configs and add them")
119+
})
120+
})
121+
122+
test("configure-claude is registered with correct metadata", async () => {
123+
await withInstance(async () => {
124+
const cmd = await Command.get("configure-claude")
125+
expect(cmd).toBeDefined()
126+
expect(cmd.name).toBe("configure-claude")
127+
expect(cmd.source).toBe("command")
128+
expect(cmd.description).toBe("configure /altimate command in Claude Code")
129+
})
130+
})
131+
132+
test("configure-codex is registered with correct metadata", async () => {
133+
await withInstance(async () => {
134+
const cmd = await Command.get("configure-codex")
135+
expect(cmd).toBeDefined()
136+
expect(cmd.name).toBe("configure-codex")
137+
expect(cmd.source).toBe("command")
138+
expect(cmd.description).toBe("configure altimate skill in Codex CLI")
139+
})
140+
})
141+
142+
test("discover-and-add-mcps template references --scope for scope selection", async () => {
143+
await withInstance(async () => {
144+
const cmd = await Command.get("discover-and-add-mcps")
145+
const template = await cmd.template
146+
expect(template).toContain("--scope")
147+
expect(template).toContain("mcp_discover")
148+
})
149+
})
93150
})
94151

95152
describe("user-defined commands from config", () => {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { describe, test, expect } from "bun:test"
2+
import { Command } from "../../src/command/index"
3+
4+
describe("Command.hints: template placeholder extraction", () => {
5+
test("extracts sorted numbered placeholders", () => {
6+
expect(Command.hints("Do $2 then $1 and $3")).toEqual(["$1", "$2", "$3"])
7+
})
8+
9+
test("extracts $ARGUMENTS", () => {
10+
expect(Command.hints("Run something with $ARGUMENTS")).toEqual(["$ARGUMENTS"])
11+
})
12+
13+
test("extracts both numbered and $ARGUMENTS", () => {
14+
expect(Command.hints("Do $1 with $ARGUMENTS")).toEqual(["$1", "$ARGUMENTS"])
15+
})
16+
17+
test("deduplicates repeated numbered placeholders", () => {
18+
expect(Command.hints("$1 and $1 again")).toEqual(["$1"])
19+
})
20+
21+
test("returns empty for template with no placeholders", () => {
22+
expect(Command.hints("Just a plain template")).toEqual([])
23+
})
24+
25+
test("returns empty for empty string", () => {
26+
expect(Command.hints("")).toEqual([])
27+
})
28+
29+
test("handles non-sequential numbering", () => {
30+
expect(Command.hints("$3 then $7")).toEqual(["$3", "$7"])
31+
})
32+
})

0 commit comments

Comments
 (0)