@openpresentation/cli 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Data-Advantage
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,117 @@
1
+ # @openpresentation/cli
2
+
3
+ A local CLI for agents and people working with `.opf.json` presentations. Create documents, validate them, apply precise edits, paginate content, and inspect the bundled schemas and catalogs. Node 20+ on macOS, Linux, or Windows is required.
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. It does not render slides; successful validation is not visual verification.
6
+
7
+ ## Install the current preview
8
+
9
+ This version is an installable npm tarball, **not yet published to the npm registry**. From the OPF checkout, build and verify it:
10
+
11
+ ```sh
12
+ pnpm install
13
+ pnpm test:cli:packed
14
+ ```
15
+
16
+ That creates `artifacts/cli/openpresentation-cli-0.1.0.tgz`. Install it globally using its absolute path:
17
+
18
+ ```sh
19
+ npm install -g /absolute/path/to/opf/artifacts/cli/openpresentation-cli-0.1.0.tgz
20
+ opf --version
21
+ ```
22
+
23
+ Or install the tarball as a development dependency and use `npx --no-install opf`. For source development, run `pnpm --filter @openpresentation/cli build` and `node packages/cli/dist/index.js --help` from the checkout. Publishing is a separate release step; the package metadata and `opf` binary are ready for it.
24
+
25
+ ## Create and validate
26
+
27
+ ```sh
28
+ opf create decision.opf.json --title "Launch decision"
29
+ opf validate decision.opf.json
30
+ opf create copy.opf.json --from decision.opf.json
31
+ ```
32
+
33
+ Creation supplies a minimal deck with one stable slide ID, `slide-1`. `--title` sets both deck name and visible slide title. `--from` accepts a complete OPF document and preserves its fields; use it to supply arbitrary content, assets, and design options. `--title` and `--from` cannot be combined.
34
+
35
+ Use `-` for stdin/stdout. Creation defaults to stdout if no destination is supplied:
36
+
37
+ ```sh
38
+ opf create - --title "Launch decision" | opf validate -
39
+ opf create imported.opf.json --from - < authored.opf.json
40
+ ```
41
+
42
+ Validation prints the complete result, including errors, warnings, and the input's SHA-256 digest. `--strict` fails when there are warnings, even when `valid` is true. Reference warnings do not cover every possible unresolved reference: free-form layout IDs can pass without warnings.
43
+
44
+ ## Edit with JSON Patch
45
+
46
+ Create `changes.json`:
47
+
48
+ ```json
49
+ [
50
+ { "op": "test", "path": "/slides/0/id", "value": "slide-1" },
51
+ { "op": "replace", "path": "/slides/0/title", "value": "Approve the next milestone" },
52
+ { "op": "add", "path": "/slides/0/text", "value": "Describe the evidence and requested decision here." },
53
+ { "op": "add", "path": "/slides/-", "value": { "id": "next-steps", "title": "Next steps" } }
54
+ ]
55
+ ```
56
+
57
+ Preview the result, save a separate file, or update the source:
58
+
59
+ ```sh
60
+ opf edit decision.opf.json --patch changes.json --dry-run
61
+ opf edit decision.opf.json --patch changes.json --output reviewed.opf.json
62
+ opf edit decision.opf.json --patch changes.json --in-place
63
+ ```
64
+
65
+ The editor implements [JSON Patch (RFC 6902)](https://www.rfc-editor.org/rfc/rfc6902): `add`, `remove`, `replace`, `move`, `copy`, and `test`. Paths are JSON Pointers: `~1` escapes `/`, `~0` escapes `~`, and the empty path addresses the whole document. `add` can insert into arrays or append with `-`; `replace` requires an existing target. It preserves unrelated fields and validates the complete result before writing. An invalid input document can be repaired as long as the final document validates. Failed operations or validation leave the file untouched.
66
+
67
+ With no destination, editing writes the resulting document to stdout. Either the source or patch can come from stdin, but not both. `--dry-run` always writes the candidate document to stdout without saving, even with `--in-place` or `--output`.
68
+
69
+ Use `test` to guard specific values. Resolve a slide ID to its current array index before constructing edits. For a whole-file guard, pass the digest from an earlier `opf validate` result:
70
+
71
+ ```sh
72
+ opf edit decision.opf.json --patch changes.json --in-place --expect-sha256 "$EXPECTED_SHA256"
73
+ ```
74
+
75
+ 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.
76
+
77
+ ## Import CSV and JSON data
78
+
79
+ ```sh
80
+ opf import-data revenue.csv --as table --output table.opf.json
81
+ opf import-data revenue.json --as chart --chart-type line --output chart.opf.json
82
+ opf import-data revenue.csv --as chart --category Quarter --series '["Revenue","Costs"]' --into decision.opf.json --in-place
83
+ ```
84
+
85
+ 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.
86
+
87
+ ## Discover format options
88
+
89
+ ```sh
90
+ opf schemas
91
+ opf schema presentation '/$defs/Composition'
92
+ opf catalogs
93
+ opf catalog layouts
94
+ opf catalog fontSchemes roboto
95
+ ```
96
+
97
+ `schemas` and `catalogs` list available names/kinds. `schema` returns the whole schema or a branch addressed by a pointer into the schema. `catalog` returns all records in a kind, or one exact ID. These commands inspect the bundled version and do not fetch galleries.
98
+
99
+ ```sh
100
+ opf paginate decision.opf.json paginated.opf.json
101
+ ```
102
+
103
+ Pagination emits ordinary OPF slides and a page mapping. Preview the result with the renderer to assess wrapping and visual fidelity.
104
+
105
+ ## Agent output contract
106
+
107
+ - Reports and errors are JSON; only help text is plain text.
108
+ - `validate` reports to stdout, including for invalid documents.
109
+ - Commands emitting a document to stdout send validation diagnostics to stderr, so pipes remain valid JSON.
110
+ - File-writing commands report the absolute output path, output SHA-256, and warnings to stdout.
111
+ - Exit `0`: success, possibly with warnings. Exit `1`: invalid document, failed patch/test, strict warning failure, or file conflict. Exit `2`: usage, malformed JSON, or I/O failure.
112
+ - File-writing commands accept `--strict`. Use `--` before positional filenames that start with `--`.
113
+ - No telemetry, automatic uploads, or execution of instructions inside document text.
114
+
115
+ ## Development checks
116
+
117
+ `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.