fix: standardize user-level config directories via btw_user_dirs()#182
Merged
fix: standardize user-level config directories via btw_user_dirs()#182
btw_user_dirs()#182Conversation
Introduces `btw_user_dirs()` as a single source of truth for all
user-level btw config locations, returning paths in decreasing priority
order (~/.btw, ~/.config/btw, tools::R_user_dir("btw")).
Previously, skills, agents, and btw.md each hardcoded their own
inconsistent sets of user-level paths. Skills used
`tools::R_user_dir("btw", "config")` (wrong `which` argument, shipped
in v1.2.0), agents used ~/.btw and ~/.config/btw, and btw.md used the
home dir and ~/.config/btw.
Now all three subsystems use `btw_user_dirs()`:
- `path_find_user()`: gains ~/.btw and tools::R_user_dir("btw") lookups
- `find_user_agent_files()`: gains tools::R_user_dir("btw") lookup
- `btw_skills_directories()`: uses rev(btw_user_dirs()) for correct
increasing-priority insertion; retains tools::R_user_dir("btw","config")
as a legacy read-only fallback for skills installed with btw <= 1.2.0
- `resolve_skill_scope("user")`: new resolve_user_skill_dir() picks the
first non-empty existing candidate from btw_user_dirs(), defaulting
to ~/.btw/skills
btw_skills_directories() builds its list in increasing priority order (last = highest). find_skill() was iterating in that same order and returning on first match, meaning it returned the *lowest*-priority version — the opposite of btw_skills_list()'s last-wins semantics. Fix by iterating rev(skill_dirs) in both the fast and slow paths so find_skill() and btw_skills_list() agree on which version wins. Also adds tests for find_skill() priority resolution and resolve_user_skill_dir() selection semantics.
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.
Summary
Introduces
btw_user_dirs()inR/utils.Ras a single source of truth for all user-level btw configuration locations. Previously, skills, agents, andbtw.mddiscovery each hardcoded different and inconsistent sets of paths — and skills usedtools::R_user_dir("btw", "config"), the wrongwhichargument (shipped in v1.2.0).btw_user_dirs()returns paths in decreasing priority order:~/.btw,~/.config/btw,tools::R_user_dir("btw"). All three subsystems now use it:btw_skills_directories()): usesrev(btw_user_dirs())to build the increasing-priority dir list; retainstools::R_user_dir("btw", "config")/skillsas a legacy read-only fallback for installs from btw <= 1.2.0resolve_user_skill_dir()): picks the first non-empty existing candidate frombtw_user_dirs(), defaulting to~/.btw/skillsfind_user_agent_files()): gainstools::R_user_dir("btw")lookupbtw.mddiscovery (path_find_user()): gains~/.btw/btw.mdandtools::R_user_dir("btw")/btw.mdlookupsAlso includes: a btw CLI fix for standard packages not loading (datasets, stats, methods), and AGENTS.md updates documenting
btw_user_dirs()as the canonical helper to use for any future user-level config work.Verification