diff --git a/DESCRIPTION b/DESCRIPTION index a747650..e107478 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: saber Type: Package Title: Context Engineering for Large Language Model Agents -Version: 0.7.1 +Version: 0.7.1.1 Authors@R: c( person("Troy", "Hernandez", role = c("aut", "cre"), email = "troy@cornball.ai", diff --git a/NEWS.md b/NEWS.md index 06f0aae..0564b2d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,12 @@ +# saber 0.7.1.1 + +## Changes + +- `fn_graph()` now accepts `cache_dir`, mirroring `blast_radius()` and + `symbols()`. The default is unchanged. The example and tinytest pass + `tempdir()` so R CMD check no longer leaves files under + `tools::R_user_dir("saber", "cache")`. + # saber 0.7.1 ## Changes diff --git a/R/fn_graph.R b/R/fn_graph.R index ac458cb..a879163 100644 --- a/R/fn_graph.R +++ b/R/fn_graph.R @@ -13,6 +13,10 @@ #' functions called from other packages. Default \code{FALSE}. #' @param ... Passed through to \code{\link{graph_svg}} (e.g., #' \code{width}, \code{height}, \code{iterations}, \code{seed}). +#' @param cache_dir Directory for the underlying \code{\link{symbols}} +#' cache. Pass \code{tempdir()} (or any non-default path) when running +#' examples / tests to avoid writing to the user's persistent cache. +#' Name-only argument — must be passed by name. #' @return Character vector of SVG lines. Write with \code{writeLines()}. #' @examples #' d <- file.path(tempdir(), "fngdemo") @@ -22,11 +26,12 @@ #' writeLines("add <- function(x, y) x + y", file.path(d, "R", "add.R")) #' writeLines("double <- function(x) add(x, x)", #' file.path(d, "R", "double.R")) -#' svg <- fn_graph(d) +#' svg <- fn_graph(d, cache_dir = tempdir()) #' writeLines(svg, tempfile(fileext = ".svg")) #' @export -fn_graph <- function(project_dir, include_external = FALSE, ...) { - idx <- symbols(project_dir) +fn_graph <- function(project_dir, include_external = FALSE, ..., + cache_dir = file.path(tools::R_user_dir("saber", "cache"), "symbols")) { + idx <- symbols(project_dir, cache_dir = cache_dir) defs <- idx$defs calls <- idx$calls diff --git a/inst/tinytest/test_fn_graph.R b/inst/tinytest/test_fn_graph.R index 73e84ef..027f2b6 100644 --- a/inst/tinytest/test_fn_graph.R +++ b/inst/tinytest/test_fn_graph.R @@ -8,7 +8,7 @@ writeLines(c("Package: demo", "Version: 0.1.0"), file.path(d, "DESCRIPTION")) writeLines("add <- function(x, y) x + y", file.path(d, "R", "add.R")) writeLines("double <- function(x) add(x, x)", file.path(d, "R", "double.R")) -svg <- fn_graph(d) +svg <- fn_graph(d, cache_dir = tempdir()) expect_true(is.character(svg)) expect_true(any(grepl("^