agentperm 0.2.1__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentperm-0.4.0/PKG-INFO +267 -0
- agentperm-0.4.0/README.md +206 -0
- agentperm-0.4.0/docs/README.md +43 -0
- {agentperm-0.2.1 → agentperm-0.4.0}/pyproject.toml +10 -29
- agentperm-0.4.0/src/agentperm/__init__.py +128 -0
- agentperm-0.4.0/src/agentperm/adapters/__init__.py +55 -0
- agentperm-0.4.0/src/agentperm/adapters/apply_patch.py +64 -0
- agentperm-0.4.0/src/agentperm/adapters/base.py +381 -0
- agentperm-0.4.0/src/agentperm/adapters/claude.py +150 -0
- agentperm-0.4.0/src/agentperm/adapters/codex.py +189 -0
- agentperm-0.4.0/src/agentperm/adapters/gemini.py +112 -0
- agentperm-0.4.0/src/agentperm/adapters/kiro.py +392 -0
- agentperm-0.4.0/src/agentperm/adapters/opencode.py +221 -0
- agentperm-0.4.0/src/agentperm/cli.py +648 -0
- agentperm-0.4.0/src/agentperm/domain.py +844 -0
- agentperm-0.4.0/src/agentperm/errors.py +5 -0
- agentperm-0.4.0/src/agentperm/fileio.py +32 -0
- agentperm-0.4.0/src/agentperm/policy.py +428 -0
- agentperm-0.4.0/src/agentperm/pythoncode.py +308 -0
- agentperm-0.4.0/src/agentperm/rules.py +173 -0
- agentperm-0.4.0/src/agentperm/shell.py +778 -0
- agentperm-0.4.0/src/agentperm/shellpattern.py +695 -0
- agentperm-0.4.0/src/agentperm/templates/aws-read-only.jsonc +31 -0
- agentperm-0.4.0/src/agentperm/templates/docker-read-only.jsonc +14 -0
- agentperm-0.4.0/src/agentperm/templates/file-inspection.jsonc +26 -0
- agentperm-0.4.0/src/agentperm/templates/gh-read-only.jsonc +21 -0
- agentperm-0.4.0/src/agentperm/templates/git-read-only.jsonc +22 -0
- agentperm-0.4.0/src/agentperm/templates/packages-read-only.jsonc +24 -0
- agentperm-0.4.0/src/agentperm/templates/python-checks.jsonc +24 -0
- agentperm-0.4.0/src/agentperm/templates/safety-baseline.jsonc +29 -0
- agentperm-0.4.0/src/agentperm/validate.py +201 -0
- {agentperm-0.2.1 → agentperm-0.4.0}/tests/test_adapters.py +687 -28
- {agentperm-0.2.1 → agentperm-0.4.0}/tests/test_cli.py +106 -27
- agentperm-0.4.0/tests/test_opencode_guard.py +130 -0
- {agentperm-0.2.1 → agentperm-0.4.0}/tests/test_parser.py +155 -0
- agentperm-0.4.0/tests/test_policy.py +1550 -0
- agentperm-0.4.0/tests/test_pythoncode.py +185 -0
- agentperm-0.4.0/tests/test_semantic_file_adapters.py +146 -0
- agentperm-0.4.0/tests/test_shellpattern.py +1047 -0
- agentperm-0.4.0/tests/test_templates.py +235 -0
- agentperm-0.4.0/tests/test_validate.py +150 -0
- {agentperm-0.2.1 → agentperm-0.4.0}/zellij-plugin/README.md +16 -2
- agentperm-0.2.1/zellij-plugin/src/lib.rs → agentperm-0.4.0/zellij-plugin/src/main.rs +9 -0
- agentperm-0.2.1/PKG-INFO +0 -202
- agentperm-0.2.1/README.md +0 -143
- agentperm-0.2.1/src/agentperm/__init__.py +0 -2433
- agentperm-0.2.1/tests/test_policy.py +0 -743
- {agentperm-0.2.1 → agentperm-0.4.0}/.gitignore +0 -0
- {agentperm-0.2.1 → agentperm-0.4.0}/LICENSE +0 -0
- {agentperm-0.2.1 → agentperm-0.4.0}/tests/__init__.py +0 -0
agentperm-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agentperm
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Permission policy mediator for Claude Code, Codex, OpenCode, Gemini CLI, and Kiro.
|
|
5
|
+
Project-URL: Homepage, https://github.com/jacks0n/agentperm
|
|
6
|
+
Project-URL: Repository, https://github.com/jacks0n/agentperm
|
|
7
|
+
Project-URL: Documentation, https://github.com/jacks0n/agentperm/tree/main/docs
|
|
8
|
+
Project-URL: Changelog, https://github.com/jacks0n/agentperm/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/jacks0n/agentperm/issues
|
|
10
|
+
Author-email: Jackson Cooper <jackson@jacksonc.com>
|
|
11
|
+
License: MIT License
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2026 Jackson Cooper
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Keywords: ai-agents,claude-code,codex-cli,coding-agent,gemini-cli,hooks,kiro,llm,opencode,permissions,policy-engine,tree-sitter-bash
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Environment :: Console
|
|
36
|
+
Classifier: Intended Audience :: Developers
|
|
37
|
+
Classifier: Intended Audience :: System Administrators
|
|
38
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
39
|
+
Classifier: Operating System :: MacOS
|
|
40
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
41
|
+
Classifier: Programming Language :: Python :: 3
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
44
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
45
|
+
Classifier: Topic :: Security
|
|
46
|
+
Classifier: Topic :: Software Development
|
|
47
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
48
|
+
Classifier: Topic :: System :: Shells
|
|
49
|
+
Classifier: Topic :: System :: Systems Administration
|
|
50
|
+
Classifier: Typing :: Typed
|
|
51
|
+
Requires-Python: >=3.12
|
|
52
|
+
Requires-Dist: pyjson5<3,>=2.0
|
|
53
|
+
Requires-Dist: tomlkit<0.14,>=0.13
|
|
54
|
+
Requires-Dist: tree-sitter-bash<0.26,>=0.25
|
|
55
|
+
Requires-Dist: tree-sitter<0.26,>=0.25
|
|
56
|
+
Provides-Extra: dev
|
|
57
|
+
Requires-Dist: basedpyright>=1.13; extra == 'dev'
|
|
58
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
59
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
60
|
+
Description-Content-Type: text/markdown
|
|
61
|
+
|
|
62
|
+
# agentperm
|
|
63
|
+
|
|
64
|
+
**Stop approving the same safe command because a flag moved or it entered a pipe.**
|
|
65
|
+
|
|
66
|
+
agentperm gives [Claude Code](https://docs.anthropic.com/en/docs/claude-code),
|
|
67
|
+
[Codex CLI](https://github.com/openai/codex), [OpenCode](https://opencode.ai),
|
|
68
|
+
[Gemini CLI](https://github.com/google-gemini/gemini-cli), and [Kiro](https://kiro.dev) one local
|
|
69
|
+
permission policy. It parses shell programs, evaluates every command, and applies the strictest
|
|
70
|
+
result. You review intent once instead of maintaining five fragile string allowlists.
|
|
71
|
+
|
|
72
|
+
[](https://pypi.org/project/agentperm/)
|
|
73
|
+
[](https://pypi.org/project/agentperm/)
|
|
74
|
+
[](https://github.com/jacks0n/agentperm/actions/workflows/ci.yml)
|
|
75
|
+
[](https://github.com/jacks0n/agentperm/blob/main/LICENSE)
|
|
76
|
+
|
|
77
|
+
https://github.com/user-attachments/assets/9abcd24d-147c-4323-a1c3-970544e0d86a
|
|
78
|
+
|
|
79
|
+
[GIF fallback](https://raw.githubusercontent.com/jacks0n/agentperm/main/docs/media/demo.gif)
|
|
80
|
+
|
|
81
|
+
## One command, fully understood
|
|
82
|
+
|
|
83
|
+
This policy allows read-only AWS inspection, `jq`, and `git status`:
|
|
84
|
+
|
|
85
|
+
```jsonc
|
|
86
|
+
{
|
|
87
|
+
"version": 1,
|
|
88
|
+
"permissions": {
|
|
89
|
+
"allow": [
|
|
90
|
+
"Shell(aws values(--region, --profile) ec2 describe-* only(--region, --profile))",
|
|
91
|
+
"Shell(jq !-*)",
|
|
92
|
+
"Shell(git values(-C) status only(-C, --short))"
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Now an agent can run this without a prompt:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
bash -lc 'aws --profile dev ec2 describe-instances --region ap-southeast-2 | jq ".Reservations[]" && git -C . status --short'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
agentperm unwraps `bash -lc`, splits the pipe and `&&`, and checks `aws`, `jq`, and `git`
|
|
105
|
+
independently. Move `--profile` or `--region` before or after the AWS subcommand, or use
|
|
106
|
+
`--region=value`: the same reviewed rule still matches.
|
|
107
|
+
|
|
108
|
+
The rule does not become broad just because it is flexible. Add `--endpoint-url`, change
|
|
109
|
+
`describe-*` to a mutating operation, or insert an unknown pipeline stage and the compound prompts.
|
|
110
|
+
A deny anywhere denies the whole operation.
|
|
111
|
+
|
|
112
|
+
That structural evaluation is the difference: agentperm understands pipelines, command and process
|
|
113
|
+
substitutions, redirects, executable paths, quoting, supported wrappers, flag clusters, and declared
|
|
114
|
+
flag values. It matches normalized commands—not one opaque shell string.
|
|
115
|
+
|
|
116
|
+
## Try it
|
|
117
|
+
|
|
118
|
+
Requires Python 3.12+ on macOS or Linux.
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
uv tool install agentperm # or: pipx install agentperm
|
|
122
|
+
agentperm install --dry-run && agentperm install
|
|
123
|
+
agentperm init
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`install --dry-run` shows every hook file before anything changes. `init` builds
|
|
127
|
+
`~/.agent-permissions.jsonc` from conservative starter templates. Check a decision without running
|
|
128
|
+
an agent:
|
|
129
|
+
|
|
130
|
+
```console
|
|
131
|
+
$ agentperm why "git status | head -5"
|
|
132
|
+
allow — allow by rule 'Shell(git {status,log,diff,show,blame,shortlog,describe,reflog} values(-C))'
|
|
133
|
+
git status → allow (...)
|
|
134
|
+
head -5 → allow (...)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Then use your agent normally. Existing native settings stay in place and continue to participate in
|
|
138
|
+
the host's permission flow. See [Getting started](docs/getting-started.md) for installation modes,
|
|
139
|
+
starter policies, and the first safe customization.
|
|
140
|
+
|
|
141
|
+
## What one policy can express
|
|
142
|
+
|
|
143
|
+
- **Shell structure:** each command in pipes, chains, substitutions, control flow, and supported
|
|
144
|
+
wrappers is evaluated independently.
|
|
145
|
+
- **Useful permutations:** declare value-taking flags once; their order and `--flag=value` spelling
|
|
146
|
+
can vary without widening the rule.
|
|
147
|
+
- **Precise constraints:** alternate command paths, require or forbid flags, reject extra operands,
|
|
148
|
+
and allow only reviewed flags.
|
|
149
|
+
- **Semantic file controls:** write `Edit(src/**)` and `Write(dist/**)` once. Agent-specific edit,
|
|
150
|
+
write, notebook, and patch operations map to those capabilities.
|
|
151
|
+
- **Scoped tools:** match tools by name, prefix, URL domain, or normalized path, including cwd,
|
|
152
|
+
traversal, and existing symlinks.
|
|
153
|
+
- **Read-only inline Python:** `Python(readonly)` parses literal `python -c` and heredoc source with
|
|
154
|
+
Python's AST, allowing inspection while surfacing recognized mutations and dynamic effects.
|
|
155
|
+
- **Layered policy:** combine a global policy with directory policies. Global Deny is an immutable
|
|
156
|
+
floor; for Ask and Allow, the nearest matching policy wins, so a project can whitelist a global
|
|
157
|
+
prompt without weakening a deny.
|
|
158
|
+
- **Explainable decisions:** `why`, custom rule reasons, validation, and opt-in JSONL traces show why
|
|
159
|
+
a decision happened.
|
|
160
|
+
- **Portable setup:** install directly or through Rulesync, and import supported native policies.
|
|
161
|
+
|
|
162
|
+
The complete per-agent differences are in the [capability matrix](docs/capabilities.md).
|
|
163
|
+
|
|
164
|
+
## Rules in 60 seconds
|
|
165
|
+
|
|
166
|
+
Rules live in `permissions.allow`, `permissions.ask`, or `permissions.deny`:
|
|
167
|
+
|
|
168
|
+
```jsonc
|
|
169
|
+
{
|
|
170
|
+
"version": 1,
|
|
171
|
+
"permissions": {
|
|
172
|
+
"allow": [
|
|
173
|
+
"Shell(git {status,log,diff} !-*)",
|
|
174
|
+
"Shell(aws values(--region) s3 ls only(--region))",
|
|
175
|
+
"Read(src/**)",
|
|
176
|
+
"Python(readonly)"
|
|
177
|
+
],
|
|
178
|
+
"ask": [
|
|
179
|
+
"Shell(git push)"
|
|
180
|
+
],
|
|
181
|
+
"deny": [
|
|
182
|
+
{"Edit(generated/**)": {"reason": "Generated file; update its source instead."}},
|
|
183
|
+
{"Write(generated/**)": {"reason": "Generated file; update its source instead."}},
|
|
184
|
+
"Shell(git push --force)",
|
|
185
|
+
"Shell(sudo)"
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Useful Shell forms:
|
|
192
|
+
|
|
193
|
+
| Form | Meaning |
|
|
194
|
+
|---|---|
|
|
195
|
+
| `{status,log,diff}` | one of these command-path tokens |
|
|
196
|
+
| `describe-*` | glob within one token |
|
|
197
|
+
| `values(--region)` | `--region` consumes the following token |
|
|
198
|
+
| `only(--region, --profile)` | reject every other flag |
|
|
199
|
+
| `!--force` | reject this flag |
|
|
200
|
+
| `!-*` | reject every flag |
|
|
201
|
+
| `!...` | reject trailing operands |
|
|
202
|
+
|
|
203
|
+
Run `agentperm validate` after editing. The [policy reference](docs/policy-reference.md) covers the
|
|
204
|
+
whole file format; the [Shell pattern DSL](docs/pattern-dsl.md) is the exact grammar and matching
|
|
205
|
+
specification.
|
|
206
|
+
|
|
207
|
+
## How decisions compose
|
|
208
|
+
|
|
209
|
+
agentperm returns `allow`, `ask`, `deny`, or `no-opinion`. After policy-layer precedence selects a
|
|
210
|
+
verdict for each operation, the strictest result within a compound request wins:
|
|
211
|
+
|
|
212
|
+
```text
|
|
213
|
+
deny > ask > allow > no-opinion
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
An otherwise allowed pipeline with one unknown command becomes Ask. A multi-file patch with one
|
|
217
|
+
denied destination becomes Deny. `no-opinion` lets the host continue its native flow.
|
|
218
|
+
|
|
219
|
+
Policies load from `~/.agent-permissions.jsonc` and then from every directory between the filesystem
|
|
220
|
+
root and the command's working directory. Deny matches across every layer. For Ask and Allow, the
|
|
221
|
+
nearest policy with a matching rule wins; within one file, Ask precedes Allow. A cloned repository
|
|
222
|
+
can therefore bring its own allows, so review checked-in policy files like `.envrc` or
|
|
223
|
+
`.vscode/tasks.json`.
|
|
224
|
+
|
|
225
|
+
## Security boundary
|
|
226
|
+
|
|
227
|
+
agentperm is a **permission intent layer, not a sandbox**. It does not contain processes, prove what
|
|
228
|
+
an allowed program will do, or see execution paths a host does not send through hooks. Host bypass
|
|
229
|
+
mode can bypass agentperm entirely. Use OS isolation when containment matters and read
|
|
230
|
+
[SECURITY.md](SECURITY.md) before treating policies as a security control.
|
|
231
|
+
|
|
232
|
+
- It adds decisions to native permission flows; it does not replace host settings.
|
|
233
|
+
- It does not configure or isolate MCP servers.
|
|
234
|
+
- Directory policies are not trust-gated: a cloned repository can add allows and override global
|
|
235
|
+
Ask rules, though it cannot weaken any Deny.
|
|
236
|
+
- Shell and Python analysis classify reviewed intent; they do not prove program behavior.
|
|
237
|
+
|
|
238
|
+
Traces are also diagnostic—not a production audit system. They are off by default, may contain raw
|
|
239
|
+
commands and secrets, and have no built-in redaction, rotation, retention, or tamper protection.
|
|
240
|
+
See [CLI: diagnostic traces](docs/cli.md#diagnostic-traces).
|
|
241
|
+
|
|
242
|
+
There is no SQL syntax analyzer today. SQL clients can be constrained with Shell rules, but
|
|
243
|
+
agentperm does not distinguish `SELECT` from mutating SQL inside a query string.
|
|
244
|
+
|
|
245
|
+
## Zellij pane bypass
|
|
246
|
+
|
|
247
|
+
The bundled [Zellij plugin](zellij-plugin/) adds a per-pane “skip prompts” toggle. It turns Ask and
|
|
248
|
+
NoOpinion into Allow for that pane while preserving Deny, making it narrower than a host-wide
|
|
249
|
+
“dangerously skip permissions” mode.
|
|
250
|
+
|
|
251
|
+
## Documentation
|
|
252
|
+
|
|
253
|
+
- [Getting started](docs/getting-started.md) — install, initialize, and verify a policy.
|
|
254
|
+
- [Capability matrix](docs/capabilities.md) — exact coverage and behavior by agent.
|
|
255
|
+
- [Policy reference](docs/policy-reference.md) — schema, semantic tools, hierarchy, and redirects.
|
|
256
|
+
- [Shell pattern DSL](docs/pattern-dsl.md) — complete matching grammar and limitations.
|
|
257
|
+
- [CLI reference](docs/cli.md) — commands, hook installation, traces, and exit behavior.
|
|
258
|
+
- [Troubleshooting](docs/troubleshooting.md) — symptom-led diagnosis and fixes.
|
|
259
|
+
- [Architecture](docs/architecture.md) and [adapter notes](docs/adapters.md) — contributor internals.
|
|
260
|
+
- [Changelog](CHANGELOG.md) and [contributing guide](CONTRIBUTING.md) — releases and development.
|
|
261
|
+
|
|
262
|
+
`agentperm uninstall` removes only hooks written by agentperm; policy files remain yours. Then remove
|
|
263
|
+
the package with `uv tool uninstall agentperm` or `pipx uninstall agentperm`.
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
MIT
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# agentperm
|
|
2
|
+
|
|
3
|
+
**Stop approving the same safe command because a flag moved or it entered a pipe.**
|
|
4
|
+
|
|
5
|
+
agentperm gives [Claude Code](https://docs.anthropic.com/en/docs/claude-code),
|
|
6
|
+
[Codex CLI](https://github.com/openai/codex), [OpenCode](https://opencode.ai),
|
|
7
|
+
[Gemini CLI](https://github.com/google-gemini/gemini-cli), and [Kiro](https://kiro.dev) one local
|
|
8
|
+
permission policy. It parses shell programs, evaluates every command, and applies the strictest
|
|
9
|
+
result. You review intent once instead of maintaining five fragile string allowlists.
|
|
10
|
+
|
|
11
|
+
[](https://pypi.org/project/agentperm/)
|
|
12
|
+
[](https://pypi.org/project/agentperm/)
|
|
13
|
+
[](https://github.com/jacks0n/agentperm/actions/workflows/ci.yml)
|
|
14
|
+
[](https://github.com/jacks0n/agentperm/blob/main/LICENSE)
|
|
15
|
+
|
|
16
|
+
https://github.com/user-attachments/assets/9abcd24d-147c-4323-a1c3-970544e0d86a
|
|
17
|
+
|
|
18
|
+
[GIF fallback](https://raw.githubusercontent.com/jacks0n/agentperm/main/docs/media/demo.gif)
|
|
19
|
+
|
|
20
|
+
## One command, fully understood
|
|
21
|
+
|
|
22
|
+
This policy allows read-only AWS inspection, `jq`, and `git status`:
|
|
23
|
+
|
|
24
|
+
```jsonc
|
|
25
|
+
{
|
|
26
|
+
"version": 1,
|
|
27
|
+
"permissions": {
|
|
28
|
+
"allow": [
|
|
29
|
+
"Shell(aws values(--region, --profile) ec2 describe-* only(--region, --profile))",
|
|
30
|
+
"Shell(jq !-*)",
|
|
31
|
+
"Shell(git values(-C) status only(-C, --short))"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Now an agent can run this without a prompt:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
bash -lc 'aws --profile dev ec2 describe-instances --region ap-southeast-2 | jq ".Reservations[]" && git -C . status --short'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
agentperm unwraps `bash -lc`, splits the pipe and `&&`, and checks `aws`, `jq`, and `git`
|
|
44
|
+
independently. Move `--profile` or `--region` before or after the AWS subcommand, or use
|
|
45
|
+
`--region=value`: the same reviewed rule still matches.
|
|
46
|
+
|
|
47
|
+
The rule does not become broad just because it is flexible. Add `--endpoint-url`, change
|
|
48
|
+
`describe-*` to a mutating operation, or insert an unknown pipeline stage and the compound prompts.
|
|
49
|
+
A deny anywhere denies the whole operation.
|
|
50
|
+
|
|
51
|
+
That structural evaluation is the difference: agentperm understands pipelines, command and process
|
|
52
|
+
substitutions, redirects, executable paths, quoting, supported wrappers, flag clusters, and declared
|
|
53
|
+
flag values. It matches normalized commands—not one opaque shell string.
|
|
54
|
+
|
|
55
|
+
## Try it
|
|
56
|
+
|
|
57
|
+
Requires Python 3.12+ on macOS or Linux.
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
uv tool install agentperm # or: pipx install agentperm
|
|
61
|
+
agentperm install --dry-run && agentperm install
|
|
62
|
+
agentperm init
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`install --dry-run` shows every hook file before anything changes. `init` builds
|
|
66
|
+
`~/.agent-permissions.jsonc` from conservative starter templates. Check a decision without running
|
|
67
|
+
an agent:
|
|
68
|
+
|
|
69
|
+
```console
|
|
70
|
+
$ agentperm why "git status | head -5"
|
|
71
|
+
allow — allow by rule 'Shell(git {status,log,diff,show,blame,shortlog,describe,reflog} values(-C))'
|
|
72
|
+
git status → allow (...)
|
|
73
|
+
head -5 → allow (...)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Then use your agent normally. Existing native settings stay in place and continue to participate in
|
|
77
|
+
the host's permission flow. See [Getting started](docs/getting-started.md) for installation modes,
|
|
78
|
+
starter policies, and the first safe customization.
|
|
79
|
+
|
|
80
|
+
## What one policy can express
|
|
81
|
+
|
|
82
|
+
- **Shell structure:** each command in pipes, chains, substitutions, control flow, and supported
|
|
83
|
+
wrappers is evaluated independently.
|
|
84
|
+
- **Useful permutations:** declare value-taking flags once; their order and `--flag=value` spelling
|
|
85
|
+
can vary without widening the rule.
|
|
86
|
+
- **Precise constraints:** alternate command paths, require or forbid flags, reject extra operands,
|
|
87
|
+
and allow only reviewed flags.
|
|
88
|
+
- **Semantic file controls:** write `Edit(src/**)` and `Write(dist/**)` once. Agent-specific edit,
|
|
89
|
+
write, notebook, and patch operations map to those capabilities.
|
|
90
|
+
- **Scoped tools:** match tools by name, prefix, URL domain, or normalized path, including cwd,
|
|
91
|
+
traversal, and existing symlinks.
|
|
92
|
+
- **Read-only inline Python:** `Python(readonly)` parses literal `python -c` and heredoc source with
|
|
93
|
+
Python's AST, allowing inspection while surfacing recognized mutations and dynamic effects.
|
|
94
|
+
- **Layered policy:** combine a global policy with directory policies. Global Deny is an immutable
|
|
95
|
+
floor; for Ask and Allow, the nearest matching policy wins, so a project can whitelist a global
|
|
96
|
+
prompt without weakening a deny.
|
|
97
|
+
- **Explainable decisions:** `why`, custom rule reasons, validation, and opt-in JSONL traces show why
|
|
98
|
+
a decision happened.
|
|
99
|
+
- **Portable setup:** install directly or through Rulesync, and import supported native policies.
|
|
100
|
+
|
|
101
|
+
The complete per-agent differences are in the [capability matrix](docs/capabilities.md).
|
|
102
|
+
|
|
103
|
+
## Rules in 60 seconds
|
|
104
|
+
|
|
105
|
+
Rules live in `permissions.allow`, `permissions.ask`, or `permissions.deny`:
|
|
106
|
+
|
|
107
|
+
```jsonc
|
|
108
|
+
{
|
|
109
|
+
"version": 1,
|
|
110
|
+
"permissions": {
|
|
111
|
+
"allow": [
|
|
112
|
+
"Shell(git {status,log,diff} !-*)",
|
|
113
|
+
"Shell(aws values(--region) s3 ls only(--region))",
|
|
114
|
+
"Read(src/**)",
|
|
115
|
+
"Python(readonly)"
|
|
116
|
+
],
|
|
117
|
+
"ask": [
|
|
118
|
+
"Shell(git push)"
|
|
119
|
+
],
|
|
120
|
+
"deny": [
|
|
121
|
+
{"Edit(generated/**)": {"reason": "Generated file; update its source instead."}},
|
|
122
|
+
{"Write(generated/**)": {"reason": "Generated file; update its source instead."}},
|
|
123
|
+
"Shell(git push --force)",
|
|
124
|
+
"Shell(sudo)"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Useful Shell forms:
|
|
131
|
+
|
|
132
|
+
| Form | Meaning |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `{status,log,diff}` | one of these command-path tokens |
|
|
135
|
+
| `describe-*` | glob within one token |
|
|
136
|
+
| `values(--region)` | `--region` consumes the following token |
|
|
137
|
+
| `only(--region, --profile)` | reject every other flag |
|
|
138
|
+
| `!--force` | reject this flag |
|
|
139
|
+
| `!-*` | reject every flag |
|
|
140
|
+
| `!...` | reject trailing operands |
|
|
141
|
+
|
|
142
|
+
Run `agentperm validate` after editing. The [policy reference](docs/policy-reference.md) covers the
|
|
143
|
+
whole file format; the [Shell pattern DSL](docs/pattern-dsl.md) is the exact grammar and matching
|
|
144
|
+
specification.
|
|
145
|
+
|
|
146
|
+
## How decisions compose
|
|
147
|
+
|
|
148
|
+
agentperm returns `allow`, `ask`, `deny`, or `no-opinion`. After policy-layer precedence selects a
|
|
149
|
+
verdict for each operation, the strictest result within a compound request wins:
|
|
150
|
+
|
|
151
|
+
```text
|
|
152
|
+
deny > ask > allow > no-opinion
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
An otherwise allowed pipeline with one unknown command becomes Ask. A multi-file patch with one
|
|
156
|
+
denied destination becomes Deny. `no-opinion` lets the host continue its native flow.
|
|
157
|
+
|
|
158
|
+
Policies load from `~/.agent-permissions.jsonc` and then from every directory between the filesystem
|
|
159
|
+
root and the command's working directory. Deny matches across every layer. For Ask and Allow, the
|
|
160
|
+
nearest policy with a matching rule wins; within one file, Ask precedes Allow. A cloned repository
|
|
161
|
+
can therefore bring its own allows, so review checked-in policy files like `.envrc` or
|
|
162
|
+
`.vscode/tasks.json`.
|
|
163
|
+
|
|
164
|
+
## Security boundary
|
|
165
|
+
|
|
166
|
+
agentperm is a **permission intent layer, not a sandbox**. It does not contain processes, prove what
|
|
167
|
+
an allowed program will do, or see execution paths a host does not send through hooks. Host bypass
|
|
168
|
+
mode can bypass agentperm entirely. Use OS isolation when containment matters and read
|
|
169
|
+
[SECURITY.md](SECURITY.md) before treating policies as a security control.
|
|
170
|
+
|
|
171
|
+
- It adds decisions to native permission flows; it does not replace host settings.
|
|
172
|
+
- It does not configure or isolate MCP servers.
|
|
173
|
+
- Directory policies are not trust-gated: a cloned repository can add allows and override global
|
|
174
|
+
Ask rules, though it cannot weaken any Deny.
|
|
175
|
+
- Shell and Python analysis classify reviewed intent; they do not prove program behavior.
|
|
176
|
+
|
|
177
|
+
Traces are also diagnostic—not a production audit system. They are off by default, may contain raw
|
|
178
|
+
commands and secrets, and have no built-in redaction, rotation, retention, or tamper protection.
|
|
179
|
+
See [CLI: diagnostic traces](docs/cli.md#diagnostic-traces).
|
|
180
|
+
|
|
181
|
+
There is no SQL syntax analyzer today. SQL clients can be constrained with Shell rules, but
|
|
182
|
+
agentperm does not distinguish `SELECT` from mutating SQL inside a query string.
|
|
183
|
+
|
|
184
|
+
## Zellij pane bypass
|
|
185
|
+
|
|
186
|
+
The bundled [Zellij plugin](zellij-plugin/) adds a per-pane “skip prompts” toggle. It turns Ask and
|
|
187
|
+
NoOpinion into Allow for that pane while preserving Deny, making it narrower than a host-wide
|
|
188
|
+
“dangerously skip permissions” mode.
|
|
189
|
+
|
|
190
|
+
## Documentation
|
|
191
|
+
|
|
192
|
+
- [Getting started](docs/getting-started.md) — install, initialize, and verify a policy.
|
|
193
|
+
- [Capability matrix](docs/capabilities.md) — exact coverage and behavior by agent.
|
|
194
|
+
- [Policy reference](docs/policy-reference.md) — schema, semantic tools, hierarchy, and redirects.
|
|
195
|
+
- [Shell pattern DSL](docs/pattern-dsl.md) — complete matching grammar and limitations.
|
|
196
|
+
- [CLI reference](docs/cli.md) — commands, hook installation, traces, and exit behavior.
|
|
197
|
+
- [Troubleshooting](docs/troubleshooting.md) — symptom-led diagnosis and fixes.
|
|
198
|
+
- [Architecture](docs/architecture.md) and [adapter notes](docs/adapters.md) — contributor internals.
|
|
199
|
+
- [Changelog](CHANGELOG.md) and [contributing guide](CONTRIBUTING.md) — releases and development.
|
|
200
|
+
|
|
201
|
+
`agentperm uninstall` removes only hooks written by agentperm; policy files remain yours. Then remove
|
|
202
|
+
the package with `uv tool uninstall agentperm` or `pipx uninstall agentperm`.
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
MIT
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# agentperm documentation
|
|
2
|
+
|
|
3
|
+
Use this page to find the shortest path to the answer you need. The README explains why agentperm
|
|
4
|
+
exists; these docs separate tasks, exact behavior, and maintainer internals so each fact has one
|
|
5
|
+
authoritative home.
|
|
6
|
+
|
|
7
|
+
## I want to…
|
|
8
|
+
|
|
9
|
+
| Goal | Start here |
|
|
10
|
+
|---|---|
|
|
11
|
+
| Install agentperm and remove my first prompt | [Getting started](getting-started.md) |
|
|
12
|
+
| See what each supported agent can enforce | [Capability matrix](capabilities.md) |
|
|
13
|
+
| Write or organize a policy | [Policy reference](policy-reference.md) |
|
|
14
|
+
| Match flags, permutations, pipes, and wrappers | [Shell pattern DSL](pattern-dsl.md) |
|
|
15
|
+
| Understand a decision or inspect a trace | [`why`](cli.md#why) and [diagnostic traces](cli.md#diagnostic-traces) |
|
|
16
|
+
| Fix prompting, hook, policy, or parsing problems | [Troubleshooting](troubleshooting.md) |
|
|
17
|
+
| Assess the security boundary | [Security model](../SECURITY.md) |
|
|
18
|
+
| Understand or extend the implementation | [Architecture](architecture.md), then [adapter notes](adapters.md) |
|
|
19
|
+
|
|
20
|
+
## Reading layers
|
|
21
|
+
|
|
22
|
+
- **Evaluate and try:** [project README](../README.md) and [getting started](getting-started.md).
|
|
23
|
+
- **Operate:** [CLI reference](cli.md), [capability matrix](capabilities.md), and
|
|
24
|
+
[troubleshooting](troubleshooting.md).
|
|
25
|
+
- **Specify:** [policy reference](policy-reference.md) and [Shell pattern DSL](pattern-dsl.md).
|
|
26
|
+
- **Maintain:** [architecture](architecture.md), [adapter notes](adapters.md), and
|
|
27
|
+
[contributing](../CONTRIBUTING.md).
|
|
28
|
+
|
|
29
|
+
## Terminology
|
|
30
|
+
|
|
31
|
+
| Term | Meaning |
|
|
32
|
+
|---|---|
|
|
33
|
+
| **policy** | The merged global and directory `.agent-permissions.jsonc` files used for a request. |
|
|
34
|
+
| **rule** | One allow, ask, or deny entry: `Shell(...)`, legacy `Bash(...)`, a named/scoped tool, a structured Bash option rule, or `Python(readonly)`. |
|
|
35
|
+
| **segment** | One executable command extracted from shell source. `a | b && c` has three. |
|
|
36
|
+
| **request** | A shell operation, semantic tool operation, compound operation, or rejected operation produced by an adapter. |
|
|
37
|
+
| **verdict** | `allow`, `ask`, `deny`, or `no-opinion`, plus a rationale. |
|
|
38
|
+
|
|
39
|
+
## Documentation contract
|
|
40
|
+
|
|
41
|
+
Guides optimize for completing a task; references define exact behavior. When a guide and reference
|
|
42
|
+
appear to disagree, treat that as a documentation bug. Implementation tests and the Unreleased
|
|
43
|
+
changelog are checked during documentation updates so shipped behavior stays authoritative.
|
|
@@ -4,46 +4,25 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "agentperm"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "Permission policy mediator for Claude Code, Codex, OpenCode,
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
description = "Permission policy mediator for Claude Code, Codex, OpenCode, Gemini CLI, and Kiro."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
11
11
|
requires-python = ">=3.12"
|
|
12
12
|
authors = [{ name = "Jackson Cooper", email = "jackson@jacksonc.com" }]
|
|
13
13
|
keywords = [
|
|
14
|
-
"ai",
|
|
15
|
-
"ai-agent",
|
|
16
|
-
"ai-agents",
|
|
17
|
-
"ai-tools",
|
|
18
|
-
"agent",
|
|
19
|
-
"agentic",
|
|
20
|
-
"agentic-ai",
|
|
21
|
-
"agentic-tools",
|
|
22
|
-
"ai-coding-assistant",
|
|
23
|
-
"anthropic",
|
|
24
|
-
"tree-sitter",
|
|
25
|
-
"tree-sitter-bash",
|
|
26
|
-
"claude",
|
|
27
14
|
"claude-code",
|
|
28
|
-
"codex",
|
|
29
15
|
"codex-cli",
|
|
30
|
-
"coding-agent",
|
|
31
|
-
"coding-assistant",
|
|
32
|
-
"developer-tools",
|
|
33
|
-
"gemini",
|
|
34
16
|
"gemini-cli",
|
|
35
|
-
"hooks",
|
|
36
|
-
"llm",
|
|
37
|
-
"llm-agent",
|
|
38
|
-
"llm-tools",
|
|
39
|
-
"mcp",
|
|
40
|
-
"mediator",
|
|
41
17
|
"opencode",
|
|
42
|
-
"
|
|
18
|
+
"kiro",
|
|
19
|
+
"coding-agent",
|
|
20
|
+
"ai-agents",
|
|
43
21
|
"permissions",
|
|
44
|
-
"policy",
|
|
45
22
|
"policy-engine",
|
|
46
|
-
"
|
|
23
|
+
"hooks",
|
|
24
|
+
"tree-sitter-bash",
|
|
25
|
+
"llm",
|
|
47
26
|
]
|
|
48
27
|
classifiers = [
|
|
49
28
|
"Development Status :: 4 - Beta",
|
|
@@ -74,6 +53,8 @@ dependencies = [
|
|
|
74
53
|
[project.urls]
|
|
75
54
|
Homepage = "https://github.com/jacks0n/agentperm"
|
|
76
55
|
Repository = "https://github.com/jacks0n/agentperm"
|
|
56
|
+
Documentation = "https://github.com/jacks0n/agentperm/tree/main/docs"
|
|
57
|
+
Changelog = "https://github.com/jacks0n/agentperm/blob/main/CHANGELOG.md"
|
|
77
58
|
Issues = "https://github.com/jacks0n/agentperm/issues"
|
|
78
59
|
|
|
79
60
|
[project.scripts]
|