fix(opencode): deny bash in plan mode#33640
Open
Haohao-end wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #33526
Type of change
What does this PR do?
Plan mode is supposed to be read-only.
plan-mode.txtstates the agent "MUST NOT ... run any non-readonly tools (including changing configs or making commits)". But theplanagent's permission only denieseditandtask.general; it inheritsdefaults("*": "allow") for everything else, sobashstays allowed. That lets the model run write commands likegit add/git commitdirectly while planning — the behavior reported in #33526.This adds
bash: "deny"to theplanagent's permission. Exploration still works because it goes through theexploresubagent, which carries its ownbash: "allow". The plan agent keeps its read-only tools (read,grep,glob,list,webfetch,websearch), plan-file editing,question,plan_exit, andtask(subagents).How did you verify your code works?
bun typecheckinpackages/opencodepasses.bashis the permission key the shell tool uses (packages/opencode/src/tool/shell/id.ts, kept as"bash"for compatibility) and that permission resolution uses last-match (evaluateviafindLastover the merged ruleset), so the plan agent'sbash: "deny"— declared afterdefaults— wins overdefaults's"*": "allow".bash; theexploresubagent it dispatches still can, and the defaultbuildagent is unaffected.Checklist