ModelScript is a completely web-native, polyglot incremental compiler supporting multiple engineering domains — from requirements and system architecture to simulation, CAD, CAE, and manufacturing. By natively supporting Modelica, SysML v2, STEP, OWL2, and OpenFOAM (CFD), ModelScript enables seamless cross-domain simulation-based requirements verification.
Designed for modern workflows, it features a robust engine for incremental compilation and flattening, seamless FMU import/export and integration, surrogate ROM generation from FMUs, as well as advanced model optimization and parameter calibration. All of this is accessible directly in the browser or via the command line.
- Salsa-Based Incremental Compiler: Powered by a query-based incremental compilation architecture (inspired by Rust's Salsa). ModelScript caches intermediate representations and only recompiles what has changed, enabling instantaneous feedback in the IDE.
- Arena Data-Oriented Simulator: The simulator utilizes a zero-garbage, Data-Oriented Design (DoD) architecture (
ArenaDAEBuilder). By moving from legacy recursive AST visitors to direct flat-buffer indexing, it provides high-performance equation sorting, Pantelides index reduction, and bipartite matching with zero allocation overhead. - Polyglot & Cross-Domain: Unified AST querying and cross-language interoperability between Modelica (Simulation), SysML v2 (Architecture/Requirements), and STEP (CAD/Manufacturing).
This project is a monorepo managed with Lerna, Nx, and npm workspaces. The structure reflects our transition to a fully modular, high-performance compiler and simulator architecture.
| Package | Description |
|---|---|
@modelscript/cad |
Procedural CAD: TypeScript DSL for programmatic 3D geometry with STEP compilation |
@modelscript/compiler |
Salsa-based query engine for incremental compilation, type checking, and flattening |
@modelscript/core |
Central compiler engine for ModelScript (legacy flattener, simulator, optimizer) |
@modelscript/cosim |
MQTT-linked co-simulation engine for ModelScript |
@modelscript/diagram |
Diagram rendering, interactive SVG generation, and X6-based visual layouts |
@modelscript/ecad |
ECAD structural extraction and Gerber layout generator for ModelScript |
@modelscript/fmi |
FMI 2.0/3.0 model description, C code generation, and FMU archive builder |
@modelscript/lsp |
Language Server Protocol — completions, hover, diagnostics, formatting, colors |
@modelscript/mcp |
Model Context Protocol implementation for AI/LLM integration |
@modelscript/reasoner |
ModelScript OWL2 Reasoner — subsumption, consistency, and SPARQL-DL queries |
@modelscript/symbolics |
ModelScript Symbolics Engine |
@modelscript/utils |
Common utility functions across the monorepo |
| Package | Description |
|---|---|
@modelscript/csv |
CSV tabular data parsing and validation |
@modelscript/example |
Example language configuration illustrating how to add new languages |
@modelscript/modelica |
Tree-sitter grammar (native + WASM) and language configuration for Modelica |
@modelscript/owl2 |
OWL2 Functional Syntax parsing and ontological knowledge extraction |
@modelscript/step |
STEP (ISO 10303) grammar and querying for CAD/CAE interoperability |
@modelscript/sysml2 |
SysML v2 tree-sitter AST querying, handling, and verification |
| Package | Description |
|---|---|
@modelscript/cli |
msc command-line interface — flatten, simulate, optimize, lint, render, and more |
@modelscript/api |
REST API for ModelScript — simulation, publishing, GraphQL, SPARQL, and RDF |
@modelscript/morsel |
Visual editor — code editing, diagram viewer, simulation, and plotting |
@modelscript/web |
Web frontend for browsing and exploring libraries (NPM-style registry) |
@modelscript/ide |
ModelScript VS Code Web IDE with GitHub/GitLab repository integration |
@modelscript/site |
Main modelscript.org website |
@modelscript/vscode |
VS Code extension — syntax highlighting, LSP client, diagram view |
- Polyglot Incremental Compiler — completely web-native, query-based (Salsa) architecture supporting Modelica, SysML v2, and STEP for cross-domain engineering.
- Data-Oriented Simulation Engine — arena-native ODE/DAE solver featuring zero-garbage buffer allocation, Pantelides index reduction, and BLT ordering.
- Cross-Domain Verification — continuous simulation-based requirements verification spanning architecture, simulation, CAD, CAE, and manufacturing.
- Incremental Flattening — state-of-the-art incremental compilation and unrolling of hierarchical models into flat Differential Algebraic Equations (DAE).
- FMU & ROM — seamless FMU import/export, integration, and high-performance surrogate ROM generation from FMUs.
- Optimization & Calibration — direct collocation solvers for optimal control problems, model optimization, and parameter calibration.
- Accurate Parsing — custom Tree-sitter grammars for efficient, incremental parsing of all supported domains.
- Semantic Analysis — full scope and name resolution for complex multi-domain hierarchies.
- Diagram Rendering — interactive SVG diagrams and X6-based visual layouts with auto-placement.
- Language Server — rich completions, hover, diagnostics, formatting, and color provider.
- Linting & i18n — comprehensive lint rules and string extraction support.
- Node.js ≥ 24 (see
.nvmrc) - emsdk (required for building the Tree-sitter WASM parser):
git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install latest ./emsdk activate latest source ./emsdk_env.sh
git clone https://github.com/modelscript/modelscript.git
cd modelscript
npm installBuild all packages (in dependency order via Nx):
npm run buildStart all services concurrently:
npm run devThis launches:
| Service | URL | Description |
|---|---|---|
| Morsel (editor) | http://localhost:3002 | Visual editor with diagrams and simulation |
| Web (library browser) | http://localhost:3001 | Browse and explore libraries |
| API | http://localhost:3000 | REST API for simulation, publishing, queries |
| IDE (VS Code Web) | http://localhost:3003 | Browser-based VS Code environment |
The IDE includes a browser-local AI assistant powered by WebLLM (Qwen3-0.6B). To enable it, download the model weights (~350 MB, one-time):
npm run download-model --workspace=@modelscript/ideOnce downloaded, restart npm run dev and open the ModelScript AI panel in the IDE sidebar.
After building, the CLI is available as msc:
# Flatten a model to DAE incrementally
npx msc flatten Modelica.Electrical.Analog.Examples.CauerLowPassAnalog path/to/MSL
# Simulate a model (outputs CSV by default)
npx msc simulate BouncingBall model.mo --stop-time 5
# Simulate with JSON output
npx msc simulate BouncingBall model.mo --format json
# Solve an optimal control problem
npx msc optimize MyModel model.mo \
--objective "u^2" --controls "u" --control-bounds "u:-1:1" --stop-time 10
# Lint Modelica files
npx msc lint model.mo
# Render a diagram to SVG (outputs to stdout)
npx msc render MyModel model.mo > diagram.svgRun the test suite across all packages (including the new compiler tests):
npm testnpm run lint
npm run formatPre-built images are published to the GitHub Container Registry on every push to main.
Run the latest images without building:
docker compose pull # Pull latest images from ghcr.io/modelscript/*
docker compose up -d # Start containers
docker compose down # Stop containers
docker compose logs -f # Tail logsTo build from source instead:
npm run docker:build # Build images locally
npm run docker:up # Start containers| Service | Port | URL |
|---|---|---|
| API | 3000 | http://localhost:3000 |
| Morsel | 3002 | http://localhost:3002 |
| Web | 3001 | http://localhost:3001 |
| IDE | 3003 | http://localhost:3003 |
ModelScript is licensed under the AGPL-3.0-or-later. See COPYING for more details.