diff --git a/NAMESPACE b/NAMESPACE index 8f2065a..9cfc1e2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,9 +1,9 @@ # Generated by roxygen2: do not edit by hand S3method(print,pal_response) +export(.pal_add) export(.pal_addin) export(.pal_init) -export(pal_add) import(rlang) importFrom(elmer,content_image_file) importFrom(glue,glue) diff --git a/R/pal-add-remove.R b/R/pal-add-remove.R index aceb0e1..13e4624 100644 --- a/R/pal-add-remove.R +++ b/R/pal-add-remove.R @@ -1,7 +1,7 @@ #' Creating custom pals #' #' @description -#' Users can create custom pals using the `pal_add()` function; after passing +#' Users can create custom pals using the `.pal_add()` function; after passing #' the function a role and prompt, the pal will be available on the command #' palette. #' @@ -15,20 +15,13 @@ #' [cli pal][pal_cli] `"replace"`s the selection, while the #' [roxygen pal][pal_roxygen] `"prefixes"` the selected code with documentation. #' -#' @details -#' `pal_add()` will register the add-in as coming from the pal package -#' itself—because of this, custom pals will be deleted when the pal -#' package is reinstalled. Include `pal_add()` code in your `.Rprofile` or -#' make a pal extension package using `pal_add(package = TRUE)` to create -#' persistent custom pals. -#' #' @returns #' `NULL`, invisibly. Called for its side effect: a pal with role `role` #' is registered with the pal package. #' #' @name pal_add_remove #' @export -pal_add <- function( +.pal_add <- function( role, prompt = NULL, interface = c("replace", "prefix", "suffix") @@ -45,7 +38,7 @@ pal_add <- function( } #' @rdname pal_add_remove -pal_remove <- function(role) { +.pal_remove <- function(role) { check_string(role) if (!role %in% list_pals()) { cli::cli_abort("No active pal with the given {.arg role}.") diff --git a/R/pal-init.R b/R/pal-init.R index 55e80b5..4e03818 100644 --- a/R/pal-init.R +++ b/R/pal-init.R @@ -4,12 +4,12 @@ #' **Users typically should not need to call this function.** #' #' * Create new pals that will automatically be registered with this function -#' with [pal_add()]. +#' with [.pal_add()]. #' * The [pal addin][.pal_addin()] will initialize needed pals on-the-fly. #' #' @param role The identifier for a pal prompt. By default one #' of `r glue::glue_collapse(paste0("[", glue::double_quote(default_roles), "]", "[pal_", default_roles, "]"), ", ", last = " or ")`, -#' though custom pals can be added with [pal_add()]. +#' though custom pals can be added with [.pal_add()]. #' @param fn A `new_*()` function, likely from the elmer package. Defaults #' to [elmer::chat_claude()]. To set a persistent alternative default, #' set the `.pal_fn` option; see examples below. @@ -52,7 +52,7 @@ if (!role %in% list_pals()) { cli::cli_abort(c( "No pals with role {.arg {role}} registered.", - "i" = "See {.fn pal_add}." + "i" = "See {.fn .pal_add}." )) } diff --git a/R/zzz.R b/R/zzz.R index 2c7b839..83d182b 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -11,7 +11,7 @@ prompt <- paste0(readLines(prompts[idx]), collapse = "\n") interface <- roles_and_interfaces[[idx]][2] - pal_add(role = role, prompt = prompt, interface = interface) + .pal_add(role = role, prompt = prompt, interface = interface) } } diff --git a/man/dot-pal_init.Rd b/man/dot-pal_init.Rd index 36b3607..9e006a2 100644 --- a/man/dot-pal_init.Rd +++ b/man/dot-pal_init.Rd @@ -14,7 +14,7 @@ \arguments{ \item{role}{The identifier for a pal prompt. By default one of \link[=pal_cli]{"cli"}, \link[=pal_testthat]{"testthat"} or \link[=pal_roxygen]{"roxygen"}, -though custom pals can be added with \code{\link[=pal_add]{pal_add()}}.} +though custom pals can be added with \code{\link[=.pal_add]{.pal_add()}}.} \item{fn}{A \verb{new_*()} function, likely from the elmer package. Defaults to \code{\link[elmer:chat_claude]{elmer::chat_claude()}}. To set a persistent alternative default, @@ -30,7 +30,7 @@ set the \code{.pal_args} option; see examples below.} \strong{Users typically should not need to call this function.} \itemize{ \item Create new pals that will automatically be registered with this function -with \code{\link[=pal_add]{pal_add()}}. +with \code{\link[=.pal_add]{.pal_add()}}. \item The \link[=.pal_addin]{pal addin} will initialize needed pals on-the-fly. } } @@ -43,10 +43,10 @@ to look for your API credentials and will call needed functions by itself. \examples{ \dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # to create a chat with claude: - .pal_init() +.pal_init() # or with OpenAI's 4o-mini: - .pal_init( +.pal_init( "chat_openai", model = "gpt-4o-mini" ) diff --git a/man/pal_add_remove.Rd b/man/pal_add_remove.Rd index 918265a..a396fcd 100644 --- a/man/pal_add_remove.Rd +++ b/man/pal_add_remove.Rd @@ -2,16 +2,16 @@ % Please edit documentation in R/pal-add-remove.R \name{pal_add_remove} \alias{pal_add_remove} -\alias{pal_add} -\alias{pal_remove} +\alias{.pal_add} +\alias{.pal_remove} \title{Creating custom pals} \usage{ -pal_add(role, prompt = NULL, interface = c("replace", "prefix", "suffix")) +.pal_add(role, prompt = NULL, interface = c("replace", "prefix", "suffix")) -pal_remove(role) +.pal_remove(role) } \arguments{ -\item{role}{A single string giving the \code{\link[= .pal_init]{ .pal_init()}} role.} +\item{role}{A single string giving the \code{\link[=.pal_init]{.pal_init()}} role.} \item{prompt}{A file path to a markdown file giving the system prompt or the output of \code{\link[elmer:interpolate]{elmer::interpolate()}}.} @@ -26,14 +26,7 @@ how the pal will interact with the selection. For example, the is registered with the pal package. } \description{ -Users can create custom pals using the \code{pal_add()} function; after passing +Users can create custom pals using the \code{.pal_add()} function; after passing the function a role and prompt, the pal will be available on the command palette. } -\details{ -\code{pal_add()} will register the add-in as coming from the pal package -itself—because of this, custom pals will be deleted when the pal -package is reinstalled. Include \code{pal_add()} code in your \code{.Rprofile} or -make a pal extension package using \code{pal_add(package = TRUE)} to create -persistent custom pals. -} diff --git a/man/pal_cli.Rd b/man/pal_cli.Rd index be801a2..4155eb1 100644 --- a/man/pal_cli.Rd +++ b/man/pal_cli.Rd @@ -175,7 +175,7 @@ Returns: Pals are typically interfaced with via the pal addin. To call the cli pal directly, use: -\if{html}{\out{