Skip to content

Support user-level AGENTS.md fallback and scoped path_btw - #236

Open
gadenbuie wants to merge 7 commits into
mainfrom
fix/226-support-user-level-agents-md-as-a-fallback
Open

gadenbuie wants to merge 7 commits into
mainfrom
fix/226-support-user-level-agents-md-as-a-fallback

Conversation

@gadenbuie

Copy link
Copy Markdown
Collaborator

Fixes #226

Summary

When no user-level btw.md exists, btw_client() and btw_app() now fall back to a user-level AGENTS.md in the cross-tool ~/.agents/ directory. This mirrors the project-level precedence btw.md > AGENTS.md > CLAUDE.md, except a user-level CLAUDE.md is never used. Frontmatter in a user-level AGENTS.md configures client, tools, and options just like a btw.md, and user-level context is combined with the project-level context file.

edit_btw_md("user") opens a user-level AGENTS.md when only one exists and includes them in the multi-file menu. use_btw_md("user") warns (or asks interactively) before creating a ~/.btw/btw.md that would take priority over an existing user-level AGENTS.md.

path_btw in btw_client() and btw_app() now also accepts a named list with project and/or user fields, each TRUE (search the default locations), FALSE (skip that scope), or a path to a specific file. A missing field keeps the default for that scope: project searches project locations and user follows the new btw.client.path_btw_user option (TRUE/FALSE/path), so options(btw.client.path_btw_user = FALSE) in ~/.Rprofile opts out of user-level context globally. btw_app()'s chat history scoping understands the list form too.

One deliberate behavior change: a scalar path now uses only that file, a shortcut for list(project = path, user = FALSE). Previously the user-level btw.md was also loaded alongside it; pass list(project = "path") to combine a specific project file with the default user-level context.

Verification

Full test suite passes locally: 2709 pass, 0 fail, 1 skip (CI-only web tool test).

# Project context plus user-level AGENTS.md fallback (the default)
chat <- btw_client()

# Skip user-level context for a single chat
chat <- btw_client(path_btw = list(user = FALSE))

# Use only a specific file (no user-level context)
chat <- btw_client(path_btw = "analysis/btw.md")

# Combine a specific project file with the default user-level context
chat <- btw_client(path_btw = list(project = "analysis/btw.md"))

# Opt out of user-level context everywhere (e.g. in ~/.Rprofile)
options(btw.client.path_btw_user = FALSE)

If no user-level btw.md exists, btw_client() and btw_app() now fall back to
a user-level AGENTS.md, searched in ~/.btw/, ~/.config/btw/,
tools::R_user_dir("btw"), and ~/.agents/, in that order; a user-level
CLAUDE.md is never used. edit_btw_md("user") opens a user-level AGENTS.md
when no user-level btw.md exists, and use_btw_md("user") warns before
creating a btw.md that would take priority over an existing AGENTS.md.

The path_btw argument of btw_client() and btw_app() now also accepts a
named list with project and/or user fields, each TRUE (search the default
locations), FALSE (skip that scope), or a path to a specific file; a
missing field keeps the default for that scope. A scalar path now uses
only that file (previously the user-level btw.md was also loaded alongside
it); pass list(project = "path") to combine a specific project file with
the default user-level context. The new btw.client.path_btw_user option
sets the default for the user scope.

Fixes #226
A user-level AGENTS.md is a cross-tool convention, so it is now searched
only in ~/.agents/ rather than in btw's own config directories, which
remain reserved for btw.md. The multiple-user-config warning now points
AGENTS.md duplicates at ~/.agents/AGENTS.md as the consolidation target.
@gadenbuie
gadenbuie marked this pull request as ready for review October 6, 2026 14:47
Trim implementation details now covered in the function docs and break
up the dense path_btw bullet into separate sentences.
Drop a redundant restatement and merge two sentences explaining the
user-level lookup.
A user-level CLAUDE.md not being used is covered in ?btw_client and
?btw-config; NEWS needn't mention a non-feature.
Generalize the user-scope option default into btw_path_scope_default()
so the project scope has a matching option. Both options are documented
in ?btw_client and set the defaults for the corresponding path_btw scope.

Also mention the user-level CLAUDE.md exclusion only in ?btw-config,
dropping it from the vignette, ?use_btw_md, and ?btw_client where it
appeared without context.

This branch has not been deployed

No deployments
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 user-level AGENTS.md as a fallback for user-level btw.md

1 participant