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

refactor: Add plugin API abstraction layer

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

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.ts directly uses client.session.prompt(), client.session.get(), hook registration
  • notifications.ts, compaction.ts, commands.ts all depend directly on SDK types
  • No interface abstraction for the plugin SDK

Proposed Solution

  1. Define a PluginHost interface covering MC's SDK usage: notifications, hooks, session state, commands
  2. Implement OpenCodePluginHost wrapping the real SDK
  3. MC core logic depends on PluginHost, not the SDK directly
  4. Tests can use MockPluginHost
  5. 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.ts and commands.ts testable

nigel-dev avatar Feb 13 '26 19:02 nigel-dev