Skip to contents

Lists the permission rules in effect, or adds and removes rules. A rule is tool or tool(spec): a path glob for read, write, edit, grep, find and ls (write(results/**), relative to the project root; ~/... for the home; //... for other absolute paths); for r, level<=n, fn:name,... (every flagged function covered), category:name,..., sh:<command glob> (r(sh:git status*)), sql:<keywords> (r(sql:select)) and secret:NAME (the only rule that pre-approves a guarded secret read); MCP tools by name (mcp__github__*). Deny rules win over ask rules, which win over allow rules. Allow rules never loosen plan mode and never pre-approve level-4 (critical or control) actions.

Usage

gptr_permissions(
  allow = NULL,
  ask = NULL,
  deny = NULL,
  remove = NULL,
  scope = c("session", "project", "user")
)

Arguments

allow, ask, deny

Character vectors of rules to add to that list, or NULL.

remove

Character vector of rules to remove from every list of scope, or NULL.

scope

One of "session", "project", "user".

Value

A gptr_permissions data frame with columns rule, list, scope and source; invisibly when rules were added or removed.

Details

Scopes: "session" is this R process; "project" is the user-level project file tools::R_user_dir("gptr", "config")/projects/<hash>.json, personal and never inside the project tree; "user" is the user settings file. The listing also shows the shared project rules of .gptr/settings.json (an untrusted project contributes only deny and ask rules) and the deny/ask rules of a legacy .gptr/settings.local.json in a trusted project.

Called from model code during a run, adding or removing rules needs the user's approval of that call; otherwise it signals gptr_error_permission.

Examples

gptr_permissions(allow = "r(level<=1)")
gptr_permissions()
#>   rule         source   list   scope
#> 1 r(level<=1)  process  allow  session
#> 
#> # 1 row
gptr_permissions(remove = "r(level<=1)")