🤖 feat: VS Code-style extension system with global host architecture #534
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces a VS Code-style extension system for cmux, allowing users to extend functionality via custom extensions loaded from
~/.cmux/ext/.Features
Extension Discovery:
~/.cmux/ext/(global directory).js) and folder-based extensions (withmanifest.json)Extension Execution:
Extension API:
Architecture:
Implementation
Core Components
ExtensionManager (
src/services/extensions/extensionManager.ts):initializeGlobal()- Discovers extensions and spawns global host once at startupregisterWorkspace()- Creates runtime for workspace on first useunregisterWorkspace()- Removes workspace runtime when workspace removedshutdown()- Cleans up global host on app exitExtensionHost (
src/services/extensions/extensionHost.ts):Map<workspaceId, Runtime>for all active workspacesinit,register-workspace,unregister-workspace,post-tool-useDiscovery (
src/utils/extensions/discovery.ts):ExtensionInfoobjectsIntegration
AIService (
src/services/aiService.ts):initializeGlobal()in constructor (spawns host once)registerWorkspace()on first message from workspaceIpcMain (
src/services/ipcMain.ts):unregisterWorkspace()when workspace removedMessage Protocol
Testing
✅ Unit Tests (14 tests, all pass):
src/utils/extensions/discovery.test.ts- 9 tests covering discovery edge casessrc/services/extensions/extensionManager.test.ts- 5 tests covering manager lifecycle✅ Integration Tests (3 tests, all pass):
tests/extensions/extensions.test.ts- End-to-end extension execution✅ Static Checks:
Example Extensions
Single-file extension (
~/.cmux/ext/tool-logger.js):Folder-based extension (
~/.cmux/ext/echo-extension/):Architecture Decision: Global vs Per-Workspace
Chose global host architecture (consistent with VS Code) over per-workspace hosts:
Benefits:
Trade-offs:
This is the right choice for cmux's "parallel agentic development" use case where users frequently have many workspaces open.
Files Added
Core (7 files):
src/types/extensions.ts- Type definitions for extension systemsrc/services/extensions/extensionHost.ts- Extension host process entry pointsrc/services/extensions/extensionManager.ts- Extension manager servicesrc/utils/extensions/discovery.ts- Extension discovery utilityTests (3 files):
src/utils/extensions/discovery.test.ts- Discovery unit testssrc/services/extensions/extensionManager.test.ts- Manager unit teststests/extensions/extensions.test.ts- Integration testsFiles Modified
Integration points (3 files):
src/services/aiService.ts- Initialize global host, register workspacessrc/services/ipcMain.ts- Unregister workspaces on removalsrc/services/streamManager.ts- Import extension typesNext Steps
docs/).cmux/ext/) in addition to globalGenerated with
cmux