dsh-pin-default-model 1.2.0 → 1.3.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  English | [简体中文](./README.zh.md)
4
4
 
5
- Pins the DeepSeek Harness default model so switching models inside a session never changes what the next new session starts with. Change the pin any time from **Settings → Default model pin**.
5
+ Pins the DeepSeek Harness default model **and reasoning effort**, so switching either inside a session never changes what the next new session starts with. Change the pin any time from **Settings → Default model pin**.
6
6
 
7
7
  ![Default model pin settings section](./docs/preview.svg)
8
8
 
@@ -19,15 +19,25 @@ It replaces `saveSelection` on the live `agentDefaultModel` service with one tha
19
19
  | Action | Result |
20
20
  | --- | --- |
21
21
  | Switch models inside a session | ✅ works, that session uses the new model |
22
- | New session afterwards | ✅ still starts on the pinned model |
22
+ | Switch reasoning effort inside a session | ✅ works, that session uses the new effort |
23
+ | New session afterwards | ✅ still starts on the pinned model and effort |
23
24
  | Change the pin in Settings | ✅ applies to all later new sessions |
24
25
  | Unload the plugin | ✅ original behaviour returns |
25
26
 
26
- The browser page talks to two local host routes with plain fetch; it has no dependency on DSH's settings-client services, so it loads regardless of plugin activation order.
27
+ The pin is a routing triple: provider, model, and an optional reasoning effort. The browser page talks to two local host routes with plain fetch; it has no dependency on DSH's settings-client services, so it loads regardless of plugin activation order.
28
+
29
+ ## Reasoning effort
30
+
31
+ The effort dropdown lists the levels the **selected model** actually offers, taken from the live model catalog.
32
+
33
+ - **Follow the model default** leaves the effort unlocked. A session may then use any effort the model offers, and the pin keeps holding only the route.
34
+ - **Locking an effort** (for example `high`) pins the route *and* the effort. A session that changes only its effort no longer rewrites the default.
35
+
36
+ > **A locked effort must be one the model supports.** DSH rejects a call whose effort the model does not offer (`UNSUPPORTED_REASONING_EFFORT`), and some models offer no reasoning effort at all. The plugin refuses to store such a pin and the settings page shows a warning instead of failing later at session creation.
27
37
 
28
38
  ## Configuration
29
39
 
30
- Open **Settings → Default model pin** and pick a model from the grouped dropdown, then press **Save**. The pin is written to the profile and survives a restart.
40
+ Open **Settings → Default model pin** and pick a model from the grouped dropdown, then pick a reasoning effort and press **Save**. The pin is written to the profile and survives a restart.
31
41
 
32
42
  It can also be set by hand in `cordis.patch.yml`:
33
43
 
@@ -38,17 +48,18 @@ It can also be set by hand in `cordis.patch.yml`:
38
48
  config:
39
49
  provider: magpie
40
50
  model: group/x-call
51
+ reasoningEffort: high
41
52
  ```
42
53
 
43
54
  | Field | Required | Meaning |
44
55
  | --- | --- | --- |
45
56
  | `provider` | yes | Provider route to hold, e.g. `magpie`, `workbuddy-ai` |
46
57
  | `model` | yes | Model id on that route, e.g. `group/x-call` |
47
- | `reasoningEffort` | no | Reasoning effort to hold with it |
58
+ | `reasoningEffort` | no | Reasoning effort to hold. Omit it to let the provider default apply |
48
59
 
49
60
  With no pin configured, the bundled default `magpie / group/x-call` applies.
50
61
 
51
- A change affects sessions created **after** it is saved. An open conversation keeps the model recorded in its own request log.
62
+ A change affects sessions created **after** it is saved. An open conversation keeps the model and effort recorded in its own request log.
52
63
 
53
64
  ## Safety and caveats
54
65
 
@@ -81,6 +92,7 @@ node --check lib/index.js
81
92
  node --check client/client.js
82
93
  node test/behaviour.mjs
83
94
  node test/client.mjs
95
+ node test/render.mjs
84
96
  ```
85
97
 
86
98
  ## License
package/README.zh.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](./README.md) | 简体中文
4
4
 
5
- 锁定 DeepSeek Harness 的默认模型,让「会话内切换模型」不再影响下一个新会话。随时可在 **设置 → 默认模型锁定** 修改锁定值。
5
+ 锁定 DeepSeek Harness 的默认模型**与推理等级**,让「会话内切换模型或推理等级」不再影响下一个新会话。随时可在 **设置 → 默认模型锁定** 修改锁定值。
6
6
 
7
7
  ![默认模型锁定设置分区](./docs/preview.zh.svg)
8
8
 
@@ -19,15 +19,25 @@ DSH 会把「在会话里切换模型」记录成新的进程级默认值。`ses
19
19
  | 操作 | 结果 |
20
20
  | --- | --- |
21
21
  | 会话内切换模型 | ✅ 正常生效,该会话用新模型 |
22
- | 之后新建的会话 | ✅ 仍然使用锁定的模型 |
22
+ | 会话内切换推理等级 | ✅ 正常生效,该会话用新档位 |
23
+ | 之后新建的会话 | ✅ 仍然使用锁定的模型与推理等级 |
23
24
  | 在设置里改锁定值 | ✅ 之后新建的会话全部用新值 |
24
25
  | 卸载插件 | ✅ 恢复 DSH 原有行为 |
25
26
 
26
- 浏览器页面通过两条本地路由用纯 fetch 读写,不依赖 DSH 的设置客户端服务,因此不受插件加载顺序影响。
27
+ 锁定值是一个三元组:provider、model,以及可选的推理等级。浏览器页面通过两条本地路由用纯 fetch 读写,不依赖 DSH 的设置客户端服务,因此不受插件加载顺序影响。
28
+
29
+ ## 推理等级
30
+
31
+ 推理等级下拉框列出的是**当前所选模型实际提供**的档位,来源是实时模型目录。
32
+
33
+ - **跟随模型默认**表示不锁定推理等级。会话可以自由使用该模型支持的任何档位,锁定值只约束模型路由。
34
+ - **锁定某个档位**(例如 `high`)则同时锁定路由和档位,会话内只切档位也不再改写默认值。
35
+
36
+ > **锁定的档位必须是该模型支持的。** DSH 对模型不支持的档位会直接报错(`UNSUPPORTED_REASONING_EFFORT`),而且部分模型完全不提供推理等级。插件会拒绝保存这类锁定值,设置页也会明确警告,而不是等到新建会话时才失败。
27
37
 
28
38
  ## 配置
29
39
 
30
- 打开 **设置 → 默认模型锁定**,在下拉框里选模型,点 **保存**。锁定值写入 profile,重启后依然有效。
40
+ 打开 **设置 → 默认模型锁定**,在下拉框里选模型,再选推理等级,点 **保存**。锁定值写入 profile,重启后依然有效。
31
41
 
32
42
  也可以手改 `cordis.patch.yml`:
33
43
 
@@ -38,17 +48,18 @@ DSH 会把「在会话里切换模型」记录成新的进程级默认值。`ses
38
48
  config:
39
49
  provider: magpie
40
50
  model: group/x-call
51
+ reasoningEffort: high
41
52
  ```
42
53
 
43
54
  | 字段 | 必填 | 含义 |
44
55
  | --- | --- | --- |
45
56
  | `provider` | 是 | 要锁定的提供方路由,如 `magpie`、`workbuddy-ai` |
46
57
  | `model` | 是 | 该路由下的模型 id,如 `group/x-call` |
47
- | `reasoningEffort` | 否 | 一并锁定的推理档位 |
58
+ | `reasoningEffort` | 否 | 要锁定的推理等级。省略则跟随提供方默认 |
48
59
 
49
60
  没有配置锁定值时,使用内置的 `magpie / group/x-call`。
50
61
 
51
- 改动只对**保存之后**新建的会话生效;已经打开的对话继续使用它请求日志里记录的模型。
62
+ 改动只对**保存之后**新建的会话生效;已经打开的对话继续使用它请求日志里记录的模型与推理等级。
52
63
 
53
64
  ## 安全性与注意
54
65
 
@@ -81,6 +92,7 @@ node --check lib/index.js
81
92
  node --check client/client.js
82
93
  node test/behaviour.mjs
83
94
  node test/client.mjs
95
+ node test/render.mjs
84
96
  ```
85
97
 
86
98
  ## 许可
package/client/client.js CHANGED
@@ -1,10 +1,13 @@
1
1
  /**
2
2
  * dsh-pin-default-model browser half: a Settings section for choosing which
3
- * model every new conversation starts on.
3
+ * model and reasoning effort every new conversation starts on.
4
4
  *
5
5
  * All state lives on the host; this page only talks to two local routes with
6
6
  * plain fetch. It deliberately avoids the settings-client services so it can
7
7
  * load regardless of plugin activation order.
8
+ *
9
+ * The catalog exposes `reasoning.efforts` as an array of `{ id, name }`, so
10
+ * the effort dropdown lists effort ids and shows their display names.
8
11
  */
9
12
  window.__ModuleLoader__.load({
10
13
  id: "dsh-pin-default-model",
@@ -21,7 +24,7 @@ window.__ModuleLoader__.load({
21
24
 
22
25
  const zh = {
23
26
  nav: "默认模型锁定",
24
- desc: "锁定新建会话使用的模型。在会话内切换模型仍然只对那个会话生效,不会改写这里的设置。",
27
+ desc: "锁定新建会话使用的模型与推理等级。在会话内切换模型或推理等级仍然只对那个会话生效,不会改写这里的设置。",
25
28
  current: "当前锁定",
26
29
  notSet: "未设置(使用插件默认值 magpie/group/x-call)",
27
30
  choose: "选择模型",
@@ -33,15 +36,21 @@ window.__ModuleLoader__.load({
33
36
  loading: "加载中…",
34
37
  noCatalog: "没有可用模型。",
35
38
  noCatalogHint: "请先在设置 → 模型里配置至少一个提供方。",
36
- effort: "推理档位",
39
+ effort: "推理等级",
37
40
  effortDefault: "跟随模型默认",
41
+ effortNone: "该模型不提供推理等级。",
42
+ effortSuggested: "建议锁定 high",
43
+ effortLockHigh: "锁定 high",
44
+ effortFollow: "改为跟随模型默认",
45
+ effortIncompatible: "当前模型不支持推理等级",
46
+ effortIncompatibleDetail: "该模型只支持:",
38
47
  reset: "刷新",
39
48
  unavailable: "该模型当前不在可用目录中(仍会按此值锁定)。",
40
49
  note: "锁定值写入 profile 配置。修改后对新建会话立即生效,已打开的会话保持不变。"
41
50
  };
42
51
  const en = {
43
52
  nav: "Default model pin",
44
- desc: "Hold the model that new conversations start on. Switching a model inside a session still applies to that session only and no longer rewrites this setting.",
53
+ desc: "Hold the model and reasoning effort that new conversations start on. Switching either inside a session still applies to that session only and no longer rewrites this setting.",
45
54
  current: "Currently pinned",
46
55
  notSet: "Not set — the bundled default magpie/group/x-call applies",
47
56
  choose: "Choose a model",
@@ -54,7 +63,13 @@ window.__ModuleLoader__.load({
54
63
  noCatalog: "No models available.",
55
64
  noCatalogHint: "Configure at least one provider in Settings → Models first.",
56
65
  effort: "Reasoning effort",
57
- effortDefault: "Model default",
66
+ effortDefault: "Follow the model default",
67
+ effortNone: "This model offers no reasoning effort.",
68
+ effortSuggested: "Suggested: lock high",
69
+ effortLockHigh: "Lock high",
70
+ effortFollow: "Follow the model default instead",
71
+ effortIncompatible: "The current model does not support this reasoning effort",
72
+ effortIncompatibleDetail: "Supported:",
58
73
  reset: "Refresh",
59
74
  unavailable: "This model is not in the current catalog (the pin still uses it).",
60
75
  note: "The pin is written to the profile. A change applies to new conversations immediately; open conversations stay as they are."
@@ -76,6 +91,36 @@ window.__ModuleLoader__.load({
76
91
  return `${selection.provider}/${selection.model}`;
77
92
  }
78
93
 
94
+ /**
95
+ * Find one model in a provider-grouped catalog.
96
+ * @param groups - provider groups from the model catalog.
97
+ * @param provider - provider id.
98
+ * @param model - model id.
99
+ * @returns the catalog entry, or undefined.
100
+ */
101
+ function findModel(groups, provider, model) {
102
+ const group = (groups ?? []).find((candidate) => candidate?.id === provider);
103
+ if (group === undefined) return undefined;
104
+ return (group.models ?? []).find((candidate) => candidate?.id === model);
105
+ }
106
+
107
+ /**
108
+ * List the reasoning efforts of one model route.
109
+ * The catalog exposes `efforts` as an array of `{ id, name }`.
110
+ * @param groups - provider groups from the model catalog.
111
+ * @param provider - provider id.
112
+ * @param model - model id.
113
+ * @returns an array of `{ id, name }` entries.
114
+ */
115
+ function effortsOf(groups, provider, model) {
116
+ const entry = findModel(groups, provider, model);
117
+ const efforts = entry?.reasoning?.efforts;
118
+ if (!Array.isArray(efforts)) return [];
119
+ return efforts
120
+ .filter((effort) => typeof effort?.id === 'string' && effort.id !== '')
121
+ .map((effort) => ({ id: effort.id, name: effort.name ?? effort.id }));
122
+ }
123
+
79
124
  function PinSection({ t }) {
80
125
  const [loading, setLoading] = react.useState(true);
81
126
  const [pinned, setPinned] = react.useState(null);
@@ -107,18 +152,46 @@ window.__ModuleLoader__.load({
107
152
  load();
108
153
  }, [load]);
109
154
 
110
- const effortNames = react.useMemo(() => {
111
- if (!draft) return [];
112
- const group = groups.find((g) => g.id === draft.provider);
113
- const model = group?.models?.find((m) => m.id === draft.model);
114
- const efforts = model?.reasoning?.efforts;
115
- if (!efforts) return [];
116
- return Object.keys(efforts).filter((k) => efforts[k] !== false);
117
- }, [groups, draft]);
155
+ const effective = draft ?? pinned ?? {};
156
+ const effectiveProvider = effective.provider;
157
+ const effectiveModel = effective.model;
118
158
 
119
- const fromCatalog = Boolean(
120
- groups.some((g) => g.id === pinned?.provider && g.models?.some((m) => m.id === pinned?.model)),
159
+ // Efforts belong to one exact model route, so they follow the selection.
160
+ const efforts = react.useMemo(
161
+ () => effortsOf(groups, effectiveProvider, effectiveModel),
162
+ [groups, effectiveProvider, effectiveModel],
121
163
  );
164
+ const effortIds = efforts.map((effort) => effort.id);
165
+ const supportsHigh = effortIds.includes("high");
166
+
167
+ // A locked effort the current model cannot serve is a hard DSH error at
168
+ // call time, so it is called out here instead of failing silently later.
169
+ const lockedEffort = effective.reasoningEffort;
170
+ const effortIncompatible = Boolean(
171
+ lockedEffort && effortIds.length > 0 && !effortIds.includes(lockedEffort),
172
+ );
173
+ const effortUnsupported = Boolean(lockedEffort && effortIds.length === 0);
174
+
175
+ const pickModel = (provider, model) => {
176
+ // Carry over a locked effort only when the new route supports it.
177
+ const nextEfforts = effortsOf(groups, provider, model).map((effort) => effort.id);
178
+ const carried = lockedEffort && nextEfforts.includes(lockedEffort) ? lockedEffort : undefined;
179
+ setDraft({
180
+ provider,
181
+ model,
182
+ ...(carried === undefined ? {} : { reasoningEffort: carried }),
183
+ });
184
+ setSaved(false);
185
+ };
186
+
187
+ const pickEffort = (effort) => {
188
+ setDraft({
189
+ provider: effectiveProvider,
190
+ model: effectiveModel,
191
+ ...(effort === "" ? {} : { reasoningEffort: effort }),
192
+ });
193
+ setSaved(false);
194
+ };
122
195
 
123
196
  const submit = react.useCallback(() => {
124
197
  if (!draft) return;
@@ -149,7 +222,9 @@ window.__ModuleLoader__.load({
149
222
  return react_jsx_runtime.jsx("div", { style: { padding: 12, opacity: 0.75 }, children: t("loading") });
150
223
  }
151
224
 
152
- const effective = draft ?? pinned ?? {};
225
+ const fromCatalog = Boolean(
226
+ groups.some((g) => g.id === pinned?.provider && g.models?.some((m) => m.id === pinned?.model)),
227
+ );
153
228
 
154
229
  return react_jsx_runtime.jsxs("div", {
155
230
  style: { display: "flex", flexDirection: "column", gap: 12, padding: "4px 0" },
@@ -185,7 +260,10 @@ window.__ModuleLoader__.load({
185
260
  pinned?.reasoningEffort ? react_jsx_runtime.jsx("span", {
186
261
  style: { fontSize: 12, opacity: 0.7 },
187
262
  children: `${t("effort")}: ${pinned.reasoningEffort}`
188
- }) : null
263
+ }) : react_jsx_runtime.jsx("span", {
264
+ style: { fontSize: 12, opacity: 0.7 },
265
+ children: `${t("effort")}: ${t("effortDefault")}`
266
+ })
189
267
  ]
190
268
  }),
191
269
 
@@ -199,16 +277,13 @@ window.__ModuleLoader__.load({
199
277
  style: { display: "flex", gap: 8, flexWrap: "wrap", alignItems: "center" },
200
278
  children: [
201
279
  react_jsx_runtime.jsxs("select", {
202
- value: effective.provider ? `${effective.provider}\u0000${effective.model}` : "",
280
+ value: effectiveProvider ? `${effectiveProvider}\u0000${effectiveModel}` : "",
203
281
  disabled: busy,
204
282
  onChange: (event) => {
205
283
  const [provider, model] = String(event.target.value).split("\u0000");
206
- if (provider && model) {
207
- setDraft({ provider, model });
208
- setSaved(false);
209
- }
284
+ if (provider && model) pickModel(provider, model);
210
285
  },
211
- style: { ...box, flex: "1 1 260px", minWidth: 200 },
286
+ style: { ...box, flex: "1 1 240px", minWidth: 190 },
212
287
  children: [
213
288
  react_jsx_runtime.jsx("option", { value: "", children: t("choose") }),
214
289
  groups.map((group) => react_jsx_runtime.jsx("optgroup", {
@@ -220,27 +295,70 @@ window.__ModuleLoader__.load({
220
295
  }, group.id))
221
296
  ]
222
297
  }),
223
- effortNames.length > 0 ? react_jsx_runtime.jsxs("select", {
224
- value: effective.reasoningEffort ?? "",
225
- disabled: busy,
226
- onChange: (event) => {
227
- const effort = String(event.target.value);
228
- setDraft({
229
- provider: effective.provider,
230
- model: effective.model,
231
- ...(effort ? { reasoningEffort: effort } : {})
232
- });
233
- setSaved(false);
234
- },
235
- style: { ...box, flex: "0 1 170px" },
298
+ react_jsx_runtime.jsxs("select", {
299
+ value: lockedEffort ?? "",
300
+ disabled: busy || effortIds.length === 0,
301
+ onChange: (event) => pickEffort(String(event.target.value)),
302
+ style: { ...box, flex: "0 1 180px" },
236
303
  children: [
237
304
  react_jsx_runtime.jsx("option", { value: "", children: t("effortDefault") }),
238
- effortNames.map((name) => react_jsx_runtime.jsx("option", { value: name, children: name }, name))
305
+ efforts.map((effort) => react_jsx_runtime.jsx("option", {
306
+ value: effort.id,
307
+ children: effort.name === effort.id ? effort.id : `${effort.name} · ${effort.id}`
308
+ }, effort.id))
239
309
  ]
240
- }) : null
310
+ })
241
311
  ]
242
312
  }),
243
313
 
314
+ effortIds.length === 0 && effectiveProvider ? react_jsx_runtime.jsx("div", {
315
+ style: { fontSize: 12, opacity: 0.7 },
316
+ children: t("effortNone")
317
+ }) : null,
318
+
319
+ effortIncompatible || effortUnsupported ? react_jsx_runtime.jsxs("div", {
320
+ style: {
321
+ display: "flex",
322
+ flexDirection: "column",
323
+ gap: 6,
324
+ padding: "8px 10px",
325
+ borderRadius: 6,
326
+ border: "1px solid rgba(230,162,60,.4)",
327
+ background: "rgba(230,162,60,.08)"
328
+ },
329
+ children: [
330
+ react_jsx_runtime.jsx("div", {
331
+ style: { fontSize: 12, color: "var(--dsh-warning, #e6a23c)" },
332
+ children: `${t("effortIncompatible")}:${lockedEffort}`
333
+ }),
334
+ effortIds.length > 0 ? react_jsx_runtime.jsx("div", {
335
+ style: { fontSize: 12, opacity: 0.8 },
336
+ children: `${t("effortIncompatibleDetail")} ${effortIds.join(", ")}`
337
+ }) : null,
338
+ react_jsx_runtime.jsx("button", {
339
+ type: "button",
340
+ disabled: busy,
341
+ onClick: () => pickEffort(""),
342
+ style: { ...box, cursor: "pointer", alignSelf: "flex-start", opacity: 0.9 },
343
+ children: t("effortFollow")
344
+ })
345
+ ]
346
+ }) : null,
347
+
348
+ !effortIncompatible && !effortUnsupported && !lockedEffort && supportsHigh ? react_jsx_runtime.jsxs("div", {
349
+ style: { display: "flex", gap: 8, alignItems: "center", flexWrap: "wrap" },
350
+ children: [
351
+ react_jsx_runtime.jsx("span", { style: { fontSize: 12, opacity: 0.72 }, children: t("effortSuggested") }),
352
+ react_jsx_runtime.jsx("button", {
353
+ type: "button",
354
+ disabled: busy,
355
+ onClick: () => pickEffort("high"),
356
+ style: { ...box, cursor: "pointer", opacity: 0.9 },
357
+ children: t("effortLockHigh")
358
+ })
359
+ ]
360
+ }) : null,
361
+
244
362
  !fromCatalog && pinned?.provider ? react_jsx_runtime.jsx("div", {
245
363
  style: { fontSize: 12, color: "var(--dsh-warning, #e6a23c)" },
246
364
  children: t("unavailable")
package/cordis.patch.yml CHANGED
@@ -1,7 +1,9 @@
1
- # dsh bundle patch: inserts this plugin into a profile's layer stack.
2
1
  - insert:
3
2
  - id: dsh-pin-default-model
4
3
  name: 'dsh-pin-default-model'
5
4
  config:
6
5
  provider: magpie
7
6
  model: group/x-call
7
+ # Optional. Omit it to let each model use its own default effort.
8
+ # When set, the model above must actually offer this effort level.
9
+ # reasoningEffort: high