Package {codriver}


Title: Context-Aware AI Assistant for 'RStudio'
Version: 1.1.0
Description: A context-aware AI assistant for 'RStudio' that works directly in the source editor without switching context or opening a separate chat window. Reads the cursor position and selection to automatically choose the right action - generate, complete, continue, edit, or comment. Results are presented as ghost text or an in-place diff suggestion. Supports configuration of multiple large language model providers and can be invoked via the keyboard shortcut or Addins menu.
URL: https://vdwulp.github.io/codriver/
BugReports: https://github.com/vdwulp/codriver/issues
License: MIT + file LICENSE
Encoding: UTF-8
Language: en-US
Config/roxygen2/version: 8.1.0
Config/roxygen2/markdown: TRUE
Config/testthat/edition: 3
VignetteBuilder: knitr
SystemRequirements: RStudio (>= 2026.04, https://posit.co/download/rstudio-desktop/)
Depends: R (≥ 4.0.0)
Imports: cli, ellmer (≥ 0.3.0), jsonlite, rlang, rstudio.prefs (≥ 0.1.6), rstudioapi (≥ 0.19.0)
Suggests: testthat (≥ 3.0.0), glue, knitr, rmarkdown, spelling, tibble, withr
NeedsCompilation: no
Packaged: 2026-10-18 14:33:25 UTC; wulps
Author: S.A. van der Wulp [aut, cre, cph]
Maintainer: S.A. van der Wulp <vdwulp@gmail.com>
Repository: CRAN
Date/Publication: 2026-10-18 14:50:02 UTC

Context-aware AI assistant for RStudio

Description

Inspects the current editor context — cursor position and any selection — and automatically chooses and executes one of five modes: complete, continue, generate, edit, or comment. Results are presented as ghost text or an edit suggestion directly in the source editor.

Usage

codriver()

Details

Codriver is intended to be invoked via a keyboard shortcut Ctrl+/ (default) or the RStudio Addins menu, not called directly. Use codriver_configure() to set up a provider and register the recommended shortcut before first use.

Value

Returns TRUE invisibly on success. Returns FALSE invisibly if RStudio is not available, no configuration is found, or the mode cannot be resolved.

See Also


Configure codriver

Description

Set up the AI provider that codriver uses to generate and edit R code and comments. The configuration is saved locally and validated immediately by making a test call to the provider.

Usage

codriver_configure(name, ...)

Arguments

name

Character. Provider name passed to ellmer::chat(), in the form "provider" or "provider/model". Supported providers are listed on https://ellmer.tidyverse.org/index.html#providers.

...

Named arguments passed to the ellmer constructor, such as model or base_url.

Details

Pass any arguments supported by the underlying ellmer::chat() constructor directly via name and ....

If no keyboard shortcut is registered for codriver, the function offers to register the default shortcut ⁠Ctrl+/⁠. Shortcut registration is strongly recommended but can be skipped or changed later via Tools > ⁠Modify Keyboard Shortcuts⁠ in RStudio.

Value

Returns TRUE invisibly on successful provider configuration. Returns FALSE invisibly if RStudio is not available or provider validation fails.

See Also

Examples

## Not run: 
  codriver_configure("openai",
                     model = "gpt-4o")
  codriver_configure("openai_compatible/mistral",
                     base_url = "http://localhost:1234/v1")

## End(Not run)


Collect codriver diagnostic information

Description

Collects the current package version, active configuration, and R/RStudio environment details.

Usage

codriver_info()

Value

A codriver_info object: a named list with elements version, configuration, and environment (a named list with r, rstudio, rstudioapi, and ellmer).


Inspect the most recent codriver request

Description

Returns the prompts and raw assistant response recorded for the most recent codriver request in the current R session.

Usage

codriver_last_request()

Value

A codriver_last_request object or NULL if no request has been recorded. The object is a named list that may contain:

system_prompt

The system prompt used for the request.

user_prompt

The user prompt sent to the language model.

assistant_response

The raw response returned by the language model.