Skip to content

test: command — hints parser and altimate builtin registration#436

Closed
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260324-0610
Closed

test: command — hints parser and altimate builtin registration#436
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260324-0610

Conversation

@anandgupta42
Copy link
Contributor

@anandgupta42 anandgupta42 commented Mar 24, 2026

What does this PR do?

1. Command.hintssrc/command/index.ts:53-61 (7 new tests)

This pure function extracts template placeholders ($1, $2, $ARGUMENTS) from command templates and is used by every command registration (default, user-defined, MCP, and skill commands) to determine what TUI hints to display. Zero tests existed. New coverage includes:

  • Numbered placeholder extraction and sorted deduplication
  • $ARGUMENTS detection (separate from numbered regex)
  • Combined numbered + $ARGUMENTS templates
  • Empty template (no placeholders)
  • Lexicographic sort behavior for double-digit placeholders ($10 sorts before $2 — documents current behavior)

2. Altimate builtin commands registration — src/command/index.ts:63-144 (5 new tests)

Commit 528af75 shipped discover-and-add-mcps as a builtin command to fix a phantom command issue where the toast suggestion sent users to a non-existent command. The three altimate-specific builtin commands (configure-claude, configure-codex, discover-and-add-mcps) had zero test coverage. New coverage includes:

  • All three altimate commands are present in Command.list()
  • discover-and-add-mcps has correct source, description, template referencing mcp_discover, and $ARGUMENTS hint
  • configure-claude has correct source and exact description string

Type of change

  • New feature (non-breaking change which adds functionality)

Issue for this PR

N/A — proactive test coverage

How did you verify your code works?

bun test test/command/hints.test.ts              # 7 pass
bun test test/command/command-resilience.test.ts  # 5 new + 9 existing (all require tmpdir git fixture)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

https://claude.ai/code/session_01LBpRnh2zYViskgkbqiTG8v

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for new built-in commands (configure-claude, configure-codex, discover-and-add-mcps) and their configurations.
    • Enhanced test suite for command hint and placeholder extraction functionality to ensure correct behavior and formatting.

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) <noreply@anthropic.com>

https://claude.ai/code/session_01LBpRnh2zYViskgkbqiTG8v
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

Test coverage has been added for Altimate's built-in commands, including verification that discover-and-add-mcps, configure-claude, and configure-codex are present in the command registry with correct metadata, and for the Command.hints() method's placeholder extraction behavior across multiple scenarios.

Changes

Cohort / File(s) Summary
Command Test Coverage
packages/opencode/test/command/command-resilience.test.ts
Tests verifying presence and correctness of new built-in commands (configure-claude, configure-codex, discover-and-add-mcps) in the command registry, including assertions on source, description, template, and hints fields.
Hints Extraction Tests
packages/opencode/test/command/hints.test.ts
Tests for Command.hints() method covering placeholder extraction, deduplication, $ARGUMENTS literal handling, empty cases, and lexicographic sorting behavior for multi-digit numbered placeholders.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

contributor

Poem

🐰 Hopping through tests with care so keen,
New commands are verified, crystal clean,
Hints extracted, placeholders aligned—
A robust foundation, perfectly designed! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the two main additions: testing the command hints parser and Altimate builtin command registration.
Description check ✅ Passed The description is comprehensive, detailing specific functions tested, test coverage areas, and verification steps, but lacks explicit checklist completion confirmation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/hourly-20260324-0610

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/opencode/test/command/command-resilience.test.ts (1)

128-135: Consider adding similar metadata test for configure-codex.

The configure-claude metadata test is good. For completeness, you may want to add a similar test for configure-codex to verify its source and description. This would ensure all three Altimate commands have equivalent coverage.

📝 Optional test addition
test("configure-codex has correct metadata", async () => {
  await withInstance(async () => {
    const cmd = await Command.get("configure-codex")
    expect(cmd).toBeDefined()
    expect(cmd.source).toBe("command")
    expect(cmd.description).toBe("configure altimate skill in Codex CLI")
  })
})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/test/command/command-resilience.test.ts` around lines 128 -
135, Add a parallel metadata test for the "configure-codex" command similar to
the existing "configure-claude" test: inside the same test suite use
withInstance and call Command.get("configure-codex"), assert the returned cmd is
defined, cmd.source equals "command", and cmd.description equals "configure
altimate skill in Codex CLI" so that configure-codex metadata is verified; place
this new test alongside the existing configure-claude test and name it
"configure-codex has correct metadata".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/opencode/test/command/command-resilience.test.ts`:
- Around line 128-135: Add a parallel metadata test for the "configure-codex"
command similar to the existing "configure-claude" test: inside the same test
suite use withInstance and call Command.get("configure-codex"), assert the
returned cmd is defined, cmd.source equals "command", and cmd.description equals
"configure altimate skill in Codex CLI" so that configure-codex metadata is
verified; place this new test alongside the existing configure-claude test and
name it "configure-codex has correct metadata".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bf24ed8b-e097-4d62-9454-e8e6b5f755ce

📥 Commits

Reviewing files that changed from the base of the PR and between 544903f and cd5486a.

📒 Files selected for processing (2)
  • packages/opencode/test/command/command-resilience.test.ts
  • packages/opencode/test/command/hints.test.ts

@anandgupta42
Copy link
Contributor Author

Superseded by #439 which consolidates all 12 test PRs into one, deduplicates overlapping tests, and fixes bugs found during review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants