Skip to content

Isolated worktrees for write-capable /opencode:rescue #34

Closed

Description

@JohnnyVicious

Summary

Write-capable /opencode:rescue tasks currently operate directly in the user's current working tree. This can interleave OpenCode edits with the user's own uncommitted changes or with concurrent Claude Code edits.

There is an existing local issue about a worktree cleanup hang when a Claude subagent is itself isolated in a worktree (#16). This issue is separate: it tracks plugin-managed worktree isolation as a feature for safer write-capable OpenCode tasks.

Motivation

A plugin-managed worktree would help with:

  • protecting user WIP from OpenCode edits
  • allowing Claude and OpenCode to work concurrently without racing on the same files
  • reviewing OpenCode's diff before applying it to the main tree
  • discarding unwanted OpenCode changes cheaply

Proposed UX

Examples:

/opencode:rescue --worktree fix the failing parser tests
/opencode:rescue --background --worktree implement the migration script

Potential default: use worktree isolation automatically for background write-capable tasks.

Implementation sketch

  1. Create a temporary branch/worktree under a plugin-owned directory.
  2. Run opencode-companion task --write with cwd set to that worktree.
  3. On completion, store the worktree path, branch name, and diff in job data.
  4. Add follow-up commands or result guidance to apply, merge, or discard the changes.
  5. Ensure background workers do not run in Claude-managed worktrees that can be deleted before OpenCode finishes.

Upstream reference

Derived from openai/codex-plugin-cc#135.

Activity

  1. changed the title [-]Feature: isolate write-capable /opencode:rescue tasks in git worktrees[/-] [+]Isolated worktrees for write-capable /opencode:rescue[/+] on Apr 12, 2026
  2. JohnnyVicious commented on Apr 12, 2026

    @JohnnyVicious
    OwnerAuthor

    Consolidating #43 here. The canonical scope is plugin-managed worktree isolation for write-capable rescue tasks, including the --worktree UX and background-safe lifecycle handling.

  3. JohnnyVicious commented on Apr 12, 2026

    @JohnnyVicious
    OwnerAuthor

    Fixed by PR #51 commit 23f7fef — --worktree flag creates disposable .worktrees/opencode- on a fresh opencode/ branch; handleTaskWorker parses and forwards it; worktree-cleanup subcommand supports keep/discard with patch preservation on failure.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions