zcode-app-cli 3.3.6-4 → 3.4.2-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # zcode-app-cli
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/zcode-app-cli.svg?label=npm)](https://www.npmjs.com/package/zcode-app-cli)
4
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
5
+
3
6
  Unofficial terminal client for the official agent runtime shipped with ZCode Desktop.
4
7
 
5
8
  The project extracts the upstream `resources/glm` runtime, injects a local
@@ -12,9 +15,34 @@ This project is not affiliated with or endorsed by Z.ai. ZCode and its bundled
12
15
  runtime remain subject to their upstream terms. Confirm that you are allowed to
13
16
  redistribute the extracted runtime before publishing the npm package.
14
17
 
15
- ## Install and update
18
+ ![zcode-app-cli TUI demo](./docs/assets/demo.svg)
19
+
20
+ ## Quick start
21
+
22
+ ```bash
23
+ npm install -g zcode-app-cli@latest
24
+ zcode
25
+ ```
26
+
27
+ On first launch, ZCode creates `~/.zcode/cli/config.json` (or
28
+ `%USERPROFILE%\.zcode\cli\config.json` on Windows) with credential-free
29
+ defaults. Choose one of the three model-access paths in
30
+ [Configuration](./docs/CONFIGURATION.md) before sending your first prompt.
31
+
32
+ ## Table of contents
16
33
 
17
- Install or update the CLI through the `latest` dist-tag:
34
+ - [Quick start](#quick-start)
35
+ - [Install and update](#install-and-update)
36
+ - [Architecture](#architecture)
37
+ - [Features](#features)
38
+ - [Workspace integration](#workspace-integration)
39
+ - [Requirements](#requirements)
40
+ - [Configuration](#configuration)
41
+ - [Local development](#local-development)
42
+ - [Contributing](#contributing)
43
+ - [License](#license)
44
+
45
+ ## Install and update
18
46
 
19
47
  ```bash
20
48
  npm install -g zcode-app-cli@latest
@@ -26,16 +54,11 @@ Using `@latest` is intentional because the App-aligned release format uses a
26
54
  SemVer prerelease segment such as `3.3.5-2`. The tag always points to the
27
55
  newest validated App-plus-build release.
28
56
 
29
- Interactive startup checks the npm `latest` tag at most once every 20 hours for
30
- each installed package version. Installing a different package build triggers
31
- one fresh check even when an older cache entry is still within that window.
32
- A cached newer version is shown as a non-blocking update card with the exact
33
- install command and release-notes link. Missing or stale cache data is refreshed
34
- in the background, and a newly discovered update is shown in the current
35
- session, so registry latency or failure never delays the editor. Set
36
- `ZCODE_DISABLE_UPDATE_CHECK=1` or
37
- `NO_UPDATE_NOTIFIER=1` to disable the check; CI environments skip it
38
- automatically.
57
+ Interactive startup checks the npm `latest` tag at most once every 20 hours
58
+ per installed version and shows a cached newer version as a non-blocking
59
+ update card with the exact install command and release-notes link. CI
60
+ environments skip the check automatically. Set `ZCODE_DISABLE_UPDATE_CHECK=1`
61
+ or `NO_UPDATE_NOTIFIER=1` to disable it.
39
62
 
40
63
  A normal installation requires only Node.js and has no native PTY addon or
41
64
  postinstall build step.
@@ -53,48 +76,58 @@ Node.js npm launcher (config / login / version metadata)
53
76
  The official agent, model, session, tool, plugin, MCP, credential store and
54
77
  provider-configuration logic remains in the extracted runtime. The local
55
78
  package supplies the missing terminal interface and a narrow macOS callback
56
- bridge for Z.AI's registered Desktop OAuth flow.
57
-
58
- Node.js starts the public npm command and remains the compatibility host for the
59
- extracted upstream kernel. The official runtime directly owns raw terminal mode,
60
- IME cursor placement and resize handling; the launcher does not insert a second
61
- PTY or relay terminal bytes. Synchronization adds the local TUI/data bridge,
62
- OAuth compatibility handoff and clearer HTTP diagnostics. OAuth callbacks are
63
- passed to the official runtime over stdin; its encrypted credential store,
64
- Coding Plan key resolver and config writer remain the only persistence path.
65
-
66
- ## Current TUI functionality
67
-
68
- - pi-tui differential rendering and CJK-aware multi-line editor;
69
- - streamed assistant text from official ZCode session events;
70
- - slash-command and workspace-path completion;
71
- - persisted prompt history through ZCode's history API;
72
- - `/mode`, `/model`, `/resume`, `/plugins` and other upstream slash commands;
73
- - searchable model and reasoning-effort selectors, plus MCP and workflow panels;
74
- - status-bar-only Shift+Tab mode (`build` → `edit` → `yolo` → `plan`), Ctrl+N model and empty-prompt Tab effort cycling;
75
- - structured session-goal status in the right side of the turn footer;
76
- - animated active-turn timer with a static `ZCODE_TUI_REDUCED_MOTION=1` fallback;
77
- - responsive context-remaining and session-token metrics in the status line;
78
- - generic upstream selection dialogs for sessions, plugins and checkpoints;
79
- - `/login` setup choices with masked API-key entry, redacted transcript/history and OAuth waiting state;
80
- - suspended Z.AI browser login with terminal restoration and an optional `ZCODE_TUI_LOGIN_CMD` override;
81
- - interactive tool-permission approval dialogs;
82
- - clipboard image attachments through Ctrl+V or `/paste-image`, with a keyboard-selectable attachment row;
83
- - compact tool execution views with path, command, progress, result and image previews;
84
- - parent/child Agent tool trees with resumable subagent metadata and expandable Prompt/Response details;
85
- - syntax-highlighted Markdown code blocks with stable streaming-block rendering;
86
- - Pierre-style inline diffs with line numbers, syntax highlighting, word-level changes and CJK wrapping;
87
- - `/diff` browser for current Git changes and per-turn file changes, including paged details and binary/untracked states;
88
- - terminal-native Mermaid previews with source fallback for unsupported or oversized diagrams;
89
- - `/context` prompt-composition, cache and context-usage details;
90
- - `/status` session, runtime, goal, MCP and workspace details;
91
- - searchable transcript navigation with per-block expansion, selected-block copying and `n`/`N` match traversal;
92
- - persistent active-tool, background-task and open-plan activity between the transcript and editor;
93
- - active-turn steering, cancellation and error reporting;
94
- - unfocused turn-completion notifications through terminal-native OSC 9 or BEL, with optional desktop commands;
95
- - double-Esc rewind with input-point selection and safe conversation/workspace scopes;
96
- - `/copy`, `/clear`, `/exit`, Ctrl+C and Ctrl+D handling with token usage and resume guidance on exit;
97
- - `--no-color` and `NO_COLOR` support.
79
+ bridge for Z.AI's registered Desktop OAuth flow. Node.js starts the public npm
80
+ command and remains the compatibility host for the extracted upstream kernel.
81
+ The official runtime directly owns raw terminal mode, IME cursor placement and
82
+ resize handling; the launcher does not insert a second PTY or relay terminal
83
+ bytes.
84
+
85
+ ## Features
86
+
87
+ **Editor and input.** pi-tui differential rendering with a CJK-aware
88
+ multi-line editor; slash-command and workspace-path completion; persisted
89
+ prompt history through ZCode's history API; `--no-color` and `NO_COLOR`
90
+ support.
91
+
92
+ **Streaming and conversation.** Streamed assistant text from official ZCode
93
+ session events; `/mode`, `/model`, `/resume`, `/plugins` and other upstream
94
+ slash commands; searchable model and reasoning-effort selectors, plus MCP and
95
+ workflow panels; status-bar-only Shift+Tab mode cycling
96
+ (`build` → `edit` → `yolo` → `plan`), Ctrl+N model and empty-prompt Tab effort
97
+ cycling; structured session-goal status in the right side of the turn footer;
98
+ animated active-turn timer with a static `ZCODE_TUI_REDUCED_MOTION=1`
99
+ fallback; responsive context-remaining and session-token metrics.
100
+
101
+ **Login and permissions.** `/login` setup choices with masked API-key entry,
102
+ redacted transcript/history and OAuth waiting state; suspended Z.AI browser
103
+ login with terminal restoration and an optional `ZCODE_TUI_LOGIN_CMD`
104
+ override; interactive tool-permission approval dialogs.
105
+
106
+ **Attachments and rich output.** Clipboard image attachments through Ctrl+V
107
+ or `/paste-image`, with a keyboard-selectable attachment row; compact tool
108
+ execution views with path, command, progress, result and image previews;
109
+ parent/child Agent tool trees with resumable subagent metadata and expandable
110
+ Prompt/Response details; syntax-highlighted Markdown code blocks with stable
111
+ streaming-block rendering; Pierre-style inline diffs with line numbers,
112
+ syntax highlighting, word-level changes and CJK wrapping; terminal-native
113
+ Mermaid previews with source fallback for unsupported or oversized diagrams.
114
+
115
+ **Inspection and navigation.** `/diff` browser for current Git changes and
116
+ per-turn file changes; `/context` prompt-composition, cache and context-usage
117
+ details; `/status` session, runtime, goal, MCP and workspace details;
118
+ `/activity` and `/tasks` for active tools and background tasks; searchable
119
+ transcript navigation with per-block expansion, selected-block copying and
120
+ `n`/`N` match traversal; persistent active-tool, background-task and open-plan
121
+ activity between the transcript and editor.
122
+
123
+ **Steering, rewind and notifications.** Active-turn steering, cancellation
124
+ and error reporting; double-Esc rewind with input-point selection and safe
125
+ conversation/workspace scopes; unfocused turn-completion notifications through
126
+ terminal-native OSC 9 or BEL, with optional desktop commands; `/copy`,
127
+ `/clear`, `/exit`, Ctrl+C and Ctrl+D handling with token usage and resume
128
+ guidance on exit.
129
+
130
+ ## Workspace integration
98
131
 
99
132
  ### Referencing workspace files
100
133
 
@@ -148,68 +181,6 @@ Move the editor cursor to the start of its first line and press `Up`, or run
148
181
  Run `/attachments clear` to remove every pending image at once. `Ctrl+D`
149
182
  retains its terminal-standard empty-editor exit and forward-delete behavior.
150
183
 
151
- ### Theme
152
-
153
- Set `ui.theme` to `"auto"` (terminal detection), `"dark"`, or `"light"` in the
154
- user config: `~/.zcode/cli/config.json` on macOS/Linux or
155
- `%USERPROFILE%\.zcode\cli\config.json` on Windows. An explicit dark/light value
156
- takes priority over terminal probing. `auto` queries the terminal background
157
- color and color scheme at startup and re-applies the matching palette.
158
-
159
- ### Turn completion notifications
160
-
161
- Notifications are enabled by default and emitted after a normal agent turn
162
- completes or fails while the terminal is unfocused. Following Codex's terminal
163
- capability fallback, `auto` uses OSC 9 in Ghostty, iTerm2, Kitty, Warp and
164
- WezTerm, and BEL in terminals such as Apple Terminal. Selecting OSC 9 in an
165
- unsupported terminal also falls back to BEL instead of silently emitting an
166
- ignored sequence.
167
-
168
- The `unfocused` condition uses DEC focus reporting when the terminal provides
169
- it. Until focus support is confirmed, ZCode sends the notification instead of
170
- permanently suppressing it as focused. `native` is an explicit opt-in that uses
171
- an existing system command: `terminal-notifier` on macOS, `notify-send` on
172
- Linux, or `SnoreToast` on Windows. These tools are not bundled, keeping the
173
- default terminal notification path dependency-free. If the selected command is
174
- unavailable or delivery fails, ZCode falls back to BEL. On macOS, the detected
175
- terminal application is used as both the sender and click target. Exact tab or
176
- pane restoration remains terminal-dependent; use the default `auto` setting so
177
- OSC-capable terminals can preserve their native session behavior.
178
-
179
- Open the interactive settings picker inside the TUI (both commands are
180
- equivalent):
181
-
182
- ```text
183
- /config
184
- /settings
185
- ```
186
-
187
- Saving a value returns to the settings root so several options can be changed
188
- in one visit. `Esc` returns from a setting to the root, then closes the root.
189
-
190
- The picker updates the active session immediately and persists the selected
191
- values under `ui.notifications` in the cross-platform user `config.json`:
192
-
193
- ```json
194
- {
195
- "ui": {
196
- "notifications": {
197
- "method": "auto",
198
- "condition": "unfocused"
199
- }
200
- }
201
- }
202
- ```
203
-
204
- Environment variables override `config.json` on startup and are useful for a
205
- temporary per-shell setting:
206
-
207
- ```bash
208
- export ZCODE_TUI_NOTIFICATION_METHOD=auto # auto|osc9|bel|native|off
209
- export ZCODE_TUI_NOTIFICATION_CONDITION=always # unfocused|always
210
- node bin/zcode.js
211
- ```
212
-
213
184
  ### Conversation rewind
214
185
 
215
186
  With an empty editor and no active turn, press `Esc` twice within 800 ms to
@@ -255,9 +226,6 @@ an oversized selected block without rendering the entire message at once.
255
226
  - Node.js 22.19 or newer;
256
227
  - macOS, Linux or Windows on x64 or ARM64.
257
228
 
258
- Developing or publishing from source additionally requires Bun 1.3 or newer.
259
- `7z` is needed only when downloading and extracting a remote installer.
260
-
261
229
  Z.AI browser OAuth currently requires macOS because the registered provider
262
230
  callback is `zcode://zai-auth/callback`; API-key and custom-provider access work
263
231
  on every supported platform.
@@ -265,201 +233,26 @@ on every supported platform.
265
233
  Set `ZCODE_NODE=/absolute/path/to/node` when the desired Node.js executable is
266
234
  not available on `PATH`.
267
235
 
268
- ## Model access and configuration
269
-
270
- On first launch, ZCode recursively creates the configuration directory and a
271
- credential-free `config.json` when it is missing. Existing files are never
272
- replaced. The location is `~/.zcode/cli/config.json` on macOS and Linux, and
273
- `%USERPROFILE%\.zcode\cli\config.json` on Windows. Newly created directories
274
- and files use private permissions on POSIX; Windows keeps the current user's
275
- inherited ACLs.
276
-
277
- The generated file contains the complete non-secret configuration shape plus
278
- valid Z.AI model metadata, but deliberately omits `apiKey` until one is
279
- configured. This lets the official runtime and TUI start cleanly without
280
- pretending that model access is already configured. Choose one of these
281
- model-access paths before sending a prompt:
282
-
283
- - Z.AI OAuth on macOS: run `zcode login` when no provider is configured, or
284
- `zcode login --oauth` to force reauthorization;
285
- - Z.AI/BigModel Coding Plan API key: open `/login` in the TUI and choose the
286
- matching masked API-key option;
287
- - direct API key with a custom provider: use the
288
- [`config.example.json`](./config.example.json) template and do not log in.
289
-
290
- When `model.main` already resolves to a configured provider/model with an
291
- inline API key, plain `zcode login` exits successfully and explains that OAuth
292
- is unnecessary. This prevents a custom provider from being replaced by an
293
- unrelated login flow.
294
-
295
- ### Coding Plan API key
296
-
297
- Start the TUI and open its setup picker:
298
-
299
- ```text
300
- /login
301
- ```
302
-
303
- Choose either **Z.AI Coding Plan API Key** or **BigModel Coding Plan API Key**,
304
- then paste the key into the masked prompt. The raw key is sent only to the
305
- official runtime's `configureCodingPlanApiKey` implementation. The local TUI
306
- does not add it to editor history or the visible/session transcript, and error
307
- messages are redacted before rendering.
308
-
309
- The same picker includes a **Custom provider** entry that points to the
310
- configuration-template path below. Custom providers do not use OAuth.
311
-
312
- Selecting **Z.AI Coding Plan** releases TUI raw mode and starts the registered
313
- Desktop authorization-code flow. On macOS the CLI temporarily installs a
314
- background-only callback receiver, verifies the returned `state`, restores the
315
- previous `zcode://` handler, and hands the callback to the official runtime.
316
- The authorization code travels over stdin instead of command-line arguments or
317
- environment variables. The runtime performs token exchange, encrypted
318
- credential persistence, Coding Plan API-key resolution and `config.json`
319
- updates. The TUI is then restored and the model configuration is re-read.
320
-
321
- The callback receiver is removed after success, cancellation or timeout. A
322
- small recovery record lets the next login restore the previous handler after
323
- an unclean process exit. The BigModel option continues to use the official
324
- localhost-callback implementation inside the runtime.
325
-
326
- ### Custom provider without login
327
-
328
- Start `zcode` once to generate the full user configuration automatically. From
329
- a source checkout, `config.example.json` contains the same initial structure
330
- for reference. Then edit the generated file:
331
-
332
- ```bash
333
- zcode
334
- ```
335
-
336
- Edit these four areas in `~/.zcode/cli/config.json` (or the Windows path shown
337
- above):
338
-
339
- 1. `provider.zai.kind`: use `anthropic`, `openai-compatible`, or `openai`;
340
- 2. `provider.zai.options.baseURL`: use the provider's API root;
341
- 3. `provider.zai.options.apiKey`: insert the direct API key;
342
- 4. replace the entries in `provider.zai.models`, then point both `model.main`
343
- and `model.lite` at the desired model IDs.
344
-
345
- The provider map key is deliberately `zai`. The upstream CLI 0.15.x TUI
346
- considers a direct API key configured only when it is stored under provider ID
347
- `zai` or `bigmodel`. An arbitrary provider ID is valid model configuration,
348
- but as the only provider it still triggers the upstream login gate. The
349
- display name, API format, endpoint, headers and models remain fully custom.
350
-
351
- For an Anthropic-compatible endpoint:
352
-
353
- ```json
354
- {
355
- "kind": "anthropic",
356
- "options": {
357
- "baseURL": "https://example.com/api/anthropic",
358
- "apiKey": "YOUR_API_KEY",
359
- "apiKeyRequired": true
360
- }
361
- }
362
- ```
363
-
364
- Use the API root, not a final `/messages` path. For an OpenAI-compatible
365
- endpoint, set `kind` to `openai-compatible` and normally use a root ending in
366
- `/v1`, not `/chat/completions`. For the official OpenAI API, use `openai`;
367
- `baseURL` can be omitted.
368
-
369
- The object keys form the runtime model reference:
370
-
371
- ```text
372
- provider.<provider-id>.models.<model-id>
373
- -> <provider-id>/<model-id>
374
- ```
375
-
376
- Set both roles to keep all work on the custom provider:
377
-
378
- ```json
379
- {
380
- "model": {
381
- "main": "zai/your-model-id",
382
- "lite": "zai/your-model-id"
383
- }
384
- }
385
- ```
386
-
387
- `main` is the normal conversation model. `lite` is used for lightweight and
388
- subagent work. Model IDs are case-sensitive and must match the endpoint.
389
-
390
- The no-login TUI path currently requires a non-empty `options.apiKey` in the
391
- local config; an environment-only API key does not satisfy the upstream login
392
- gate. Never commit the populated file, and keep its mode at `600`.
393
-
394
- ### Use the custom provider
395
-
396
- After saving the config, no login command is required. Start the client:
397
-
398
- ```bash
399
- node bin/zcode.js
400
- ```
401
-
402
- Or, after `bun link` or an npm installation:
403
-
404
- ```bash
405
- zcode
406
- ```
407
-
408
- Use these commands inside the TUI:
409
-
410
- ```text
411
- /model # show the active and available models
412
- /model zai/your-model-id # switch to the custom provider explicitly
413
- /new # start a new session with the configured default
414
- ```
415
-
416
- The status line should show `zai/your-model-id`. Setting both `model.main` and
417
- `model.lite` in the config makes the custom provider the default for normal,
418
- lightweight and subagent work. A resumed session may retain its previous model,
419
- so use `/new` after changing the default.
420
-
421
- Headless prompts use the same provider configuration:
422
-
423
- ```bash
424
- zcode --prompt "Explain this repository"
425
- ```
426
-
427
- `ZCODE_MODEL`, `zcode.json`, or `.zcode/config.json` can override the
428
- user-level default. Running `/model` does not call the provider, so it is a safe
429
- configuration check before the first prompt.
430
-
431
- ### Request retries and stalled streams
432
-
433
- The CLI leaves retry classification and execution to the official ZCode
434
- runtime. It supplies a default retry budget of five retries; override it when
435
- needed with the runtime's own environment variable:
436
-
437
- ```bash
438
- ZCODE_MODEL_RETRY_MAX_RETRIES=3 zcode
439
- ```
440
-
441
- Newly generated configs use a 60-second model-stream idle timeout:
236
+ ## Configuration
442
237
 
443
- ```json
444
- {
445
- "modelStream": {
446
- "idleTimeoutMs": 60000
447
- }
448
- }
449
- ```
238
+ ZCode reads configuration from `~/.zcode/cli/config.json` (or
239
+ `%USERPROFILE%\.zcode\cli\config.json` on Windows), with project-level
240
+ overrides from `zcode.json` or `.zcode/config.json` in the working directory.
241
+ Existing files are never replaced.
450
242
 
451
- Existing configs are never overwritten, so update this field manually if an
452
- older generated file still contains `600000`. Retryable timeouts, dropped
453
- streams, rate limits and server/network errors are retried and shown in the
454
- TUI. Authentication and invalid-request responses remain non-retryable.
243
+ Three model-access paths are supported: Z.AI OAuth (macOS only), Z.AI/BigModel
244
+ Coding Plan API key, or a direct API key with a custom provider. For detailed
245
+ setup steps, retries/timeouts, theme, and turn-completion notifications, see
246
+ [Configuration](./docs/CONFIGURATION.md).
455
247
 
456
248
  ## Local development
457
249
 
458
- Install dependencies and extract the already installed macOS application:
250
+ Install dependencies and start the client with live TypeScript and auto-sync
251
+ from the local ZCode Desktop installation:
459
252
 
460
253
  ```bash
461
254
  bun install
462
- bun run sync:local
255
+ bun run dev
463
256
  ```
464
257
 
465
258
  Run all validation layers:
@@ -471,270 +264,18 @@ bun run check
471
264
  bun run check:tui
472
265
  ```
473
266
 
474
- `check:tui` runs real-PTY scenarios. The official runtime scenario completes
475
- masked Coding Plan API-key setup in a temporary home, verifies the official
476
- config output, executes `/help`, switches to plan mode, exits, and checks that
477
- the launcher forwards terminal SIGHUP shutdown. The offline
478
- feature scenario also covers suspended login restoration, selectors, image
479
- attachments, nested Agent tools, Markdown, Mermaid, diffs, transcript
480
- navigation, context/status details, MCP actions, background tasks and the
481
- workflow panel. A pressure scenario verifies that steering, UTF-8 input and
482
- Ctrl+C cancellation remain responsive during rapid Bash progress output. The
483
- scenarios advance from observed terminal output instead of fixed timers and do
484
- not make model API calls.
485
-
486
- Start the client directly:
487
-
488
- ```bash
489
- node bin/zcode.js
490
- ```
491
-
492
- For the OAuth path:
493
-
494
- ```bash
495
- node bin/zcode.js login --oauth
496
- node bin/zcode.js
497
- ```
498
-
499
- To print the authorization URL without launching the browser:
500
-
501
- ```bash
502
- node bin/zcode.js login --oauth --no-browser
503
- ```
504
-
505
- The URL must still be opened on the same Mac so its `zcode://` callback reaches
506
- the waiting CLI. Cross-device SSH login is not supported by this provider flow;
507
- use the masked Z.AI Coding Plan API-key option instead. The wrapper no longer
508
- uses the upstream `oauth/cli/init` polling endpoint, which currently returns
509
- HTTP 404.
510
-
511
- Verify native callback capture and automatic handler restoration without
512
- contacting Z.AI or changing the real `zcode://` association:
513
-
514
- ```bash
515
- bun run check:oauth-callback
516
- ```
517
-
518
- ### Continuous integration
519
-
520
- `.github/workflows/ci.yml` runs for pull requests, pushes to `main` and manual
521
- dispatches. It validates the project on the minimum supported Node.js 22.19,
522
- including the locked runtime build, TypeScript and unit tests, PTY scenarios,
523
- the reviewed npm tarball and an isolated installed-package smoke test. A newer
524
- commit to the same pull request or branch automatically cancels its superseded
525
- CI run; unrelated pull requests continue independently.
526
-
527
- To hand `/login` to another interactive command, set an explicit override:
528
-
529
- ```bash
530
- export ZCODE_TUI_LOGIN_CMD='zcode login --oauth'
531
- ```
532
-
533
- The TUI then releases raw terminal mode, runs that command with inherited
534
- stdio, restores the interface, and checks `~/.zcode/cli/config.json` again.
535
-
536
- For the direct API-key path, follow
537
- [Custom provider without login](#custom-provider-without-login) instead.
538
-
539
- Install a local `zcode` command:
540
-
541
- ```bash
542
- bun link
543
- zcode
544
- ```
545
-
546
- Headless and protocol commands use the same inherited stdio path:
547
-
548
- ```bash
549
- zcode --version
550
- zcode doctor --json
551
- zcode --prompt "Explain this repository"
552
- zcode app-server
553
- ```
554
-
555
- `zcode version`, `zcode --version` and `zcode -v` identify both packaged
556
- layers explicitly:
557
-
558
- ```text
559
- zcode-app-cli 3.3.6-3
560
- zcode-runtime 0.15.2
561
- ```
562
-
563
- ## Remote extraction
564
-
565
- The same path used by CI can be run locally:
566
-
567
- ```bash
568
- brew install sevenzip
569
- bun run sync -- --platform linux --arch x64
570
- ```
571
-
572
- Use the committed artifact instead of the latest updater manifest when
573
- rebuilding a reviewed release:
574
-
575
- ```bash
576
- bun run sync:locked
577
- ```
578
-
579
- The synchronization command:
580
-
581
- 1. reads the official updater manifest;
582
- 2. downloads the matching installer;
583
- 3. verifies its SHA-512 from the manifest;
584
- 4. extracts `resources/glm`;
585
- 5. builds and injects the local `@zcode/tui` adapter;
586
- 6. validates the official CLI version;
587
- 7. records provenance in `vendor/extraction.json`;
588
- 8. records the remote artifact URL and SHA-512 in
589
- `zcode-runtime.lock.json`;
590
- 9. aligns the npm version prefix with the ZCode App version while preserving
591
- the independently incremented CLI build revision.
592
-
593
- ## npm package contents
594
-
595
- The published package is controlled by the `files` allowlist in `package.json`.
596
- It contains only:
267
+ For the OAuth path, release workflow details, CI, and the full development
268
+ guide, see [Development](./docs/DEVELOPMENT.md). For maintainer-only release
269
+ and publishing workflows, see [Releasing](./docs/RELEASING.md).
597
270
 
598
- - `bin/zcode.js`, the bundled executable Node.js launcher;
599
- - `vendor/`, the verified official `zcode.cjs` runtime, official bundled
600
- plugins and the compiled local `@zcode/tui` adapter;
601
- - `config.example.json` and `zcode-runtime.lock.json`;
602
- - `README.md`, `LICENSE` and the required npm `package.json`.
271
+ ## Contributing
603
272
 
604
- Tests, GitHub workflows, build scripts, launcher/TUI TypeScript sources, local
605
- config, `.release/` artifacts and development `node_modules` are not published.
606
- npm installs only the declared pi-tui runtime dependency. The launcher and TUI
607
- are compiled to JavaScript with `tsdown`; its launcher banner adds the Node.js
608
- shebang directly, with no post-build rewrite. The compiled TUI is injected into
609
- `vendor/` before publication.
273
+ Issues and pull requests are welcome at
274
+ [github.com/kingsword09/zcode-cli](https://github.com/kingsword09/zcode-cli).
275
+ Please open an issue first to discuss substantial changes. See
276
+ [Development](./docs/DEVELOPMENT.md) for the local setup and validation
277
+ commands, and [Releasing](./docs/RELEASING.md) for the release flow.
610
278
 
611
- ## Automated npm publishing
612
-
613
- Package versions use `<app-version>-<build>`, for example `3.3.5-2`. The prefix
614
- tracks the upstream ZCode App. The globally increasing build revision tracks
615
- fixes and features in this project. Do not use `3.3.5+build.2`: SemVer ignores
616
- `+build` metadata when comparing upgrades.
617
-
618
- Increment the project revision before publishing a local fix or feature:
619
-
620
- ```bash
621
- bun run version:build
622
- ```
623
-
624
- The release workflows normally perform that increment for you. The command is
625
- also available for local inspection and exceptional manual preparation.
626
-
627
- ### Release flow
628
-
629
- Publishing is split into two workflows so the committed version, npm package,
630
- Git tag and GitHub Release all describe the same release:
631
-
632
- 1. `.github/workflows/prepare-release.yml` extracts and validates the current
633
- official runtime, then opens or updates a Release PR containing the exact
634
- `package.json` version and `zcode-runtime.lock.json` build input;
635
- 2. a maintainer reviews and merges that PR;
636
- 3. `.github/workflows/publish.yml` checks out its merge commit, rebuilds the
637
- exact locked runtime, audits and install-tests the tarball, publishes through
638
- npm Trusted Publishing, then creates `v<version>` and the corresponding
639
- GitHub Release.
640
-
641
- The generated `vendor/` directory remains ignored by Git and is rebuilt in both
642
- workflows. Its updater URL and SHA-512 are committed in
643
- `zcode-runtime.lock.json`. Preparation resolves the latest manifest; publishing
644
- downloads the committed URL and verifies the locked SHA-512, so a later upstream
645
- update cannot silently change a reviewed release.
646
-
647
- The preparation workflow runs every day at 02:23 UTC in `upstream` mode. It
648
- creates a PR when the ZCode App version or the pinned installer changes. A
649
- same-version upstream repack increments the global build so npm still receives
650
- an immutable new version. From the Actions page, run **Prepare ZCode CLI
651
- release** with one of these modes:
652
-
653
- - `cli` increments the global build and also aligns with the latest App;
654
- - `upstream` checks for an App update without incrementing the build.
655
-
656
- The modes use `release/zcode-cli` and `release/zcode-upstream` respectively. If
657
- both PRs are open, merge one and rerun the other preparation mode so its version
658
- is recalculated from the new `main` branch.
659
-
660
- Merging either Release PR publishes automatically. **Publish ZCode CLI
661
- release** can also be started manually for recovery. Its `publish` checkbox can
662
- be disabled to run all validation and consistency checks without changing npm,
663
- Git tags or GitHub Releases. Publication, tag creation and GitHub Release
664
- creation are independently idempotent, so a partially completed run can be
665
- retried safely.
666
-
667
- ### Local release build
668
-
669
- Local packaging uses the same commands as the publishing workflow. Start from
670
- the exact clean commit whose version will be published:
671
-
672
- ```bash
673
- bun install --frozen-lockfile
674
- bun run release:build
675
- git diff --exit-code -- package.json zcode-runtime.lock.json
676
- bun run release:pack
677
- ```
678
-
679
- `release:build` runs TypeScript checking and all tests, downloads the artifact
680
- from `zcode-runtime.lock.json`, verifies its SHA-512, builds and injects the TUI,
681
- then runs runtime and PTY smoke tests. `release:pack` runs the offline
682
- `prepack` guard, creates `.release/zcode-app-cli-<version>.tgz`, audits every
683
- included path and executable mode, installs it into a temporary directory, and
684
- runs the installed `zcode --version`. Its final size, integrity and file count
685
- are written to `.release/release.json`.
686
-
687
- Inspect that manifest and then publish explicitly:
688
-
689
- ```bash
690
- npm login
691
- npm publish --access public --tag latest --provenance=false
692
- ```
279
+ ## License
693
280
 
694
- The final `npm publish` intentionally remains explicit to avoid an accidental
695
- registry mutation. It reruns the same offline `prepack` guard and fails if the
696
- compiled TUI, runtime provenance, lock file, launcher permissions or package
697
- allowlist are stale. `--provenance=false` applies only to this local bootstrap
698
- path; GitHub OIDC generates provenance automatically.
699
-
700
- Publish from the repository root as shown, rather than passing the `.tgz` to
701
- `npm publish`: directory publication lets npm record the current Git `gitHead`,
702
- which the recovery workflow later verifies. The tarball is the audited preview
703
- and install-test artifact.
704
-
705
- ### Initial npm setup
706
-
707
- If the package does not exist on npm yet, bootstrap it once from the exact
708
- committed `main` revision using the local release build above. If its Git diff
709
- check fails, do not publish from that working tree; refresh the Release PR or
710
- restore the committed version and lock first.
711
-
712
- Synchronization preserves the build when the upstream App version changes. For
713
- example, syncing `3.3.5-12` against ZCode App `3.4.0` produces `3.4.0-12`.
714
-
715
- Before enabling publication:
716
-
717
- 1. confirm that `zcode-app-cli` is the npm package name you control;
718
- 2. confirm redistribution rights for the extracted ZCode runtime;
719
- 3. under the GitHub repository's **Settings** → **Actions** → **General**,
720
- enable **Allow GitHub Actions to create and approve pull requests**;
721
- 4. open the package on npmjs.com and select **Settings** →
722
- **Trusted Publisher** → **GitHub Actions**;
723
- 5. enter the GitHub organization or user, repository, and workflow filename
724
- `publish.yml`; leave the environment name empty because this
725
- workflow does not use a GitHub Environment, and select `npm publish` under
726
- **Allowed actions**;
727
- 6. save the publisher, prepare a `cli` release, and merge its Release PR to
728
- verify an OIDC publication.
729
-
730
- The publisher runs on a GitHub-hosted runner with Node 24, grants
731
- `id-token: write`, and updates npm to the current release. It never reads an
732
- `NPM_TOKEN` repository secret; npm attaches provenance from the OIDC identity.
733
- After verifying the first OIDC release, npm recommends setting **Publishing
734
- access** to require 2FA and disallow tokens, then revoking any obsolete
735
- automation token.
736
-
737
- The publisher skips an identical existing version, refuses older versions,
738
- verifies every existing npm release's `gitHead`, and refuses to reuse a tag
739
- that points at another commit. The `latest` dist-tag therefore advances only
740
- to the newest validated App-plus-build release.
281
+ MIT — see [LICENSE](./LICENSE).