Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# btw (development version)

* Updates for compatibility with S7 > 0.2.2.

* `path_find_in_project()` now stops its upward search when it reaches the home directory (either `fs::path_home()` or `fs::path_home_r()`, which differ on Windows) and never treats files there as project files, so `~/AGENTS.md` or `~/CLAUDE.md` are no longer picked up as project context when the working directory is under `~` but outside a project. Home-level files are handled only by the user-level lookup. This also fixes `~/btw.md` instructions being included twice — once as the project file and once as the user-level config (#225).

* `btw_client(path_btw = ...)` no longer duplicates instructions when `path_btw` is set explicitly to the same file as the user-level `btw.md` (#225).
Expand Down
2 changes: 1 addition & 1 deletion R/btw.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ btw <- function(..., clipboard = TRUE) {

if (identical(res, "")) {
cli::cli_alert_warning("Nothing to include in the btw() context.")
return(invisible(BTW("")))
return(invisible(BTW(text = "")))
}

BTW(text = res, settings = env(clipboard = clipboard))
Expand Down
16 changes: 15 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.onLoad <- function(libname, pkgname) {
# run_on_load()
S7::methods_register()
if ("S7_on_load" %in% getNamespaceExports("S7")) {
getExportedValue("S7", "S7_on_load")()
} else {
S7::methods_register()
}

pkg_env <- rlang::fn_env(btw_tools)
for (tool_def in as_ellmer_tools(.btw_tools, force = TRUE)) {
Expand Down Expand Up @@ -32,3 +36,13 @@ if (getRversion() < "4.3.0") {
# R6 binds `self` and `super` at runtime; declare them so codetools doesn't
# flag them as global variables in R CMD check.
utils::globalVariables(c("private", "self", "super"))

.onUnload <- function(...) {
if ("S7_on_unload" %in% getNamespaceExports("S7")) {
getExportedValue("S7", "S7_on_unload")()
}
}

if ("S7_on_build" %in% getNamespaceExports("S7")) {
getExportedValue("S7", "S7_on_build")()
}
Loading