The extension follows a Redux Pattern + MVVM + Hexagonal Architecture approach with clear separation of concerns:
graph TB
UI[VS Code UI<br/>TreeView, Webview, Commands]
VM[View Models<br/>Presentation Logic]
M[Mediators<br/>Cross-cutting Concerns]
Store[Application Store<br/>Global State]
UI <--> VM
VM --> Store
M --> Store
M --> VM
subgraph "Framework-Free Zone"
VM
Store
end
subgraph "VS Code Integration"
UI
M
end
style Store fill:#e1f5fe
style VM fill:#f3e5f5
style M fill:#fff3e0
style UI fill:#e8f5e8
- Models:
application-store.ts- Zustand-based global state management - ViewModels: Framework-free presentation logic (no
vscodeimports)TreeViewModel- Tree structure and navigationEditorViewModel- Editor interactions and positioningDocifyViewModel- Documentation generation stateCalmModelViewModel- Model data displayTemplateViewModel- Template processing and live mode
- Views: VS Code specific UI implementations (TreeDataProvider, WebviewPanel, etc.)
- Controller:
calm-extension-controller.tshandles dependency wiring and VS Code lifecycle
src/core/
├── ports/ # Interfaces (dependency inversion)
├── services/ # Core business logic
├── mediators/ # Cross-cutting concerns coordination
└── application-store.ts # Central state management
Mediators handle cross-cutting concerns without tight coupling:
- RefreshService: Coordinates model updates and UI refreshes
- SelectionService: Syncs selection across tree, editor, and preview
- WatchService: File system monitoring and change detection
- StoreReactionMediator: Reactive state management orchestration
src/
├── application-store.ts # Zustand store (global state)
├── calm-extension-controller.ts # Main orchestration controller
├── extension.ts # VS Code entry point
├──
├── core/ # Hexagonal architecture core
│ ├── ports/ # Dependency inversion interfaces
│ ├── services/ # Business logic services
│ ├── mediators/ # Cross-cutting concern coordinators
│ └── emitter.ts # Framework-free event system
│
├── features/ # Feature-based organization
│ ├── editor/ # Editor integration (hover, CodeLens)
│ ├── preview/ # Webview preview panel
│ │ ├── docify-tab/ # Documentation generation
│ │ ├── model-tab/ # Model data display
│ │ └── template-tab/ # Template processing
│ └── tree-view/ # Sidebar tree navigation
│ └── view-model/ # MVVM presentation logic
│
├── commands/ # VS Code command implementations
├── models/ # Model parsing and indexing
└── cli/ # CLI integration (to be replaced)
- VS Code 1.88+
- Node.js 20+
-
Install dependencies:
cd calm-plugins/vscode npm install -
Start development server:
npm run watch
-
Launch Extension Development Host:
- Press
F5in VS Code - Or use "Run CALM Extension" from the debug panel
- Press
At the root project level
npm run package:vscodeThis will ensure dependent projects are compiled first
npm test # Run all tests
npm test -- --watch # Run tests in watch mode
npm test -- tree-view # Run specific test suiteTest Coverage: 109 tests across all ViewModels with comprehensive:
- State management validation
- Event emission testing
- Resource cleanup verification
- Edge case handling
The extension can be published via GitHub Actions using manual workflow dispatch:
- Navigate to Actions tab in your GitHub repository
- Select "Build VS Code Extension" from the workflow list
- Click "Run workflow" button
- Choose your options:
- ☐ Leave unchecked: Build, test, and package only
- ☑️ Check "Publish to VS Code Marketplace": Build, test, package, AND publish
What it does
- Always runs: Lint → Test → Package
- Conditionally runs: Publish (only when checkbox is selected)
Prerequisites
- Ensure
VSCE_PATsecret is configured in repository settings - Secret is only needed if you plan to publish
VS Code Marketplace The extension will be published to the VS Code Marketplace.
- MVVM Architecture: Clean separation with framework-free ViewModels
- Comprehensive Testing: 109 tests covering all ViewModels
- State Management: Zustand-based reactive store
- Interactive Preview: Cytoscape-powered graph with rich interactions
- Tree Navigation: Full CRUD operations with search/filter
- Editor Integration: Hover, CodeLens, and automatic refresh
- Template System: Handlebars processing with live mode
- Hexagonal Architecture Refinement: Completing ports/adapters pattern
- Mediator Coordination: Fine-tuning cross-cutting concerns
- CLI Integration Replacement:
--scaffoldmode from docify CLI will replace most of the code insrc/cli/folder (See finos#1563) - Model Updates: Original POC models in
src/models/and settings need updating to potentially use models from @finos/calm-models and reduce use of any - Enhanced Validation: Richer diagnostics and error reporting
- ✅ Be framework-free (no
vscodeimports) - ✅ React to store state changes only
- ✅ Provide presentation-ready data
- ✅ Emit events for user intents
- ❌ NOT know about mediators directly
- ✅ Coordinate between different parts of the system
- ✅ Handle cross-cutting concerns (selection, refresh, etc.)
- ✅ Subscribe to store changes and ViewModel events
- ❌ NOT contain business logic