@everfir/az8-cli 0.1.1 → 0.2.0-preview.2

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/package.json CHANGED
@@ -1,30 +1,46 @@
1
1
  {
2
2
  "name": "@everfir/az8-cli",
3
- "version": "0.1.1",
4
- "description": "Read-only Project Canvas inspection CLI for AZ8 Studio.",
3
+ "version": "0.2.0-preview.2",
4
+ "description": "Semantic Project Canvas client for AZ8 Studio agents.",
5
+ "license": "UNLICENSED",
5
6
  "type": "module",
6
7
  "files": [
7
- "dist"
8
+ "dist",
9
+ "skills",
10
+ "CHANGELOG.md",
11
+ "RELEASE.md"
8
12
  ],
9
13
  "bin": {
10
14
  "az8": "dist/main.js"
11
15
  },
12
16
  "main": "./dist/main.js",
13
17
  "publishConfig": {
14
- "access": "public"
18
+ "access": "public",
19
+ "tag": "preview"
15
20
  },
16
21
  "scripts": {
17
- "build": "rm -rf dist && esbuild src/main.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/main.js",
22
+ "build": "rm -rf dist && esbuild src/main.ts --bundle --platform=node --format=esm --target=node20 --banner:js='import { createRequire } from \"node:module\"; const require = createRequire(import.meta.url);' --outfile=dist/main.js",
18
23
  "dev": "tsx src/main.ts",
19
24
  "start": "node dist/main.js",
20
25
  "typecheck": "tsc -p tsconfig.json --noEmit",
21
26
  "lint": "biome check .",
22
- "test": "tsx --test src/**/*.test.ts"
27
+ "prepack": "pnpm build",
28
+ "prepublishOnly": "pnpm release:check",
29
+ "release:check": "pnpm test && pnpm typecheck && node scripts/verify-package.js",
30
+ "release:pack": "node scripts/verify-package.js --output-dir ../../tmp/az8-cli-release --keep-install",
31
+ "release:smoke": "node scripts/smoke-test.js",
32
+ "test": "tsx --tsconfig tsconfig.test.json --test src/**/*.test.ts"
23
33
  },
24
34
  "devDependencies": {
25
35
  "@types/node": "^25.5.0",
36
+ "@workspace/account-profile": "workspace:*",
37
+ "@workspace/foundation-data": "workspace:*",
38
+ "@workspace/project-canvas-document": "workspace:*",
26
39
  "@workspace/project-canvas-runtime": "workspace:*",
40
+ "@workspace/project-content": "workspace:*",
41
+ "@workspace/project-management": "workspace:*",
27
42
  "@workspace/typescript-config": "workspace:*",
43
+ "@workspace/workflow-runtime": "workspace:*",
28
44
  "esbuild": "^0.27.7",
29
45
  "tsx": "^4.21.0",
30
46
  "typescript": "^6.0.3",
@@ -32,5 +48,8 @@
32
48
  },
33
49
  "engines": {
34
50
  "node": ">=20"
51
+ },
52
+ "dependencies": {
53
+ "file-type": "^21.3.4"
35
54
  }
36
55
  }
@@ -0,0 +1,278 @@
1
+ ---
2
+ name: az8-cli
3
+ description: Use AZ8 CLI to safely select or create Projects, inspect and author Project Canvases, run generation workflows, transfer media, and participate as a persistent collaborative agent. Use whenever a task asks an agent to read, create, edit, organize, generate, upload, or download content in AZ8 Studio.
4
+ ---
5
+
6
+ # Use AZ8 CLI
7
+
8
+ Treat `az8` as a semantic AZ8 Studio client, not as a document editor or generic backend client.
9
+ Follow this guide before the first Project Canvas action in a new environment. Query runtime
10
+ capabilities instead of guessing operation names or input shapes.
11
+
12
+ ## Contract
13
+
14
+ - Use only public `az8 projects` and `az8 canvas` commands. Never mutate backend records, Yjs,
15
+ Collaborative Document fields, Core Node payloads, or Project Content bindings directly.
16
+ - Explicitly select `test` or `production`. Never infer authorization to write production data.
17
+ - Read the relevant Canvas facts before planning a write. Submit one semantic Operation at a time.
18
+ - Treat every accepted write as a blocker: wait for its terminal Receipt before issuing any later
19
+ query or Operation.
20
+ - A sequence is ordered but not transactional. Stop immediately after the first failure or
21
+ indeterminate result; do not execute later steps.
22
+ - Never automatically retry a write. Retry only bounded reads when the returned error says doing so
23
+ is safe. An idempotency key does not authorize blind replay.
24
+ - Keep tokens in the process environment or an ignored env file. Never put a token in argv, an
25
+ stdio frame, a prompt, a log, or output.
26
+
27
+ ## Concepts
28
+
29
+ - **Project** is the collaboration and permission boundary. Create, list, get, and rename Projects
30
+ through `az8 projects`.
31
+ - **Project Canvas** is the synchronized creative surface inside one Project. A persistent client
32
+ has its own connection, lifecycle, projection, History, Receipt Log, and Awareness identity.
33
+ - **View Node** is a Canvas placement: note, group, or resource target with position, size, parent,
34
+ stacking, Draft, and presentation state.
35
+ - **Core Node** is immutable or server-owned creative content such as an image, video, or audio.
36
+ Resource View Nodes resolve Core Nodes through Project Content. Do not manufacture Core Nodes or
37
+ bindings.
38
+ - **Project Content** is the authority that associates a View Node target with its effective Core
39
+ Node output. Assets are a separate organization of Core Nodes and are not implemented here.
40
+ - **Workflow Definition** describes a generation capability and its current input contract.
41
+ **Workflow Run** is one server-side generation execution.
42
+ - **Operation** is one validated business interaction. **Command** is its internal mutation
43
+ boundary and is never caller-accessible.
44
+ - **Receipt** is the append-only record of one attempted Operation. It reports identity, ordering,
45
+ outcome, revisions, and optional usage. It is not Canvas History.
46
+ - **History** contains reversible local interactions. Only Operations advertised as `undoable`
47
+ participate. A generation start is a History barrier and is not undone by `undo`.
48
+ - **Awareness** is ephemeral presence, client name, and Attention Cursor information. It never
49
+ grants authority, changes persisted authorship, or proves a business result.
50
+ - **Actor** is the authenticated account from `AZ8_TOKEN`. A client or awareness name cannot
51
+ impersonate another author.
52
+
53
+ ## Bootstrap
54
+
55
+ 1. Verify the installed client and explicitly choose an environment:
56
+
57
+ ```bash
58
+ az8 --version
59
+ export AZ8_ENVIRONMENT=test
60
+ export AZ8_TOKEN=...
61
+ ```
62
+
63
+ Prefer an ignored `.env.local` when the shell environment is not appropriate. Never print the
64
+ token to confirm it.
65
+
66
+ 2. Select an existing Project or create a bounded workspace:
67
+
68
+ ```bash
69
+ az8 projects list --scope owned
70
+ az8 projects get <project-id>
71
+ az8 projects create --name "Agent workspace"
72
+ ```
73
+
74
+ Retain the returned Project ID. Confirm the authenticated role before assuming write access.
75
+
76
+ 3. Discover the effective surface for that Project:
77
+
78
+ ```bash
79
+ az8 canvas query <project-id> capabilities.summary
80
+ az8 canvas query <project-id> capabilities.detail
81
+ az8 canvas query <project-id> canvas.summary
82
+ ```
83
+
84
+ `capabilities.summary` is the short menu. `capabilities.detail` is authoritative for exact JSON
85
+ Schema, `effect`, `history`, `completion`, and `retry`. Availability is filtered by the current
86
+ account, Project role, upstream services, and CLI version. Do not rely on remembered schemas.
87
+
88
+ 4. Use `canvas.detail` only when exact node geometry, Draft, status, or bindings are needed:
89
+
90
+ ```bash
91
+ az8 canvas query <project-id> canvas.detail --view-node-id <view-node-id>
92
+ ```
93
+
94
+ 5. Choose one-shot for independent tasks and persistent stdio for a collaborative session. Finish
95
+ by inspecting the affected View Nodes or Workflow Run rather than trusting visual assumptions.
96
+
97
+ ## Interaction modes
98
+
99
+ Use one-shot commands for a self-contained query, write, upload, or download:
100
+
101
+ ```bash
102
+ printf '%s\n' '{"text":"Idea","position":{"x":160,"y":160}}' |
103
+ az8 canvas operation <project-id> createNote --input-stdin --request-id create-note-1
104
+ ```
105
+
106
+ - Supply Operation input through exactly one of `--input-stdin`, `--input-file`, or `--input-json`.
107
+ - Give every write attempt a meaningful unique `--request-id` and retain its returned Receipt.
108
+ - Each invocation opens, hydrates, executes, and closes a real Canvas client.
109
+ - One-shot processes do not preserve local History, Receipt Log, Awareness, or request replay.
110
+ Therefore `undo`, `redo`, `receipts.summary`, and `receipt.detail` require persistent stdio.
111
+
112
+ Use persistent stdio when multiple ordered interactions, live synchronization, History, Receipt
113
+ lookup, observations, or human collaboration matter:
114
+
115
+ ```bash
116
+ az8 canvas open <project-id> --write --format ndjson
117
+ ```
118
+
119
+ 1. Continuously drain stdout; it is an ordered NDJSON protocol stream and may apply backpressure.
120
+ 2. Read `hello`, select protocol `1.0`, then send `initialize` for the same Project ID.
121
+ 3. Wait for `ready` before any query or Operation.
122
+ 4. Keep exactly one reader for stdout. Parse each frame by `type`, `requestId`, and `streamSeq`.
123
+ 5. Use `compact` observations by default. Query `awareness.detail` when cursor context is needed;
124
+ cursor coordinates are intentionally not streamed.
125
+ 6. On an observation gap, query summary/detail and rebuild the local view.
126
+ 7. Send `shutdown` and wait for ordered completion. EOF or a signal is emergency cleanup, not a
127
+ cancellation or rollback mechanism.
128
+
129
+ Protocol truth is written to stdout. stderr contains diagnostics only. Unknown optional fields are
130
+ additive; ignore them. Do not treat a process exit code as the result of the last persistent request.
131
+
132
+ ## Canvas SOP
133
+
134
+ 1. Query `canvas.summary`; query selected details only as needed.
135
+ 2. Query `capabilities.detail` and validate the planned Operation input against its schema.
136
+ 3. Pick explicit absolute Canvas coordinates. Public move positions remain absolute even for group
137
+ children.
138
+ 4. Submit one Operation with a new request ID and wait for its terminal Receipt.
139
+ 5. Confirm the Receipt outcome and affected IDs, then query the changed View Node when subsequent
140
+ work depends on its exact state.
141
+ 6. Only then plan the next interaction.
142
+
143
+ Common capabilities include notes, move/resize/rename, duplicate/remove, groups and stacking, Core
144
+ Node placement, and media targets. The runtime catalog is authoritative. Group nodes cannot nest;
145
+ stacking applies only among siblings. Unsupported World, Decoration, Asset, alignment, and automatic
146
+ layout behavior must not be simulated through lower-level writes.
147
+
148
+ Use `undo` or `redo` only in the same persistent session and only after checking History semantics
149
+ in capability detail. Silent edits are valid Web-equivalent interactions but do not create History
150
+ entries. Never use compensating low-level mutations to imitate undo.
151
+
152
+ ## Generation
153
+
154
+ Generation is an explicit sequence, never one transaction:
155
+
156
+ 1. Create a target with `createMediaTarget` and retain its View Node ID.
157
+ 2. Call the read-only `planGeneration` Operation with the target, prompt, and any references. Use
158
+ `detail: "detail"` when configuration fields or dynamic enum options are needed.
159
+ 3. If the plan reports blocking issues, resolve them and plan again. Do not execute a non-ready
160
+ plan.
161
+ 4. Execute `plan.operations` exactly in order, one Operation at a time. Each step revalidates
162
+ current facts. Stop after the first non-success.
163
+ 5. `startGeneration` succeeds when the Workflow Run is accepted and immediate Canvas effects are
164
+ acknowledged. This completes the start interaction; it does not mean generation finished.
165
+ 6. Retain the Workflow Run ID. Use `waitWorkflowRun` when waiting is useful, or `getWorkflowRun`
166
+ later. An observation-window timeout while the authoritative Run remains pending/running is an
167
+ ordinary read outcome and does not cancel the Run or take a healthy context offline.
168
+ 7. On terminal success, query the target detail and resolve its current output Core Node through
169
+ Project Content before downloading or placing it elsewhere.
170
+
171
+ Workflow Definitions change over time. Query `workflowDefinitions.summary`, then
172
+ `workflowDefinition.detail` only when planning detail is insufficient. Never guess a Definition,
173
+ configuration option, modality, cost, or media compatibility from its display name.
174
+
175
+ The start Receipt may report `usage.credits.status` as `estimated`, `not-consumed`, or `unknown`.
176
+ Estimated cost is informational, not final charged usage. There is no second confirmation. Never
177
+ claim actual credit consumption from an estimate.
178
+
179
+ ## Media
180
+
181
+ For a local image, video, or audio file, use the semantic upload wrapper:
182
+
183
+ ```bash
184
+ az8 canvas upload <project-id> \
185
+ --file ./reference.png \
186
+ --idempotency-key reference-image-1 \
187
+ --name "Reference image" \
188
+ --position-x 640 --position-y 160
189
+ ```
190
+
191
+ - Use a stable logical idempotency key for that exact file intent. Conflicting key reuse is an
192
+ error. Replay only after inspecting and reconciling the prior attempt.
193
+ - Let the CLI inspect bytes, MIME, size, and checksum and let the server create the Core Node and
194
+ binding. Do not supply a claimed media type, upload URL, Core Node ID, or Project Content record.
195
+ - A known failure may leave one inspectable `failed` View Node. An unknown response leaves it
196
+ `pending` and isolates the context; do not create a replacement until reconciliation.
197
+
198
+ Use `importExternalMedia` only for a deliberate public HTTP(S) media URL. It references that URL; it
199
+ does not upload bytes or add content to an Asset.
200
+
201
+ Download only an effective View Node output or an explicit Core Node within the Project context:
202
+
203
+ ```bash
204
+ az8 canvas download <project-id> --view-node-id <view-node-id> --output ./result.png
205
+ ```
206
+
207
+ The destination must be explicit. Existing files are preserved unless `--overwrite` is explicitly
208
+ chosen. Verify the returned absolute path, byte count, detected MIME, Core Node ID, and SHA-256.
209
+ Never extract or reuse hidden media URLs as a general downloader.
210
+
211
+ ## Recovery
212
+
213
+ Classify the outcome before deciding what to do:
214
+
215
+ - **Succeeded:** accept only a terminal success result/Receipt, retain returned identities, and
216
+ inspect facts required by the next step.
217
+ - **Definitive failure:** the Operation did not take its promised effect. Fix input, permissions, or
218
+ business state before making a new explicitly identified attempt.
219
+ - **Indeterminate write:** acknowledgement, transport, backend response, or deadline was lost after
220
+ the write might have started. Assume neither success nor failure. Stop the sequence, take the
221
+ context offline, reconnect manually, inspect Canvas/Project Content/Workflow facts and Receipts,
222
+ then decide whether a new attempt is safe. Never automatically retry.
223
+ - **Read failure:** retry only if capability/error metadata marks the read retryable, and keep the
224
+ retry bounded. A reconnect failure cancels queued unfinished work; it does not replay it.
225
+ - **Workflow wait timeout:** if the Run is authoritatively still pending or running, treat this as
226
+ the end of one observation window. Continue other work or query later; do not cancel or restart.
227
+ - **Caller cancellation:** cancellation is safe only before an Operation begins. Once a write has
228
+ attempted to start, interruption waits for its deadline and cannot roll it back. After uncertainty,
229
+ reconcile facts before acting.
230
+
231
+ For one-shot Canvas commands, exit `0` means success, `1` means a definitive caller/business
232
+ failure, and `2` means an indeterminate lifecycle or transport outcome. Media download may return
233
+ `130` for caller cancellation. Always read the structured result; do not generalize these codes to
234
+ Project commands or the lifetime of a persistent stdio process.
235
+
236
+ ## Safety
237
+
238
+ Never:
239
+
240
+ - write raw backend endpoints, Yjs maps, Collaborative Document paths, generic patches, Core Node
241
+ payloads, or Project Content bindings;
242
+ - invent an Operation or input field absent from `capabilities.detail`;
243
+ - execute writes concurrently, continue a planned sequence after a failure, or wrap multiple
244
+ Operations in assumed transaction semantics;
245
+ - automatically retry a write, reuse a request ID for an unrelated attempt, or treat an idempotency
246
+ key as proof that blind replay is safe;
247
+ - conclude that a timed-out write failed, conclude that an accepted Workflow Run completed, or
248
+ conclude that an Awareness event persisted data;
249
+ - expose a token, presigned URL, permanent media URL, env-file contents, or private output in logs
250
+ or protocol payloads;
251
+ - use awareness client names to impersonate persisted authors or treat Attention Cursor position as
252
+ authority;
253
+ - use one-shot as if it retained History, Receipts, replay state, observations, or presence;
254
+ - attempt Asset membership, arbitrary Core Node creation, 3D World editing, unsupported
255
+ Decoration, alignment, or automatic layout through lower-level access;
256
+ - write production unless the user explicitly selected and authorized production for the concrete
257
+ action.
258
+
259
+ ## Completion
260
+
261
+ Before reporting a task complete, verify all applicable facts:
262
+
263
+ - The intended environment, Project ID, authenticated role, and installed CLI version are known.
264
+ - Runtime capability discovery—not memory—authorized every Operation and input schema used.
265
+ - Every write has its own request ID, terminal Receipt, and sequential position; no write was
266
+ automatically retried.
267
+ - The first failure stopped the remaining sequence, and every indeterminate effect was reconciled
268
+ after explicit reconnect/inspection.
269
+ - Created or edited View Nodes were checked at the detail level needed by downstream work.
270
+ - Generation start and generation completion were reported as separate interactions; the target's
271
+ effective Core Node was resolved after completion.
272
+ - Media transfers were verified by identities and checksums without exposing URLs or credentials.
273
+ - Persistent stdio was shut down in order, or any abnormal termination and uncertain active write
274
+ was disclosed.
275
+ - Deferred scopes were not approximated by bypassing the public semantic surface.
276
+
277
+ When any item cannot be proven, report the uncertainty and the next safe read or reconciliation
278
+ step instead of claiming completion.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "AZ8 CLI"
3
+ short_description: "Safely create and collaborate in AZ8 Project Canvases"
4
+ default_prompt: "Use $az8-cli to create or edit an AZ8 Project Canvas safely."