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 <noreply@anthropic.com>
This commit is contained in:
Davor Racić 2026-02-25 10:24:36 +01:00
parent 97a533e298
commit 0b219d09e8
7 changed files with 18 additions and 8 deletions

View File

@ -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);

View File

@ -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]

View File

@ -1,5 +1,5 @@
---
name: '{{name}}'
mode: all
description: '{{description}}'
---

View File

@ -1,5 +1,4 @@
---
name: '{{name}}'
description: '{{description}}'
---

View File

@ -1,5 +1,4 @@
---
name: '{{name}}'
description: '{{description}}'
---

View File

@ -1,5 +1,4 @@
---
name: '{{name}}'
description: '{{description}}'
---

View File

@ -1,5 +1,4 @@
---
name: '{{name}}'
description: '{{description}}'
---