opencode-mission-control icon indicating copy to clipboard operation
opencode-mission-control copied to clipboard

Improvement: Symlink .opencode/ into spawned worktrees for plugin availability

Open nigel-dev opened this issue 9 months ago • 1 comments

Problem

Spawned agent sessions have no Mission Control awareness. The .opencode/ directory is in .gitignore, so git worktree add doesn't include it. This means:

  • No mc_* tools available in spawned sessions
  • No /mc-* slash commands
  • No worktree awareness (getWorktreeContext() not running)
  • No compaction context injection
  • No auto-status toasts
  • No plan awareness

Agents are completely blind to the orchestration. The only thing monitoring them is the JobMonitor polling tmux pane status from the parent session.

Proposed Fix

The createWorktree() function already supports a postCreate hook with copyFiles and symlinkDirs options, but neither mc_launch nor the orchestrator's launchJob() uses them.

Add .opencode to symlinkDirs in both launch paths:

// In mc_launch (src/tools/launch.ts)
worktreePath = await createWorktree({
  branch,
  postCreate: {
    symlinkDirs: ['.opencode'],
  },
});

// In orchestrator.launchJob (src/lib/orchestrator.ts)
worktreePath = await createWorktree({
  branch,
  postCreate: {
    symlinkDirs: ['.opencode'],
  },
});

A symlink is preferred over copying because plugin updates propagate automatically.

Follow-up Considerations

Once agents have the plugin loaded, we need to consider:

  1. Tool safety: Which mc_* tools should agents be allowed to use? (mc_kill, mc_plan_cancel, mc_merge could disrupt the orchestrator)
  2. Plan awareness: Even with the plugin, agents don't know they're part of a plan — planId is on the Job record but not exposed via getWorktreeContext()
  3. Sibling coordination: Should agents be able to see and coordinate with sibling jobs?

Discovery Context

Found during manual test planning — the entire "Agent Capabilities" section of the test plan had to be rewritten when we realized agents are running vanilla OpenCode.

nigel-dev avatar Feb 07 '26 08:02 nigel-dev

Fixed in 2ea38d3. The .opencode/ directory is now automatically symlinked into every spawned worktree, so agents have access to the Mission Control plugin and tools.

Additionally, users can now configure custom file copying, directory symlinking, and post-create commands via:

  • Config: worktreeSetup in .mission-control/config.json for project-wide defaults
  • Per-launch: copyFiles, symlinkDirs, commands args on mc_launch
  • Per-plan-job: same fields on individual jobs in mc_plan

Examples: copy .env files, symlink node_modules to save disk, run bun install after creation.

nigel-dev avatar Feb 07 '26 08:02 nigel-dev