feat: one OpenCode per project — worktree sessions run in-app (#265) #273
No reviewers
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman!273
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "integration/one-opencode-per-project"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
One OpenCode instance per project. Worktree and same-directory
sessions now run in-app on that single instance instead of each
spawning their own
opencode --port 0in a dedicated tmux window.Net effect per project: 1 opencode + 1 tmux session instead of N.
Implements the spec at
spec/one-opencode-per-project/requirements.md(parent #265) across four tickets.
What changed
opencode.CreateSessionsends the session'sdirectory(URL-encoded
x-opencode-directoryheader) so one instance can createa session rooted at an external directory (a worktree). Optional
Porton
CreateSessionRequestskips lsof discovery when the instance isalready known.
hostsvc.Host.EnsureProjectOpencode: discovers orlaunches exactly one opencode per project (rooted at the main
checkout), seeded with a scoped
external_directoryOPENCODE_PERMISSIONrule for the project's.worktrees/<repo>/**root. Idempotent; remote gRPC passthrough included.
/wt, MCPnew_session(worktree + same-dir), andloops
spawn_worktreeto create sessions in-app on the projectinstance.
WorktreeSessionResultcarries the created session ID;SessionLauncherdrops the tmux launcher for an injected ensurer;frontend navigates to the session in-app.
(
LaunchWorktreeWindow, theocman-worktreesession, dead resultfields, the frontend tmux-switch button) and updates AGENTS.md +
docs/architecture.md.Also includes a standalone test-infra fix:
internal/mcpworktree testnow cleans
GIT_*env sogit initin a tempdir isn't hijacked byhook-injected
GIT_DIR.Notes / limitations
launch was not seeded with the
external_directoryrule; runtimeautoapprove covers that gap. (Documented in AGENTS.md.)
OPENCODE_PERMISSIONmerge helper composes with #101 (inheritparent always-allow) — that ticket is out of scope here.
Testing
make test && make lint && make buildgreen. New tests cover thedirectory header + URL-encoding,
EnsureProjectOpencode(discover/launch/idempotent/non-repo/timeout), the permission builder
(scoped, merge-preserving), and the in-app
/wtwiring.Reviewed via the two-axis code-review (standards + spec); the one
finding — a stale frontend tmux-switch button — is fixed in #269.
Closes #265
Closes #266
Closes #267
Closes #268
Closes #269
7de0376c2df1d1ffb7f1f1d1ffb7f1ecea0136f5ecea0136f55181602888Coverage ratchet: ✅ pass
Tolerance: -0.1%. Baseline stored on
gh-pages.