dsh-model-capability-sync 0.0.0-stage → 0.2.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,55 @@
1
+ # Changelog
2
+
3
+ Notable changes, newest first. The plugin follows semantic versioning: the
4
+ settings surface and the config it writes are the public contract.
5
+
6
+ ## 0.2.0
7
+
8
+ Everything below landed after 0.1.0 was published, so 0.1.0 users see the
9
+ capability fill only — no renaming, no reordering, and the older matcher.
10
+
11
+ ### Added
12
+
13
+ - **Name redirect.** Every model gets `【vendor】 name`, taking the vendor from
14
+ the id prefix and falling back to `【other】` when there is none. Runs over all
15
+ models at once, keeps the id untouched, and is idempotent.
16
+ - **Ordering.** Two modes, both vendor-first then by name: by id prefix, or by
17
+ the `【vendor】` group. Written together with the config so the order is a
18
+ choice, not an artifact of load order.
19
+ - **Editable capability values.** Context, output and image can be typed
20
+ directly in the table, including for models the catalog never listed — those
21
+ now get a row instead of sitting in a read-only list. A typed value is marked
22
+ blue, overlays the catalog value, and is applied even with overwrite off.
23
+ - **Matching rules**, in the order they run:
24
+ - version separators folded both ways (`.` / `-` / `_`), so
25
+ `sensenova-6-8-flash-lite` reaches `sensenova-6.8-flash-lite`
26
+ - variant markers stripped (27 suffix words, `:route` tags, build numbers)
27
+ - a reseller's namespace peeled off (`sn-glm-5-3` → `glm-5-3`), accepted only
28
+ when what remains matches exactly
29
+ - a label's word gaps read as dashes (`Qwen3.8 Flash` → `qwen3.8-flash`)
30
+ - display names, then aliases, as the last resorts
31
+
32
+ ### Fixed
33
+
34
+ - **Renaming then reordering lost the new names.** The held descriptor kept the
35
+ pre-write models, and anything that rebuilt the list from it put the old names
36
+ back. A write now updates both, and writers read a synchronous mirror of the
37
+ list so two clicks in a row cannot race.
38
+ - **Casing could hand a model to a reseller.** A verbatim id match returned only
39
+ that casing's entries, so `scnet-token-plan` (which capitalises like the label)
40
+ beat `alibaba` even though alibaba is first-party and had more facts.
41
+ - **A column header rendered as `colName`.** The dictionary lacked the key and
42
+ the lookup fell back to the key itself. A test now fails when the UI asks for
43
+ a key either dictionary lacks.
44
+ - Table fits the panel instead of scrolling sideways: fixed layout with
45
+ proportional columns, wrapping ids and names.
46
+
47
+ ### Tests
48
+
49
+ 61 unit tests (`rename` 11, `match` 29, `sort` 6, `write-merge` 6, `locale` 3,
50
+ `fields` 6) plus 25 packaging checks, all offline.
51
+
52
+ ## 0.1.0
53
+
54
+ First release: query models.dev for context window, output cap, image support
55
+ and reasoning efforts, and write the selected rows into a provider's model list.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-model-capability-sync contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,238 @@
1
- # Temporary Holding Version
1
+ # dsh-model-capability-sync
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 给已经配好的 DeepSeek Harness LLM 供应商**补全模型能力参数**,并顺手把模型列表的
4
+ **名称和顺序**整理清楚的插件。
5
+
6
+ 它做三件事,都在同一个设置页里:
7
+
8
+ 1. **补全能力**:拿你已配置的模型 id 去 [models.dev](https://models.dev) 查事实,把
9
+ `上下文窗口 / 输出上限 / 是否支持图片 / 推理档位` 写回官方适配器的配置。
10
+ 2. **重定向名称**:给每个模型的显示名称加上 `【供应商】` 前缀,同名模型一眼分得清。
11
+ 3. **重排顺序**:按「供应商分组」或「名称字母序」重排模型列表,随时可重排一次。
12
+
13
+ **它不发任何推理请求,也不注册 LLM 路由**——调用仍然由官方插件负责。
14
+ 名称重定向只改 `name` 字段,**模型 ID 始终不变**,所以实际调用、路由、计费都不受影响。
15
+
16
+ ## 为什么需要它
17
+
18
+ 中转网关(NewAPI、Cline、Trae 之类)的 `/models` 只返回模型 id,不告诉你上下文多大、
19
+ 能不能吃图片。官方适配器把没声明的能力按"纯文本"处理,于是模型明明支持图片,
20
+ 界面上却提示不支持。
21
+
22
+ 另外,网关用路径前缀区分上游(`qoder/qfmodel`、`qoder-cn/qfmodel`),显示名称却沿用
23
+ 上游的 `Qwen3.8-Flash`,于是两个来源在模型选择器里长得一模一样。本插件一并解决这两件事。
24
+
25
+ ## 工作方式
26
+
27
+ ```
28
+ 设置页(浏览器) 宿主
29
+ ┌──────────────────────┐ RPC ┌──────────────────────────┐
30
+ │ 读 llm-pi-ai 的配置 │ ───────► │ 下载 models.dev(带缓存) │
31
+ │ 列出模型 / 勾选 │ ◄─────── │ 匹配 id → 能力字段 │
32
+ │ 预览将写入的字段 │ └──────────────────────────┘
33
+ │ 应用 → settings.mutate│
34
+ └──────────────────────┘
35
+ ```
36
+
37
+ ### 补全能力
38
+
39
+ - 写入走**官方 settings 服务**(`remote.settings.mutate`),落点是 profile 的
40
+ `cordis.patch.yml`,热生效,不用重启。
41
+ - 默认**只填空白字段**:你手填过的值不会被改写,除非勾选「覆盖已有值」。
42
+ 空白包括 `undefined`、`''`、`[]`、`{}` —— 配置 schema 会给没填的字段补默认值
43
+ (例如没声明 `input` 会读成 `[]`),这些默认值不算「你填过」。
44
+ - 表里有两列图片:**「图片」= 目录声明将写入的值,「当前生效」= 真正接管这条路由的
45
+ 适配器此刻上报的值**(也就是聊天请求看到的)。两列不一致,说明同一个 provider
46
+ 路由被另一个插件抢占,写这份配置不会生效。
47
+ - **每个单元格显示 `旧值 → 新值`**,顶部汇总"将修改 N 行 · M 个字段";没有变化的行
48
+ 不可勾选,「全选」只作用于可见且有变化的行。支持按模型 ID / 目录 ID 搜索,以及
49
+ 「只看有变化的」筛选。
50
+ - 「名称」列显示重定向后的名称(`【qoder】 Qwen3.8-Flash`),写配置前就能看到最终效果。
51
+ - 目录下载失败会重试 3 次,仍失败则回落到本机缓存
52
+ `~/.dsh/model-capability-sync/catalog.json`,页面标注「正在使用本机缓存」。
53
+ 手动预热:`node --experimental-strip-types scripts/warm-cache.mjs`。
54
+ 宿主进程连不上 models.dev 时页面依然可用。
55
+
56
+ ### 匹配规则
57
+
58
+ 由严到松,命中哪一条会在「匹配方式」列标出来:
59
+
60
+ | 顺序 | 规则 | 例子 |
61
+ | --- | --- | --- |
62
+ | 1 | 精确 | `gemini-3.8-flash` |
63
+ | 2 | 忽略大小写 | `GLM-5.3` → `glm-5.3` |
64
+ | 3 | 版本点折叠 | `claude-sonnet-4.5` → `claude-sonnet-4-5` |
65
+ | 4 | 剥变体标记 | `gemini-3.8-flash-tiered` → `gemini-3.8-flash` |
66
+ | 5 | 前缀匹配 | `nemotron-3.5-lightning` → `nemotron-3.5-lightning-30b-a3b` |
67
+ | 6 | 逐段剥供应商前缀 | `cline/dots-studio/dots-3-note-preview:free` → `dots-studio/dots-3-note-preview` |
68
+ | 7 | 去经销商命名空间 | `raccoon/sn-glm-5-3` → `glm-5-3` |
69
+ | 8 | 显示名称(空格转横线) | `Qwen3.8 Flash` → `qwen3.8-flash`;`Qwen3.8 Max` → `qwen3.8-max` |
70
+ | 9 | 别名(手工兜底) | 你自己配的 id 映射 |
71
+
72
+ **变体标记**包括销售点后缀与路由标签,会循环剥(网关常叠加多个):
73
+
74
+ - 后缀(27 个):`-high` `-low` `-medium` `-minimal` `-max` `-xhigh` `-thinking`
75
+ `-preview` `-latest` `-chat` `-tiered` `-disabled` `-trial` `-official` `-free`
76
+ `-stable` `-experimental` `-reasoning` `-it` `-instruct` `-base` `-pro` `-flash`
77
+ `-mini` `-nano` `-small` `-large`
78
+ - 路由标签:`:free` `:beta` `:nitro` 等 `:xxx`
79
+ - 构建号:尾部纯数字,如 `kimi-k3-1` → `kimi-k3`
80
+
81
+ **版本分隔符双向折叠**:`.`、`-`、`_` 在数字之间视为同一写法。目录里 `sensenova-6.8-flash-lite`
82
+ 是点号,而经销商给的 `sn-sensenova-6-8-flash-lite` 是横线,不折叠就永远对不上。
83
+
84
+ **空格转横线**:显示名称是给人看的,词与词之间用空格
85
+ (`Qwen3.8 Flash`),目录里的 id 用分隔符(`qwen3.8-flash`)。两者没有任何共同形态,
86
+ 大小写、版本点、变体标记都跨不过这个空格。规则只改写**候选**(把空格当横线),
87
+ 且仍要求精确命中,所以 `Dots Studio: …` 这类带真实空格的名称不会被硬掰成别的模型。
88
+
89
+ **去经销商命名空间**:有些聚合商在自己的池子前面加 2–4 个字母的标签
90
+ (`raccoon/sn-glm-5-3` 的 `sn-`)。`sn` 不是目录里的供应商 id,只是经销商的缩写。
91
+ 规则只接受「剥掉标签后能**精确**命中目录」的情况,所以:
92
+
93
+ - `sn-glm-5-3` → `glm-5-3` ✅ 命中
94
+ - `raccoon-19b265` → 目录里没有 `19b265`,保持未匹配(**不会**瞎猜)
95
+ - `kimi-k3` 本身精确命中,不会被误当成 `kimi-` + `k3`
96
+
97
+ 这些都不改变模型本身,所以也不该决定能力事实能不能查到。
98
+
99
+ **优先选第一方厂商**的目录条目(`openai`/`anthropic`/`google`/`deepseek`/`nvidia`…),
100
+ 避免被聚合站的错误数字带偏;同分时取事实最全的条目。
101
+
102
+ **别名放在最后**:别名是手工兜底,若放在名称匹配之前,被别名处理过的名称会被所有
103
+ 同名行继承,等于失效。
104
+
105
+ ### 名称重定向
106
+
107
+ **自动应用到所有模型**,点一次「重定向」按钮即可,不需要逐行勾选。
108
+
109
+ 规则是机械的:**取模型 ID 第一个 `/` 之前的前缀,清洗名称里所有该前缀的其他形态,
110
+ 然后在名称最前面放一个全角 `【前缀】`**。没有前缀的 ID 归入 `【other】`。
111
+
112
+ | 模型 ID | 原名称 | 新名称 |
113
+ | --- | --- | --- |
114
+ | `qoder/qfmodel` | `Qwen3.8-Flash` | `【qoder】 Qwen3.8-Flash` |
115
+ | `qoder-cn/qfmodel` | `Qwen3.8-Flash` | `【qoder-cn】 Qwen3.8-Flash` |
116
+ | `beichen/gpt-6-astra` | `beichen/gpt-6-astra` | `【beichen】 gpt-6-astra` |
117
+ | `standalone` | `Bare` | `【other】 Bare` |
118
+
119
+ - **前缀在前**:列表按供应商分组时,来源一眼可见,不用看到名字末尾才发现。
120
+ - **幂等**:先剥再贴。开头的 `【qoder】`、开头的 `qoder/`、旧的末尾 `【qoder】`
121
+ 和半角 ` (qoder)` 都会被清掉,重复应用不会叠成 `【qoder】【qoder】`。
122
+ - **无前缀归 `【other】`**:不会被跳过,也不会散落各处。
123
+ - **名称留空时**用 ID 去掉前缀后的部分兜底:`qoder/unnamed` → `【qoder】 unnamed`。
124
+ - 用全角括号是因为上游自己的名字里已经塞满半角括号(`Qwen3.8-Flash (0305)`),
125
+ 再来一对半角就分不清哪段是来源、哪段是原名。
126
+ - 只写 `name` 字段:上下文窗口、图片能力、推理档位一概不碰;写入同样走
127
+ `remote.settings.mutate`,同样处理 `settings/conflict`(重载后再确认)。
128
+
129
+ ### 排序与重排
130
+
131
+ 顶部「排序」下拉二选一,点「重排」按钮按当前选择把列表写回配置:
132
+
133
+ | 选项 | 行为 |
134
+ | --- | --- |
135
+ | `按模型前缀排序(分组)` | 先按 ID 前缀分组,组内按名称 —— 「谁提供什么」的视角 |
136
+ | `按重定向后【来源】名称排序` | 按 `【供应商】` 分组,组内按名称字母序 |
137
+
138
+ - 两种都是**供应商优先**:同来源的模型聚在一起,组内再按名称排。
139
+ - 比较忽略大小写(`Workbuddy` 与 `workbuddy` 不会拆成两组),末尾用原始 ID 兜底,
140
+ 所以每次重排结果完全一致。
141
+ - 未重定向的行按规则**预演**排序键,因此重定向与否排序结果相同。
142
+ - 补全能力、重定向、重排三个动作写入时都按当前排序落盘,列表顺序与配置顺序始终一致。
143
+
144
+ ## 安装
145
+
146
+ 从 npm 安装(发布后):
147
+
148
+ ```sh
149
+ dsh plugin --profile web add dsh-model-capability-sync
150
+ ```
151
+
152
+ 从本地 tarball 安装:
153
+
154
+ ```sh
155
+ dsh plugin --profile web add /path/to/dsh-model-capability-sync-0.2.0.tgz
156
+ ```
157
+
158
+ 从本地源码安装(开发用):
159
+
160
+ ```sh
161
+ dsh plugin --profile web add /path/to/dsh-model-capability-sync
162
+ ```
163
+
164
+ **DSH 桌面版不要用命令行装**:桌面应用独占自己的 profile,CLI 改动不生效,
165
+ 请在应用内 **设置 → 插件** 里安装。
166
+
167
+ 装完重启 dsh,设置页会出现「模型能力同步」。
168
+
169
+ 要求:`dsh` 运行时 `^0.2.1-rc.2`(写在 `package.json` 的 `engines.dsh`,宿主会据此做兼容检查)。
170
+
171
+ ## 目录结构
172
+
173
+ | 路径 | 用途 |
174
+ | --- | --- |
175
+ | `src/index.ts` | 宿主半:RPC 通道 `preview`(目录能力)+ `live`(当前生效) |
176
+ | `src/catalog.ts` | models.dev 下载 / 缓存(内存 + 本机文件)/ 索引 |
177
+ | `src/match.ts` | 网关 id → 目录条目的匹配规则(八级阶梯) |
178
+ | `src/mapping.ts` | 目录条目 → 能力字段(纯函数) |
179
+ | `src/sort.ts` | 模型排序(前缀分组 / 重定向后名称) |
180
+ | `src/client/apply.ts` | 注册设置节、样式、RPC 与 settings 注入 |
181
+ | `src/client/SyncSection.tsx` | 设置页主体(能力表 + 重定向 + 重排) |
182
+ | `src/client/rename.ts` | 名称重定向规则(纯函数) |
183
+ | `src/client/shared.ts` | 配置读取工具与共享类型 |
184
+ | `src/client/locale.ts` | 界面文案(zh / en 逐键镜像) |
185
+ | `scripts/` | 构建、冒烟、发布检查、规则单元测试 |
186
+ | `docs/` | 需求、技术选型、设计规范、开发计划、发版 |
187
+
188
+ ## 开发
189
+
190
+ ```sh
191
+ npm install
192
+ npm run typecheck # 两端类型检查
193
+ npm run build # lib/index.js + lib/client.js
194
+ npm run verify:package # 发布卫生检查(26 项)
195
+
196
+ # 单元测试(离线,不需要 profile 或网络)
197
+ npm run test:rename # 名称重定向规则(11 条)
198
+ npm run test:match # id 匹配规则(29 条)
199
+ npm run test:sort # 两种排序(6 条)
200
+ npm run test:write-merge # 写入后状态合并(6 条)
201
+ npm run test:locale # 文案键完整性(3 条)
202
+
203
+ # 真实目录冒烟(需联网)
204
+ node --experimental-strip-types scripts/smoke.mjs
205
+ ```
206
+
207
+ ## 里程碑
208
+
209
+ | 阶段 | 内容 | 状态 |
210
+ | --- | --- | --- |
211
+ | P0 | 骨架、构建、文档 | ✅ |
212
+ | P1 | 目录拉取、匹配、映射、只读预览 | ✅ |
213
+ | P2 | 预览表 + 写入设置 | ✅ |
214
+ | P2.5 | 差异预览、筛选、排序、写入位置文案 | ✅ |
215
+ | P2.6 | 名称重定向(自动加 `【供应商】`,含 `【other】` 兜底) | ✅ |
216
+ | P2.7 | 排序二选一 + 一键重排 | ✅ |
217
+ | P2.8 | 匹配规则扩展(变体标记 / 前缀 / 构建号 / 多级命名空间) | ✅ |
218
+ | P3 | 别名表、手动覆盖 | ⬜ |
219
+ | P4 | 迁移旧适配器的模型清单并停用它 | ⬜ |
220
+ | P5 | 打包发布(npm + 社区目录) | 🔄 仓库已就绪,待发布 |
221
+
222
+ 发版步骤见仓库内的 `docs/publishing.md`。
223
+
224
+ ## 已知边界
225
+
226
+ - models.dev 描述的是**官方模型**能力;中转网关背后实际路由到哪个上游,目录说了不算。
227
+ 本插件给的是"最可能的答案",最终仍建议用一张真图验证。
228
+ - **前缀匹配是唯一可能误判的规则**:`north-mini-code` 同时能匹配
229
+ `north-mini-code-1-0` 和 `north-mini-code-free`。按「第一方优先 + 事实最全」取舍,
230
+ 界面上标为「前缀匹配」,可信度自行判断。
231
+ - 纯代号且没有显示名称的模型无法推断,例如 `1fmodel`;目录里确实没有的模型
232
+ (新模型、厂商自造别名)保持原样,可在 P3 的别名表里手工指定。
233
+ - 名称重定向只改显示名称,**不改模型 ID**。若某个客户端只认 ID 而忽略名称,
234
+ 重定向对它不可见。
235
+
236
+ ## 许可证
237
+
238
+ [MIT](LICENSE)
@@ -0,0 +1,8 @@
1
+ # dsh-model-capability-sync bundle patch
2
+ #
3
+ # 在 profile 组合中插入插件行。本插件不注册任何 LLM 路由,只注册一个自有 RPC
4
+ # 通道 + 一个设置页,因此不会与任何适配器争抢 provider 路由。
5
+
6
+ - insert:
7
+ - id: model-capability-sync
8
+ name: dsh-model-capability-sync