Skip to content

fix: opencode 2.0.19+ support (team_spawn, worktrees, teammate edits, read-only agents) - #46

Open
zudsniper wants to merge 2 commits into
hueyexe:mainfrom
zudsniper:fix/opencode-2.0.24
Open

zudsniper wants to merge 2 commits into
hueyexe:mainfrom
zudsniper:fix/opencode-2.0.24

Conversation

@zudsniper

@zudsniper zudsniper commented Oct 17, 2026 •

Copy link
Copy Markdown

fixes the team_spawn crash + silent worktree failure from #40 on opencode 2.0.19+, plus the stuff that still stops teammates from working after that.

vs #41 / #43

both guard ctx.permission.rules, #41 also validates depends_on. this does both, plus:

▸ worktree root cause: #41 adds a warning but couldn't find why worktree.create made nothing. 2.0.19+ worktree endpoints need a projectID. ensemble never sent one → creation failed → everyone shared the base tree. now passes ctx.location.project.id to create/list/remove/refresh

▸ detached worktrees (2.0.32+): opencode now does git worktree add --detach (packages/core/src/git.ts). teammate commits land on a detached HEAD → team_merge: "not something we can merge". if the new worktree has no branch, ensemble creates it

▸ edits stuck on approval: v2 checks in-location files as relative paths, so edit <worktree>/** allow never matched → ask nobody answers. worktree teammates also get edit * allow. outside-the-worktree stays behind external_directory

▸ read-only detection: was name-only (plan, explore). custom reviewers got a worktree + shell * allow. now reads the agent's own rules via agent.get, names as fallback

not touched: the 4th #40 thing (notifications redelivered after purge).

on permission.rules: since 2.0.19 core merges session rules after agent rules (merge(agent, session), last match wins), so the session.create permissions already win. skipping rules() when it's gone loses nothing.

verification

✓ bun run typecheck clean
✓ bun test 857 pass / 0 fail (new: projectID pass-through, detached naming, read-only from rules, edit *, unknown depends_on)
✓ bun run lint only pre-existing warnings
✓ live on 2.0.24 + 2.0.32:

team_create → team_spawn(build, worktree) → own worktree + branch → commit
           → team_shutdown → team_merge ✓ → team_cleanup

✗ not verified: subagent-mode teammates (explore etc.) on opencode's free big-pickle. they get "free tier can only be used from within OpenCode", built-ins too, so it looks like a host/provider thing, not ensemble.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GUtz6gBn7rhXaufK97d8cm

zudsniper and others added 2 commits October 12, 2026 00:04
Fixes hueyexe#40 against OpenCode 2.0.24:

- session.create: only call permission.rules() when the host still has it
  (2.0.3-2.0.18). Since 2.0.19 the session ruleset merges after the agent's
  (core permission.ts merge(agent, session) with last-match evaluation), so
  create() permissions are enough and rules() no longer exists.
- worktree create/list/remove/refresh: pass the location's projectID, which
  the 2.0.19+ worktree API requires; worktree creation silently failed
  without it and every teammate shared the base tree.
- team_spawn: also allow `edit *` for worktree teammates. V2 checks files
  inside the session location as relative paths, so the absolute
  `<worktree>/**` rule never matched and edits fell back to an ask nobody
  could answer. Files outside the worktree stay behind external_directory.
- team_spawn: detect read-only agents from the agent's own permission rules
  (agent.get) instead of only the names plan/explore, so custom reviewer
  agents are not given a worktree and `shell * allow`.
- team_tasks_add: reject unknown depends_on IDs up front instead of creating
  a task that can never unblock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUtz6gBn7rhXaufK97d8cm
OpenCode 2.0.32 creates worktrees with `git worktree add --detach`, so a
teammate's commits landed on a detached HEAD and team_merge failed with
"not something we can merge". When the new worktree has no branch, create
the requested branch in it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUtz6gBn7rhXaufK97d8cm
@zudsniper
zudsniper requested a review from hueyexe as a code owner October 17, 2026 09:34
@zudsniper zudsniper changed the title fix: support OpenCode 2.0.19+ (team_spawn, worktrees, teammate edits, read-only agents) fix: opencode 2.0.19+ support (team_spawn, worktrees, teammate edits, read-only agents) Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant