Skip to content

fix(opencode): use native agents/ and commands/ layout instead of skills/#2056

Closed
arnoe wants to merge 1 commit intobmad-code-org:mainfrom
arnoe:fix/opencode-native-agents-commands
Closed

fix(opencode): use native agents/ and commands/ layout instead of skills/#2056
arnoe wants to merge 1 commit intobmad-code-org:mainfrom
arnoe:fix/opencode-native-agents-commands

Conversation

@arnoe
Copy link
Copy Markdown

@arnoe arnoe commented Mar 18, 2026

Summary

  • OpenCode does not have a native "skills" concept — it uses .opencode/agents/ for agent persona definitions and .opencode/commands/ for slash commands
  • The installer was incorrectly placing everything into .opencode/skills/ as SKILL.md directories, which duplicated content from _bmad/ and prevented workflows from appearing as native opencode commands
  • Switch opencode to a multi-target layout using the existing targets mechanism in _config-driven.js:
    • .opencode/agents/ — flat agent launcher files (using opencode-agent template with mode: all frontmatter)
    • .opencode/commands/ — flat workflow/task/tool command files (thin loaders pointing to _bmad/ canonical sources)

What changed

platform-codes.yaml

  • Replaced single target_dir: .opencode/skills + skill_format: true with a targets array containing two entries (agents + commands)
  • Moved .opencode/skills into legacy_targets so existing skill-based installations are cleaned up on upgrade
  • Removed .opencode/agents and .opencode/commands from legacy_targets since they are now active output targets

_config-driven.js

  • detect(): Added multi-target detection — checks all targets[].target_dir directories for bmad-prefixed entries (previously only worked for single target_dir with skill_format)
  • findAncestorConflict(): Now collects target directories from both target_dir and targets[] for ancestor conflict checking, so platforms with multiple output directories are fully covered

test-installation-components.js

  • Updated OpenCode test suite (Suite 8) to verify multi-target layout: flat agent files in .opencode/agents/, commands directory created, opencode-specific mode: all frontmatter
  • Updated ancestor conflict test (Suite 15) to check .opencode/agents/ instead of .opencode/skills/
  • All 234 tests pass, 0 failures

Motivation

This was discovered by comparing a v6.0.4 installation (poc-create-brief) — which correctly used .opencode/agents/ + .opencode/commands/ — against a v6.2.0 installation which placed everything in .opencode/skills/. The v6.0.4 output was the correct structure for opencode's native concepts, and this PR restores that behavior using the config-driven architecture.

…lls/

OpenCode does not have a native 'skills' concept. It uses .opencode/agents/
for agent persona definitions and .opencode/commands/ for slash commands.
The installer was incorrectly placing everything into .opencode/skills/ as
SKILL.md directories, which duplicated content from _bmad/ and prevented
workflows from appearing as native opencode commands.

Switch opencode to a multi-target layout:
- .opencode/agents/ — flat agent launcher files (opencode-agent template)
- .opencode/commands/ — flat workflow/task/tool command files

This matches the output that older installations (e.g. v6.0.4) produced and
aligns with how opencode actually discovers and surfaces agents and commands.

Also update detect() and findAncestorConflict() in the config-driven handler
to support multi-target platforms, so detection and ancestor conflict checks
work correctly for all target directories.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 49ba1fe1-d951-4b49-b2f7-a6b8729a7baa

📥 Commits

Reviewing files that changed from the base of the PR and between be555aa and cd88291.

📒 Files selected for processing (3)
  • test/test-installation-components.js
  • tools/cli/installers/lib/ide/_config-driven.js
  • tools/cli/installers/lib/ide/platform-codes.yaml

📝 Walkthrough

Walkthrough

The OpenCode installer is refactored to support a multi-target configuration instead of a single target. Installation now routes agents to .opencode/agents and commands (workflows, tasks, tools) to .opencode/commands. Detection and ancestor conflict resolution logic extend to handle multiple target directories, and tests validate the new structure.

Changes

Cohort / File(s) Summary
Test Validation
test/test-installation-components.js
Updated assertions to validate a two-target OpenCode layout with agents at .opencode/agents and commands at .opencode/commands. Tests now verify artifact types, legacy directory cleanup, and presence of flat agent files under the new multi-target structure.
Detection and Conflict Logic
tools/cli/installers/lib/ide/_config-driven.js
Extended detect() to iterate all target directories and check for BMAD entries. Enhanced findAncestorConflict() to collect and check multiple target_dirs against ancestor directories for existing BMAD entries. Added error handling for unreadable directories.
Installer Configuration
tools/cli/installers/lib/ide/platform-codes.yaml
OpenCode platform installer changed from single-target layout (target_dir, template_type, skill_format) to explicit multi-target structure with two targets: agents (.opencode/agents, artifact_types: [agents]) and commands (.opencode/commands, artifact_types: [workflows, tasks, tools]). Legacy targets adjusted with comment.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • bmadcode
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: switching OpenCode from a skills/ layout to the native agents/ and commands/ layout, which is the core fix across all modified files.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, detailing the problem, solution, specific file changes, and motivation for the fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.

@alexeyv
Copy link
Copy Markdown
Collaborator

alexeyv commented Mar 18, 2026

Sorry, not doing that anymore. BMAD (and just about everybody else in this space) has switched from 20 custom, constantly changing installers to shipping skills. If you want some sort of wrapper around them for your own platform, it usually takes about 15 minutes to make one. And if you decide to publish that, please advertise it on BMAD's Discord!

@alexeyv alexeyv closed this Mar 18, 2026
@arnoe arnoe deleted the fix/opencode-native-agents-commands branch March 19, 2026 15:47
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.

2 participants