Skip to content

fix(zcode): prefer the builtin provider config ZCode Desktop refreshed - #1256

Merged
iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
oneopcai:fix/zcode-builtin-provider-config-cache
Nov 27, 2026
Merged

iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
oneopcai:fix/zcode-builtin-provider-config-cache

Conversation

@oneopcai

@oneopcai oneopcai commented Nov 27, 2026 •

Copy link
Copy Markdown

Summary

ZCode 适配器在未设置 ZCODE_BUILTIN_PROVIDER_CONFIG_FILE 时,固定把安装包自带的 config/provider/zcode-builtin.json 传给 CLI。ZCode Desktop 从 Endpoint 把内置 Provider 配置刷新到 {dataRoot}/runtime/provider/<platform>/<App version>/endpoint-<key>/zcode-builtin.json,并用自己的 resolveZCodeBuiltinCachePaths 与 EndpointScopedZCodeBuiltinSource(bundledFilePath 与 activeFilePath)决定生效文件;它启动自带 CLI 时传的是刷新后的文件。App 发布后新增的 Model 只存在于刷新后的文件中,所以 codexhost 的 ZCode 模型目录缺少这些 Model。

改动:

  • 新增 packages/adapters/zcode/src/builtin-provider-config.ts:内置 Provider 配置的 schema(从 account.ts 移出,两处共用)与 resolveDesktopBuiltinProviderConfig。后者在已安装 App 版本的 Endpoint 目录中取能按 schema 解析且 revision 最高的刷新文件,仅当它高于安装包文件的 revision 时返回该路径,否则返回 undefined。
  • installation.ts:传给 CLI 的文件按「环境变量 › Desktop 刷新后的文件 › 安装包文件」选取,dataRoot 的计算移到选取之前。
  • account.ts:改用共用的 schema,读取与 basedOnZCodeBuiltinRevision 的计算不变。
  • test/installation.test.ts:覆盖优先选取、各类回退、多个 Endpoint 目录取最高 revision、环境变量优先。
  • docs/harnesses/zcode/zcode-harness-integration.md:新增「内置 Provider 配置」一节并同步环境变量说明与验证记录。

刷新文件缺失、无法解析或版本不高于安装包文件时,检测结果与现状一致。

Related issues

Fixes #1255

UI Demo

无 / N/A:不涉及可见 UI 改动。

Test plan

自动测试(Node 24.9.0,Windows 11 x64):

  • npx tsc -b packages/adapters/zcode:通过。
  • npx vitest run --config tests/vitest.config.js packages/adapters/zcode/test/installation.test.ts:21 通过。新增的「prefers the builtin Provider config ZCode Desktop refreshed for the installed App version」与「takes the highest revision among Desktop's Endpoint copies of the builtin Provider config」在本改动之前失败(21 个中 2 个失败),改动之后通过。
  • npx vitest run --config tests/vitest.config.js packages/adapters/zcode/test:226 通过,20 跳过(需要 CODEXHOST_TEST_ZCODE_APP 的原生测试)。
  • npx prettier --check 与 npx eslint 只对改动文件运行:通过。

实机(Windows 11 x64,ZCode Desktop 4.0.0,Node 24.9.0):本机没有 Rust 工具链,未运行 npm start;改用已安装的 0.27.0 启动器加载 npm run build:typescript 构建的 Host,在独立数据目录与独立端口启动,环境未设置 ZCODE_BUILTIN_PROVIDER_CONFIG_FILE。

  • 基线 main@d0b0892:codexhost harness inspect zcode 的目录不含 account:bigmodel-individual-coding-plan/GLM-5.4,默认 Model 为 GLM-5.3。
  • 本分支:目录含 GLM-5.4(account:bigmodel-individual-coding-plan 与 bigmodel-api 各一条),默认 Model 为 GLM-5.4;未指定 Model 的 codexhost delegate start --harness zcode 以 BigModel / GLM-5.4 执行并正常完成。

未验证:macOS 与 Linux;同一 App 版本下多个 Endpoint 目录并存的真实安装(只有单元测试);全量测试未在本地运行。

全仓静态检查补充:npm run typecheck 与 node tools/check-boundaries.mjs 通过。npm run lint 报 21 个 eslint 错误,全部位于本 PR 未改动的文件(packages/web-server、packages/host-runtime/test、packages/renderer-extension/test),main@d0b0892 上相同;本 PR 改动的文件无错误。

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 新功能

    • ZCode 现在会优先使用当前应用版本中更新且有效的内置 Provider 配置;有多个可用配置时,选择版本号最高的一份。
    • 设置 ZCODE_BUILTIN_PROVIDER_CONFIG_FILE 后,仍优先使用指定配置;没有合适的更新配置时,回退至应用自带配置。
  • 文档

    • 补充配置选择规则及 ZCode 4.0.0(Windows x64)的实测记录。

ZCode Adapter 现在可选择当前 App 版本中 revision 高于安装包配置的 Desktop 刷新配置。环境变量指定的配置仍优先;无符合条件的刷新配置时,使用 App 内置配置。

Changes: ZCode 内置 Provider 配置

Layer / File(s) Summary
配置校验与刷新副本解析
packages/adapters/zcode/src/builtin-provider-config.ts, packages/adapters/zcode/src/account.ts
新增共享配置 schema 和 revision 读取逻辑。解析器扫描当前 App 版本的 Endpoint 配置,并返回高于安装包配置的最高 revision 文件。accountConfig 改用共享 schema。
安装配置选择与验证
packages/adapters/zcode/src/installation.ts, packages/adapters/zcode/test/installation.test.ts, docs/harnesses/zcode/zcode-harness-integration.md
安装解析优先使用环境变量指定的文件,其次选择符合条件的 Desktop 配置,最后回退到 App 内置配置。测试覆盖 revision、App 版本、配置有效性、多个 Endpoint 和显式路径优先级。文档说明选择规则,并记录 ZCode 4.0.0 / Windows x64 的实测结果。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant resolveInstallation
  participant resolveDesktopBuiltinProviderConfig
  participant DesktopConfigFiles
  resolveInstallation->>resolveDesktopBuiltinProviderConfig: 传入 dataRoot、App 版本和 bundled 文件
  resolveDesktopBuiltinProviderConfig->>DesktopConfigFiles: 扫描当前版本的 endpoint 配置
  DesktopConfigFiles-->>resolveDesktopBuiltinProviderConfig: 返回配置文件及 revision
  resolveDesktopBuiltinProviderConfig-->>resolveInstallation: 返回符合条件的最高 revision 文件路径
  resolveInstallation->>resolveInstallation: 使用所选路径或回退到 bundled 文件
Loading

Suggested labels: ZCode 接入

Suggested reviewers: lpmasser

Merge Risk: Minimal · up to dac15

Without the environment variable, ZCode can now use the Desktop-refreshed provider config when it is newer than the bundled one, so models such as GLM-5.4 appear in the catalog. Missing, invalid or not-newer refreshed files fall back to the bundled config as before. No concrete merge-blocking risk was established. Cross-platform behavior and multi-Endpoint installations have not been exercised on real installs.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(zcode): prefer the builtin provider config ZCode Desktop refreshed”准确描述了主要变更:ZCode 适配器在安装包配置之外优先选用 ZCode Desktop 刷新的内置 Provider 配置。变更集中的 builtin-provider-config.ts、installation.ts 和 account.ts …
Linked Issues check Passed [#1255] 需求:未设置 ZCODE_BUILTIN_PROVIDER_CONFIG_FILE 时,ZCode 模型目录须包含 Desktop 刷新后的 Model(如 GLM-5.4)。实现:packages/adapters/zcode/src/builtin-provider-config.ts 中的 resolveDesktopBuiltinProviderConfig 扫…
Out of Scope Changes check Passed 变更均与 #1255 的修复直接相关。builtin-provider-config.ts 实现刷新文件选取;installation.ts 接入选取顺序,并将 dataRoot 计算提前;account.ts 只改为复用共享 schema,读取逻辑与 basedOnZCodeBuiltinRevision 计算未变;installation.test.ts 为支撑测试;`…
Description check Passed PR 描述与变更集高度相关。描述说明了问题原因(ZCode 适配器固定使用安装包内的 zcode-builtin.json,未读取 Desktop 刷新后的文件)、各文件的改动(builtin-provider-config.ts、installation.ts、account.ts、测试与文档)、选取顺序(环境变量、Desktop 刷新文件、安装包文件),以及测试与实机验证结果。描述同时列出未验…
Full details: Title check

Explanation

标题“fix(zcode): prefer the builtin provider config ZCode Desktop refreshed”准确描述了主要变更:ZCode 适配器在安装包配置之外优先选用 ZCode Desktop 刷新的内置 Provider 配置。变更集中的 builtin-provider-config.ts、installation.ts 和 account.ts 都与该标题一致。标题为英文,与仓库的 conventional commit 风格一致。

Full details: Linked Issues check

Explanation

[#1255] 需求:未设置 ZCODE_BUILTIN_PROVIDER_CONFIG_FILE 时,ZCode 模型目录须包含 Desktop 刷新后的 Model(如 GLM-5.4)。实现:packages/adapters/zcode/src/builtin-provider-config.ts 中的 resolveDesktopBuiltinProviderConfig 扫描 {dataRoot}/runtime/provider/&lt;platform&gt;/&lt;appVersion&gt;/endpoint-*/zcode-builtin.json,只保留可按 schema 解析的文件,选取 revision 最高的文件,且仅当其 revision 高于安装包文件时返回。installation.ts 的选取顺序为环境变量、刷新文件、安装包文件,符合 Issue 的预期行为。installation.test.ts 覆盖优先选取、回退、多 Endpoint 取最高 revision 与环境变量优先。PR 描述报告在 Windows 11 与 ZCode Desktop 4.0.0 上,基线缺少 GLM-5.4,本分支目录包含 GLM-5.4,默认 Model 为 GLM-5.4,且默认委派成功。未验证项:macOS 与 Linux,以及同一 App 版本下多个 Endpoint 目录并存的真实安装。未直接核对 Desktop 的 activeFilePath 选取逻辑,因此多 Endpoint 时“取最高 revision”与 Desktop 的生效文件是否一致仍未经实机确认。Issue 的复现限定于 Windows,未要求其他平台。

Full details: Out of Scope Changes check

Explanation

变更均与 #1255 的修复直接相关。builtin-provider-config.ts 实现刷新文件选取;installation.ts 接入选取顺序,并将 dataRoot 计算提前;account.ts 只改为复用共享 schema,读取逻辑与 basedOnZCodeBuiltinRevision 计算未变;installation.test.ts 为支撑测试;docs/harnesses/zcode/zcode-harness-integration.md 记录新的选取规则与验证结果。未发现与 Issue 无关的功能或行为改动。

Full details: Description check

Explanation

PR 描述与变更集高度相关。描述说明了问题原因(ZCode 适配器固定使用安装包内的 zcode-builtin.json,未读取 Desktop 刷新后的文件)、各文件的改动(builtin-provider-config.ts、installation.ts、account.ts、测试与文档)、选取顺序(环境变量、Desktop 刷新文件、安装包文件),以及测试与实机验证结果。描述同时列出未验证的范围(macOS、Linux、多 Endpoint 真实安装、全量测试)。

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Without ZCODE_BUILTIN_PROVIDER_CONFIG_FILE the adapter handed the CLI the
config bundled in the App. ZCode Desktop refreshes that config from its
Endpoint into its runtime provider directory and starts its own CLI with
the refreshed file, so Models added after the App shipped were missing
from the ZCode catalog.

Pick the highest-revision refreshed file of the installed App version
when it is newer than the bundled one, and keep the bundled file otherwise.
@oneopcai
oneopcai force-pushed the fix/zcode-builtin-provider-config-cache branch from 9f6dbeb to dac155e Compare November 27, 2026 00:21
@iruriQ
iruriQ merged commit 6f587b5 into BytePioneer-AI:main Nov 27, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] ZCode adapter reads only the bundled provider config and misses Models refreshed by ZCode Desktop

2 participants