feat(agents): discover custom agents from .btw/agents/ subdirectory#205
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #202
btw already supports a
.btw/skills/directory, but custom agents could only be placed as flatagent-*.mdfiles. This adds support for anagents/subdirectory so agent files can be organized in a dedicated folder and copied around more easily.What changed
R/utils.R):find_project_agent_files()andfind_user_agent_files()now also scan anagents/subdirectory —.btw/agents/*.mdat the project level and<user_dir>/agents/*.mdat the user level (~/.btw/,~/.config/btw/,tools::R_user_dir("btw")) — in addition to the existing flatagent-*.mdfiles.agents/use plain{name}.mdnames; the agent name is taken from the YAML frontmatter (convention:agents/{name}.mdmatches the frontmattername, but the frontmatter is authoritative).agents/*.mdfiles are returned ahead of flatagent-*.mdfiles, so on a name conflict the subdirectory version wins via the existing first-wins dedup incustom_agent_discover_tools()(which still warns on duplicates). Theagents/directory is otherwise the same priority tier as the flat files.btw_agent_tool()and the project/user location docs in?btw-config.Backward compatibility
Fully backward compatible — the flat
agent-*.mdbehavior 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
nameremains authoritative and the{name}.mdconvention is documented in roxygen only.