@flux-lang/cli 0.1.13 → 0.1.15
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/README.md +23 -180
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,196 +1,39 @@
|
|
|
1
1
|
# @flux-lang/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
1) **What this package is**
|
|
4
|
+
CLI tooling for the Flux score language. It ships the `flux` binary.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
2) **When you use it**
|
|
7
|
+
Use it to parse/check/render documents, preview them locally, or export snapshots.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
- `flux check` – parse + run basic static checks (grids, neighbors, timers).
|
|
9
|
-
- `flux render` – render a Flux document to canonical Render IR.
|
|
10
|
-
- `flux tick` – advance time and render updated IR.
|
|
11
|
-
- `flux step` – advance docsteps and render updated IR.
|
|
12
|
-
|
|
13
|
-
Flux is a small, declarative language for **deterministically evolving documents**. See the main repo for the full IR and language spec.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
Global install:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install -g @flux-lang/cli
|
|
23
|
-
````
|
|
24
|
-
|
|
25
|
-
Project-local (dev) install:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm install --save-dev @flux-lang/cli
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
You can also use `npx` without installing globally.
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## Commands
|
|
36
|
-
|
|
37
|
-
### `flux parse`
|
|
38
|
-
|
|
39
|
-
Parse one or more `.flux` files and print their IR as JSON.
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
flux parse example.flux
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
For a single file, the default output is pretty-printed JSON, e.g.:
|
|
46
|
-
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"meta": {
|
|
50
|
-
"version": "0.1.0",
|
|
51
|
-
"title": "Example"
|
|
52
|
-
},
|
|
53
|
-
"state": {
|
|
54
|
-
"params": []
|
|
55
|
-
},
|
|
56
|
-
"grids": [],
|
|
57
|
-
"rules": []
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Options:
|
|
62
|
-
|
|
63
|
-
* `--ndjson` – emit **one JSON object per line** `{ "file", "doc" }` (always used when parsing multiple files).
|
|
64
|
-
* `--pretty` – always pretty-print JSON (2-space indent).
|
|
65
|
-
* `--compact` – compact JSON with no extra whitespace.
|
|
66
|
-
|
|
67
|
-
You can also read from stdin using `-`:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
cat example.flux | flux parse -
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
> Note: `-` (stdin) can only be used by itself (not mixed with other file paths).
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
### `flux check`
|
|
78
|
-
|
|
79
|
-
Parse `.flux` files and run basic static checks:
|
|
80
|
-
|
|
81
|
-
* Unknown `grid` references in rule scopes.
|
|
82
|
-
* Unsupported `neighbors.*` methods.
|
|
83
|
-
* Obvious runtime timer issues (`timer(...)` amount must be positive).
|
|
84
|
-
* A light `initRuntimeState` smoke-check to catch obviously invalid IR.
|
|
85
|
-
|
|
86
|
-
Basic usage:
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
flux check example.flux
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
If all files are OK:
|
|
93
|
-
|
|
94
|
-
```text
|
|
95
|
-
✓ 1 files OK
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
If some fail, diagnostics go to **stderr** and a summary to **stdout**:
|
|
99
|
-
|
|
100
|
-
```text
|
|
101
|
-
# stderr
|
|
102
|
-
example.flux:0:0: Check error: Rule 'oops' references unknown grid 'notAGrid'
|
|
103
|
-
|
|
104
|
-
# stdout
|
|
105
|
-
✗ 1 of 1 files failed checks
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
#### JSON / NDJSON output
|
|
109
|
-
|
|
110
|
-
You can get machine-readable diagnostics via:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
flux check --json example.flux
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
This emits one JSON line per input file:
|
|
117
|
-
|
|
118
|
-
```json
|
|
119
|
-
{"file":"example.flux","ok":false,"errors":[{"message":"example.flux:0:0: Check error: Rule 'oops' references unknown grid 'notAGrid'"}]}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
### `flux render`
|
|
125
|
-
|
|
126
|
-
Render a `.flux` file to the canonical Render IR JSON:
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
flux render --format ir --seed 123 --time 10 --docstep 2 example.flux
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Key options:
|
|
133
|
-
|
|
134
|
-
* `--format ir` – output the Render IR (required, only format today).
|
|
135
|
-
* `--seed N` – deterministic RNG seed (default: `0`).
|
|
136
|
-
* `--time T` – render time in seconds (default: `0`).
|
|
137
|
-
* `--docstep D` – render docstep index (default: `0`).
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
### `flux tick`
|
|
142
|
-
|
|
143
|
-
Advance time and render updated IR:
|
|
9
|
+
3) **Install**
|
|
144
10
|
|
|
145
11
|
```bash
|
|
146
|
-
|
|
12
|
+
pnpm add -g @flux-lang/cli
|
|
147
13
|
```
|
|
148
14
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
### `flux step`
|
|
152
|
-
|
|
153
|
-
Advance docsteps and render updated IR:
|
|
15
|
+
4) **Basic usage**
|
|
154
16
|
|
|
155
17
|
```bash
|
|
156
|
-
flux
|
|
18
|
+
flux render --format ir examples/viewer-demo.flux --pretty
|
|
157
19
|
```
|
|
158
20
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
{
|
|
165
|
-
"scripts": {
|
|
166
|
-
"flux:parse": "flux parse src/scores/*.flux",
|
|
167
|
-
"flux:check": "flux check src/scores/*.flux"
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
In CI, you can simply run:
|
|
173
|
-
|
|
174
|
-
```bash
|
|
175
|
-
npx flux check src/scores/*.flux
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
and treat a non-zero exit code as a failure.
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## Relationship to `@flux-lang/core`
|
|
183
|
-
|
|
184
|
-
`@flux-lang/cli` is a thin wrapper around `@flux-lang/core`:
|
|
185
|
-
|
|
186
|
-
* `flux parse` calls `parseDocument` and prints the `FluxDocument` AST IR.
|
|
187
|
-
* `flux render` uses `renderDocument` and prints the `RenderDocument` IR.
|
|
188
|
-
* `flux check` uses both the parser and `checkDocument` to validate documents.
|
|
21
|
+
5) **Reference**
|
|
22
|
+
- **Binary**: `flux`
|
|
23
|
+
- **Commands**: `parse`, `check`, `render`, `fmt`, `tick`, `step`, `view`, `edit`, `pdf`, `config`, `new`, `add`
|
|
24
|
+
- **Help**: `flux --help` and `flux <command> --help`
|
|
25
|
+
- **Source**: `src/bin/flux.ts`
|
|
189
26
|
|
|
190
|
-
|
|
27
|
+
6) **How it relates to IR/runtime**
|
|
28
|
+
The CLI parses documents into AST IR, renders canonical Render IR, and drives runtime stepping (docstep/time/seed) for deterministic outputs.
|
|
191
29
|
|
|
192
|
-
|
|
30
|
+
7) **Gotchas & troubleshooting**
|
|
31
|
+
- The CLI launches the Ink UI automatically in TTYs; use `--no-ui` for pure stdout mode.
|
|
193
32
|
|
|
194
|
-
|
|
33
|
+
8) **Versioning / compatibility notes**
|
|
34
|
+
- The CLI reports versions with `flux --version` (CLI, viewer, editor build ID).
|
|
195
35
|
|
|
196
|
-
|
|
36
|
+
9) **Links**
|
|
37
|
+
- Root Flux manual: [`../../README.md`](../../README.md)
|
|
38
|
+
- Examples: [`../../examples/`](../../examples/)
|
|
39
|
+
- CLI source: [`src/`](src/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flux-lang/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "CLI tooling for the Flux score language",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Suarez-Solis",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@flux-lang/
|
|
21
|
-
"@flux-lang/
|
|
22
|
-
"@flux-lang/
|
|
23
|
-
"@flux-lang/cli-
|
|
20
|
+
"@flux-lang/brand": "^0.1.15",
|
|
21
|
+
"@flux-lang/core": "^0.1.15",
|
|
22
|
+
"@flux-lang/cli-core": "^0.1.15",
|
|
23
|
+
"@flux-lang/cli-ui": "^0.1.15"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^22.0.0",
|