Skip to content

Commit

Permalink
release v0.1.0 (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch authored Feb 21, 2025
1 parent 074cba8 commit 7d56f6a
Show file tree
Hide file tree
Showing 28 changed files with 180 additions and 213 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: chores
Title: A Collection of Large Language Model Assistants
Version: 0.0.4
Version: 0.1.0
Authors@R: c(
person("Simon", "Couch", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5676-5107")),
Expand All @@ -9,9 +9,9 @@ Authors@R: c(
Description: Provides a collection of ergonomic large language model assistants
designed to help you complete repetitive, hard-to-automate tasks quickly.
After selecting some code, press the keyboard shortcut you've chosen to
trigger the package app, select an assistant, and watch your code be
rewritten. While the package ships with a number of helpers for R package
development, users can create custom helpers just by writing some
trigger the package app, select an assistant, and watch your chore be
carried out. While the package ships with a number of chore helpers for R
package development, users can create custom helpers just by writing some
instructions in a markdown file.
License: MIT + file LICENSE
Config/testthat/edition: 3
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method(print,helper_response)
export(.helper_add)
export(.init_addin)
export(.init_helper)
export(directory_list)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# chores (development version)
# chores 0.1.0

* Initial CRAN submission.

Expand Down
46 changes: 33 additions & 13 deletions R/directory.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
#' `directory_*()` functions allow users to interface with the directory,
#' making new "chores" available:
#'
#' * `directory_path()` returns the path to the prompt directory, which
#' defaults to `~/.config/chores`.
#' * `directory_path()` returns the path to the prompt directory.
#' * `directory_set()` changes the path to the prompt directory (by setting
#' the option `.chores_dir`).
#' * `directory_list()` enumerates all of the different prompts that currently
#' live in the directory (and provides clickable links to each).
#' * `directory_load()` registers each of the prompts in the prompt
#' directory with the chores package (via [.helper_add()]).
#' directory with the chores package.
#'
#' [Functions prefixed with][prompt] `prompt*()` allow users to conveniently create, edit,
#' and delete the prompts in chores' prompt directory.
Expand Down Expand Up @@ -51,15 +50,28 @@
#' loading the package, just set the `.chores_dir` option with
#' `options(.chores_dir = some_dir)`. To load a directory of files that's not
#' the prompt directory, provide a `dir` argument to `directory_load()`.
#'
#' @returns
#' * `directory_path()` returns the path to the prompt directory (which is
#' not created by default unless explicitly requested by the user).
#' * `directory_set()` return the path to the new prompt directory.
#' * `directory_list()` returns the file paths of all of the prompts that
#' currently live in the directory (and provides clickable links to each).
#' * `directory_load()` returns `NULL` invisibly.
#'
#' @name directory
#'
#' @seealso The "Custom helpers" vignette, at `vignette("custom", package = "chores")`,
#' for more on adding your own helper prompts, sharing them with others, and
#' using prompts from others.
#' @seealso The "Custom helpers" vignette, at
#' `vignette("custom", package = "chores")`,for more on adding your own
#' helper prompts, sharing them with others, and using prompts from others.
#'
#' @examples
#' # choose a path for the prompt directory
#' tmp_dir <- withr::local_tempdir()
#' directory_set(tmp_dir)
#'
#' @examplesIf FALSE
#' # print out the current prompt directory
#' directory_get()
#' directory_path()
#'
#' # list out prompts currently in the directory
#' directory_list()
Expand All @@ -74,10 +86,6 @@
#' # (this will also happen automatically on reload)
#' directory_load()
#'
#' # these are equivalent:
#' directory_set("some/folder")
#' options(.chores_dir = "some/folder")
#'
#' @export
directory_load <- function(dir = directory_path()) {
prompt_base_names <- directory_base_names(dir)
Expand All @@ -94,6 +102,8 @@ directory_load <- function(dir = directory_path()) {

.helper_add(chore = chore, prompt = prompt, interface = interface)
}

invisible()
}

#' @rdname directory
Expand Down Expand Up @@ -131,7 +141,17 @@ directory_list <- function() {
#' @rdname directory
#' @export
directory_path <- function() {
getOption(".chores_dir", default = file.path("~", ".config", "chores"))
.chores_dir <- getOption(".chores_dir", default = NULL)

if (is.null(.chores_dir)) {
cli::cli_warn(c(
"No {.pkg chores} prompt directory configured.",
'Set one in your {.file .Rprofile} using e.g.
{.code directory_set(file.path("~", ".config", "chores"))}.'
))
}

.chores_dir
}

#' @rdname directory
Expand Down
3 changes: 1 addition & 2 deletions R/doc-helper-roxygen.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#'
#' @section Gallery:
#'
#' This section includes a handful of examples
#' "[from the wild](https://github.com/hadley/elmer/tree/e497d627e7be01206df6f1420ca36235141dc22a/R)"
#' This section includes a handful of examples "from the wild"
#' and are generated with the recommended model, Claude Sonnet 3.5.
#'
#' Documenting a function factory:
Expand Down
55 changes: 27 additions & 28 deletions R/helper-add-remove.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
#' Registering helpers
#'
#' @description
#' Users can create custom helpers using the `.helper_add()` function; after passing
#' the function a chore and prompt, the helper will be available in the
#' [chores addin][.init_addin].
#'
#' **Most users should not need to interact with these functions.**
#' [prompt_new()] and friends can be used to create prompts for new helpers, and
#' those helpers can be registered with chores using [directory_load()] and friends.
#' The helpers created by those functions will be persistent across sessions.
#'
#' @param chore A single string giving a descriptor of the helper's functionality.
#' Cand only contain letters and numbers.
#' @param prompt A single string giving the system prompt. In most cases, this
#' is a rather long string, containing several newlines.
#' @param interface One of `"replace"`, `"prefix"`, or `"suffix"`, describing
#' how the helper will interact with the selection. For example, the
#' [cli helper][cli_helper] `"replace"`s the selection, while the
#' [roxygen helper][roxygen_helper] `"prefixes"` the selected code with documentation.
#'
#' @returns
#' `NULL`, invisibly. Called for its side effect: a helper for chore `chore`
#' is registered (or unregistered) with the chores package.
#'
#' @name helper_add_remove
#' @export
# Registering helpers
#
# @description
# Users can create custom helpers using the `.helper_add()` function; after passing
# the function a chore and prompt, the helper will be available in the
# [chores addin][.init_addin].
#
# **Most users should not need to interact with these functions.**
# [prompt_new()] and friends can be used to create prompts for new helpers, and
# those helpers can be registered with chores using [directory_load()] and friends.
# The helpers created by those functions will be persistent across sessions.
#
# @param chore A single string giving a descriptor of the helper's functionality.
# Cand only contain letters and numbers.
# @param prompt A single string giving the system prompt. In most cases, this
# is a rather long string, containing several newlines.
# @param interface One of `"replace"`, `"prefix"`, or `"suffix"`, describing
# how the helper will interact with the selection. For example, the
# [cli helper][cli_helper] `"replace"`s the selection, while the
# [roxygen helper][roxygen_helper] `"prefixes"` the selected code with documentation.
#
# @returns
# `NULL`, invisibly. Called for its side effect: a helper for chore `chore`
# is registered (or unregistered) with the chores package.
#
# @name helper_add_remove
.helper_add <- function(
chore,
prompt = NULL,
Expand All @@ -39,7 +38,7 @@
invisible()
}

#' @rdname helper_add_remove
# @rdname helper_add_remove
.helper_remove <- function(chore) {
check_string(chore)
if (!chore %in% list_helpers()) {
Expand Down
4 changes: 4 additions & 0 deletions R/init-addin.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#' `NULL`, invisibly. Called for the side effect of launching the chores addin
#' and interfacing with selected text.
#'
#' @examples
#' if (interactive()) {
#' .init_addin()
#' }
#' @export
.init_addin <- function() {
if (is.null(fetch_chores_chat())) {
Expand Down
14 changes: 10 additions & 4 deletions R/init-helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
#'
#' @param chore The identifier for a helper prompt. By default one
#' of `r glue::glue_collapse(paste0("[", glue::double_quote(default_chores), "]", "[", default_chores, "_helper", "]"), ", ", last = " or ")`,
#' though custom helpers can be added with [.helper_add()].
#' though custom helpers can be added with [prompt_new()].
#' @param .chores_chat An ellmer Chat, e.g.
#' `function() ellmer::chat_claude()`. Defaults to the option by the same name,
#' so e.g. set `options(.chores_chat = ellmer::chat_claude())` in your
#' `.Rprofile` to configure chores with ellmer every time you start a new R session.
#'
#' @examplesIf FALSE
#' @returns
#' A Helper object, which is a subclass of an ellmer chat.
#'
#' @examples
#' # requires an API key and sets options
#' \dontrun{
#' # to create a chat with claude:
#' .init_helper()
#' .init_helper(.chores_chat = ellmer::chat_claude())
#'
#' # or with OpenAI's 4o-mini:
#' .init_helper(.chores_chat = ellmer::chat_openai(model = "gpt-4o-mini"))
Expand All @@ -28,6 +33,7 @@
#' options(
#' .chores_chat = ellmer::chat_openai(model = "gpt-4o-mini")
#' )
#' }
#' @export
.init_helper <- function(
chore = NULL,
Expand All @@ -37,7 +43,7 @@
if (!chore %in% list_helpers()) {
cli::cli_abort(c(
"No helpers for chore {.arg {chore}} registered.",
"i" = "See {.fn .helper_add}."
"i" = "See {.fn prompt_new}."
))
}

Expand Down
12 changes: 9 additions & 3 deletions R/prompt.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
#' Load the prompts you create with these functions using [directory_load()]
#' (which is automatically called when the package loads).
#'
#' @inheritParams helper_add_remove
#' @param chore A single string giving a descriptor of the helper's functionality.
#' Cand only contain letters and numbers.
#' @param interface One of `"replace"`, `"prefix"`, or `"suffix"`, describing
#' how the helper will interact with the selection. For example, the
#' [cli helper][cli_helper] `"replace"`s the selection, while the
#' [roxygen helper][roxygen_helper] `"prefixes"` the selected code with documentation.
#' @param contents Optional. Path to a markdown file with contents that will
#' "pre-fill" the file. Anything file ending in `.md` or `.markdown` that can be
#' read with `readLines()` is fair game; this could be a local file, a "raw"
Expand All @@ -32,7 +37,8 @@
#' Each `prompt_*()` function returns the file path to the created, edited, or
#' removed filepath, invisibly.
#'
#' @examplesIf FALSE
#' @examples
#' if (interactive()) {
#' # create a new helper for chore `"boop"` that replaces the selected text:
#' prompt_new("boop")
#'
Expand Down Expand Up @@ -66,7 +72,7 @@
#' "58c9b4da/summarize-prefix.md"
#' )
#' )
#'
#' }
#' @name prompt

#' @rdname prompt
Expand Down
4 changes: 2 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

directory_load(system.file("prompts", package = "chores"))

chores_dir <- getOption(".chores_dir", default = file.path("~", ".config", "chores"))
if (dir.exists(chores_dir)) {
chores_dir <- getOption(".chores_dir", default = NULL)
if (!is.null(chores_dir) && dir.exists(chores_dir)) {
directory_load(chores_dir)
}
}
Expand Down
8 changes: 7 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ Getting started with chores takes three steps.

**1)** Install the chores package like so:

``` r
install.packages("chores")
```

You can install the developmental version with:

``` r
pak::pak("simonpcouch/chores")
```
Expand Down Expand Up @@ -79,7 +85,7 @@ As-is, the package provides ergonomic LLM assistants for R package development:

Users have also contributed a number of helpers for a wide range of tasks--see `vignette("gallery", package = "chores")` for a gallery of user-contributed helpers!

That said, all you need to create your own chore helper is a markdown file with some instructions on how you'd like it to work. See `prompt_new()` and `directory_load()` for more information, and [chorespable](https://github.com/simonpcouch/chorespable) for an example chores extension package.
That said, all you need to create your own chore helper is a markdown file with some instructions on how you'd like it to work. See `prompt_new()` and `directory_load()` for more information, and [palpable](https://github.com/simonpcouch/palpable) for an example chores extension package.

## How much do helpers cost?

Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN
status](https://www.r-pkg.org/badges/version/chores)](https://CRAN.R-project.org/package=chores)
[![R-CMD-check](https://github.com/simonpcouch/chores/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/simonpcouch/chores/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

Expand All @@ -26,6 +24,12 @@ Getting started with chores takes three steps.

**1)** Install the chores package like so:

``` r
install.packages("chores")
```

You can install the developmental version with:

``` r
pak::pak("simonpcouch/chores")
```
Expand Down Expand Up @@ -98,7 +102,7 @@ user-contributed helpers!
That said, all you need to create your own chore helper is a markdown
file with some instructions on how you’d like it to work. See
`prompt_new()` and `directory_load()` for more information, and
[chorespable](https://github.com/simonpcouch/chorespable) for an example
[palpable](https://github.com/simonpcouch/palpable) for an example
chores extension package.

## How much do helpers cost?
Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ reference:
- cli_helper
- title: Developer Infrastructure
contents:
- helper_add_remove
- .init_helper
- .init_addin
18 changes: 15 additions & 3 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
## R CMD check results
**Notes for CRAN maintainers**

0 errors | 0 warnings | 1 note
There's 1 R CMD check NOTE, as this is a new release.

* This is a new release.
> If there are references describing the methods in your package...
Unfortunately, there are not formal references for the methods implemented in this package. Relevant software is mentioned in single quotes in the Description.

> Please add \value to .Rd files regarding exported methods and explain the functions results in the documentation.
Added docs on return value for this missing functions, thanks!

> Please ensure that your functions do not write by default or in your examples/vignettes/tests in the user's home filespace... In your examples/vignettes/tests you can write to tempdir().
Thanks, examples/tests/vignettes now use a tempdir.

Thank you all for your work.
2 changes: 1 addition & 1 deletion man/chores-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7d56f6a

Please sign in to comment.