-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Description
Commit b9ef09a added glob pattern support for plural directory names (commands/, agents/), but did not update the name extraction logic accordingly.
This causes nested command/agent names to lose their prefix when using plural directory names.
Reproduction
When using OPENCODE_CONFIG_DIR pointing to a custom config directory with structure:
commands/
email/
digest.md
- Expected command name:
email/digest - Actual command name:
digest(prefix lost)
Root Cause
In packages/opencode/src/config/config.ts:
-
The glob pattern correctly matches both singular and plural:
const COMMAND_GLOB = new Bun.Glob("{command,commands}/**/*.md")
-
But the name extraction logic only checks for singular patterns:
const patterns = ["/.opencode/command/", "/command/"]
-
When the path contains
/commands/(plural), no pattern matches, causing fallback topath.basename()which loses the directory prefix.
The same issue exists in loadAgent function.
Proposed Fix
Add plural patterns to the name extraction logic:
- For commands: add
"/.opencode/commands/"and"/commands/" - For agents: add
"/.opencode/agents/"and"/agents/"
I have a fix ready and can submit a PR if this approach is approved.
Related
- Original commit adding plural support: b9ef09a