Skip to content

fix: name extraction missing plural directory support (commands/, agents/) #7667

Closed

Description

@yanmxa

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:

  1. The glob pattern correctly matches both singular and plural:

    const COMMAND_GLOB = new Bun.Glob("{command,commands}/**/*.md")
  2. But the name extraction logic only checks for singular patterns:

    const patterns = ["/.opencode/command/", "/command/"]
  3. When the path contains /commands/ (plural), no pattern matches, causing fallback to path.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

Activity

  1. github-actions commented on Jan 10, 2026

    @github-actions
    Contributor

    This issue addresses the implementation gap for plural directory support that was requested in #5052. The plural patterns were added to the glob patterns but the name extraction logic wasn't updated accordingly. This fix ensures that commands and agents defined in plural directories (e.g., commands/, agents/) have their names extracted correctly, preserving nested directory prefixes as intended.

  2. rekram1-node commented on Jan 13, 2026

    @rekram1-node
    Contributor

    fixed by: 735f3d1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions