From 0b219d09e8f8d0d5323a0a5e34f4dea3f237eeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davor=20Raci=C4=87?= Date: Wed, 25 Feb 2026 10:24:36 +0100 Subject: [PATCH] fix(opencode): use mode: all in agent template, remove name frontmatter, fix directory names - Replace name: '{{name}}' with mode: all in opencode-agent.md mode: all enables both Tab-key agent switching in the TUI and @subagent invocation via the Task tool (mode: primary blocked subagent use) - Remove name: '{{name}}' from opencode-task/tool/workflow/workflow-yaml templates OpenCode derives command name from filename, not from a name frontmatter field; the bare {{name}} value was overriding the bmad- prefixed filename causing name collisions with built-in OpenCode commands (fixes #1762) - Fix deprecated singular directory names in platform-codes.yaml: .opencode/agent -> .opencode/agents, .opencode/command -> .opencode/commands - Add legacy_targets migration: cleanup() now removes stale bmad-* files from old singular directories on reinstall so existing users don't get duplicates - Fix removeEmptyParents to continue walking up to parent when starting dir is already absent instead of breaking early Co-Authored-By: Claude Sonnet 4.6 --- tools/cli/installers/lib/ide/_config-driven.js | 13 ++++++++++++- tools/cli/installers/lib/ide/platform-codes.yaml | 7 +++++-- .../lib/ide/templates/combined/opencode-agent.md | 2 +- .../lib/ide/templates/combined/opencode-task.md | 1 - .../lib/ide/templates/combined/opencode-tool.md | 1 - .../templates/combined/opencode-workflow-yaml.md | 1 - .../lib/ide/templates/combined/opencode-workflow.md | 1 - 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/cli/installers/lib/ide/_config-driven.js b/tools/cli/installers/lib/ide/_config-driven.js index 85196cf76..3aa86613d 100644 --- a/tools/cli/installers/lib/ide/_config-driven.js +++ b/tools/cli/installers/lib/ide/_config-driven.js @@ -453,6 +453,14 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} * @param {string} projectDir - Project directory */ async cleanup(projectDir, options = {}) { + // Migrate legacy target directories (e.g. .opencode/agent → .opencode/agents) + if (this.installerConfig?.legacy_targets) { + for (const legacyDir of this.installerConfig.legacy_targets) { + await this.cleanupTarget(projectDir, legacyDir, options); + await this.removeEmptyParents(projectDir, legacyDir); + } + } + // Clean all target directories if (this.installerConfig?.targets) { const parentDirs = new Set(); @@ -544,7 +552,10 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} last = current; const fullPath = path.join(projectDir, current); try { - if (!(await fs.pathExists(fullPath))) break; + if (!(await fs.pathExists(fullPath))) { + current = path.dirname(current); + continue; + } const remaining = await fs.readdir(fullPath); if (remaining.length > 0) break; await fs.rmdir(fullPath); diff --git a/tools/cli/installers/lib/ide/platform-codes.yaml b/tools/cli/installers/lib/ide/platform-codes.yaml index 16723f9c5..fe5b42a7a 100644 --- a/tools/cli/installers/lib/ide/platform-codes.yaml +++ b/tools/cli/installers/lib/ide/platform-codes.yaml @@ -131,11 +131,14 @@ platforms: category: ide description: "OpenCode terminal coding assistant" installer: + legacy_targets: + - .opencode/agent + - .opencode/command targets: - - target_dir: .opencode/agent + - target_dir: .opencode/agents template_type: opencode artifact_types: [agents] - - target_dir: .opencode/command + - target_dir: .opencode/commands template_type: opencode artifact_types: [workflows, tasks, tools] diff --git a/tools/cli/installers/lib/ide/templates/combined/opencode-agent.md b/tools/cli/installers/lib/ide/templates/combined/opencode-agent.md index 65f0a771d..828d673ac 100644 --- a/tools/cli/installers/lib/ide/templates/combined/opencode-agent.md +++ b/tools/cli/installers/lib/ide/templates/combined/opencode-agent.md @@ -1,5 +1,5 @@ --- -name: '{{name}}' +mode: all description: '{{description}}' --- diff --git a/tools/cli/installers/lib/ide/templates/combined/opencode-task.md b/tools/cli/installers/lib/ide/templates/combined/opencode-task.md index 98b3a5d77..772f9c9eb 100644 --- a/tools/cli/installers/lib/ide/templates/combined/opencode-task.md +++ b/tools/cli/installers/lib/ide/templates/combined/opencode-task.md @@ -1,5 +1,4 @@ --- -name: '{{name}}' description: '{{description}}' --- diff --git a/tools/cli/installers/lib/ide/templates/combined/opencode-tool.md b/tools/cli/installers/lib/ide/templates/combined/opencode-tool.md index 1ae9c9ac8..88c317e63 100644 --- a/tools/cli/installers/lib/ide/templates/combined/opencode-tool.md +++ b/tools/cli/installers/lib/ide/templates/combined/opencode-tool.md @@ -1,5 +1,4 @@ --- -name: '{{name}}' description: '{{description}}' --- diff --git a/tools/cli/installers/lib/ide/templates/combined/opencode-workflow-yaml.md b/tools/cli/installers/lib/ide/templates/combined/opencode-workflow-yaml.md index a6f5cb96f..88838cc1c 100644 --- a/tools/cli/installers/lib/ide/templates/combined/opencode-workflow-yaml.md +++ b/tools/cli/installers/lib/ide/templates/combined/opencode-workflow-yaml.md @@ -1,5 +1,4 @@ --- -name: '{{name}}' description: '{{description}}' --- diff --git a/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md b/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md index a6f5cb96f..88838cc1c 100644 --- a/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md +++ b/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md @@ -1,5 +1,4 @@ --- -name: '{{name}}' description: '{{description}}' ---