GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): require edit permission for worktree_create by jadelike-wine · Pull Request #66859 · anomalyco/opencode

Conversation

@jadelike-wine

@jadelike-wine jadelike-wine commented Nov 27, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jadelike-wine
fix(core): require edit permission for worktree_create
8a07816
opencodejr[bot]
opencodejr Bot reviewed Nov 27, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as described. I ran OpenCode from source with the simulated model in Plan mode, and the model called worktree_create and then worktree_remove from Code Mode. On the base branch the worktree was created and only the removal was refused. With this PR both calls fail with Permission denied: edit and nothing is created. The updated test/tool-opencode.test.ts passes here and fails on the base branch, and tsc -b tsconfig.json tsconfig.tests.json passes. The package's typecheck script stops with "Script not found check" on the base branch as well, so I ran tsc directly.

Public API: nothing changes in the SDK, the HTTP API, config or CLI. The behaviour change is that worktree_create now goes through the edit permission on <worktree parent>/<name>, so users with edit set to ask or deny will be prompted or blocked when creating worktrees, as the updated docs say.

I have no blocking concerns. The permission check follows the same pattern as worktree_remove.

Related: #61121

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

plan mode: worktree_create bypasses read-only restriction

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@jadelike-wine
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.