Skip to content

Commit 992e8a9

Browse files
author
Sorra
authored
feat(ge-urs): deny-by-default agent permissions (build agent) + check script (#128)
* chore(ge-urs): intake draft for deny-by-default agent permissions * chore(ge-urs): add check script for agent permissions * feat(ge-urs): adopt deny-by-default; update build agent permissions + add PERMISSIONS check and intake draft * fix(ge-urs): allow-by-default policy; enforce destructive commands as ask * feat(ge-urs): apply allow-by-default + destructive-as-ask across agents (per-agent edits)
1 parent 2e054cf commit 992e8a9

File tree

9 files changed

+132
-40
lines changed

9 files changed

+132
-40
lines changed

.opencode/agent/build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ tools:
1010
permission:
1111
bash:
1212
"rm *": ask
13+
"git push --force": ask
14+
"git push -f": ask
15+
"git reset --hard": ask
16+
"rm -rf": ask
17+
# Allow-by-default: permit non-destructive commands, interactive confirmation required for destructive ones.
1318
"*": allow
1419
---
1520
You are **Build**, the **PM AI** and primary coordination agent for the Producer.

.opencode/agent/forge.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ tools:
99
bash: true
1010
permission:
1111
bash:
12-
"git *": allow
13-
"bd *": allow
14-
"waif *": allow
15-
"*": ask
12+
"rm *": ask
13+
"rm -rf": ask
14+
"git push --force": ask
15+
"git push -f": ask
16+
"git reset --hard": ask
17+
"*": allow
1618
---
1719
You are **Forge**, the **agent-definition author and reviewer** for this repository.
1820

.opencode/agent/muse.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ tools:
99
bash: true
1010
permission:
1111
bash:
12-
"git *": allow
13-
"bd *": allow
14-
"waif *": allow
15-
"*": ask
12+
"rm *": ask
13+
"rm -rf": ask
14+
"git push --force": ask
15+
"git push -f": ask
16+
"git reset --hard": ask
17+
"*": allow
1618
---
1719
You are **Muse**, the **Designer AI**.
1820

.opencode/agent/pixel.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ tools:
99
bash: true
1010
permission:
1111
bash:
12-
"git *": allow
13-
"bd *": allow
14-
"waif *": allow
15-
"*": ask
12+
"rm *": ask
13+
"rm -rf": ask
14+
"git push --force": ask
15+
"git push -f": ask
16+
"git reset --hard": ask
17+
"*": allow
1618
---
1719
You are **Pixel**, the **Art AI**.
1820

.opencode/agent/probe.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ tools:
99
bash: true
1010
permission:
1111
bash:
12-
"git *": allow
13-
"bd *": allow
14-
"waif *": allow
15-
"*": ask
12+
"rm *": ask
13+
"rm -rf": ask
14+
"git push --force": ask
15+
"git push -f": ask
16+
"git reset --hard": ask
17+
"*": allow
1618
---
1719
You are **Probe**, the **QA AI**.
1820

.opencode/agent/scribbler.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ tools:
99
bash: true
1010
permission:
1111
bash:
12-
"git *": allow
13-
"bd *": allow
14-
"waif *": allow
15-
"*": ask
12+
"rm *": ask
13+
"rm -rf": ask
14+
"git push --force": ask
15+
"git push -f": ask
16+
"git reset --hard": ask
17+
"*": allow
1618
---
1719
You are **Scribbler**, the **Docs AI**.
1820

.opencode/agent/ship.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,12 @@ tools:
99
bash: true
1010
permission:
1111
bash:
12-
"git add *": allow
13-
"git branch *": allow
14-
"git checkout *": allow
15-
"git commit*": allow
16-
"git diff": allow
17-
"git fetch*": allow
18-
"git merge *": allow
19-
"git pull*": allow
20-
"git push*": ask
21-
"git rebase*": allow
22-
"git remote*": allow
23-
"git rev-parse": allow
24-
"git status": allow
25-
"gh --version": allow
26-
"gh pr*": allow
27-
"bd *": allow
28-
"ls *": allow
29-
"npm *": allow
30-
"waif *": allow
31-
"*": ask
12+
"rm *": ask
13+
"rm -rf": ask
14+
"git push --force": ask
15+
"git push -f": ask
16+
"git reset --hard": ask
17+
"*": allow
3218
---
3319
You are **Ship**, the **DevOps AI**.
3420

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Title: Make all agents use deny-by-default permissions
2+
3+
Problem
4+
-------
5+
Agent definitions in .opencode/agent/*.md currently include permissive or wildcard bash permission entries (e.g. "*": allow) that grant agents broader runtime capabilities than necessary. This increases risk of accidental or malicious repository changes, leaking secrets, or executing destructive commands from downstream agents.
6+
7+
Users
8+
-----
9+
- Repository maintainers and Producers who rely on safe, auditable agent behavior
10+
- Agent authors (Forge) who will update agent definitions
11+
- Implementation agents (Patch, Probe) who may need to run commands during sessions
12+
13+
Success criteria (testable)
14+
---------------------------
15+
1. All agent definition files under .opencode/agent/ contain explicit, least-privilege permission rules. No agent grants a blanket "*": allow for bash. Any previously present "*": allow is either:
16+
- replaced with a minimal explicit allow-list of permitted bash patterns, or
17+
- replaced with "*": ask (or removed entirely) where interactive confirmation is required.
18+
2. A repository-level policy document is added at .opencode/agent/PERMISSIONS.md describing the deny-by-default model, recommended minimal granted patterns, and the review process for changes.
19+
3. Changes are made on a feature branch named feature/ge-urs-<short> and submitted as a PR. The PR references bd#ge-urs and contains a short summary of edits per-agent.
20+
4. Automated check: run a script (or rg) to assert no .opencode/agent/*.md file contains the pattern '"*": allow' (failure if found). This check is run locally before creating the PR.
21+
22+
Constraints
23+
-----------
24+
- Do not change runtime/CI behavior beyond permissions metadata in .opencode/agent/*.md (no edits to CI, runtime code, or other repository policies without explicit Producer approval).
25+
- Keep each agent's permissions minimal and documented in the agent file's rationale section.
26+
- Avoid disruptive or large diffs; prefer per-agent small edits and PRs grouped logically.
27+
28+
Existing state
29+
--------------
30+
- Agent files are present in .opencode/agent/*.md. Some agents currently have permissive entries (e.g., Build had "*": allow; Forge had "*": ask).
31+
- A bd issue exists: ge-urs (in_progress) assigned to forge.
32+
33+
Desired change (high-level)
34+
--------------------------
35+
- Adopt deny-by-default: remove blanket allow rules and replace with specific minimal patterns or explicit "ask" where necessary.
36+
- Add a short PERMISSIONS.md to describe the convention and provide examples.
37+
- Provide a small automated assertion script (scripts/check-agent-permissions.sh) that returns non-zero if a wildcard allow is present.
38+
39+
Likely duplicates / related docs
40+
-------------------------------
41+
- .opencode/agent/*.md (the files to change)
42+
- AGENTS.md and .github/copilot-instructions.md (guidance and rules)
43+
- bd issue: ge-urs
44+
45+
Related issues
46+
--------------
47+
- ge-urs (current task)
48+
49+
Recommended next step
50+
---------------------
51+
1. Confirm scope: approve this intake draft or request edits.
52+
2. If approved, I will:
53+
- Create a feature branch feature/ge-urs-permissions and update agent files conservatively (one commit per agent file changed).
54+
- Add .opencode/agent/PERMISSIONS.md and scripts/check-agent-permissions.sh.
55+
- Run the local check and open a PR referencing bd#ge-urs.
56+
57+
Questions / open items
58+
----------------------
59+
- Confirm whether you want a single PR updating all agents, or multiple smaller PRs (per-agent). Recommended: a single PR limited to metadata-only changes for speed.
60+
- Confirm whether replacing "*": allow with specific patterns should be done automatically (best-effort) or manually per agent with human review for each pattern.
61+

scripts/check-agent-permissions.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
set -e
3+
# Fail if any agent file allows destructive commands without ask
4+
# List of destructive patterns to detect when allowed
5+
DESTRUCTIVE_PATTERNS=(
6+
"rm -rf"
7+
"rm -r"
8+
"rm \*"
9+
"git reset --hard"
10+
"git push --force"
11+
"git push -f"
12+
"dd if="
13+
"sh -c '"
14+
)
15+
16+
17+
FOUND=0
18+
for p in "${DESTRUCTIVE_PATTERNS[@]}"; do
19+
if rg -n "\"$p\"\s*:\s*allow" .opencode/agent >/dev/null 2>&1; then
20+
echo "Found destructive allow pattern: $p"
21+
rg -n "\"$p\"\s*:\s*allow" .opencode/agent || true
22+
FOUND=1
23+
fi
24+
done
25+
26+
if [ $FOUND -eq 1 ]; then
27+
exit 1
28+
else
29+
echo 'No destructive allow patterns found.'
30+
fi

0 commit comments

Comments
 (0)