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 push*); a glob ending in * also
matches the command alone, so r(sh:cat *) covers cat too; a glob matches the command as
written, in any case on macOS and Windows, so it misses options placed before a subcommand, as
in git -C dir push), sql:<keywords> (r(sql:select)) and secret:NAME (the only rule
that pre-approves a guarded secret read: an allow rule covers r code only when every call it
flags reads one of the named secrets by name, with Sys.getenv() or a shell's $NAME; it
covers a secret handed to a child through the env of peter$sh() or peter$script() only
when the same code reads that secret by name, while a deny or ask secret:NAME rule meets every
such hand-over); MCP tools by name (mcp__github__*). A tool name names a tool the model calls,
never a peter$ member, served or not: r(fn:peter$script) names peter$script() in r code.
Deny rules win over ask rules, which win over allow rules. Deny and ask
rules match any call that gptr_risk() flags, a read-only shell command included
(r(sh:cat *) denies peter$sh("cat notes.txt")); an R function it knows to be read-only,
such as readLines(), is not flagged, so fn: rules never match it. Allow rules
never loosen plan mode and never pre-approve level-4 (critical or control) actions. In auto and
yolo mode only an fn: rule that names the function, such as r(fn:system), lets system(),
system2(), shell(), shell.exec(), pipe(), processx::run() (r(fn:run)) or
data.table::fread(cmd =) run a command the code computes, which those modes otherwise refuse
(see gptr_security).
Usage
gptr_permissions(
allow = NULL,
ask = NULL,
deny = NULL,
remove = NULL,
scope = c("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 file
projects/<hash>.json in tools::R_user_dir("gptr", "config"), 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 an allowing permission
decision (a person's, in every mode but yolo; see gptr_security); otherwise it signals
gptr_error_permission.