Packages: what to install and what depends on what¶
Audience: developers who build on struktJS as a toolkit, in a web page, a Node program, a build or a product · about 6 minutes · Prerequisites: Node.js 22 or newer
struktJS is a set of small packages. The engine that reads, checks, runs and generates models is one of them, the projectional editor is another, and every language ships as its own package. The IDE and the desktop app are programs assembled from the same pieces, so a page that embeds the editor and a script that checks a model in a build run the same code as the IDE does. You install the ones you need and leave out the rest.
Install¶
The packages are distributed privately, as tarballs. npm run build:package in a checkout writes one struktjs-<name>-<version>.tgz per package into dist/. Install the ones you need together, in one npm install:
npm install ./struktjs-core-0.1.0.tgz ./struktjs-grammar-python-0.1.0.tgz ./struktjs-lang-core-0.1.0.tgz
Three rules keep a set of packages working:
- Take all the tarballs from one build. The packages import each other's files by path, so a package only works with the build of
@struktjs/coreit was made with. The version number does not tell two builds apart, so every package carries a build id (struktjs.buildIdin itspackage.json) and the checks in the repository's tests report a mixed set by name. - Peers are pinned to the exact version. Every package except the CLI needs
@struktjs/coreas a peer, and a tree holds exactly one copy of it. - The CLI stands alone.
@struktjs/clicarries its own engine and every language, so it needs none of the others and is not part of a build id.
A program in Node¶
import { createCore } from "@struktjs/core";
import { loadGrammarPython } from "@struktjs/grammar-python";
import core from "@struktjs/lang-core";
await loadGrammarPython();
const c = await createCore({ packs: [core] });
const model = c.parse("x = 1 + 2\nprint(x)\n", { language: "core" });
console.log(model.check().errors, (await model.run()).output);
Add @struktjs/python-runtime and pass runtime to createCore to run Core programs on real Python instead of the language's own evaluator. Add @struktjs/editor (and @struktjs/widgets, which holds its stylesheet) to edit the same model in a page. Embedding the editor in a web page shows both with the options and the files a page has to serve.
The packages¶
| Package | What it is | Needs | Stability | Tested in |
|---|---|---|---|---|
@struktjs/core |
The headless engine: createCore parses, prints, checks, type-checks, runs and generates models of the languages you give it. Browser and Node 22 or newer, no DOM, no languages of its own. Optionally runs on real Python (runtime). |
nothing | Provisional until 1.0, then Stable | core-alone, core-and-language, core-grammar-language |
@struktjs/grammar-python |
The tree-sitter grammars (Python, JavaScript, TypeScript) and their wasm: loadGrammarPython(). Needed to read model text; not needed to build models as trees. |
@struktjs/core |
Provisional until 1.0, then Stable | core-grammar-language, decision-table, pattern, diagram-language, formula-language, git, lionweb-repository, python-runtime-node, python-runtime-browser, widgets-without-editor, smallest-editor, elk-layout-engine, diagram-editor-without-engine, everything |
@struktjs/editor |
The projectional editor, mountEditor(el, { core }) (browser only). It carries no languages of its own: it edits the ones of the core you pass. |
@struktjs/core, @struktjs/widgets, @struktjs/grammar-python |
Provisional until 1.0, then Stable | lionweb-repository, smallest-editor, elk-layout-engine, diagram-editor-without-engine, everything |
@struktjs/widgets |
The Problems and Results views for a page with no editor, and the stylesheet of the editor and the views (@struktjs/widgets/style.css). |
@struktjs/core |
Provisional until 1.0, then Stable | widgets-without-editor, everything |
@struktjs/diagram |
Optional: the ELK layout engine behind the diagram editor's "Layout Diagram (ELK)" actions (about 2 MB, loaded when first used). Import it once and the editor finds it. | @struktjs/core |
Provisional until 1.0, then Stable | elk-layout-engine, everything |
@struktjs/lionweb |
Keeps an editor's model in a LionWeb repository you run: connectRepository(editor, { url }), then pull and push. |
@struktjs/core |
Provisional until 1.0, then Stable | lionweb-repository, everything |
@struktjs/git |
Structural version control over model source texts, with no git binary and no UI: a tree diff, a three-way merge that reports conflicts, and per-node blame. | @struktjs/core |
Provisional until 1.0, then Stable | git, git-without-grammar |
@struktjs/collab |
Headless collaboration: the AST-to-Yjs mirror and the relay session (host, join, resume), usable from a bot, a server or a test. Secure by default. | @struktjs/core |
Provisional until 1.0, then Stable | collab-headless |
@struktjs/python-runtime |
Real Python execution: createPythonRuntime() for createCore({ runtime }). Pyodide in a page (files shipped in the package), the machine's python3 or Pyodide in Node. |
@struktjs/core |
Provisional until 1.0, then Stable | python-runtime-node, python-runtime-browser |
@struktjs/stubs-python |
Opt-in Python standard-library stubs for completion and types (import os). Only in a package built with --with-stubs; a very large number of lazy files. |
@struktjs/core, @struktjs/grammar-python |
Provisional until 1.0, then Stable | stubs-python |
@struktjs/cli |
The strukts command-line tool (check, generate, test, run, package, an MCP server, a local HTTP service) as a self-contained package with a bin. It carries its own engine and every language, so it shares nothing with the other packages. |
nothing (self-contained) | Stable | cli |
@struktjs/lang-core |
Core, the Python-family language most models and plugins use, with its standard library. | @struktjs/core |
Provisional until 1.0, then Stable | core-and-language, core-grammar-language, git, git-without-grammar, lionweb-repository, python-runtime-node, python-runtime-browser, widgets-without-editor, smallest-editor, elk-layout-engine, diagram-editor-without-engine, everything |
@struktjs/lang-core-decision-table |
Decision tables as a language: rows of conditions and the result each one gives. | @struktjs/core, @struktjs/lang-core |
Provisional until 1.0, then Stable | decision-table |
@struktjs/lang-diagram |
Diagrams and flowcharts as a language. | @struktjs/core, @struktjs/lang-core |
Provisional until 1.0, then Stable | diagram-language, elk-layout-engine, diagram-editor-without-engine, everything |
@struktjs/lang-formula |
Maths formulas as a language (it also brings the diagram and decision-table languages it imports). | @struktjs/core, @struktjs/lang-core, @struktjs/lang-diagram, @struktjs/lang-core-decision-table |
Provisional until 1.0, then Stable | formula-language, everything |
@struktjs/lang-pattern |
The pattern language (a devkit member: it registers no language of its own beside Core). | @struktjs/core, @struktjs/lang-core |
Provisional until 1.0, then Stable | pattern |
Needs lists the packages a package imports from, directly. Installing one means installing what it needs too, and their needs in turn. Tested in names the subsets below that install the package by name.
Subsets that are tested¶
Every row below is installed alone, from the packed tarballs, into an empty directory, and then does what its last column says, including the clear error you get when something is not installed. Adding a package without such a row fails the build, so this table is also the list of what you can add or leave out and still have it work.
| Subset | Installs | What it proves |
|---|---|---|
core-alone |
@struktjs/core |
the headless engine over a language the caller defines: build trees, check, run; no grammar, no language packs, no DOM |
core-and-language |
@struktjs/core, @struktjs/lang-core |
Core as a language over trees (no grammar installed): models built as trees check and run; reading source text says which grammar is missing |
core-grammar-language |
@struktjs/core, @struktjs/grammar-python, @struktjs/lang-core |
source text in, checked and run Core out (Node, no editor) |
decision-table |
@struktjs/lang-core-decision-table, @struktjs/grammar-python |
the decision-table language loads on core + Core |
pattern |
@struktjs/lang-pattern, @struktjs/grammar-python |
the pattern pack (a devkit member: it registers no language of its own) loads on core + Core without disturbing it |
diagram-language |
@struktjs/lang-diagram, @struktjs/grammar-python |
the diagram language loads on core + Core, no editor and no layout engine |
formula-language |
@struktjs/lang-formula, @struktjs/grammar-python |
formula, with the diagram and decision-table languages it imports (the full Node scenario: parse, check, print, run) |
git |
@struktjs/git, @struktjs/grammar-python, @struktjs/lang-core |
structural diff, three-way merge (with conflicts and their resolutions) and per-node blame over model source texts, headless: no git binary, no editor |
git-without-grammar |
@struktjs/git, @struktjs/lang-core |
the same helpers with no grammar installed: reading model text reports that it could not be parsed instead of throwing |
collab-headless |
@struktjs/collab |
a headless peer: two Yjs documents kept in step with an AST through the mirror (a hydrated copy and a remote edit both converge), and the relay URL policy is secure by default and opened only by a settings reader the caller installs |
lionweb-repository |
@struktjs/editor, @struktjs/lionweb, @struktjs/lang-core, @struktjs/grammar-python |
an editor kept in a LionWeb repository: the first push creates the partition and later ones store into it, a second editor pulls the same program, a wrong token is refused and the message says so; none of the other add-ons is installed |
cli |
@struktjs/cli (only in a build that made it) |
the strukts command-line tool installed alone (no other @struktjs package, no checkout): it lists and checks the shipped projects, checks a project folder of its own, and runs a program on Pyodide when the machine has no python |
python-runtime-node |
@struktjs/python-runtime, @struktjs/grammar-python, @struktjs/lang-core |
real Python for a core in Node: createCore({ runtime }) runs a Core program on CPython (Pyodide here, no python on the path needed) where a core without a runtime uses the language's own evaluator; a failing program rejects with Python's error |
python-runtime-browser |
@struktjs/python-runtime, @struktjs/grammar-python, @struktjs/lang-core |
real Python for a core in a page: Pyodide's files come from the package (same origin, no download), createCore({ runtime }) runs a program on CPython in a worker, input() is answered, and a failing program rejects with Python's error |
widgets-without-editor |
@struktjs/widgets, @struktjs/lang-core, @struktjs/grammar-python |
the Problems and Results views over a headless model; no editor package installed |
smallest-editor |
@struktjs/editor, @struktjs/lang-core, @struktjs/grammar-python |
the projectional editor over core + Core, with no layout engine and no other language; without a core it is the clear error |
elk-layout-engine |
@struktjs/diagram, @struktjs/editor, @struktjs/lang-core, @struktjs/lang-diagram, @struktjs/grammar-python |
a diagram editor with the optional layout-engine package: importing it plugs ELK in, and "Layout Diagram (ELK)" fetches the engine only then and lays out without complaint |
diagram-editor-without-engine |
@struktjs/editor, @struktjs/lang-core, @struktjs/lang-diagram, @struktjs/grammar-python |
the same diagram editor without the layout-engine package: "Layout Diagram (ELK)" changes nothing and says which package to add |
everything |
@struktjs/editor, @struktjs/widgets, @struktjs/lionweb, @struktjs/diagram, @struktjs/lang-core, @struktjs/lang-formula, @struktjs/lang-diagram, @struktjs/grammar-python |
every package at once, in a plain page, a Vite build and a TypeScript program |
stubs-python |
@struktjs/stubs-python (only in a build that made it) |
the opt-in Python standard-library stubs: only installed, and only with a package built with --with-stubs |
How stable is each package?¶
Each package has a stability tier, set out in the stability policy. Before 1.0 the documented surface of most packages is Provisional: it may change in a minor release, with a note in the changelog. The command-line tool is Stable from the first release.
Related¶
- Embedding the editor in a web page: the options, the styling and the files a page serves.
- The strukts CLI: the command-line tool, also installable as
@struktjs/cli. - Start here: I run struktJS in a pipeline or a product
- How the packages are built: the plan, the partition of one build into packages, and what each landing verified.