fix: restore OpenCode IDE handler with agent switch functionality#1555
fix: restore OpenCode IDE handler with agent switch functionality#1555adittanu wants to merge 2 commits intobmad-code-org:mainfrom
Conversation
- Add missing opencode.js handler for OpenCode IDE integration - Register opencode.js in IdeManager custom files list - Restores agent switch functionality for OpenCode that was lost in v6.0.0-Beta.6 - OpenCode now properly exports agents, workflows, tasks, and tools to .opencode/ directory
📝 WalkthroughWalkthroughIntroduces a new OpenCode IDE setup handler integrated into the IDE manager's custom installer loading process. The OpenCodeSetup class manages installation of BMAD agents, workflows, and commands into an OpenCode project structure with cleanup and file organization capabilities. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@tools/cli/installers/lib/ide/opencode.js`:
- Around line 228-244: The YAML frontmatter is built via raw string
interpolation into launcherContent using agentName and metadata.title which can
break when those values contain quotes or YAML-special characters; replace this
manual construction by calling this.stringifyFrontmatter() (or yaml.dump once
fixed) to produce escaped frontmatter, or at minimum sanitize/escape agentName
and metadata.title before interpolation; update the code that produces
launcherContent to use the safe serializer (or escaped values) and reference the
same symbols (launcherContent, agentName, metadata.title,
this.stringifyFrontmatter, yaml.dump) so the frontmatter is always valid.
- Around line 163-174: The stringifyFrontmatter function calls yaml.dump (and
passes js-yaml options) which doesn't exist on the yaml v2 package; replace
yaml.dump(...) with yaml.stringify(...) and adjust the options to the yaml v2
API (remove js-yaml-only options like noRefs and sortKeys and use supported keys
such as indent and any v2 equivalents for line width), then keep the trimEnd()
and the frontmatter wrapper `---\n${yamlText}\n---` intact so the function
returns the same formatted YAML string.
- Around line 145-161: The parseFrontmatter method returns inconsistent keys:
when no frontmatter is matched it returns { data: {}, body } but when matched it
returns { frontmatter, body }, causing callers (e.g., createAgentContent) that
destructure { frontmatter } to get undefined; update the no-match return to use
the same key name (return { frontmatter: {}, body: content }), and ensure the
local variable used for parsed YAML is named/returned as frontmatter (keep
frontmatter = yaml.parse(...) || {} and return { frontmatter, body }) so all
callers and the base class see a consistent frontmatter property.
- Around line 80-86: The summary returned from setup() currently includes
success, agents, workflows and workflowCounts but omits the task/tool counts
that were logged earlier; update the return object in the setup() function to
include the task and tool count variables (e.g., taskCount and toolCount or
taskCounts/toolCounts as used where they are logged) so consumers receive those
counts alongside workflowCounts, agents, and workflows.
🧹 Nitpick comments (1)
tools/cli/installers/lib/ide/manager.js (1)
11-11: Stale comment —opencode.jsnot listed.The inline documentation still lists only
codex.js, kilo.js, kiro-cli.js. Consider updating it to includeopencode.jsso it stays in sync with the actualcustomFilesarray on line 64.
- Fix parseFrontmatter to return consistent {frontmatter} key (was {data})
- Replace yaml.dump with yaml.stringify for yaml v2 compatibility
- Add tasks and tools to setup() return value
- Use stringifyFrontmatter for safe YAML generation in launcher
- Update manager.js comment to include opencode.js
|
Template based OpenCode setup implemented in #1556 |
Problem
OpenCode IDE handler was missing in v6.0.0-Beta.6, causing:
Solution
Changes
Testing
After this fix, OpenCode now:
Related
Fixes missing OpenCode integration that was present in v6.0.0-alpha.23