@kizenapps/cli 1.17.0 → 1.18.0-3811cee

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
@@ -110,9 +110,11 @@ Scaffolds a new Kizen plugin project. Interactive by default; passing any flag o
110
110
 
111
111
  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`.
112
112
 
113
+ It also writes the coding-agent skills, once for Claude Code (`.claude/skills/`) and once for Codex (`.agents/skills/`): `kizen-custom-block` (building custom blocks, with its design guide) and `kizen-business-apps` (publishing with [`appbuilder app`](#appbuilder-app)). Plugins scaffolded before a skill existed pick it up with [`appbuilder setup-claude`](#appbuilder-setup-claude) or [`appbuilder setup-codex`](#appbuilder-setup-codex).
114
+
113
115
  ### `appbuilder setup-copilot`
114
116
 
115
- Writes the same Copilot review files into an existing plugin repo — run it from the repo root (a `kizen.json` must be there). The four files are CLI-owned, so the command overwrites them and prints `created`, `updated`, or `unchanged` per file; a clobbered local customization is recoverable from git. It also adds `.kizenapp/` and `.copilot-docs/` to `.gitignore` if they are missing.
117
+ Writes the same Copilot review files into an existing plugin repo — run it from the repo root (a `kizen.json` must be there). The four files are CLI-owned, so the command overwrites them and prints `created`, `updated`, or `unchanged` per file; a clobbered local customization is recoverable from git. A file (or a folder on its path) that is a symbolic link is refused, and nothing is written. It also adds `.kizenapp/` and `.copilot-docs/` to `.gitignore` if they are missing.
116
118
 
117
119
  | Flag | Default | Purpose |
118
120
  | ----------- | ------- | ----------------------------------------------- |
@@ -122,7 +124,7 @@ As with `create`, the workflow only runs once it has reached the repository's de
122
124
 
123
125
  ### `appbuilder setup-claude`
124
126
 
125
- 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. With `--mcp` it only registers the Kizen MCP server instead and writes no files, so it can run in any directory (see below).
127
+ Installs or refreshes the Claude Code skills in the plugin in the current directory: `kizen-custom-block` for building custom blocks (`.claude/skills/kizen-custom-block/SKILL.md`) and `kizen-business-apps` for publishing with [`appbuilder app`](#appbuilder-app) (`.claude/skills/kizen-business-apps/SKILL.md`). `appbuilder create` writes the skills once; run `setup-claude` in an existing plugin to add them, or after upgrading the CLI to pick up the bundled versions. With `--mcp` it only registers the Kizen MCP server instead and writes no files, so it can run in any directory (see below).
126
128
 
127
129
  ```sh
128
130
  appbuilder setup-claude [--dry-run] [--include-lib]
@@ -141,9 +143,28 @@ appbuilder setup-claude --mcp [--env <env>] [--force] [--dry-run]
141
143
 
142
144
  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`.
143
145
 
144
- 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. Without `--mcp`, it fails with exit code 1 when there's no `kizen.json` in the current directory.
146
+ 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, the Codex skills or block code. It writes only regular files inside the plugin folder: if a managed file, or any folder on its path, is a symbolic link, or something other than a file or folder is in the way, it writes nothing and fails with exit code 1, naming the path. That includes the entry directory: with `--include-lib` (or an existing `kizenData.js`), an entry directory such as `src` that is a symbolic link, as some monorepo setups use, is refused. Without `--mcp`, it also fails with exit code 1 when there's no `kizen.json` in the current directory.
147
+
148
+ `block push` and every [`appbuilder app`](#appbuilder-app) command add the warning `Claude files managed by appbuilder are out of date; run appbuilder setup-claude` to their result's `warnings` when the plugin has any of the Claude skills and any managed file is missing or differs from the bundled one: either skill's files, or an existing `kizenData.js`. A plugin installed before a skill existed is therefore out of date until `setup-claude` adds it. A plugin with no Claude skill gets no warning. The warning never fails the command, and only headless runs show it.
149
+
150
+ ### `appbuilder setup-codex`
151
+
152
+ The same skills for Codex, which discovers repository skills in `.agents/skills/<name>/SKILL.md`: it installs or refreshes `.agents/skills/kizen-custom-block/` (with `design.md`) and `.agents/skills/kizen-business-apps/` in the plugin in the current directory. Both commands render the skills from the same templates; the Codex copies name `setup-codex`, `.agents/skills` and Codex's sandbox escalation where the Claude copies name `setup-claude`, `.claude/skills` and Claude Code's sandbox settings. `appbuilder create` writes both sets.
153
+
154
+ ```sh
155
+ appbuilder setup-codex [--dry-run] [--include-lib]
156
+ ```
157
+
158
+ | Flag | Default | Purpose |
159
+ | --------------- | ------- | ------------------------------------------------------------ |
160
+ | `--dry-run` | off | Report what would change without writing files. |
161
+ | `--include-lib` | off | Also install the Kizen data helper library (`kizenData.js`). |
145
162
 
146
- `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.
163
+ `--include-lib`, the per-file output, the summary (`Codex files: …`), the refusal to write through a symbolic link and the exit code 1 outside a plugin work as for `setup-claude`. The files are managed by the CLI, so a differing file is replaced without any flag. Inside Codex's sandbox `.agents/` is read-only, so an agent running `setup-codex` there needs to escalate it.
164
+
165
+ `block push` and every `appbuilder app` command add `Codex files managed by appbuilder are out of date; run appbuilder setup-codex` under the same rule as the Claude warning, judged on the Codex skills; a plugin with both sets can get both warnings.
166
+
167
+ There's no `--mcp`: Codex doesn't take an MCP headers helper from its CLI (`codex mcp add` has no flag for it), so registering one means editing `~/.codex/config.toml` by hand, and Codex gives the helper 10 seconds, which a first `npx` download of the pinned CLI can exceed.
147
168
 
148
169
  ### `appbuilder build`
149
170
 
@@ -242,7 +263,7 @@ appbuilder block push [api_name] [flags]
242
263
 
243
264
  Interactive by default: pick the environment (only when you pass no `--env` and you're signed in to several, or the account you name is saved in several), 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.
244
265
 
245
- 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.
266
+ It runs headless when stdin or stdout is not a TTY, under a coding agent or CI, or with `--json`, `--no-interactive` or `APPBUILDER_NO_INTERACTIVE` (see [Interactive or headless](#interactive-or-headless)). `--yes` never selects the mode. Headless runs never prompt: anything that would be a question fails with `needs_choice` and lists the choices.
246
267
 
247
268
  | Argument / flag | Default | Purpose |
248
269
  | -------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
@@ -258,13 +279,14 @@ It runs headless when stdin or stdout is not a TTY, or when `--json` is passed.
258
279
  | `--force` | off | Overwrite a dashlet that was edited in Kizen since the last push |
259
280
  | `--forget` | off | Clear the remembered target for this block before resolving |
260
281
  | `--json` | off | Print a JSON result to stdout (forces headless); the human summary goes to stderr |
282
+ | `--no-interactive` | off (`$APPBUILDER_NO_INTERACTIVE`) | Run headless even at a terminal |
261
283
  | `--env <env>` | the only signed-in environment, or with `--business` the only one where it's saved | Environment of the session to use. Not with `-c` or `--profile`. |
262
284
  | `--business <id or name>` | `$APPBUILDER_BUSINESS`, else the current account | Saved account to use, matched as for [`login --business`](#saved-accounts). Not with `-c` or `--profile`. |
263
285
  | `--user <user id>` | `$APPBUILDER_USER` | With `--business`, the user id of that saved account. Not with `-c` or `--profile`. |
264
286
 
265
- **Credentials.** Without `-c` or `--profile`, the push uses your [`appbuilder login`](#appbuilder-login-logout-whoami-and-auth-header) session for `--env`, or for the only environment you're signed in to. If you're signed in to several environments and pass no `--env`, the run is `needs_choice` with `choice: "environment"`. It uses that environment's current account, unless `--business` (and `--user`), or `APPBUILDER_BUSINESS` (and `APPBUILDER_USER`), names another saved account; then the environment without `--env` is the only one where that name matches a saved account, whether or not any account there is current, and several such environments are `needs_choice` the same way (see [Saved accounts](#saved-accounts)). If you're signed out, it fails with `credentials_invalid` and tells you to run `appbuilder login`; it never falls back to an API key. API keys (deprecated) are used only with `-c <path>` or `--profile <name>`, and never touch the session; `--env`, `--business` or `--user` with either is a `usage_error`, and `APPBUILDER_BUSINESS` and `APPBUILDER_USER` are ignored. 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. A `.kizenapp/config.json` `activeCredentialProfile` no longer selects an API key: the push uses the session and prints a one-line notice to stderr, so `--json` output stays clean. `credentialMode: "local"` doesn't affect block commands.
287
+ **Credentials.** Without `-c` or `--profile`, the push uses your [`appbuilder login`](#appbuilder-login-logout-whoami-and-auth-header) session for `--env`, or for the only environment you're signed in to. If you're signed in to several environments and pass no `--env`, the run is `needs_choice` with `choice: "environment"`. It uses that environment's current account, unless `--business` (and `--user`), or `APPBUILDER_BUSINESS` (and `APPBUILDER_USER`), names another saved account; then the environment without `--env` is the only one where that name matches a saved account, whether or not any account there is current, and several such environments are `needs_choice` the same way (see [Saved accounts](#saved-accounts)). If you're signed out, it fails with `not_signed_in`, whose `login.argv` is the `appbuilder login` command to run; it never falls back to an API key. API keys (deprecated) are used only with `-c <path>` or `--profile <name>`, and never touch the session; `--env`, `--business` or `--user` with either is a `usage_error`, and `APPBUILDER_BUSINESS` and `APPBUILDER_USER` are ignored. 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. A `.kizenapp/config.json` `activeCredentialProfile` no longer selects an API key: the push uses the session and prints a one-line notice to stderr, so `--json` output stays clean. `credentialMode: "local"` doesn't affect block commands.
266
288
 
267
- **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.
289
+ **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`). A dry run's `applyArgv` is the command that writes what it showed: the same push with `--yes`, pinned to its dashboard and dashlet (`--dashboard` plus `--dashlet` or `--create`) and to the account the run signed in as, with `--allow-production` only on production, where `requiresProductionConsent` is `true` so an agent asks the user first. 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.
268
290
 
269
291
  **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.
270
292
 
@@ -301,7 +323,26 @@ With `--json`, every result is one pretty-printed JSON object on stdout, and the
301
323
  "method": "PATCH",
302
324
  "path": "/dashboards/5f1e…/dashlet/9a2d…",
303
325
  "body": { "config": { "…": "…" } },
304
- "warnings": []
326
+ "warnings": [],
327
+ "applyArgv": [
328
+ "appbuilder",
329
+ "block",
330
+ "push",
331
+ "pipeline_summary",
332
+ "--env",
333
+ "staging",
334
+ "--business",
335
+ "b0c6…",
336
+ "--user",
337
+ "7d1f…",
338
+ "--dashboard",
339
+ "5f1e…",
340
+ "--dashlet",
341
+ "9a2d…",
342
+ "--yes",
343
+ "--json"
344
+ ],
345
+ "requiresProductionConsent": false
305
346
  }
306
347
  ```
307
348
 
@@ -339,7 +380,7 @@ An applied write:
339
380
 
340
381
  `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.
341
382
 
342
- A failure exits 1:
383
+ A failure exits 2 when it stops for a decision (`needs_choice`) and 1 otherwise:
343
384
 
344
385
  ```json
345
386
  {
@@ -353,21 +394,59 @@ A failure exits 1:
353
394
  "label": "Pipeline summary",
354
395
  "args": ["--dashboard", "5f1e…", "--dashlet", "9a2d…"],
355
396
  "pushKey": "appbuilder:my_plugin/pipeline_summary",
356
- "isFromThisPlugin": true
397
+ "isFromThisPlugin": true,
398
+ "argv": [
399
+ "appbuilder",
400
+ "block",
401
+ "push",
402
+ "pipeline_summary",
403
+ "--env",
404
+ "staging",
405
+ "--business",
406
+ "b0c6…",
407
+ "--user",
408
+ "7d1f…",
409
+ "--dashboard",
410
+ "5f1e…",
411
+ "--dashlet",
412
+ "9a2d…",
413
+ "--json"
414
+ ]
357
415
  },
358
- { "value": "new", "label": "Create a new block", "args": ["--dashboard", "5f1e…", "--create"] }
416
+ {
417
+ "value": "new",
418
+ "label": "Create a new block",
419
+ "args": ["--dashboard", "5f1e…", "--create"],
420
+ "argv": [
421
+ "appbuilder",
422
+ "block",
423
+ "push",
424
+ "pipeline_summary",
425
+ "--env",
426
+ "staging",
427
+ "--business",
428
+ "b0c6…",
429
+ "--user",
430
+ "7d1f…",
431
+ "--dashboard",
432
+ "5f1e…",
433
+ "--create",
434
+ "--json"
435
+ ]
436
+ }
359
437
  ]
360
438
  }
361
439
  ```
362
440
 
363
- Optional failure fields: `choice` (`environment`, `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`).
441
+ Optional failure fields: `choice` (`environment`, `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` (what to do next) with `not_signed_in`, `auth_failed`, `forbidden`, `session_store_unwritable` and others; `login` (`{ "argv": [...] }`, the `appbuilder login` command for the user to run) with `not_signed_in`; and `sandbox` (`"codex_network_disabled"`) on a `network_error` when Codex's sandbox has the network turned off. Each choice's `argv` is the whole command that selects it: the push re-run with that choice and the account flags (`--json` too when the run had it), without `--yes`, so it's a dry run whose `applyArgv` then writes. Run it as given. `args` are only the flags that select it (dashboard choices also carry `surface` and `canEdit`).
364
442
 
365
443
  | Code | Meaning |
366
444
  | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
367
445
  | `needs_choice` | An environment, block, dashboard or target must be chosen; see `choice` and `choices` |
368
446
  | `validation_failed` | The plugin failed validation |
369
447
  | `invalid_block` | The plugin has no blocks, or the block would be rejected (`field` names the problem) |
370
- | `credentials_invalid` | Not signed in (run `appbuilder login`), or the `-c`/`--profile` file's `environment` is missing or invalid |
448
+ | `not_signed_in` | No usable sign-in session (missing, expired, rejected or unreadable); `login.argv` is the `appbuilder login` command for the user to run |
449
+ | `credentials_invalid` | The `-c`/`--profile` file can't be read, its `environment` is missing or invalid, or it lacks `apiKey`, `userId` or `businessId` |
371
450
  | `auth_failed` | Kizen rejected the credentials |
372
451
  | `forbidden` | The credentials can't access the dashboard |
373
452
  | `not_found` | The dashboard, or the `--dashlet` on it, doesn't exist |
@@ -375,11 +454,12 @@ Optional failure fields: `choice` (`environment`, `block`, `dashboard` or `targe
375
454
  | `drift_detected` | The dashlet was edited in Kizen since the last push; `--force` overwrites |
376
455
  | `production_requires_flag` | `--yes` against `go` / `fmo` without `--allow-production` |
377
456
  | `usage_error` | Conflicting flags (`--dashlet` with `--create`, `--dashlet` without `--dashboard`), a non-custom-code `--dashlet`, or a `--business` (or `APPBUILDER_BUSINESS`) that matches no saved account, or several |
378
- | `network_error` | Kizen couldn't be reached |
457
+ | `network_error` | Kizen couldn't be reached; `sandbox: "codex_network_disabled"` when Codex's sandbox has the network off |
458
+ | `session_store_unwritable` | The session couldn't be saved to `~/.kizenappbuilder/oauth/` (a sandbox, or a full disk); `hint` says how to allow it |
379
459
  | `api_error` | Any other Kizen API failure |
380
460
  | `local_error` | A local failure that isn't a validation error: no `kizen.json`, packaging, reading `.kizenapp/pushes.json`, or writing it for `--forget` |
381
461
 
382
- Sign-in sessions add these cases: not being signed in is `credentials_invalid`; several signed-in environments and no `--env` is `needs_choice` (`choice: "environment"`, each choice `{ value, label, args: ["--env", <env>] }`), and so is a `--business` (or `APPBUILDER_BUSINESS`) that matches saved accounts in several environments, whose retry commands keep `--business` and `--user`; a session that needs a new `appbuilder login` (expired, rejected or unreadable) is `auth_failed`; `--env`, `--business` or `--user` with `-c` or `--profile`, or an unknown `--env`, is `usage_error`; a `--business` (or `APPBUILDER_BUSINESS`) that matches no saved account, or several, is `usage_error` with a message that lists them, and so is `--user` without `--business` (or `APPBUILDER_USER` without `APPBUILDER_BUSINESS`); an unreachable token endpoint is `network_error`; and any other failure to refresh the session is `api_error`.
462
+ Sign-in sessions add these cases: not being signed in, or a session that needs a new `appbuilder login` (expired, rejected or unreadable), is `not_signed_in` with `login.argv` (`appbuilder login`, plus `--env` when the environment is known and `--business`/`--user` when the run named an account); several signed-in environments and no `--env` is `needs_choice` (`choice: "environment"`, each choice `{ value, label, args: ["--env", <env>], argv }`), and so is a `--business` (or `APPBUILDER_BUSINESS`) that matches saved accounts in several environments, whose retry commands keep `--business` and `--user`; `--env`, `--business` or `--user` with `-c` or `--profile`, or an unknown `--env`, is `usage_error`; a `--business` (or `APPBUILDER_BUSINESS`) that matches no saved account, or several, is `usage_error` with a message that lists them, and so is `--user` without `--business` (or `APPBUILDER_USER` without `APPBUILDER_BUSINESS`); an unreachable token endpoint is `network_error`; a refreshed session that can't be saved is `session_store_unwritable`; and any other failure to refresh the session is `api_error`.
383
463
 
384
464
  ### `appbuilder block targets`
385
465
 
@@ -431,7 +511,7 @@ With `--object <id>` the shape is `{ ok, environment, businessId, object: { id,
431
511
 
432
512
  #### Agent loop
433
513
 
434
- 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.
514
+ The sequence a coding agent follows to build a block and put it on a dashboard. After upgrading the CLI, run `appbuilder setup-claude` (or `appbuilder setup-codex`) so the agent's skill matches the new commands.
435
515
 
436
516
  ```sh
437
517
  appbuilder block export <api_name>
@@ -450,9 +530,528 @@ Guardrails:
450
530
 
451
531
  - Never pass `--allow-production` unless the user named production.
452
532
  - Stop on `drift_detected` and ask the user before retrying with `--force`.
453
- - On `needs_choice`, ask the user using `choices` (labels to show, `args` to append).
533
+ - On `needs_choice` (exit 2), ask the user using `choices` (labels to show), then run the chosen `argv` exactly as given.
534
+ - Run a dry run's `applyArgv` as given, and only after the user agreed; when `requiresProductionConsent` is `true`, only after they agreed to write to production.
535
+ - On `not_signed_in`, ask the user to run `login.argv` (it opens a browser).
454
536
  - On `remembered_target_missing`, ask whether to `--create` a new block rather than creating one.
455
537
 
538
+ ### `appbuilder app`
539
+
540
+ Publishes the plugin in the current folder as a Kizen Business App on the business you're signed in to. Each developer pushes their own preview of the app; publishing a preview makes it the next Live version, which every user of the business gets. The server numbers the releases (`kizen.json` `version` isn't sent).
541
+
542
+ ```sh
543
+ appbuilder app versions # Live, released and preview versions, and this folder's base
544
+ appbuilder app push [--force] [--base-from-preview <id>] # save this folder as your preview
545
+ appbuilder app publish [--force] [--expect-preview <id>] # make your preview the next Live version
546
+ appbuilder app merge [--release <n>] [--base <n> | --accept-live-base] # merge Live (or release n) into this folder
547
+ appbuilder app rollback <n> # restore released version n as your preview
548
+ appbuilder app pull <n> [--out <dir>] # download release n's source into a new folder
549
+ appbuilder app pull --preview [--out <dir>] # download your preview's source into a new folder
550
+ appbuilder app actions list # the app's JS actions and the objects they're linked to
551
+ appbuilder app actions link <action> <object> [--menu | --no-menu] # link a JS action to an object
552
+ appbuilder app actions unlink <action> <object> # remove that link
553
+ appbuilder app preview delete [--owner <userId>] [--expect-updated <ts>] [--delete-app] # delete your preview (or another developer's)
554
+ ```
555
+
556
+ At a terminal each command is interactive: it shows the plan and asks before writing, and production (`go`, `fmo`) needs a typed `y`. It runs headless when stdin or stdout is not a TTY, under a coding agent or CI, or with `--json`, `--no-interactive` or `APPBUILDER_NO_INTERACTIVE` (see [Interactive or headless](#interactive-or-headless)).
557
+
558
+ | Flag | Commands | Purpose |
559
+ | ------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
560
+ | `-c, --credentials <path>` | all | API key (deprecated): credentials JSON file to use instead of the session |
561
+ | `--profile <name>` | all | API key (deprecated): stored credential profile to use instead of the session |
562
+ | `--dry-run` | push, publish, merge, rollback, actions link/unlink, preview delete | Show what would change without writing |
563
+ | `--yes` | push, publish, merge, rollback, actions link/unlink, preview delete | Write without asking. Headless runs without it are dry runs. |
564
+ | `--allow-production` | push, publish, rollback, actions link/unlink, preview delete | Allow headless writes to `go` / `fmo` (`merge` writes only local files, so it has none) |
565
+ | `--menu`, `--no-menu` | actions link | Show the action in the object's Perform Action menus, or not. A new link isn't shown unless `--menu`; an existing link keeps its setting unless one is passed. |
566
+ | `--force` | push | Push even though files still have merge conflict markers |
567
+ | `--base-from-preview <id>` | push | Take this folder's base from your preview, while your preview is still source package `<id>`. Only a `base_required` choice prints it (see [`base_required`](#base_required)) |
568
+ | `--force` | publish | Publish even though Live changed since your preview was based on it, or its base is unknown. Never publishes a preview pushed again since it was reviewed (`preview_replaced`) |
569
+ | `--expect-preview <id>` | publish | Publish only if your preview's source package is still `<id>` (a dry run's `applyArgv` carries it) |
570
+ | `--release <n>` | merge | Merge release `<n>` instead of Live |
571
+ | `--base <n>` | merge | The release this folder was copied from, when no base is recorded. A wrong one drops the changes made since then. |
572
+ | `--accept-live-base` | merge | Record Live (or `--release`) as this folder's base without merging, after merging by hand |
573
+ | `--preview` | pull | Download your preview instead of a released version. Pass `<n>` or `--preview`, not both |
574
+ | `--out <dir>` | pull | Folder to create (default `../<api_name>-v<n>`, or `../<api_name>-preview` with `--preview`, next to the plugin folder) |
575
+ | `--owner <userId>` | preview delete | Delete this user's preview instead of yours (a user id, as `versions` lists in `previews[].previewOwner.id`) |
576
+ | `--expect-updated <ts>` | preview delete | Delete only if the preview's last update is still `<ts>` (a dry run's `applyArgv` carries it) |
577
+ | `--delete-app` | preview delete | Allow deleting the whole app when the preview is its only version (a dry run's `applyArgv` carries it only when it warned about that) |
578
+ | `--json` | all | Print one JSON result to stdout (forces headless); the human text goes to stderr |
579
+ | `--no-interactive` | all | Run headless even at a terminal (also `$APPBUILDER_NO_INTERACTIVE`) |
580
+ | `--env`, `--business`, `--user` | all | The session and saved account to use, as for [`block push`](#appbuilder-block-push) |
581
+
582
+ Credentials work as for `block push`: the `appbuilder login` session by default, an API key only with `-c` or `--profile`. Business Apps need the Marketplace › Business App Developer permission at the Delete/All level; without it the commands fail with `forbidden` and say so in `hint`.
583
+
584
+ #### Workflow
585
+
586
+ 1. `appbuilder app versions` shows where things stand. Its `next` is `merge` when Live moved past this folder's base, else `push` then `publish`.
587
+ 2. `appbuilder app push` saves this folder as your preview. Other developers' previews and Live don't change.
588
+ 3. `appbuilder app publish` makes your preview the next Live version (`nextReleaseAtLeast` in the dry run). Before promoting it, it checks that Live hasn't moved since your preview's base, both in the dry run and again just before the write. Your preview's base is read from your preview on the server (see [Moving to another machine](#moving-to-another-machine)), so it doesn't matter which folder or machine pushed it.
589
+ 4. When someone else published in between, publish fails with `publish_conflict`: run `appbuilder app merge`, resolve any conflict markers, then push and publish again.
590
+
591
+ The first push of an app that isn't on the business yet creates it (`published: false` in `versions` until then). A release needs a thumbnail; publishing a preview without one fails with `thumbnail_required`.
592
+
593
+ #### Headless write gate and JSON results
594
+
595
+ `push`, `publish`, `merge`, `rollback` and `preview delete` are dry runs headless unless `--yes` is passed, and `--yes` against `go` or `fmo` also needs `--allow-production` (else `production_requires_flag`). `merge` only writes local files, so it needs `--yes` but never `--allow-production`. `pull` writes only into a new folder and needs neither. `versions` is read-only.
596
+
597
+ A dry run:
598
+
599
+ ```json
600
+ {
601
+ "ok": true,
602
+ "applied": false,
603
+ "dryRun": true,
604
+ "reason": "no_yes",
605
+ "action": "push",
606
+ "environment": "staging",
607
+ "businessId": "b0c6…",
608
+ "userId": "7d1f…",
609
+ "app": { "baseApiName": "acme", "apiName": "acme_abc123", "name": "Acme", "liveVersion": "5" },
610
+ "source": { "files": 12, "mode": "git", "bytes": 18342, "hash": "dfc2…" },
611
+ "thumbnail": true,
612
+ "preview": { "exists": true, "updated": "2026-10-20T00:00:00.000Z" },
613
+ "base": { "version": "5", "source": "recorded", "liveMoved": false },
614
+ "conflictMarkers": [],
615
+ "notices": [],
616
+ "warnings": [],
617
+ "applyArgv": [
618
+ "appbuilder",
619
+ "app",
620
+ "push",
621
+ "--yes",
622
+ "--env",
623
+ "staging",
624
+ "--business",
625
+ "b0c6…",
626
+ "--user",
627
+ "7d1f…",
628
+ "--json"
629
+ ],
630
+ "requiresProductionConsent": false,
631
+ "next": []
632
+ }
633
+ ```
634
+
635
+ `applyArgv` is the command that applies what the dry run showed: the same command with `--yes`, plus `--allow-production` on `go` or `fmo`, pinned to the account the run signed in as (`--env`, `--business`, `--user`, or the `-c`/`--profile` it was given) so that a switch to another account meanwhile can't redirect it. A `publish` dry run pins the preview it reviewed (`--expect-preview <id>`), a `merge` dry run the version it planned (`--release <n>`, plus `--base <n>` when the base came from the flag or was detected), `rollback` its version, and `preview delete` the preview's owner (`--owner <userId>`, even for your own), the preview it reviewed (`--expect-updated <ts>`) and, only when it warned that the app goes too, `--delete-app`. A `push` apply uploads the folder as it is when it runs. `requiresProductionConsent` is `true` exactly when `applyArgv` carries `--allow-production`: an agent asks the user before running it. A dry run's `next` is empty, so the only way on is `applyArgv`. A push's `base.source` says where its base came from: `recorded` (this folder's state), `never_published` (no Live version, so none is needed), `detected` (the folder matches a release exactly), `preview` (it matches your preview exactly, and the base is your preview's, read from the server) or `base_from_preview` (`--base-from-preview`). A publish's `conflictCheck` compares your preview's base, read from its lineage on the server, with Live: `baseLiveVersion` and `baseSourcePackageId` are the lineage's, and `reason` says why it's a conflict.
636
+
637
+ An applied write has `applied: true`, the command's results (`previewVersion`, `sourcePackageId` and `thumbnailId` for a push; `liveVersion` and `previousLiveVersion` for a publish; `status` and the file lists for a merge) and `next`, the commands that follow, each `{ "step", "argv" }`: a push is followed by a publish dry run (after the JS action link steps, when any action may need linking; see [`app actions`](#app-actions-linking-js-actions-to-objects)), a rollback by a publish dry run, a merge by push and publish dry runs. A merge that left conflict markers starts `next` with a step that has no command:
638
+
639
+ ```json
640
+ { "step": "resolve", "files": ["src/a.js"], "markers": { "local": "HEAD", "incoming": "live" } }
641
+ ```
642
+
643
+ `remembered` is `false` (with a warning) when `.kizenapp/apps.json` couldn't be written; the write itself still succeeded.
644
+
645
+ A push adds the CLI's entries to `.gitignore` when they're missing and then zips the folder again, so the applied result's `source` describes the zip that was uploaded. If any file other than `.gitignore` changed since the plan (an edit made while the confirm was open, say), the push stops with `local_error` and uploads nothing; run it again to review the change.
646
+
647
+ A publish that can't confirm that the release is the preview it reviewed (the preview was pushed again from elsewhere, or the check failed) still publishes, but says in `warnings` that this folder's base wasn't advanced. The next publish from this folder then stops with `publish_conflict`; merge, push and publish again.
648
+
649
+ #### Failures and exit codes
650
+
651
+ With `--json` a failure is `{ "ok": false, "code", "message", "hint"?, … }` on stdout. Exit `0` is success, dry runs included; exit `2` means the command stopped for a decision (`needs_choice` or `base_required`) and its `choices` say how to go on; every other failure exits `1`. Each choice carries `argv`, the whole command to run as given: `--json` and the run's account flags are already in it.
652
+
653
+ ```json
654
+ {
655
+ "ok": false,
656
+ "code": "base_required",
657
+ "message": "No base version is recorded for this folder, and Live is v3. Merge Live into this folder, or record that it already contains Live, then push.",
658
+ "choice": "base",
659
+ "choices": [
660
+ {
661
+ "value": "merge",
662
+ "label": "Preview merging Live v3 into this folder",
663
+ "args": [],
664
+ "argv": [
665
+ "appbuilder",
666
+ "app",
667
+ "merge",
668
+ "--release",
669
+ "3",
670
+ "--env",
671
+ "staging",
672
+ "--business",
673
+ "b0c6…",
674
+ "--user",
675
+ "7d1f…",
676
+ "--json"
677
+ ]
678
+ },
679
+ {
680
+ "value": "accept",
681
+ "label": "This folder already contains Live v3",
682
+ "args": [],
683
+ "argv": [
684
+ "appbuilder",
685
+ "app",
686
+ "merge",
687
+ "--release",
688
+ "3",
689
+ "--accept-live-base",
690
+ "--yes",
691
+ "--env",
692
+ "staging",
693
+ "--business",
694
+ "b0c6…",
695
+ "--user",
696
+ "7d1f…",
697
+ "--json"
698
+ ]
699
+ }
700
+ ]
701
+ }
702
+ ```
703
+
704
+ | Code | Meaning |
705
+ | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
706
+ | `needs_choice` | Signed in to several environments and no `--env`; each choice re-runs the command with one |
707
+ | `base_required` | No base is recorded for this folder and it doesn't match a release or your preview exactly (see below) |
708
+ | `publish_conflict` | Live moved since your preview's base, or that base was replaced (`conflict.reason: "base_replaced"`), or your preview's source doesn't say what it's based on (`"base_unknown"`). `next` is the `merge` dry run; a `push` dry run for `base_unknown`; or a new `publish` dry run when your preview changed since it was reviewed (`"preview_replaced"`: `--expect-preview` no longer matches, or it was pushed again between the plan and the promote, `--force` and the terminal confirm included) |
709
+ | `unresolved_conflicts` | Files still have merge conflict markers; `files` lists them. `push --force` pushes anyway. |
710
+ | `no_preview` | You have no preview to publish (or, for `pull --preview`, to pull); push first |
711
+ | `preview_incomplete` | Your preview has no source package (`publish`, `pull --preview`); push again |
712
+ | `preview_changed` | `preview delete`: the preview was pushed again since the dry run (`--expect-updated` no longer matches), or deleting it would delete the whole app without `--delete-app`; nothing was deleted. `next` is a new `preview delete` dry run |
713
+ | `thumbnail_required` | Your preview has no thumbnail, which a release needs; add one, push, then publish |
714
+ | `source_invalid` | The folder can't be zipped: no `kizen.json` in it, an unreadable `.kizenignore`, a folder the enclosing git repository ignores, or a file over 50 MiB (200 MiB in all) |
715
+ | `validation_failed` | The plugin failed validation; `issues` lists the problems |
716
+ | `forbidden` | Missing the Business App Developer permission (`hint`) |
717
+ | `production_requires_flag` | `--yes` against `go` / `fmo` without `--allow-production` |
718
+ | `not_signed_in` | No usable sign-in session; `login.argv` is the `appbuilder login` command for the user to run |
719
+ | `session_store_unwritable` | The session couldn't be saved to `~/.kizenappbuilder/oauth/` (usually an agent's sandbox); `hint` says how to allow it |
720
+ | `network_error` | Kizen couldn't be reached; `sandbox: "codex_network_disabled"` when Codex's sandbox has the network off |
721
+ | `credentials_invalid` | The `-c`/`--profile` API-key file is unusable |
722
+ | `auth_failed` | Kizen rejected the credentials |
723
+ | `not_found` | The version doesn't exist, the app isn't published to this business yet (`rollback`, `pull`, `merge`, `actions`, `preview delete`), there's no Live version to merge, no such JS action, object or link, or no such preview |
724
+ | `usage_error` | A bad argument, such as a version that isn't a release number, `pull` with both `<n>` and `--preview` or neither, a `pull` folder that already exists, or `actions link`/`unlink` without `<action>` or `<object>` headless |
725
+ | `api_error`, `local_error` | Any other Kizen API failure, or a local one |
726
+
727
+ #### `app actions`: linking JS actions to objects
728
+
729
+ A JS action template does nothing until it's linked to an object. A link belongs to the app's install on the business and names the template by its `api_name`, so it survives new previews and releases. Create links with these commands (or the Kizen UI); an app's setup assistant may also have a step for it.
730
+
731
+ `push`, `publish` and `versions` check the app's JS actions and warn about every one that may need linking, at a terminal and headless alike. With `--json` they carry the check as `jsActions`:
732
+
733
+ ```json
734
+ {
735
+ "status": "checked",
736
+ "liveVersion": "5",
737
+ "actions": [
738
+ {
739
+ "apiName": "hello_action",
740
+ "name": "Say hello",
741
+ "hintObjectName": "client_client",
742
+ "status": "linked",
743
+ "inLive": true,
744
+ "links": [
745
+ {
746
+ "id": "8c1e…",
747
+ "objectId": "41aa…",
748
+ "objectName": "client_client",
749
+ "label": "Contacts",
750
+ "includePerformAction": true,
751
+ "unlinkArgv": [
752
+ "appbuilder",
753
+ "app",
754
+ "actions",
755
+ "unlink",
756
+ "hello_action",
757
+ "41aa…",
758
+ "--env",
759
+ "staging",
760
+ "--business",
761
+ "b0c6…",
762
+ "--user",
763
+ "7d1f…",
764
+ "--json"
765
+ ]
766
+ }
767
+ ],
768
+ "linkArgv": [
769
+ "appbuilder",
770
+ "app",
771
+ "actions",
772
+ "link",
773
+ "hello_action",
774
+ "<object>",
775
+ "--env",
776
+ "staging",
777
+ "--business",
778
+ "b0c6…",
779
+ "--user",
780
+ "7d1f…",
781
+ "--json"
782
+ ],
783
+ "linkMenuArgv": [
784
+ "appbuilder",
785
+ "app",
786
+ "actions",
787
+ "link",
788
+ "hello_action",
789
+ "<object>",
790
+ "--menu",
791
+ "--env",
792
+ "staging",
793
+ "--business",
794
+ "b0c6…",
795
+ "--user",
796
+ "7d1f…",
797
+ "--json"
798
+ ],
799
+ "linkNoMenuArgv": [
800
+ "appbuilder",
801
+ "app",
802
+ "actions",
803
+ "link",
804
+ "hello_action",
805
+ "<object>",
806
+ "--no-menu",
807
+ "--env",
808
+ "staging",
809
+ "--business",
810
+ "b0c6…",
811
+ "--user",
812
+ "7d1f…",
813
+ "--json"
814
+ ]
815
+ },
816
+ {
817
+ "apiName": "other_action",
818
+ "name": "Other",
819
+ "hintObjectName": "client_client",
820
+ "status": "unlinked",
821
+ "inLive": true,
822
+ "links": [],
823
+ "linkArgv": [
824
+ "appbuilder",
825
+ "app",
826
+ "actions",
827
+ "link",
828
+ "other_action",
829
+ "<object>",
830
+ "--env",
831
+ "staging",
832
+ "--business",
833
+ "b0c6…",
834
+ "--user",
835
+ "7d1f…",
836
+ "--json"
837
+ ],
838
+ "linkMenuArgv": [
839
+ "appbuilder",
840
+ "app",
841
+ "actions",
842
+ "link",
843
+ "other_action",
844
+ "<object>",
845
+ "--menu",
846
+ "--env",
847
+ "staging",
848
+ "--business",
849
+ "b0c6…",
850
+ "--user",
851
+ "7d1f…",
852
+ "--json"
853
+ ],
854
+ "linkNoMenuArgv": [
855
+ "appbuilder",
856
+ "app",
857
+ "actions",
858
+ "link",
859
+ "other_action",
860
+ "<object>",
861
+ "--no-menu",
862
+ "--env",
863
+ "staging",
864
+ "--business",
865
+ "b0c6…",
866
+ "--user",
867
+ "7d1f…",
868
+ "--json"
869
+ ]
870
+ }
871
+ ],
872
+ "next": [
873
+ {
874
+ "step": "actions",
875
+ "argv": [
876
+ "appbuilder",
877
+ "app",
878
+ "actions",
879
+ "list",
880
+ "--env",
881
+ "staging",
882
+ "--business",
883
+ "b0c6…",
884
+ "--user",
885
+ "7d1f…",
886
+ "--json"
887
+ ]
888
+ },
889
+ {
890
+ "step": "link",
891
+ "argv": [
892
+ "appbuilder",
893
+ "app",
894
+ "actions",
895
+ "link",
896
+ "other_action",
897
+ "client_client",
898
+ "--env",
899
+ "staging",
900
+ "--business",
901
+ "b0c6…",
902
+ "--user",
903
+ "7d1f…",
904
+ "--json"
905
+ ]
906
+ }
907
+ ]
908
+ }
909
+ ```
910
+
911
+ | Action `status` | Meaning |
912
+ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
913
+ | `linked` | At least one link; `links` lists them, with the object and `includePerformAction` (whether it shows in the object's Perform Action menus; `null` when never set) |
914
+ | `unlinked` | In the Live version (or the app isn't on the business yet) with no link |
915
+ | `unknown` | Not in the Live version, only in a preview, so its links can't be listed. It may or may not be linked; link it like an `unlinked` one |
916
+
917
+ Every action, wherever it's listed (`jsActions.actions` on `push`, `publish` and `versions`, and `actions` from `actions list`), carries the commands that act on it, pinned like every printed command to the account the run signed in as (`--env`, `--business`, `--user`, or its `-c`/`--profile`) and with `--json` when the run had it: `linkArgv`, `linkMenuArgv` (the same with `--menu`) and `linkNoMenuArgv` (with `--no-menu`, which also turns an existing link's menu off) are `link` dry runs whose one element `<object>` is a placeholder. Replace exactly that element with an object's api name or id, and nothing else. Each listed link carries `unlinkArgv`, an `unlink` dry run naming its object by id.
918
+
919
+ The check's own `status` is `checked`, `not_installed` (the app isn't on the business yet; nothing is linked), `no_live_version` (no links can be listed yet) or `failed` (a request failed: `error`, and a notice; the command itself still succeeds). `next` has an `actions list` step whenever an action may need linking (or the check failed), and a `link` dry run per `unlinked` action with a hint object. An `unknown` action gets no `link` step of its own: it may already be linked, so pick its object with the user. An applied push checks the app as the push left it: after a first push, the app is installed with only your preview, so the check is `no_live_version` and every action `unknown`. An applied push puts these steps first in its own `next`, before `publish`; an applied publish, and `versions`, end their own `next` with them (a dry run's `next` stays empty).
920
+
921
+ Kizen lists only the links of templates in the install's Live version, which is why a preview-only action is `unknown`. Link one right after `appbuilder app push`, as you would a Live one; `link` notes that an existing link to that object can't be seen, and reports `already_linked` if there was one. On a Kizen environment that doesn't have the fix for linking preview-only actions (KZN-19521) yet, the link fails with `api_error` and a `hint` saying so: publish first, then link.
922
+
923
+ `appbuilder app actions list` (read-only) returns `{ ok, environment, businessId, userId, app, published, status, actions, warnings, next }`: the actions of the Live version and your preview, with `next` holding the `link` dry runs. `link` and `unlink` are writes: headless dry runs without `--yes`, `--allow-production` on `go` and `fmo`, and a dry run's `applyArgv` names the object by id (and, for `link`, the menu setting it showed). `<object>` is an object's api name (`client_client`), id, or display name ignoring case; Contacts counts. A name that matches several objects stops with exit 2 (`needs_choice`, `choice: "object"`), one choice per object by id. A `link` result has `jsAction`, `object`, `change` (`create`, `update` or `up_to_date`), `includePerformAction`, `existing` and, once applied, `status`: `created`, `updated`, `up_to_date` (nothing written), or `already_linked` (the server already had the link, and its menu setting was left alone: for an action only in a preview, a link made while its links can't be listed; for an action in Live, a link made after this command listed them, in which case run `appbuilder app actions list` and link it again to set the menu setting). A link belongs to the app's one install, shared by Live and every preview, and each user's version resolves it, so creating, removing or changing the menu setting of a link to an action in Live (`inLive: true`) changes what everyone using Live sees as soon as it's made; there's no preview of a link. The dry run (and the confirm at a terminal) warns about it in `warnings`, and so does the applied result. A preview-only action's link reaches only the users of a version that has the action, and a result that changed nothing (`up_to_date`, `already_linked`) carries no such warning. An `unlink` result has `jsAction`, `object`, `associationId` and `status: "unlinked"`; unlinking an action that's only in a preview fails with `not_found`, because its links can't be listed: publish it first.
924
+
925
+ At a terminal, `link` and `unlink` work like the other writes (the plan, then a confirm; a typed `y` on production). Leave out `<action>` or `<object>` to pick them: `link` asks for the action (with its status), then the object (type to filter; the action's hint object starts highlighted, and objects that share a display name are told apart by api name), then whether it shows in the Perform Action menus unless `--menu` or `--no-menu` was passed; `unlink` asks which of the listed links to remove. Esc at a picker or `n` at the confirm cancels without writing, and so does Ctrl+C before the write starts. When `push`, `publish` or `versions` finds actions that may need linking, it offers "Link JS actions now", which runs `link`'s pickers right there. Headless, both arguments are required: a missing one is a `usage_error` naming it.
926
+
927
+ #### `app preview delete`
928
+
929
+ `appbuilder app preview delete` deletes your preview of the app, with every install of it and its OAuth connections. `--owner <userId>` deletes another developer's preview instead (Kizen lets anyone with the Business App Developer permission do that); it takes a user id, not a name, and a user with no preview is `not_found`, with the previews in `hint`. It's a write like the others: a dry run headless without `--yes`, `--allow-production` on `go` and `fmo`, and at a terminal the plan and a confirm (a typed `y` on production). Esc or `n` at the confirm cancels, and so does Ctrl+C before the delete starts.
930
+
931
+ Users who were using the preview switch to their own preview, or Live, and Kizen notifies them. When the preview is the app's only version (no release and no other preview), Kizen deletes the whole app from the business, with its settings and secrets. A dry run warns about each of these, and about deleting someone else's preview:
932
+
933
+ ```json
934
+ {
935
+ "ok": true,
936
+ "applied": false,
937
+ "dryRun": true,
938
+ "reason": "no_yes",
939
+ "action": "preview delete",
940
+ "environment": "staging",
941
+ "businessId": "b0c6…",
942
+ "userId": "7d1f…",
943
+ "app": { "baseApiName": "acme", "apiName": "acme_abc123", "name": "Acme", "liveVersion": null },
944
+ "owner": { "id": "7d1f…", "fullName": "Ada Lovelace", "yours": true },
945
+ "preview": {
946
+ "updated": "2026-10-20T00:00:00.000Z",
947
+ "activeUsersCount": 2,
948
+ "installedCount": 3,
949
+ "otherActiveUsersCount": 1
950
+ },
951
+ "deletesApp": true,
952
+ "notices": [],
953
+ "warnings": [
954
+ "This preview is the only version of Acme, so deleting it deletes the whole app from this business, with its settings and secrets.",
955
+ "1 other user is using this preview."
956
+ ],
957
+ "applyArgv": [
958
+ "appbuilder",
959
+ "app",
960
+ "preview",
961
+ "delete",
962
+ "--owner",
963
+ "7d1f…",
964
+ "--expect-updated",
965
+ "2026-10-20T00:00:00.000Z",
966
+ "--delete-app",
967
+ "--yes",
968
+ "--env",
969
+ "staging",
970
+ "--business",
971
+ "b0c6…",
972
+ "--user",
973
+ "7d1f…",
974
+ "--json"
975
+ ],
976
+ "requiresProductionConsent": false,
977
+ "next": []
978
+ }
979
+ ```
980
+
981
+ `activeUsersCount` counts everyone using the preview, its owner included; `otherActiveUsersCount` leaves you out (the users the delete switches and notifies). Either is `null` when Kizen doesn't say.
982
+
983
+ `applyArgv` reads the app again and refuses what the dry run didn't show: a preview that's gone is `not_found`; one pushed again since (its `updated` isn't `--expect-updated` any more) stops with `preview_changed`, and so does a delete that would now take the whole app with it when the dry run said the app stays (no `--delete-app`). A `--yes` run without `--delete-app` never deletes an app. At a terminal, deleting one takes a typed `y`, even with `--yes`, unless `--delete-app` is passed with it: `--yes --delete-app` is explicit consent and skips the confirm, as it does headless. When Kizen reports no last update for the preview (`preview.updated` is `null`), the dry run can't be pinned to it, so it has no `applyArgv` (and a notice says so). Nothing is deleted then. At a terminal the confirm re-checks the same way right before deleting. Kizen's delete takes no precondition, so a change in the moment between that last read and the delete itself can't be caught, as with `publish`'s promote.
984
+
985
+ The applied result adds `status: "deleted"` and `appDeleted`: `true` when the app no longer exists on the business afterwards (read again after the delete), `null` with a warning when that read failed. When the dry run said the app goes but another version appeared before the delete, the app stays: `appDeleted` is `false`, and the result says so. Deleting your own preview also forgets it in `.kizenapp/apps.json` (this folder's base stays), and `next` is a `push` dry run; deleting someone else's changes nothing here, and `next` is empty. When the app is deleted with the preview (`appDeleted: true`), whoever's preview it was, every base recorded here for the app is forgotten too, since it named a version of an app that's gone. A base recorded for an app that's no longer on the business is ignored in any case: the next `push` says so and records the base afresh, as for a new app.
986
+
987
+ #### Merging and conflict markers
988
+
989
+ `appbuilder app merge` three-way merges Live (or `--release <n>`) into this folder against the folder's recorded base, using `git` (it must be installed; the folder doesn't need to be a repository). Text conflicts get git's two-way markers: the side after `<<<<<<< HEAD` is this folder's file, the side before `>>>>>>> live` is the merged version's. The merge records which files have markers, and `app push` refuses with `unresolved_conflicts` until they're gone. An applied merge records the merged version as the folder's base, conflicts or not, so the next push is based on it. Files changed on both sides that aren't text keep your copy (`binaryConflicts`), files Live has but `.gitignore` or `.kizenignore` excludes here are not written (`ignoredIncoming`), and a file deleted on one side and edited on the other keeps the edit.
990
+
991
+ When the merge can't run (no usable base, or no `git`), the result's `kind` is `fallback`: applying it extracts the version's source into a new folder under `.kizenapp/` so you can merge by hand, and its `choices` record a base and merge from it (`--base <n>`) or record the version as already contained (`--accept-live-base`).
992
+
993
+ #### `base_required`
994
+
995
+ A folder with no recorded base (a fresh clone, or another developer's copy) can't be checked against Live. Its first `push` finds the base on its own when it can be sure of it: when the folder's files match your preview exactly, it takes your preview's base (`base.source: "preview"`; see below); otherwise, when they match Live or one of the latest releases exactly, that release (`"detected"`). Otherwise it stops with `base_required` and two choices: preview merging Live into the folder, or record that the folder already contains Live (`--accept-live-base`, only when that's true, or the next publish overwrites Live's changes).
996
+
997
+ When you have a preview whose base the server records, there's a third choice, "This folder continues your preview (based on vN)": `appbuilder app push --base-from-preview <id>`, a dry run that pushes this folder with your preview's base (`base.source: "base_from_preview"`). Pick it only when this folder really is your preview's source with more changes, for example the same work carried on from another machine; if the folder came from somewhere else, the next publish can overwrite Live's changes. It's never picked for you, `--yes` included. `<id>` pins the preview the choice was offered for: if your preview is pushed again in the meantime, the push doesn't take its base (a notice says so) and goes on as if the flag weren't given, so it can stop with `base_required` again.
998
+
999
+ With no base to merge from, the merge preview always comes back as a `fallback`. Its choices merge from the release the folder was copied from (`--base <n>`, one choice per recent release) or record the version as already contained. If you know which release the folder came from, run that `--base` choice: it merges like any other merge. A wrong one drops the changes made since then. If you don't know, apply the fallback: it extracts Live's source into `.kizenapp/live-v<n>-<time>/`, so you can merge its changes into the folder by hand and then record the base with the accept choice.
1000
+
1001
+ #### Moving to another machine
1002
+
1003
+ What your preview is based on lives on the server, in the preview itself: every source zip `push` and `rollback` upload carries a small record of the preview's base, its lineage (`.kizenapp/lineage.json` in the zip: the base's Live version, that version's source package, and a format version). It's never extracted into a folder and never counts when sources are compared. So:
1004
+
1005
+ - `publish` reads your preview's base from its source on the server, whichever folder or machine pushed it. Moving to another machine, or another folder, and publishing the preview you pushed elsewhere works as it did where you pushed it: no merge, no `--force`. A preview pushed again from somewhere else is judged by its own lineage.
1006
+ - A `push` from a folder with nothing recorded takes your preview's base when the folder's files match your preview exactly, and otherwise offers it as the third `base_required` choice above.
1007
+ - A preview whose record is missing or can't be read is never trusted: publish stops with `publish_conflict` and `conflict.reason: "base_unknown"`, and its `next` is a push dry run. Pushing this folder gives the preview a lineage; `--force` publishes it as it is.
1008
+ - A base names a version by number, and Kizen doesn't say which app a version belongs to, so an app deleted and created again reuses the numbers. The lineage also names the base version's source package. When your preview's base is the version publish compares with but that version has another source package now, publish stops with `publish_conflict` and `conflict.reason: "base_replaced"` (never a silent match): merge Live into the folder as for any conflict. A push never takes a base from a lineage whose package no longer matches, and a base recorded in `.kizenapp/apps.json` (always with its package) is ignored, with a notice, once that version's package differs.
1009
+
1010
+ A preview pushed from this folder and then published outside `appbuilder app publish` (in Kizen, or from another machine) is recognised too: when Live's source package is the one this folder's last push uploaded, Live is that push, so it becomes this folder's base (with a notice, and recorded on the next write to `.kizenapp/apps.json`), and `versions` and `push` don't ask for a merge. That holds only while this folder's base is still the one it pushed with, as Live's own lineage says; after a merge or `--accept-live-base` (or for a preview restored with `rollback`) the recorded base stays.
1011
+
1012
+ A developer with no preview of their own (a new one, say) gets their base from a release the folder matches exactly, or stops with `base_required`; their first push puts their preview's base on the server. Reading the lineage costs one download of your preview's source per `publish` (and per `push` with nothing recorded). If that download fails, `publish` stops, `--force` included, since what the preview is based on can't be read; try again, or push again.
1013
+
1014
+ #### `rollback` and `pull`
1015
+
1016
+ `appbuilder app rollback <n>` restores released version `<n>` as your preview without touching Live; publish it to make it Live. It uploads version `<n>`'s files again (unchanged) with the restored preview's lineage, which says it's based on the current Live version, so publishing it from any machine replaces Live on purpose rather than stopping on a conflict. When the app has releases but no Live version, the restored preview is based on no Live version, and publishing it stops with `publish_conflict` (`live_moved`, against the latest release) like any preview from before that release. `appbuilder app pull <n>` downloads release `<n>`'s source into a new folder (`../<api_name>-v<n>` by default, or `--out <dir>`), refusing a folder that exists or holds the plugin, and records `<n>` as that folder's base so pushing from it is checked like any other folder.
1017
+
1018
+ `appbuilder app pull --preview` does the same with your own preview's source (previews are per user, so it's always yours), into `../<api_name>-preview` by default, with the same `--out` rules and the same files left out. It fails with `no_preview` when you have none, before creating anything. The new folder's base is your preview's base, read from its lineage (see [Moving to another machine](#moving-to-another-machine)) and checked against the business the way `push` checks it, so `push`, `versions` and `merge` from the folder start from the same base as the folder that pushed the preview. The folder also records your preview as the one it last saved, so publishing that preview from the folder advances the folder's base, and, when a base was recorded, so does publishing it outside the CLI, as for the folder that pushed it. Until the folder pushes, a publish from it warns that no push from it is recorded. When the lineage is missing, can't be read, or names a release that no longer exists or has another source package now, no base is recorded (`base.recorded: false`, with a warning), and the first push from the folder finds one or stops with `base_required`. Its result has the release pull's keys, with `source: "preview"`, `preview` and `base` in place of `version`:
1019
+
1020
+ ```json
1021
+ {
1022
+ "ok": true,
1023
+ "environment": "staging",
1024
+ "businessId": "b0c6…",
1025
+ "userId": "7d1f…",
1026
+ "app": { "baseApiName": "acme", "apiName": "acme_abc123", "name": "Acme", "liveVersion": "5" },
1027
+ "source": "preview",
1028
+ "preview": { "updated": "2026-10-20T00:00:00.000Z", "sourcePackageId": "3f2a…" },
1029
+ "base": { "recorded": true, "version": "5" },
1030
+ "dir": "/work/acme-preview",
1031
+ "written": ["kizen.json", "src/a.js"],
1032
+ "skipped": [],
1033
+ "remembered": true,
1034
+ "warnings": [],
1035
+ "next": []
1036
+ }
1037
+ ```
1038
+
1039
+ `base.version` is `null` with `recorded: true` when your preview was pushed before the app had a Live version.
1040
+
1041
+ #### What a push uploads
1042
+
1043
+ In a git work tree, the files `git ls-files --cached --others --exclude-standard` lists: tracked files, plus untracked ones `.gitignore` (and git's other excludes) don't drop. Outside git, every file in the folder minus what the root `.gitignore` excludes. In both cases the root `.kizenignore` (gitignore syntax) then excludes more; it can't add back a file the other rules dropped. Some files are never uploaded whatever either file says: `node_modules`, `.git`, `.kizenapp`, `.kizenappbuilder`, `.copilot-docs`, `__pycache__` and `dist` at any depth, and `.DS_Store`, `.env`, `.env.*`, `.npmrc` and `credentials.json`. A source with a file over 50 MiB, or over 200 MiB in all, is refused with `source_invalid` before anything is uploaded: those are the limits `pull`, `merge`, `rollback` and base detection read source zips with. Neither are the skill folders appbuilder manages for coding agents (`.claude/skills/` and `.agents/skills/` `kizen-custom-block` and `kizen-business-apps`), which `setup-claude` and `setup-codex` rewrite on every upgrade: merges skip them, and a pull of an older release that has them leaves them out. Your own skills in those folders are uploaded. Symbolic links are never followed. The dry run's `source.files` counts what would go, and `source.bytes` and `source.hash` describe the folder's files; the zip uploaded also carries the preview's lineage at `.kizenapp/lineage.json` (see [Moving to another machine](#moving-to-another-machine)).
1044
+
1045
+ #### State
1046
+
1047
+ `.kizenapp/apps.json` (gitignored) records, per environment, business, app and user, the release this folder's source is based on (with that release's source package), which preview this folder last saved, and the files a merge left markers in. Don't edit it. Your preview's base isn't in it: it's in the preview's lineage on the server, which publish reads. `merge`, `--accept-live-base`, `pull` (in the folder it creates; `pull --preview` also records your preview there), publishing a preview pushed from this folder (here, or outside the CLI: see [Moving to another machine](#moving-to-another-machine)) and `push` (which records the base it pushed with) move the folder's base; `push` and `rollback` write the preview's into its lineage. A recorded base whose version no longer exists, or whose version is another one now (the app deleted and created again), is ignored with a notice, and the next push asks for a base again (`base_required`).
1048
+
1049
+ #### For coding agents
1050
+
1051
+ `appbuilder create` and `appbuilder setup-claude` / `setup-codex` install the `kizen-business-apps` skill, which tells Claude Code and Codex how to use these commands. Its rules: always pass `--json`; run every `argv` (`applyArgv`, `choices[].argv`, `next[].argv`, `login.argv`, and a JS action's `linkArgv`, `linkMenuArgv`, `linkNoMenuArgv` and `unlinkArgv`) exactly as given, the only edit being to replace a `<object>` element with an object's api name or id; show the user each dry run before running its `applyArgv`, and get their explicit go-ahead first when `requiresProductionConsent` is `true`; on exit 2 present the `choices` (the merge preview, a dry run, is the only one to run unasked; "This folder continues your preview" only when the user says the folder really continues their preview); never pass `--force`, `--allow-production` or `--accept-live-base` unless the user asked for it; never edit `.kizenapp/`; after a push or publish, link every JS action `jsActions` reports as `unlinked` or `unknown` to an object the user confirms (its `linkMenuArgv` or `linkNoMenuArgv`, a dry run first), and unlink (a link's `unlinkArgv`) only when asked; delete a preview only when asked, and another developer's only when the user names it.
1052
+
1053
+ Under Claude Code's sandbox, add `"appbuilder *"` to `sandbox.excludedCommands` in your user settings (`~/.claude/settings.json`); Claude Code ignores a project's `excludedCommands` in strict mode. An allowed-domains list can't cover `appbuilder`: `push` uploads go to whichever file-storage host the Kizen server names for each upload, and sessions are written to `~/.kizenappbuilder`. Under Codex, run `appbuilder` with escalated permissions (`sandbox_permissions: "require_escalated"`, `prefix_rule: ["appbuilder"]`).
1054
+
456
1055
  ### `appbuilder login`, `logout`, `whoami` and `auth-header`
457
1056
 
458
1057
  Browser sign-in, the default for `block push` and `block targets`. API keys are deprecated for these commands and are used only when you pass `-c` or `--profile`.
@@ -460,7 +1059,7 @@ Browser sign-in, the default for `block push` and `block targets`. API keys are
460
1059
  ```sh
461
1060
  appbuilder login [--env <env>] [--business <id or name> [--user <user id>]]
462
1061
  appbuilder login [--env <env>] --list [--json]
463
- appbuilder whoami [--env <env>] [--business <id or name> [--user <user id>]]
1062
+ appbuilder whoami [--env <env>] [--business <id or name> [--user <user id>]] [--json]
464
1063
  appbuilder logout [--env <env>] [--all | --business <id or name> [--user <user id>]]
465
1064
  appbuilder auth-header [--env <env>] [--business <business id> --user <user id>]
466
1065
  appbuilder block push [api_name] [--env <env>] [--business <id or name> [--user <user id>]] [flags]
@@ -490,6 +1089,8 @@ Two cases fall back to the browser: the saved account's refresh token has expire
490
1089
 
491
1090
  When both stdin and stdout are terminals and you pass neither `--business` nor `--list`, `login` shows a picker of the saved accounts, labeled by business name, business id and email, with "Sign in with the browser" as the last option. In every other case, `login` never prompts: without `--business` it runs the browser sign-in, and if accounts are saved it first prints a hint about `--business` and `--list` to stderr.
492
1091
 
1092
+ `whoami --json` prints `{ ok, environment, businessId, businessName, userId, fullName, email }` on stdout (`null` for what the session's identity doesn't say) and the usual lines on stderr. Its failures follow the `app` commands' contract: `{ ok: false, code, message, hint? }` with exit 1, `not_signed_in` carrying `login.argv` (the `appbuilder login` command to run), and `needs_choice` with `choice: "environment"` and exit 2 when you're signed in to several environments, each choice's `argv` a whole `appbuilder whoami … --json` command.
1093
+
493
1094
  `logout` removes the current account's session and leaves the other saved accounts. `logout --business <id or name>` removes one saved account, matched the same way as for `login`; if it's the current account, you're signed out too. `logout --all` removes every saved account for the environment. When no environment has a current account, both `--business` and `--all` need `--env`.
494
1095
 
495
1096
  | Command | `--env` default | What it does |
@@ -559,6 +1160,16 @@ To try a local `kizen` build, set `APPBUILDER_KIZEN_WHEEL` to the path of a `kiz
559
1160
 
560
1161
  ## Reference
561
1162
 
1163
+ ### Interactive or headless
1164
+
1165
+ `create`, `encrypt`, `login`, `block push` and every `app` command have an interactive terminal UI. They use it only when stdin and stdout are both terminals and nothing below asks for headless; otherwise they run headless and never prompt (`block push` and `app` then answer a question with a failure that lists the choices).
1166
+
1167
+ - `--json` (where the command has it) or `--no-interactive`.
1168
+ - `APPBUILDER_NO_INTERACTIVE` set to anything but empty, `0` or `false`.
1169
+ - A coding agent or CI: `CLAUDECODE` (Claude Code) or `CODEX_CI` (Codex) set to any value, `CI` set to anything but empty, `0` or `false`, or `TERM=dumb`.
1170
+
1171
+ Coding agents should pass `--json` anyway, so stdout is one JSON object.
1172
+
562
1173
  ### Environment variables
563
1174
 
564
1175
  Four environment variables point the CLI at a different Plugin Wizard (encryption API) host. Precedence for the `dev` target:
@@ -572,7 +1183,11 @@ Prod follows the same order minus step 3: `PLUGIN_WIZARD_URL`, then **`PLUGIN_WI
572
1183
 
573
1184
  **`CLAUDE_CODE_MCP_SERVER_URL`** is set by Claude Code when it runs `appbuilder auth-header`, which uses it to pick the environment (see [Using the session from Claude Code](#using-the-session-from-claude-code-mcp)).
574
1185
 
575
- **`APPBUILDER_BUSINESS`** and **`APPBUILDER_USER`** name a saved account for `whoami`, `admin`, `block push` and `block targets` to use instead of the current one, like `--business` and `--user`, which win over them. `APPBUILDER_USER` only applies with `APPBUILDER_BUSINESS`, and an empty value counts as unset. `auth-header` ignores them, and so do `block push` and `block targets` with `-c` or `--profile` (see [Saved accounts](#saved-accounts)).
1186
+ **`APPBUILDER_BUSINESS`** and **`APPBUILDER_USER`** name a saved account for `whoami`, `admin`, `block push`, `block targets` and the `app` commands to use instead of the current one, like `--business` and `--user`, which win over them. `APPBUILDER_USER` only applies with `APPBUILDER_BUSINESS`, and an empty value counts as unset. `auth-header` ignores them, and so do `block push` and `block targets` with `-c` or `--profile` (see [Saved accounts](#saved-accounts)).
1187
+
1188
+ **`APPBUILDER_NO_INTERACTIVE`** makes every command with an interactive UI run headless, like `--no-interactive`. **`CLAUDECODE`**, **`CODEX_CI`**, **`CI`** and **`TERM=dumb`** do the same; see [Interactive or headless](#interactive-or-headless).
1189
+
1190
+ **`CODEX_SANDBOX_NETWORK_DISABLED`** is set to `1` by Codex when its sandbox has the network turned off. A `network_error` then carries `sandbox: "codex_network_disabled"` and a `hint` saying to re-run the command with escalated permissions.
576
1191
 
577
1192
  **`APPBUILDER_KIZEN_WHEEL`** is the path of a local `kizen_builder-<version>-….whl` for `appbuilder admin` to install instead of the `kizen` release this CLI version pins, with no download or hash check (see [`appbuilder admin`](#appbuilder-admin)).
578
1193
 
@@ -580,13 +1195,14 @@ Prod follows the same order minus step 3: `PLUGIN_WIZARD_URL`, then **`PLUGIN_WI
580
1195
 
581
1196
  `build` and `dev` create `.kizenapp/` next to your `kizen.json` and add it to `.gitignore` automatically. It holds machine-local state only — **keep it gitignored**:
582
1197
 
583
- | Path | Contents |
584
- | ------------- | ------------------------------------------------------------------------------------------------------------------------------- |
585
- | `bundle.json` | The packaged, minified, validated plugin bundle the viewer loads. |
586
- | `config.json` | Per-project preferences: credential mode, active profile name, last viewed path, encryption target. |
587
- | `pushes.json` | The remembered `block push` targets: one dashlet per environment, business, plugin and block. |
588
- | `.chrome/` | The dedicated Chromium user-data directory for the viewer — cookies and session state included. |
589
- | `venv/` | The Python virtualenv used to execute code steps locally. Rebuilt when its interpreter is too old for the bundled requirements. |
1198
+ | Path | Contents |
1199
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1200
+ | `bundle.json` | The packaged, minified, validated plugin bundle the viewer loads. |
1201
+ | `config.json` | Per-project preferences: credential mode, active profile name, last viewed path, encryption target. |
1202
+ | `pushes.json` | The remembered `block push` targets: one dashlet per environment, business, plugin and block. |
1203
+ | `apps.json` | What `appbuilder app` knows about this folder: the release its source is based on, and the preview it last saved. Your preview's base is on the server, in its source. Don't edit it. |
1204
+ | `.chrome/` | The dedicated Chromium user-data directory for the viewer — cookies and session state included. |
1205
+ | `venv/` | The Python virtualenv used to execute code steps locally. Rebuilt when its interpreter is too old for the bundled requirements. |
590
1206
 
591
1207
  ### Navigation context
592
1208