Skip to main content

Module userconfig

Module userconfig 

Source
Expand description

safe-chains config: read and change ~/.config/safe-chains.toml without opening it.

The file decides what safe-chains approves, so changing it by hand is where things go wrong: a hand-written grant has let head ~/.ssh/id_rsa through. These operations change one rule at a time, keep the rest of the file exactly as it was, refuse anything a built-in rule protects, and refuse to write a file safe-chains could not load.

Nothing here approves itself. The classifier treats safe-chains config add, remove and grant like any other write (see commands/tools/safe-chains.toml), so a person approves each one, and the MCP server marks the same operations destructive.

Each operation reads the file afresh. The hook’s registry and grants are loaded once per process, which is right for a process that classifies one command and exits, and wrong for a long-lived MCP server, so the server runs these through the CLI rather than calling them in-process.

Enums§

Access
Which faces a grant opens.
EditError
What a config operation could not do. Every message says what was wrong, what would work instead, and that nothing changed.
Protected
Why a path cannot be granted from a command.
Step
Something the reader can do next, named the way the surface they are using spells it.

Constants§

SHOWN_PATH
Where the user config lives, written the way every message shows it.

Functions§

add_entry
Add an entry that approves command as it was written, at level (inert, safe-read, safe-write). Returns what to tell the person.
entry_level
The level an added entry gets, as the CLI spells it and as the file spells it.
grant
Grant access to path, merging with a grant already on that path.
grantable_path
path as safe-chains config grant would write it, or why that command would refuse it.
list
The listing, ready to print. Reads the files afresh every call.
remove_command
Remove the command entry named name.
remove_grant
Remove the grant on path.
runs_an_agent
Whether name runs an AI coding agent, which no entry may approve.
step
user_config_path
~/.config/safe-chains.toml under $HOME. The same rule as the loader: never XDG_CONFIG_HOME.