# tonto-cli

> Tonto is a DSL for creating OntoUML models

Latest version **0.4.14** (published 2026-08-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install tonto-cli
pnpm add tonto-cli
yarn add tonto-cli
bun add tonto-cli
```

Provides the command `tonto-cli`.

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

Negative: insecure dependencies.

## Facts

| | |
|---|---|
| Version | 0.4.14 |
| Published | 2026-08-21 |
| First published | 2023-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 20 |
| Dependencies | 20 |
| Unpacked size | 2.2 MB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Matheus Lenke Coutinho |
| Maintainers | matheuslenke |

## Links

- npm: https://www.npmjs.com/package/tonto-cli
- Repository: https://github.com/nemo-ufes/Tonto
- Homepage: https://github.com/nemo-ufes/Tonto#readme
- Issues: https://github.com/nemo-ufes/Tonto/issues
- npm.io page: https://npm.io/package/tonto-cli

## Dependencies (20)

- [glob](https://npm.io/package/glob.md) ^10.2.2
- [uuid](https://npm.io/package/uuid.md) ^9.0.1
- [chalk](https://npm.io/package/chalk.md) ^5.6.2
- [elkjs](https://npm.io/package/elkjs.md) ^0.10.0
- [rimraf](https://npm.io/package/rimraf.md) ^4.1.2
- [langium](https://npm.io/package/langium.md) 3.2.0
- [sprotty](https://npm.io/package/sprotty.md) ^1.2.0
- [chevrotain](https://npm.io/package/chevrotain.md) 11.0.3
- [ontouml-js](https://npm.io/package/ontouml-js.md) github:matheuslenke/ontouml-js#feature/include-types-in-build
- [vscode-uri](https://npm.io/package/vscode-uri.md) ^3.0.7
- [sprotty-elk](https://npm.io/package/sprotty-elk.md) ^1.2.0
- [@vscode/vsce](https://npm.io/package/@vscode/vsce.md) 3.3.2
- [concurrently](https://npm.io/package/concurrently.md) 3.5.1
- [langium-sprotty](https://npm.io/package/langium-sprotty.md) 3.2.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.2.2
- [@inquirer/prompts](https://npm.io/package/@inquirer/prompts.md) ^7.8.6
- [node-fetch-native](https://npm.io/package/node-fetch-native.md) ^1.0.1
- [vscode-languageclient](https://npm.io/package/vscode-languageclient.md) ~9.0.1
- [vscode-languageserver](https://npm.io/package/vscode-languageserver.md) ~9.0.1
- [vscode-languageserver-types](https://npm.io/package/vscode-languageserver-types.md) ^3.17.3

## Recent versions

- 0.4.14 (latest) — 2026-08-21
- 0.4.13 — 2026-07-09
- 0.4.12 — 2026-06-19
- 0.4.11 — 2026-05-17
- 0.4.10 — 2026-05-17
- 0.4.9 — 2026-04-24
- 0.4.3 — 2025-10-18
- 0.4.0 — 2025-08-06
- 0.3.10 — 2024-10-06
- 0.3.9 — 2024-10-06
- 0.3.8 — 2024-10-04
- 0.3.7 — 2024-10-04
- 0.3.6 — 2024-05-22
- 0.3.5 — 2024-05-22
- 0.3.4 — 2024-05-04
- … 17 more at https://npm.io/package/tonto-cli/versions

## README

# Tonto CLI And Language Package

`packages/tonto` contains the Tonto grammar, generated language services, validation rules, diagram model generation, and the `tonto-cli` command-line interface.

This is the core package used by the VS Code extension, the webview, TPM, tests, and external users that install `tonto-cli` from npm.

## Responsibilities

- Define the Tonto grammar with Langium.
- Provide language services for parsing, validation, formatting, references, completion, hover information, and semantic tokens.
- Convert Tonto projects to OntoUML JSON.
- Import OntoUML JSON back into Tonto source files.
- Validate projects locally, with optional OntoUML API validation.
- Transform models to gUFO/Turtle through the OntoUML toolchain.
- Generate PlantUML diagram source from a Tonto project.
- Initialize new Tonto projects and optional guidance files for agentic IDE workflows.

## Command Flow

```mermaid
flowchart LR
    Project["Tonto project<br/>tonto.json + src/*.tonto"] --> Parser["Langium parser<br/>workspace documents"]
    Parser --> Validation["Local validators"]
    Parser --> JSON["OntoUML JSON<br/>generate"]
    JSON --> Import["Tonto source<br/>import"]
    JSON --> GUFO["gUFO Turtle<br/>transform"]
    Parser --> PlantUML["PlantUML source<br/>plantuml"]
    Init["init"] --> Project
```

## Install

From npm:

```bash
npm install -g tonto-cli
```

From this repository:

```bash
npm install
npm run build --workspace=tonto-cli
```

## CLI Commands

| Command | Purpose |
|---|---|
| `tonto-cli init` | Initialize a new Tonto project. Use `--destination <dir>`, `--template <blank|cat-dog>`, and `--guidance <target>` for non-interactive setup. |
| `tonto-cli generate <dir>` | Generate OntoUML JSON from a project. Use `--destination <dir>` to choose the output folder. |
| `tonto-cli generateSingle <file>` | Generate JSON from a single `.tonto` file. |
| `tonto-cli import <file>` | Generate a Tonto project from an OntoUML JSON file. |
| `tonto-cli importSingle <file>` | Generate a single Tonto output from an OntoUML JSON file. |
| `tonto-cli validate <dir>` | Validate a project locally. Add `--with-api` to also call the OntoUML API. |
| `tonto-cli transform <dir>` | Transform a Tonto project to gUFO/Turtle through the OntoUML toolchain. |
| `tonto-cli plantuml <dir>` | Generate PlantUML diagram source. Supports `--destination`, `--per-package`, `--no-external-references`, and `--layout`. |
| `tonto-cli add-skill` | Add the Tonto ontology skill files for supported editor and agentic IDE targets. |

Examples:

```bash
tonto-cli init --destination my-ontology
tonto-cli generate my-ontology --destination generated
tonto-cli validate my-ontology --with-api
tonto-cli plantuml my-ontology --per-package --layout left-to-right
```

## Language Overview

Every `.tonto` file declares one package:

```tonto
package university
```

Tonto supports OntoUML/UFO stereotypes for sortals, non-sortals, relators, qualities, perdurants, higher-order types, and neutral classes.

```tonto
package university

kind Person {
    name: string
    birthDate: date [0..1]
}

role Student specializes Person
role Professor specializes Person

kind Course {
    code: string
    title: string
}

relator Enrollment {
    @mediation [1] -- [1] Student
    @mediation [1] -- [1] Course
}

@material relation Student [0..*] -- enrollsIn -- [0..*] Course
```

## Common Declarations

### Classes

```tonto
kind Person
subkind Employee specializes Person
phase Child specializes Person
role Student specializes Person
relator Employment
```

### Datatypes And Enumerations

```tonto
datatype Address {
    street: string
    city: string
}

enum EyeColor { Blue, Green, Brown, Black }
```

Built-in datatypes include `string`, `number`, `boolean`, `date`, `time`, and `datetime`.

### Attributes

```tonto
kind Person {
    name: string [1]
    nicknames: string [*] { ordered }
    nationalId: string [0..1] { const }
}
```

### Relations

```tonto
kind University {
    @componentOf [1] <>-- hasDepartments -- [1..*] Department
}

@mediation relation Employment [1] -- [1] Employee
```

### Generalization Sets

```tonto
disjoint complete genset PersonLifePhase where Child, Adult specializes Person

genset PersonRoles {
    general Person
    specifics Student, Professor
}
```

## Development

From the repository root:

```bash
npm run langium:generate
npm run build --workspace=tonto-cli
npm run test --workspace=tonto-cli
npm run watch --workspace=tonto-cli
```

The grammar entry point is `src/language/tonto.langium`. Generated language files are checked in under `src/language/generated`.

## License

Distributed under the MIT License. See the repository root [LICENSE](../../LICENSE) file for more information.

---
_Source: https://npm.io/package/tonto-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
