Issue for this PR
Closes #64162
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
In Plan mode, worktree_create ran to completion while worktree_remove was refused with Permission denied: edit. The two tools mutate the same kind of state (a worktree directory plus .git/worktrees/ bookkeeping) but only worktree_remove carried the edit permission classification, so Plan's read-only policy never saw worktree_create.
This change gives worktree_create the same edit treatment worktree_remove already has:
options.permission: edit so the tool is filtered out of the catalog when edit is denied outright (as in Plan mode).
- A leaf-level
permission.assert({ action: edit, resources: [target.resource], ... }) in execute, since registration options only control whole-tool definition filtering — the call still executes the leaf policy (see src/tool/AGENTS.md). The resolved resource is the configured worktree parent directory joined with the requested name, matching where Worktree.create will place it.
The docs line that said the other worktree utilities request no permission action is updated to match.
session_move has a similar gap noted in the issue; I left it out to keep this PR small — happy to follow up if maintainers want it gated too.
How did you verify your code works?
Extended test/tool-opencode.test.ts: with edit denied, worktree_create returns the rejection feedback as a tool error and leaves nothing on disk; with edit allowed, the call creates the worktree and the assertion records { action: edit, resources: [<worktree dir>], save: [*] } (forward slashes on Windows, same as worktree_remove).
bun test test/tool-opencode.test.ts (3 pass) and bun run check pass locally on Windows.
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Added by the opencode bot (AI-generated).
Related: #61121