-
Notifications
You must be signed in to change notification settings - Fork 26
test: command — hints parsing and altimate builtin completeness #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { describe, test, expect } from "bun:test" | ||
| import { Command } from "../../src/command/index" | ||
| import { Instance } from "../../src/project/instance" | ||
| import { tmpdir } from "../fixture/fixture" | ||
|
|
||
| async function withInstance(fn: () => Promise<void>) { | ||
| await using tmp = await tmpdir({ git: true }) | ||
| await Instance.provide({ directory: tmp.path, fn }) | ||
| } | ||
|
|
||
| describe("Altimate builtin commands", () => { | ||
| test("all altimate-specific commands are registered", async () => { | ||
| await withInstance(async () => { | ||
| const commands = await Command.list() | ||
| const names = commands.map((c) => c.name) | ||
| // These are the altimate_change commands that must ship with the package. | ||
| // Regression guard: commit 528af75 fixed discover-and-add-mcps not shipping. | ||
| expect(names).toContain("configure-claude") | ||
| expect(names).toContain("configure-codex") | ||
| expect(names).toContain("discover-and-add-mcps") | ||
| expect(names).toContain("feedback") | ||
| }) | ||
| }) | ||
|
|
||
| test("Command.Default includes all altimate constants", () => { | ||
| expect(Command.Default.CONFIGURE_CLAUDE).toBe("configure-claude") | ||
| expect(Command.Default.CONFIGURE_CODEX).toBe("configure-codex") | ||
| expect(Command.Default.DISCOVER_MCPS).toBe("discover-and-add-mcps") | ||
| expect(Command.Default.FEEDBACK).toBe("feedback") | ||
| }) | ||
|
|
||
| test("discover-and-add-mcps has correct metadata and template", 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") | ||
| const template = await cmd.template | ||
| expect(template).toContain("mcp_discover") | ||
| expect(cmd.hints).toContain("$ARGUMENTS") | ||
| }) | ||
| }) | ||
|
|
||
| test("configure-claude has 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 has 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") | ||
| }) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 numbered placeholders in order", () => { | ||
| expect(Command.hints("Do $1 then $2")).toEqual(["$1", "$2"]) | ||
| }) | ||
|
|
||
| test("deduplicates repeated numbered placeholders", () => { | ||
| expect(Command.hints("Use $1 and $1 again")).toEqual(["$1"]) | ||
| }) | ||
|
|
||
| test("extracts $ARGUMENTS", () => { | ||
| expect(Command.hints("Run with $ARGUMENTS")).toEqual(["$ARGUMENTS"]) | ||
| }) | ||
|
|
||
| test("numbered placeholders before $ARGUMENTS", () => { | ||
| expect(Command.hints("Do $2 then $1 with $ARGUMENTS")).toEqual(["$1", "$2", "$ARGUMENTS"]) | ||
| }) | ||
|
|
||
| test("returns empty for no placeholders", () => { | ||
| expect(Command.hints("Plain text with no variables")).toEqual([]) | ||
| }) | ||
|
|
||
| test("handles template with only $ARGUMENTS", () => { | ||
| expect(Command.hints("If $ARGUMENTS contains --scope global")).toEqual(["$ARGUMENTS"]) | ||
| }) | ||
|
|
||
| test("only recognises $N and $ARGUMENTS — not $OTHER or $FOO", () => { | ||
| expect(Command.hints("Use $OTHER and $FOO")).toEqual([]) | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 3377
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 931
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 4271
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 3471
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 50
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 2506
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 50
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 850
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 486
🏁 Script executed:
Repository: AltimateAI/altimate-code
Length of output: 8339
The
awaitoncmd.templateis unnecessary for the default "discover-and-add-mcps" command.The
templateproperty is defined asPromise<string> | string(inpackages/opencode/src/command/index.ts:51). Default commands like "discover-and-add-mcps" use a getter that returns a plain string directly (line 139-140), so awaiting it is harmless but redundant. This works because awaiting a non-Promise value simply returns that value. Consider removing theawaiton line 39 if the intent is to test only default commands, or keep it if you want to support both synchronous and asynchronous command sources (MCP commands return promises).🤖 Prompt for AI Agents