dsh-thinking-levels 0.7.1-beta.2 → 0.7.1-beta.4

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
@@ -1,231 +1,249 @@
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
- > **v0.7.0-beta.1 (2026-09-06): the short-circuit route is retired.** This release no longer depends on `dsh-llm-openai-completions` — custom-gateway fixes ride the official `llm-pi-ai` compat surface (requires **dsh ≥ v0.1.0-rc.8**); keep the adapter plugin uninstalled. See the [CHANGELOG](./CHANGELOG.md).
7
-
8
- - [中文 README](./README.zh.md)
9
- - [日本語 README](./README.ja.md)
10
- - [한국어 README](./README.ko.md)
11
- - [Installation guide](./INSTALL.md)
12
- - [中文安装指南](./INSTALL.zh.md)
13
- - [日本語インストールガイド](./INSTALL.ja.md)
14
- - [한국어 설치 안내](./INSTALL.ko.md)
15
- - [Changelog](./CHANGELOG.md)
16
- - [日本語 changelog](./CHANGELOG.ja.md)
17
- - [한국어 changelog](./CHANGELOG.ko.md)
18
-
19
- > **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.
20
-
21
- 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.
22
-
23
- ## Preview
24
-
25
- Screenshots of the live UI (dsh web):
26
-
27
- <figure>
28
- <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" />
29
- <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>
30
- </figure>
31
-
32
- <figure>
33
- <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 the progressive per-model editor, and apply-to-all presets (Off/High/Max official DeepSeek style, Off/Low/Medium/High generic)." src="assets/自动思考级别配置.png" />
34
- <figcaption>Thinking-level settings card: the auto scheduler plus its boundaries, and llm-pi-ai model-capability mapping (gear → gateway wire values).</figcaption>
35
- </figure>
36
-
37
- <figure>
38
- <img style="max-width:100%" alt="Per-model capability editor for a custom openai-completions model (local-35b / Qwen3.6-35B-A3B): thinking model and vision enabled, support think effort off, thinking format qwen-chat-template (auto-filled); no takeover switch — the official compat flag lives on the provider row; context-window limit presets 64K/128K/256K/400K/512K/1M with a custom input." src="assets/自定义模型的思考接管-短路-上下文窗口限制.png" />
39
- <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 &amp; writes capabilities into the official llm-pi-ai compat surface (no adapter needed since 0.7.0-beta.1).</figcaption>
40
- </figure>
41
-
42
- ## Levels
43
-
44
- | Level | Meaning | Where |
45
- |---|---|---|
46
- | `off` | thinking disabled (manual only — never auto-picked) | model selector / default level |
47
- | `on` | thinking enabled (toggle-only models only): sends `enable_thinking`, never a think effort | model selector / default level |
48
- | `minimal` | least effort (very light tasks) | model selector / default level |
49
- | `low` | manual pick for simple chat tasks (cheap rounds stay cheap) | model selector / default level |
50
- | `medium` | medium effort | model selector / default level |
51
- | `high` | the official default effort | model selector / default level |
52
- | `xhigh` | extra high effort | model selector / default level |
53
- | `max` | heavy work | model selector / default level |
54
- | `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 |
55
-
56
- 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.
57
-
58
- ## Custom wire mapping
59
-
60
- 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".
61
-
62
- - Official preset: `Off / High / Max` (official DeepSeek style)
63
- - Generic preset: `Off / Low / Medium / High`
64
-
65
- ## Context-window presets
66
-
67
- 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`).
68
-
69
- 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 compat sync does not block model discovery, a settings edit takes effect on the next request without a restart.
70
-
71
- The plugin config also accepts `models['provider/model'].contextWindow` as a validated (integer `2000`–`1000000`) declaration at the composition/config surface.
72
-
73
- ## Model-aware guard (v0.5.0)
74
-
75
- The plugin never sends a `reasoning_effort` to a model that does not advertise one. Custom
76
- openai-completions routes (e.g. a local Qwen3.6 without `reasoningEfforts`) are classified
77
- non-reasoning via `ctx.llm.resolveModelInfo`, and any effort — inherited or scheduled — is
78
- **stripped** instead of sent, so dsh's per-request `UNSUPPORTED_REASONING_EFFORT` rejection
79
- cannot fire. Unsupported fields are never passed to an API that cannot take them.
80
-
81
- Version behavior:
82
-
83
- | dsh version | `low` handling |
84
- |---|---|
85
- | 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 |
86
- | rc.7+ (new) | native: the plugin neither rewrites nor re-injects it; a manual `low` pick passes through unchanged |
87
-
88
- The auto scheduler may still pick `low` for supporting models — the capability guard above is
89
- what keeps it away from models that cannot take it.
90
-
91
- ## Model-selector Auto
92
-
93
- The session model selector (next to the model) now offers **Auto** after the wire levels (injected into the model-directory metadata by the plugin):
94
-
95
- | Model-selector pick | Behavior |
96
- |---|---|
97
- | **Auto** | plugin schedules via tool history + the upgrade/downgrade toggles, resolves to `low` / `high` / `max` before submission |
98
- | `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) |
99
- | unset | the plugin's default level applies (below) |
100
-
101
- ## Auto scheduler
102
-
103
- The hub is `high` (the official default). `auto` schedules between `low` / `high` / `max`; it never picks `off`.
104
-
105
- | Recent tool calls | Level |
106
- |---|---|
107
- | none (fresh prompt, pure chat) | `low` |
108
- | ≥75% simple tools, small args, downgrades allowed | `low` |
109
- | mixed / heavy tools | `high` |
110
- | very heavy payloads, upgrades allowed | `max` |
111
-
112
- 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).
113
-
114
- ## Install
115
-
116
- See [INSTALL.md](./INSTALL.md) for the full official-CLI guide (profile discovery, upgrade, migration, verification, troubleshooting). Quick start:
117
-
118
- ```bash
119
- # 1. install the plugin into a profile from npm (web shown; any profile works)
120
- # (the web profile is a pnpm workspace root, so -w is required)
121
- dsh plugin --profile web add dsh-thinking-levels -w
122
- # GitHub alternative:
123
- # dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
124
- # local-path alternative (no network needed):
125
- # dsh plugin --profile web add /absolute/path/to/dsh-thinking-levels
126
-
127
- # 2. restart dsh web (a running instance does not hot-load new bundle layers)
128
- dsh web
129
- ```
130
-
131
- > Note: the dsh runtime uses pnpm 11, whose `minimumReleaseAge` supply-chain policy may block a
132
- > freshly published version with `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION` — add the version to
133
- > `minimumReleaseAgeExclude` in `~/.dsh/profiles/web/pnpm-workspace.yaml` to lift the cooling period.
134
-
135
- Manual `link:` registration (alternative to `dsh plugin add`):
136
-
137
- ```bash
138
- # ~/.dsh/profiles/web/package.json dependencies:
139
- # "dsh-thinking-levels": "link:<absolute path to dsh-thinking-levels>"
140
- # ~/.dsh/profiles/web/cordis.patch.yml:
141
- # - insert:
142
- # - id: thinking-levels
143
- # name: dsh-thinking-levels
144
- cd ~/.dsh/profiles/web && pnpm install && dsh web
145
- ```
146
-
147
- ## Configuration
148
-
149
- Two surfaces share one schema:
150
-
151
- - **Assembly** — the plugin row's `config:` in the profile composition (e.g. `cordis.yml`):
152
- ```yaml
153
- config:
154
- level: auto # off | on | minimal | low | medium | high | xhigh | max | auto — the default level when the session picks nothing
155
- allowDowngrade: true # let the scheduler drop below `high`
156
- allowUpgrade: false # forbid the scheduler lifting to `max`
157
- ```
158
- - **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.
159
-
160
- Per-model capability overrides (`models`, keyed `provider/model`) confirm what auto-detection
161
- finds; the configurer has the final word:
162
-
163
- ```yaml
164
- config:
165
- level: auto
166
- models:
167
- llm-pi-ai/Qwen3.6-35B-A3B: # non-reasoning thinking model (thinking toggle + budget)
168
- vision: false
169
- thinking: true
170
- efforts: false # never send reasoning_effort (stripped at request time)
171
- llm-pi-ai/Qwen3.8-27B: # effort-capable model (rc.6-era adapter without low)
172
- efforts: [low, high] # confirm low → advertised in the selector + passed through
173
- ```
174
-
175
- > For Qwen thinking on/off + budget, configure the **llm-pi-ai** route instead:
176
- > `compat.thinkingFormat: qwen` (→ wire `enable_thinking` + `thinking_budget` via
177
- > `thinkingBudgets`), or `qwen-chat-template` (→ `chat_template_kwargs.enable_thinking`) for
178
- > effort models like Qwen3.8-27B.
179
-
180
- Defaults: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false, models: {} }`.
181
-
182
- > 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.
183
-
184
- ## Official compat surface: the short-circuit tool is retired (0.7.0-beta.1)
185
-
186
- Once custom gateways (vLLM / LM Studio / self-hosted OpenAI-compatible proxies) declare
187
- thinking, this plugin writes the fixes into the **official `llm-pi-ai` compat surface**
188
- (introduced in dsh ≥ **v0.1.0-rc.8**, commit `884f7b9c41`) —
189
- [dsh-llm-openai-completions](https://github.com/drscrewdriver/dsh-llm-openai-completions)
190
- is no longer needed and should stay uninstalled:
191
-
192
- - Scans `llm-pi-ai.providers` for routes that are custom openai-completions gateways
193
- (`api: openai-completions` or a non-official baseURL) **and** declare a `reasoningEfforts`
194
- table on any model (including `modelOverrides`), then writes:
195
- - route-level `compat.supportsDeveloperRole: false` — the system prompt goes out as
196
- `system`, fixing the vLLM / SGLang `Unexpected message role` 400;
197
- - model-level `compat.thinkingFormat: 'qwen-chat-template'` on toggle-style thinking rows
198
- (thinking table without row-level `supportsReasoningEffort`) — pi-ai then sends
199
- `chat_template_kwargs.enable_thinking` (bare vLLM servers ignore the top-level
200
- `enable_thinking` of the plain `qwen` format);
201
- - Writes go through the official settings channel (read → pure transform → whole-section
202
- `settings.update('llm-pi-ai', …)`), so dsh's schema validates the write **where it is
203
- written**: a dsh older than rc.8 rejects the fields with a log warning — no silent
204
- misconfiguration; explicit values on any layer are never clobbered;
205
- - Triggers on plugin start, `llm/adapters-updated`, and `llm-pi-ai` settings changes — no
206
- manual config editing;
207
- - The capability card is de-short-circuited too: the provider-level switch is now
208
- "**gateway rejects the developer role**" (writes/clears the route-level flag; unchecking
209
- restores inheritance), and the model editor is progressive
210
- (thinking/vision → effort support → effort editor);
211
- - Response-side inline `<think>` splitting remains a **gateway concern**: bare vLLM needs
212
- `--reasoning-parser qwen3` (pi-ai parses only `reasoning_content` / `reasoning` /
213
- `reasoning_text`).
214
-
215
- # Dependency note
216
-
217
- 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).
218
-
219
- ## Development
220
-
221
- ```bash
222
- npm run lint # eslint (typescript-eslint flat config)
223
- npm run typecheck # tsc --noEmit
224
- npm test # vitest — 46 tests
225
- ```
226
-
227
- 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 the official-compat sync (identification, explicit-value respect, identity idempotence, write-time schema gating).
228
-
229
- ## License
230
-
231
- MIT
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
+ > **v0.7.0-beta.1 (2026-09-06): the short-circuit route is retired.** This release no longer depends on `dsh-llm-openai-completions` — custom-gateway fixes ride the official `llm-pi-ai` compat surface (requires **dsh ≥ v0.1.0-rc.8**); keep the adapter plugin uninstalled. See the [CHANGELOG](./CHANGELOG.md).
7
+
8
+ - [中文 README](./README.zh.md)
9
+ - [日本語 README](./README.ja.md)
10
+ - [한국어 README](./README.ko.md)
11
+ - [Installation guide](./INSTALL.md)
12
+ - [中文安装指南](./INSTALL.zh.md)
13
+ - [日本語インストールガイド](./INSTALL.ja.md)
14
+ - [한국어 설치 안내](./INSTALL.ko.md)
15
+ - [Changelog](./CHANGELOG.md)
16
+ - [日本語 changelog](./CHANGELOG.ja.md)
17
+ - [한국어 changelog](./CHANGELOG.ko.md)
18
+
19
+ > # ⚠️ LEGACY BRANCH — `compat/dsh-0.1.1`
20
+ >
21
+ > **This branch is the frozen old-version line. It is not the mainline.**
22
+ >
23
+ > - **Mainline**: `master` — the DSH 0.1.2+ line, where versions move forward.
24
+ > - **This branch**: `compat/dsh-0.1.1` — the DSH 0.1.0 / 0.1.1 line, published under the npm `compat` tag only. It receives no feature work; it exists so old DSH installs keep working.
25
+ >
26
+ > **▼ DSH version support — compat line**
27
+ >
28
+ > This release (`0.7.1-beta.x`) supports **DSH < 0.1.2-alpha.1** (the 0.1.0 / 0.1.1 lines) only.
29
+ >
30
+ > | DSH version | Status | Install |
31
+ > | --- | --- | --- |
32
+ > | < 0.1.2-alpha.1 | ✅ Supported (this line) | `npm i dsh-thinking-levels@compat` |
33
+ > | ≥ 0.1.2-alpha.1 | ❌ **Not supported** | Use `npm i dsh-thinking-levels@beta` (0.7.2+) instead |
34
+ >
35
+ > The boundary is `0.1.2-alpha.1`, where DSH removed `@deepseek-ai/dsh-client-runtime`. This line still imports `ClientContext` from it, so it cannot build or run against 0.1.2+; `engines.dsh` is narrowed to `>=0.1.0-rc.8 <0.1.2-alpha.1` to block a wrong install. `compat` is the 0.1.0/0.1.1 line; `beta` is the 0.1.2+ line, which takes `Context` from `@deepseek-ai/cordis`. The two lines never overwrite each other.
36
+
37
+ > **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.
38
+
39
+ 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.
40
+
41
+ ## Preview
42
+
43
+ Screenshots of the live UI (dsh web):
44
+
45
+ <figure>
46
+ <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" />
47
+ <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>
48
+ </figure>
49
+
50
+ <figure>
51
+ <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 the progressive per-model editor, and apply-to-all presets (Off/High/Max official DeepSeek style, Off/Low/Medium/High generic)." src="assets/自动思考级别配置.png" />
52
+ <figcaption>Thinking-level settings card: the auto scheduler plus its boundaries, and llm-pi-ai model-capability mapping (gear → gateway wire values).</figcaption>
53
+ </figure>
54
+
55
+ <figure>
56
+ <img style="max-width:100%" alt="Per-model capability editor for a custom openai-completions model (local-35b / Qwen3.6-35B-A3B): thinking model and vision enabled, support think effort off, thinking format qwen-chat-template (auto-filled); no takeover switch — the official compat flag lives on the provider row; context-window limit presets 64K/128K/256K/400K/512K/1M with a custom input." src="assets/自定义模型的思考接管-短路-上下文窗口限制.png" />
57
+ <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 &amp; writes capabilities into the official llm-pi-ai compat surface (no adapter needed since 0.7.0-beta.1).</figcaption>
58
+ </figure>
59
+
60
+ ## Levels
61
+
62
+ | Level | Meaning | Where |
63
+ |---|---|---|
64
+ | `off` | thinking disabled (manual only — never auto-picked) | model selector / default level |
65
+ | `on` | thinking enabled (toggle-only models only): sends `enable_thinking`, never a think effort | model selector / default level |
66
+ | `minimal` | least effort (very light tasks) | model selector / default level |
67
+ | `low` | manual pick for simple chat tasks (cheap rounds stay cheap) | model selector / default level |
68
+ | `medium` | medium effort | model selector / default level |
69
+ | `high` | the official default effort | model selector / default level |
70
+ | `xhigh` | extra high effort | model selector / default level |
71
+ | `max` | heavy work | model selector / default level |
72
+ | `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 |
73
+
74
+ 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.
75
+
76
+ ## Custom wire mapping
77
+
78
+ 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".
79
+
80
+ - Official preset: `Off / High / Max` (official DeepSeek style)
81
+ - Generic preset: `Off / Low / Medium / High`
82
+
83
+ ## Context-window presets
84
+
85
+ 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`).
86
+
87
+ 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 compat sync does not block model discovery, a settings edit takes effect on the next request without a restart.
88
+
89
+ The plugin config also accepts `models['provider/model'].contextWindow` as a validated (integer `2000`–`1000000`) declaration at the composition/config surface.
90
+
91
+ ## Model-aware guard (v0.5.0)
92
+
93
+ The plugin never sends a `reasoning_effort` to a model that does not advertise one. Custom
94
+ openai-completions routes (e.g. a local Qwen3.6 without `reasoningEfforts`) are classified
95
+ non-reasoning via `ctx.llm.resolveModelInfo`, and any effort — inherited or scheduled — is
96
+ **stripped** instead of sent, so dsh's per-request `UNSUPPORTED_REASONING_EFFORT` rejection
97
+ cannot fire. Unsupported fields are never passed to an API that cannot take them.
98
+
99
+ Version behavior:
100
+
101
+ | dsh version | `low` handling |
102
+ |---|---|
103
+ | 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 |
104
+ | rc.7+ (new) | native: the plugin neither rewrites nor re-injects it; a manual `low` pick passes through unchanged |
105
+
106
+ The auto scheduler may still pick `low` for supporting models — the capability guard above is
107
+ what keeps it away from models that cannot take it.
108
+
109
+ ## Model-selector Auto
110
+
111
+ The session model selector (next to the model) now offers **Auto** after the wire levels (injected into the model-directory metadata by the plugin):
112
+
113
+ | Model-selector pick | Behavior |
114
+ |---|---|
115
+ | **Auto** | plugin schedules via tool history + the upgrade/downgrade toggles, resolves to `low` / `high` / `max` before submission |
116
+ | `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) |
117
+ | unset | the plugin's default level applies (below) |
118
+
119
+ ## Auto scheduler
120
+
121
+ The hub is `high` (the official default). `auto` schedules between `low` / `high` / `max`; it never picks `off`.
122
+
123
+ | Recent tool calls | Level |
124
+ |---|---|
125
+ | none (fresh prompt, pure chat) | `low` |
126
+ | ≥75% simple tools, small args, downgrades allowed | `low` |
127
+ | mixed / heavy tools | `high` |
128
+ | very heavy payloads, upgrades allowed | `max` |
129
+
130
+ 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).
131
+
132
+ ## Install
133
+
134
+ See [INSTALL.md](./INSTALL.md) for the full official-CLI guide (profile discovery, upgrade, migration, verification, troubleshooting). Quick start:
135
+
136
+ ```bash
137
+ # 1. install the plugin into a profile from npm (web shown; any profile works)
138
+ # (the web profile is a pnpm workspace root, so -w is required)
139
+ dsh plugin --profile web add dsh-thinking-levels -w
140
+ # GitHub alternative:
141
+ # dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
142
+ # local-path alternative (no network needed):
143
+ # dsh plugin --profile web add /absolute/path/to/dsh-thinking-levels
144
+
145
+ # 2. restart dsh web (a running instance does not hot-load new bundle layers)
146
+ dsh web
147
+ ```
148
+
149
+ > Note: the dsh runtime uses pnpm 11, whose `minimumReleaseAge` supply-chain policy may block a
150
+ > freshly published version with `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION` — add the version to
151
+ > `minimumReleaseAgeExclude` in `~/.dsh/profiles/web/pnpm-workspace.yaml` to lift the cooling period.
152
+
153
+ Manual `link:` registration (alternative to `dsh plugin add`):
154
+
155
+ ```bash
156
+ # ~/.dsh/profiles/web/package.json dependencies:
157
+ # "dsh-thinking-levels": "link:<absolute path to dsh-thinking-levels>"
158
+ # ~/.dsh/profiles/web/cordis.patch.yml:
159
+ # - insert:
160
+ # - id: thinking-levels
161
+ # name: dsh-thinking-levels
162
+ cd ~/.dsh/profiles/web && pnpm install && dsh web
163
+ ```
164
+
165
+ ## Configuration
166
+
167
+ Two surfaces share one schema:
168
+
169
+ - **Assembly** — the plugin row's `config:` in the profile composition (e.g. `cordis.yml`):
170
+ ```yaml
171
+ config:
172
+ level: auto # off | on | minimal | low | medium | high | xhigh | max | auto — the default level when the session picks nothing
173
+ allowDowngrade: true # let the scheduler drop below `high`
174
+ allowUpgrade: false # forbid the scheduler lifting to `max`
175
+ ```
176
+ - **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.
177
+
178
+ Per-model capability overrides (`models`, keyed `provider/model`) confirm what auto-detection
179
+ finds; the configurer has the final word:
180
+
181
+ ```yaml
182
+ config:
183
+ level: auto
184
+ models:
185
+ llm-pi-ai/Qwen3.6-35B-A3B: # non-reasoning thinking model (thinking toggle + budget)
186
+ vision: false
187
+ thinking: true
188
+ efforts: false # never send reasoning_effort (stripped at request time)
189
+ llm-pi-ai/Qwen3.8-27B: # effort-capable model (rc.6-era adapter without low)
190
+ efforts: [low, high] # confirm low → advertised in the selector + passed through
191
+ ```
192
+
193
+ > For Qwen thinking on/off + budget, configure the **llm-pi-ai** route instead:
194
+ > `compat.thinkingFormat: qwen` (→ wire `enable_thinking` + `thinking_budget` via
195
+ > `thinkingBudgets`), or `qwen-chat-template` (→ `chat_template_kwargs.enable_thinking`) for
196
+ > effort models like Qwen3.8-27B.
197
+
198
+ Defaults: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false, models: {} }`.
199
+
200
+ > 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.
201
+
202
+ ## Official compat surface: the short-circuit tool is retired (0.7.0-beta.1)
203
+
204
+ Once custom gateways (vLLM / LM Studio / self-hosted OpenAI-compatible proxies) declare
205
+ thinking, this plugin writes the fixes into the **official `llm-pi-ai` compat surface**
206
+ (introduced in dsh ≥ **v0.1.0-rc.8**, commit `884f7b9c41`) —
207
+ [dsh-llm-openai-completions](https://github.com/drscrewdriver/dsh-llm-openai-completions)
208
+ is no longer needed and should stay uninstalled:
209
+
210
+ - Scans `llm-pi-ai.providers` for routes that are custom openai-completions gateways
211
+ (`api: openai-completions` or a non-official baseURL) **and** declare a `reasoningEfforts`
212
+ table on any model (including `modelOverrides`), then writes:
213
+ - route-level `compat.supportsDeveloperRole: false` — the system prompt goes out as
214
+ `system`, fixing the vLLM / SGLang `Unexpected message role` 400;
215
+ - model-level `compat.thinkingFormat: 'qwen-chat-template'` on toggle-style thinking rows
216
+ (thinking table without row-level `supportsReasoningEffort`) — pi-ai then sends
217
+ `chat_template_kwargs.enable_thinking` (bare vLLM servers ignore the top-level
218
+ `enable_thinking` of the plain `qwen` format);
219
+ - Writes go through the official settings channel (read → pure transform → whole-section
220
+ `settings.update('llm-pi-ai', …)`), so dsh's schema validates the write **where it is
221
+ written**: a dsh older than rc.8 rejects the fields with a log warning — no silent
222
+ misconfiguration; explicit values on any layer are never clobbered;
223
+ - Triggers on plugin start, `llm/adapters-updated`, and `llm-pi-ai` settings changes — no
224
+ manual config editing;
225
+ - The capability card is de-short-circuited too: the provider-level switch is now
226
+ "**gateway rejects the developer role**" (writes/clears the route-level flag; unchecking
227
+ restores inheritance), and the model editor is progressive
228
+ (thinking/vision → effort support → effort editor);
229
+ - Response-side inline `<think>` splitting remains a **gateway concern**: bare vLLM needs
230
+ `--reasoning-parser qwen3` (pi-ai parses only `reasoning_content` / `reasoning` /
231
+ `reasoning_text`).
232
+
233
+ # Dependency note
234
+
235
+ 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).
236
+
237
+ ## Development
238
+
239
+ ```bash
240
+ npm run lint # eslint (typescript-eslint flat config)
241
+ npm run typecheck # tsc --noEmit
242
+ npm test # vitest — 46 tests
243
+ ```
244
+
245
+ 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 the official-compat sync (identification, explicit-value respect, identity idempotence, write-time schema gating).
246
+
247
+ ## License
248
+
249
+ MIT