Feature Proposal
Target Project:
calm-plugins/vscode (primary), cli and shared (refactoring support)
Description of Feature:
Integrate core CALM CLI capabilities (validate, generate, docify) directly into the VSCode extension by utilizing the shared code libraries, rather than executing the CLI as a subprocess. This ensures a smoother user experience, faster performance, and removes the requirement for users to have the calm CLI installed globally or locally in their project.
This integration will allow users to:
- Validate architecture files against patterns with inline error reporting in the VSCode Problems panel.
- Generate architecture files from patterns using a UI-driven wizard.
- Docify their models into documentation sites directly from the command palette.
User Stories:
- As a CALM architect, I want to see validation errors in my
architecture.json file highlighted in the editor (squiggles) and listed in the Problems panel, so I can fix issues immediately without running a command.
- As a developer, I want to right-click a CALM pattern file and select "Generate Architecture", so I can quickly scaffold a new architecture file.
- As a documentation writer, I want to run "CALM: Docify" from the command palette to generate the static site, without needing to learn the CLI syntax or install Node.js dependencies manually.
- As a new user, I want the extension to work "out of the box" without needing to configure a path to the CALM CLI binary.
Current Limitations:
- The current extension focuses primarily on visualization (Preview).
- Users must install the
calm CLI separately to perform validation or generation.
- There is no feedback loop between the editor and the validation logic (no inline linting).
- Shelling out to a subprocess (if implemented) is slow, requires path configuration, and error handling is brittle.
Proposed Implementation:
Technical Design Considerations
The core logic for CALM commands already resides in the @finos/calm-shared package, which is a dependency of both the CLI and the VSCode extension. The proposed approach is to consume these shared libraries directly within the VSCode extension.
-
Refactoring (cli -> shared):
- The
validate command in the CLI currently contains logic for loading files and resolving references (loadArchitectureAndPattern, resolveSchemaRef) inside cli/src/command-helpers/validate.ts.
- This logic should be moved to
@finos/calm-shared (e.g., shared/src/document-loader/loading-helpers.ts) so it can be reused by the VSCode extension to load and parse documents exactly as the CLI does.
-
VSCode Integration (calm-plugins/vscode):
- Validation:
- Create a
ValidationProvider that listens to vscode.workspace.onDidSaveTextDocument.
- Use
DocumentLoader (from shared) and the refactored loading helpers to parse the file.
- Call
validate() from @finos/calm-shared/commands/validate.
- Map the resulting
ValidationOutcome errors/warnings to a vscode.DiagnosticCollection to show squiggles and problem markers.
- Generation:
- Register command
calm.generate.
- Use VSCode
QuickPick API to replicate the interactive prompts (currently using inquirer in CLI).
- Call
runGenerate() from @finos/calm-shared.
- Docify:
- Register command
calm.docify.
- Call
Docifier class from @finos/calm-shared.
API Changes
@finos/calm-shared: Export new helper functions for loading architecture/patterns and resolving references (extracted from CLI).
Dependencies on Other Components
- Depends on
@finos/calm-shared.
- No external binary dependencies.
Alternatives Considered:
- Shelling out to CLI: Execute
calm validate ... as a child process.
- Rejected: Slower, requires user to manage CLI installation/version, difficult to map stdout/stderr to VSCode diagnostics precisely, poor UX for interactive commands.
- Language Server Protocol (LSP): Implement a full LSP server.
- Rejected for now: Significantly higher complexity. Direct integration is a good first step; LSP can be a future evolution if we need to support other editors (Neovim, IntelliJ).
Testing Strategy:
- Unit Tests: Verify the refactored loading logic in
shared has high coverage.
- Extension Tests: Use
@vscode/test-electron to run integration tests:
- Open a workspace with invalid architecture.
- Assert that diagnostics are generated.
- Run generation command and assert file creation.
Documentation Requirements:
- Update VSCode extension
README.md to highlight new features.
- Update
CONTRIBUTING.md or AGENTS.md in vscode package to explain how to debug the shared logic.
Implementation Checklist:
Feature Proposal
Target Project:
calm-plugins/vscode(primary),cliandshared(refactoring support)Description of Feature:
Integrate core CALM CLI capabilities (
validate,generate,docify) directly into the VSCode extension by utilizing the shared code libraries, rather than executing the CLI as a subprocess. This ensures a smoother user experience, faster performance, and removes the requirement for users to have thecalmCLI installed globally or locally in their project.This integration will allow users to:
User Stories:
architecture.jsonfile highlighted in the editor (squiggles) and listed in the Problems panel, so I can fix issues immediately without running a command.Current Limitations:
calmCLI separately to perform validation or generation.Proposed Implementation:
Technical Design Considerations
The core logic for CALM commands already resides in the
@finos/calm-sharedpackage, which is a dependency of both the CLI and the VSCode extension. The proposed approach is to consume these shared libraries directly within the VSCode extension.Refactoring (
cli->shared):validatecommand in the CLI currently contains logic for loading files and resolving references (loadArchitectureAndPattern,resolveSchemaRef) insidecli/src/command-helpers/validate.ts.@finos/calm-shared(e.g.,shared/src/document-loader/loading-helpers.ts) so it can be reused by the VSCode extension to load and parse documents exactly as the CLI does.VSCode Integration (
calm-plugins/vscode):ValidationProviderthat listens tovscode.workspace.onDidSaveTextDocument.DocumentLoader(from shared) and the refactored loading helpers to parse the file.validate()from@finos/calm-shared/commands/validate.ValidationOutcomeerrors/warnings to avscode.DiagnosticCollectionto show squiggles and problem markers.calm.generate.QuickPickAPI to replicate the interactive prompts (currently usinginquirerin CLI).runGenerate()from@finos/calm-shared.calm.docify.Docifierclass from@finos/calm-shared.API Changes
@finos/calm-shared: Export new helper functions for loading architecture/patterns and resolving references (extracted from CLI).Dependencies on Other Components
@finos/calm-shared.Alternatives Considered:
calm validate ...as a child process.Testing Strategy:
sharedhas high coverage.@vscode/test-electronto run integration tests:Documentation Requirements:
README.mdto highlight new features.CONTRIBUTING.mdorAGENTS.mdinvscodepackage to explain how to debug the shared logic.Implementation Checklist:
loadArchitectureAndPatternandresolveSchemaReffrom CLI to Shared.ValidationProviderin VSCode extension.calm.generatecommand in VSCode.calm.docifycommand in VSCode.