agentperm 0.1.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.
@@ -0,0 +1,16 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ .venv/
7
+ dist/
8
+ build/
9
+ .coverage
10
+ .python-version
11
+ .env
12
+ .claude/
13
+ .codex/
14
+ .gemini/
15
+ .opencode/
16
+ zellij-plugin/target/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jackson Cooper
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentperm
3
+ Version: 0.1.0
4
+ Summary: Permission policy mediator for Claude Code, Codex, OpenCode, and Gemini CLI.
5
+ Project-URL: Homepage, https://github.com/jacks0n/agentperm
6
+ Project-URL: Repository, https://github.com/jacks0n/agentperm
7
+ Project-URL: Issues, https://github.com/jacks0n/agentperm/issues
8
+ Author-email: Jackson Cooper <jackson@jacksonc.com>
9
+ License: MIT License
10
+
11
+ Copyright (c) 2026 Jackson Cooper
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Keywords: agent,agentic,agentic-ai,agentic-tools,ai,ai-agent,ai-agents,ai-coding-assistant,ai-tools,anthropic,claude,claude-code,codex,codex-cli,coding-agent,coding-assistant,developer-tools,gemini,gemini-cli,hooks,llm,llm-agent,llm-tools,mcp,mediator,openai,opencode,permissions,policy,policy-engine,shell,tree-sitter,tree-sitter-bash
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Environment :: Console
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: Intended Audience :: System Administrators
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Operating System :: MacOS
38
+ Classifier: Operating System :: POSIX :: Linux
39
+ Classifier: Programming Language :: Python :: 3
40
+ Classifier: Programming Language :: Python :: 3.12
41
+ Classifier: Programming Language :: Python :: 3.13
42
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
43
+ Classifier: Topic :: Security
44
+ Classifier: Topic :: Software Development
45
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
46
+ Classifier: Topic :: System :: Shells
47
+ Classifier: Topic :: System :: Systems Administration
48
+ Classifier: Typing :: Typed
49
+ Requires-Python: >=3.12
50
+ Requires-Dist: pyjson5<3,>=2.0
51
+ Requires-Dist: tomlkit<0.14,>=0.13
52
+ Requires-Dist: tree-sitter-bash<0.26,>=0.25
53
+ Requires-Dist: tree-sitter<0.26,>=0.25
54
+ Provides-Extra: dev
55
+ Requires-Dist: basedpyright>=1.13; extra == 'dev'
56
+ Requires-Dist: pytest>=8.0; extra == 'dev'
57
+ Requires-Dist: ruff>=0.6; extra == 'dev'
58
+ Description-Content-Type: text/markdown
59
+
60
+ # agentperm
61
+
62
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
63
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://www.python.org/downloads/)
64
+
65
+ One permission policy file for coding agents. Configure [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [Codex CLI](https://github.com/openai/codex), or [OpenCode](https://opencode.ai) to call the bridge from their hook systems, and they can all consult `~/.agent-permissions.jsonc` before tools run — so the same allow / ask / deny rules apply everywhere.
66
+
67
+ ## Why
68
+
69
+ Every agent ships its own permission system, and none of them parse compound shell commands the way a shell does. `cat foo 2>/dev/null | head -60` is two read-only segments separated by a pipe, but the native config typically can't reason about pipes, redirects, `&&`, `for ... do ... done`, or `bash -c "..."` — so it asks, every time. The bridge parses the command with the Tree-sitter Bash grammar, evaluates each executable segment against your policy, and returns a single decision.
70
+
71
+ It also gives you one source of truth instead of four, plus a richer rule grammar (e.g. "ask before `sed -i`, allow `sed` otherwise").
72
+
73
+ ## Install
74
+
75
+ ```sh
76
+ pipx install agentperm
77
+ # or
78
+ uv tool install agentperm
79
+ ```
80
+
81
+ Then:
82
+
83
+ ```sh
84
+ agentperm import # pulls existing native rules into ~/.agent-permissions.jsonc
85
+ agentperm install # wires the bridge into Claude Code, Codex, OpenCode, and Gemini hooks
86
+ agentperm edit # opens the policy in $EDITOR (creates a default if missing)
87
+ ```
88
+
89
+ `install` auto-detects whether you use [Rulesync](https://github.com/dyoshikawa/rulesync) — if `~/.rulesync/` exists, it merges hook entries into `~/.rulesync/hooks.json` and you re-run `rulesync` to materialise per-tool configs. Otherwise it writes per-tool configs (`~/.claude/settings.json`, `~/.codex/hooks.json`+`config.toml`, `~/.gemini/settings.json`) directly. The OpenCode plugin shim is always installed at `~/.config/opencode/plugins/agentperm.js` because rulesync has no schema for `permission.ask` plugins. Pass `--mode rulesync|direct` to override detection or `--dry-run` to preview.
90
+
91
+ Per-project overrides live in `<project>/.agent-permissions.jsonc` — both files merge at decision time, deny wins.
92
+
93
+ ## Quickstart
94
+
95
+ ```jsonc
96
+ {
97
+ "version": 1,
98
+ "permissions": {
99
+ "allow": [
100
+ "Bash(git status:*)",
101
+ "Bash(ls:*)",
102
+ "Bash(cat:*)",
103
+ "Read",
104
+ "Grep",
105
+ "WebFetch(domain:github.com)"
106
+ ],
107
+ "ask": [
108
+ {
109
+ "tool": "Bash",
110
+ "command": ["sed", "gsed"],
111
+ "when": { "hasOption": ["-i", "--in-place"] },
112
+ "reason": "sed in-place editing changes files"
113
+ }
114
+ ],
115
+ "deny": [
116
+ "Bash(sudo:*)",
117
+ "Bash(rm -rf /*)"
118
+ ]
119
+ }
120
+ }
121
+ ```
122
+
123
+ A compound like `cat foo 2>&1 | head -60` passes through silently with the policy above — every segment matches an allow rule, the redirect is a safe `2>&1` fd-dup, and the bridge returns `allow`.
124
+
125
+ `sed -i s/foo/bar/ x.txt` surfaces a prompt with the rationale `"sed in-place editing changes files"` — the `ask` rule beats the `allow` rule on `sed`.
126
+
127
+ `rm -rf /tmp/*` is denied without prompting.
128
+
129
+ ## Bypass mode (zellij)
130
+
131
+ A per-pane "skip prompts" toggle for users running their agents inside [zellij](https://zellij.dev). Bind a key to flip a flag file for the focused pane; while the flag is on, `agentperm` coerces `Ask` and `NoOpinion` verdicts to `Allow` — but only in that pane, and `Deny` rules still bite. (Claude's own `bypassPermissions` is different: there agentperm defers entirely and lets Claude handle everything.) The toggle and indicator live in a small WASM plugin shipped at [`zellij-plugin/`](zellij-plugin/README.md).
132
+
133
+ ## Documentation
134
+
135
+ - [Architecture](docs/architecture.md) — domain model, AST parsing, aggregation, bypass coercion
136
+ - [Policy reference](docs/policy-reference.md) — full grammar of `.agent-permissions.jsonc`
137
+ - [CLI reference](docs/cli.md) — `install`, `import`, `check`, `edit`, pane bypass
138
+ - [Adapter notes](docs/adapters.md) — agent-specific behavior and limits
139
+ - [Troubleshooting](docs/troubleshooting.md) — diagnosing prompts, the trace env var, common pitfalls
140
+ - [zellij plugin](zellij-plugin/README.md) — per-pane bypass toggle and indicator
141
+ - [Contributing](CONTRIBUTING.md) — dev setup, tests, PR conventions
142
+ - [Changelog](CHANGELOG.md)
143
+
144
+ ## What it doesn't do
145
+
146
+ - **Manage MCP servers** — use Rulesync, native agent config, or your own dotfile tooling.
147
+ - **Replace native permission settings** — those keep working as fast paths. The bridge layers on top.
148
+ - **Sandbox commands** — the bridge is a policy engine, not an enforcement engine. Commands the agent decides to run still run with your shell's privileges.
149
+
150
+ ## License
151
+
152
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,93 @@
1
+ # agentperm
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
4
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://www.python.org/downloads/)
5
+
6
+ One permission policy file for coding agents. Configure [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [Codex CLI](https://github.com/openai/codex), or [OpenCode](https://opencode.ai) to call the bridge from their hook systems, and they can all consult `~/.agent-permissions.jsonc` before tools run — so the same allow / ask / deny rules apply everywhere.
7
+
8
+ ## Why
9
+
10
+ Every agent ships its own permission system, and none of them parse compound shell commands the way a shell does. `cat foo 2>/dev/null | head -60` is two read-only segments separated by a pipe, but the native config typically can't reason about pipes, redirects, `&&`, `for ... do ... done`, or `bash -c "..."` — so it asks, every time. The bridge parses the command with the Tree-sitter Bash grammar, evaluates each executable segment against your policy, and returns a single decision.
11
+
12
+ It also gives you one source of truth instead of four, plus a richer rule grammar (e.g. "ask before `sed -i`, allow `sed` otherwise").
13
+
14
+ ## Install
15
+
16
+ ```sh
17
+ pipx install agentperm
18
+ # or
19
+ uv tool install agentperm
20
+ ```
21
+
22
+ Then:
23
+
24
+ ```sh
25
+ agentperm import # pulls existing native rules into ~/.agent-permissions.jsonc
26
+ agentperm install # wires the bridge into Claude Code, Codex, OpenCode, and Gemini hooks
27
+ agentperm edit # opens the policy in $EDITOR (creates a default if missing)
28
+ ```
29
+
30
+ `install` auto-detects whether you use [Rulesync](https://github.com/dyoshikawa/rulesync) — if `~/.rulesync/` exists, it merges hook entries into `~/.rulesync/hooks.json` and you re-run `rulesync` to materialise per-tool configs. Otherwise it writes per-tool configs (`~/.claude/settings.json`, `~/.codex/hooks.json`+`config.toml`, `~/.gemini/settings.json`) directly. The OpenCode plugin shim is always installed at `~/.config/opencode/plugins/agentperm.js` because rulesync has no schema for `permission.ask` plugins. Pass `--mode rulesync|direct` to override detection or `--dry-run` to preview.
31
+
32
+ Per-project overrides live in `<project>/.agent-permissions.jsonc` — both files merge at decision time, deny wins.
33
+
34
+ ## Quickstart
35
+
36
+ ```jsonc
37
+ {
38
+ "version": 1,
39
+ "permissions": {
40
+ "allow": [
41
+ "Bash(git status:*)",
42
+ "Bash(ls:*)",
43
+ "Bash(cat:*)",
44
+ "Read",
45
+ "Grep",
46
+ "WebFetch(domain:github.com)"
47
+ ],
48
+ "ask": [
49
+ {
50
+ "tool": "Bash",
51
+ "command": ["sed", "gsed"],
52
+ "when": { "hasOption": ["-i", "--in-place"] },
53
+ "reason": "sed in-place editing changes files"
54
+ }
55
+ ],
56
+ "deny": [
57
+ "Bash(sudo:*)",
58
+ "Bash(rm -rf /*)"
59
+ ]
60
+ }
61
+ }
62
+ ```
63
+
64
+ A compound like `cat foo 2>&1 | head -60` passes through silently with the policy above — every segment matches an allow rule, the redirect is a safe `2>&1` fd-dup, and the bridge returns `allow`.
65
+
66
+ `sed -i s/foo/bar/ x.txt` surfaces a prompt with the rationale `"sed in-place editing changes files"` — the `ask` rule beats the `allow` rule on `sed`.
67
+
68
+ `rm -rf /tmp/*` is denied without prompting.
69
+
70
+ ## Bypass mode (zellij)
71
+
72
+ A per-pane "skip prompts" toggle for users running their agents inside [zellij](https://zellij.dev). Bind a key to flip a flag file for the focused pane; while the flag is on, `agentperm` coerces `Ask` and `NoOpinion` verdicts to `Allow` — but only in that pane, and `Deny` rules still bite. (Claude's own `bypassPermissions` is different: there agentperm defers entirely and lets Claude handle everything.) The toggle and indicator live in a small WASM plugin shipped at [`zellij-plugin/`](zellij-plugin/README.md).
73
+
74
+ ## Documentation
75
+
76
+ - [Architecture](docs/architecture.md) — domain model, AST parsing, aggregation, bypass coercion
77
+ - [Policy reference](docs/policy-reference.md) — full grammar of `.agent-permissions.jsonc`
78
+ - [CLI reference](docs/cli.md) — `install`, `import`, `check`, `edit`, pane bypass
79
+ - [Adapter notes](docs/adapters.md) — agent-specific behavior and limits
80
+ - [Troubleshooting](docs/troubleshooting.md) — diagnosing prompts, the trace env var, common pitfalls
81
+ - [zellij plugin](zellij-plugin/README.md) — per-pane bypass toggle and indicator
82
+ - [Contributing](CONTRIBUTING.md) — dev setup, tests, PR conventions
83
+ - [Changelog](CHANGELOG.md)
84
+
85
+ ## What it doesn't do
86
+
87
+ - **Manage MCP servers** — use Rulesync, native agent config, or your own dotfile tooling.
88
+ - **Replace native permission settings** — those keep working as fast paths. The bridge layers on top.
89
+ - **Sandbox commands** — the bridge is a policy engine, not an enforcement engine. Commands the agent decides to run still run with your shell's privileges.
90
+
91
+ ## License
92
+
93
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,115 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "agentperm"
7
+ version = "0.1.0"
8
+ description = "Permission policy mediator for Claude Code, Codex, OpenCode, and Gemini CLI."
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ requires-python = ">=3.12"
12
+ authors = [{ name = "Jackson Cooper", email = "jackson@jacksonc.com" }]
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
+ "claude-code",
28
+ "codex",
29
+ "codex-cli",
30
+ "coding-agent",
31
+ "coding-assistant",
32
+ "developer-tools",
33
+ "gemini",
34
+ "gemini-cli",
35
+ "hooks",
36
+ "llm",
37
+ "llm-agent",
38
+ "llm-tools",
39
+ "mcp",
40
+ "mediator",
41
+ "opencode",
42
+ "openai",
43
+ "permissions",
44
+ "policy",
45
+ "policy-engine",
46
+ "shell",
47
+ ]
48
+ classifiers = [
49
+ "Development Status :: 4 - Beta",
50
+ "Environment :: Console",
51
+ "Intended Audience :: Developers",
52
+ "Intended Audience :: System Administrators",
53
+ "License :: OSI Approved :: MIT License",
54
+ "Operating System :: MacOS",
55
+ "Operating System :: POSIX :: Linux",
56
+ "Programming Language :: Python :: 3",
57
+ "Programming Language :: Python :: 3.12",
58
+ "Programming Language :: Python :: 3.13",
59
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
60
+ "Topic :: Security",
61
+ "Topic :: Software Development",
62
+ "Topic :: Software Development :: Libraries :: Python Modules",
63
+ "Topic :: System :: Shells",
64
+ "Topic :: System :: Systems Administration",
65
+ "Typing :: Typed",
66
+ ]
67
+ dependencies = [
68
+ "pyjson5>=2.0,<3",
69
+ "tomlkit>=0.13,<0.14",
70
+ "tree-sitter>=0.25,<0.26",
71
+ "tree-sitter-bash>=0.25,<0.26",
72
+ ]
73
+
74
+ [project.urls]
75
+ Homepage = "https://github.com/jacks0n/agentperm"
76
+ Repository = "https://github.com/jacks0n/agentperm"
77
+ Issues = "https://github.com/jacks0n/agentperm/issues"
78
+
79
+ [project.scripts]
80
+ agentperm = "agentperm:main"
81
+
82
+ [project.optional-dependencies]
83
+ dev = [
84
+ "pytest>=8.0",
85
+ "ruff>=0.6",
86
+ "basedpyright>=1.13",
87
+ ]
88
+
89
+ [tool.hatch.build.targets.wheel]
90
+ packages = ["src/agentperm"]
91
+
92
+ [tool.hatch.build.targets.sdist]
93
+ include = ["src/", "tests/", "README.md", "LICENSE", "pyproject.toml"]
94
+
95
+ [tool.ruff]
96
+ line-length = 120
97
+ target-version = "py312"
98
+
99
+ [tool.ruff.lint]
100
+ select = ["E", "F", "I", "N", "UP", "B", "SIM", "RUF"]
101
+
102
+ [tool.basedpyright]
103
+ include = ["src", "tests"]
104
+ pythonVersion = "3.12"
105
+ typeCheckingMode = "strict"
106
+ # tree-sitter-bash stubs are partial. We narrow at the parser boundary so domain
107
+ # code never sees Unknown.
108
+ reportMissingTypeStubs = false
109
+ reportUnknownMemberType = false
110
+ reportUnknownVariableType = false
111
+ reportUnknownArgumentType = false
112
+
113
+ [tool.pytest.ini_options]
114
+ testpaths = ["tests"]
115
+ addopts = "-ra"