Skip to content

Commit 71778fa

Browse files
committed
test: command — hints parsing and altimate builtin completeness
Guard against regressions in Command.hints() template placeholder extraction (used by every command for TUI argument hints) and ensure all altimate-specific builtin commands (configure-claude, configure-codex, discover-and-add-mcps) are registered — the latter would have caught the regression fixed in 528af75. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> https://claude.ai/code/session_018jF7cHcSoARmZRt6Wb7m9o
1 parent 528af75 commit 71778fa

2 files changed

Lines changed: 96 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { describe, test, expect } from "bun:test"
2+
import { Command } from "../../src/command/index"
3+
import { Instance } from "../../src/project/instance"
4+
import { tmpdir } from "../fixture/fixture"
5+
6+
async function withInstance(fn: () => Promise<void>) {
7+
await using tmp = await tmpdir({ git: true })
8+
await Instance.provide({ directory: tmp.path, fn })
9+
}
10+
11+
describe("Altimate builtin commands", () => {
12+
test("all altimate-specific commands are registered", async () => {
13+
await withInstance(async () => {
14+
const commands = await Command.list()
15+
const names = commands.map((c) => c.name)
16+
// These are the altimate_change commands that must ship with the package.
17+
// Regression guard: commit 528af75 fixed discover-and-add-mcps not shipping.
18+
expect(names).toContain("configure-claude")
19+
expect(names).toContain("configure-codex")
20+
expect(names).toContain("discover-and-add-mcps")
21+
expect(names).toContain("feedback")
22+
})
23+
})
24+
25+
test("Command.Default includes all altimate constants", () => {
26+
expect(Command.Default.CONFIGURE_CLAUDE).toBe("configure-claude")
27+
expect(Command.Default.CONFIGURE_CODEX).toBe("configure-codex")
28+
expect(Command.Default.DISCOVER_MCPS).toBe("discover-and-add-mcps")
29+
expect(Command.Default.FEEDBACK).toBe("feedback")
30+
})
31+
32+
test("discover-and-add-mcps has correct metadata and template", async () => {
33+
await withInstance(async () => {
34+
const cmd = await Command.get("discover-and-add-mcps")
35+
expect(cmd).toBeDefined()
36+
expect(cmd.name).toBe("discover-and-add-mcps")
37+
expect(cmd.source).toBe("command")
38+
expect(cmd.description).toBe("discover MCP servers from external AI tool configs and add them")
39+
const template = await cmd.template
40+
expect(template).toContain("mcp_discover")
41+
expect(cmd.hints).toContain("$ARGUMENTS")
42+
})
43+
})
44+
45+
test("configure-claude has correct metadata", async () => {
46+
await withInstance(async () => {
47+
const cmd = await Command.get("configure-claude")
48+
expect(cmd).toBeDefined()
49+
expect(cmd.name).toBe("configure-claude")
50+
expect(cmd.source).toBe("command")
51+
expect(cmd.description).toBe("configure /altimate command in Claude Code")
52+
})
53+
})
54+
55+
test("configure-codex has correct metadata", async () => {
56+
await withInstance(async () => {
57+
const cmd = await Command.get("configure-codex")
58+
expect(cmd).toBeDefined()
59+
expect(cmd.name).toBe("configure-codex")
60+
expect(cmd.source).toBe("command")
61+
expect(cmd.description).toBe("configure altimate skill in Codex CLI")
62+
})
63+
})
64+
})
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 numbered placeholders in order", () => {
6+
expect(Command.hints("Do $1 then $2")).toEqual(["$1", "$2"])
7+
})
8+
9+
test("deduplicates repeated numbered 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("numbered placeholders before $ARGUMENTS", () => {
18+
expect(Command.hints("Do $2 then $1 with $ARGUMENTS")).toEqual(["$1", "$2", "$ARGUMENTS"])
19+
})
20+
21+
test("returns empty for no placeholders", () => {
22+
expect(Command.hints("Plain text with no variables")).toEqual([])
23+
})
24+
25+
test("handles template with only $ARGUMENTS", () => {
26+
expect(Command.hints("If $ARGUMENTS contains --scope global")).toEqual(["$ARGUMENTS"])
27+
})
28+
29+
test("only recognises $N and $ARGUMENTS — not $OTHER or $FOO", () => {
30+
expect(Command.hints("Use $OTHER and $FOO")).toEqual([])
31+
})
32+
})

0 commit comments

Comments
 (0)