opencode-mission-control
opencode-mission-control copied to clipboard
refactor: Add dependency injection for gitCommand, tmux, and Bun.spawn
Source
Audit report — Section 7: Technical Debt > Architecture
Description
orchestrator.ts, worktree.ts, integration.ts, and other core modules directly import and call gitCommand(), tmux functions, and Bun.spawn(). This makes unit testing difficult — tests must mock module-level imports via spyOn rather than injecting test doubles through constructors.
Current State
orchestrator.tsdirectly imports fromtmux.ts,git.ts,integration.ts,worktree.ts- Tests use
spyOn(module, 'function')pattern extensively (fragile, order-dependent) - No interface abstractions for git operations, tmux, or process spawning
Proposed Solution
- Define interfaces:
GitClient,Multiplexer,ProcessRunner - Accept these via constructor injection in
Orchestrator,MergeTrain,WorktreeProvider - Provide default implementations wrapping current functions
- Tests inject mocks directly — no more module-level spying
Relationship to Other Issues
- Prerequisite for #27 (Multiplexer interface) — DI makes swapping tmux for Zellij natural
- Aids #17 (Orchestrator decomposition) — extracted modules take dependencies via constructor
- Improves #25 (test coverage) — makes previously hard-to-test code testable
Priority
P3 — architectural improvement, not blocking any functionality. Best done alongside #17 decomposition.