Skip to content

feat(agents): discover custom agents from .btw/agents/ subdirectory#205

Merged
gadenbuie merged 1 commit into
mainfrom
feat/202-support-agents-subdir
Jul 17, 2026
Merged

feat(agents): discover custom agents from .btw/agents/ subdirectory#205
gadenbuie merged 1 commit into
mainfrom
feat/202-support-agents-subdir

Conversation

@gadenbuie

@gadenbuie gadenbuie commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Fixes #202

btw already supports a .btw/skills/ directory, but custom agents could only be placed as flat agent-*.md files. This adds support for an agents/ subdirectory so agent files can be organized in a dedicated folder and copied around more easily.

What changed

  • Discovery (R/utils.R): find_project_agent_files() and find_user_agent_files() now also scan an agents/ subdirectory — .btw/agents/*.md at the project level and <user_dir>/agents/*.md at the user level (~/.btw/, ~/.config/btw/, tools::R_user_dir("btw")) — in addition to the existing flat agent-*.md files.
  • Naming: files inside agents/ use plain {name}.md names; the agent name is taken from the YAML frontmatter (convention: agents/{name}.md matches the frontmatter name, but the frontmatter is authoritative).
  • Precedence: agents/*.md files are returned ahead of flat agent-*.md files, so on a name conflict the subdirectory version wins via the existing first-wins dedup in custom_agent_discover_tools() (which still warns on duplicates). The agents/ directory is otherwise the same priority tier as the flat files.
  • Docs: updated the "Automatic Discovery" section of btw_agent_tool() and the project/user location docs in ?btw-config.

Backward compatibility

Fully backward compatible — the flat agent-*.md behavior is unchanged.

Tests

Added tests for project- and user-level agents/ discovery, discovery ordering (subdir before flat), and the agents/-wins-over-flat precedence on a name conflict.

Notes

  • No filename/frontmatter-name mismatch warning was added; the frontmatter name remains authoritative and the {name}.md convention is documented in roxygen only.

Support an agents/ subdirectory at both project (.btw/agents/*.md) and
user (<user_dir>/agents/*.md) levels in addition to the flat agent-*.md
files. Files in agents/ use plain {name}.md names with the agent name
taken from YAML frontmatter.

Discovery returns agents/ subdir files before flat agent-*.md files, so
the subdir version wins on a name conflict via the existing first-wins
dedup in custom_agent_discover_tools().

Fixes #202
@gadenbuie
gadenbuie merged commit c50e872 into main Jul 17, 2026
9 checks passed
@gadenbuie
gadenbuie deleted the feat/202-support-agents-subdir branch July 17, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support .btw/agents/ directory in addition to .btw/agents-* prefix

1 participant