@nexart/cli 0.2.3 → 0.3.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,6 +1,6 @@
1
- # @nexart/cli v0.2.3
1
+ # @nexart/cli v0.3.1
2
2
 
3
- Command-line interface for NexArt CodeMode — run, replay, and verify deterministic generative art.
3
+ Command-line interface for NexArt — run, replay, and verify deterministic generative art, plus AI execution certification commands.
4
4
 
5
5
  ## Installation
6
6
 
@@ -76,14 +76,11 @@ npx @nexart/cli replay out.snapshot.json --out replay.png
76
76
 
77
77
  ## Overview
78
78
 
79
- The CLI renders Code Mode sketches via a **remote canonical renderer** and creates verifiable snapshots.
79
+ The CLI has two command groups:
80
80
 
81
- **v0.2.2 features:**
82
- - Authenticated remote rendering with API keys
83
- - Real PNG output via remote renderer
84
- - Snapshot v1 format with SHA-256 hashing
85
- - Verify and replay commands
86
- - Optional code embedding in snapshots
81
+ **Code Mode commands** — render generative art sketches, create verifiable snapshots, replay and verify them.
82
+
83
+ **AI certification commands** — create, certify, and verify tamper-evident Canonical Execution Records (CERs) for AI operations via the NexArt node API.
87
84
 
88
85
  ## Authentication
89
86
 
@@ -97,7 +94,7 @@ export NEXART_RENDERER_ENDPOINT=https://nexart-canonical-renderer-production.up.
97
94
  export NEXART_API_KEY=nx_live_your_key_here
98
95
 
99
96
  # Run with authentication
100
- npx @nexart/cli@0.2.2 run sketch.js --seed 12345 --include-code --out out.png
97
+ npx @nexart/cli run sketch.js --seed 12345 --include-code --out out.png
101
98
  ```
102
99
 
103
100
  ### API Key Options
@@ -122,7 +119,7 @@ If authentication fails:
122
119
 
123
120
  ## Commands
124
121
 
125
- ### Run
122
+ ### run
126
123
 
127
124
  Execute a sketch and create a snapshot:
128
125
 
@@ -155,7 +152,7 @@ nexart run sketch.js --renderer local
155
152
  - `render.png` — The rendered image
156
153
  - `render.snapshot.json` — Snapshot for replay/verify
157
154
 
158
- ### Verify
155
+ ### verify
159
156
 
160
157
  Check that a snapshot produces the expected output:
161
158
 
@@ -170,7 +167,7 @@ nexart verify render.snapshot.json --code sketch.js
170
167
  - `0` — PASS (hashes match)
171
168
  - `1` — FAIL (hashes differ or error)
172
169
 
173
- ### Replay
170
+ ### replay
174
171
 
175
172
  Re-execute from a snapshot:
176
173
 
@@ -181,6 +178,165 @@ nexart replay render.snapshot.json --out replay.png
181
178
  nexart replay render.snapshot.json --code sketch.js --out replay.png
182
179
  ```
183
180
 
181
+ ---
182
+
183
+ ## AI Certification Commands (`nexart ai`)
184
+
185
+ These commands interact with the NexArt node API to manage Canonical Execution Records (CERs) for AI operations. CERs are tamper-evident bundles that cryptographically certify an AI execution (input, output, model, parameters).
186
+
187
+ ### Environment Variables
188
+
189
+ | Variable | Description |
190
+ |----------|-------------|
191
+ | `NEXART_NODE_ENDPOINT` | NexArt node API URL (default: `https://node.nexart.art`) |
192
+ | `NEXART_API_KEY` | Shared API key for authenticated requests |
193
+
194
+ ### `nexart ai create`
195
+
196
+ Create a CER bundle from an AI execution record.
197
+
198
+ ```bash
199
+ # From file
200
+ nexart ai create execution.json
201
+
202
+ # From stdin
203
+ cat execution.json | nexart ai create
204
+
205
+ # With explicit endpoint and API key
206
+ nexart ai create execution.json \
207
+ --endpoint https://node.nexart.art \
208
+ --api-key nx_live_...
209
+
210
+ # Save to file
211
+ nexart ai create execution.json --out cer.json
212
+ ```
213
+
214
+ **Input format** (JSON file or stdin):
215
+ ```json
216
+ {
217
+ "executionId": "exec-001",
218
+ "provider": "openai",
219
+ "model": "gpt-4o",
220
+ "input": "What is 2+2?",
221
+ "output": "4",
222
+ "parameters": { "temperature": 0 }
223
+ }
224
+ ```
225
+
226
+ **Output:** CER bundle JSON printed to stdout (or saved via `--out`).
227
+
228
+ **Options:**
229
+ | Flag | Default | Description |
230
+ |------|---------|-------------|
231
+ | `--endpoint` | env/`https://node.nexart.art` | NexArt node URL |
232
+ | `--api-key` | env | API key |
233
+ | `--out` | stdout | Save bundle to file |
234
+
235
+ **Exit codes:**
236
+ - `0` — Success
237
+ - `1` — API error or missing input
238
+
239
+ ### `nexart ai certify`
240
+
241
+ Certify an AI execution and receive an attested CER bundle. The node API signs the bundle and attaches an attestation.
242
+
243
+ ```bash
244
+ # From file
245
+ nexart ai certify execution.json
246
+
247
+ # From stdin
248
+ cat execution.json | nexart ai certify
249
+
250
+ # JSON output (machine-readable)
251
+ nexart ai certify execution.json --json
252
+
253
+ # Save output
254
+ nexart ai certify execution.json --out certified.json
255
+ ```
256
+
257
+ **Default output:**
258
+ ```
259
+ [nexart] CER certified successfully
260
+ bundleType : cer.ai.execution.v1
261
+ hash : sha256:a1b2c3...
262
+ attestation: present
263
+ ```
264
+
265
+ **JSON output** (`--json`):
266
+ ```json
267
+ {
268
+ "ok": true,
269
+ "bundleType": "cer.ai.execution.v1",
270
+ "certificateHash": "sha256:a1b2c3...",
271
+ "hasAttestation": true,
272
+ "bundle": { ... }
273
+ }
274
+ ```
275
+
276
+ **Options:**
277
+ | Flag | Default | Description |
278
+ |------|---------|-------------|
279
+ | `--endpoint` | env/`https://node.nexart.art` | NexArt node URL |
280
+ | `--api-key` | env | API key |
281
+ | `--out` | stdout | Save bundle to file |
282
+ | `--json` | false | Machine-readable JSON output |
283
+
284
+ **Exit codes:**
285
+ - `0` — Certified successfully
286
+ - `1` — API error (e.g. 401 Unauthorized), missing input, or invalid response
287
+
288
+ ### `nexart ai verify`
289
+
290
+ Verify a CER bundle locally. No network call — computes and compares the `certificateHash` against the bundle contents.
291
+
292
+ ```bash
293
+ # From file
294
+ nexart ai verify cer.json
295
+
296
+ # From stdin
297
+ cat cer.json | nexart ai verify
298
+
299
+ # JSON output
300
+ nexart ai verify cer.json --json
301
+ ```
302
+
303
+ **Default output (PASS):**
304
+ ```
305
+ [nexart] CER verification: PASS
306
+ bundleType : cer.ai.execution.v1
307
+ hash : sha256:a1b2c3...
308
+ attestation: present
309
+ ```
310
+
311
+ **Default output (FAIL):**
312
+ ```
313
+ [nexart] CER verification: FAIL
314
+ reason : hash mismatch
315
+ expected : sha256:a1b2c3...
316
+ computed : sha256:d4e5f6...
317
+ ```
318
+
319
+ **JSON output** (`--json`):
320
+ ```json
321
+ {
322
+ "ok": true,
323
+ "bundleType": "cer.ai.execution.v1",
324
+ "certificateHash": "sha256:a1b2c3...",
325
+ "hasAttestation": true
326
+ }
327
+ ```
328
+
329
+ **Options:**
330
+ | Flag | Default | Description |
331
+ |------|---------|-------------|
332
+ | `--json` | false | Machine-readable JSON output |
333
+
334
+ **Exit codes:**
335
+ - `0` — PASS (hash matches)
336
+ - `1` — FAIL (hash mismatch or invalid bundle)
337
+
338
+ ---
339
+
184
340
  ## Remote Renderer
185
341
 
186
342
  The CLI calls a canonical Node.js renderer endpoint for real PNG generation.
@@ -272,7 +428,8 @@ Real local/offline rendering is planned for a future release.
272
428
  | Variable | Description |
273
429
  |----------|-------------|
274
430
  | `NEXART_RENDERER_ENDPOINT` | Remote renderer URL (default: http://localhost:5000) |
275
- | `NEXART_API_KEY` | API key for authenticated rendering |
431
+ | `NEXART_NODE_ENDPOINT` | NexArt node API URL (default: https://node.nexart.art) |
432
+ | `NEXART_API_KEY` | API key for authenticated requests |
276
433
 
277
434
  ## License
278
435
 
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @nexart/cli v0.3.0 — AI command tests
3
+ *
4
+ * Tests:
5
+ * A) canonicalJson + computeBundleHash (unit)
6
+ * B) readInputJson — file input
7
+ * C) readInputJson — stdin input
8
+ * D) aiCreateCommand — request/response
9
+ * E) aiCertifyCommand — summary output
10
+ * F) aiCertifyCommand — --json output
11
+ * G) aiVerifyCommand — PASS
12
+ * H) aiVerifyCommand — FAIL (tampered hash)
13
+ * I) aiVerifyCommand — FAIL (wrong bundleType)
14
+ * J) aiVerifyCommand — attestation present/absent
15
+ * K) aiVerifyCommand — --json output
16
+ * L) backward compat — Code Mode exports exist
17
+ * M) callNodeApi — sets Authorization header and sends body
18
+ * N) aiCreateCommand — stdin input
19
+ * O) aiCertifyCommand — stdin input
20
+ * P) aiCreateCommand — saves --out file
21
+ * Q) aiCertifyCommand — 401 handling
22
+ */
23
+ export {};
24
+ //# sourceMappingURL=ai.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/ai.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG"}