@openpresentation/cli 0.9.1 → 0.10.0
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 +64 -6
- package/dist/index.js +28081 -13042
- package/dist/index.js.map +1 -1
- package/package.json +19 -4
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @openpresentation/cli
|
|
2
2
|
|
|
3
|
-
A local CLI for agents and people working with `.opf.json` presentations. Create documents, validate them, apply precise edits, paginate content, bundle catalog references for offline use,
|
|
3
|
+
A local CLI for agents and people working with `.opf.json` presentations. Create documents, validate them, apply precise edits, paginate content, bundle catalog references for offline use, inspect the bundled schemas and catalogs, and render, export (PPTX, PDF, PNG, SVG) and import (PPTX) files. Node 24 on macOS, Linux, or Windows is required.
|
|
4
4
|
|
|
5
|
-
The CLI bundles its OPF schema, catalogs, and validator. It needs no separate core package, API key, or network connection at runtime. `opf --version` reports the CLI and bundled core versions.
|
|
5
|
+
The CLI bundles its OPF schema, catalogs, and validator. It needs no separate core package, API key, or network connection at runtime. `opf --version` reports the CLI and bundled core versions. Validation, lint and editing never render; successful validation is not visual verification. `opf render`, `opf export` and `opf import` use the optional peers `@openpresentation/opf-render` and `@openpresentation/opf-pptx` (see [Render, export and import](#render-export-and-import)).
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -13,9 +13,9 @@ npm install -g @openpresentation/cli
|
|
|
13
13
|
opf --version
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Or install it as a development dependency and use `npx --no-install opf`. CLI 0.
|
|
16
|
+
Or install it as a development dependency and use `npx --no-install opf`. CLI 0.10.0 bundles OPF 0.12.0 (templates and variables, numbered lists, footnotes and captions, chart options, the 0.01 pt font grid; plus the design fields, the 100-layout catalog and the pinned gallery default catalog), including the reference layer (`variables`, ColorRef, payload ids, `opf bundle`), complete code and quote composition, source-preserving pagination and readability floors, styled/merged table cells, shared headers/footers, `opf lint`, and the six OPF agent skills. Browser rendering and editable PowerPoint export require the coordinated library releases documented in [the compatibility matrix](../../docs/compatibility-matrix.md).
|
|
17
17
|
|
|
18
|
-
To verify the standalone package from source, run `pnpm install` and `pnpm test:cli:packed`. This creates `artifacts/cli/openpresentation-cli-0.
|
|
18
|
+
To verify the standalone package from source, run `pnpm install` and `pnpm test:cli:packed`. This creates `artifacts/cli/openpresentation-cli-0.10.0.tgz`, which can be installed using its absolute path. For source development, run `pnpm --filter @openpresentation/cli build` and `node packages/cli/dist/index.js --help`.
|
|
19
19
|
|
|
20
20
|
## Install agent skills
|
|
21
21
|
|
|
@@ -83,6 +83,22 @@ opf edit decision.opf.json --patch changes.json --in-place --expect-sha256 "$EXP
|
|
|
83
83
|
|
|
84
84
|
The digest compares the exact input bytes, including whitespace. The CLI also rechecks the input before replacing that same path. Writes use a temporary sibling file and atomic publication. Existing destinations require `--force`; `--in-place` explicitly authorizes replacing the input. Symlink and non-regular destinations are rejected. Coordinate concurrent writers externally: the hash check and rename are not a filesystem compare-and-swap or a collaboration lock. There is no persistent undo history; use version control or save a separate output when needed.
|
|
85
85
|
|
|
86
|
+
## Diff, merge and format
|
|
87
|
+
|
|
88
|
+
Added in CLI 0.10.0 (RR-31; not in 0.9.2 or earlier): check `opf --help`. These commands are local and deterministic. See [patch, diff, merge and format](../../docs/patch-diff-merge-format.md) for the matching rules, conflict objects and key order.
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
opf diff before.opf.json after.opf.json # readable report
|
|
92
|
+
opf diff before.opf.json after.opf.json --format patch # JSON Patch from before to after
|
|
93
|
+
opf diff a.opf.json b.opf.json --exit-code # exit 1 when they differ
|
|
94
|
+
opf merge base.opf.json ours.opf.json theirs.opf.json --output merged.opf.json
|
|
95
|
+
opf merge base.opf.json ours.opf.json theirs.opf.json --prefer theirs --report conflicts.json --output merged.opf.json
|
|
96
|
+
opf format deck.opf.json --in-place
|
|
97
|
+
opf format decks/*.opf.json --check # CI: exit 1 if any file would change (the shell expands the glob)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`diff` matches slides by `id`, then identical content, then content similarity, and reports additions, removals, moves and field, block, design and metadata changes; `--format json` adds the structured changes and `--format patch` prints only the patch, which `opf edit --patch` applies. `merge` combines two edits of a base: changes in different places merge, and conflicts are listed with the base, our and their values and **block the write** (exit 1, report on stderr) unless `--prefer ours|theirs` picks a side, in which case every conflict is still reported. The merged document is validated before it is written. `format` rewrites a file with canonical key order (the schema's property order), two-space indentation, LF endings (`--eol crlf|preserve`) and one trailing newline; it is idempotent and does not validate. `opf edit`, `diff` and `merge` share one RFC 6902 implementation with the editor.
|
|
101
|
+
|
|
86
102
|
## Import CSV and JSON data
|
|
87
103
|
|
|
88
104
|
```sh
|
|
@@ -93,6 +109,19 @@ opf import-data revenue.csv --as chart --category Quarter --series '["Revenue","
|
|
|
93
109
|
|
|
94
110
|
Data can come from a file or stdin (`-`). JSON accepts arrays of records, row matrices, or `{columns, rows}`. `--path /slides/0/table` replaces or adds a table field inside an existing parent; use `/chart` for charts. With `--into` and no path, a new slide is appended. Other options include `--format csv|tsv|json`, `--delimiter`, `--no-header`, `--columns` (a JSON array), and `--title`. Preview on stdout by omitting an output destination. All file writes validate the complete document. CSV table strings are preserved; chart measures must be numeric. Data is embedded, not linked to the source file.
|
|
95
111
|
|
|
112
|
+
## Fill a template
|
|
113
|
+
|
|
114
|
+
A template is an OPF file with `"template": true` and variables (`{{id}}` tokens and `var:id` references, see [templates and variables](../../docs/templates-and-variables.md)). `opf fill` resolves them from data:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
opf fill quarterly.opf.json --data globex.json --output globex.opf.json # one JSON object, one deck
|
|
118
|
+
opf fill quarterly.opf.json --data clients.csv --out-dir decks --name "qbr-{client}" # one deck per row
|
|
119
|
+
opf fill quarterly.opf.json --data clients.csv --combine --output all.opf.json # one deck, a slide group per row
|
|
120
|
+
opf fill quarterly.opf.json --examples --output preview.opf.json # fill from each variable's example
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
CSV and TSV headers match variable ids and cells coerce per kind (numbers, ISO dates, newline-separated lists); JSON also carries rich text, lists and image objects. A blank cell keeps the declared value. An unfilled required variable or a value of the wrong kind exits 1 before any file is written; `--partial` allows unfilled variables and keeps their declarations for a later pass. `opf validate` accepts a template and reports its unfilled variables.
|
|
124
|
+
|
|
96
125
|
## Discover format options
|
|
97
126
|
|
|
98
127
|
```sh
|
|
@@ -127,10 +156,39 @@ Bundle inlines every bundled catalog record the document references — includin
|
|
|
127
156
|
- File-writing commands accept `--strict`. Use `--` before positional filenames that start with `--`.
|
|
128
157
|
- No telemetry, automatic uploads, or execution of instructions inside document text.
|
|
129
158
|
|
|
159
|
+
## Markdown and outlines
|
|
160
|
+
|
|
161
|
+
`opf from-md <deck.md|-> [output.opf.json|-] [--split <rules|headings>] [--title <text>] [--force] [--strict]` converts Markdown in the OPF dialect (YAML front matter, `---` between slides, `#` title, lists, quotes, tables, `chart`, `metric` and `timeline` fences, `Note:` notes, `<!-- slide: ... -->` options) to a validated deck, and `opf to-md <deck.opf.json|-> [output.md|-] [--drop-unsupported] [--force] [--strict]` writes a deck as that Markdown, which `from-md` reads back unchanged. Both print JSON reports and follow the exit codes above; Markdown errors carry `line` and `column`. Not in releases before the one that lists it in the changelog. See the [Markdown guide](../../docs/markdown.md).
|
|
162
|
+
## Render, export and import
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
npm install -g @openpresentation/cli @openpresentation/opf-render @openpresentation/opf-pptx
|
|
166
|
+
opf render deck.opf.json --slides 1,3-5 --format png --scale 2 --out slides
|
|
167
|
+
opf export deck.opf.json --format pptx # deck.pptx
|
|
168
|
+
opf export deck.opf.json --format pdf --pdf-mode vector
|
|
169
|
+
opf export deck.opf.json --format svg --out slides.zip
|
|
170
|
+
opf import deck.pptx --out deck.opf.json --signals signals.json
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
These commands write files; every other command only prints JSON. They lint the document first and print the `opf lint` report (`diagnostics`, `counts`, exit 1 on errors, `--strict` also on warnings, in which case nothing is written) plus an `outputs` list with each file's SHA-256. Output is deterministic: no network, no system fonts, no clock (`--date` supplies the date for `date: true` fields). Fonts are the renderer's bundled open pack plus the `.ttf`/`.otf` files in each `--font-dir`; relative images are read only from the document's folder (`--asset-dir`); URLs are never fetched. Existing outputs need `--force`.
|
|
174
|
+
|
|
175
|
+
opf-render and opf-pptx are **optional peer dependencies**, loaded the first time a command needs them (beside the CLI first, then in the working directory), so the CLI stays small and dependency-free; a missing peer exits 2 with the install command. `--pdf-mode vector` and `--signals` need renderer and PPTX releases that have them and are refused otherwise. Scripts beyond Latin, Greek and Cyrillic need the renderer's optional Noto script packages (the report names them). The full reference, the report fields and the decisions are in [docs/cli.md](https://github.com/OpenPresentation/opf/blob/main/docs/cli.md).
|
|
176
|
+
|
|
130
177
|
## Development checks
|
|
131
178
|
|
|
132
|
-
`pnpm test:cli` runs command-level regression checks. `pnpm test:cli:packed` builds and packs the CLI, installs the tarball offline into an isolated global prefix, exercises the actual executable, and reruns the same checks against the installation. It does not change your global installation. Package builds bundle their current core dependency; rebuild after schema/catalog changes.
|
|
179
|
+
`pnpm test:cli` runs command-level regression checks, including `test/files.mjs` for render, export and import against the workspace's pinned opf-render and opf-pptx (set `UPDATE_GOLDEN=1` to refresh the pinned SVG digests after a renderer or core bump). `pnpm test:cli:packed:peers` installs the packed CLI with both peers from the npm registry and repeats those checks against the installed binary and through `npm exec`. `pnpm test:cli:packed` builds and packs the CLI, installs the tarball offline into an isolated global prefix, exercises the actual executable, and reruns the same checks against the installation. It does not change your global installation. Package builds bundle their current core dependency; rebuild after schema/catalog changes.
|
|
180
|
+
|
|
181
|
+
## Audit design and accessibility
|
|
182
|
+
|
|
183
|
+
```sh
|
|
184
|
+
opf audit deck.opf.json
|
|
185
|
+
opf audit deck.opf.json --json --fail-on warning
|
|
186
|
+
opf audit deck.opf.json --rule text-contrast --rule missing-alt-text
|
|
187
|
+
opf audit --list-rules
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`opf audit` checks what a schema cannot: text contrast against the resolved background (WCAG 2.x AA, gradients and patterns included), overflow and minimum type size from the shared composition, missing alt text, slide titles, reading order, link text, fonts outside the scheme, placeholder text, low-resolution embedded images and more. Findings use lint's report shape with stable `audit/<rule>` ids, source ranges and suggested fixes; `--json` prints the report, otherwise one readable line per finding. It exits 0 when nothing is at or above `--fail-on` (default `error`), 1 otherwise and 2 for usage errors. It is read-only and fetches nothing. See [the audit guide](../../docs/audit.md).
|
|
133
191
|
|
|
134
192
|
## OPF lint
|
|
135
193
|
|
|
136
|
-
CLI 0.8.0 added `opf lint <file|-> [--config <local-json-file>] [--strict]`; CLI **0.
|
|
194
|
+
CLI 0.8.0 added `opf lint <file|-> [--config <local-json-file>] [--strict]`; CLI **0.10.0** still includes it and bundles core 0.12.0. It reports source ranges, schema constraints, local catalog alternatives, asset registry errors and explicit design contracts without modifying the document or fetching resources. JSON reports include source/configuration hashes and distinguish structural checks from unperformed layout/font/native checks. Earlier CLI versions than 0.8.0 do not include this command. See [the lint guide](../../docs/lint.md).
|