Skip to content

Commit 7d56f6a

Browse files
authored
release v0.1.0 (#86)
1 parent 074cba8 commit 7d56f6a

28 files changed

+180
-213
lines changed

DESCRIPTION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: chores
22
Title: A Collection of Large Language Model Assistants
3-
Version: 0.0.4
3+
Version: 0.1.0
44
Authors@R: c(
55
person("Simon", "Couch", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0001-5676-5107")),
@@ -9,9 +9,9 @@ Authors@R: c(
99
Description: Provides a collection of ergonomic large language model assistants
1010
designed to help you complete repetitive, hard-to-automate tasks quickly.
1111
After selecting some code, press the keyboard shortcut you've chosen to
12-
trigger the package app, select an assistant, and watch your code be
13-
rewritten. While the package ships with a number of helpers for R package
14-
development, users can create custom helpers just by writing some
12+
trigger the package app, select an assistant, and watch your chore be
13+
carried out. While the package ships with a number of chore helpers for R
14+
package development, users can create custom helpers just by writing some
1515
instructions in a markdown file.
1616
License: MIT + file LICENSE
1717
Config/testthat/edition: 3

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Generated by roxygen2: do not edit by hand
22

33
S3method(print,helper_response)
4-
export(.helper_add)
54
export(.init_addin)
65
export(.init_helper)
76
export(directory_list)

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# chores (development version)
1+
# chores 0.1.0
22

33
* Initial CRAN submission.
44

R/directory.R

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
#' `directory_*()` functions allow users to interface with the directory,
77
#' making new "chores" available:
88
#'
9-
#' * `directory_path()` returns the path to the prompt directory, which
10-
#' defaults to `~/.config/chores`.
9+
#' * `directory_path()` returns the path to the prompt directory.
1110
#' * `directory_set()` changes the path to the prompt directory (by setting
1211
#' the option `.chores_dir`).
1312
#' * `directory_list()` enumerates all of the different prompts that currently
1413
#' live in the directory (and provides clickable links to each).
1514
#' * `directory_load()` registers each of the prompts in the prompt
16-
#' directory with the chores package (via [.helper_add()]).
15+
#' directory with the chores package.
1716
#'
1817
#' [Functions prefixed with][prompt] `prompt*()` allow users to conveniently create, edit,
1918
#' and delete the prompts in chores' prompt directory.
@@ -51,15 +50,28 @@
5150
#' loading the package, just set the `.chores_dir` option with
5251
#' `options(.chores_dir = some_dir)`. To load a directory of files that's not
5352
#' the prompt directory, provide a `dir` argument to `directory_load()`.
53+
#'
54+
#' @returns
55+
#' * `directory_path()` returns the path to the prompt directory (which is
56+
#' not created by default unless explicitly requested by the user).
57+
#' * `directory_set()` return the path to the new prompt directory.
58+
#' * `directory_list()` returns the file paths of all of the prompts that
59+
#' currently live in the directory (and provides clickable links to each).
60+
#' * `directory_load()` returns `NULL` invisibly.
61+
#'
5462
#' @name directory
5563
#'
56-
#' @seealso The "Custom helpers" vignette, at `vignette("custom", package = "chores")`,
57-
#' for more on adding your own helper prompts, sharing them with others, and
58-
#' using prompts from others.
64+
#' @seealso The "Custom helpers" vignette, at
65+
#' `vignette("custom", package = "chores")`,for more on adding your own
66+
#' helper prompts, sharing them with others, and using prompts from others.
67+
#'
68+
#' @examples
69+
#' # choose a path for the prompt directory
70+
#' tmp_dir <- withr::local_tempdir()
71+
#' directory_set(tmp_dir)
5972
#'
60-
#' @examplesIf FALSE
6173
#' # print out the current prompt directory
62-
#' directory_get()
74+
#' directory_path()
6375
#'
6476
#' # list out prompts currently in the directory
6577
#' directory_list()
@@ -74,10 +86,6 @@
7486
#' # (this will also happen automatically on reload)
7587
#' directory_load()
7688
#'
77-
#' # these are equivalent:
78-
#' directory_set("some/folder")
79-
#' options(.chores_dir = "some/folder")
80-
#'
8189
#' @export
8290
directory_load <- function(dir = directory_path()) {
8391
prompt_base_names <- directory_base_names(dir)
@@ -94,6 +102,8 @@ directory_load <- function(dir = directory_path()) {
94102

95103
.helper_add(chore = chore, prompt = prompt, interface = interface)
96104
}
105+
106+
invisible()
97107
}
98108

99109
#' @rdname directory
@@ -131,7 +141,17 @@ directory_list <- function() {
131141
#' @rdname directory
132142
#' @export
133143
directory_path <- function() {
134-
getOption(".chores_dir", default = file.path("~", ".config", "chores"))
144+
.chores_dir <- getOption(".chores_dir", default = NULL)
145+
146+
if (is.null(.chores_dir)) {
147+
cli::cli_warn(c(
148+
"No {.pkg chores} prompt directory configured.",
149+
'Set one in your {.file .Rprofile} using e.g.
150+
{.code directory_set(file.path("~", ".config", "chores"))}.'
151+
))
152+
}
153+
154+
.chores_dir
135155
}
136156

137157
#' @rdname directory

R/doc-helper-roxygen.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
#'
3232
#' @section Gallery:
3333
#'
34-
#' This section includes a handful of examples
35-
#' "[from the wild](https://github.com/hadley/elmer/tree/e497d627e7be01206df6f1420ca36235141dc22a/R)"
34+
#' This section includes a handful of examples "from the wild"
3635
#' and are generated with the recommended model, Claude Sonnet 3.5.
3736
#'
3837
#' Documenting a function factory:

R/helper-add-remove.R

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
#' Registering helpers
2-
#'
3-
#' @description
4-
#' Users can create custom helpers using the `.helper_add()` function; after passing
5-
#' the function a chore and prompt, the helper will be available in the
6-
#' [chores addin][.init_addin].
7-
#'
8-
#' **Most users should not need to interact with these functions.**
9-
#' [prompt_new()] and friends can be used to create prompts for new helpers, and
10-
#' those helpers can be registered with chores using [directory_load()] and friends.
11-
#' The helpers created by those functions will be persistent across sessions.
12-
#'
13-
#' @param chore A single string giving a descriptor of the helper's functionality.
14-
#' Cand only contain letters and numbers.
15-
#' @param prompt A single string giving the system prompt. In most cases, this
16-
#' is a rather long string, containing several newlines.
17-
#' @param interface One of `"replace"`, `"prefix"`, or `"suffix"`, describing
18-
#' how the helper will interact with the selection. For example, the
19-
#' [cli helper][cli_helper] `"replace"`s the selection, while the
20-
#' [roxygen helper][roxygen_helper] `"prefixes"` the selected code with documentation.
21-
#'
22-
#' @returns
23-
#' `NULL`, invisibly. Called for its side effect: a helper for chore `chore`
24-
#' is registered (or unregistered) with the chores package.
25-
#'
26-
#' @name helper_add_remove
27-
#' @export
1+
# Registering helpers
2+
#
3+
# @description
4+
# Users can create custom helpers using the `.helper_add()` function; after passing
5+
# the function a chore and prompt, the helper will be available in the
6+
# [chores addin][.init_addin].
7+
#
8+
# **Most users should not need to interact with these functions.**
9+
# [prompt_new()] and friends can be used to create prompts for new helpers, and
10+
# those helpers can be registered with chores using [directory_load()] and friends.
11+
# The helpers created by those functions will be persistent across sessions.
12+
#
13+
# @param chore A single string giving a descriptor of the helper's functionality.
14+
# Cand only contain letters and numbers.
15+
# @param prompt A single string giving the system prompt. In most cases, this
16+
# is a rather long string, containing several newlines.
17+
# @param interface One of `"replace"`, `"prefix"`, or `"suffix"`, describing
18+
# how the helper will interact with the selection. For example, the
19+
# [cli helper][cli_helper] `"replace"`s the selection, while the
20+
# [roxygen helper][roxygen_helper] `"prefixes"` the selected code with documentation.
21+
#
22+
# @returns
23+
# `NULL`, invisibly. Called for its side effect: a helper for chore `chore`
24+
# is registered (or unregistered) with the chores package.
25+
#
26+
# @name helper_add_remove
2827
.helper_add <- function(
2928
chore,
3029
prompt = NULL,
@@ -39,7 +38,7 @@
3938
invisible()
4039
}
4140

42-
#' @rdname helper_add_remove
41+
# @rdname helper_add_remove
4342
.helper_remove <- function(chore) {
4443
check_string(chore)
4544
if (!chore %in% list_helpers()) {

R/init-addin.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#' `NULL`, invisibly. Called for the side effect of launching the chores addin
1414
#' and interfacing with selected text.
1515
#'
16+
#' @examples
17+
#' if (interactive()) {
18+
#' .init_addin()
19+
#' }
1620
#' @export
1721
.init_addin <- function() {
1822
if (is.null(fetch_chores_chat())) {

R/init-helper.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99
#'
1010
#' @param chore The identifier for a helper prompt. By default one
1111
#' of `r glue::glue_collapse(paste0("[", glue::double_quote(default_chores), "]", "[", default_chores, "_helper", "]"), ", ", last = " or ")`,
12-
#' though custom helpers can be added with [.helper_add()].
12+
#' though custom helpers can be added with [prompt_new()].
1313
#' @param .chores_chat An ellmer Chat, e.g.
1414
#' `function() ellmer::chat_claude()`. Defaults to the option by the same name,
1515
#' so e.g. set `options(.chores_chat = ellmer::chat_claude())` in your
1616
#' `.Rprofile` to configure chores with ellmer every time you start a new R session.
1717
#'
18-
#' @examplesIf FALSE
18+
#' @returns
19+
#' A Helper object, which is a subclass of an ellmer chat.
20+
#'
21+
#' @examples
22+
#' # requires an API key and sets options
23+
#' \dontrun{
1924
#' # to create a chat with claude:
20-
#' .init_helper()
25+
#' .init_helper(.chores_chat = ellmer::chat_claude())
2126
#'
2227
#' # or with OpenAI's 4o-mini:
2328
#' .init_helper(.chores_chat = ellmer::chat_openai(model = "gpt-4o-mini"))
@@ -28,6 +33,7 @@
2833
#' options(
2934
#' .chores_chat = ellmer::chat_openai(model = "gpt-4o-mini")
3035
#' )
36+
#' }
3137
#' @export
3238
.init_helper <- function(
3339
chore = NULL,
@@ -37,7 +43,7 @@
3743
if (!chore %in% list_helpers()) {
3844
cli::cli_abort(c(
3945
"No helpers for chore {.arg {chore}} registered.",
40-
"i" = "See {.fn .helper_add}."
46+
"i" = "See {.fn prompt_new}."
4147
))
4248
}
4349

R/prompt.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
#' Load the prompts you create with these functions using [directory_load()]
1919
#' (which is automatically called when the package loads).
2020
#'
21-
#' @inheritParams helper_add_remove
21+
#' @param chore A single string giving a descriptor of the helper's functionality.
22+
#' Cand only contain letters and numbers.
23+
#' @param interface One of `"replace"`, `"prefix"`, or `"suffix"`, describing
24+
#' how the helper will interact with the selection. For example, the
25+
#' [cli helper][cli_helper] `"replace"`s the selection, while the
26+
#' [roxygen helper][roxygen_helper] `"prefixes"` the selected code with documentation.
2227
#' @param contents Optional. Path to a markdown file with contents that will
2328
#' "pre-fill" the file. Anything file ending in `.md` or `.markdown` that can be
2429
#' read with `readLines()` is fair game; this could be a local file, a "raw"
@@ -32,7 +37,8 @@
3237
#' Each `prompt_*()` function returns the file path to the created, edited, or
3338
#' removed filepath, invisibly.
3439
#'
35-
#' @examplesIf FALSE
40+
#' @examples
41+
#' if (interactive()) {
3642
#' # create a new helper for chore `"boop"` that replaces the selected text:
3743
#' prompt_new("boop")
3844
#'
@@ -66,7 +72,7 @@
6672
#' "58c9b4da/summarize-prefix.md"
6773
#' )
6874
#' )
69-
#'
75+
#' }
7076
#' @name prompt
7177

7278
#' @rdname prompt

R/zzz.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

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

9-
chores_dir <- getOption(".chores_dir", default = file.path("~", ".config", "chores"))
10-
if (dir.exists(chores_dir)) {
9+
chores_dir <- getOption(".chores_dir", default = NULL)
10+
if (!is.null(chores_dir) && dir.exists(chores_dir)) {
1111
directory_load(chores_dir)
1212
}
1313
}

0 commit comments

Comments
 (0)