fix(opencode): enforce read-only bash permissions in plan mode#24110
fix(opencode): enforce read-only bash permissions in plan mode#24110kzekiue wants to merge 2 commits intoanomalyco:devfrom
Conversation
…24102-plan-mode-bash-allowlist
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found a related PR that may be relevant: Related PR:
The other results are related to permissions and bash command handling but appear to be either older historical changes or addressing different aspects (like sandboxing, auto-approval, and subagent restrictions). The most relevant connection is with PR #23985, which is also addressing plan mode tool permissions, though it focuses on allowing specific CLI tools rather than restricting bash commands. |
Issue for this PR
Closes #24102
Type of change
What does this PR do?
Plan mode could still run mutating bash commands because it inherited the default broad tool permissions and only denied edit tools.
This PR makes the native plan agent enforce bash as read-only by default. It denies bash commands unless they match a small allowlist of inspection commands such as git status, git log, git diff, git show, git branch, git stash list, ls, cat, grep, rg, find, wc, head, and tail.
It also adds Agent.permissions(...) so plan-mode rules remain authoritative when session-level permissions are merged in. That prevents session/config permissions from re-allowing mutating commands in plan mode while preserving the existing merge behavior for other agents.
How did you verify your code works?
The session tests were run outside the sandbox because their local HTTP test servers could not bind ephemeral ports inside it.
Screenshots / recordings
Not a UI change.
Checklist