Skip to content

Commit cd5486a

Browse files
committed
test: command — hints parser and altimate builtin registration
Cover Command.hints() template placeholder extraction (7 tests) and verify altimate-specific builtin commands (configure-claude, configure-codex, discover-and-add-mcps) are properly registered with correct metadata. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> https://claude.ai/code/session_01LBpRnh2zYViskgkbqiTG8v
1 parent 544903f commit cd5486a

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,49 @@ describe("Command module", () => {
9090
expect(cmd).toBeUndefined()
9191
})
9292
})
93+
94+
test("altimate builtin commands are registered", async () => {
95+
await withInstance(async () => {
96+
const commands = await Command.list()
97+
const names = commands.map((c) => c.name)
98+
expect(names).toContain("configure-claude")
99+
expect(names).toContain("configure-codex")
100+
expect(names).toContain("discover-and-add-mcps")
101+
})
102+
})
103+
104+
test("discover-and-add-mcps has correct metadata", async () => {
105+
await withInstance(async () => {
106+
const cmd = await Command.get("discover-and-add-mcps")
107+
expect(cmd).toBeDefined()
108+
expect(cmd.source).toBe("command")
109+
expect(cmd.description).toBe("discover MCP servers from external AI tool configs and add them")
110+
})
111+
})
112+
113+
test("discover-and-add-mcps template references mcp_discover tool", async () => {
114+
await withInstance(async () => {
115+
const cmd = await Command.get("discover-and-add-mcps")
116+
const template = await cmd.template
117+
expect(template).toContain("mcp_discover")
118+
})
119+
})
120+
121+
test("discover-and-add-mcps has $ARGUMENTS hint", async () => {
122+
await withInstance(async () => {
123+
const cmd = await Command.get("discover-and-add-mcps")
124+
expect(cmd.hints).toContain("$ARGUMENTS")
125+
})
126+
})
127+
128+
test("configure-claude has correct metadata", async () => {
129+
await withInstance(async () => {
130+
const cmd = await Command.get("configure-claude")
131+
expect(cmd).toBeDefined()
132+
expect(cmd.source).toBe("command")
133+
expect(cmd.description).toBe("configure /altimate command in Claude Code")
134+
})
135+
})
93136
})
94137

95138
describe("user-defined commands from config", () => {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 numbered placeholders in sorted order", () => {
6+
expect(Command.hints("Do $2 then $1")).toEqual(["$1", "$2"])
7+
})
8+
9+
test("deduplicates repeated placeholders", () => {
10+
expect(Command.hints("Use $1 and $1 again")).toEqual(["$1"])
11+
})
12+
13+
test("extracts $ARGUMENTS", () => {
14+
expect(Command.hints("Run with $ARGUMENTS")).toEqual(["$ARGUMENTS"])
15+
})
16+
17+
test("extracts both numbered and $ARGUMENTS", () => {
18+
expect(Command.hints("Do $1 with $ARGUMENTS")).toEqual(["$1", "$ARGUMENTS"])
19+
})
20+
21+
test("returns empty for templates with no placeholders", () => {
22+
expect(Command.hints("Just a plain prompt")).toEqual([])
23+
})
24+
25+
test("does not extract $ARGUMENTS as numbered", () => {
26+
// $ARGUMENTS should only appear via the explicit check, not the numbered regex
27+
expect(Command.hints("$ARGUMENTS only")).toEqual(["$ARGUMENTS"])
28+
})
29+
30+
test("handles double-digit placeholders with lexicographic sort", () => {
31+
// Note: sort is lexicographic, so $10 < $2. This documents current behavior.
32+
expect(Command.hints("$10 then $2 then $1")).toEqual(["$1", "$10", "$2"])
33+
})
34+
})

0 commit comments

Comments
 (0)