<p align="center">
  <strong>meMO Tools</strong><br>
  <em>Model engine + CLI for the Medical Engineering Modelling Ontology</em>
</p>

<p align="center">
  Parse text-first SysML v2 into a semantic graph, run closure and consistency
  checks, and generate assurance views — <code>memo validate</code> in CI.
</p>

<p align="center">
  <code>memo-tools 0.13.2</code> &middot; MIT &middot; SysML v2 &middot; ISO 14971 &middot; IEC 62304 &middot; ISO/IEC/IEEE 42010
</p>

<p align="center">
  <a href="https://memoarchitect.com/memo-tools.html">Product website</a> &middot;
  <a href="https://memoarchitect.com/memo-tools/">Documentation</a> &middot;
  <a href="https://github.com/memoarchitect/memo-tools">GitHub repository</a> &middot;
  <a href="https://www.npmjs.com/package/@memoarchitect/tools">npm package</a>
</p>

---

> **Status: published preview.** `@memoarchitect/tools` is available on npm.
> Its API, CLI flags, and model semantics remain pre-stable and may change
> before version 1.0.

## Version compatibility

`memo`, `memo-tools`, and `memo-architect` share a `MAJOR.MINOR` compatibility
line. Any `0.6.x` release is intended to work with the other `0.6.x` products;
patch versions may advance independently for fixes and additive changes.

`VERSION` is the sole release-version source for this repository. Run
`pnpm version:sync` after changing it; CI rejects unsynchronized generated
version fields and automatically creates the matching `v<version>` tag when
the change reaches `main`.

## The meMO stack

meMO is a four-layer stack — adopt what you need
(see [memoarchitect.com](https://memoarchitect.com)):

| Layer | What | Where |
|---|---|---|
| 01 Ontology | Typed SysML v2 elements and architecture definitions | [Docs](https://memoarchitect.com/memo/) · [Repository](https://github.com/memoarchitect/memo) |
| 02 Methodology | Profiles, viewpoints, rules, workflow gates | [Docs](https://memoarchitect.com/memo/) · [Repository](https://github.com/memoarchitect/memo) |
| **03 Tools** | **Model engine + `memo` CLI — this repo** | [Docs](https://memoarchitect.com/memo-tools/) · [Repository](https://github.com/memoarchitect/memo-tools) |
| 04 Architect | Web workbench over the same model | [Docs](https://memoarchitect.com/memo-architect/) · [Repository](https://github.com/memoarchitect/memo-architect) |

## Supported tools

Memo Tools is one npm package with internal engine, CLI, and maintainer-tool
modules. The UI lives in Memo Architect; editor functionality belongs to a
user's SysML v2 editor rather than a MEMO-specific VS Code extension.

| Surface | Purpose | Typical use |
|---|---|---|
| `@memoarchitect/tools` | Parser, semantic model, validation, analysis, project operations, document tooling, and the `memo` CLI | Reused by the CLI and Memo Architect server |
| `tools/ontology-tools` | Internal dependency-free repository checks (not an npm package) | Maintainers validating ontology structure and editor portability |

### CLI usage

```bash
# Create and inspect a project
memo init --list
memo init my-device
memo init my-device --template samd
memo init gpca --example gpca
memo ontology show

# Upgrade a pre-native project safely (reports only unless --write is supplied)
memo convert . --diff
memo convert . --write

# Validate locally or in CI
memo validate .
memo validate . --format junit --output validation.xml

# Exchange and publish model data
memo export json --output model.json
memo export dot --output model.dot
memo import csv elements.csv
memo ontology export owl --output ontology.ttl
memo pack --output model.kpar
memo sysand publish --dry-run

# Generate assurance artifacts
memo dhf status
memo export dhf --format docx --output dhf-output
memo rules coverage
```

Run `memo --help` or `memo <command> --help` for the complete command surface.

`memo convert` moves legacy project content beneath `model/catalog/`, rewrites
the corresponding packages/imports/artifact URIs, and creates the native project
binding entrypoint where needed. It plans before touching the filesystem, refuses
collisions, and is idempotent. Review its default dry-run output (or `--diff`)
before using `--write`; then run `memo validate` and your external SysML gate.

### Jupyter analysis samples

Every `memo init` project includes `analysis/Samples/` with seven portable
Syside notebooks. They cover model overview and quality, architecture hotspots,
change-impact exploration, semantic charts, an ownership graph, and an HTML/CSV
inventory table. The notebooks discover either `model/` or `src/` automatically,
so the same samples work with default templates and worked examples.

Run them in a licensed Syside environment:

```bash
python -m venv analysis/.venv
source analysis/.venv/bin/activate
python -m pip install jupyterlab syside
cd analysis
jupyter lab --port 8888
```

## Documentation

The [published documentation](https://memoarchitect.com/memo-tools/)
starts with installation and a
first useful workflow, then covers validation, import, export, CI, configuration,
and the library API. Its source starts at [`docs/index.md`](docs/index.md). Build
it locally with:

```bash
python3 -m pip install "mkdocs>=1.6" "mkdocs-material>=9.5" "pymdown-extensions>=10.0"
pnpm run docs:build
```

### Toolchain selection

Each toolchain role is filled by one provider: the **validator** answers "is
this valid SysML/KerML?", **lowering** answers "what can MEMO ingest from this
revision?", and the **packager** builds the archive. Omit `toolchain` entirely
to use MEMO's built-in parser and KPAR writer, which need nothing installed.

```yaml
toolchain:
  validator: syside
  lowering: internal
  packager: sysand
  syside:
    executable: ~/.local/bin/syside
    configFile: ./syside.toml
    warningsAsErrors: true  # default: true
    diagnose: all           # default: all; all | external | project | none
  sysand:
    executable: ~/.local/bin/sysand
    configFile: ./sysand.toml
```

`memo validate` and `memo pack` run `syside check --diagnose all
--warnings-as-errors` by default when it is the selected validator, automatically
including the resolved ontology directories. Set `warningsAsErrors: false` or use
`diagnose: none` to relax the check. `memo pack` delegates archive creation to
SysAnd when selected. Relative executable and config paths resolve from the
project directory; bare executable names resolve through `PATH`. A selected tool
that is not installed is a clear error, never a silent fallback.

Every leaf under `toolchain` also has a generated flag, so a project can be run
against a different toolchain without editing its settings:

```bash
memo toolchain probe                 # which provider, which binary, which version
memo config effective                # settings + flags + defaults, fully resolved
memo validate --toolchain.validator syside
```

`toolchain.compiler` is a deprecated alias kept for existing settings files; see
`docs/reference/configuration.md`.

### Core library usage

`@memoarchitect/tools` is the reusable implementation layer. Protocol DTOs expose its
supported application boundary; the CLI is an adapter over that boundary, and
React does not import core internals directly.

```ts
import { buildMemoModel } from '@memoarchitect/tools';
```

The API is pre-stable. Pin an exact `0.6.x` patch when embedding it directly.

### Maintainer checks

```bash
pnpm run ontology:lint    # naming, inheritance, and ontology policy checks
pnpm run ontology:compat  # static SysML v2 / SysIDE portability checks
pnpm run build
pnpm run test
pnpm run type-check
```

The authoritative external parse/package validation remains the `sysand` build
in the sibling `memo` repository within `memo-meta`. Diagram and presentation generators are private
release/documentation machinery maintained in `memo-meta`, not product tools.

## Layout

```
packages/tools/       internal source for the root @memoarchitect/tools package
tools/ontology-tools/ internal repository lint and editor-portability checks
```

The engine resolves ontology content through its exact
`@memoarchitect/ontology` npm dependency. In `memo-meta`, pnpm links that
dependency to the sibling `memo` checkout for iterative development.

## Current repository relationship

- A standalone clone installs `@memoarchitect/ontology@0.6.3` from npm.
- The Tools repository contains no ontology git submodule.
- The private `memo-meta` workspace keeps `memo` and `memo-tools` as sibling
  submodules and applies local pnpm overrides for cross-repository work.
- Publishing Tools never depends on the meta repository.

## Quickstart

Requires Node.js 26 or later and pnpm 9.15.

```bash
git clone https://github.com/memoarchitect/memo-tools.git
cd memo-tools
pnpm install && pnpm run build && pnpm run test

# validate the GPCA reference pump
pnpm run example:validate
```

Memo Tools deliberately exposes no CLI commands that require Architect.
Interactive development and static viewer builds are provided by the separate
`@memoarchitect/architect` command.

## License

MIT © 2026 memoarchitect
