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
- Define a
PluginHost interface covering MC's SDK usage: notifications, hooks, session state, commands
- Implement
OpenCodePluginHost wrapping 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
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:Current State
index.tsdirectly usesclient.session.prompt(),client.session.get(), hook registrationnotifications.ts,compaction.ts,commands.tsall depend directly on SDK typesProposed Solution
PluginHostinterface covering MC's SDK usage: notifications, hooks, session state, commandsOpenCodePluginHostwrapping the real SDKPluginHost, not the SDK directlyMockPluginHostClaudeCodePluginHost,CursorPluginHost, etc.Priority
P3 — architectural improvement. Not blocking functionality, but improves testability and future portability.
Relationship to Other Issues
index.tsandcommands.tstestable