zcode-app-cli 3.14.4-31 → 3.14.4-33
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 +56 -7
- package/bin/zcode.js +85 -11
- package/docs/CONFIGURATION.md +185 -6
- package/docs/CONFIGURATION.zh-CN.md +161 -5
- package/docs/PROVIDER_CONFIG.md +4 -2
- package/docs/PROVIDER_CONFIG.zh-CN.md +3 -2
- package/package.json +1 -1
- package/vendor/cli-config.cjs +106 -3
- package/vendor/extraction.json +21 -1
- package/vendor/node_modules/@zcode/tui/dist/index.js +51 -10
- package/vendor/zcode.cjs +7 -7
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
[English](CONFIGURATION.md) | 简体中文
|
|
4
4
|
|
|
5
|
-
CLI 跟随当前 ZCode runtime 的 provider registry schema
|
|
6
|
-
|
|
5
|
+
CLI 跟随当前 ZCode runtime 的 provider registry schema。Provider 和模型设置存放在
|
|
6
|
+
`provider_config.json`;MCP、hooks、插件、权限等通用运行设置存放在 CLI 的 `setting.json`。
|
|
7
|
+
模型配置中的“智能配置”对应英文界面的 **Smart configuration**。
|
|
7
8
|
|
|
8
9
|
## 配置文件
|
|
9
10
|
|
|
10
11
|
| 文件 | 用途 |
|
|
11
12
|
| --- | --- |
|
|
12
|
-
| `~/.zcode/cli/setting.json` | CLI
|
|
13
|
+
| `~/.zcode/cli/setting.json` | MCP、hooks、插件、权限、网络、存储和 CLI 显示设置 |
|
|
13
14
|
| `~/.zcode/v2/setting.json` | 桌面端已有的语言和记忆偏好,CLI 只读不修改 |
|
|
14
15
|
| `~/.zcode/v2/provider_config.json` | Provider、模型元数据覆盖和默认模型 |
|
|
15
16
|
| `~/.zcode/v2/credentials.json` | 原生 runtime 持久化的凭证 |
|
|
@@ -19,7 +20,16 @@ Windows 使用 `%USERPROFILE%` 代替 `~`。Provider 文件默认与桌面端共
|
|
|
19
20
|
|
|
20
21
|
设置 `ZCODE_PERSONAL_PROVIDER_CONFIG_FILE` 可使用独立的 provider 文件。
|
|
21
22
|
`ZCODE_DATA_BASE_DIR` 改变原生 runtime 的基础目录,包括 provider 和凭证存储。
|
|
22
|
-
CLI
|
|
23
|
+
CLI 通用设置默认使用用户目录中的 `~/.zcode/cli/setting.json`。
|
|
24
|
+
设置 `ZCODE_CLI_SETTINGS_FILE` 为绝对文件路径,可为单个进程指定独立设置。
|
|
25
|
+
未设置或仅含空白时使用默认路径。所选文件替换用户级设置来源;显式 runtime 文件路径和
|
|
26
|
+
项目配置保留原有优先级。
|
|
27
|
+
|
|
28
|
+
旧 `config.json` 和 `migrations/` 标记使用所选文件所在目录,hook 信任命令也读取该文件的
|
|
29
|
+
`storage.dir`。Provider、凭证和会话数据库(含持久化项目权限)有各自的路径覆盖变量,
|
|
30
|
+
仅切换设置文件不会隔离这些存储,示例见[宿主集成](HOST_INTEGRATION.md#environment-and-configuration)。
|
|
31
|
+
Desktop 偏好仍位于 `~/.zcode/v2/setting.json`;桌面端保存在 `~/.zcode/cli/config.json`
|
|
32
|
+
中的用户 hooks 和 MCP 配置不会与 CLI 设置文件持续同步。
|
|
23
33
|
|
|
24
34
|
首次启动时,CLI 根据不含凭证的 [`setting.example.json`](../setting.example.json)
|
|
25
35
|
创建通用设置,不覆盖已有文件。Provider 配置由原生登录创建,或参考
|
|
@@ -78,12 +88,158 @@ CLI 专属字段迁移到 `~/.zcode/cli/setting.json`,省略 provider、main/l
|
|
|
78
88
|
| 恢复会话/重启 | 恢复该会话保存的模型和推理选项 |
|
|
79
89
|
| 语言与记忆 | 读取桌面端 `localePreference`/`memoryEnabled`,显式 CLI 设置优先 |
|
|
80
90
|
| 主题、终端布局、选中复制、通知 | CLI `setting.json` |
|
|
81
|
-
|
|
|
91
|
+
| MCP 服务器 | CLI `setting.json` → `mcp.servers`;项目与插件服务器的合并规则见 [项目配置与插件](#项目配置与插件) |
|
|
92
|
+
| 工具权限、重试、流超时、hooks、插件等运行设置 | CLI `setting.json`,保留原生项目和环境配置优先级 |
|
|
82
93
|
| 更新缓存、诊断日志、迁移状态 | CLI 目录下的运行文件 |
|
|
83
94
|
|
|
84
95
|
CLI 不向桌面端的 `setting.json` 增加字段。通知和显示设置只写 CLI 文件。
|
|
85
96
|
共享偏好在加载 runtime 设置时生效,不会因修改其他 CLI 选项而被复制进 CLI 设置。
|
|
86
97
|
|
|
98
|
+
## MCP 服务器
|
|
99
|
+
|
|
100
|
+
在 `~/.zcode/cli/setting.json` 的顶层 `mcp.servers` 对象中添加服务器,键名就是服务器名。
|
|
101
|
+
`mcp` 与 `features`、`permission`、`plugins`、`hooks` 同级;
|
|
102
|
+
`schemaVersion` / `config` 外层结构属于 `provider_config.json`。
|
|
103
|
+
|
|
104
|
+
将以下内容合并到已有设置中,并把地址和可执行文件路径替换为你实际运行的 HTTP 服务
|
|
105
|
+
及已安装的 stdio 服务:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"features": {
|
|
110
|
+
"mcp": true
|
|
111
|
+
},
|
|
112
|
+
"mcp": {
|
|
113
|
+
"servers": {
|
|
114
|
+
"basic-memory": {
|
|
115
|
+
"type": "http",
|
|
116
|
+
"url": "http://127.0.0.1:18796/mcp"
|
|
117
|
+
},
|
|
118
|
+
"token-savior": {
|
|
119
|
+
"type": "stdio",
|
|
120
|
+
"command": "/absolute/path/to/token-savior-mcp",
|
|
121
|
+
"args": [],
|
|
122
|
+
"timeoutMs": 30000
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Runtime 每次启动都会读取此文件,修改 MCP 设置后重启 ZCode 即可。
|
|
130
|
+
`settings-v1.json` 标记只控制从旧 CLI `config.json` 的迁移,不会阻止后续修改
|
|
131
|
+
`setting.json` 生效。修改模型/provider 文件或完成 provider 登录,不会配置自定义 MCP。
|
|
132
|
+
|
|
133
|
+
### 服务器字段
|
|
134
|
+
|
|
135
|
+
| 字段 | 适用类型 | 含义 |
|
|
136
|
+
| --- | --- | --- |
|
|
137
|
+
| `type` | 全部 | `"stdio"`、`"http"` 或 `"sse"`,按服务器支持的传输方式选择 |
|
|
138
|
+
| `command` | stdio | 可执行文件名或绝对路径;命令参数单独放在 `args` 中 |
|
|
139
|
+
| `args` | stdio | 可选,字符串数组 |
|
|
140
|
+
| `env` | stdio | 可选,环境变量名到字符串值的对象 |
|
|
141
|
+
| `cwd` | stdio | 可选,服务器进程的工作目录 |
|
|
142
|
+
| `url` | HTTP / SSE | 服务器地址,包含实际的 MCP 或 SSE 路径 |
|
|
143
|
+
| `headers` | HTTP / SSE | 可选,请求头名称到字符串值的对象,例如 `Authorization` |
|
|
144
|
+
| `oauth` | HTTP / SSE | 可选,OAuth 配置,见下文 |
|
|
145
|
+
| `enabled` | 全部 | 设为 `false` 可禁用服务器并保留配置 |
|
|
146
|
+
| `timeoutMs` | 全部 | 可选,正数,单位为毫秒;超时应使用此字段,`timeout` 和 `startup_timeout_sec` 不生效 |
|
|
147
|
+
| `protocolVersion` | 全部 | Runtime 0.16.9 支持可选值 `"auto"`、`"legacy"`、`"2026-07-28"`;通常省略,使用自动协商 |
|
|
148
|
+
|
|
149
|
+
`oauth.type` 支持 `"authorization_code"` 和 `"client_credentials"`。
|
|
150
|
+
两者都支持 `clientId`、`clientSecret`、`clientName`、`scope`;client credentials 模式
|
|
151
|
+
必须填写 `clientId` 和 `clientSecret`,authorization code 模式还支持 `redirectPath`。
|
|
152
|
+
按 MCP 服务器的鉴权要求配置即可。
|
|
153
|
+
|
|
154
|
+
### 项目配置与插件
|
|
155
|
+
|
|
156
|
+
项目的 `zcode.json` 或 `.zcode/config.json` 使用相同的 `mcp.servers` 结构。
|
|
157
|
+
在 Git 工作树内,runtime 从工作树根目录到当前工作目录发现这些文件;工作树外只检查
|
|
158
|
+
当前工作目录。项目 stdio 服务器的相对 `cwd` 以配置的基础目录解析:
|
|
159
|
+
对 `.zcode/config.json`,基础目录是 `.zcode` 的父目录;省略 `cwd` 时也使用该基础目录。
|
|
160
|
+
|
|
161
|
+
MCP 服务器按名称合并。当前 runtime 中,**同名服务器的用户配置优先于项目配置**;
|
|
162
|
+
不同名称的服务器都会保留。这与其他设置通常由项目覆盖用户配置的规则不同。
|
|
163
|
+
用户配置中的空 `mcp.servers` 对象不会禁用项目或插件服务器。
|
|
164
|
+
可对指定服务器设置 `enabled: false`,或用 `features.mcp: false` 关闭整个 MCP 功能。
|
|
165
|
+
|
|
166
|
+
已启用的插件也会提供 MCP,定义来自插件的 `.mcp.json` 或 manifest,通常显示为
|
|
167
|
+
`plugin:<插件名>:<服务器名>`。独立的用户 MCP 定义放在 `setting.json`;
|
|
168
|
+
此 CLI 不会自动读取 `.agents/mcp.json`。
|
|
169
|
+
插件控制仍在 `setting.json` 的 `plugins` 下,hook 声明在 `hooks.events.<Event>` 下,
|
|
170
|
+
工具权限在 `permission` 下。
|
|
171
|
+
|
|
172
|
+
### 上游源码与配置路径的区别
|
|
173
|
+
|
|
174
|
+
下面区分本发行包与上游应用。源码引用固定在上游
|
|
175
|
+
[`29628c9` / `v3.14.3`](https://github.com/zai-org/ZCode/tree/29628c9acdb81b703bbd4080c207a0e7ce5e276e)。
|
|
176
|
+
本项目 runtime lock 选择的是独立发布的 Desktop 3.14.4 产物,不能据此认定该产物
|
|
177
|
+
由这个公开源码提交构建。
|
|
178
|
+
|
|
179
|
+
| 客户端/配置源 | 用户级 MCP 文件 | JSON 路径 |
|
|
180
|
+
| --- | --- | --- |
|
|
181
|
+
| 未打补丁的上游 CLI | `~/.zcode/cli/config.json` | `mcp.servers` |
|
|
182
|
+
| 本项目 `zcode-app-cli` | `~/.zcode/cli/setting.json` | `mcp.servers` |
|
|
183
|
+
| 上游 Desktop 的 ZCode 目录配置源 | `~/.zcode/cli/config.json` | `mcp.servers` |
|
|
184
|
+
| 上游 Desktop 的 `.agents` 回退配置源 | `~/.agents/mcp.json` | `mcpServers` |
|
|
185
|
+
|
|
186
|
+
上游 [文件加载器](https://github.com/zai-org/ZCode/blob/29628c9acdb81b703bbd4080c207a0e7ce5e276e/apps/zcode-cli/packages/adapters/src/config/file-config.adapter.ts#L61-L118)
|
|
187
|
+
默认使用 `config.json`。本项目的
|
|
188
|
+
[`patchRuntimeSharedConfig`](https://github.com/kingsword09/zcode-cli/blob/e93caf41292314bd751180cf9b08f6d18895a5b5/scripts/sync-runtime.ts#L1026-L1046)
|
|
189
|
+
将文件名改成 `setting.json`。
|
|
190
|
+
[通用设置 schema](https://github.com/zai-org/ZCode/blob/29628c9acdb81b703bbd4080c207a0e7ce5e276e/apps/zcode-cli/packages/adapters/src/config/schema.ts#L286-L306)
|
|
191
|
+
包含 `mcp`、`plugins`、`permission` 和 `hooks`;独立且严格的
|
|
192
|
+
[provider 文件 schema](https://github.com/zai-org/ZCode/blob/29628c9acdb81b703bbd4080c207a0e7ce5e276e/packages/provider-node/src/provider-config-file-codec.ts#L18-L30)
|
|
193
|
+
只接受 provider/模型规则、provider 排序和默认模型选择,向其中添加 MCP 会导致 schema
|
|
194
|
+
校验失败。[MCP 合并函数](https://github.com/zai-org/ZCode/blob/29628c9acdb81b703bbd4080c207a0e7ce5e276e/apps/zcode-cli/packages/adapters/src/config/config-factory.ts#L372-L397)
|
|
195
|
+
明确先应用项目配置,再应用用户配置。
|
|
196
|
+
|
|
197
|
+
Desktop 有独立的
|
|
198
|
+
[MCP 目录读写模块](https://github.com/zai-org/ZCode/blob/29628c9acdb81b703bbd4080c207a0e7ce5e276e/packages/desktop/src/main/mcpUserDirectory/index.ts#L37-L69)。
|
|
199
|
+
在每个用户/项目作用域内,ZCode 文件没有 MCP 条目时,它会
|
|
200
|
+
[回退到 `.agents/mcp.json`](https://github.com/zai-org/ZCode/blob/29628c9acdb81b703bbd4080c207a0e7ce5e276e/packages/desktop/src/main/mcpUserDirectory/index.ts#L334-L375)。
|
|
201
|
+
项目级文件分别是 `.zcode/config.json` 和 `.agents/mcp.json`。
|
|
202
|
+
与 Desktop 共用 `provider_config.json` 不代表这些用户 MCP 文件会与本项目的
|
|
203
|
+
`setting.json` 同步;旧 CLI 文件只在前述一次性迁移时导入。
|
|
204
|
+
|
|
205
|
+
### 确认配置是否加载
|
|
206
|
+
|
|
207
|
+
运行 `zcode doctor` 查看实际配置路径、加载状态、校验通过的 MCP 名称及用户/项目来源。
|
|
208
|
+
需要排查问题时可生成 JSON 报告:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
zcode doctor --json
|
|
212
|
+
zcode --cwd /path/to/project doctor --json
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
JSON 保留原有 runtime 信息,新增 `configuration`:包含 `user.path` / `user.status`、
|
|
216
|
+
`project.paths` / `project.status`、`mcp.enabled`、`mcp.servers` 和 `diagnostics`。
|
|
217
|
+
状态为 `loaded`、`missing` 或 `invalid`;诊断指出对应文件与被拒绝的字段。
|
|
218
|
+
服务器记录只包含名称、传输方式、启用状态和来源,不输出命令参数、URL、环境变量、
|
|
219
|
+
请求头或凭据。`provider.path` 只标明 provider 文件位置,不验证 provider 凭据。
|
|
220
|
+
|
|
221
|
+
Doctor 无需登录,即使 `setting.json` 的 JSON 语法损坏也能运行。它跳过首次设置文件创建
|
|
222
|
+
和 provider 迁移,并将旧 `config.json` 标为仅供迁移使用。它不会启动 MCP 或请求模型。
|
|
223
|
+
设置文件缺失是允许的;配置无效或有 MCP 条目被跳过时退出码为 `1`,有效配置为 `0`。
|
|
224
|
+
|
|
225
|
+
服务器列表覆盖用户/项目配置。插件和内置 MCP 会在会话启动时另外加入,doctor 不测试
|
|
226
|
+
连接是否成功。在 TUI 中使用 `/status` 查看连接状态。结构化 runtime 日志默认位于
|
|
227
|
+
`~/.zcode/cli/log/`;服务器缺失时,以下事件可提供实际会话的加载和连接证据:
|
|
228
|
+
|
|
229
|
+
| 事件 | 检查内容 |
|
|
230
|
+
| --- | --- |
|
|
231
|
+
| `bootstrap.app.startup.config.completed` | `context.configSourceUser` 表示是否成功加载用户设置文件 |
|
|
232
|
+
| `config.file.invalid` | `context.configPath` 和 `context.diagnosticMessage` 指出文件解析或 schema 校验错误 |
|
|
233
|
+
| `config.mcp_server.skipped` | `context.diagnosticPath` 和 `context.diagnosticMessage` 指出无效的服务器配置项 |
|
|
234
|
+
| `mcp.configured_servers.connect.started` | `context.serverNames` 列出准备连接的服务器 |
|
|
235
|
+
| `mcp.configured_servers.connect.completed` | 连接状态和工具数量,可区分配置加载问题与连接失败 |
|
|
236
|
+
|
|
237
|
+
JSON 语法正确还不够,字段也必须符合 runtime 的 schema。单个 MCP 服务器条目以外的
|
|
238
|
+
schema 错误可能导致整份设置文件被忽略。例如 `ui.theme: "system"` 无效,正确值是
|
|
239
|
+
`"auto"`、`"dark"` 或 `"light"`。此时 runtime 仍可能使用默认设置及插件服务器启动。
|
|
240
|
+
`features.mcp` 默认就是 `true`,因此 MCP 开关已开启不能证明用户文件加载成功。
|
|
241
|
+
单个服务器条目无效时,会记录 `config.mcp_server.skipped` 并跳过该条目,其他有效条目仍可加载。
|
|
242
|
+
|
|
87
243
|
## 模型目录与默认选择
|
|
88
244
|
|
|
89
245
|
原生 registry 加载随包提供的目录,并管理上游目录刷新。`/model`、模型循环切换以及
|
package/docs/PROVIDER_CONFIG.md
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
English | [简体中文](PROVIDER_CONFIG.zh-CN.md)
|
|
4
4
|
|
|
5
5
|
ZCode Desktop and CLI share `~/.zcode/v2/provider_config.json` (underscore).
|
|
6
|
-
`ZCODE_PERSONAL_PROVIDER_CONFIG_FILE` can select another file.
|
|
7
|
-
|
|
6
|
+
`ZCODE_PERSONAL_PROVIDER_CONFIG_FILE` can select another file. MCP servers, hooks,
|
|
7
|
+
plugins, permissions, terminal and network settings belong in
|
|
8
|
+
`~/.zcode/cli/setting.json`. See [MCP servers](CONFIGURATION.md#mcp-servers)
|
|
9
|
+
for the `mcp.servers` structure and HTTP/stdio examples.
|
|
8
10
|
|
|
9
11
|
[`provider.example.json`](../provider.example.json) covers the current personal
|
|
10
12
|
provider schema. It is valid JSON without comments. This reference explains the
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
[English](PROVIDER_CONFIG.md) | 简体中文
|
|
4
4
|
|
|
5
5
|
ZCode 桌面端与 CLI 共用 `~/.zcode/v2/provider_config.json`,文件名使用下划线。
|
|
6
|
-
可通过 `ZCODE_PERSONAL_PROVIDER_CONFIG_FILE`
|
|
7
|
-
CLI 设置放在 `~/.zcode/cli/setting.json`。
|
|
6
|
+
可通过 `ZCODE_PERSONAL_PROVIDER_CONFIG_FILE` 指定其他文件。MCP、hooks、插件、权限、
|
|
7
|
+
终端显示和网络等 CLI 设置放在 `~/.zcode/cli/setting.json`。
|
|
8
|
+
`mcp.servers` 的结构及 HTTP/stdio 示例见 [MCP 服务器配置](CONFIGURATION.zh-CN.md#mcp-服务器)。
|
|
8
9
|
|
|
9
10
|
[`provider.example.json`](../provider.example.json) 展示当前个人 provider schema 的配置项。
|
|
10
11
|
它是可以解析的标准 JSON,不包含注释;各字段的含义、可选值及互斥关系由本文说明。
|
package/package.json
CHANGED
package/vendor/cli-config.cjs
CHANGED
|
@@ -6,13 +6,22 @@ let node_crypto = require("node:crypto");
|
|
|
6
6
|
let node_os = require("node:os");
|
|
7
7
|
let node_async_hooks = require("node:async_hooks");
|
|
8
8
|
//#region src/config-paths.ts
|
|
9
|
-
function
|
|
9
|
+
function homeCliSettingsPath(env, platform, fallbackHome) {
|
|
10
10
|
const path = platform === "win32" ? node_path.win32 : node_path.posix;
|
|
11
11
|
const home = (platform === "win32" ? env.USERPROFILE : env.HOME)?.trim() || fallbackHome;
|
|
12
12
|
return path.join(home, ".zcode", "cli", "setting.json");
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The CLI settings file. `ZCODE_CLI_SETTINGS_FILE` lets a host run one process
|
|
16
|
+
* on its own settings file (hooks, MCP servers, permissions) without editing
|
|
17
|
+
* the user's `~/.zcode/cli/setting.json`. Files that are derived from the
|
|
18
|
+
* settings location (migration markers, the legacy `config.json`) follow it.
|
|
19
|
+
*/
|
|
20
|
+
function cliSettingsPath(env = process.env, platform = process.platform, fallbackHome = (0, node_os.homedir)()) {
|
|
21
|
+
return env.ZCODE_CLI_SETTINGS_FILE?.trim() || homeCliSettingsPath(env, platform, fallbackHome);
|
|
22
|
+
}
|
|
14
23
|
function desktopSettingsPath(env = process.env) {
|
|
15
|
-
return (0, node_path.join)((0, node_path.dirname)((0, node_path.dirname)(
|
|
24
|
+
return (0, node_path.join)((0, node_path.dirname)((0, node_path.dirname)(homeCliSettingsPath(env, process.platform, (0, node_os.homedir)()))), "v2", "setting.json");
|
|
16
25
|
}
|
|
17
26
|
function readDesktopSettings(env = process.env) {
|
|
18
27
|
try {
|
|
@@ -653,6 +662,98 @@ function appServerRegistryOptions(env, createRefreshReporter) {
|
|
|
653
662
|
return appServerAuthMode(env) === "host" ? {} : { standalone: createRefreshReporter(process.stderr) };
|
|
654
663
|
}
|
|
655
664
|
//#endregion
|
|
665
|
+
//#region src/config-diagnostics.ts
|
|
666
|
+
const schemaDiagnosticPrefix = /^(?:<config>|modelStream|permission|storage|network|features|memory|mcp|plugins|skills|skill|command|logging|ui|toolConcurrency|modelAnomalyGuard|hooks)(?:[.:[\]]|$)/u;
|
|
667
|
+
function publicDiagnostic(diagnostic, scope) {
|
|
668
|
+
const message = diagnostic.code === "config_file_invalid" && !schemaDiagnosticPrefix.test(diagnostic.message) ? "Unable to read or parse configuration JSON. Check the file syntax and permissions." : diagnostic.message;
|
|
669
|
+
return {
|
|
670
|
+
code: diagnostic.code,
|
|
671
|
+
scope,
|
|
672
|
+
severity: diagnostic.severity,
|
|
673
|
+
filePath: diagnostic.filePath,
|
|
674
|
+
path: diagnostic.path,
|
|
675
|
+
message
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
function sourceStatus(source) {
|
|
679
|
+
if (source.diagnostics.some((diagnostic) => diagnostic.code === "config_file_invalid")) return "invalid";
|
|
680
|
+
return source.loaded ? "loaded" : "missing";
|
|
681
|
+
}
|
|
682
|
+
/** Inspect the runtime's resolved configuration without starting providers, plugins or MCP connections. */
|
|
683
|
+
function inspectRuntimeConfiguration(workingDirectory, createConfig, env = process.env) {
|
|
684
|
+
const logger = {
|
|
685
|
+
child: () => logger,
|
|
686
|
+
warn() {}
|
|
687
|
+
};
|
|
688
|
+
const result = createConfig({
|
|
689
|
+
workingDirectory,
|
|
690
|
+
env,
|
|
691
|
+
loggerFactory: { createLogger: () => logger }
|
|
692
|
+
});
|
|
693
|
+
const diagnostics = [...result.sources.user.diagnostics.map((diagnostic) => publicDiagnostic(diagnostic, "user")), ...result.sources.project.diagnostics.map((diagnostic) => publicDiagnostic(diagnostic, "project"))];
|
|
694
|
+
let providerPath;
|
|
695
|
+
try {
|
|
696
|
+
providerPath = providerConfigPath(env);
|
|
697
|
+
} catch {
|
|
698
|
+
diagnostics.push({
|
|
699
|
+
code: "desktop_settings_invalid",
|
|
700
|
+
scope: "desktop",
|
|
701
|
+
severity: "error",
|
|
702
|
+
filePath: desktopSettingsPath(env),
|
|
703
|
+
message: "Desktop settings could not be read to resolve the provider configuration path."
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
const legacyPath = legacyCliConfigPath(env);
|
|
707
|
+
return {
|
|
708
|
+
ok: !diagnostics.some((diagnostic) => diagnostic.severity === "error" || diagnostic.code === "config_mcp_server_invalid"),
|
|
709
|
+
user: {
|
|
710
|
+
path: result.sources.user.path,
|
|
711
|
+
status: sourceStatus(result.sources.user),
|
|
712
|
+
mcpServerNames: result.sources.user.mcpServerNames
|
|
713
|
+
},
|
|
714
|
+
project: {
|
|
715
|
+
paths: [.../* @__PURE__ */ new Set([...result.sources.project.paths ?? [], ...result.sources.project.diagnostics.flatMap((diagnostic) => diagnostic.filePath ? [diagnostic.filePath] : [])])],
|
|
716
|
+
status: sourceStatus(result.sources.project),
|
|
717
|
+
mcpServerNames: result.sources.project.mcpServerNames
|
|
718
|
+
},
|
|
719
|
+
provider: { path: providerPath },
|
|
720
|
+
legacy: {
|
|
721
|
+
path: legacyPath,
|
|
722
|
+
exists: (0, node_fs.existsSync)(legacyPath),
|
|
723
|
+
usage: "first-run-migration-only"
|
|
724
|
+
},
|
|
725
|
+
mcp: {
|
|
726
|
+
enabled: result.config.features.mcp,
|
|
727
|
+
servers: Object.entries(result.config.mcp.servers).map(([name, server]) => ({
|
|
728
|
+
name,
|
|
729
|
+
type: server.type,
|
|
730
|
+
enabled: server.enabled !== false,
|
|
731
|
+
source: result.sources.mcp.serverSources[name] ?? "unknown"
|
|
732
|
+
})).sort((left, right) => left.name.localeCompare(right.name))
|
|
733
|
+
},
|
|
734
|
+
diagnostics
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
function printable(value) {
|
|
738
|
+
return value.replace(/[\u0000-\u001f\u007f-\u009f]/gu, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
739
|
+
}
|
|
740
|
+
function writeConfigurationDoctor(output, report) {
|
|
741
|
+
const lines = [
|
|
742
|
+
"",
|
|
743
|
+
"Configuration:",
|
|
744
|
+
` user: ${report.user.path ?? "unknown"} (${report.user.status})`,
|
|
745
|
+
` project: ${report.project.paths.join(", ") || "none"} (${report.project.status})`,
|
|
746
|
+
` providers: ${report.provider.path ?? "unavailable"}`,
|
|
747
|
+
` legacy: ${report.legacy.path} (${report.legacy.exists ? "present; migration source only" : "absent"})`,
|
|
748
|
+
` MCP: ${report.mcp.enabled ? "enabled" : "disabled"}; ${report.mcp.servers.length} configured server(s)`,
|
|
749
|
+
...report.mcp.servers.map((server) => ` ${JSON.stringify(server.name)}: ${server.type}, ${server.source}, ${server.enabled ? "enabled" : "disabled"}`),
|
|
750
|
+
" Plugin and built-in MCP servers are added at session startup; connections were not tested.",
|
|
751
|
+
...report.diagnostics.map((diagnostic) => ` ${diagnostic.severity}: ${diagnostic.filePath ?? diagnostic.scope}${diagnostic.path ? ` [${diagnostic.path}]` : ""}: ${diagnostic.message}`)
|
|
752
|
+
];
|
|
753
|
+
output.write(lines.map(printable).join("\n") + "\n");
|
|
754
|
+
return report.ok ? 0 : 1;
|
|
755
|
+
}
|
|
756
|
+
//#endregion
|
|
656
757
|
//#region src/runtime-config-bridge.ts
|
|
657
758
|
function record(value) {
|
|
658
759
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
@@ -662,7 +763,7 @@ function mergeDesktopSettings(value, filePath, env = process.env) {
|
|
|
662
763
|
const settings = record(value);
|
|
663
764
|
if (!settings || (0, node_path.resolve)(filePath) !== (0, node_path.resolve)(cliSettingsPath(env))) return value;
|
|
664
765
|
const desktop = readDesktopSettings(env);
|
|
665
|
-
const locale = desktop.localePreference;
|
|
766
|
+
const locale = desktop.localePreference === "system" ? "auto" : desktop.localePreference;
|
|
666
767
|
const memory = typeof desktop.memoryEnabled === "boolean" ? desktop.memoryEnabled : void 0;
|
|
667
768
|
const memorySettings = {
|
|
668
769
|
...memory !== void 0 ? {
|
|
@@ -771,6 +872,7 @@ async function migrateLegacyProviders(options) {
|
|
|
771
872
|
//#endregion
|
|
772
873
|
exports.appServerRegistryOptions = appServerRegistryOptions;
|
|
773
874
|
exports.assertSessionModelReady = assertSessionModelReady;
|
|
875
|
+
exports.inspectRuntimeConfiguration = inspectRuntimeConfiguration;
|
|
774
876
|
exports.installSqliteWriteRecovery = installSqliteWriteRecovery;
|
|
775
877
|
exports.mergeDesktopSettings = mergeDesktopSettings;
|
|
776
878
|
exports.migrateLegacyProviders = migrateLegacyProviders;
|
|
@@ -781,3 +883,4 @@ exports.readTuiRuntimeProjection = readTuiRuntimeProjection;
|
|
|
781
883
|
exports.restoreTuiBackgroundTasks = restoreTuiBackgroundTasks;
|
|
782
884
|
exports.sendTuiBackgroundTaskMessage = sendTuiBackgroundTaskMessage;
|
|
783
885
|
exports.sqliteRecoveryStats = sqliteRecoveryStats;
|
|
886
|
+
exports.writeConfigurationDoctor = writeConfigurationDoctor;
|
package/vendor/extraction.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"appVersion": "3.14.4",
|
|
3
3
|
"cliVersion": "0.16.9",
|
|
4
|
-
"extractedAt": "2026-10-
|
|
4
|
+
"extractedAt": "2026-10-08T06:18:19.033Z",
|
|
5
5
|
"sha512": "CMaAUbHehEEGuClDJeJI30ufA0zAgzfXgzV4ES200EuGDt0yYhEpzvtjayxvE/ag9T9ThnDg1eP4o3j9HkCHKg==",
|
|
6
6
|
"source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.14.4/linux-x64/ZCode-3.14.4-linux-x64.deb",
|
|
7
7
|
"runtimeCapabilities": {
|
|
@@ -116,6 +116,16 @@
|
|
|
116
116
|
"requirement": "required",
|
|
117
117
|
"status": "applied"
|
|
118
118
|
},
|
|
119
|
+
{
|
|
120
|
+
"id": "cli-settings-file",
|
|
121
|
+
"requirement": "required",
|
|
122
|
+
"status": "applied"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"id": "configuration-diagnostics",
|
|
126
|
+
"requirement": "required",
|
|
127
|
+
"status": "applied"
|
|
128
|
+
},
|
|
119
129
|
{
|
|
120
130
|
"id": "session-model-recovery",
|
|
121
131
|
"requirement": "required",
|
|
@@ -186,6 +196,16 @@
|
|
|
186
196
|
"requirement": "optional",
|
|
187
197
|
"status": "applied"
|
|
188
198
|
},
|
|
199
|
+
{
|
|
200
|
+
"id": "cli-credentials",
|
|
201
|
+
"requirement": "required",
|
|
202
|
+
"status": "applied"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"id": "prompt-model",
|
|
206
|
+
"requirement": "required",
|
|
207
|
+
"status": "applied"
|
|
208
|
+
},
|
|
189
209
|
{
|
|
190
210
|
"id": "desktop-oauth",
|
|
191
211
|
"requirement": "required",
|
|
@@ -89,13 +89,22 @@ var setting_example_default = {
|
|
|
89
89
|
};
|
|
90
90
|
//#endregion
|
|
91
91
|
//#region src/config-paths.ts
|
|
92
|
-
function
|
|
92
|
+
function homeCliSettingsPath(env, platform, fallbackHome) {
|
|
93
93
|
const path = platform === "win32" ? win32 : posix;
|
|
94
94
|
const home = (platform === "win32" ? env.USERPROFILE : env.HOME)?.trim() || fallbackHome;
|
|
95
95
|
return path.join(home, ".zcode", "cli", "setting.json");
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* The CLI settings file. `ZCODE_CLI_SETTINGS_FILE` lets a host run one process
|
|
99
|
+
* on its own settings file (hooks, MCP servers, permissions) without editing
|
|
100
|
+
* the user's `~/.zcode/cli/setting.json`. Files that are derived from the
|
|
101
|
+
* settings location (migration markers, the legacy `config.json`) follow it.
|
|
102
|
+
*/
|
|
103
|
+
function cliSettingsPath(env = process.env, platform = process.platform, fallbackHome = homedir()) {
|
|
104
|
+
return env.ZCODE_CLI_SETTINGS_FILE?.trim() || homeCliSettingsPath(env, platform, fallbackHome);
|
|
105
|
+
}
|
|
97
106
|
function desktopSettingsPath(env = process.env) {
|
|
98
|
-
return join(dirname(dirname(
|
|
107
|
+
return join(dirname(dirname(homeCliSettingsPath(env, process.platform, homedir()))), "v2", "setting.json");
|
|
99
108
|
}
|
|
100
109
|
function readDesktopSettings(env = process.env) {
|
|
101
110
|
try {
|
|
@@ -116,6 +125,9 @@ function providerConfigPath(env = process.env, platform = process.platform, fall
|
|
|
116
125
|
const path = platform === "win32" ? win32 : posix;
|
|
117
126
|
return env.ZCODE_PERSONAL_PROVIDER_CONFIG_FILE?.trim() || path.join(sharedDataBaseDir(env, platform, fallbackHome), ".zcode", "v2", "provider_config.json");
|
|
118
127
|
}
|
|
128
|
+
function credentialsPath(env = process.env) {
|
|
129
|
+
return env.ZCODE_CLI_CREDENTIALS_FILE?.trim() || join(sharedDataBaseDir(env), ".zcode", "v2", "credentials.json");
|
|
130
|
+
}
|
|
119
131
|
function legacyCliConfigPath(env = process.env) {
|
|
120
132
|
return join(dirname(cliSettingsPath(env)), "config.json");
|
|
121
133
|
}
|
|
@@ -266,7 +278,6 @@ function record$5(value) {
|
|
|
266
278
|
}
|
|
267
279
|
/** Configuration presence only; the runtime owns credential decryption and authentication. */
|
|
268
280
|
async function readConfiguredModelAccess(env = process.env) {
|
|
269
|
-
const directory = join(sharedDataBaseDir(env), ".zcode", "v2");
|
|
270
281
|
const configPath = providerConfigPath(env);
|
|
271
282
|
let value;
|
|
272
283
|
try {
|
|
@@ -286,7 +297,7 @@ async function readConfiguredModelAccess(env = process.env) {
|
|
|
286
297
|
providerId
|
|
287
298
|
};
|
|
288
299
|
if (providerId.startsWith("account:")) try {
|
|
289
|
-
const credentials = record$5(JSON.parse(await readFile(
|
|
300
|
+
const credentials = record$5(JSON.parse(await readFile(credentialsPath(env), "utf8")));
|
|
290
301
|
const identity = credentials?.[`account-provider:${providerId}:identity`];
|
|
291
302
|
const keyPrefix = `account-provider:coding-plan:${providerId}:account:`;
|
|
292
303
|
return typeof identity === "string" && identity.length > 0 && Object.entries(credentials ?? {}).some(([key, secret]) => key.startsWith(keyPrefix) && key.endsWith(":api-key") && typeof secret === "string" && secret.length > 0) ? result : null;
|
|
@@ -157565,6 +157576,7 @@ var ChoiceDialog = class {
|
|
|
157565
157576
|
contentLabel;
|
|
157566
157577
|
maxContentLines;
|
|
157567
157578
|
maxExpandedContentLines;
|
|
157579
|
+
filterList;
|
|
157568
157580
|
filter = "";
|
|
157569
157581
|
selectionPreview;
|
|
157570
157582
|
contentExpanded = false;
|
|
@@ -157573,7 +157585,7 @@ var ChoiceDialog = class {
|
|
|
157573
157585
|
contentPageSize = 1;
|
|
157574
157586
|
/** Number of quick-selectable items; digits beyond this are ignored. */
|
|
157575
157587
|
numberShortcutCount = 0;
|
|
157576
|
-
constructor(title, prompt, help, list, theme, content, contentLabel = "Details", maxContentLines = 0, maxExpandedContentLines = 0) {
|
|
157588
|
+
constructor(title, prompt, help, list, theme, content, contentLabel = "Details", maxContentLines = 0, maxExpandedContentLines = 0, filterList) {
|
|
157577
157589
|
this.title = title;
|
|
157578
157590
|
this.prompt = prompt;
|
|
157579
157591
|
this.help = help;
|
|
@@ -157583,6 +157595,7 @@ var ChoiceDialog = class {
|
|
|
157583
157595
|
this.contentLabel = contentLabel;
|
|
157584
157596
|
this.maxContentLines = maxContentLines;
|
|
157585
157597
|
this.maxExpandedContentLines = maxExpandedContentLines;
|
|
157598
|
+
this.filterList = filterList;
|
|
157586
157599
|
}
|
|
157587
157600
|
setSelectionPreview(preview) {
|
|
157588
157601
|
if (this.selectionPreview !== preview) this.contentOffset = 0;
|
|
@@ -157689,7 +157702,13 @@ var ChoiceDialog = class {
|
|
|
157689
157702
|
}
|
|
157690
157703
|
updateFilter(filter) {
|
|
157691
157704
|
this.filter = filter;
|
|
157692
|
-
this.
|
|
157705
|
+
if (this.filterList) {
|
|
157706
|
+
const next = this.filterList(filter);
|
|
157707
|
+
next.onSelect = this.list.onSelect;
|
|
157708
|
+
next.onCancel = this.list.onCancel;
|
|
157709
|
+
next.onSelectionChange = this.list.onSelectionChange;
|
|
157710
|
+
this.list = next;
|
|
157711
|
+
} else this.list.setFilter(filter);
|
|
157693
157712
|
const selected = this.list.getSelectedItem();
|
|
157694
157713
|
if (selected) this.list.onSelectionChange?.(selected);
|
|
157695
157714
|
else this.setSelectionPreview(void 0);
|
|
@@ -157758,7 +157777,10 @@ function choose(ui, host, theme, options) {
|
|
|
157758
157777
|
list.setSelectedIndex(options.selectedIndex ?? 0);
|
|
157759
157778
|
const maxContentLines = Math.max(0, ui.terminal.rows - maxVisible - 9);
|
|
157760
157779
|
const maxExpandedContentLines = Math.max(2, maxContentLines, ui.terminal.rows - 8);
|
|
157761
|
-
const dialog = new ChoiceDialog(sanitizeTerminalText(options.title, { preserveSgr: false }), sanitizeTerminalText(options.prompt, { preserveSgr: false }), sanitizeTerminalText(options.help ?? (hasDetails ? numberShortcutsEnabled ? "Type to filter · number selects · Up/Down choose · Ctrl+O details · ←/→ or PgUp/PgDn scroll · Enter confirm · Esc cancel" : "Type to filter · Up/Down choose · Ctrl+O details · ←/→ or PgUp/PgDn scroll · Enter confirm · Esc cancel" : numberShortcutsEnabled ? "Type to filter · number selects · Up/Down choose · Enter confirm · Esc cancel · Ctrl+U clear" : "Type to filter · Up/Down choose · Enter confirm · Esc cancel · Ctrl+U clear"), { preserveSgr: false }), list, theme, options.content, sanitizeTerminalText(options.contentLabel ?? "Details", { preserveSgr: false }), maxContentLines, maxExpandedContentLines)
|
|
157780
|
+
const dialog = new ChoiceDialog(sanitizeTerminalText(options.title, { preserveSgr: false }), sanitizeTerminalText(options.prompt, { preserveSgr: false }), sanitizeTerminalText(options.help ?? (hasDetails ? numberShortcutsEnabled ? "Type to filter · number selects · Up/Down choose · Ctrl+O details · ←/→ or PgUp/PgDn scroll · Enter confirm · Esc cancel" : "Type to filter · Up/Down choose · Ctrl+O details · ←/→ or PgUp/PgDn scroll · Enter confirm · Esc cancel" : numberShortcutsEnabled ? "Type to filter · number selects · Up/Down choose · Enter confirm · Esc cancel · Ctrl+U clear" : "Type to filter · Up/Down choose · Enter confirm · Esc cancel · Ctrl+U clear"), { preserveSgr: false }), list, theme, options.content, sanitizeTerminalText(options.contentLabel ?? "Details", { preserveSgr: false }), maxContentLines, maxExpandedContentLines, options.filterMode === "substring" ? (filter) => {
|
|
157781
|
+
const query = filter.toLowerCase();
|
|
157782
|
+
return new SelectList(searchableItems.filter((item) => item.label.toLowerCase().includes(query) || item.description?.toLowerCase().includes(query)), maxVisible, theme.select);
|
|
157783
|
+
} : void 0);
|
|
157762
157784
|
dialog.numberShortcutCount = numberShortcutsEnabled ? options.items.length : 0;
|
|
157763
157785
|
const previewFor = (item) => {
|
|
157764
157786
|
if (!item) return void 0;
|
|
@@ -161575,6 +161597,19 @@ var PermissionRequestQueue = class {
|
|
|
161575
161597
|
return result;
|
|
161576
161598
|
}
|
|
161577
161599
|
};
|
|
161600
|
+
/**
|
|
161601
|
+
* The abort signal of one permission request. The runtime passes its broker
|
|
161602
|
+
* options (`{ signal, claimResponse, timeoutMs }`) as the request context and
|
|
161603
|
+
* aborts `signal` when another responder settles the request first, such as a
|
|
161604
|
+
* `PermissionRequest` hook that allows or denies the call. `abortSignal` is
|
|
161605
|
+
* accepted as well for callers that use the TUI's own option name.
|
|
161606
|
+
*/
|
|
161607
|
+
function permissionRequestSignal(context) {
|
|
161608
|
+
if (typeof context !== "object" || context === null) return void 0;
|
|
161609
|
+
const record = context;
|
|
161610
|
+
if (record.signal instanceof AbortSignal) return record.signal;
|
|
161611
|
+
if (record.abortSignal instanceof AbortSignal) return record.abortSignal;
|
|
161612
|
+
}
|
|
161578
161613
|
//#endregion
|
|
161579
161614
|
//#region src/app-server-client.ts
|
|
161580
161615
|
const maximumOutputBytes = 16 * 1024 * 1024;
|
|
@@ -168862,11 +168897,14 @@ var ZCodeTui = class {
|
|
|
168862
168897
|
this.ui.requestRender();
|
|
168863
168898
|
}
|
|
168864
168899
|
requestPermission(requestValue, context) {
|
|
168865
|
-
const
|
|
168866
|
-
const signal = contextRecord?.abortSignal instanceof AbortSignal ? contextRecord.abortSignal : this.turnAbortController?.signal;
|
|
168900
|
+
const signal = permissionRequestSignal(context) ?? this.turnAbortController?.signal;
|
|
168867
168901
|
return this.permissionRequests.run(() => this.requestPermissionUnqueued(requestValue, signal));
|
|
168868
168902
|
}
|
|
168869
168903
|
async requestPermissionUnqueued(requestValue, signal) {
|
|
168904
|
+
if (signal?.aborted) return {
|
|
168905
|
+
decision: "deny",
|
|
168906
|
+
reason: "Permission request cancelled"
|
|
168907
|
+
};
|
|
168870
168908
|
const request = isRecord(requestValue) ? requestValue : {};
|
|
168871
168909
|
const toolName = asString(request.toolName) ?? "tool";
|
|
168872
168910
|
const asksUserQuestion = isAskUserQuestionTool(toolName);
|
|
@@ -168877,7 +168915,8 @@ var ZCodeTui = class {
|
|
|
168877
168915
|
if (asksUserQuestion) response = await this.requestUserQuestions(request.input, signal);
|
|
168878
168916
|
else if (isExitPlanModeTool(toolName)) response = await this.requestPlanApproval(request.input, signal);
|
|
168879
168917
|
else response = await this.requestToolPermission(request, toolName, signal);
|
|
168880
|
-
|
|
168918
|
+
const settledElsewhere = signal?.aborted === true && this.turnAbortController?.signal.aborted !== true;
|
|
168919
|
+
if (tool && !settledElsewhere) {
|
|
168881
168920
|
const record = isRecord(response) ? response : void 0;
|
|
168882
168921
|
const decision = asString(record?.decision)?.toLowerCase();
|
|
168883
168922
|
const allowed = decision === "allow" || decision === "modify";
|
|
@@ -169255,6 +169294,7 @@ var ZCodeTui = class {
|
|
|
169255
169294
|
...item,
|
|
169256
169295
|
payload: item.value
|
|
169257
169296
|
})),
|
|
169297
|
+
filterMode: "substring",
|
|
169258
169298
|
selectedIndex: picker.selectedIndex
|
|
169259
169299
|
}))?.payload;
|
|
169260
169300
|
if (typeof modelId !== "string") {
|
|
@@ -169299,6 +169339,7 @@ var ZCodeTui = class {
|
|
|
169299
169339
|
prompt: "Select the model used for new sessions.",
|
|
169300
169340
|
help: "Up/Down choose · Enter save · Esc back to settings",
|
|
169301
169341
|
items: picker.items,
|
|
169342
|
+
filterMode: "substring",
|
|
169302
169343
|
selectedIndex: picker.selectedIndex
|
|
169303
169344
|
});
|
|
169304
169345
|
if (!choice) return;
|