Skip to content

feat(tools): add Command Code command adapter for /opsx-* commands - #1622

Open
clay-good wants to merge 2 commits into
mainfrom
feat/command-code-command-adapter
Open

feat(tools): add Command Code command adapter for /opsx-* commands#1622
clay-good wants to merge 2 commits into
mainfrom
feat/command-code-command-adapter

Conversation

@clay-good

@clay-good clay-good commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Closes #1614
Builds on #1613

Status

Ready for review. Full suite green except the two failures that are pre-existing on main (config-profile PATH-resolution test, artifact-workflow Cursor test) — baselined below.

What was missing / the motivation

#1613 added Command Code as a skills-only tool (skills under .commandcode/skills/), on the premise that "Command Code has no slash-command files." That premise is incorrect. Command Code's own docs document custom slash commands:

"The command name comes from the markdown filename (without the .md extension)."
Example: .commandcode/commands/frontend/component.md/component
https://commandcode.ai/docs/reference/slash-commands

So Command Code discovers custom commands from .commandcode/commands/*.md with the same flat naming Cursor and OpenCode use. #1614 specifically wanted the /opsx command surface, which skills-only does not deliver.

What it does

Adds a Command Code command adapter — a standard flat adapter writing .commandcode/commands/opsx-<id>.md, which Command Code registers as /opsx-<id>.

Registering the adapter flips Command Code from none to adapter-backed in command-surface.ts, so with the default both delivery openspec init now generates commands alongside the skills it already installs. No new wiring — the existing delivery machinery does the rest.

Before (#1613) After (this PR)
Skills .commandcode/skills/openspec-*/SKILL.md same
Commands none (skills-only) .commandcode/commands/opsx-<id>.md/opsx-<id>

Proof it works

  • New adapter unit test (adapters.test.ts): path is .commandcode/commands/opsx-explore.md, plain-Markdown output, $ARGUMENTS propagation, and /opsx:/opsx- reference rewriting.
  • New init test (init.test.ts): a real openspec init --tools command-code writes both the skill file and .commandcode/commands/opsx-explore.md.
  • Registry-wide invocation.test.ts classifies it automatically (flat, / prefix) — no edit needed.
  • Full suite: 3903 passing; the only 2 failures are identical on clean main (verified by stash-and-run), so zero regression.

Hardening

  • Emits Command Code’s documented plain Markdown prompt body instead of adding undocumented description frontmatter to the executed prompt.
  • Injects $ARGUMENTS beside each workflow’s **Input**: contract so invocations such as /opsx-propose add-auth retain user input.
  • Adds a registry-wide tripwire: every argument-accepting workflow must preserve its arguments; only the intentionally interactive onboard workflow is exempt.

Notes / merge order

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added Command Code support to initialization workflows.
    • openspec init --tools command-code now generates skills in .commandcode/skills and /opsx-<id> commands in .commandcode/commands.
    • Generated commands preserve or add argument placeholders and use the expected formatting.
  • Documentation

    • Updated CLI and supported-tools documentation with Command Code setup details.
  • Tests

    • Added coverage for generated paths, command formatting, references, and initialization output.

Command Code documents custom slash commands under
`.commandcode/commands/`, where the command name is the markdown
filename without its `.md` extension (see
https://commandcode.ai/docs/reference/slash-commands). That is the same
flat naming Cursor and OpenCode use, so a standard flat adapter writing
`.commandcode/commands/opsx-<id>.md` registers `/opsx-<id>`.

Registering the adapter flips Command Code from `none` to
`adapter-backed`, so with the default `both` delivery `openspec init`
now generates OpenSpec commands alongside the skills it already installs
under `.commandcode/skills/`.

Builds on #1613, which registered Command Code as a skills-only tool.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@clay-good
clay-good requested a review from a team as a code owner August 10, 2026 13:31
@clay-good
clay-good requested review from TabishB and removed request for a team August 10, 2026 13:31
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying openspec-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 41d0d63
Status: ✅  Deploy successful!
Preview URL: https://32b807bd.openspec-docs.pages.dev
Branch Preview URL: https://feat-command-code-command-ad.openspec-docs.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Command Code is added as a supported tool. Initialization generates .commandcode skills and /opsx-<id> command files through a registered adapter. Documentation and tests cover the integration.

Changes

Command Code support

Layer / File(s) Summary
Tool definition and documentation
src/core/config.ts, docs/cli.md, docs/supported-tools.md, .changeset/command-code-command-adapter.md
Adds the command-code configuration, documents its skills and command paths, and records the changeset.
Command generation and registry wiring
src/core/command-generation/adapters/command-code.ts, src/core/command-generation/adapters/index.ts, src/core/command-generation/registry.ts
Adds the adapter, generates .commandcode/commands/opsx-<id>.md, preserves or injects $ARGUMENTS, rewrites command references, and registers the adapter.
Adapter and initialization validation
test/core/command-generation/adapters.test.ts, test/core/command-generation/registry.test.ts, test/core/init.test.ts
Tests adapter metadata, paths, formatting, argument handling, reference rewriting, frontmatter behavior, and initialization output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InitCommand
  participant CommandAdapterRegistry
  participant commandCodeAdapter
  participant CommandFiles
  InitCommand->>CommandAdapterRegistry: request command generation
  CommandAdapterRegistry->>commandCodeAdapter: generateCommand
  commandCodeAdapter->>CommandFiles: write .commandcode/commands/opsx-<id>.md
Loading

Possibly related PRs

Suggested reviewers: tabishb, alfred-openspec

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #1614 by adding Command Code recognition, initialization support, and generated /opsx-* command files.
Out of Scope Changes check ✅ Passed The adapter, configuration, documentation, changeset, and tests directly support the Command Code integration described in issue #1614.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a Command Code adapter for /opsx-* commands.
✨ 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 feat/command-code-command-adapter

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/core/command-generation/adapters/command-code.ts`:
- Around line 16-17: Update the placeholder detection in command-code generation
to recognize $ARGUMENTS, $@, ${ARGUMENTS}, and ${@} anywhere in body, not only
as the complete **Provided arguments** line, so injection never duplicates an
existing placeholder. In test/core/command-generation/adapters.test.ts lines
146-155, add coverage for each placeholder appearing outside that section and
assert no second placeholder is injected.

In `@test/core/command-generation/registry.test.ts`:
- Line 133: Update the registry test around the noYamlFrontmatter list to
explicitly verify that CommandAdapterRegistry registers the "command-code"
adapter, using get, has, or a getAll membership assertion. Keep the existing
frontmatter behavior checks unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b170c2f-8da2-4ce1-86fa-933f08370921

📥 Commits

Reviewing files that changed from the base of the PR and between 41d0d63 and 87df1f9.

📒 Files selected for processing (4)
  • src/core/command-generation/adapters/command-code.ts
  • test/core/command-generation/adapters.test.ts
  • test/core/command-generation/registry.test.ts
  • test/core/init.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/core/init.test.ts

Comment on lines +16 to +17
if (/^\*\*Provided arguments\*\*:\s*(?:\$(?:ARGUMENTS|@)|\$\{(?:ARGUMENTS|@)\})\s*$/m.test(body)) {
return body;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Detect supported placeholders throughout the command body.

Line 16 only recognizes a placeholder when it is the complete value of a **Provided arguments** line. A body that already uses $ARGUMENTS, $@, ${ARGUMENTS}, or ${@} elsewhere receives a second injected $ARGUMENTS line. This duplicates the invocation text.

  • src/core/command-generation/adapters/command-code.ts#L16-L17: Detect the supported placeholders anywhere in body before injection.
  • test/core/command-generation/adapters.test.ts#L146-L155: Add cases with each supported placeholder outside **Provided arguments** and assert that injection does not add a second placeholder.
📍 Affects 2 files
  • src/core/command-generation/adapters/command-code.ts#L16-L17 (this comment)
  • test/core/command-generation/adapters.test.ts#L146-L155
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/command-generation/adapters/command-code.ts` around lines 16 - 17,
Update the placeholder detection in command-code generation to recognize
$ARGUMENTS, $@, ${ARGUMENTS}, and ${@} anywhere in body, not only as the
complete **Provided arguments** line, so injection never duplicates an existing
placeholder. In test/core/command-generation/adapters.test.ts lines 146-155, add
coverage for each placeholder appearing outside that section and assert no
second placeholder is injected.


// Tools that don't use YAML frontmatter (markdown headers or TOML or plain)
const noYamlFrontmatter = ['cline', 'kilocode', 'roocode', 'gemini'];
const noYamlFrontmatter = ['cline', 'command-code', 'kilocode', 'roocode', 'gemini'];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add an explicit Command Code registry assertion.

The noYamlFrontmatter list only affects adapters that getAll() already returns. If command-code is not registered, this test still passes. Assert that CommandAdapterRegistry.get('command-code'), has('command-code'), or getAll() includes the adapter.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/core/command-generation/registry.test.ts` at line 133, Update the
registry test around the noYamlFrontmatter list to explicitly verify that
CommandAdapterRegistry registers the "command-code" adapter, using get, has, or
a getAll membership assertion. Keep the existing frontmatter behavior checks
unchanged.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add Support for Command Code Harness

1 participant