Skip to content

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

Merged
clay-good merged 3 commits into
mainfrom
feat/command-code-command-adapter
Aug 11, 2026
Merged

feat(tools): add Command Code command adapter for /opsx-* commands#1622
clay-good merged 3 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 support for the Command Code tool.
    • Initialization can now generate workflow commands under .commandcode/commands/.
    • Commands support $ARGUMENTS placeholders and preserve existing argument references.
    • Command Code installations can be updated alongside generated skills.
  • Documentation

    • Added Command Code to the supported tools list, including its command and skill paths.

@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

cloudflare-workers-and-pages Bot commented Aug 10, 2026

Copy link
Copy Markdown

Deploying openspec-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: cbb3f55
Status: ✅  Deploy successful!
Preview URL: https://2abff1b6.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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 94b8a481-8e18-431a-9936-b6142b9644bf

📥 Commits

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

📒 Files selected for processing (2)
  • test/core/init.test.ts
  • test/core/update.test.ts

📝 Walkthrough

Walkthrough

Command Code becomes a registered command-generation tool. The adapter writes flat /opsx-<id> Markdown commands, preserves or injects $ARGUMENTS, and integrates with initialization and update flows. Documentation, changeset metadata, and tests are updated.

Changes

Command Code support

Layer / File(s) Summary
Tool definition
.changeset/command-code-command-adapter.md, docs/supported-tools.md
Documents Command Code paths and adds command-code to the supported tool IDs.
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 and registers commandCodeAdapter, which generates .commandcode/commands/opsx-<id>.md files with argument handling and trailing newlines.
Generation, initialization, and update validation
test/core/command-generation/adapters.test.ts, test/core/command-generation/registry.test.ts, test/core/init.test.ts, test/core/update.test.ts
Tests command formatting, argument preservation, reference rewriting, frontmatter behavior, initialization modes, and update regeneration.

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

Sequence Diagram(s)

sequenceDiagram
  participant InitOrUpdate
  participant CommandAdapterRegistry
  participant commandCodeAdapter
  participant CommandFiles
  InitOrUpdate->>CommandAdapterRegistry: request Command Code command generation
  CommandAdapterRegistry->>commandCodeAdapter: generateCommand
  commandCodeAdapter->>CommandFiles: write opsx-<id>.md
  CommandFiles-->>InitOrUpdate: generated command available
Loading

Possibly related PRs

Suggested reviewers: tabishb, alfred-openspec

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding a Command Code adapter for /opsx-* commands.
Linked Issues check ✅ Passed The changes implement first-class Command Code support, including tool registration, /opsx-* commands, skills, documentation, and coverage for issue #1614.
Out of Scope Changes check ✅ Passed The adapter, registry, documentation, changeset, and tests directly support the linked issue objectives without unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The adapter and argument forwarding look sound, but the regression only covers default delivery during init. Please add Command Code-specific commands-only and openspec update tests so we prove the adapter survives both paths before approval.

clay-good and others added 3 commits August 11, 2026 15:34
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>
Addresses review: prove the Command Code adapter survives both the
commands-only init path and the update path, not just default delivery.

- init: delivery=commands generates .commandcode/commands/opsx-explore.md
  and installs no skills.
- update: a detected .commandcode install regenerates the flat
  opsx-<id>.md command (plain Markdown, $ARGUMENTS injected).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@clay-good
clay-good force-pushed the feat/command-code-command-adapter branch from 87df1f9 to cbb3f55 Compare August 11, 2026 20:38
@clay-good

Copy link
Copy Markdown
Collaborator Author

Rebased onto main (now that #1613 has landed) and addressed the review.

Conflict resolution (as planned in the PR description):

@alfred-openspec — added the requested coverage proving the adapter survives both non-default paths:

  • init.test.ts: delivery=commands generates .commandcode/commands/opsx-explore.md and installs no skills.
  • update.test.ts: a detected .commandcode install regenerates the flat opsx-<id>.md command (plain Markdown, $ARGUMENTS injected).

Full suite green against dist except the two failures that are pre-existing on main (config-profile PATH test, artifact-workflow Cursor test) — verified the changed surface (init/update/adapters/registry/available-tools) passes 1355/1355.

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The follow-up covers both blocked paths: commands-only init keeps the flat Command Code adapter without skills, and openspec update regenerates the command with $ARGUMENTS. Fresh focused adapter, init, and update tests pass at cbb3f55, and the hosted matrix is green.

@clay-good
clay-good added this pull request to the merge queue Aug 11, 2026
Merged via the queue into main with commit 59c16a4 Aug 11, 2026
18 checks passed
@clay-good
clay-good deleted the feat/command-code-command-adapter branch August 11, 2026 20:58
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

2 participants