@aruzone/aze-forge 0.1.0 → 0.1.1

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 CHANGED
@@ -1,408 +1,235 @@
1
1
  # AzeForge
2
2
 
3
- AzeForge compiles AzeMark into deterministic, self-contained HTML and continuous-layout SVG Artifacts.
4
-
5
- ## Supported syntax
6
-
7
- - AzeMark v1 YAML front matter
8
- - ATX headings such as `# Heading`
9
- - Setext headings
10
- - paragraphs
11
- - plain inline text
12
- - equation directive Blocks (readable aliases plus trusted-local raw LaTeX)
13
-
14
- Readable equation example:
15
-
16
- ```text
17
- :::: equation
18
- id: euler
19
- number: true
20
- align: center
21
-
22
- F(omega) =
23
- integral t=-infinity..infinity of
24
- f(t) exp(-i omega t) dt
25
- ::::
26
- ```
27
-
28
- Header attributes are `id`, `number: true|false`, `align: left|center|right`,
29
- and `syntax: readable|latex` (default `readable`). Readable aliases cover
30
- Greek letters, `sqrt`/`frac`/`root`, `sum`/`product`, `integral`, `limit`,
31
- derivatives, `matrix`, `cases`, and relations/sets; they render through
32
- pinned KaTeX (`0.18.5`, offline `htmlAndMathml`, `trust: false`, bounded,
33
- sanitized). Raw LaTeX is denied by default with
34
- `azeforge.security#raw-latex-disabled` and renders only with
35
- `--allow-raw-latex` on `validate` or `render`:
36
-
37
- ```text
38
- :::: equation
39
- syntax: latex
40
-
41
- \frac{a}{b}
42
- ::::
43
- ```
44
-
45
- Directive envelopes are recovered as `InvalidBlock` values until Plugins are registered. Raw HTML is denied and never rendered as text or markup. Lists, Mermaid, images, and other Markdown constructs are not implemented yet.
3
+ Write once in readable **AzeMark**, publish everywhere: deterministic,
4
+ self-contained **HTML**, **SVG**, **PNG**, and **PDF** from a single Source —
5
+ no build chain, no runtime dependencies in your output.
6
+
7
+ - **Deterministic.** The same Source always produces byte-identical
8
+ Artifacts. Every Artifact carries the content hash of the Document it
9
+ represents, so you can prove what you published.
10
+ - **Self-contained.** Fonts are embedded, scripts are never emitted, and
11
+ Artifacts phone home to nothing. Send the file; it renders as-is.
12
+ - **Fail-closed.** Invalid Sources produce precise, ranged diagnostics
13
+ never a half-written Artifact, never a stack trace.
14
+ - **Offline math.** Equations render through a pinned, sandboxed KaTeX
15
+ bundle. Readable aliases cover Greek, fractions, sums, integrals, limits,
16
+ matrices, and more; raw LaTeX stays denied unless you explicitly opt in.
17
+ - **Diagrams included.** Mermaid flowcharts, GFM-style tables, and callouts
18
+ are first-class Blocks rendered through a pinned browser engine.
46
19
 
47
20
  ## Install
48
21
 
49
- Consumers install the published package; no repo checkout is needed:
50
-
51
22
  ```bash
52
23
  npm install -g @aruzone/aze-forge
53
24
  azeforge --help
54
25
  ```
55
26
 
56
- Prerequisites: Node.js 22 or 24, on Ubuntu or macOS.
57
- Windows support is parked until platform-specific verification lands (see issue #43).
58
- There is no standalone binary: the npm global install is the distribution
59
- path, so the Node prerequisite always applies. A single-file binary would
60
- have to bundle Node plus the pinned browser engine and fonts below, and is
61
- deferred; users re-install for new versions (no auto-update).
62
-
63
- The install downloads the pinned browser engine (Chrome Headless Shell
64
- `152.0.7977.75` into `~/.cache/puppeteer`) via the `puppeteer` postinstall
65
- script, so the installing machine needs network access once. Verify it with
66
- a browser-backed format:
67
-
68
- ```bash
69
- azeforge capabilities --probe --json
70
- azeforge render /tmp/manual.aze.md --output /tmp/manual.svg
71
- ```
72
-
73
- Offline or browser-missing installs stay structured: browser-backed formats
74
- (`svg`, `png`, `pdf`, Mermaid diagrams) fail with exit `1` and a
75
- `azeforge.renderer#browser-unavailable` (or `adapter-missing`) diagnostic
76
- suggesting `Reinstall AzeForge browser dependencies and retry`, never a
77
- stack trace. Plain-HTML rendering without diagrams keeps working. Remedy:
78
- re-install with network access, or fetch only the engine with
79
- `npx puppeteer browsers install chrome-headless-shell@152.0.7977.75`.
80
-
81
- The acceptance gate runs identically against the consumer install by
82
- pointing the runner at the `azeforge` on `PATH`:
27
+ Requires Node.js 22 or 24 on Ubuntu or macOS (Windows support is parked).
28
+ The install fetches a pinned browser engine for diagrams and visual formats;
29
+ on npm 11+ allow its install script once:
83
30
 
84
31
  ```bash
85
- AZEFORGE_CLI=azeforge node scripts/acceptance.mjs
32
+ npm install -g @aruzone/aze-forge --allow-scripts=puppeteer
86
33
  ```
87
34
 
88
- (from a checkout; the runner itself ships in the repo, the CLI under test
89
- is the installed one).
35
+ Details, offline installs, and uninstall live in
36
+ [docs/development.md](docs/development.md#browser-engine-and-offline-installs).
90
37
 
91
- Uninstall:
38
+ ## Try it: your first document
92
39
 
93
- ```bash
94
- npm uninstall -g @aruzone/aze-forge
95
- # optional: remove the downloaded browser engine
96
- rm -rf ~/.cache/puppeteer
97
- ```
98
-
99
- ## Build
100
-
101
- The project requires Node.js 22 or newer.
102
-
103
- Supported releases run on Node.js 22 and 24 (Ubuntu, macOS);
104
- Windows support is parked until platform-specific verification lands (see issue #43).
105
- Canonical HTML/SVG/PNG/PDF golden and visual evidence is built on pinned
106
- Ubuntu x64 with Node 24. `azeforge capabilities --json` reports the exact
107
- support matrix under `runtime`.
40
+ Create a Source file — plain Markdown with a small front matter header:
108
41
 
109
42
  ```bash
110
- npm install
111
- npm run build
112
- ```
113
-
114
- The examples below invoke the built CLI directly:
115
-
116
- ```bash
117
- node dist/cli.js
118
- ```
119
- ## Create a Source file
120
-
121
- ```bash
122
- cat >/tmp/manual.aze.md <<'EOF'
43
+ cat > hello.aze.md <<'EOF'
123
44
  ---
124
45
  azemark: 1
125
- title: Manual AzeForge test
46
+ title: Hello AzeForge
126
47
  author:
127
48
  - Test Author
128
49
  theme: default
129
- outputs:
130
- - html
131
50
  ---
132
51
 
133
52
  # Introduction
134
53
 
135
54
  This document tests the current compiler.
136
-
137
- Results
138
- -------
139
-
140
- The render is deterministic.
141
55
  EOF
142
56
  ```
143
57
 
144
- ## Validate
58
+ Validate it (silence means valid) and render it:
145
59
 
146
60
  ```bash
147
- node dist/cli.js validate /tmp/manual.aze.md
148
- echo $?
61
+ azeforge validate hello.aze.md && echo VALID
62
+ azeforge render hello.aze.md --output hello.html && open hello.html
149
63
  ```
150
64
 
151
- A valid Source produces no stdout or stderr and exits with status `0`.
152
-
153
- Add `--diagnostics json` to `validate` or file-targeted `render` to emit exactly one `azeforge.diagnostics/v1` report on stdout. The package exports `diagnosticsJsonSchema` for JSON Schema 2020-12 validation. Human diagnostics remain on stderr.
154
-
155
- ## Format Source
156
-
157
- ```bash
158
- # Write LF-formatted UTF-8 Source to stdout.
159
- node dist/cli.js format /tmp/manual.aze.md
160
-
161
- # Atomically replace a file.
162
- node dist/cli.js format /tmp/manual.aze.md --write
163
-
164
- # Emit no Source; exit 1 only when formatting is required.
165
- node dist/cli.js format /tmp/manual.aze.md --check
166
-
167
- # Stdin is explicit; `-` is not an alias.
168
- cat /tmp/manual.aze.md | node dist/cli.js format --stdin
169
- ```
170
-
171
- Formatting removes a leading BOM, emits LF line endings, preserves comments,
172
- unknown directive bodies, invalid regions, and denied raw content, and writes
173
- nothing when structural syntax is ambiguous. `--write` rejects stdin, and
174
- `--write` and `--check` cannot be combined.
175
-
176
- ## Render to a file
177
-
178
- ```bash
179
- node dist/cli.js render \
180
- /tmp/manual.aze.md \
181
- --output /tmp/manual.html
182
-
183
- echo $?
184
- open /tmp/manual.html
185
- ```
186
-
187
- A successful render exits with status `0` and atomically replaces `/tmp/manual.html`.
188
-
189
- Use an `.svg` destination or pass `--format svg` to produce SVG2 with an
190
- XHTML `foreignObject`. The SVG records its required `svg2` and
191
- `xhtml-foreign-object` capabilities in Artifact metadata; it does not emit a
192
- fallback format.
193
-
194
- ```bash
195
- node dist/cli.js render \
196
- /tmp/manual.aze.md \
197
- --output /tmp/manual.svg
198
- ```
65
+ ## Try it: equations
199
66
 
200
- Check that the Artifact embeds its fonts and contains no scripts:
67
+ Readable math no LaTeX required:
201
68
 
202
69
  ```bash
203
- grep -o 'data:font/woff2;base64' /tmp/manual.html | sort -u
204
- grep -i '<script' /tmp/manual.html
205
- ```
70
+ cat > equation.aze.md <<'EOF'
71
+ ---
72
+ azemark: 1
73
+ title: Equation check
74
+ ---
206
75
 
207
- The first command prints `data:font/woff2;base64`. The second prints nothing.
76
+ ::::: equation
77
+ id: euler
208
78
 
209
- ## Render to stdout
79
+ F(omega) = integral x=0..infinity of x^2 dx
80
+ :::::
81
+ EOF
210
82
 
211
- ```bash
212
- node dist/cli.js render \
213
- /tmp/manual.aze.md \
214
- --stdout \
215
- --format html \
216
- >/tmp/manual-stdout.html
217
-
218
- cmp /tmp/manual.html /tmp/manual-stdout.html
219
- echo $?
83
+ azeforge render equation.aze.md --output equation.html
220
84
  ```
221
85
 
222
- `cmp` produces no output and exits with status `0`.
223
-
224
- ## Watch a Source
86
+ Need raw LaTeX? It is denied by default and opt-in per command:
225
87
 
226
88
  ```bash
227
- node dist/cli.js watch \
228
- /tmp/manual.aze.md \
229
- --output /tmp/manual.html
89
+ azeforge validate equation.aze.md --allow-raw-latex && echo ALLOWED
230
90
  ```
231
91
 
232
- `watch` compiles immediately, then fully recompiles after coalesced changes to
233
- the Source or its project images. Compiles are serialized; a failed cycle
234
- preserves the last successful Artifact and keeps watching. Add
235
- `--diagnostics json` to stream `azeforge.event/v1` NDJSON records on stdout
236
- instead of human diagnostics on stderr.
237
-
238
- ## Serve a preview
92
+ ## Try it: tables and callouts
239
93
 
240
94
  ```bash
241
- node dist/cli.js serve /tmp/manual.aze.md --port 0
242
- # serve: listening on http://127.0.0.1:62545/ for /tmp/manual.aze.md
243
- ```
95
+ cat > blocks.aze.md <<'EOF'
96
+ ---
97
+ azemark: 1
98
+ title: Blocks
99
+ ---
244
100
 
245
- `serve` binds only loopback (ephemeral port by default) and shows the current
246
- HTML preview or the current diagnostics, never stale content. The preview
247
- wraps the exact Artifact bytes in an unhashable reload shell; only preview,
248
- SSE, and opaque asset routes exist. Stop with `SIGINT` or `SIGTERM`.
101
+ ::::: callout
102
+ variant: note
103
+ title: Determinism note
249
104
 
250
- ## Check deterministic output
105
+ Callout bodies parse ordinary Markdown, including nested equations.
106
+ :::::
251
107
 
252
- ```bash
253
- cp /tmp/manual.html /tmp/manual-first.html
108
+ ::::: table
109
+ caption: Thermal properties
110
+ id: materials
254
111
 
255
- node dist/cli.js render \
256
- /tmp/manual.aze.md \
257
- --output /tmp/manual.html
112
+ | material | density [kg/m^3] | conductivity [W/(m K)] |
113
+ | :--- | :---: | ---: |
114
+ | Aluminum | 2700 | 205 |
115
+ | Steel | 7850 | 50 |
116
+ :::::
117
+ EOF
258
118
 
259
- cmp /tmp/manual-first.html /tmp/manual.html
260
- shasum -a 256 /tmp/manual-first.html /tmp/manual.html
119
+ azeforge render blocks.aze.md --output blocks.html
261
120
  ```
262
121
 
263
- The files must be byte-identical and have the same SHA-256 value.
122
+ ## Try it: diagrams
264
123
 
265
- The HTML also records the semantic content hash:
124
+ Mermaid flowcharts render through the pinned browser engine:
266
125
 
267
126
  ```bash
268
- grep -o 'name="azeforge-content-hash" content="sha256:[^"]*"' \
269
- /tmp/manual.html
270
- ```
271
-
272
- ## Check failure handling
273
-
274
- ```bash
275
- cat >/tmp/invalid.aze.md <<'EOF'
127
+ cat > diagram.aze.md <<'EOF'
276
128
  ---
277
- azemark: 2
129
+ azemark: 1
130
+ title: Diagram
278
131
  ---
279
132
 
280
- This version is unsupported.
281
- EOF
282
-
283
- printf 'previous successful Artifact' >/tmp/preserved.html
133
+ :::::: mermaid
134
+ id: flow
135
+ title: Measurement flow
284
136
 
285
- node dist/cli.js render \
286
- /tmp/invalid.aze.md \
287
- --output /tmp/preserved.html
137
+ flowchart LR
138
+ start[Start] --> inspect[Inspect setup]
139
+ inspect --> done[Done]
140
+ ::::::
141
+ EOF
288
142
 
289
- echo "exit: $?"
290
- cat /tmp/preserved.html
143
+ azeforge render diagram.aze.md --output diagram.html
291
144
  ```
292
145
 
293
- The command reports `azeforge.source#version-unsupported`, exits with status `1`, and leaves the previous Artifact unchanged.
294
-
295
- CLI exit statuses:
146
+ ## Try it: every format and theme
296
147
 
297
- - `0`: the operation succeeded, including warning-only validation
298
- - `1`: an accepted operation failed on Source or component diagnostics
299
- - `2`: arguments or options could not form an operation
300
-
301
- ## Test invalid Source recovery
302
-
303
- Exercise the recovery seam with malformed UTF-8, malformed front matter, duplicate IDs, unknown directives, raw HTML, CRLF, and multi-error Source:
148
+ One Source, four Artifacts, three themes (`default`, `academic`,
149
+ `dark-presentation`):
304
150
 
305
151
  ```bash
306
- node dist/cli.js validate /tmp/bad.aze.md; echo "exit=$?"
307
- node dist/cli.js validate /tmp/bad.aze.md --diagnostics json > /tmp/report.json; echo "exit=$?"
308
- node dist/cli.js render /tmp/bad.aze.md --output /tmp/bad.html --diagnostics json; echo "exit=$?"
152
+ for format in html svg png pdf; do
153
+ azeforge render hello.aze.md --output "hello.${format}"
154
+ done
155
+ azeforge render hello.aze.md --output hello-academic.html --theme academic
309
156
  ```
310
157
 
311
- Exit `2` is reserved for malformed operations (bad flags or arguments). Exit `1` means an accepted operation failed on Source or component diagnostics. Exit `0` with no stdout or stderr means a valid Source.
312
-
313
- Confirm the JSON report is the single finite `azeforge.diagnostics/v1` document on stdout while human diagnostics stay on stderr, and validate it against the exported `diagnosticsJsonSchema` (JSON Schema 2020-12):
158
+ Artifacts embed their fonts and contain no scripts:
314
159
 
315
160
  ```bash
316
- node dist/cli.js render /tmp/bad.aze.md --output /tmp/bad.html --diagnostics json 2>/tmp/stderr.txt | tee /tmp/report.json
317
- test ! -s /tmp/stderr.txt && echo "stderr clean in json mode"
161
+ grep -o 'data:font/woff2;base64' hello.html | sort -u
162
+ grep -i '<script' hello.html || echo "no scripts"
318
163
  ```
319
164
 
320
- Confirm a failed render never commits an Artifact by pre-seeding the destination:
165
+ ## Try it: machine diagnostics
321
166
 
322
- ```bash
323
- echo "last successful Artifact" > /tmp/out.html
324
- node dist/cli.js render /tmp/bad.aze.md --output /tmp/out.html; echo "exit=$?"
325
- grep -qx "last successful Artifact" /tmp/out.html && echo "artifact preserved"
326
- ```
327
-
328
- Probe raw HTML denial, which must report `azeforge.security#raw-html-disabled`, exit `1`, and never render the markup:
167
+ One JSON report on stdout, human text on stderr:
329
168
 
330
169
  ```bash
331
- printf -- '---\nazemark: 1\n---\n\nBefore\n\n<div>\n\nAfter\n' > /tmp/html.aze.md
332
- node dist/cli.js render /tmp/html.aze.md --output /tmp/html.html --diagnostics json
333
- grep -i '<script\|<div' /tmp/html.html || echo "no raw html rendered"
170
+ azeforge validate hello.aze.md --diagnostics json
334
171
  ```
335
172
 
336
- Repeat the probes with CRLF line endings and a BOM prefix; diagnostic ranges, columns, and offsets must still line up in the JSON report.
337
-
338
- ## Automated checks
173
+ Break something and watch it fail closed exit `1`, previous Artifact
174
+ untouched:
339
175
 
340
176
  ```bash
341
- npm run typecheck
342
- npm test
177
+ printf -- '---\nazemark: 2\n---\n\nUnsupported.\n' > invalid.aze.md
178
+ printf 'previous Artifact' > preserved.html
179
+ azeforge render invalid.aze.md --output preserved.html; echo "exit: $?"
180
+ cat preserved.html
343
181
  ```
344
182
 
345
- `npm test` rebuilds `dist/` and runs the full suite (`test/*.test.mjs`).
346
- Bare `node --test` reuses the last build, so rebuild after editing `src/`.
347
- Target one layer while working:
183
+ ## Try it: live rebuild and preview
184
+
185
+ Recompile on every save, or preview in a loopback browser tab:
348
186
 
349
187
  ```bash
350
- npm run build
351
- npm run test:compiler
352
- npm run test:cli
353
- npm run test:matrix
354
- npm run test:browser-smoke
355
- npm run test:canonical-suite
356
- npm run test:canonical
357
- node --test test/equation.test.mjs
188
+ azeforge watch hello.aze.md --output hello.html
189
+ azeforge serve hello.aze.md --port 0
190
+ # serve: listening on http://127.0.0.1:62545/ for hello.aze.md
358
191
  ```
359
192
 
360
- `test:matrix` is the browser-independent unit, schema, and installed-CLI
361
- compatibility seam. `test:browser-smoke` invokes the packaged pinned engine.
362
- `test:canonical-suite` and `test:canonical` own Golden report and visual
363
- evidence and are authoritative only on Ubuntu 24.04 x64 with Node 24.
193
+ `watch` preserves the last successful Artifact through failed cycles; `serve`
194
+ binds loopback only and never shows stale content. Stop either with
195
+ `SIGINT` or `SIGTERM`.
364
196
 
365
- `test/equation.test.mjs` is the equation seam: versioned Blocks, alias
366
- coverage, ranged diagnostics, raw-LaTeX policy, adapter failure modes,
367
- registry rejection, descriptor conformance, and real CLI calls.
197
+ ## Try it: prove determinism
368
198
 
369
- Probe equations by hand:
199
+ Render twice; the bytes — and their hashes — must match exactly:
370
200
 
371
201
  ```bash
372
- cat >/tmp/eq.aze.md <<'EOF'
373
- ---
374
- azemark: 1
375
- title: Equation check
376
- ---
202
+ azeforge render hello.aze.md --output hello-first.html
203
+ azeforge render hello.aze.md --output hello.html
204
+ cmp hello-first.html hello.html && echo IDENTICAL
205
+ shasum -a 256 hello-first.html hello.html
206
+ ```
377
207
 
378
- :::: equation
379
- id: euler
208
+ ## Commands
380
209
 
381
- F(omega) = integral x=0..infinity of x^2 dx
382
- ::::
383
- EOF
210
+ | Command | Purpose |
211
+ | -------------- | ---------------------------------------------------- |
212
+ | `render` | Compile a Source to `html`, `svg`, `png`, or `pdf` |
213
+ | `validate` | Check a Source; silent success, ranged diagnostics |
214
+ | `format` | Canonical LF/UTF-8 formatting (`--write`, `--check`) |
215
+ | `watch` | Recompile on save, preserving last good Artifact |
216
+ | `serve` | Loopback live preview with reload |
217
+ | `capabilities` | Supported commands, formats, engines (`--probe`) |
218
+ | `version` | Tool, runtime, and schema versions (`--json`) |
384
219
 
385
- node dist/cli.js validate /tmp/eq.aze.md && echo VALID
386
- node dist/cli.js render /tmp/eq.aze.md --output /tmp/eq.html
387
- grep -o 'class="katex"\|<math\|<annotation' /tmp/eq.html | sort | uniq -c
388
- ```
220
+ Exit statuses: `0` success (including warning-only validation), `1` the
221
+ operation was accepted but the Source failed, `2` the invocation itself was
222
+ malformed. Run `azeforge <command> --help` for full options.
389
223
 
390
- Probe the raw-LaTeX gate (denied by default, trusted-local opt-in):
224
+ ## Uninstall
391
225
 
392
226
  ```bash
393
- cat >/tmp/raw.aze.md <<'EOF'
394
- ---
395
- azemark: 1
396
- ---
397
-
398
- :::: equation
399
- syntax: latex
227
+ npm uninstall -g @aruzone/aze-forge
228
+ rm -rf ~/.cache/puppeteer # optional: remove the downloaded browser engine
229
+ ```
400
230
 
401
- \frac{a}{b}
402
- ::::
403
- EOF
231
+ ## Contribute
404
232
 
405
- node dist/cli.js validate /tmp/raw.aze.md; echo "exit=$? (expect 1)"
406
- node dist/cli.js validate /tmp/raw.aze.md --allow-raw-latex && echo ALLOWED
407
- node dist/cli.js render /tmp/raw.aze.md --output /tmp/raw.html --allow-raw-latex
408
- ```
233
+ Development setup, the test seams, the acceptance runner, and the release
234
+ process are in [docs/development.md](docs/development.md). AzeForge is
235
+ [MIT](LICENSE)-licensed.
@@ -1,3 +1,3 @@
1
1
  /** Single source of truth for the CLI SemVer reported in every machine envelope. */
2
- export declare const TOOL_VERSION: "0.1.0";
2
+ export declare const TOOL_VERSION: "0.1.1";
3
3
  export type ToolVersion = typeof TOOL_VERSION;
@@ -1,3 +1,3 @@
1
1
  /** Single source of truth for the CLI SemVer reported in every machine envelope. */
2
- export const TOOL_VERSION = "0.1.0";
2
+ export const TOOL_VERSION = "0.1.1";
3
3
  //# sourceMappingURL=tool-version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aruzone/aze-forge",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Deterministic AzeMark compiler: readable source in, self-contained HTML, SVG, PNG, and PDF artifacts out.",
5
5
  "license": "MIT",
6
6
  "repository": {