zcode-app-cli 3.11.2-24 → 3.12.3-26

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.
Files changed (39) hide show
  1. package/README.md +35 -8
  2. package/bin/zcode.js +265 -133
  3. package/docs/CONFIGURATION.md +387 -0
  4. package/docs/CONFIGURATION.zh-CN.md +324 -0
  5. package/docs/PROVIDER_CONFIG.md +271 -0
  6. package/docs/PROVIDER_CONFIG.zh-CN.md +245 -0
  7. package/package.json +15 -6
  8. package/provider.example.json +151 -0
  9. package/{config.example.json → setting.example.json} +0 -47
  10. package/vendor/cli-config.cjs +161 -0
  11. package/vendor/extraction.json +17 -4
  12. package/vendor/node_modules/@zcode/tui/dist/index.js +495 -1095
  13. package/vendor/packages/browser-use-plugin/dist/mcp/server.js +35543 -34422
  14. package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +2 -2
  15. package/vendor/packages/document-skills-plugin/package.json +4 -4
  16. package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +34 -0
  17. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-advanced.md +9 -0
  18. package/vendor/packages/document-skills-plugin/skills/docx/routes/edit.md +11 -0
  19. package/vendor/packages/document-skills-plugin/skills/docx/routes/format.md +7 -0
  20. package/vendor/packages/document-skills-plugin/skills/docx/routes/read.md +7 -0
  21. package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +10 -1
  22. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +19 -4
  23. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/env_check.sh +6 -2
  24. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup.md +12 -3
  25. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_mac_linux.sh +9 -3
  26. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_windows.ps1 +8 -3
  27. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +30 -6
  28. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +9 -3
  29. package/vendor/packages/document-skills-plugin/skills/pptx/SKILL.md +33 -0
  30. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/setup.md +29 -4
  31. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/setup_mac_linux.sh +8 -3
  32. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/setup_windows.ps1 +8 -3
  33. package/vendor/packages/document-skills-plugin/skills/xlsx/quality/pipeline.md +9 -0
  34. package/vendor/packages/document-skills-plugin/skills/xlsx/setup.sh +8 -3
  35. package/vendor/packages/document-skills-plugin/skills/xlsx/xlsx.py +15 -1
  36. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/restore-conversation.mjs +13 -8
  37. package/vendor/provider/zcode-builtin.json +6296 -0
  38. package/vendor/zcode.cjs +1159 -840
  39. package/zcode-runtime.lock.json +3 -3
@@ -0,0 +1,387 @@
1
+ # Configuration
2
+
3
+ English | [简体中文](CONFIGURATION.zh-CN.md)
4
+
5
+ The CLI follows the current ZCode runtime's provider registry schema. General
6
+ runtime settings and provider configuration live in separate files.
7
+
8
+ ## Configuration files
9
+
10
+ | File | Purpose |
11
+ | --- | --- |
12
+ | `~/.zcode/cli/setting.json` | CLI theme, notifications, tools, storage and other runtime settings |
13
+ | `~/.zcode/v2/setting.json` | Existing Desktop language and memory preferences, read without modification |
14
+ | `~/.zcode/v2/provider_config.json` | Providers, model metadata overrides and the default model |
15
+ | `~/.zcode/v2/credentials.json` | Credentials persisted by the native runtime |
16
+
17
+ On Windows, use `%USERPROFILE%` in place of `~`. The provider file is shared
18
+ with ZCode Desktop by default: changing providers or the saved default affects
19
+ both clients. `/model` changes only the current CLI session.
20
+
21
+ Set `ZCODE_PERSONAL_PROVIDER_CONFIG_FILE` to a separate file to isolate provider
22
+ settings. `ZCODE_DATA_BASE_DIR` changes the native runtime's base directory,
23
+ including its provider and credential storage. General CLI settings still use
24
+ the user's `~/.zcode/cli/setting.json`.
25
+
26
+ On first launch, the CLI creates a credential-free general configuration from
27
+ [`setting.example.json`](../setting.example.json). Existing files are not replaced.
28
+ Provider settings are created by native login or configured using
29
+ [`provider.example.json`](../provider.example.json). The complete
30
+ [provider field reference](PROVIDER_CONFIG.md) explains every supported personal
31
+ configuration field, Desktop editor mapping and automatic catalog inheritance.
32
+
33
+ ## Startup migration
34
+
35
+ The CLI follows the Desktop migration rules and uses the runtime's native parser
36
+ and file-locked provider repository. Desktop imports its legacy providers when
37
+ its native file is first created. CLI startup performs one additional, one-time
38
+ merge from `~/.zcode/cli/config.json`, because the shared provider file may
39
+ already have been created by Desktop.
40
+
41
+ Only missing personal provider IDs are added. Existing provider definitions,
42
+ model overrides, ordering and the shared default selection are preserved.
43
+ Account providers and encrypted secrets are excluded. Deleted models are
44
+ excluded; native model IDs and provider aliases are normalized by the upstream
45
+ parser. Unsupported provider configurations are recorded as skipped.
46
+
47
+ CLI-specific fields move to `~/.zcode/cli/setting.json`; provider, main/lite and
48
+ catalog-overlay fields are omitted. The original file remains intact. A marker
49
+ under `~/.zcode/cli/migrations/` records completion for each target provider file,
50
+ so later startup does not re-import providers that a user has deleted. A separate
51
+ `settings-v1.json` marker prevents a reset of CLI settings from importing the old
52
+ settings again. The old
53
+ file is never used as a runtime configuration fallback. Invalid new files are
54
+ reported rather than replaced by old settings.
55
+
56
+ ## Setting ownership and precedence
57
+
58
+ | Setting or action | Read/write behavior |
59
+ | --- | --- |
60
+ | Providers and model metadata | Shared native `provider_config.json` |
61
+ | Default model in `/settings` | Writes the shared default and applies it to the current session |
62
+ | `/model`, model cycling and reasoning effort | Change/persist this session's native selection; shared default stays unchanged |
63
+ | `/new` | Reads the current shared default |
64
+ | Resume/restart | Restores the session's model and reasoning options |
65
+ | Language and memory | Reads Desktop `localePreference` / `memoryEnabled`; explicit CLI settings override these values |
66
+ | Theme, terminal layout, copy-on-select and notifications | CLI `setting.json` |
67
+ | Tool permissions, retries, stream timeout, CLI plugin/MCP options and other runtime settings | CLI `setting.json`, with native project/environment precedence |
68
+ | Update cache, diagnostic logs and migration state | Operational files beneath the CLI directory |
69
+
70
+ The CLI does not add keys to Desktop's `setting.json`. Notification and display
71
+ changes write only the CLI file. Shared preferences are applied while loading
72
+ runtime settings, not copied into CLI settings during unrelated updates.
73
+
74
+ ## Model catalogs and default selection
75
+
76
+ The native registry loads the bundled catalog and manages upstream catalog
77
+ refreshes. `/model`, model cycling, and **Settings > Model providers** refresh
78
+ the current registry from its configuration sources. The session is retained.
79
+ The CLI does not keep a separate legacy model catalog cache.
80
+
81
+ `config.defaultModelSelection` in the provider file chooses the model for new
82
+ sessions. `/settings` saves that selection through the native repository and
83
+ applies it to the current session. `/model provider/model` is a temporary session
84
+ switch. A resumed session can retain its saved selection.
85
+
86
+ Reasoning options omitted from a saved selection are completed using that
87
+ model's registry defaults. Explicit reasoning choices remain intact.
88
+
89
+ ## First-run setup
90
+
91
+ The setup wizard appears on the first interactive launch. Choose **Sign in**,
92
+ **Custom provider**, or **Skip for now**. `/setup` reopens it. A `setup-pending`
93
+ marker beside the general config survives non-interactive commands and is
94
+ cleared after successful configuration or an explicit skip. An existing native
95
+ provider configuration is recognized directly; no desktop import step is needed.
96
+
97
+ ## Model access
98
+
99
+ - **Z.AI OAuth on macOS:** use `zcode login`, or `zcode login --oauth` to force
100
+ authorization. `--no-browser` prints the authorization URL.
101
+ - **Z.AI/BigModel Coding Plan API key:** open `/login` and choose the masked
102
+ API-key option. The official runtime owns credential and provider persistence.
103
+ - **Custom provider:** configure the native provider file directly. Any provider
104
+ ID can be used; a separate OAuth login is unnecessary.
105
+
106
+ Plain `zcode login` recognizes a configured native default and reports its
107
+ configuration path. Configuration presence is checked locally; credential
108
+ validation and decryption belong to the runtime.
109
+
110
+ For macOS OAuth, the CLI temporarily registers a callback receiver, checks
111
+ `state`, restores the previous `zcode://` handler and sends the callback through
112
+ stdin. The runtime exchanges the token, stores encrypted credentials, resolves
113
+ the Coding Plan API key and saves the native default model. The TUI then rereads
114
+ provider configuration. BigModel uses the runtime's localhost callback.
115
+
116
+ ## Custom provider
117
+
118
+ Use `provider.example.json` as a reference for a new provider file. Its enabled
119
+ model inherits the upstream catalog; its disabled reference models demonstrate
120
+ all smart-override and manual fields. Fill the empty API key, replace the
121
+ placeholder IDs/endpoint, and remove unused reference entries. When a file already
122
+ exists, merge the desired provider rule into it and preserve the other rules and
123
+ selections.
124
+
125
+ A minimal configuration uses this structure:
126
+
127
+ ```json
128
+ {
129
+ "schemaVersion": 1,
130
+ "config": {
131
+ "providerConfigRules": {
132
+ "providerRules": [
133
+ {
134
+ "providerId": "custom",
135
+ "providerName": "Custom provider",
136
+ "config": {
137
+ "group": "standard-personal",
138
+ "access": { "type": "api-key", "apiKey": "YOUR_API_KEY" },
139
+ "api": {
140
+ "type": "openai-chat-completions",
141
+ "baseUrl": "https://api.example.com/v1"
142
+ },
143
+ "personalModelIds": ["your-model-id"]
144
+ }
145
+ }
146
+ ]
147
+ },
148
+ "modelConfigRules": {
149
+ "providerModelRules": [],
150
+ "manualProviderModelRules": []
151
+ },
152
+ "defaultModelSelection": {
153
+ "providerId": "custom",
154
+ "modelId": "your-model-id"
155
+ }
156
+ }
157
+ }
158
+ ```
159
+
160
+ Use `anthropic-messages` for an Anthropic-compatible endpoint,
161
+ `openai-chat-completions` for Chat Completions, or `openai-responses` for the
162
+ Responses API. `baseUrl` is the API root; model IDs are case-sensitive.
163
+ The model reference is `providerId/modelId`.
164
+
165
+ ```text
166
+ /model custom/your-model-id
167
+ /settings
168
+ /new
169
+ ```
170
+
171
+ The native catalog supplies context limits, reasoning options and input/output
172
+ capabilities for known models. Custom metadata overrides belong in the native
173
+ `modelConfigRules`, including `properties.contextWindow`,
174
+ `properties.inputFormat` and `optionSpecs`. Image, video and PDF support follow
175
+ the selected model's registry metadata.
176
+
177
+ Use `properties.supportsJsonSchemaOutput`, `supportsNativeWebSearch` and
178
+ `supportsMidConversationSystem` for Desktop's three capability switches.
179
+ The maximum output limit is `optionSpecs.maxOutputTokens.max`; it is independent
180
+ of the context window. Request parameter mappings belong in each option's `map`
181
+ string. See the [complete field tables and examples](PROVIDER_CONFIG.md).
182
+
183
+ When the upstream catalog changes, smart models inherit the new capability
184
+ and option metadata automatically. Only explicit personal overrides remain fixed.
185
+ Runtime sync copies the complete catalog, and `/model` refreshes the live registry;
186
+ there is no need to write upstream capability values into every personal model.
187
+
188
+ ## Permission and planning state
189
+
190
+ The CLI follows Desktop's three selectable permission modes: `build` (ask before
191
+ changes), `edit` (edit automatically), and `yolo` (full access). `/mode` opens the
192
+ picker; Shift+Tab cycles these three options. The internal `auto` value is not a
193
+ menu option.
194
+
195
+ `/plan` toggles planning independently. `/plan on` and `/plan off` set it
196
+ explicitly. Changing permissions keeps the Plan switch unchanged; toggling Plan
197
+ keeps the selected permissions unchanged. The native runtime owns validation,
198
+ including the restriction against enabling Plan while a Goal is active.
199
+
200
+ When enabled, `Plan` appears at the right end of the input's upper border without
201
+ adding a row. An empty editor shows a planning hint. The statusline always shows
202
+ the permission mode, and `/status` lists Mode and Plan separately. The marker
203
+ follows native state changes, including plan approval, new sessions and resume;
204
+ no separate CLI preference is written for Plan.
205
+
206
+ ## Prompt access preflight
207
+
208
+ New headless prompts and ordinary TUI input diagnose missing provider setup or
209
+ an explicitly keyless API-key provider before a model turn starts. No key or
210
+ credential value is printed or checked over the network. Account authentication,
211
+ malformed configuration, environment overrides, project configuration and resumed
212
+ headless sessions remain the runtime's responsibility.
213
+
214
+ The TUI restores rejected input to an empty editor, or retains it in the
215
+ follow-up queue without replacing a newer draft. Headless commands exit with
216
+ setup instructions. Login, setup and other management commands remain usable.
217
+
218
+ ### Background agents
219
+
220
+ Long-running Agent calls automatically detach from the foreground turn after
221
+ one second and remain available through `/tasks`. Short Agent calls stay inline
222
+ so the current response can use their result without a notification round trip.
223
+ Configure the threshold in milliseconds:
224
+
225
+ ```json
226
+ {
227
+ "subagents": {
228
+ "autoBackgroundMs": 1000
229
+ }
230
+ }
231
+ ```
232
+
233
+ Set the value to `0` to disable automatic backgrounding. Agent tool calls that
234
+ use `run_in_background: true` detach immediately regardless of this threshold.
235
+
236
+ ### Request retries and stalled streams
237
+
238
+ The CLI leaves retry classification and execution to the official ZCode
239
+ runtime. It supplies a default retry budget of five retries; override it when
240
+ needed with the runtime's own environment variable:
241
+
242
+ ```bash
243
+ ZCODE_MODEL_RETRY_MAX_RETRIES=3 zcode
244
+ ```
245
+
246
+ Newly generated configs use a 60-second model-stream idle timeout:
247
+
248
+ ```json
249
+ {
250
+ "modelStream": {
251
+ "idleTimeoutMs": 60000
252
+ }
253
+ }
254
+ ```
255
+
256
+ Existing configs are never overwritten, so update this field manually if an
257
+ older generated file still contains `600000`. Retryable timeouts, dropped
258
+ streams, rate limits and server/network errors are retried and shown in the
259
+ TUI. Authentication and invalid-request responses remain non-retryable.
260
+
261
+ ## Runtime diagnostics
262
+
263
+ The interactive TUI captures runtime `stderr` so background diagnostics cannot
264
+ overwrite terminal rendering. A non-zero runtime exit prints its status and the
265
+ diagnostic path after the TUI stops. The active log is capped at 2 MB and rotated
266
+ to `.1` on the next launch; both files use owner-only permissions.
267
+
268
+ The default path is `~/.zcode/cli/tui-runtime.log`. Override it when collecting
269
+ diagnostics in an isolated environment:
270
+
271
+ ```bash
272
+ ZCODE_TUI_RUNTIME_LOG=/tmp/zcode-tui-runtime.log zcode
273
+ ```
274
+
275
+ ## TUI display mode
276
+
277
+ The interactive TUI uses regular scrollback output by default. Set
278
+ `ui.tuiMode` to `"fullscreen"` to use the terminal's alternate screen with an
279
+ independently scrollable transcript, a fixed composer, and mouse-wheel/
280
+ scrollbar navigation. The composer remains available while older transcript
281
+ content is being reviewed. The scrollbar is hidden when the transcript fits,
282
+ then appears briefly while scrolling and follows the active dark/light theme.
283
+
284
+ ```json
285
+ {
286
+ "ui": {
287
+ "tuiMode": "fullscreen"
288
+ }
289
+ }
290
+ ```
291
+
292
+ The same setting can be changed from `/settings` (or `/config`) under **Display
293
+ mode**. `ZCODE_TUI_MODE=fullscreen` or `ZCODE_TUI_MODE=regular` temporarily
294
+ overrides the saved value for the current shell; the settings picker labels
295
+ this override and does not remove it.
296
+
297
+ Fullscreen mode is restored on normal exit and on handled `SIGINT`, `SIGTERM`,
298
+ or `SIGHUP` shutdowns. A hard `SIGKILL` cannot be intercepted by any terminal
299
+ application.
300
+
301
+ ### Copy on select
302
+
303
+ Releasing a mouse selection in fullscreen mode copies the selected text to the
304
+ system clipboard. Set `ui.copyOnSelect` to `false` to keep copying manual:
305
+ drags then only highlight, and the terminal's native selection (hold Shift or
306
+ the modifier your emulator documents while dragging) still works. The setting
307
+ only affects fullscreen mode; regular scrollback mode has no mouse selection.
308
+ The same toggle is available in `/settings` under **Fullscreen copy on
309
+ select**.
310
+
311
+ ```json
312
+ {
313
+ "ui": {
314
+ "copyOnSelect": false
315
+ }
316
+ }
317
+ ```
318
+
319
+ ## Theme
320
+
321
+ Set `ui.theme` to `"auto"` (terminal detection), `"dark"`, or `"light"` in the
322
+ user config: `~/.zcode/cli/setting.json` on macOS/Linux or
323
+ `%USERPROFILE%\.zcode\cli\setting.json` on Windows. An explicit dark/light value
324
+ takes priority over terminal probing. `auto` queries the terminal background
325
+ color and color scheme at startup and re-applies the matching palette.
326
+
327
+ ## Turn completion notifications
328
+
329
+ Notifications are enabled by default and emitted after a normal agent turn
330
+ completes or fails while the terminal is unfocused. Following Codex's terminal
331
+ capability fallback, `auto` uses OSC 9 in Ghostty, iTerm2, Kitty, Warp and
332
+ WezTerm, and BEL in terminals such as Apple Terminal. Selecting OSC 9 in an
333
+ unsupported terminal also falls back to BEL instead of silently emitting an
334
+ ignored sequence.
335
+
336
+ The `unfocused` condition uses DEC focus reporting when the terminal provides
337
+ it. Until focus support is confirmed, ZCode sends the notification instead of
338
+ permanently suppressing it as focused. `native` is an explicit opt-in that uses
339
+ an existing system command: `terminal-notifier` on macOS, `notify-send` on
340
+ Linux, or `SnoreToast` on Windows. These tools are not bundled, keeping the
341
+ default terminal notification path dependency-free. If the selected command is
342
+ unavailable or delivery fails, ZCode falls back to BEL. On macOS, the detected
343
+ terminal application is used as both the sender and click target. Exact tab or
344
+ pane restoration remains terminal-dependent; use the default `auto` setting so
345
+ OSC-capable terminals can preserve their native session behavior.
346
+
347
+ Open the interactive settings picker inside the TUI (both commands are
348
+ equivalent):
349
+
350
+ ```text
351
+ /config
352
+ /settings
353
+ ```
354
+
355
+ Saving a value returns to the settings root so several options can be changed
356
+ in one visit. `Esc` returns from a setting to the root, then closes the root.
357
+
358
+ The picker updates the active session immediately and persists the selected
359
+ values under `ui.notifications` in the cross-platform user `setting.json`:
360
+
361
+ ```json
362
+ {
363
+ "ui": {
364
+ "notifications": {
365
+ "method": "auto",
366
+ "condition": "unfocused"
367
+ }
368
+ }
369
+ }
370
+ ```
371
+
372
+ Environment variables override `setting.json` on startup and are useful for a
373
+ temporary per-shell setting:
374
+
375
+ ```bash
376
+ export ZCODE_TUI_NOTIFICATION_METHOD=auto # auto|osc9|bel|native|off
377
+ export ZCODE_TUI_NOTIFICATION_CONDITION=always # unfocused|always
378
+ zcode
379
+ ```
380
+
381
+ ## Official MCP Availability
382
+
383
+ When the bundled runtime has no official MCP trusted-origin registry, official
384
+ HTTP MCP services are reported as disabled with an `official_auth_unavailable`
385
+ diagnostic. Other plugin components remain available. This does not disable
386
+ certificate, origin, or permission checks, and does not suppress services when
387
+ the runtime provides the required registry. No user configuration is rewritten.