@aiwayds/dsh-model-sync 0.5.0 → 0.6.1

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
@@ -4,9 +4,9 @@
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@aiwayds/dsh-model-sync)](https://www.npmjs.com/package/@aiwayds/dsh-model-sync) · [GitHub](https://github.com/fan56/dsh-model-sync)
6
6
 
7
- A dsh (DeepSeek Harness) Cordis plugin that keeps the model catalog of your `llm-pi-ai` provider routes in step with the pi.dev gateway's model listing — written into dsh `settings.yaml` through the official settings seam (`settings.mutate`), with zero patches to dsh internals.
7
+ A dsh (DeepSeek Harness) Cordis plugin that keeps the model catalog of your `llm-pi-ai` provider routes in step with the pi.dev gateway's model listing — written through the official settings seam (`settings.mutate`), with zero patches to dsh internals.
8
8
 
9
- **Requires dsh >= 0.1.5-rc.2** — this plugin targets the dsh RC/stable line only (CI and releases resolve the newest of the `latest`/`next` dist-tags at runtime). **The alpha line is no longer supported.**
9
+ **Requires dsh >= 0.1.7-rc.1** — this plugin targets the dsh RC/stable line only (CI and releases resolve the newest of the `latest`/`next` dist-tags at runtime). **The alpha line is no longer supported.** On dsh 0.1.7+ the settings document is the profile patch (settings.yaml is imported once and renamed); the plugin only ever writes through the official API, so it works unchanged on either shape.
10
10
 
11
11
  https://github.com/user-attachments/assets/c3f9c8b1-ea5e-470c-b8a8-60a81fc5c20a
12
12
 
@@ -17,7 +17,7 @@ https://github.com/user-attachments/assets/c3f9c8b1-ea5e-470c-b8a8-60a81fc5c20a
17
17
  Model lists drift: providers ship new models, retire old ones, and adjust capabilities (`contextWindow`, `input` modalities, `thinkingFormat`, reasoning efforts). Keeping them in sync by hand is error-prone busywork. dsh-model-sync does it for you:
18
18
 
19
19
  - **Add-only, change-only writes.** New models from pi.dev are merged in, existing ones updated, and unchanged routes are left completely untouched — the writer compares against the raw user segment and skips a route when nothing changed (`writer.ts`, `profilesEqual`, `reason: 'no-change'`).
20
- - **No hand-maintained model lists.** The pi.dev remote catalog is the source of truth for the managed routes; your `settings.yaml` simply reflects it.
20
+ - **No hand-maintained model lists.** The pi.dev remote catalog is the source of truth for the managed routes; your settings (the `llm-pi-ai` provider profile) simply reflect it.
21
21
  - **Scheduled refresh.** An auto round runs shortly after startup and then on a configurable interval, so the catalog stays current without any interaction.
22
22
 
23
23
  ## Features
@@ -25,7 +25,7 @@ Model lists drift: providers ship new models, retire old ones, and adjust capabi
25
25
  - **pi.dev gateway sync.** Fetches each managed route's model list from `https://pi.dev/api/models/providers/<route>` with ETag/304 revalidation and a persistent per-provider cache under `~/.dsh/models-store.json` (`remote-catalog.ts`). Transient failures and aborts keep the last-good cache; a 404/501 treats the route as absent for the round.
26
26
  - **Default routes.** When `managedRoutes` is empty, these pi.dev routes are synced: `opencode-go`, `zai-coding-cn`, `minimax-cn`, `xiaomi-token-plan-cn` (`DEFAULT_ROUTES` in `src/index.ts`).
27
27
  - **Two write modes** (`writeMode`):
28
- - `settings` (default) — the zero-patch pipeline: fetch → translate → `settings.mutate`. Self-contained; never touches `settings.yaml` directly, only via the official settings API.
28
+ - `settings` (default) — the zero-patch pipeline: fetch → translate → `settings.mutate`. Self-contained; never touches the settings document directly, only via the official settings API.
29
29
  - `overlay` (legacy) — delegates to the patched `dsh-llm-pi-ai` adapter's `piAiCatalog.refresh()` and merges pi.dev entries in memory (requires the optional patch).
30
30
  - **Scheduled refresh.** `intervalMinutes` auto rounds (default 240 / 4h) plus a `startupDelaySeconds` initial delay (default 5); each round logs the same report a manual refresh produces. `0` disarms the interval (startup-only). The interval re-arms live when the config changes (`src/index.ts`).
31
31
  - **Change reporting / diff.** Every round reports added/removed model ids (`diffModelIds`), and in `settings` mode added/removed/changed entries against the current raw settings (`diffEntries`, `diff.ts`). Dropped and degraded entries are reported with their reasons.
@@ -37,6 +37,7 @@ Model lists drift: providers ship new models, retire old ones, and adjust capabi
37
37
  - `keepBuiltinOnly: true` — keep built-in catalog models that are not (yet) on pi.dev, so adopting the sync doesn't delete models you already use.
38
38
  - `dropUnserviceable: true` — drop unserviceable entries and continue; set to `false` to abort the whole route instead of writing a partial list.
39
39
  - `forceMaxReasoningEffort` — force models with a non-empty `thinkingFormat` to max reasoning effort (ensures `reasoningEfforts` contains `max` and forces `compat.supportsReasoningEffort = true` on `openai-completions`).
40
+ - **First-party listings, unioned in (`providerNativeFetch`, default on).** pi.dev lags the providers, so every mapped route also fetches the provider's own OpenAI-shaped `GET /models` listing and unions it in: DeepSeek, Moonshot/Kimi (`moonshotai`, `moonshotai-cn`, `kimi-coding`), Zhipu (`zai`, `zai-coding-cn`), and Xiaomi MiMo (`xiaomi`, `xiaomi-token-plan-cn/ams/sgp`; `api-key` header auth). The merge is additions-only — ids pi.dev already carries keep pi.dev's metadata, listing-only ids enter as minimal entries. Unknown capacities are simply not written (`contextWindow` only when the listing states one, e.g. Moonshot's `context_length`; `maxTokens` never), so the route's `defaultContextWindow` / `defaultMaxTokens` apply. A failed listing fetch degrades to the pi.dev result and never loses models; `providerNativeFetch: false` restores the pi.dev-only behavior.
40
41
  - **Conflict-safe writes.** Writes carry the settings revision and retry once on `SETTINGS_CONFLICT` (`writer.ts`).
41
42
 
42
43
  ## Install
@@ -48,7 +49,7 @@ npm i @aiwayds/dsh-model-sync
48
49
  dsh plugin add @aiwayds/dsh-model-sync
49
50
  ```
50
51
 
51
- The package ships `cordis.patch.yml` (wired as `dsh.bundle.patch`), which mounts the plugin into the profile's assembly tree under the stable plugin id `dsh-model-sync` and registers the `model-sync` settings namespace.
52
+ The package ships `cordis.patch.yml` (wired as `dsh.bundle.patch`), which mounts the plugin into the profile's assembly tree under the stable plugin id `dsh-model-sync` — on dsh 0.1.7+ that entry id doubles as the settings namespace for the plugin's `Config` schema.
52
53
 
53
54
  This plugin ships standalone — install it explicitly with `dsh plugin add @aiwayds/dsh-model-sync` when you want it.
54
55
 
@@ -61,12 +62,12 @@ dsh plugin remove @aiwayds/dsh-model-sync
61
62
  The host auto-cleans: the bundles entry is spliced out of the profile and the plugin's patch layer drops with the package, so the sync rounds and the `/model-sync` command simply stop. Three things intentionally stay on disk:
62
63
 
63
64
  1. **`~/.dsh/models-store.json` — back this file up before purging it.** It holds the catalog cache *plus* your `modelOverrides`: under the store-first invariant the plugin folds overrides into the written models and unsets the settings key, so for a managed route the store can be the **only** copy of your override values. Deleting the file deletes them.
64
- 2. **Synced model lists in `~/.dsh/settings.yaml`.** The plugin wrote them into the host-owned `llm-pi-ai` namespace (`providers.<route>.models`) through the official settings seam. They persist after removal and remain valid host config — dsh consumes them exactly as if you had written them by hand. Remove those entries by hand if you don't want them.
65
+ 2. **Synced model lists in the settings document.** The plugin wrote them into the host-owned `llm-pi-ai` namespace (`providers.<route>.models`) through the official settings seam (`~/.dsh/settings.yaml` up to dsh 0.1.6, the profile patch on 0.1.7+). They persist after removal and remain valid host config — dsh consumes them exactly as if you had written them by hand. Remove those entries by hand if you don't want them.
65
66
  3. **A stale staging file, rarely.** The store's writes go through a temp-file + rename; if a process died mid-write a `~/.dsh/models-store.json.<pid>.tmp` file can remain. It is safe to delete.
66
67
 
67
68
  ## Usage
68
69
 
69
- Configure the plugin under the `model-sync` namespace in `settings.yaml` — every key is optional:
70
+ Configure the plugin under the `dsh-model-sync` settings entry — on dsh 0.1.7+ the entry id (the same stable id the bundle patch always mounted) is the settings namespace; edit it in the settings UI or your profile patch. Every key is optional, and every key is a volatile field, so edits apply without restarting the plugin. Upgrading from a pre-0.1.7 install: a legacy top-level `model-sync:` section in the old `settings.yaml` is imported once into the new entry automatically at the next plugin boot (the audit record lands in `~/.dsh/storages/dsh-model-sync/legacy-import.json`):
70
71
 
71
72
  | Key | Default | Description |
72
73
  |---|---|---|
@@ -79,11 +80,13 @@ Configure the plugin under the `model-sync` namespace in `settings.yaml` — eve
79
80
  | `dropUnserviceable` | `true` | Drop unserviceable entries; `false` aborts the route instead |
80
81
  | `syncNotify` | `false` | Notify on changes (logger + `/model-sync` report) |
81
82
  | `forceMaxReasoningEffort` | `false` | Force max reasoning effort on models with a non-empty `thinkingFormat` |
83
+ | `providerNativeFetch` | `true` | Union each mapped provider's first-party `/models` listing into the pi.dev result (additions only) |
84
+ | `keepDeprecatedBuiltin` | `false` | Opt back into emitting builtin ids the official default model list dropped (dsh 0.1.7 removed `deepseek-v4-flash` / `deepseek-v4-flash-vision-exp`; the snapshot keeps the data but no longer syncs them by default) |
82
85
 
83
- Example:
86
+ Example (settings section `dsh-model-sync`; a legacy `settings.yaml` `model-sync:` section is not auto-imported by the dsh 0.1.7 host itself — the plugin recovers it once at boot, see above):
84
87
 
85
88
  ```yaml
86
- model-sync:
89
+ dsh-model-sync:
87
90
  writeMode: settings
88
91
  intervalMinutes: 30
89
92
  managedRoutes:
@@ -125,7 +128,7 @@ Tests use per-route pi.dev fixtures under `test/fixtures/` and temp directories
125
128
 
126
129
  Utility scripts under `scripts/`:
127
130
 
128
- - `generate-builtin-snapshot.mjs` — regenerate `src/builtin-catalog-snapshot.ts` from the installed `@deepseek-ai/dsh-llm-pi-ai` catalog (`--generate` for dev, `--check` for CI).
131
+ - `generate-builtin-snapshot.mjs` — regenerate `src/builtin-catalog-snapshot.ts` from the installed `@deepseek-ai/dsh-llm-pi-ai` catalog (`--generate` for dev, `--check` for CI). Hand-maintained `deprecated: true` marks (ids the official default model list dropped) are preserved by id across regenerations.
129
132
  - `verify-no-patch.mjs` — exits non-zero if any installed `dsh-llm-pi-ai` still carries the overlay patch signatures (`withRemoteCatalog` / `piAiCatalog`).
130
133
  - `backup/backup-patched.mjs` — back up a patched `dsh-llm-pi-ai/lib/index.js` to `backups/`.
131
134
  - `backup/restore-official.mjs` — restore the official unpatched `dsh-llm-pi-ai/lib/index.js` from npm, validated against the patch (`--dry-run` supported).
package/README.zh-CN.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@aiwayds/dsh-model-sync)](https://www.npmjs.com/package/@aiwayds/dsh-model-sync) · [GitHub](https://github.com/fan56/dsh-model-sync)
6
6
 
7
- 一个 dsh(DeepSeek Harness)Cordis 插件:把 `llm-pi-ai` 各 provider 路由的模型目录与 pi.dev 网关的模型列表保持同步,并通过官方 settings 接缝(`settings.mutate`)写进 dsh 的 `settings.yaml`——对 dsh 内部零补丁。
7
+ 一个 dsh(DeepSeek Harness)Cordis 插件:把 `llm-pi-ai` 各 provider 路由的模型目录与 pi.dev 网关的模型列表保持同步——经官方 settings 接缝(`settings.mutate`)写入,对 dsh 内部零补丁。
8
8
 
9
- **要求 dsh >= 0.1.5-rc.2** — 本插件只跟随 dsh RC/stable 线(CI 与发版在运行时解析 latest/next 中更新的 dist-tag)。**不再支持 alpha 线。**
9
+ **要求 dsh >= 0.1.7-rc.1** — 本插件只跟随 dsh RC/stable 线(CI 与发版在运行时解析 latest/next 中更新的 dist-tag)。**不再支持 alpha 线。** dsh 0.1.7 起 settings 文档是 profile patch(旧 settings.yaml 导入一次后改名);本插件始终只经官方 API 写入,两种形态下行为一致。
10
10
 
11
11
  https://github.com/user-attachments/assets/c3f9c8b1-ea5e-470c-b8a8-60a81fc5c20a
12
12
 
@@ -17,7 +17,7 @@ https://github.com/user-attachments/assets/c3f9c8b1-ea5e-470c-b8a8-60a81fc5c20a
17
17
  模型列表会漂移:provider 不断上架新模型、下线旧模型、调整能力字段(`contextWindow`、`input` 模态、`thinkingFormat`、reasoning efforts)。靠手工跟进既枯燥又容易出错,dsh-model-sync 替你做完这一切:
18
18
 
19
19
  - **只增只改的写入。** pi.dev 上的新模型被合并进来,已有模型按需更新,没有变化的路由完全不动——writer 会先和 settings 里的原始 user 段做比较,无变化即跳过(`writer.ts`、`profilesEqual`、`reason: 'no-change'`)。
20
- - **不再手工维护模型表。** 对受管路由而言,pi.dev remote catalog 就是唯一事实来源,你的 `settings.yaml` 只是它的投影。
20
+ - **不再手工维护模型表。** 对受管路由而言,pi.dev remote catalog 就是唯一事实来源,你的 settings(`llm-pi-ai` provider 配置)只是它的投影。
21
21
  - **定时刷新。** 启动后不久自动跑一轮,之后按可配置的周期持续刷新,目录无需任何手动操作即可保持最新。
22
22
 
23
23
  ## 特性
@@ -25,7 +25,7 @@ https://github.com/user-attachments/assets/c3f9c8b1-ea5e-470c-b8a8-60a81fc5c20a
25
25
  - **pi.dev 网关同步。** 从 `https://pi.dev/api/models/providers/<route>` 拉取每条受管路由的模型列表,带 ETag/304 revalidation,并在 `~/.dsh/models-store.json` 维护按 provider 持久化的缓存(`remote-catalog.ts`)。瞬时故障与中断保留上次成功的缓存(last-good);404/501 视为该路由本轮不存在。
26
26
  - **默认路由。** `managedRoutes` 为空时,同步以下 pi.dev 路由:`opencode-go`、`zai-coding-cn`、`minimax-cn`、`xiaomi-token-plan-cn`(`src/index.ts` 的 `DEFAULT_ROUTES`)。
27
27
  - **两种写模式**(`writeMode`):
28
- - `settings`(默认)——零补丁流水线:fetch → translate → `settings.mutate`。自包含,从不直接改写 `settings.yaml`,只经官方 settings API 落盘。
28
+ - `settings`(默认)——零补丁流水线:fetch → translate → `settings.mutate`。自包含,从不直接改写 settings 文档,只经官方 settings API 落盘。
29
29
  - `overlay`(旧方案)——委托打了补丁的 `dsh-llm-pi-ai` 适配器的 `piAiCatalog.refresh()`,把 pi.dev 条目合并进内存(需要可选补丁)。
30
30
  - **定时刷新。** `intervalMinutes` 周期轮(默认 240,即 4 小时)加 `startupDelaySeconds` 启动延迟(默认 5 秒);每轮自动刷新输出的报告与手动刷新完全相同。`0` 表示关闭周期(仅启动时刷一次)。配置变更时周期会实时重新挂载(`src/index.ts`)。
31
31
  - **变更报告 / diff。** 每轮报告新增/移除的模型 id(`diffModelIds`);`settings` 模式下还会对照当前原始 settings 报告新增/移除/变更的条目(`diffEntries`,`diff.ts`)。被丢弃(dropped)与降级(degraded)的条目连同原因一并报告。
@@ -37,6 +37,7 @@ https://github.com/user-attachments/assets/c3f9c8b1-ea5e-470c-b8a8-60a81fc5c20a
37
37
  - `keepBuiltinOnly: true`——保留内置目录里有、但 pi.dev 上(还)没有的模型,启用同步不会删掉你正在用的模型。
38
38
  - `dropUnserviceable: true`——丢弃不可服务的条目并继续;设为 `false` 则改为中止整条路由,而不是写入残缺列表。
39
39
  - `forceMaxReasoningEffort`——强制所有 `thinkingFormat` 非空的模型使用 max reasoning effort(确保 `reasoningEfforts` 包含 `max`,并在 `openai-completions` 上强制 `compat.supportsReasoningEffort = true`)。
40
+ - **厂商原生列表并入(`providerNativeFetch`,默认开)。** pi.dev 的目录滞后于厂商,所以每轮同步还会拉取映射路由的厂商自家 OpenAI 形状 `GET /models` 列表并做并集:DeepSeek、Moonshot/Kimi(`moonshotai`、`moonshotai-cn`、`kimi-coding`)、智谱(`zai`、`zai-coding-cn`)、小米 MiMo(`xiaomi`、`xiaomi-token-plan-cn/ams/sgp`,用 `api-key` 请求头认证)。合并只增不减——pi.dev 已有的 id 保留其元数据,仅厂商列表独有的 id 以最小条目进入。未知的容量参数一律不写(`contextWindow` 仅当列表自带,如 Moonshot 的 `context_length`;`maxTokens` 从不写),落到路由的 `defaultContextWindow` / `defaultMaxTokens` 兜底。拉取失败降级为纯 pi.dev 结果、绝不丢模型;`providerNativeFetch: false` 恢复旧行为。
40
41
  - **冲突安全写入。** 写入携带 settings revision,遇 `SETTINGS_CONFLICT` 自动重试一次(`writer.ts`)。
41
42
 
42
43
  ## 安装
@@ -48,7 +49,7 @@ npm i @aiwayds/dsh-model-sync
48
49
  dsh plugin add @aiwayds/dsh-model-sync
49
50
  ```
50
51
 
51
- 包内附带 `cordis.patch.yml`(经 `dsh.bundle.patch` 接线),它把插件挂载进 profile 的装配树(稳定的插件 id `dsh-model-sync`),并注册 `model-sync` settings 命名空间。
52
+ 包内附带 `cordis.patch.yml`(经 `dsh.bundle.patch` 接线),它把插件挂载进 profile 的装配树(稳定的插件 id `dsh-model-sync`)——dsh 0.1.7 起该 entry id 即插件 `Config` schema 对应的 settings 命名空间。
52
53
 
53
54
  本插件独立分发——需要时用 `dsh plugin add @aiwayds/dsh-model-sync` 显式安装即可。
54
55
 
@@ -61,12 +62,12 @@ dsh plugin remove @aiwayds/dsh-model-sync
61
62
  宿主会自动清理:bundles 条目会从 profile 中摘除,插件自带的 patch 层随包一起消失,同步轮次与 `/model-sync` 命令就此停止。有三样东西会刻意留在磁盘上:
62
63
 
63
64
  1. **`~/.dsh/models-store.json`——清除前请先备份这个文件。** 它保存目录缓存**以及**你的 `modelOverrides`:在 store-first 不变式下,插件把覆盖值折叠进写入的 models 并清掉 settings 里的键,因此对受管路由而言 store 可能是覆盖值的**唯一**副本。删掉文件就等于删掉它们。
64
- 2. **`~/.dsh/settings.yaml` 里已同步的模型列表。** 插件经官方 settings 接缝把它们写进了宿主持有的 `llm-pi-ai` 命名空间(`providers.<route>.models`)。卸载后它们会保留,并且仍是合法的宿主配置——dsh 会照常消费,就像你手写的一样。不想要就手动删除对应条目。
65
+ 2. **settings 文档里已同步的模型列表。** 插件经官方 settings 接缝把它们写进了宿主持有的 `llm-pi-ai` 命名空间(`providers.<route>.models`;dsh ≤0.1.6 在 `~/.dsh/settings.yaml`,0.1.7+ 在 profile patch)。卸载后它们会保留,并且仍是合法的宿主配置——dsh 会照常消费,就像你手写的一样。不想要就手动删除对应条目。
65
66
  3. **极少数情况下的残留暂存文件。** store 的写入走临时文件 + rename;若进程在写入中途死掉,可能留下 `~/.dsh/models-store.json.<pid>.tmp`。直接删除是安全的。
66
67
 
67
68
  ## 用法
68
69
 
69
- 在 `settings.yaml` 的 `model-sync` 命名空间下配置本插件——每个键都是可选的:
70
+ 在 `dsh-model-sync` 设置条目下配置本插件——dsh 0.1.7+ 的 entry id(与 bundle patch 一直使用的稳定 id 相同)即 settings 命名空间,在设置 UI 或 profile patch 中编辑即可。每个键都是可选的,且全部是 volatile 字段,改动无需重启插件即可生效。从 0.1.7 之前升级:旧 `settings.yaml` 里的 `model-sync:` 段会在下次插件 boot 时一次性自动迁入新条目(审计档在 `~/.dsh/storages/dsh-model-sync/legacy-import.json`):
70
71
 
71
72
  | 键 | 默认值 | 说明 |
72
73
  |---|---|---|
@@ -79,11 +80,15 @@ dsh plugin remove @aiwayds/dsh-model-sync
79
80
  | `dropUnserviceable` | `true` | 丢弃不可服务的条目;`false` 改为中止整条路由 |
80
81
  | `syncNotify` | `false` | 有变更时通知(logger + `/model-sync` 报告) |
81
82
  | `forceMaxReasoningEffort` | `false` | 对 `thinkingFormat` 非空的模型强制 max reasoning effort |
83
+ | `providerNativeFetch` | `true` | 把各厂商自家的 `/models` 列表并入 pi.dev 结果(只增不减) |
84
+ | `keepDeprecatedBuiltin` | `false` | 重新同步官方默认列表已移除的内置 id(dsh 0.1.7 移除了 `deepseek-v4-flash` / `deepseek-v4-flash-vision-exp`;快照保留数据但默认不再同步) |
82
85
 
83
86
  示例:
84
87
 
88
+ 示例(settings 段名 `dsh-model-sync`;dsh 0.1.7 宿主本身不会自动导入旧 `settings.yaml` 里的 `model-sync:` 段——插件会在 boot 时一次性迁回,见上文):
89
+
85
90
  ```yaml
86
- model-sync:
91
+ dsh-model-sync:
87
92
  writeMode: settings
88
93
  intervalMinutes: 30
89
94
  managedRoutes:
@@ -125,7 +130,7 @@ npm test # node --test(pretest 先构建):diff / translate / writer
125
130
 
126
131
  `scripts/` 下的工具脚本:
127
132
 
128
- - `generate-builtin-snapshot.mjs`——从已安装的 `@deepseek-ai/dsh-llm-pi-ai` catalog 重新生成 `src/builtin-catalog-snapshot.ts`(`--generate` 用于开发,`--check` 用于 CI)。
133
+ - `generate-builtin-snapshot.mjs`——从已安装的 `@deepseek-ai/dsh-llm-pi-ai` catalog 重新生成 `src/builtin-catalog-snapshot.ts`(`--generate` 用于开发,`--check` 用于 CI)。手工维护的 `deprecated: true` 标记(官方默认列表已移除的 id)在重新生成时按 id 保留。
129
134
  - `verify-no-patch.mjs`——若已安装的 `dsh-llm-pi-ai` 仍带有 overlay 补丁签名(`withRemoteCatalog` / `piAiCatalog`)则非零退出。
130
135
  - `backup/backup-patched.mjs`——把打过补丁的 `dsh-llm-pi-ai/lib/index.js` 备份到 `backups/`。
131
136
  - `backup/restore-official.mjs`——从 npm 恢复官方未打补丁的 `dsh-llm-pi-ai/lib/index.js`,并对照补丁校验(支持 `--dry-run`)。
package/cordis.patch.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  # dsh-model-sync bundle patch: mounts the plugin into the profile's assembly
2
- # tree under the stable plugin id `dsh-model-sync`. It registers the
3
- # `model-sync` settings namespace and keeps configured `llm-pi-ai` provider
4
- # routes' model lists in step with the gateway's /models endpoint via
5
- # add-only merges written through the official settings seam.
2
+ # tree under the stable plugin id `dsh-model-sync`. On dsh 0.1.7+ that entry
3
+ # id is also the settings namespace: the plugin's exported Config schema is
4
+ # projected into its settings form, and it keeps configured `llm-pi-ai`
5
+ # provider routes' model lists in step with the gateway's /models endpoint
6
+ # via add-only merges written through the official settings seam.
6
7
 
7
8
  - insert:
8
9
  - id: dsh-model-sync
package/icon.svg ADDED
@@ -0,0 +1,6 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M4 8h13.5"/>
3
+ <path d="M14.5 5.5 17.5 8l-3 2.5"/>
4
+ <path d="M20 16H6.5"/>
5
+ <path d="M9.5 13.5 6.5 16l3 2.5"/>
6
+ </svg>
@@ -7,6 +7,15 @@
7
7
  *
8
8
  * To regenerate: run `node scripts/generate-builtin-snapshot.mjs --generate`
9
9
  *
10
+ * Entries marked `deprecated: true` are ids the official default model list
11
+ * dropped (dsh 0.1.7-rc.1 removed deepseek-v4-flash /
12
+ * deepseek-v4-flash-vision-exp; DeepSeek renamed deepseek-v4-flash →
13
+ * deepseek-flash on its own listing). The data is retained for historical
14
+ * user configurations: keepBuiltinOnly emission skips deprecated ids
15
+ * unless keepDeprecatedBuiltin opts back in. Marks and entries survive
16
+ * regeneration — this script re-adds them even when the installed catalog
17
+ * no longer lists the id.
18
+ *
10
19
  * @module dsh-model-sync/builtin-catalog-snapshot
11
20
  */
12
21
  import type { BuiltinModelData } from './translate.ts';
@@ -7,8 +7,8 @@ export const BUILTIN_CATALOG_SNAPSHOT = {
7
7
  { id: 'MiniMax-M3', api: 'anthropic-messages', maxTokens: 512000 }
8
8
  ],
9
9
  'opencode-go': [
10
- { id: 'deepseek-v4-flash', api: 'openai-completions', maxTokens: 384000 },
11
- { id: 'deepseek-v4-flash-vision-exp', api: 'openai-completions', maxTokens: 384000 },
10
+ { id: 'deepseek-v4-flash', api: 'openai-completions', maxTokens: 384000, deprecated: true },
11
+ { id: 'deepseek-v4-flash-vision-exp', api: 'openai-completions', maxTokens: 384000, deprecated: true },
12
12
  { id: 'deepseek-v4-pro', api: 'openai-completions', maxTokens: 384000 },
13
13
  { id: 'glm-5.1', api: 'openai-completions', maxTokens: 32768 },
14
14
  { id: 'glm-5.2', api: 'openai-completions', maxTokens: 131072 },
@@ -1 +1 @@
1
- {"version":3,"file":"builtin-catalog-snapshot.js","sourceRoot":"","sources":["../src/builtin-catalog-snapshot.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAqB7E,8CAA8C;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAA8B;IACjE,YAAY,EAAE;QACZ,EAAE,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,EAAE;QACpE,EAAE,EAAE,EAAE,wBAAwB,EAAE,GAAG,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,EAAE;QAC9E,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,EAAE;KACnE;IACD,aAAa,EAAE;QACb,EAAE,EAAE,EAAE,mBAAmB,EAAE,GAAG,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,EAAE;QACzE,EAAE,EAAE,EAAE,8BAA8B,EAAE,GAAG,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,EAAE;QACpF,EAAE,EAAE,EAAE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:
6
+ * - 'settings' (default): self-contained fetch → translate → settings.mutate
7
+ * pipeline that writes through the host settings service (zero patch
8
+ * required; settings.yaml up to dsh 0.1.6, the profile patch on 0.1.7+)
9
+ * - 'overlay' (legacy): uses the patched dsh-llm-pi-ai's piAiCatalog.refresh()
10
+ * to overlay pi.dev entries in memory (requires patch)
11
+ *
12
+ * @module dsh-model-sync
13
+ */
14
+ import z from '@deepseek-ai/schemastery';
1
15
  import type { Context } from '@deepseek-ai/cordis';
16
+ import { type RemoteCatalogEntry } from './remote-catalog.ts';
17
+ import { type BuiltinModelData } from './translate.ts';
2
18
  export declare const name = "dsh-model-sync";
3
19
  /** The settings seam this plugin consumes (its own config namespace). */
4
20
  export declare const inject: string[];
21
+ /**
22
+ * The plugin's `Config` schema: the settings form the 0.1.7 host projects from
23
+ * the `dsh-model-sync` entry. Every field is user-adjustable and therefore
24
+ * `.volatile()` — volatile fields are the only ones the settings page can edit
25
+ * (and the only ones the legacy settings.yaml import accepts), and they hot-
26
+ * reload without remounting the plugin. Requires schemastery >= 3.18.4 (the
27
+ * version the dsh 0.1.7 wave ships), which provides `.volatile()`.
28
+ */
29
+ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
30
+ /**
31
+ * Write mode: 'settings' (default, zero-patch settings.mutate pipeline) or
32
+ * 'overlay' (legacy, delegates to the patched adapter's piAiCatalog.refresh
33
+ * and requires the optional patch).
34
+ */
35
+ writeMode: z<"settings" | "overlay", "settings" | "overlay", "volatile-defined">;
36
+ /** Minutes between auto refreshes (default 240 = 4 hours); 0 = startup-only. */
37
+ intervalMinutes: z<number, number, "volatile-defined">;
38
+ /** Delay before the first auto refresh, so the llm adapter is ready. */
39
+ startupDelaySeconds: z<number, number, "volatile-defined">;
40
+ /** Abort budget for one forced refresh's network round. */
41
+ refreshTimeoutMs: z<number, number, "volatile-defined">;
42
+ /** Routes to manage (empty = all pi.dev routes). */
43
+ managedRoutes: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
44
+ /** Keep builtin-only models not in pi.dev (smooth migration). */
45
+ keepBuiltinOnly: z<boolean, boolean, "volatile-defined">;
46
+ /** Drop unserviceable entries (true) or abort the entire route (false). */
47
+ dropUnserviceable: z<boolean, boolean, "volatile-defined">;
48
+ /**
49
+ * Union each mapped route's first-party /models listing into the pi.dev
50
+ * result (additions only — see provider-native.ts). Default on: the native
51
+ * listing is the fresher source; pi.dev lags (measured 2026-09-22).
52
+ */
53
+ providerNativeFetch: z<boolean, boolean, "volatile-defined">;
54
+ /** Notify on changes (logger + /model-sync report). */
55
+ syncNotify: z<boolean, boolean, "volatile-defined">;
56
+ /**
57
+ * Force all models with a non-empty thinkingFormat to have max reasoning
58
+ * effort. Skips S2 gate's SRE check, ensures reasoningEfforts contains
59
+ * max, and forces compat.supportsReasoningEffort=true (S5 gate, openai-
60
+ * completions only). 400 risk is on the user.
61
+ */
62
+ forceMaxReasoningEffort: z<boolean, boolean, "volatile-defined">;
63
+ /**
64
+ * keepBuiltinOnly may re-emit builtin ids the official default model list
65
+ * dropped (dsh 0.1.7 removed deepseek-v4-flash / deepseek-v4-flash-vision-
66
+ * exp). Those stay in the snapshot for historical user configurations but
67
+ * are excluded from the synced list unless this flag opts them back in —
68
+ * a re-emitted retired id is a model the 0.1.7 host no longer resolves.
69
+ */
70
+ keepDeprecatedBuiltin: z<boolean, boolean, "volatile-defined">;
71
+ }>>, Schemastery.ObjectT<NoInfer<{
72
+ /**
73
+ * Write mode: 'settings' (default, zero-patch settings.mutate pipeline) or
74
+ * 'overlay' (legacy, delegates to the patched adapter's piAiCatalog.refresh
75
+ * and requires the optional patch).
76
+ */
77
+ writeMode: z<"settings" | "overlay", "settings" | "overlay", "volatile-defined">;
78
+ /** Minutes between auto refreshes (default 240 = 4 hours); 0 = startup-only. */
79
+ intervalMinutes: z<number, number, "volatile-defined">;
80
+ /** Delay before the first auto refresh, so the llm adapter is ready. */
81
+ startupDelaySeconds: z<number, number, "volatile-defined">;
82
+ /** Abort budget for one forced refresh's network round. */
83
+ refreshTimeoutMs: z<number, number, "volatile-defined">;
84
+ /** Routes to manage (empty = all pi.dev routes). */
85
+ managedRoutes: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
86
+ /** Keep builtin-only models not in pi.dev (smooth migration). */
87
+ keepBuiltinOnly: z<boolean, boolean, "volatile-defined">;
88
+ /** Drop unserviceable entries (true) or abort the entire route (false). */
89
+ dropUnserviceable: z<boolean, boolean, "volatile-defined">;
90
+ /**
91
+ * Union each mapped route's first-party /models listing into the pi.dev
92
+ * result (additions only — see provider-native.ts). Default on: the native
93
+ * listing is the fresher source; pi.dev lags (measured 2026-09-22).
94
+ */
95
+ providerNativeFetch: z<boolean, boolean, "volatile-defined">;
96
+ /** Notify on changes (logger + /model-sync report). */
97
+ syncNotify: z<boolean, boolean, "volatile-defined">;
98
+ /**
99
+ * Force all models with a non-empty thinkingFormat to have max reasoning
100
+ * effort. Skips S2 gate's SRE check, ensures reasoningEfforts contains
101
+ * max, and forces compat.supportsReasoningEffort=true (S5 gate, openai-
102
+ * completions only). 400 risk is on the user.
103
+ */
104
+ forceMaxReasoningEffort: z<boolean, boolean, "volatile-defined">;
105
+ /**
106
+ * keepBuiltinOnly may re-emit builtin ids the official default model list
107
+ * dropped (dsh 0.1.7 removed deepseek-v4-flash / deepseek-v4-flash-vision-
108
+ * exp). Those stay in the snapshot for historical user configurations but
109
+ * are excluded from the synced list unless this flag opts them back in —
110
+ * a re-emitted retired id is a model the 0.1.7 host no longer resolves.
111
+ */
112
+ keepDeprecatedBuiltin: z<boolean, boolean, "volatile-defined">;
113
+ }>>, "plain">;
114
+ /**
115
+ * A stable configuration reference — the protocol the 0.1.7 host hands the
116
+ * plugin for every volatile `Config` field (cosmokit's `Volatile<T>`, declared
117
+ * locally as a structural type so this module stays dependency-free). `get()`
118
+ * returns the current immutable snapshot; the host swaps the value in place on
119
+ * volatile-only edits, so reading per round is always fresh.
120
+ */
121
+ interface VolatileRef<T> {
122
+ get(): T;
123
+ }
124
+ /** Typed view of the resolved `Config` value as delivered to apply(). */
125
+ interface ModelSyncConfigValue {
126
+ writeMode: VolatileRef<'settings' | 'overlay'>;
127
+ intervalMinutes: VolatileRef<number>;
128
+ startupDelaySeconds: VolatileRef<number>;
129
+ refreshTimeoutMs: VolatileRef<number>;
130
+ managedRoutes: VolatileRef<readonly string[]>;
131
+ keepBuiltinOnly: VolatileRef<boolean>;
132
+ dropUnserviceable: VolatileRef<boolean>;
133
+ syncNotify: VolatileRef<boolean>;
134
+ forceMaxReasoningEffort: VolatileRef<boolean>;
135
+ providerNativeFetch: VolatileRef<boolean>;
136
+ keepDeprecatedBuiltin: VolatileRef<boolean>;
137
+ }
5
138
  /** The `modelSync` service surfaced to UIs: run one refresh round and get the report. */
6
139
  export interface ModelSyncService {
7
140
  syncNow(): Promise<string>;
@@ -10,4 +143,19 @@ export interface ModelSyncService {
10
143
  * the plugin syncs when `managedRoutes` is empty. Not part of the public
11
144
  * runtime surface; subject to change without notice. */
12
145
  export declare const DEFAULT_ROUTES_LIST: string[];
13
- export declare function apply(ctx: Context): void;
146
+ export declare function apply(ctx: Context, config: ModelSyncConfigValue): Promise<void>;
147
+ /**
148
+ * Get entries from builtin catalog that are not in pi.dev (for keepBuiltinOnly).
149
+ * Returns minimal RemoteCatalogEntry-shaped objects — translateEntries only
150
+ * reads entry.id from these, emitting {id} profiles (I-3).
151
+ *
152
+ * Deprecated snapshot entries (the official default model list dropped them —
153
+ * dsh 0.1.7 removed deepseek-v4-flash / deepseek-v4-flash-vision-exp) are
154
+ * excluded unless `includeDeprecated` opts them back in: a re-emitted retired
155
+ * id is a model the 0.1.7 host no longer resolves. The data itself stays in
156
+ * the snapshot for historical user configurations.
157
+ *
158
+ * Exported for the test suite; not part of the public runtime surface.
159
+ */
160
+ export declare function getBuiltinOnlyEntries(route: string, piDevEntries: RemoteCatalogEntry[], builtinData: BuiltinModelData[], includeDeprecated?: boolean): RemoteCatalogEntry[];
161
+ export {};