@kizenapps/cli 1.14.0-cf33224 → 1.15.0-3a8e190

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
@@ -104,7 +104,7 @@ Writes `.kizenapp/bundle.json` — the same artifact `dev` serves — after runn
104
104
 
105
105
  ### `appbuilder create`
106
106
 
107
- Scaffolds a new Kizen plugin project. Interactive by default; passing any flag switches it to a non-interactive run, including `--artifacts` to choose the artifact templates up front (`appbuilder create --help` lists them all). See [Quickstart](#1-scaffold-a-plugin) for the fields it collects, the artifact picker, and everything it writes.
107
+ Scaffolds a new Kizen plugin project. Interactive by default; passing any flag other than `--include-lib` switches it to a non-interactive run, including `--artifacts` to choose the artifact templates up front (`appbuilder create --help` lists them all). Pass `--include-lib` to also write the Kizen data helper library to `src/lib/kizenData.js`; without it, no library is written. See [Quickstart](#1-scaffold-a-plugin) for the fields it collects, the artifact picker, and everything it writes.
108
108
 
109
109
  The scaffold also includes `.github/copilot-instructions.md`, two path-scoped instruction files under `.github/instructions/`, and `.github/workflows/copilot-code-review.yml`. That workflow fetches the Kizen plugin docs from `kizen/app-engine` into `.copilot-docs/` before Copilot code review runs, so reviews cite the current documentation instead of rules copied into the plugin repo. It only takes effect once it is on the repository's default branch, and `.copilot-docs/` is gitignored. Plugins scaffolded before this setup existed can pick it up with `appbuilder setup-copilot`.
110
110
 
@@ -118,6 +118,25 @@ Writes the same Copilot review files into an existing plugin repo — run it fro
118
118
 
119
119
  As with `create`, the workflow only runs once it has reached the repository's default branch.
120
120
 
121
+ ### `appbuilder setup-claude`
122
+
123
+ Installs or refreshes the Claude Code skill for building custom blocks (`.claude/skills/kizen-custom-block/SKILL.md`) in the plugin in the current directory. `appbuilder create` writes the skill once; run `setup-claude` in an existing plugin to add it, or after upgrading the CLI to pick up the bundled version.
124
+
125
+ ```sh
126
+ appbuilder setup-claude [--dry-run] [--include-lib]
127
+ ```
128
+
129
+ | Flag | Default | Purpose |
130
+ | --------------- | ------- | ------------------------------------------------------------ |
131
+ | `--dry-run` | off | Report what would change without writing files. |
132
+ | `--include-lib` | off | Also install the Kizen data helper library (`kizenData.js`). |
133
+
134
+ It also installs the skill's design guide (`.claude/skills/kizen-custom-block/design.md`), which tells the agent how to make blocks match native dashlets. With `--include-lib`, it installs the Kizen data helper library that block scripts import to read records and apply the dashboard's date and team filters. The library goes under the `entry` directory from `kizen.json` (`<entry>/lib/kizenData.js`, one per entry in a multi-plugin `kizen.json`), and under `src/` when `kizen.json` has no usable `entry`. Without the flag, it refreshes only the libraries that already exist. `appbuilder create --include-lib` writes it to `src/lib/kizenData.js`.
135
+
136
+ It prints one line per file (`created`, `updated` or `unchanged`) and a one-line summary. These files are managed by the CLI, so local edits to them, including edits to `kizenData.js`, are replaced when they're `updated`. Don't edit `kizenData.js`; put your own helpers in another file under `src/lib/`. It only writes these files and never touches the `.github/` Copilot files or block code. It fails with exit code 1 when there's no `kizen.json` in the current directory.
137
+
138
+ `block push` adds the warning `Claude files managed by appbuilder are out of date; run appbuilder setup-claude` when the plugin has the skill and the skill or its design guide is missing or differs from the bundled one, or an existing `kizenData.js` differs from the bundled one. The warning never fails the push.
139
+
121
140
  ### `appbuilder build`
122
141
 
123
142
  Reads the plugin in the current directory, validates it against the same rules enforced by the Kizen platform and Plugin Wizard, minifies sources, and writes `.kizenapp/bundle.json`. No flags.
@@ -186,6 +205,236 @@ Prints every valid icon name accepted by toolbar items, pages, and adornments, o
186
205
  appbuilder icons | grep calendar
187
206
  ```
188
207
 
208
+ ### `appbuilder block export`
209
+
210
+ Packages the plugin in the current directory (same validation and minification as `build`) and prints one block as pretty JSON — exactly what the Custom Block (AI Coded) dashlet's paste editor accepts. Nothing is written to `.kizenapp`.
211
+
212
+ ```sh
213
+ appbuilder block export [api_name] [--copy]
214
+ ```
215
+
216
+ | Argument / flag | Default | Purpose |
217
+ | --------------- | ----------------------- | ---------------------------------------------------------------------- |
218
+ | `[api_name]` | the plugin's only block | Block to export. Required when the plugin has more than one block. |
219
+ | `--copy` | off | Also copy the JSON to the clipboard; a one-line status goes to stderr. |
220
+
221
+ Only the block JSON goes to stdout, so it can be piped or redirected (`appbuilder block export > block.json`). Validation warnings and errors go to stderr. The command fails with a non-zero exit code if validation fails, the block can't be found or is ambiguous, or the packaged block would be rejected by the paste editor (for example a block with no `script.js`, a non-positive-integer `min_w`, or a `min_w` greater than its `max_w`).
222
+
223
+ The JSON carries only the sizes the block's `config.json` writes: `min_w`, `max_w`, `min_h`, `max_h`, `default_w` and `default_h`. Sizes it leaves out are left out of the JSON too, rather than filled with packager defaults. `default_w` and `default_h` are the starting size, in grid columns and rows, of a dashlet created from the block. Each size that is set must be a positive integer, each `min_*` must be no greater than its `max_*`, and each `default_*` must fall within whichever of its `min_*` and `max_*` are set (for example `min_w` ≤ `default_w` ≤ `max_w`). Otherwise the export fails as `invalid_block` naming the field.
224
+
225
+ If the plugin has components in `src/views/`, the JSON also carries a `views` array: each packaged view's `api_name`, `name`, `type`, `script`/`html`/`css` (each left out when empty) and `event_scripts` (as a `[{ name, script }]` array), so the block can open one with `this.showViewInModal('<api_name>')`. Components in `src/pages/` are not included. Without views, the output is unchanged.
226
+
227
+ ### `appbuilder block push`
228
+
229
+ Packages the plugin in the current directory (same validation as `block export`) and writes one block into a Custom Block (AI Coded) dashlet on a Kizen dashboard, homepage or chart group: it updates an existing dashlet or creates a new one. Card chrome (background, border, radius, shadow) comes from the dashboard's style settings, like native dashlets.
230
+
231
+ ```sh
232
+ appbuilder block push [api_name] [flags]
233
+ ```
234
+
235
+ Interactive by default: pick credentials, the block, the surface (dashboard, homepage or chart group), the dashboard, then whether to update an existing custom code dashlet or create a new one, and confirm. Pushing to a production environment (`go`, `fmo`) asks you to type `y`. In a TTY, `--yes` skips the confirm prompt only when the headless write gate would apply, so `go` and `fmo` still ask for a typed `y` unless `--allow-production` is also passed; `--dry-run` shows the plan without writing. A dashlet edited in Kizen since the last push still prompts before overwriting unless `--force` is passed.
236
+
237
+ It runs headless when stdin or stdout is not a TTY, or when `--json` is passed. `--yes` never selects the mode. Headless runs never prompt: anything that would be a question fails with `needs_choice` and lists the choices.
238
+
239
+ | Argument / flag | Default | Purpose |
240
+ | -------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------- |
241
+ | `[api_name]` | the plugin's only block | Block to push. Required when the plugin has more than one block. |
242
+ | `-c, --credentials <path>` | see resolution below | Credentials JSON file to use |
243
+ | `--profile <name>` | see resolution below | Stored credential profile to use |
244
+ | `--dashboard <id>` | the remembered target | Dashboard, homepage or chart group to push to |
245
+ | `--dashlet <id>` | matched by push history or name | Existing custom code dashlet to update. Needs `--dashboard`; can't be used with `--create`. |
246
+ | `--create` | off | Create a new dashlet instead of updating one |
247
+ | `--dry-run` | off | Resolve everything and print the request without writing |
248
+ | `--yes` | off | Write without asking. Headless runs without it are dry runs. |
249
+ | `--allow-production` | off | Allow headless writes to `go` / `fmo` |
250
+ | `--force` | off | Overwrite a dashlet that was edited in Kizen since the last push |
251
+ | `--forget` | off | Clear the remembered target for this block before resolving |
252
+ | `--json` | off | Print a JSON result to stdout (forces headless); the human summary goes to stderr |
253
+
254
+ **Credentials** resolve in this order: `-c`, then `--profile`, then the project's active profile from `.kizenapp/config.json`, then the only loadable stored profile; several profiles without a choice is `needs_choice`. A project set to local browser-only credentials must pass `-c` or `--profile`. The credentials file must name a valid `environment` (`go`, `fmo`, `staging`, `integration`, `test1`); a missing or invalid one is refused with `credentials_invalid` rather than defaulting to production. Empty `apiKey`, `userId` or `businessId` are refused the same way.
255
+
256
+ **Write gating (headless).** `--dry-run` is always a dry run. Without `--yes` the run is a dry run too, and stderr says `Dry run only: pass --yes to write.` With `--yes`, `go` and `fmo` also need `--allow-production` (else `production_requires_flag`). If the target dashlet was pushed from here before and its content has since been changed in Kizen, both dry runs and writes stop with `drift_detected` unless `--force` is passed.
257
+
258
+ **Remembered target.** A successful write records the target in `.kizenapp/pushes.json` (kept gitignored): one entry per environment, business, plugin and block. Pushing the block somewhere else replaces the entry. With no `--dashboard`, the next push goes to the remembered dashlet. If that dashboard or dashlet is gone, the push fails with `remembered_target_missing` and never silently creates a new one. When only the dashlet is gone the failure lists the dashboard's target `choices`, and `--create` adds a new block there; otherwise pass `--dashboard <id>` to choose another target, or `--forget` to clear it (honored in dry runs too; the result then carries `"forgotten": true`). A missing `pushes.json` just means nothing is remembered yet; one that can't be read, isn't valid JSON, or isn't a JSON array fails the push with `local_error` before anything is written, so fix or delete it.
259
+
260
+ **Size.** A dashlet created by `push` starts `default_w` columns wide, or `min_w` when there's no `default_w`, or 6 when neither is set. Its height works the same way with `default_h`, then `min_h`, then 3 rows. That size is clamped into whichever of `min_*`/`max_*` the block's `config.json` sets, then into the grid (2 to 12 columns, 1 to 99 rows). The pushed content carries exactly the sizes `config.json` writes, the same as `block export`. Updating an existing dashlet never changes its layout or size.
261
+
262
+ The pushed content includes the plugin's `src/views/` components as `views`, in the same shape as `block export`. They count toward drift detection: a view changed in Kizen since the last push stops the push with `drift_detected`. Blocks in plugins without views push exactly as before, and existing `pushes.json` entries stay valid.
263
+
264
+ `block export` and `block push` fail with `invalid_block` if a view's `api_name`, `name`, `script`, `html`, `css` or event script contains a NUL character or `{__ref:`. The field is reported as `views.<api_name>.<field>`. A warning `appbuilder/views-unmatched` appears if some `src/views/` components couldn't be matched to packaged views.
265
+
266
+ **Matching.** With `--dashboard` and neither `--dashlet` nor `--create`, the push updates the dashlet recorded in `.kizenapp/pushes.json` for that dashboard, else the single custom code dashlet named `appbuilder:<plugin_api_name>/<block_api_name>` (the name given to every dashlet `push` creates). No match, or several, is `needs_choice`.
267
+
268
+ #### JSON output
269
+
270
+ With `--json`, every result is one pretty-printed JSON object on stdout, and the human summary goes to stderr. Headless without `--json` prints human text instead: success and dry-run output on stdout, errors on stderr. A dry run:
271
+
272
+ ```json
273
+ {
274
+ "ok": true,
275
+ "applied": false,
276
+ "dryRun": true,
277
+ "reason": "no_yes",
278
+ "action": "update",
279
+ "environment": "staging",
280
+ "businessId": "b0c6…",
281
+ "dashboard": { "id": "5f1e…", "name": "Sales overview", "type": "dashboard" },
282
+ "dashletId": "9a2d…",
283
+ "url": "https://v2.staging.kizen.com/dashboard/5f1e…",
284
+ "resolvedBy": "remembered",
285
+ "block": {
286
+ "pluginApiName": "my_plugin",
287
+ "apiName": "pipeline_summary",
288
+ "name": "Pipeline summary"
289
+ },
290
+ "method": "PATCH",
291
+ "path": "/dashboards/5f1e…/dashlet/9a2d…",
292
+ "body": { "config": { "…": "…" } },
293
+ "warnings": []
294
+ }
295
+ ```
296
+
297
+ `reason` is `flag` (`--dry-run`) or `no_yes` (headless without `--yes`). `action` is `create` or `update`, `method` is `POST` or `PATCH`, and `dashletId` is `null` for a create. `resolvedBy` is `flag`, `remembered`, `push_map` or `name`. `dashboard.type` is `dashboard`, `homepage` or `chart_group`.
298
+
299
+ An applied write:
300
+
301
+ ```json
302
+ {
303
+ "ok": true,
304
+ "applied": true,
305
+ "dryRun": false,
306
+ "action": "created",
307
+ "environment": "staging",
308
+ "businessId": "b0c6…",
309
+ "dashboard": { "id": "5f1e…", "name": "Sales overview", "type": "dashboard" },
310
+ "dashletId": "c41b…",
311
+ "url": "https://v2.staging.kizen.com/dashboard/5f1e…",
312
+ "refresh": {
313
+ "dashboardId": "5f1e…",
314
+ "script": "await window.__kizenCustomBlocks?.refresh('5f1e…')"
315
+ },
316
+ "resolvedBy": "flag",
317
+ "block": {
318
+ "pluginApiName": "my_plugin",
319
+ "apiName": "pipeline_summary",
320
+ "name": "Pipeline summary"
321
+ },
322
+ "remembered": true,
323
+ "warnings": []
324
+ }
325
+ ```
326
+
327
+ `action` is `created` or `updated`. `remembered` is `false` (with a warning) when `.kizenapp/pushes.json` couldn't be written; the push itself still succeeded.
328
+
329
+ `refresh` is only on applied writes, and only when the dashboard id is a uuid; otherwise it's left out. `script` is exactly `await window.__kizenCustomBlocks?.refresh('<dashboardId>')`. Run it in a Kizen tab that already has `url` open to refetch that dashboard in place instead of reloading the page. The hook is registered on dashboards, homepages and chart groups. When it's available on the page, the script resolves to `{ refreshed: true, dashboardId }`. Otherwise it resolves to `undefined`: the page is an older Kizen build without the hook. `refreshed: true` means the dashboard query was invalidated, not that the target was on screen, which is why the agent matches the tab by `url` and screenshots afterwards. Human output prints the same script on a `Refresh an open tab:` line after the URL.
330
+
331
+ A failure exits 1:
332
+
333
+ ```json
334
+ {
335
+ "ok": false,
336
+ "code": "needs_choice",
337
+ "message": "Choose a block to update on \"Sales overview\", or create a new one; pass --dashlet <id> or --create.",
338
+ "choice": "target",
339
+ "choices": [
340
+ {
341
+ "value": "9a2d…",
342
+ "label": "Pipeline summary",
343
+ "args": ["--dashboard", "5f1e…", "--dashlet", "9a2d…"],
344
+ "pushKey": "appbuilder:my_plugin/pipeline_summary",
345
+ "isFromThisPlugin": true
346
+ },
347
+ { "value": "new", "label": "Create a new block", "args": ["--dashboard", "5f1e…", "--create"] }
348
+ ]
349
+ }
350
+ ```
351
+
352
+ Optional failure fields: `choice` (`profile`, `block`, `dashboard` or `target`) and `choices` with `needs_choice`, `remembered_target_missing` and a `--dashlet` that is `not_found`; `issues` (the packager's validation issues) with `validation_failed`; `field` with `invalid_block`; `hint` with `auth_failed` and `forbidden`. Each choice's `args` are the exact CLI arguments that select it, to be appended to the command (dashboard choices also carry `surface` and `canEdit`).
353
+
354
+ | Code | Meaning |
355
+ | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
356
+ | `needs_choice` | A profile, block, dashboard or target must be chosen; see `choice` and `choices` |
357
+ | `validation_failed` | The plugin failed validation |
358
+ | `invalid_block` | The plugin has no blocks, or the block would be rejected (`field` names the problem) |
359
+ | `credentials_invalid` | No usable credentials, or the file's `environment` is missing or invalid |
360
+ | `auth_failed` | Kizen rejected the credentials |
361
+ | `forbidden` | The credentials can't access the dashboard |
362
+ | `not_found` | The dashboard, or the `--dashlet` on it, doesn't exist |
363
+ | `remembered_target_missing` | The remembered dashboard or dashlet is gone; nothing is created without `--create` |
364
+ | `drift_detected` | The dashlet was edited in Kizen since the last push; `--force` overwrites |
365
+ | `production_requires_flag` | `--yes` against `go` / `fmo` without `--allow-production` |
366
+ | `usage_error` | Conflicting flags (`--dashlet` with `--create`, `--dashlet` without `--dashboard`), or a non-custom-code `--dashlet` |
367
+ | `network_error` | Kizen couldn't be reached |
368
+ | `api_error` | Any other Kizen API failure |
369
+ | `local_error` | A local failure that isn't a validation error: no `kizen.json`, packaging, reading `.kizenapp/pushes.json`, or writing it for `--forget` |
370
+
371
+ ### `appbuilder block targets`
372
+
373
+ Lists where a block can be pushed: the business's dashboards and homepages plus its custom objects, or with `--object` one custom object's chart groups. Always headless.
374
+
375
+ The CLI honors `HTTP_PROXY`/`HTTPS_PROXY` and `NO_PROXY` on Node versions that support it (24.14+, or with `NODE_USE_ENV_PROXY=1` set).
376
+
377
+ `customObjects` is sorted by name and ends with Contacts (`"fetchUrl": "client"`) when the CLI can look up the business's contacts object; Kizen doesn't list Contacts with the other custom objects, so if that lookup fails the row is silently left out. `--object <contacts id>` lists Contacts' chart groups like any other object's.
378
+
379
+ | Flag | Default | Purpose |
380
+ | -------------------------- | ------------------- | --------------------------------------------------------- |
381
+ | `-c, --credentials <path>` | as for `block push` | Credentials JSON file to use |
382
+ | `--profile <name>` | as for `block push` | Stored credential profile to use |
383
+ | `--object <id>` | — | List the chart groups of this custom object (or Contacts) |
384
+ | `--json` | off | Print JSON instead of tables |
385
+
386
+ ```json
387
+ {
388
+ "ok": true,
389
+ "environment": "staging",
390
+ "businessId": "b0c6…",
391
+ "surfaces": {
392
+ "dashboard": [
393
+ {
394
+ "id": "5f1e…",
395
+ "name": "Sales overview",
396
+ "type": "dashboard",
397
+ "dashletsCount": 4,
398
+ "employeeAccess": "Owner",
399
+ "hidden": false,
400
+ "canEdit": true
401
+ }
402
+ ],
403
+ "homepage": []
404
+ },
405
+ "customObjects": [
406
+ { "id": "71d0…", "objectName": "Deals", "fetchUrl": "pipeline" },
407
+ { "id": "c3a9…", "objectName": "Contacts", "fetchUrl": "client" }
408
+ ]
409
+ }
410
+ ```
411
+
412
+ With `--object <id>` the shape is `{ ok, environment, businessId, object: { id, objectName, fetchUrl } | null, surfaces: { chart_group: [...] } }`. `canEdit` is `true` for `Owner`, `Admin` or `Edit` access and `null` when Kizen reports no access level. Failures use the same shape and codes as `block push`.
413
+
414
+ #### Agent loop
415
+
416
+ The sequence a coding agent follows to build a block and put it on a dashboard. After upgrading the CLI, run `appbuilder setup-claude` so the agent's skill matches the new commands.
417
+
418
+ ```sh
419
+ appbuilder block export <api_name>
420
+ appbuilder block targets --json
421
+ appbuilder block targets --object <object_id> --json # chart groups only
422
+ appbuilder block push <api_name> --dashboard <id> --json # needs_choice → choices (existing blocks + new)
423
+ appbuilder block push <api_name> --dashboard <id> [--dashlet <id> | --create] --dry-run --json
424
+ appbuilder block push <api_name> --dashboard <id> [--dashlet <id> | --create] --yes --json
425
+ # change requests: edit, re-validate, then
426
+ appbuilder block push <api_name> --yes --json # remembered target, zero questions
427
+ ```
428
+
429
+ After each applied push, an agent that can drive the user's browser refreshes the open tab instead of reloading it: find the tab whose origin and path match `url`, run `refresh.script` there, and check that the block rendered. If the script returns `undefined`, the hook isn't available on that page, so navigate the tab to `url` instead. If no tab has `url` open, open it in a new one. `refresh` is absent when the dashboard id isn't a uuid; navigate to `url` in that case.
430
+
431
+ Guardrails:
432
+
433
+ - Never pass `--allow-production` unless the user named production.
434
+ - Stop on `drift_detected` and ask the user before retrying with `--force`.
435
+ - On `needs_choice`, ask the user using `choices` (labels to show, `args` to append).
436
+ - On `remembered_target_missing`, ask whether to `--create` a new block rather than creating one.
437
+
189
438
  ## Reference
190
439
 
191
440
  ### Environment variables
@@ -207,6 +456,7 @@ Prod follows the same order minus step 3: `PLUGIN_WIZARD_URL`, then **`PLUGIN_WI
207
456
  | ------------- | ------------------------------------------------------------------------------------------------------------------------------- |
208
457
  | `bundle.json` | The packaged, minified, validated plugin bundle the viewer loads. |
209
458
  | `config.json` | Per-project preferences: credential mode, active profile name, last viewed path, encryption target. |
459
+ | `pushes.json` | The remembered `block push` targets: one dashlet per environment, business, plugin and block. |
210
460
  | `.chrome/` | The dedicated Chromium user-data directory for the viewer — cookies and session state included. |
211
461
  | `venv/` | The Python virtualenv used to execute code steps locally. Rebuilt when its interpreter is too old for the bundled requirements. |
212
462