opencode-mission-control
opencode-mission-control copied to clipboard
refactor: Add plugin API abstraction layer
Source
Audit report — Section 7: Technical Debt > Architecture
Description
MC directly uses the OpenCode plugin SDK APIs (client.session.prompt(), client.session.get(), hook registration, etc.) throughout the codebase without an abstraction layer. This couples MC tightly to the specific OpenCode SDK version and makes it impossible to:
- Run MC logic in tests without the full plugin runtime
- Port MC to other AI coding tool ecosystems
- Mock the plugin API cleanly in unit tests
Current State
index.tsdirectly usesclient.session.prompt(),client.session.get(), hook registrationnotifications.ts,compaction.ts,commands.tsall depend directly on SDK types- No interface abstraction for the plugin SDK
Proposed Solution
- Define a
PluginHostinterface covering MC's SDK usage: notifications, hooks, session state, commands - Implement
OpenCodePluginHostwrapping the real SDK - MC core logic depends on
PluginHost, not the SDK directly - Tests can use
MockPluginHost - Future:
ClaudeCodePluginHost,CursorPluginHost, etc.
Priority
P3 — architectural improvement. Not blocking functionality, but improves testability and future portability.
Relationship to Other Issues
- Complements #45 (DI for git/tmux/spawn) — both improve testability through abstraction
- Aids #25 (test coverage) — makes
index.tsandcommands.tstestable