A comprehensive command-line interface for working with the Common Architecture Language Model (CALM)
npx @tessl/cli install tessl/npm-finos--calm-cli@1.12.0NOTE: @finos/calm-cli is a command-line tool only. It does not export functions for programmatic use in Node.js. All functionality is accessed exclusively through the
calmcommand-line interface.
CALM CLI is a comprehensive command-line interface for working with the Common Architecture Language Model (CALM). It provides tools for generating architecture shells from patterns, validating architectures against patterns with detailed error reporting, serving validation operations via HTTP API, generating documentation websites from CALM models, processing templates, and setting up AI-powered development assistance through VSCode chatmode integration.
npm install -g @finos/calm-cli# Install globally
npm install -g @finos/calm-cli
# View available commands
calm --help
# Generate architecture from pattern
calm generate -p pattern.json -o architecture.json
# Validate architecture against pattern
calm validate -a architecture.json -p pattern.json -f json
# Start validation server
calm server --port 3000 -s ./schemas
# Generate files from template
calm template -a architecture.json -b ./template-bundle -o ./output
# Generate documentation website
calm docify -a architecture.json -o ./docs
# Setup AI assistance
calm copilot-chatmode -d .CALM CLI is organized into several key modules:
cli.ts): Main command setup using Commander.js, defining all CLI commands and optionscli-config.ts): User configuration file handling from ~/.calm.jsonThe CLI depends heavily on @finos/calm-shared for core CALM functionality including schema validation, document loading, template processing, and documentation generation.
Generate an architecture shell from a CALM pattern file with interactive prompts for pattern options.
// CLI usage
calm generate [options]
// Options
interface GenerateCommandOptions {
pattern: string; // Path to pattern file or CalmHub URL (required)
output?: string; // Output path (default: "architecture.json")
schemaDirectory?: string; // Path to meta schemas directory
calmHubUrl?: string; // CALMHub instance URL
verbose?: boolean; // Enable verbose logging (default: false)
}Generate Command Documentation
Validate that a CALM architecture conforms to a given pattern with detailed error and warning reporting.
// CLI usage
calm validate [options]
// Options
interface ValidateCommandOptions {
pattern?: string; // Path to pattern file or URL
architecture?: string; // Path to architecture file or URL
schemaDirectory?: string; // Path to meta schemas (default: CALM_META_SCHEMA_DIRECTORY)
strict?: boolean; // Fail on warnings (default: false)
format?: 'json' | 'junit' | 'pretty'; // Output format (default: "json")
output?: string; // Output file path (stdout if not specified)
verbose?: boolean; // Enable verbose logging (default: false)
}Validate Command Documentation
Start an HTTP server to provide REST API access to CLI validation operations (experimental feature).
// CLI usage
calm server [options]
// Options
interface ServerCommandOptions {
port?: string; // Server port (default: "3000")
schemaDirectory: string; // Path to meta schemas directory (required)
verbose?: boolean; // Enable verbose logging (default: false)
}Generate files from a CALM model using Handlebars template bundles, single templates, or template directories.
// CLI usage
calm template [options]
// Options
interface TemplateCommandOptions {
architecture: string; // Path to CALM architecture JSON file (required)
output: string; // Output directory or file path (required)
clearOutputDirectory?: boolean; // Delete output directory contents first
bundle?: string; // Path to template bundle directory
template?: string; // Path to single .hbs or .md template file
templateDir?: string; // Path to directory of .hbs/.md templates
urlToLocalFileMapping?: string; // Path to URL mapping JSON file
verbose?: boolean; // Enable verbose logging (default: false)
}Template Command Documentation
Generate documentation websites from CALM models using templates or the built-in website generator.
// CLI usage
calm docify [options]
// Options
interface DocifyCommandOptions {
architecture: string; // Path to CALM architecture JSON file (required)
output: string; // Output directory path (required)
clearOutputDirectory?: boolean; // Delete output directory contents first
template?: string; // Path to single .hbs or .md template file
templateDir?: string; // Path to directory of .hbs/.md templates
urlToLocalFileMapping?: string; // Path to URL mapping JSON file
verbose?: boolean; // Enable verbose logging (default: false)
}Augment a git repository with CALM VSCode chatmode for AI-powered development assistance.
// CLI usage
calm copilot-chatmode [options]
// Options
interface CopilotChatmodeCommandOptions {
directory?: string; // Target directory (default: ".")
verbose?: boolean; // Enable verbose logging (default: false)
}Copilot Chatmode Command Documentation
Location: ~/.calm.json
Format:
{
"calmHubUrl": "https://your-calmhub-instance.com"
}The configuration file is automatically loaded by the CLI when present. The calmHubUrl setting provides a default CALMHub URL for loading remote patterns and schemas, which can be overridden by the --calm-hub-url command-line option.
All commands support the -v, --verbose flag which enables detailed debug logging to help troubleshoot issues:
What verbose mode does:
DEBUG=true environment variableUsage examples:
# Debug architecture generation
calm generate -p pattern.json -o output.json -v
# Debug validation issues
calm validate -a architecture.json -p pattern.json -v
# Debug template processing
calm template -a architecture.json -b ./bundle -o ./output -v
# Debug server startup and requests
calm server --port 3000 -s ./schemas -vVerbose mode is particularly useful when:
For template and docify commands, you can provide a JSON file mapping external URLs to local file paths:
{
"https://calm.finos.org/docuflow/flow/document-upload": "flows/flow-document-upload.json"
}This is useful when working with CALM models that reference external files that are not yet published.
$schema field returns 400 statusValidation Errors:
Template/Docify Errors:
Server Errors:
AI Tools Errors:
CALM CLI depends on @finos/calm-shared for core functionality:
External dependencies include:
commander - CLI framework@inquirer/prompts - Interactive promptsexpress - HTTP server (for server command)express-rate-limit - Rate limiting (for server command)