@kizenapps/cli 1.17.0-d9d38e3 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -66
- package/dist/index.js +102 -102
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,25 +122,26 @@ As with `create`, the workflow only runs once it has reached the repository's de
|
|
|
122
122
|
|
|
123
123
|
### `appbuilder setup-claude`
|
|
124
124
|
|
|
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.
|
|
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).
|
|
126
126
|
|
|
127
127
|
```sh
|
|
128
|
-
appbuilder setup-claude [--dry-run] [--include-lib]
|
|
128
|
+
appbuilder setup-claude [--dry-run] [--include-lib]
|
|
129
|
+
appbuilder setup-claude --mcp [--env <env>] [--force] [--dry-run]
|
|
129
130
|
```
|
|
130
131
|
|
|
131
|
-
| Flag | Default | Purpose
|
|
132
|
-
| --------------- | ------- |
|
|
133
|
-
| `--dry-run` | off | Report what would change without writing files.
|
|
134
|
-
| `--include-lib` | off | Also install the Kizen data helper library (`kizenData.js`).
|
|
135
|
-
| `--mcp` | off |
|
|
136
|
-
| `--env <env>` | `go` | Environment of the MCP server to register.
|
|
137
|
-
| `--force` | off | Replace an existing registration of that server.
|
|
132
|
+
| Flag | Default | Purpose |
|
|
133
|
+
| --------------- | ------- | -------------------------------------------------------------------------------------------------------------- |
|
|
134
|
+
| `--dry-run` | off | Report what would change without writing files. |
|
|
135
|
+
| `--include-lib` | off | Also install the Kizen data helper library (`kizenData.js`). |
|
|
136
|
+
| `--mcp` | off | Only register the Kizen MCP server in Claude Code (user scope); writes no files, so it works in any directory. |
|
|
137
|
+
| `--env <env>` | `go` | Environment of the MCP server to register. |
|
|
138
|
+
| `--force` | off | Replace an existing registration of that server. |
|
|
138
139
|
|
|
139
|
-
`--env` and `--force` only apply with `--mcp`; see [Using the session from Claude Code](#using-the-session-from-claude-code-mcp).
|
|
140
|
+
`--env` and `--force` only apply with `--mcp`, and `--mcp` can't be combined with `--include-lib`; see [Using the session from Claude Code](#using-the-session-from-claude-code-mcp).
|
|
140
141
|
|
|
141
142
|
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`.
|
|
142
143
|
|
|
143
|
-
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.
|
|
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.
|
|
144
145
|
|
|
145
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.
|
|
146
147
|
|
|
@@ -239,27 +240,29 @@ Packages the plugin in the current directory (same validation as `block export`)
|
|
|
239
240
|
appbuilder block push [api_name] [flags]
|
|
240
241
|
```
|
|
241
242
|
|
|
242
|
-
Interactive by default: pick the environment (only when you're signed in to several
|
|
243
|
+
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.
|
|
243
244
|
|
|
244
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.
|
|
245
246
|
|
|
246
|
-
| Argument / flag | Default
|
|
247
|
-
| -------------------------- |
|
|
248
|
-
| `[api_name]` | the plugin's only block
|
|
249
|
-
| `-c, --credentials <path>` | the sign-in session
|
|
250
|
-
| `--profile <name>` | the sign-in session
|
|
251
|
-
| `--dashboard <id>` | the remembered target
|
|
252
|
-
| `--dashlet <id>` | matched by push history or name
|
|
253
|
-
| `--create` | off
|
|
254
|
-
| `--dry-run` | off
|
|
255
|
-
| `--yes` | off
|
|
256
|
-
| `--allow-production` | off
|
|
257
|
-
| `--force` | off
|
|
258
|
-
| `--forget` | off
|
|
259
|
-
| `--json` | off
|
|
260
|
-
| `--env <env>` | the only signed-in environment
|
|
261
|
-
|
|
262
|
-
|
|
247
|
+
| Argument / flag | Default | Purpose |
|
|
248
|
+
| -------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
249
|
+
| `[api_name]` | the plugin's only block | Block to push. Required when the plugin has more than one block. |
|
|
250
|
+
| `-c, --credentials <path>` | the sign-in session | API key (deprecated): credentials JSON file to use instead of the session |
|
|
251
|
+
| `--profile <name>` | the sign-in session | API key (deprecated): stored credential profile to use instead of the session |
|
|
252
|
+
| `--dashboard <id>` | the remembered target | Dashboard, homepage or chart group to push to |
|
|
253
|
+
| `--dashlet <id>` | matched by push history or name | Existing custom code dashlet to update. Needs `--dashboard`; can't be used with `--create`. |
|
|
254
|
+
| `--create` | off | Create a new dashlet instead of updating one |
|
|
255
|
+
| `--dry-run` | off | Resolve everything and print the request without writing |
|
|
256
|
+
| `--yes` | off | Write without asking. Headless runs without it are dry runs. |
|
|
257
|
+
| `--allow-production` | off | Allow headless writes to `go` / `fmo` |
|
|
258
|
+
| `--force` | off | Overwrite a dashlet that was edited in Kizen since the last push |
|
|
259
|
+
| `--forget` | off | Clear the remembered target for this block before resolving |
|
|
260
|
+
| `--json` | off | Print a JSON result to stdout (forces headless); the human summary goes to stderr |
|
|
261
|
+
| `--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
|
+
| `--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
|
+
| `--user <user id>` | `$APPBUILDER_USER` | With `--business`, the user id of that saved account. Not with `-c` or `--profile`. |
|
|
264
|
+
|
|
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.
|
|
263
266
|
|
|
264
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.
|
|
265
268
|
|
|
@@ -359,24 +362,24 @@ A failure exits 1:
|
|
|
359
362
|
|
|
360
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`).
|
|
361
364
|
|
|
362
|
-
| Code | Meaning
|
|
363
|
-
| --------------------------- |
|
|
364
|
-
| `needs_choice` | An environment, block, dashboard or target must be chosen; see `choice` and `choices`
|
|
365
|
-
| `validation_failed` | The plugin failed validation
|
|
366
|
-
| `invalid_block` | The plugin has no blocks, or the block would be rejected (`field` names the problem)
|
|
367
|
-
| `credentials_invalid` | Not signed in (run `appbuilder login`), or the `-c`/`--profile` file's `environment` is missing or invalid
|
|
368
|
-
| `auth_failed` | Kizen rejected the credentials
|
|
369
|
-
| `forbidden` | The credentials can't access the dashboard
|
|
370
|
-
| `not_found` | The dashboard, or the `--dashlet` on it, doesn't exist
|
|
371
|
-
| `remembered_target_missing` | The remembered dashboard or dashlet is gone; nothing is created without `--create`
|
|
372
|
-
| `drift_detected` | The dashlet was edited in Kizen since the last push; `--force` overwrites
|
|
373
|
-
| `production_requires_flag` | `--yes` against `go` / `fmo` without `--allow-production`
|
|
374
|
-
| `usage_error` | Conflicting flags (`--dashlet` with `--create`, `--dashlet` without `--dashboard`),
|
|
375
|
-
| `network_error` | Kizen couldn't be reached
|
|
376
|
-
| `api_error` | Any other Kizen API failure
|
|
377
|
-
| `local_error` | A local failure that isn't a validation error: no `kizen.json`, packaging, reading `.kizenapp/pushes.json`, or writing it for `--forget`
|
|
378
|
-
|
|
379
|
-
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>] }`)
|
|
365
|
+
| Code | Meaning |
|
|
366
|
+
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
367
|
+
| `needs_choice` | An environment, block, dashboard or target must be chosen; see `choice` and `choices` |
|
|
368
|
+
| `validation_failed` | The plugin failed validation |
|
|
369
|
+
| `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 |
|
|
371
|
+
| `auth_failed` | Kizen rejected the credentials |
|
|
372
|
+
| `forbidden` | The credentials can't access the dashboard |
|
|
373
|
+
| `not_found` | The dashboard, or the `--dashlet` on it, doesn't exist |
|
|
374
|
+
| `remembered_target_missing` | The remembered dashboard or dashlet is gone; nothing is created without `--create` |
|
|
375
|
+
| `drift_detected` | The dashlet was edited in Kizen since the last push; `--force` overwrites |
|
|
376
|
+
| `production_requires_flag` | `--yes` against `go` / `fmo` without `--allow-production` |
|
|
377
|
+
| `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 |
|
|
379
|
+
| `api_error` | Any other Kizen API failure |
|
|
380
|
+
| `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
|
+
|
|
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`.
|
|
380
383
|
|
|
381
384
|
### `appbuilder block targets`
|
|
382
385
|
|
|
@@ -393,8 +396,10 @@ The CLI honors `HTTP_PROXY`/`HTTPS_PROXY` and `NO_PROXY` on Node versions that s
|
|
|
393
396
|
| `--object <id>` | — | List the chart groups of this custom object (or Contacts) |
|
|
394
397
|
| `--json` | off | Print JSON instead of tables |
|
|
395
398
|
| `--env <env>` | as for `block push` | Environment of the session to use. Not with `-c`/`--profile`. |
|
|
399
|
+
| `--business <id or name>` | as for `block push` | Saved account to use. Not with `-c`/`--profile`. |
|
|
400
|
+
| `--user <user id>` | as for `block push` | With `--business`, the user id of that saved account. |
|
|
396
401
|
|
|
397
|
-
Credentials and `--
|
|
402
|
+
Credentials, `--env`, `--business` and `--user` work as for `block push` (see [`appbuilder login`](#appbuilder-login-logout-whoami-and-auth-header)).
|
|
398
403
|
|
|
399
404
|
```json
|
|
400
405
|
{
|
|
@@ -455,18 +460,22 @@ Browser sign-in, the default for `block push` and `block targets`. API keys are
|
|
|
455
460
|
```sh
|
|
456
461
|
appbuilder login [--env <env>] [--business <id or name> [--user <user id>]]
|
|
457
462
|
appbuilder login [--env <env>] --list [--json]
|
|
458
|
-
appbuilder whoami [--env <env>]
|
|
463
|
+
appbuilder whoami [--env <env>] [--business <id or name> [--user <user id>]]
|
|
459
464
|
appbuilder logout [--env <env>] [--all | --business <id or name> [--user <user id>]]
|
|
460
465
|
appbuilder auth-header [--env <env>] [--business <business id> --user <user id>]
|
|
461
|
-
appbuilder block push [api_name] [--env <env>] [flags]
|
|
462
|
-
appbuilder block targets [--env <env>] [flags]
|
|
466
|
+
appbuilder block push [api_name] [--env <env>] [--business <id or name> [--user <user id>]] [flags]
|
|
467
|
+
appbuilder block targets [--env <env>] [--business <id or name> [--user <user id>]] [flags]
|
|
463
468
|
```
|
|
464
469
|
|
|
465
|
-
`login` opens Kizen's consent page in your browser and prints the URL in case the browser doesn't open. There, you pick the business the session is for. The CLI waits up to 5 minutes for the browser to return to `http://127.0.0.1:<port>/callback`. It uses OAuth 2.0 authorization code with PKCE (S256). It only trusts the server's OAuth metadata when its `issuer` is exactly the environment's origin (for example `https://staging.kizen.com`). It registers itself with the server on first use (dynamic client registration), so you don't need an API key or a client secret. A request to the callback with the wrong `state` gets a `400` and is otherwise ignored, so the sign-in keeps waiting for the real callback. Each session belongs to one user and one business, which the CLI looks up with `/auth/bootstrap` right after sign-in. If that lookup fails, nothing is saved. Signing in again to the same account replaces its session. A `block push` or `block targets` that's already running
|
|
470
|
+
`login` opens Kizen's consent page in your browser and prints the URL in case the browser doesn't open. There, you pick the business the session is for. The CLI waits up to 5 minutes for the browser to return to `http://127.0.0.1:<port>/callback`. It uses OAuth 2.0 authorization code with PKCE (S256). It only trusts the server's OAuth metadata when its `issuer` is exactly the environment's origin (for example `https://staging.kizen.com`). It registers itself with the server on first use (dynamic client registration), so you don't need an API key or a client secret. A request to the callback with the wrong `state` gets a `400` and is otherwise ignored, so the sign-in keeps waiting for the real callback. Each session belongs to one user and one business, which the CLI looks up with `/auth/bootstrap` right after sign-in. If that lookup fails, nothing is saved. Signing in again to the same account replaces its session. A `block push` or `block targets` that's already running keeps to the account it started with: switching to another account meanwhile doesn't affect it, and neither does signing in again to the same account. Signing out of that account stops it with a sign-in error. If the browser shows an error instead of the consent page, the saved app registration is probably stale. The sign-in then times out and clears that app registration, so running `appbuilder login` again registers afresh.
|
|
466
471
|
|
|
467
472
|
#### Saved accounts
|
|
468
473
|
|
|
469
|
-
Every account you sign in to stays saved on this machine, and one of them is current for each environment. `whoami`, `auth-header`, `block push` and `block targets`
|
|
474
|
+
Every account you sign in to stays saved on this machine, and one of them is current for each environment. `whoami`, `auth-header`, `admin`, `block push` and `block targets` use the current one unless you name another.
|
|
475
|
+
|
|
476
|
+
To use another saved account for one command without switching, pass `--business <id or name>` (and `--user <user id>`) to `whoami`, `admin`, `block push` or `block targets`, or set `APPBUILDER_BUSINESS` (and `APPBUILDER_USER`) in its environment. The flags win over the variables, and the variables over the current account; an empty variable counts as unset. The value is matched as for `login --business` below, among the saved accounts of one environment. With `--env`, that environment. Without it, the only environment where the value matches a saved account; whether any account there is current doesn't matter. If it matches in several environments, the command fails, names them and asks for `--env`. If it matches nowhere, the environment is the only one with any saved accounts, current or not, and the command fails listing them; with saved accounts in several environments, pass `--env`. If it matches no saved account in the environment, or several, the command fails and lists them; it never falls back to the current account. Naming an account never changes which one is current. `auth-header` ignores the variables, so an MCP `headersHelper` always serves the current account.
|
|
477
|
+
|
|
478
|
+
To switch without the browser, which is how scripts and agents should do it:
|
|
470
479
|
|
|
471
480
|
```sh
|
|
472
481
|
appbuilder login --env staging --list # one line per saved account; the current one is marked
|
|
@@ -483,16 +492,16 @@ When both stdin and stdout are terminals and you pass neither `--business` nor `
|
|
|
483
492
|
|
|
484
493
|
`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`.
|
|
485
494
|
|
|
486
|
-
| Command | `--env` default
|
|
487
|
-
| ------------- |
|
|
488
|
-
| `login` | `go`
|
|
489
|
-
| `whoami` | the only environment you're signed in to
|
|
490
|
-
| `logout` | the only environment you're signed in to
|
|
491
|
-
| `auth-header` | from the MCP server URL ([see below](#using-the-session-from-claude-code-mcp))
|
|
495
|
+
| Command | `--env` default | What it does |
|
|
496
|
+
| ------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
497
|
+
| `login` | `go` | Signs in with the browser, or switches to a saved account, and stores the session |
|
|
498
|
+
| `whoami` | the only environment you're signed in to; with `--business`, the only one where it's saved | Calls `/auth/bootstrap` with the current account's session, or the saved account `--business` names, and prints the user and business. Tokens are never printed. |
|
|
499
|
+
| `logout` | the only environment you're signed in to | Deletes the current account's session, one saved account (`--business`), or all of them (`--all`). Local only: the refresh tokens stay valid on Kizen. |
|
|
500
|
+
| `auth-header` | from the MCP server URL ([see below](#using-the-session-from-claude-code-mcp)) | Prints `{"Authorization":"Bearer <access token>"}` for a Claude Code MCP `headersHelper`. With `--business` and `--user` (used together, by id), it serves only that saved account, whether or not it's current; [`appbuilder admin`](#appbuilder-admin) passes them. |
|
|
492
501
|
|
|
493
502
|
The production write gate (`--allow-production`) and every other flag of `block push` and `block targets` work the same with a session as with an API key.
|
|
494
503
|
|
|
495
|
-
Sessions are stored in `~/.kizenappbuilder/oauth/` (directory `0700`, files `0600`), separate from API-key profiles. Each saved account has its own file, `<env>.<business id>.<user id>.json`, and `<env>.json` names the current account. Access tokens last an hour and refresh automatically: when less than a minute is left, or once after a `401`. Refresh tokens rotate on each use. Each process makes one refresh at a time, and every file is written atomically. Concurrent `appbuilder` processes may each refresh, which is safe because Kizen returns the same token pair when a refresh token is reused within 5 minutes. Before saving, a refresh re-reads the session: it keeps the newer tokens if another process already refreshed or you signed in again to the same account, and it fails with a sign-in error if you signed out
|
|
504
|
+
Sessions are stored in `~/.kizenappbuilder/oauth/` (directory `0700`, files `0600`), separate from API-key profiles. Each saved account has its own file, `<env>.<business id>.<user id>.json`, and `<env>.json` names the current account. Access tokens last an hour and refresh automatically: when less than a minute is left, or once after a `401`. Refresh tokens rotate on each use. Each process makes one refresh at a time, and every file is written atomically. Concurrent `appbuilder` processes may each refresh, which is safe because Kizen returns the same token pair when a refresh token is reused within 5 minutes. Before saving, a refresh re-reads the session: it keeps the newer tokens if another process already refreshed or you signed in again to the same account, and it fails with a sign-in error if you signed out of that account meanwhile. A switch to another account doesn't affect it. If the refresh token is rejected, the CLI keeps the tokens another process already refreshed to; otherwise it deletes that account's file, and the command asks you to run `appbuilder login` again (with `--env <env>` for an environment other than `go`). A refresh only ever writes or deletes its own account's file, and only `login` and `logout` change which account is current, so a refresh that finishes late can't undo a logout or a switch.
|
|
496
505
|
|
|
497
506
|
A session file that is corrupt or can't be read isn't treated as "not signed in". Commands that use it report the file's path and ask you to run `appbuilder login` (with `--env <env>` for an environment other than `go`). `appbuilder logout --env <env>` signs you out either way. If the session file is the problem, logout removes it. If `<env>.json` is the problem, logout removes that and leaves the saved accounts, and `logout --all` removes those too. `login --list` still lists a saved account whose file can't be read, by its ids.
|
|
498
507
|
|
|
@@ -500,14 +509,14 @@ A session file that is corrupt or can't be read isn't treated as "not signed in"
|
|
|
500
509
|
|
|
501
510
|
Kizen's MCP server at `/api/mcp` accepts the same session. As a Claude Code `headersHelper`, `appbuilder auth-header` prints `{"Authorization":"Bearer <access token>"}` as one line on stdout, refreshing the token first if it's about to expire.
|
|
502
511
|
|
|
503
|
-
To set it up, run these from
|
|
512
|
+
To set it up, run these from any directory:
|
|
504
513
|
|
|
505
514
|
```sh
|
|
506
515
|
npx @kizenapps/cli setup-claude --mcp --env staging
|
|
507
516
|
npx @kizenapps/cli login --env staging
|
|
508
517
|
```
|
|
509
518
|
|
|
510
|
-
`setup-claude --mcp`
|
|
519
|
+
`setup-claude --mcp` only registers the server `kizen-<env>` at user scope, by running `claude mcp add-json` (`--dry-run` only prints that command). It writes no files, in a plugin directory or anywhere else. The helper is pinned to the version of the CLI you ran it with. For CLI version 1.16.0, for example, it's equivalent to this POSIX-shell command:
|
|
511
520
|
|
|
512
521
|
```sh
|
|
513
522
|
claude mcp add-json --scope user kizen-staging '{"type":"http","url":"https://staging.kizen.com/api/mcp","headersHelper":"npx -y @kizenapps/cli@1.16.0 auth-header"}'
|
|
@@ -517,7 +526,7 @@ claude mcp add-json --scope user kizen-staging '{"type":"http","url":"https://st
|
|
|
517
526
|
- `--force` only replaces the user-scope server. A server with the same name at local or project scope (for example, one you added by hand without `--scope user`) takes precedence over it in that project. Remove that one with `claude mcp remove kizen-<env>` (run in the project) if you want the user-scope server there.
|
|
518
527
|
- If the `claude` command isn't installed, it prints this command for you to run instead, and still succeeds.
|
|
519
528
|
- If you aren't signed in to that environment yet, it reminds you to run `appbuilder login` (with `--env <env>` for an environment other than `go`). If the saved session can't be read, it prints that error, with the file's path, instead. Either way the server is still registered.
|
|
520
|
-
- If registering fails, the
|
|
529
|
+
- If registering fails, the command exits with code 1.
|
|
521
530
|
|
|
522
531
|
The helper runs through `npx`, which reuses its cached copy of the CLI (running `setup-claude` through `npx` fills that cache), so it starts in about a second. That works when Claude Code was started from a shell with `node` on `PATH`. If it wasn't (for example, with nvm and Claude Code launched outside a terminal), use absolute paths instead, from `which node` and `which appbuilder`: `"headersHelper":"/absolute/path/to/node /absolute/path/to/appbuilder auth-header"`. `appbuilder` starts with `#!/usr/bin/env node`, so the path to `appbuilder` alone isn't enough. Use the absolute paths too when testing a local or `pnpm link` build whose version isn't published, because `npx` can't fetch that version.
|
|
523
532
|
|
|
@@ -534,17 +543,17 @@ Claude Code gives the helper 10 seconds, so `auth-header` uses shorter timeouts
|
|
|
534
543
|
Runs Kizen's admin CLI, `kizen`, signed in with your `appbuilder login` session. You don't install `kizen` yourself: you only need Python 3.12 or newer on `PATH`.
|
|
535
544
|
|
|
536
545
|
```sh
|
|
537
|
-
appbuilder admin [--env <env>] [--] <kizen args...>
|
|
546
|
+
appbuilder admin [--env <env>] [--business <id or name> [--user <user id>]] [--] <kizen args...>
|
|
538
547
|
appbuilder admin init [--force]
|
|
539
548
|
```
|
|
540
549
|
|
|
541
|
-
`--env` picks the session, and defaults to the only environment you're signed in to. The wrapper's own options (`--env`, `-h`/`--help`) come first and end at the first other argument or at `--`. Everything after that goes to `kizen` verbatim, so `appbuilder admin status --help` shows `kizen`'s help, and `appbuilder admin --help` shows this wrapper's. `init` is the wrapper's own subcommand only as the first argument; `appbuilder admin -- init` passes `init` to `kizen`.
|
|
550
|
+
`--env` picks the session, and defaults to the only environment you're signed in to. `kizen` runs as that environment's current account, unless `--business` (and `--user`), or `APPBUILDER_BUSINESS` (and `APPBUILDER_USER`), names another saved account; then `--env` defaults to the only environment where that name matches a saved account (see [Saved accounts](#saved-accounts)). The wrapper's own options (`--env`, `--business`, `--user`, `-h`/`--help`) come first and end at the first other argument or at `--`. Everything after that goes to `kizen` verbatim, so `appbuilder admin status --help` shows `kizen`'s help, and `appbuilder admin --help` shows this wrapper's. `init` is the wrapper's own subcommand only as the first argument; `appbuilder admin -- init` passes `init` to `kizen`.
|
|
542
551
|
|
|
543
552
|
On first use, `appbuilder admin` installs `kizen` into a private virtual environment under `~/.kizenappbuilder/kizen/<version>-<sha>/` and reuses it afterwards without touching the network. `appbuilder admin init` does that ahead of time, and needs no session. It uses the newest of `python3.14`, `python3.13`, `python3.12` and `python3` that is 3.12 or newer, downloads the `kizen` release this CLI version pins (currently 0.3.0) from its GitHub release, checks its sha256, and installs it and its dependencies from PyPI with `pip`. Progress goes to stderr; stdout is `kizen`'s. Each time it makes a new install, it removes installs for other `kizen` versions that have gone unused for 30 days.
|
|
544
553
|
|
|
545
554
|
If the install is damaged (for example, the Python it was built with was removed), the command says so and changes nothing. `appbuilder admin init --force` deletes the install and installs it again. Don't run it while `appbuilder admin` is running, since a running `kizen` uses that install.
|
|
546
555
|
|
|
547
|
-
Under app-builder, `kizen` gets your session through `KIZEN_AUTH_HELPER`: it names `appbuilder auth-header --env <env> --business <business id> --user <user id>`, which `kizen` runs when it needs a token, and `KIZEN_BASE_URL`, `KIZEN_BUSINESS_ID` and `KIZEN_USER_ID` identify the session. With `--business` and `--user`, `auth-header` serves only that account,
|
|
556
|
+
Under app-builder, `kizen` gets your session through `KIZEN_AUTH_HELPER`: it names `appbuilder auth-header --env <env> --business <business id> --user <user id>`, which `kizen` runs when it needs a token, and `KIZEN_BASE_URL`, `KIZEN_BUSINESS_ID` and `KIZEN_USER_ID` identify the session. With `--business` and `--user`, `auth-header` serves only that account, whether or not it's current, so switching accounts with `appbuilder login` while `kizen` runs doesn't affect it. `kizen` keeps the token for the life of its process and runs the helper again only after a `401`. If you sign out of that account while `kizen` runs, its next token fetch (at startup, or after a `401`) fails. The token never appears in `kizen`'s environment or arguments. `KIZEN_PROFILE` and `CLAUDE_CODE_MCP_SERVER_URL` are removed from its environment. Under app-builder, `kizen` refuses `init`, `envs list` and `upgrade` (`upgrade --check` reports that app-builder manages the install). The command exits with `kizen`'s exit code.
|
|
548
557
|
|
|
549
558
|
To try a local `kizen` build, set `APPBUILDER_KIZEN_WHEEL` to the path of a `kizen_builder-<version>-….whl`. It's installed instead of the pinned release, with no download or hash check.
|
|
550
559
|
|
|
@@ -563,6 +572,8 @@ Prod follows the same order minus step 3: `PLUGIN_WIZARD_URL`, then **`PLUGIN_WI
|
|
|
563
572
|
|
|
564
573
|
**`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)).
|
|
565
574
|
|
|
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)).
|
|
576
|
+
|
|
566
577
|
**`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)).
|
|
567
578
|
|
|
568
579
|
### The `.kizenapp/` directory
|