@jalaxy33/pi-permit0.3.0
Permission gate for pi: command, path and workspace rules
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-permit
A permission gate for pi. Every tool call gets one of three answers: run it, ask the user, or block it.
It looks at three things, in this order:
- Protected paths — file tools and bash paths are matched against path rules. A match blocks, or asks when the rule says
"action": "ask"; a block rule on the same path wins. - Writes outside the workspace — a write or delete outside the session
cwdasks first, unless the path is on the allow list. - Commands — each command in a bash string is matched against command rules. Text inside heredocs, quotes and comments is never matched.
Install
pi install npm:@jalaxy33/pi-permit
From the repository:
pi install git:github.com/jalaxy33/pi-permit
Then run /reload.
Keys
| Key | Action |
|---|---|
y / Enter |
allow once |
a |
allow this rule with these flags, this rule and operation, or this directory, for the rest of the session |
n / Esc / Ctrl+C |
deny; the turn continues |
s |
deny and stop the turn |
j / k / ↑ / ↓ · o |
scroll · expand the command view |
Without a UI the gate fails closed: a call that would ask is blocked instead.
Commands
| Command | Action |
|---|---|
/permit |
show the loaded rules, their sources, session grants and warnings |
/permit:reload |
re-read the config without restarting pi |
Configuration
Two files are yours to edit:
| File | Scope |
|---|---|
~/.pi/agent/permit.json |
all projects |
<project>/.pi/permit.json |
one project, only after the project is trusted |
{
"commands": {
"deny": [
{ "id": "db-reset", "program": "bunx", "args": ["reset"], "terminate": true }
],
"ask": [
{ "id": "db-migrate", "program": "bunx", "args": ["migrate"] }
],
"allow": [
// override default rules with the same ids
{ "id": "git-add", "program": "git", "args": ["add"] },
{ "id": "git-commit", "program": "git", "args": ["commit"] }
]
},
"paths": [
{ "id": "my-config", "patterns": ["config/prod*.yml"], "except": ["config/prod.example.yml"], "action": "ask" },
// the default action is "block"
{ "id": "my-migrations", "patterns": ["db/migrations/**"] },
// two way to set read-only files
{ "id": "my-fixtures", "patterns": ["test/fixtures/*.json"], "protection": "read-only" },
{ "id": "my-logs", "patterns": ["logs/*.log"], "ops": ["write", "delete"] },
// temporarily disable a path rule by setting `"enabled": false`
{ "id": "your-path-rule", "patterns": ["some-file"], "enabled": false }
],
"outsideCwd": { "allowPaths": ["~/work/shared/**"] }
}
Field-by-field reference and matching rules: docs/configuration.md.
Shipped rule sets
| Set | File | Contents |
|---|---|---|
deny |
policy/deny.json |
git history rewriting, reflog expire, gc --prune=now |
basic |
policy/basic.json |
rare but unrecoverable damage: rm -r, sudo, dd of=, mkfs*, wipefs, fdisk, shred, chmod -R 777, chown -R, privileged containers; plus .env and private key files |
strict |
policy/strict.json |
git workflow, rsync --delete, bulk deletes, truncate, databases, terraform/kubectl/helm, docker volumes, publishing |
For a quiet setup, turn off the strict set:
{ "defaultRules": ["-strict"] }
Limits
A guard, not a sandbox. It sees the command text and the paths in it, so anything a program resolves on its own is out of reach.
python -c "open('.env')"passes.- Shell aliases, functions and
evalare not expanded.sh -c '...'is followed, but a wrapper in front of a command (env,command,nice,nohup, …) is not unwrapped. - Reads outside the workspace are not gated: a path rule is the only check on what the agent may read.
- Symlinks are followed: a link inside the workspace that points outside is treated as outside, and a path rule matches the file the link resolves to.
Development
bun test
pi-tui, pi-coding-agent and ajv come from symlinks in node_modules/. The first two are peer dependencies that pi provides at runtime.
Similar extensions
@aliou/pi-guardrails: which inspires this plugin.