@hydranium/cli 1.0.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +240 -0
- package/heap-analysis/analyze-heap.mjs +798 -0
- package/heap-analysis/heap/core/aggregate.mjs +152 -0
- package/heap-analysis/heap/core/bucket-label.mjs +23 -0
- package/heap-analysis/heap/core/cutpoints.mjs +51 -0
- package/heap-analysis/heap/core/diff.mjs +56 -0
- package/heap-analysis/heap/core/format.mjs +47 -0
- package/heap-analysis/heap/core/holders.mjs +80 -0
- package/heap-analysis/heap/core/load.mjs +46 -0
- package/heap-analysis/heap/core/report.mjs +68 -0
- package/heap-analysis/heap/core/strings.mjs +80 -0
- package/heap-analysis/heap/langium/concepts.mjs +230 -0
- package/heap-analysis/heap/langium/glsp.classifier.mjs +80 -0
- package/heap-analysis/heap/langium/langium.classifier.mjs +203 -0
- package/heap-analysis/heap/renderer/renderer.mjs +122 -0
- package/lib/cli-version.d.ts +21 -0
- package/lib/cli-version.d.ts.map +1 -0
- package/lib/cli-version.js +30 -0
- package/lib/cli-version.js.map +1 -0
- package/lib/cli.d.ts +11 -0
- package/lib/cli.d.ts.map +1 -0
- package/lib/cli.js +135 -0
- package/lib/cli.js.map +1 -0
- package/lib/commands/analyze-heap-args.d.ts +46 -0
- package/lib/commands/analyze-heap-args.d.ts.map +1 -0
- package/lib/commands/analyze-heap-args.js +174 -0
- package/lib/commands/analyze-heap-args.js.map +1 -0
- package/lib/commands/analyze-heap.d.ts +37 -0
- package/lib/commands/analyze-heap.d.ts.map +1 -0
- package/lib/commands/analyze-heap.js +63 -0
- package/lib/commands/analyze-heap.js.map +1 -0
- package/lib/commands/ast-ground-truth-args.d.ts +23 -0
- package/lib/commands/ast-ground-truth-args.d.ts.map +1 -0
- package/lib/commands/ast-ground-truth-args.js +47 -0
- package/lib/commands/ast-ground-truth-args.js.map +1 -0
- package/lib/commands/ast-ground-truth-driver.d.ts +10 -0
- package/lib/commands/ast-ground-truth-driver.d.ts.map +1 -0
- package/lib/commands/ast-ground-truth-driver.js +72 -0
- package/lib/commands/ast-ground-truth-driver.js.map +1 -0
- package/lib/commands/ast-ground-truth.d.ts +31 -0
- package/lib/commands/ast-ground-truth.d.ts.map +1 -0
- package/lib/commands/ast-ground-truth.js +36 -0
- package/lib/commands/ast-ground-truth.js.map +1 -0
- package/lib/commands/generate-transfer-model-args.d.ts +38 -0
- package/lib/commands/generate-transfer-model-args.d.ts.map +1 -0
- package/lib/commands/generate-transfer-model-args.js +183 -0
- package/lib/commands/generate-transfer-model-args.js.map +1 -0
- package/lib/commands/generate-transfer-model-config.d.ts +32 -0
- package/lib/commands/generate-transfer-model-config.d.ts.map +1 -0
- package/lib/commands/generate-transfer-model-config.js +122 -0
- package/lib/commands/generate-transfer-model-config.js.map +1 -0
- package/lib/commands/generate-transfer-model.d.ts +110 -0
- package/lib/commands/generate-transfer-model.d.ts.map +1 -0
- package/lib/commands/generate-transfer-model.js +587 -0
- package/lib/commands/generate-transfer-model.js.map +1 -0
- package/lib/commands/harness-args.d.ts +198 -0
- package/lib/commands/harness-args.d.ts.map +1 -0
- package/lib/commands/harness-args.js +339 -0
- package/lib/commands/harness-args.js.map +1 -0
- package/lib/commands/headless-harness.d.ts +97 -0
- package/lib/commands/headless-harness.d.ts.map +1 -0
- package/lib/commands/headless-harness.js +121 -0
- package/lib/commands/headless-harness.js.map +1 -0
- package/lib/commands/init-args.d.ts +81 -0
- package/lib/commands/init-args.d.ts.map +1 -0
- package/lib/commands/init-args.js +250 -0
- package/lib/commands/init-args.js.map +1 -0
- package/lib/commands/init-prompt.d.ts +66 -0
- package/lib/commands/init-prompt.d.ts.map +1 -0
- package/lib/commands/init-prompt.js +71 -0
- package/lib/commands/init-prompt.js.map +1 -0
- package/lib/commands/init-templates.d.ts +42 -0
- package/lib/commands/init-templates.d.ts.map +1 -0
- package/lib/commands/init-templates.js +1902 -0
- package/lib/commands/init-templates.js.map +1 -0
- package/lib/commands/init-wizard.d.ts +65 -0
- package/lib/commands/init-wizard.d.ts.map +1 -0
- package/lib/commands/init-wizard.js +302 -0
- package/lib/commands/init-wizard.js.map +1 -0
- package/lib/commands/init-workspace.d.ts +168 -0
- package/lib/commands/init-workspace.d.ts.map +1 -0
- package/lib/commands/init-workspace.js +372 -0
- package/lib/commands/init-workspace.js.map +1 -0
- package/lib/commands/init.d.ts +273 -0
- package/lib/commands/init.d.ts.map +1 -0
- package/lib/commands/init.js +303 -0
- package/lib/commands/init.js.map +1 -0
- package/lib/commands/lint-grammar-args.d.ts +23 -0
- package/lib/commands/lint-grammar-args.d.ts.map +1 -0
- package/lib/commands/lint-grammar-args.js +63 -0
- package/lib/commands/lint-grammar-args.js.map +1 -0
- package/lib/commands/lint-grammar-driver.d.ts +10 -0
- package/lib/commands/lint-grammar-driver.d.ts.map +1 -0
- package/lib/commands/lint-grammar-driver.js +72 -0
- package/lib/commands/lint-grammar-driver.js.map +1 -0
- package/lib/commands/lint-grammar-report.d.ts +24 -0
- package/lib/commands/lint-grammar-report.d.ts.map +1 -0
- package/lib/commands/lint-grammar-report.js +65 -0
- package/lib/commands/lint-grammar-report.js.map +1 -0
- package/lib/commands/lint-grammar.d.ts +33 -0
- package/lib/commands/lint-grammar.d.ts.map +1 -0
- package/lib/commands/lint-grammar.js +42 -0
- package/lib/commands/lint-grammar.js.map +1 -0
- package/lib/commands/measure-memory-args.d.ts +23 -0
- package/lib/commands/measure-memory-args.d.ts.map +1 -0
- package/lib/commands/measure-memory-args.js +106 -0
- package/lib/commands/measure-memory-args.js.map +1 -0
- package/lib/commands/measure-memory-driver.d.ts +10 -0
- package/lib/commands/measure-memory-driver.d.ts.map +1 -0
- package/lib/commands/measure-memory-driver.js +110 -0
- package/lib/commands/measure-memory-driver.js.map +1 -0
- package/lib/commands/measure-memory.d.ts +68 -0
- package/lib/commands/measure-memory.d.ts.map +1 -0
- package/lib/commands/measure-memory.js +100 -0
- package/lib/commands/measure-memory.js.map +1 -0
- package/lib/commands/model-docs-args.d.ts +23 -0
- package/lib/commands/model-docs-args.d.ts.map +1 -0
- package/lib/commands/model-docs-args.js +53 -0
- package/lib/commands/model-docs-args.js.map +1 -0
- package/lib/commands/model-docs-driver.d.ts +10 -0
- package/lib/commands/model-docs-driver.d.ts.map +1 -0
- package/lib/commands/model-docs-driver.js +61 -0
- package/lib/commands/model-docs-driver.js.map +1 -0
- package/lib/commands/model-docs-report.d.ts +18 -0
- package/lib/commands/model-docs-report.d.ts.map +1 -0
- package/lib/commands/model-docs-report.js +123 -0
- package/lib/commands/model-docs-report.js.map +1 -0
- package/lib/commands/model-docs.d.ts +30 -0
- package/lib/commands/model-docs.d.ts.map +1 -0
- package/lib/commands/model-docs.js +37 -0
- package/lib/commands/model-docs.js.map +1 -0
- package/lib/commands/projects-args.d.ts +25 -0
- package/lib/commands/projects-args.d.ts.map +1 -0
- package/lib/commands/projects-args.js +49 -0
- package/lib/commands/projects-args.js.map +1 -0
- package/lib/commands/projects.d.ts +45 -0
- package/lib/commands/projects.d.ts.map +1 -0
- package/lib/commands/projects.js +39 -0
- package/lib/commands/projects.js.map +1 -0
- package/lib/commands/query-args.d.ts +25 -0
- package/lib/commands/query-args.d.ts.map +1 -0
- package/lib/commands/query-args.js +46 -0
- package/lib/commands/query-args.js.map +1 -0
- package/lib/commands/query.d.ts +32 -0
- package/lib/commands/query.d.ts.map +1 -0
- package/lib/commands/query.js +29 -0
- package/lib/commands/query.js.map +1 -0
- package/lib/commands/reflect-args.d.ts +23 -0
- package/lib/commands/reflect-args.d.ts.map +1 -0
- package/lib/commands/reflect-args.js +59 -0
- package/lib/commands/reflect-args.js.map +1 -0
- package/lib/commands/reflect-driver.d.ts +10 -0
- package/lib/commands/reflect-driver.d.ts.map +1 -0
- package/lib/commands/reflect-driver.js +66 -0
- package/lib/commands/reflect-driver.js.map +1 -0
- package/lib/commands/reflect-report.d.ts +20 -0
- package/lib/commands/reflect-report.d.ts.map +1 -0
- package/lib/commands/reflect-report.js +127 -0
- package/lib/commands/reflect-report.js.map +1 -0
- package/lib/commands/reflect.d.ts +30 -0
- package/lib/commands/reflect.d.ts.map +1 -0
- package/lib/commands/reflect.js +38 -0
- package/lib/commands/reflect.js.map +1 -0
- package/lib/commands/save-args.d.ts +26 -0
- package/lib/commands/save-args.d.ts.map +1 -0
- package/lib/commands/save-args.js +59 -0
- package/lib/commands/save-args.js.map +1 -0
- package/lib/commands/save.d.ts +38 -0
- package/lib/commands/save.d.ts.map +1 -0
- package/lib/commands/save.js +48 -0
- package/lib/commands/save.js.map +1 -0
- package/lib/commands/validate-args.d.ts +23 -0
- package/lib/commands/validate-args.d.ts.map +1 -0
- package/lib/commands/validate-args.js +60 -0
- package/lib/commands/validate-args.js.map +1 -0
- package/lib/commands/validate-driver.d.ts +10 -0
- package/lib/commands/validate-driver.d.ts.map +1 -0
- package/lib/commands/validate-driver.js +72 -0
- package/lib/commands/validate-driver.js.map +1 -0
- package/lib/commands/validate-report.d.ts +30 -0
- package/lib/commands/validate-report.d.ts.map +1 -0
- package/lib/commands/validate-report.js +87 -0
- package/lib/commands/validate-report.js.map +1 -0
- package/lib/commands/validate.d.ts +34 -0
- package/lib/commands/validate.d.ts.map +1 -0
- package/lib/commands/validate.js +41 -0
- package/lib/commands/validate.js.map +1 -0
- package/lib/commands/watch-args.d.ts +26 -0
- package/lib/commands/watch-args.d.ts.map +1 -0
- package/lib/commands/watch-args.js +59 -0
- package/lib/commands/watch-args.js.map +1 -0
- package/lib/commands/watch.d.ts +75 -0
- package/lib/commands/watch.d.ts.map +1 -0
- package/lib/commands/watch.js +112 -0
- package/lib/commands/watch.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +16 -0
- package/lib/index.js.map +1 -0
- package/lib/log-level.d.ts +39 -0
- package/lib/log-level.d.ts.map +1 -0
- package/lib/log-level.js +47 -0
- package/lib/log-level.js.map +1 -0
- package/lib/package-name.d.ts +33 -0
- package/lib/package-name.d.ts.map +1 -0
- package/lib/package-name.js +37 -0
- package/lib/package-name.js.map +1 -0
- package/lib/spawn-data-server.d.ts +102 -0
- package/lib/spawn-data-server.d.ts.map +1 -0
- package/lib/spawn-data-server.js +154 -0
- package/lib/spawn-data-server.js.map +1 -0
- package/lib/testing/echo-server.d.ts +11 -0
- package/lib/testing/echo-server.d.ts.map +1 -0
- package/lib/testing/echo-server.js +79 -0
- package/lib/testing/echo-server.js.map +1 -0
- package/package.json +105 -0
- package/src/cli-version.ts +32 -0
- package/src/cli.ts +139 -0
- package/src/commands/analyze-heap-args.ts +184 -0
- package/src/commands/analyze-heap.ts +76 -0
- package/src/commands/ast-ground-truth-args.ts +63 -0
- package/src/commands/ast-ground-truth-driver.ts +81 -0
- package/src/commands/ast-ground-truth.ts +49 -0
- package/src/commands/generate-transfer-model-args.ts +203 -0
- package/src/commands/generate-transfer-model-config.ts +128 -0
- package/src/commands/generate-transfer-model.ts +716 -0
- package/src/commands/harness-args.ts +429 -0
- package/src/commands/headless-harness.ts +165 -0
- package/src/commands/init-args.ts +273 -0
- package/src/commands/init-prompt.ts +149 -0
- package/src/commands/init-templates.ts +2037 -0
- package/src/commands/init-wizard.ts +378 -0
- package/src/commands/init-workspace.ts +442 -0
- package/src/commands/init.ts +554 -0
- package/src/commands/lint-grammar-args.ts +79 -0
- package/src/commands/lint-grammar-driver.ts +83 -0
- package/src/commands/lint-grammar-report.ts +74 -0
- package/src/commands/lint-grammar.ts +57 -0
- package/src/commands/measure-memory-args.ts +123 -0
- package/src/commands/measure-memory-driver.ts +128 -0
- package/src/commands/measure-memory.ts +143 -0
- package/src/commands/model-docs-args.ts +69 -0
- package/src/commands/model-docs-driver.ts +68 -0
- package/src/commands/model-docs-report.ts +133 -0
- package/src/commands/model-docs.ts +48 -0
- package/src/commands/projects-args.ts +62 -0
- package/src/commands/projects.ts +76 -0
- package/src/commands/query-args.ts +61 -0
- package/src/commands/query.ts +58 -0
- package/src/commands/reflect-args.ts +75 -0
- package/src/commands/reflect-driver.ts +76 -0
- package/src/commands/reflect-report.ts +138 -0
- package/src/commands/reflect.ts +51 -0
- package/src/commands/save-args.ts +74 -0
- package/src/commands/save.ts +84 -0
- package/src/commands/validate-args.ts +76 -0
- package/src/commands/validate-driver.ts +84 -0
- package/src/commands/validate-report.ts +95 -0
- package/src/commands/validate.ts +58 -0
- package/src/commands/watch-args.ts +74 -0
- package/src/commands/watch.ts +185 -0
- package/src/index.ts +16 -0
- package/src/log-level.ts +49 -0
- package/src/package-name.ts +39 -0
- package/src/spawn-data-server.ts +247 -0
- package/src/testing/echo-server.ts +93 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# `@hydranium/cli`
|
|
2
|
+
|
|
3
|
+
The headless tool surface of the [Hydranium](https://github.com/eclipse-emfcloud/hydranium)
|
|
4
|
+
framework, published as the `hydranium-cli` binary.
|
|
5
|
+
|
|
6
|
+
Install it if you are building a Hydranium language. `init` scaffolds a complete project from one
|
|
7
|
+
invocation; the other twelve subcommands drive an already-built head from a shell or a CI step —
|
|
8
|
+
grammar introspection, headless validation, transfer-model codegen, memory measurement, and
|
|
9
|
+
operations against a spawned data-server.
|
|
10
|
+
|
|
11
|
+
## What it gives you
|
|
12
|
+
|
|
13
|
+
- **`init`** — a buildable project (starter grammar, `create<Name>Services` DI wiring, an LSP +
|
|
14
|
+
data-server launch, `langium-config.json`, build scripts) from one command, or from a wizard that
|
|
15
|
+
echoes the flags it composed.
|
|
16
|
+
- **CI gates that need no editor** — `validate` exits non-zero on a diagnostic; `lint-grammar`
|
|
17
|
+
checks that every concrete cross-reference target carries a name property and that each language
|
|
18
|
+
declares an entry rule.
|
|
19
|
+
- **Grammar introspection** — `reflect` (type hierarchy, terminals, every cross-reference target;
|
|
20
|
+
Markdown or `--json`) and `model-docs` (a navigable Markdown model reference for your own docs).
|
|
21
|
+
- **Codegen** — `generate-transfer-model` turns a Langium-generated AST into a serializable transfer
|
|
22
|
+
model, once or in `--watch`.
|
|
23
|
+
- **Memory and profiling** — `measure-memory`, `ast-ground-truth`, and the memlab-based
|
|
24
|
+
`analyze-heap`.
|
|
25
|
+
- **Data-server operations** — `projects`, `query`, `save` and `watch` spawn a data-server child and
|
|
26
|
+
speak its protocol, printing JSON / NDJSON a script can pipe.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
> **Nothing in `@hydranium/*` is on npm yet**, so every `npx` line below
|
|
31
|
+
> resolves to no package and fails with `E404`. Until the first release the CLI
|
|
32
|
+
> is reachable only from a clone of this repository: run `npm run build`, then
|
|
33
|
+
> substitute `node packages/cli/lib/cli.js` for the `npx …` prefix. Subcommands,
|
|
34
|
+
> flags and output are the same either way.
|
|
35
|
+
|
|
36
|
+
`init` needs no install at all:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx @hydranium/cli init ./my-lang --name MyLang
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For the subcommands you run repeatedly, add it to the project it inspects, or install it globally:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install --save-dev @hydranium/cli
|
|
46
|
+
npm install --global @hydranium/cli
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The framework edges are **peer dependencies** — `@hydranium/core`, `@hydranium/data-server`,
|
|
50
|
+
`@hydranium/langium`, `@hydranium/protocol` and `vscode-jsonrpc` — so the CLI runs the same physical
|
|
51
|
+
copies as the head it inspects (`init` itself needs none of them). The memlab packages
|
|
52
|
+
`analyze-heap` loads are **optional peer dependencies**, so installing this package pulls no browser:
|
|
53
|
+
run `npm install @memlab/core @memlab/heap-analysis` (heavy, ~86 MB) before the first
|
|
54
|
+
`analyze-heap`. Every other subcommand works without them.
|
|
55
|
+
|
|
56
|
+
## Subcommands
|
|
57
|
+
|
|
58
|
+
`hydranium-cli --help` lists them; `hydranium-cli <command> --help` prints one command's own flags.
|
|
59
|
+
|
|
60
|
+
Most subcommands take `--services <module>`: an ESM module exporting a zero-arg
|
|
61
|
+
`createServices(): { shared }` thunk — normally your build's `./lib/services.js`. The head wires its
|
|
62
|
+
own filesystem inside, so the CLI boots it with no arguments.
|
|
63
|
+
|
|
64
|
+
**Scaffolding**
|
|
65
|
+
|
|
66
|
+
- `init <target-dir>` — scaffold a new language project. See the section below.
|
|
67
|
+
|
|
68
|
+
**Grammar and workspace** (`--services <module>`)
|
|
69
|
+
|
|
70
|
+
- `reflect` — dump the grammar/AST reflection: type hierarchy, per-language terminals and entry
|
|
71
|
+
rule, every cross-reference target. `--json`, `--out-file <file>`.
|
|
72
|
+
- `lint-grammar` — check the grammar against framework conventions; non-zero exit on a violation.
|
|
73
|
+
`--name-property <p>` (repeatable), `--strict`, `--json`.
|
|
74
|
+
- `model-docs` — emit a navigable Markdown model reference on stdout, or into `--out-file <file>`.
|
|
75
|
+
- `validate <workspace>` — build a workspace headlessly and report its diagnostics; non-zero exit on
|
|
76
|
+
any error. `--strict` (also fail on warnings), `--json`, `--out-file <file>`.
|
|
77
|
+
- `measure-memory <workspace>` — measure model-store memory in an `--expose-gc` child.
|
|
78
|
+
`--edits <N>`, `--edit-docs <N>`, `--churn-suffix <ext>`, `--settle <ms>`, `--snapshot`,
|
|
79
|
+
`--snapshot-path <p>`, `--profile <dims>`, `--session-out <dir>`, `--json`.
|
|
80
|
+
- `ast-ground-truth <workspace>` — tally the live model's AST nodes by `$type`, the ground truth
|
|
81
|
+
`analyze-heap --validate` checks a snapshot against. `--out-file <file>`.
|
|
82
|
+
|
|
83
|
+
All six also take `--log-level <off|error|warn|info|debug|trace>`, which sets the threshold for the
|
|
84
|
+
head the subcommand boots — not for the CLI itself. It reaches the head through the child's
|
|
85
|
+
environment, so a head that binds a logger of its own decides what the flag means to it.
|
|
86
|
+
|
|
87
|
+
The three `<workspace>` commands resolve that argument to an existing directory before they start —
|
|
88
|
+
a filesystem path or a `file:` URI — and exit 2 naming it when it reaches none. Without that a CI
|
|
89
|
+
step whose path has rotted builds nothing, reports whatever documents the head contributes
|
|
90
|
+
independently of the workspace, and exits 0; the count is a property of the head, so it can be
|
|
91
|
+
plausibly non-zero and cannot be read as the tell.
|
|
92
|
+
|
|
93
|
+
**Codegen**
|
|
94
|
+
|
|
95
|
+
- `generate-transfer-model` — generate a transfer-model TypeScript file from a Langium AST.
|
|
96
|
+
`--ast-file`, `--augmentation-file` and `--out-file` are required, and may come from
|
|
97
|
+
`--config <path>` instead; `--langium-config <path>` derives `--ast-file` from that config's `out`
|
|
98
|
+
directory. `--watch` regenerates on change, and the output-naming flags (`--element-type-name`,
|
|
99
|
+
`--terminals-name`, `--terminals-source-name`, `--skip-type-alias`, `--skip-terminal`,
|
|
100
|
+
`--regen-command`) tune the emitted file.
|
|
101
|
+
|
|
102
|
+
**Heap analysis**
|
|
103
|
+
|
|
104
|
+
- `analyze-heap <snapshot>` — Langium-aware V8 heap-snapshot analysis. Its flags (`--out-file`,
|
|
105
|
+
`--json`, `--diff`, `--validate <gt.json>`, `--renderer`, and the drill-down tuning flags) are
|
|
106
|
+
declared alongside every other subcommand's, so an unrecognised one is rejected rather than
|
|
107
|
+
ignored.
|
|
108
|
+
|
|
109
|
+
**Data-server operations** (`--server "<cmd> [args...]"`)
|
|
110
|
+
|
|
111
|
+
These spawn a data-server child and talk to it over its protocol. All four also take `--cwd <dir>`
|
|
112
|
+
and `--log-level <off|error|warn|info|debug|trace>`.
|
|
113
|
+
|
|
114
|
+
`--server` has to name an entry that puts the **data** protocol on stdio, which for a scaffolded
|
|
115
|
+
project is `lib/data-server-main.js` — `init` emits it, and the `<project-id>-data-server` bin key
|
|
116
|
+
points at it. `lib/main.js` is the editor entry: stdio there carries LSP and the data head is a
|
|
117
|
+
socket whose port is published over the LSP connection, so pointing `--server` at it answers
|
|
118
|
+
`Unhandled method data-server/getProjects` (or, without `--stdio`, exits on "Connection input stream
|
|
119
|
+
is not set"). Pass the workspace as the entry's own argument rather than through `--cwd`: `--cwd`
|
|
120
|
+
re-roots the child, so a relative entry path would resolve against the workspace — the parser
|
|
121
|
+
refuses that combination by name rather than letting the child fail on a bare module-not-found.
|
|
122
|
+
An absolute entry path works with `--cwd`.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
hydranium-cli projects --server "node ./lib/data-server-main.js ./models"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- `projects` — list the projects the server exposes, one JSON envelope per line.
|
|
129
|
+
- `query --uri <uri>` — print that document's envelope as a single JSON line.
|
|
130
|
+
- `save --uri <uri> --content <text|@file>` — update and persist the document; an `@`-prefixed value
|
|
131
|
+
reads the content from a file. `--client-id <id>`. This is the only writing subcommand, and it
|
|
132
|
+
spawns a data server of its own: a workspace has a **single writer**, so pointing it at one an
|
|
133
|
+
editor already has open is two writers and the later write wins. Neither process will see a
|
|
134
|
+
half-written file, but nothing serialises them either, so a lost write is the documented
|
|
135
|
+
outcome rather than a defect — the guarantee, its one exception and what it does not cover are
|
|
136
|
+
in [Status: one process writes a workspace](../../docs/adopting/status.md#one-process-writes-a-workspace).
|
|
137
|
+
- `watch --uri <uri>` — subscribe to document updates and print events as NDJSON until Ctrl-C.
|
|
138
|
+
`--client-id <id>`.
|
|
139
|
+
|
|
140
|
+
## `init` in detail
|
|
141
|
+
|
|
142
|
+
`init` writes a project you can build immediately, and it writes **only inside the target
|
|
143
|
+
directory** — it refuses a non-empty directory without `--force`, and it never edits a surrounding
|
|
144
|
+
manifest (a root `workspaces` entry is printed, not added). It also does **not** run `npm install`
|
|
145
|
+
or `langium generate`; both are printed as next steps.
|
|
146
|
+
|
|
147
|
+
Project options are position-free:
|
|
148
|
+
|
|
149
|
+
- `<target-dir>` and `--name <Name>` are required. `--name` is the PascalCase **project** name and
|
|
150
|
+
drives the shared generated symbols (`<Name>AstReflection`, `<Name>GeneratedSharedModule`).
|
|
151
|
+
- `--heads <list>` picks the protocol heads from `lsp`, `data`, `glsp`; default `lsp,data`. `lsp` is
|
|
152
|
+
mandatory — it owns the workspace, the build pipeline and the shared tier the others read through.
|
|
153
|
+
- `--monorepo` scaffolds a member of the surrounding npm workspace, `--scope <@scope>` sets the npm
|
|
154
|
+
scope, `--public` drops the emitted `"private": true`, `--force` allows a non-empty directory.
|
|
155
|
+
|
|
156
|
+
The emitted manifest carries `files` (`lib`, `src`, `syntaxes`), a derived `description` and
|
|
157
|
+
`keywords`, and an empty `author` for you to fill. It is `"private": true` unless you pass
|
|
158
|
+
`--public`, because it also declares `"license": "UNLICENSED"` — a scaffold cannot pick a licence for
|
|
159
|
+
your project, and a package that grants no rights has no business being publishable to a public
|
|
160
|
+
registry. Choose a licence, then pass `--public`. The wizard asks this on every run rather than
|
|
161
|
+
letting a default settle it. `files` is not cosmetic: without it npm falls back
|
|
162
|
+
to the `.gitignore` the scaffold also writes, which ignores `lib/` — so a publish would ship `main`
|
|
163
|
+
and omit the `bin` targets beside it, and succeed. There is deliberately no `repository`: a scaffold
|
|
164
|
+
cannot know yours, and tooling follows that field rather than merely displaying it.
|
|
165
|
+
|
|
166
|
+
There is one `bin` key per executable entry — `<project-id>` for `src/main.ts`, plus
|
|
167
|
+
`<project-id>-data-server` for `src/data-server-main.ts` when `data` is in `--heads`. Both sources
|
|
168
|
+
begin with a `#!` line, because npm sets the exec bit on a linked target without adding one: a
|
|
169
|
+
first line that is anything else is handed to the shell.
|
|
170
|
+
|
|
171
|
+
Grammar options are **repeatable and order-scoped**: each applies to the `--grammar` it follows.
|
|
172
|
+
|
|
173
|
+
- `--grammar <Name>` — the PascalCase grammar name; pass it once per grammar. Defaults to `--name`.
|
|
174
|
+
- `--extensions <list>` — comma-separated file extensions for that grammar, leading dot optional;
|
|
175
|
+
accumulates. Defaults to the kebab-cased grammar name.
|
|
176
|
+
- `--language-id <id>` — override that grammar's derived routing key.
|
|
177
|
+
- `--diagram` — scaffold a GLSP diagram for that grammar; requires `glsp` in `--heads`.
|
|
178
|
+
|
|
179
|
+
Leave `--name` off on an interactive terminal and `init` prompts instead, then echoes the command it
|
|
180
|
+
composed before running it — so the wizard is a way to reach an `init` command line, not an
|
|
181
|
+
alternative to one. Without a TTY a missing `--name` stays an error, so CI never hangs.
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Scaffold, install, build
|
|
185
|
+
npx @hydranium/cli init ./my-lang --name MyLang
|
|
186
|
+
cd my-lang
|
|
187
|
+
npm install
|
|
188
|
+
npm run build # langium generate + tsc, into lib/
|
|
189
|
+
npm test # the scaffolded DI-composition test
|
|
190
|
+
|
|
191
|
+
# The editor entry: LSP on stdio, every other head on a published socket
|
|
192
|
+
node lib/main.js --stdio
|
|
193
|
+
|
|
194
|
+
# The data head alone, on stdio — the entry the four --server subcommands spawn
|
|
195
|
+
hydranium-cli projects --server "node ./lib/data-server-main.js ./models"
|
|
196
|
+
|
|
197
|
+
# Drive the rest of the CLI against the built factory
|
|
198
|
+
npx hydranium-cli reflect --services ./lib/services.js
|
|
199
|
+
npx hydranium-cli lint-grammar --services ./lib/services.js
|
|
200
|
+
npx hydranium-cli validate --services ./lib/services.js ./models
|
|
201
|
+
npx hydranium-cli model-docs --services ./lib/services.js --out-file model-reference.md
|
|
202
|
+
|
|
203
|
+
# Several grammars, three heads, one of them with a diagram
|
|
204
|
+
npx @hydranium/cli init ./order-flow --name OrderFlow --heads lsp,data,glsp \
|
|
205
|
+
--grammar Domain --grammar Process --diagram \
|
|
206
|
+
--grammar Layout --extensions diagram
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The scaffold wires only the framework defaults. The seams a real language customizes are walked
|
|
210
|
+
beside those defaults in
|
|
211
|
+
[`docs/concepts/framework-vs-adopter.md`](../../docs/concepts/framework-vs-adopter.md).
|
|
212
|
+
|
|
213
|
+
## Entry points
|
|
214
|
+
|
|
215
|
+
This package declares a two-key `exports` map — the root barrel and the CLI
|
|
216
|
+
binary — plus a `main` and a `bin`. The binary key is spelled `./lib/cli.js` and
|
|
217
|
+
carries no bare alias: the pairing rule that gives every subpath a `./lib/` twin
|
|
218
|
+
runs one way only, and a key already spelled that way resolves under both
|
|
219
|
+
resolvers as it stands. A consumer that spawns the binary resolves it by
|
|
220
|
+
specifier, and `bin` offers a shim on `PATH` rather than a path.
|
|
221
|
+
|
|
222
|
+
| Entry | Kind | Contents |
|
|
223
|
+
| ---------------- | ------ | -------------------------------- |
|
|
224
|
+
| `hydranium-cli` | `bin` | The binary — all 13 subcommands. |
|
|
225
|
+
| `@hydranium/cli` | `main` | Programmatic API (see below). |
|
|
226
|
+
|
|
227
|
+
The programmatic surface is the part of the CLI worth calling from your own scripts and tests rather
|
|
228
|
+
than through argv: `spawnDataServer` / `withDataServer` (spawn a data-server child and get a typed
|
|
229
|
+
proxy, with teardown), `generateTransferModel` / `watchTransferModel` (the codegen, as a function),
|
|
230
|
+
and the `runProjects` / `runQuery` / `runSave` / `runWatch` command bodies.
|
|
231
|
+
|
|
232
|
+
## Status
|
|
233
|
+
|
|
234
|
+
Alpha — pre-v0, not yet published. The subcommand surface and the programmatic API are both still
|
|
235
|
+
moving. See the [repository README](../../README.md) for the current status and known limitations.
|
|
236
|
+
|
|
237
|
+
## License
|
|
238
|
+
|
|
239
|
+
`MIT` — see this package's [`LICENSE`](./LICENSE), and the repository
|
|
240
|
+
[`NOTICE.md`](../../NOTICE.md) for third-party notices.
|