dsh-thinking-levels 0.4.1 → 0.7.0-beta.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/CHANGELOG.ja.md +117 -0
- package/CHANGELOG.ko.md +117 -0
- package/CHANGELOG.md +126 -0
- package/INSTALL.ja.md +163 -0
- package/INSTALL.ko.md +163 -0
- package/INSTALL.md +163 -0
- package/INSTALL.zh.md +163 -0
- package/LICENSE +21 -0
- package/README.ja.md +168 -0
- package/README.ko.md +168 -0
- package/README.md +222 -108
- package/README.zh.md +174 -108
- package/lib/client.js +1801 -94
- package/lib/client.js.map +1 -1
- package/lib/context-window.d.ts +41 -0
- package/lib/context-window.js +54 -0
- package/lib/index.d.ts +41 -3
- package/lib/index.js +227 -26
- package/lib/takeover-sync.d.ts +123 -0
- package/lib/takeover-sync.js +237 -0
- package/lib/thinking-level.d.ts +106 -16
- package/lib/thinking-level.js +126 -13
- package/package.json +88 -79
package/README.md
CHANGED
|
@@ -1,108 +1,222 @@
|
|
|
1
|
-
# dsh-thinking-levels
|
|
2
|
-
|
|
3
|
-
**Per-round thinking-level (`reasoning_effort`) control for [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness): pick `Auto` (a mask) in the session model selector and the plugin schedules `low` / `high` / `max` from the recent tool-call history before submitting the API effort — or fix a wire level (`off` / `low` / `high` / `max`) manually. Cheap tool rounds stay cheap; heavy work never starves.**
|
|
4
|
-
|
|
5
|
-
[
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
1
|
+
# dsh-thinking-levels
|
|
2
|
+
|
|
3
|
+
**Per-round thinking-level (`reasoning_effort`) control for [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness): pick `Auto` (a mask) in the session model selector and the plugin schedules `low` / `high` / `max` from the recent tool-call history before submitting the API effort — or fix a wire level (`off` / `on` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max`) manually. Cheap tool rounds stay cheap; heavy work never starves.**
|
|
4
|
+
|
|
5
|
+
- [English README](./README.md)
|
|
6
|
+
- [中文 README](./README.zh.md)
|
|
7
|
+
- [日本語 README](./README.ja.md)
|
|
8
|
+
- [한국어 README](./README.ko.md)
|
|
9
|
+
- [Installation guide](./INSTALL.md)
|
|
10
|
+
- [中文安装指南](./INSTALL.zh.md)
|
|
11
|
+
- [日本語インストールガイド](./INSTALL.ja.md)
|
|
12
|
+
- [한국어 설치 안내](./INSTALL.ko.md)
|
|
13
|
+
- [Changelog](./CHANGELOG.md)
|
|
14
|
+
- [日本語 changelog](./CHANGELOG.ja.md)
|
|
15
|
+
- [한국어 changelog](./CHANGELOG.ko.md)
|
|
16
|
+
|
|
17
|
+
> **Compatibility note:** Version `0.6.0` includes Japanese (`ja`) and Korean (`ko`) dictionaries and selector entries, but the current official DSH releases expose only `zh` and `en` through `LocaleRuntime`. On stock DSH, selecting `ja` or `ko` fails with `locale "<id>" is not registered`. These languages will work after official DSH adds the locale IDs. Advanced users can use a DSH fork that updates `packages/client/locale/src/locale-settings.ts` (`LOCALE_IDS`) and `packages/client/locale/src/client/index.ts` (`LOCALES` labels), together with the corresponding core dictionaries and tests, then rebuild and run the forked DSH. Changing this plugin alone cannot extend DSH's global locale list.
|
|
18
|
+
|
|
19
|
+
In a multi-step tool chain, the model re-thinks before **every** tool call — and that thinking dominates the wall-clock time (a 50-step agent task can spend minutes reasoning between tools). `dsh-thinking-levels` plugs into the `agent/request` waterfall that dsh re-resolves for every step (registered with `prepend` so the session model-selection assembly cannot overwrite its decision) and injects a thinking level into the next model request.
|
|
20
|
+
|
|
21
|
+
## Preview
|
|
22
|
+
|
|
23
|
+
Screenshots of the live UI (dsh web):
|
|
24
|
+
|
|
25
|
+
<figure>
|
|
26
|
+
<img width="460" alt="Model selector Auto dropdown injected by the plugin: levels Off / Low / High / Max / Auto, High currently selected, Auto highlighted — Auto is a mask, the plugin schedules low/high/max per step from the tool history." src="assets/官方模型的自动级别调整.png" />
|
|
27
|
+
<figcaption>Native model selector gains <strong>Auto</strong> — pick it and the plugin schedules low/high/max per step instead of a fixed wire level.</figcaption>
|
|
28
|
+
</figure>
|
|
29
|
+
|
|
30
|
+
<figure>
|
|
31
|
+
<img style="max-width:100%" alt="思考档位 settings card: default level (auto scheduling), enable / allow-downgrade / allow-upgrade toggles, llm-pi-ai custom-provider model-capability table with per-model short-circuit takeover, and apply-to-all presets (Off/High/Max official DeepSeek style, Off/Low/Medium/High generic)." src="assets/自动思考级别配置.png" />
|
|
32
|
+
<figcaption>Thinking-level settings card: the auto scheduler plus its boundaries, and llm-pi-ai model-capability mapping (gear → gateway wire values).</figcaption>
|
|
33
|
+
</figure>
|
|
34
|
+
|
|
35
|
+
<figure>
|
|
36
|
+
<img style="max-width:100%" alt="Per-model capability editor for a custom openai-completions model (local-35b / Qwen3.6-35B-A3B): short-circuit takeover checked; thinking model and vision enabled, support think effort off; thinking format qwen; context-window limit presets 64K/128K/256K/400K/512K/1M with a custom input." src="assets/自定义模型的思考接管-短路-上下文窗口限制.png" />
|
|
37
|
+
<figcaption>Per-model capability card — pairs with <a href="https://github.com/drscrewdriver/dsh-llm-openai-completions">dsh-llm-openai-completions</a>: this card detects & writes capabilities, that adapter takes over the wire (compat.thinkingFormat).</figcaption>
|
|
38
|
+
</figure>
|
|
39
|
+
|
|
40
|
+
## Levels
|
|
41
|
+
|
|
42
|
+
| Level | Meaning | Where |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| `off` | thinking disabled (manual only — never auto-picked) | model selector / default level |
|
|
45
|
+
| `on` | thinking enabled (toggle-only models only): sends `enable_thinking`, never a think effort | model selector / default level |
|
|
46
|
+
| `minimal` | least effort (very light tasks) | model selector / default level |
|
|
47
|
+
| `low` | manual pick for simple chat tasks (cheap rounds stay cheap) | model selector / default level |
|
|
48
|
+
| `medium` | medium effort | model selector / default level |
|
|
49
|
+
| `high` | the official default effort | model selector / default level |
|
|
50
|
+
| `xhigh` | extra high effort | model selector / default level |
|
|
51
|
+
| `max` | heavy work | model selector / default level |
|
|
52
|
+
| `auto` | **mask**: schedule per step from the recent tool-call history, resolved to a wire level before submission | model selector (injected by the plugin) / default level |
|
|
53
|
+
|
|
54
|
+
Wire-level facts (verified against the official DeepSeek docs and dsh's `llm-deepseek` adapter): `low` maps 1:1 on deepseek-v4-flash / v4-pro, while `medium` / `xhigh` collapse onto `high`. The adapter accepts `off | low | high | max` and rejects anything else with `UNSUPPORTED_REASONING_EFFORT` — `auto` is the plugin's mask layer, never sent to the API, always resolved to a concrete wire level before injection. `on` is **not** an effort level: it is advertised only by toggle-only models (Qwen3.6-style), and it only flips `enable_thinking` true — no `reasoning_effort` is sent; an effort-capable model never advertises `on`, so a manual `on` pick on one is stripped.
|
|
55
|
+
|
|
56
|
+
## Custom wire mapping
|
|
57
|
+
|
|
58
|
+
For hand-declared `llm-pi-ai` models the settings card lets you map each level to the exact value your gateway expects (borrowed from dsh-thinking-effort): tick a level and enter its wire value, e.g. `high` → `ultra`. The mapping is stored as the model's `reasoningEfforts` table, so the Composer selection `High` sends `ultra` to the gateway. Leaving `off` empty means "do not send".
|
|
59
|
+
|
|
60
|
+
- Official preset: `Off / High / Max` (official DeepSeek style)
|
|
61
|
+
- Generic preset: `Off / Low / Medium / High`
|
|
62
|
+
|
|
63
|
+
## Context-window presets
|
|
64
|
+
|
|
65
|
+
The settings card's per-model editor now includes a **context window limit** control: preset buttons `64K / 128K / 256K / 400K / 512K / 1M`, a custom integer input, and a clear button. The value is written to the `llm-pi-ai` model entry `contextWindow` (integer `2000`–`1000000`).
|
|
66
|
+
|
|
67
|
+
Upstream, the harness consumes it through `resolveModelInfo(...).context.contextWindow` for compaction thresholds, context-overflow detection and context-pressure projections. Because `llm-pi-ai` re-reads the live config on every resolve and the openai-completions takeover does not block model discovery, a settings edit takes effect on the next request without a restart.
|
|
68
|
+
|
|
69
|
+
The plugin config also accepts `models['provider/model'].contextWindow` as a validated (integer `2000`–`1000000`) declaration at the composition/config surface.
|
|
70
|
+
|
|
71
|
+
## Model-aware guard (v0.5.0)
|
|
72
|
+
|
|
73
|
+
The plugin never sends a `reasoning_effort` to a model that does not advertise one. Custom
|
|
74
|
+
openai-completions routes (e.g. a local Qwen3.6 without `reasoningEfforts`) are classified
|
|
75
|
+
non-reasoning via `ctx.llm.resolveModelInfo`, and any effort — inherited or scheduled — is
|
|
76
|
+
**stripped** instead of sent, so dsh's per-request `UNSUPPORTED_REASONING_EFFORT` rejection
|
|
77
|
+
cannot fire. Unsupported fields are never passed to an API that cannot take them.
|
|
78
|
+
|
|
79
|
+
Version behavior:
|
|
80
|
+
|
|
81
|
+
| dsh version | `low` handling |
|
|
82
|
+
|---|---|
|
|
83
|
+
| rc.6 (old) | not native: the selector only shows it when a configurer-confirmed `models` override names it; the level is then advertised (selector + request validation) and passed through verbatim |
|
|
84
|
+
| rc.7+ (new) | native: the plugin neither rewrites nor re-injects it; a manual `low` pick passes through unchanged |
|
|
85
|
+
|
|
86
|
+
The auto scheduler may still pick `low` for supporting models — the capability guard above is
|
|
87
|
+
what keeps it away from models that cannot take it.
|
|
88
|
+
|
|
89
|
+
## Model-selector Auto
|
|
90
|
+
|
|
91
|
+
The session model selector (next to the model) now offers **Auto** after the wire levels (injected into the model-directory metadata by the plugin):
|
|
92
|
+
|
|
93
|
+
| Model-selector pick | Behavior |
|
|
94
|
+
|---|---|
|
|
95
|
+
| **Auto** | plugin schedules via tool history + the upgrade/downgrade toggles, resolves to `low` / `high` / `max` before submission |
|
|
96
|
+
| `off` / `on` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max` | **manual choice wins** — plugin does not intervene (`on` stays `on` on toggle-only models, never lifted to an effort; effort-capable models strip it) |
|
|
97
|
+
| unset | the plugin's default level applies (below) |
|
|
98
|
+
|
|
99
|
+
## Auto scheduler
|
|
100
|
+
|
|
101
|
+
The hub is `high` (the official default). `auto` schedules between `low` / `high` / `max`; it never picks `off`.
|
|
102
|
+
|
|
103
|
+
| Recent tool calls | Level |
|
|
104
|
+
|---|---|
|
|
105
|
+
| none (fresh prompt, pure chat) | `low` |
|
|
106
|
+
| ≥75% simple tools, small args, downgrades allowed | `low` |
|
|
107
|
+
| mixed / heavy tools | `high` |
|
|
108
|
+
| very heavy payloads, upgrades allowed | `max` |
|
|
109
|
+
|
|
110
|
+
The scheduling policy is the same source as [dsh-tool-turbo](https://github.com/drscrewdriver/dsh-tool-turbo) (same simple-tool whitelist / payload thresholds / 75% ratio rule).
|
|
111
|
+
|
|
112
|
+
## Install
|
|
113
|
+
|
|
114
|
+
See [INSTALL.md](./INSTALL.md) for the full official-CLI guide (profile discovery, upgrade, migration, verification, troubleshooting). Quick start:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# 1. install the plugin into a profile from npm (web shown; any profile works)
|
|
118
|
+
# (the web profile is a pnpm workspace root, so -w is required)
|
|
119
|
+
dsh plugin --profile web add dsh-thinking-levels -w
|
|
120
|
+
# GitHub alternative:
|
|
121
|
+
# dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
|
|
122
|
+
# local-path alternative (no network needed):
|
|
123
|
+
# dsh plugin --profile web add /absolute/path/to/dsh-thinking-levels
|
|
124
|
+
|
|
125
|
+
# 2. restart dsh web (a running instance does not hot-load new bundle layers)
|
|
126
|
+
dsh web
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
> Note: the dsh runtime uses pnpm 11, whose `minimumReleaseAge` supply-chain policy may block a
|
|
130
|
+
> freshly published version with `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION` — add the version to
|
|
131
|
+
> `minimumReleaseAgeExclude` in `~/.dsh/profiles/web/pnpm-workspace.yaml` to lift the cooling period.
|
|
132
|
+
|
|
133
|
+
Manual `link:` registration (alternative to `dsh plugin add`):
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# ~/.dsh/profiles/web/package.json dependencies:
|
|
137
|
+
# "dsh-thinking-levels": "link:<absolute path to dsh-thinking-levels>"
|
|
138
|
+
# ~/.dsh/profiles/web/cordis.patch.yml:
|
|
139
|
+
# - insert:
|
|
140
|
+
# - id: thinking-levels
|
|
141
|
+
# name: dsh-thinking-levels
|
|
142
|
+
cd ~/.dsh/profiles/web && pnpm install && dsh web
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Configuration
|
|
146
|
+
|
|
147
|
+
Two surfaces share one schema:
|
|
148
|
+
|
|
149
|
+
- **Assembly** — the plugin row's `config:` in the profile composition (e.g. `cordis.yml`):
|
|
150
|
+
```yaml
|
|
151
|
+
config:
|
|
152
|
+
level: auto # off | on | minimal | low | medium | high | xhigh | max | auto — the default level when the session picks nothing
|
|
153
|
+
allowDowngrade: true # let the scheduler drop below `high`
|
|
154
|
+
allowUpgrade: false # forbid the scheduler lifting to `max`
|
|
155
|
+
```
|
|
156
|
+
- **Runtime** — the dsh-settings namespace `thinking-levels` (`level`, `allowDowngrade`, `allowUpgrade`, `enabled`, `models`): changes apply to the next model request, no restart needed. A visual editor is available under Settings → Plugins → configurable plugins.
|
|
157
|
+
|
|
158
|
+
Per-model capability overrides (`models`, keyed `provider/model`) confirm what auto-detection
|
|
159
|
+
finds; the configurer has the final word:
|
|
160
|
+
|
|
161
|
+
```yaml
|
|
162
|
+
config:
|
|
163
|
+
level: auto
|
|
164
|
+
models:
|
|
165
|
+
llm-pi-ai/Qwen3.6-35B-A3B: # non-reasoning thinking model (thinking toggle + budget)
|
|
166
|
+
vision: false
|
|
167
|
+
thinking: true
|
|
168
|
+
efforts: false # never send reasoning_effort (stripped at request time)
|
|
169
|
+
llm-pi-ai/Qwen3.8-27B: # effort-capable model (rc.6-era adapter without low)
|
|
170
|
+
efforts: [low, high] # confirm low → advertised in the selector + passed through
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
> For Qwen thinking on/off + budget, configure the **llm-pi-ai** route instead:
|
|
174
|
+
> `compat.thinkingFormat: qwen` (→ wire `enable_thinking` + `thinking_budget` via
|
|
175
|
+
> `thinkingBudgets`), or `qwen-chat-template` (→ `chat_template_kwargs.enable_thinking`) for
|
|
176
|
+
> effort models like Qwen3.8-27B.
|
|
177
|
+
|
|
178
|
+
Defaults: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false, models: {} }`.
|
|
179
|
+
|
|
180
|
+
> Semantics: the model-selector pick outranks the plugin's default level. Pick `auto` (mask) → plugin schedules; pick a wire level → applied directly; pick nothing → the plugin's `level` default is used. `allowDowngrade` / `allowUpgrade` constrain `auto` scheduling only.
|
|
181
|
+
|
|
182
|
+
## Auto-takeover of dsh-llm-openai-completions (v0.5.2)
|
|
183
|
+
|
|
184
|
+
Custom gateways (vLLM / LM Studio / self-hosted OpenAI-compatible proxies) must be served by
|
|
185
|
+
[dsh-llm-openai-completions](https://github.com/drscrewdriver/dsh-llm-openai-completions) once
|
|
186
|
+
they declare thinking (`reasoningEfforts` table in `llm-pi-ai`) — otherwise pi-ai sends
|
|
187
|
+
`role: "developer"` (400) or drops `enable_thinking`. This plugin **maintains the takeover list
|
|
188
|
+
automatically**:
|
|
189
|
+
|
|
190
|
+
- Scans `llm-pi-ai.providers` for providers that are custom openai-completions gateways
|
|
191
|
+
(`api: openai-completions` or a non-official baseURL) **and** declare a `reasoningEfforts`
|
|
192
|
+
table on any model;
|
|
193
|
+
- Merges them into `llm-openai-completions.providers` with `enabled: true` (existing manual
|
|
194
|
+
entries are preserved, deduplicated);
|
|
195
|
+
- Triggers on plugin start, `llm/adapters-updated`, and settings changes to `llm-pi-ai` or the
|
|
196
|
+
takeover list — no manual config editing;
|
|
197
|
+
- Soft-coupled: skips the write silently when `llm-openai-completions` is not installed (its
|
|
198
|
+
namespace is unregistered).
|
|
199
|
+
|
|
200
|
+
The takeover mechanism as a whole — control-plane contract (who is taken over,
|
|
201
|
+
how a control-layer plugin decides and injects) and transport-plane wire
|
|
202
|
+
contract — is standardized in the
|
|
203
|
+
**[Takeover Control Spec](https://github.com/drscrewdriver/dsh-llm-openai-completions/blob/main/docs/takeover-spec.md)**;
|
|
204
|
+
this plugin is the reference control-layer implementation of it.
|
|
205
|
+
|
|
206
|
+
## Dependency note
|
|
207
|
+
|
|
208
|
+
The host half does **not** value-depend on `@deepseek-ai/dsh-settings` (settings registration goes through the cordis `settings` service provided by the dsh runtime) — no need to install official packages into the profile manually. `dependencies` is just `@deepseek-ai/schemastery` (installed automatically with the package).
|
|
209
|
+
|
|
210
|
+
## Development
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
npm run lint # eslint (typescript-eslint flat config)
|
|
214
|
+
npm run typecheck # tsc --noEmit
|
|
215
|
+
npm test # vitest — 46 tests
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Test coverage: level policy (manual pass-through incl. the extended levels, `on` clamping, auto scheduler, validation, simple-tool boundary), the model-capability guard (`reasoningEffortSupported`, `resolveEffortInjection` stripping/passthrough), session-event parsing (guards, window cap, malformed records), the config schema (defaults lockstep, out-of-band rejection, `models` overrides), and takeover-sync (identification, dedupe merge, soft-coupling).
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
MIT
|