dsh-thinking-levels 0.4.1 → 0.6.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.ko.md ADDED
@@ -0,0 +1,168 @@
1
+ # dsh-thinking-levels
2
+
3
+ **[DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness)용 라운드별 사고 수준(`reasoning_effort`) 제어: 세션 모델 선택기에서 `Auto`(마스크)를 고르면 플러그인이 최근 도구 호출 기록에서 `low` / `high` / `max`를 스케줄링하여 API에 제출합니다. 또는 `off` / `on` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max`를 수동으로 고정. 가벼운 도구 라운드는 가볍게, 무거운 작업도 추론 부족 없이.**
4
+
5
+ - [English README](./README.md)
6
+ - [中文 README](./README.zh.md)
7
+ - [日本語 README](./README.ja.md)
8
+ - [한국어 README](./README.ko.md)
9
+ - [설치 안내](./INSTALL.ko.md)
10
+ - [English installation guide](./INSTALL.md)
11
+ - [中文安装指南](./INSTALL.zh.md)
12
+ - [日本語インストールガイド](./INSTALL.ja.md)
13
+ - [Changelog](./CHANGELOG.md)
14
+ - [日本語 changelog](./CHANGELOG.ja.md)
15
+ - [한국어 changelog](./CHANGELOG.ko.md)
16
+
17
+ > **호환성 참고:** `0.6.0`에는 일본어(`ja`)와 한국어(`ko`) 사전 및 선택 항목이 포함되어 있지만, 현재 공식 DSH는 `LocaleRuntime`을 통해 `zh`와 `en`만 제공합니다. 순정 DSH에서 `ja` 또는 `ko`를 선택하면 `locale "<id>" is not registered` 오류가 발생합니다. 공식 DSH가 해당 locale ID를 추가할 때까지 사용할 수 없습니다. 고급 사용자는 DSH 포크를 유지하면서 `packages/client/locale/src/locale-settings.ts`의 `LOCALE_IDS`와 `packages/client/locale/src/client/index.ts`의 `LOCALES` 라벨을 업데이트하고 핵심 사전과 테스트를 추가한 뒤 다시 빌드하여 실행할 수 있습니다. 이 플러그인만으로는 DSH의 전역 locale 목록을 확장할 수 없습니다.
18
+
19
+ 멀티스텝 도구 체인에서 모델은 **모든 도구 호출 전에** 다시 생각합니다——그 사고가 벽시계 시간의 대부분을 차지합니다(50스텝 에이전트 작업은 도구 사이에 수 분의 추론을 쓸 수 있습니다). `dsh-thinking-levels`는 dsh가 매 스텝 다시 해석하는 `agent/request` waterfall(`prepend`로 최외곽에 등록하여 세션 모델 선택 어셈블리가 덮어쓰지 못하게 함)에 연결되어 다음 모델 요청에 사고 수준을 주입합니다.
20
+
21
+ ## 수준
22
+
23
+ | 수준 | 의미 | 위치 |
24
+ |---|---|---|
25
+ | `off` | 사고 비활성화(수동 전용. 자동 스케줄링에서 선택되지 않음) | 모델 선택기 / 기본 수준 |
26
+ | `on` | 사고 활성화(토글 전용 모델용): `enable_thinking`만 전송하고 think effort는 전송하지 않음 | 모델 선택기 / 기본 수준 |
27
+ | `minimal` | 최소(매우 가벼운 작업) | 모델 선택기 / 기본 수준 |
28
+ | `low` | 단순 채팅 작업용 수동 낮음(가벼운 라운드는 가볍게 유지) | 모델 선택기 / 기본 수준 |
29
+ | `medium` | 중간 | 모델 선택기 / 기본 수준 |
30
+ | `high` | 공식 기본 수준 | 모델 선택기 / 기본 수준 |
31
+ | `xhigh` | 특별히 높음 | 모델 선택기 / 기본 수준 |
32
+ | `max` | 무거운 작업 | 모델 선택기 / 기본 수준 |
33
+ | `auto` | **마스크**: 최근 도구 호출 기록에서 스텝별로 스케줄링하고 제출 전에 구체적 수준으로 해석 | 모델 선택기(플러그인 주입) / 기본 수준 |
34
+
35
+ 와이어 수준 사실(공식 DeepSeek 문서와 dsh의 `llm-deepseek` 어댑터로 확인): deepseek-v4-flash / v4-pro에서 `low`는 1:1로 유효하며 `medium` / `xhigh`는 `high`로 접힙니다. 어댑터는 `off | low | high | max`만 받고 그 외에는 `UNSUPPORTED_REASONING_EFFORT`로 거부합니다——`auto`는 플러그인의 마스크 계층으로 API에 절대 전송되지 않으며 주입 전에 항상 구체적 와이어 수준으로 해석됩니다. `on`은 **effort 수준이 아닙니다**: 토글 전용 모델(Qwen3.6 방식)만 광고하며 `enable_thinking`만 true로 만듭니다——`reasoning_effort`는 전송되지 않습니다. effort 지원 모델은 `on`을 광고하지 않으므로 수동으로 `on`을 골라도 제거됩니다.
36
+
37
+ ## 사용자 지정 전송 값 매핑
38
+
39
+ `llm-pi-ai`에 수동 선언한 모델은 설정 카드에서 각 수준을 게이트웨이가 실제로 받아들이는 값으로 매핑할 수 있습니다(dsh-thinking-effort에서 차용): 수준을 체크하고 전송 값을 입력합니다(예: `high` → `ultra`). 매핑은 모델의 `reasoningEfforts` 테이블로 저장되며, Composer에서 `High`를 선택하면 게이트웨이에는 `ultra`가 전송됩니다. `off`를 비워 두면 전송되지 않습니다.
40
+
41
+ - 공식 프리셋: `Off / High / Max`(공식 DeepSeek 방식)
42
+ - 일반 프리셋: `Off / Low / Medium / High`
43
+
44
+ ## 모델 기능 가드(v0.5.0)
45
+
46
+ 플러그인은 추론 기능을 선언하지 않은 모델에 `reasoning_effort`를 **절대 전송하지 않습니다**. 사용자 지정 openai-completions 라우트(예: `reasoningEfforts`가 없는 로컬 Qwen3.6)는 `ctx.llm.resolveModelInfo`로 비추론 모델로 분류되며, 상속·스케줄링 여부와 무관하게 모든 수준은 **제거**되어 전송되지 않습니다——dsh의 요청별 `UNSUPPORTED_REASONING_EFFORT` 거부가 발생하지 않습니다. 지원되지 않는 필드가 API에 전달되는 일은 없습니다.
47
+
48
+ | dsh 버전 | `low` 처리 |
49
+ |---|---|
50
+ | rc.6(구형) | 비네이티브: `models` 오버라이드로 확인된 경우에만 선택기에 표시. 표시(선택기 + 요청 검증) 후 그대로 통과 |
51
+ | rc.7+(신형) | 네이티브: 플러그인이 재작성하거나 재주입하지 않음. 수동 `low`는 그대로 통과 |
52
+
53
+ auto 스케줄러는 지원 모델에서 `low`를 선택할 수 있습니다——위 가드가 받을 수 없는 모델에서 멀어지게 합니다.
54
+
55
+ ## 모델 선택기 Auto
56
+
57
+ 세션 모델 선택기(모델 옆)에는 와이어 수준 뒤에 **Auto**가 표시됩니다(플러그인이 모델 디렉터리 메타데이터에 주입):
58
+
59
+ | 선택기 선택 | 동작 |
60
+ |---|---|
61
+ | **Auto** | 도구 기록 + 승격/강등 토글로 스케줄링하고 제출 전에 `low` / `high` / `max`로 해석 |
62
+ | `off` / `on` / `minimal` / `low` / `medium` / `high` / `xhigh` / `max` | **수동 선택 우선**——플러그인 개입 없음(토글 전용 모델에서는 `on`이 `on`으로 유지되며 effort로 끌어올려지지 않고, effort 지원 모델에서는 제거됨) |
63
+ | 미선택 | 플러그인 기본 수준 적용(아래) |
64
+
65
+ ## 자동 스케줄러
66
+
67
+ 허브는 `high`(공식 기본값). `auto`는 `low` / `high` / `max` 사이에서만 스케줄링하며 `off`는 선택하지 않습니다.
68
+
69
+ | 최근 도구 호출 | 수준 |
70
+ |---|---|
71
+ | 없음(새 프롬프트, 순수 채팅) | `low` |
72
+ | ≥75% 단순 도구·작은 인자·강등 허용 | `low` |
73
+ | 혼합 / 무거운 도구 | `high` |
74
+ | 매우 무거운 페이로드·승격 허용 | `max` |
75
+
76
+ 스케줄링 정책은 [dsh-tool-turbo](https://github.com/drscrewdriver/dsh-tool-turbo)와 동일한 소스입니다(같은 단순 도구 화이트리스트 / 페이로드 임계값 / 75% 비율 규칙).
77
+
78
+ ## 설치
79
+
80
+ 전체 절차(profile 확인, 업그레이드, 마이그레이션, 검증, 트러블슈팅)는 [INSTALL.ko.md](./INSTALL.ko.md)를 참조하세요. 빠른 시작:
81
+
82
+ ```bash
83
+ # 1. npm에서 profile로 플러그인 설치(예: web. 아무 profile이나 가능)
84
+ # (web profile은 pnpm workspace root이므로 -w 필수)
85
+ dsh plugin --profile web add dsh-thinking-levels -w
86
+ # GitHub 버전:
87
+ # dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
88
+ # 로컬 경로 버전(네트워크 불필요):
89
+ # dsh plugin --profile web add /absolute/path/to/dsh-thinking-levels
90
+
91
+ # 2. dsh web 재시작(실행 중인 인스턴스는 새 bundle 계층을 핫로드하지 않음)
92
+ dsh web
93
+ ```
94
+
95
+ > 참고: dsh 런타임은 pnpm 11을 사용하며 새로 게시된 버전은 `minimumReleaseAge` 쿨링 기간의 대상입니다. `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION`이 발생하면 `~/.dsh/profiles/web/pnpm-workspace.yaml`의 `minimumReleaseAgeExclude`에 버전을 추가하세요.
96
+
97
+ 수동 `link:` 등록(`dsh plugin add` 대안):
98
+
99
+ ```bash
100
+ # ~/.dsh/profiles/web/package.json dependencies:
101
+ # "dsh-thinking-levels": "link:<dsh-thinking-levels 절대 경로>"
102
+ # ~/.dsh/profiles/web/cordis.patch.yml:
103
+ # - insert:
104
+ # - id: thinking-levels
105
+ # name: dsh-thinking-levels
106
+ cd ~/.dsh/profiles/web && pnpm install && dsh web
107
+ ```
108
+
109
+ ## 구성
110
+
111
+ 두 표면이 같은 스키마를 공유합니다:
112
+
113
+ - **어셈블리** — profile 구성의 플러그인 행 `config:`(예: `cordis.yml`):
114
+ ```yaml
115
+ config:
116
+ level: auto # off | on | minimal | low | medium | high | xhigh | max | auto — 세션이 아무것도 고르지 않을 때의 기본 수준
117
+ allowDowngrade: true # 스케줄러가 `high` 아래로 내리는 것을 허용
118
+ allowUpgrade: false # 스케줄러가 `max`로 올리는 것을 금지
119
+ ```
120
+ - **런타임** — dsh-settings 네임스페이스 `thinking-levels`(`level`, `allowDowngrade`, `allowUpgrade`, `enabled`, `models`): 변경은 다음 모델 요청부터 적용, 재시작 불필요. 설정 패널(설정 → 플러그인 → 설정 가능한 플러그인)에 시각적 편집기가 있습니다(수준 그리드 + 전송 값 입력 + 검색 + 원클릭 프리셋).
121
+
122
+ 모델별 능력 오버라이드(`models`, 키는 `provider/model`)는 자동 감지 결과를 확정합니다. 구성자가 최종 결정권을 가집니다:
123
+
124
+ ```yaml
125
+ config:
126
+ level: auto
127
+ models:
128
+ llm-pi-ai/Qwen3.6-35B-A3B: # 비-effort 사고 모델(사고 토글 + budget)
129
+ vision: false
130
+ thinking: true
131
+ efforts: false # reasoning_effort 전송 안 함(요청 시 제거)
132
+ llm-pi-ai/Qwen3.8-27B: # effort 지원 모델(rc.6 시대 어댑터에 low 없음)
133
+ efforts: [low, high] # low 확인 → 선택기 표시 + 통과
134
+ ```
135
+
136
+ > Qwen 사고 on/off + budget은 **llm-pi-ai** 라우트에서 구성하세요:
137
+ > `compat.thinkingFormat: qwen`(→ 와이어 `enable_thinking` + `thinking_budget`, `thinkingBudgets` 경유), 또는 effort 모델(Qwen3.8-27B 등)에서는 `qwen-chat-template`(→ `chat_template_kwargs.enable_thinking`).
138
+
139
+ 기본값: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false, models: {} }`.
140
+
141
+ > 의미: 모델 선택기 선택이 플러그인 기본 수준보다 우선합니다. `auto`(마스크) → 플러그인 스케줄링. 와이어 수준 → 직접 적용. 미선택 → 플러그인 `level` 기본값. `allowDowngrade` / `allowUpgrade`는 `auto` 스케줄링만 제약합니다.
142
+
143
+ ## dsh-llm-openai-completions 자동 인계(v0.5.2)
144
+
145
+ 사용자 지정 게이트웨이(vLLM / LM Studio / 자체 OpenAI 호환 프록시)가 사고를 선언하면(`llm-pi-ai` 모델 행에 `reasoningEfforts` 테이블) [dsh-llm-openai-completions](https://github.com/drscrewdriver/dsh-llm-openai-completions)가 해당 라우트를 인계해야 합니다——그렇지 않으면 pi-ai가 `role: "developer"`(400)를 보내거나 `enable_thinking`을 누락합니다. 이 플러그인은 인계 목록을 **자동 유지**합니다:
146
+
147
+ - `llm-pi-ai.providers`를 스캔하여「사용자 지정 openai-completions 게이트웨이(`api: openai-completions` 또는 비공식 baseURL) **그리고** 어떤 모델이 `reasoningEfforts` 테이블을 선언」한 provider 식별;
148
+ - 자동으로 `llm-openai-completions.providers`에 병합하고 `enabled: true`로(수동 추가분 유지, 중복 제거);
149
+ - 트리거: 플러그인 시작, `llm/adapters-updated`, `llm-pi-ai` 또는 인계 목록 설정 변경——수동 편집 불필요;
150
+ - 소프트 결합: `llm-openai-completions` 미설치(네임스페이스 미등록)면 쓰기를 건너뛰고 다른 기능에 영향 없음.
151
+
152
+ ## 의존성
153
+
154
+ 호스트 측은 `@deepseek-ai/dsh-settings`에 값 의존하지 않습니다(설정 등록은 cordis `settings` 서비스 경유, dsh 런타임 제공). profile에 공식 패키지를 수동 설치할 필요가 없습니다. `dependencies`는 `@deepseek-ai/schemastery`뿐입니다(패키지와 함께 자동 설치).
155
+
156
+ ## 개발
157
+
158
+ ```bash
159
+ npm run lint # eslint(typescript-eslint flat config)
160
+ npm run typecheck # tsc --noEmit
161
+ npm test # vitest — 46개 테스트
162
+ ```
163
+
164
+ 테스트 커버리지: 수준 정책(수동 통과·확장 수준, `on` 클램프, auto 스케줄러, 검증, 단순 도구 경계), 모델 기능 가드(`reasoningEffortSupported`, `resolveEffortInjection` 제거/통과), 세션 이벤트 파싱(가드, 창 상한, 잘못된 레코드), 구성 스키마(기본값 잠금, 범위 밖 거부, `models` 오버라이드), 인계 동기화(식별, 중복 제거 병합, 소프트 결합).
165
+
166
+ ## 라이선스
167
+
168
+ MIT
package/README.md CHANGED
@@ -1,108 +1,195 @@
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
- [中文文档](./README.zh.md) · English
6
-
7
- 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.
8
-
9
- ## Levels
10
-
11
- | Level | Meaning | Where |
12
- |---|---|---|
13
- | `off` | thinking disabled (manual only — never auto-picked) | model selector / default level |
14
- | `low` | manual pick for simple chat tasks (cheap rounds stay cheap) | model selector / default level |
15
- | `high` | the official default effort | model selector / default level |
16
- | `max` | heavy work | model selector / default level |
17
- | `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 |
18
-
19
- 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.
20
-
21
- ## Model-selector Auto
22
-
23
- The session model selector (next to the model) now offers **Auto** after `Off / Low / High / Max` (injected into the model-directory metadata by the plugin):
24
-
25
- | Model-selector pick | Behavior |
26
- |---|---|
27
- | **Auto** | plugin schedules via tool history + the upgrade/downgrade toggles, resolves to `low` / `high` / `max` before submission |
28
- | `off` / `low` / `high` / `max` | **manual choice wins** — plugin does not intervene |
29
- | unset | the plugin's default level applies (below) |
30
-
31
- ## Auto scheduler
32
-
33
- The hub is `high` (the official default). `auto` schedules between `low` / `high` / `max`; it never picks `off`.
34
-
35
- | Recent tool calls | Level |
36
- |---|---|
37
- | none (fresh prompt, pure chat) | `low` |
38
- | ≥75% simple tools, small args, downgrades allowed | `low` |
39
- | mixed / heavy tools | `high` |
40
- | very heavy payloads, upgrades allowed | `max` |
41
-
42
- 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).
43
-
44
- ## Install
45
-
46
- ```bash
47
- # 1. install the plugin into a profile from npm (web shown; any profile works)
48
- # (the web profile is a pnpm workspace root, so -w is required)
49
- dsh plugin --profile web add dsh-thinking-levels -w
50
- # GitHub alternative:
51
- # dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
52
- # local-path alternative (no network needed):
53
- # dsh plugin --profile web add /absolute/path/to/dsh-thinking-levels
54
-
55
- # 2. restart dsh web (a running instance does not hot-load new bundle layers)
56
- dsh web
57
- ```
58
-
59
- > Note: the dsh runtime uses pnpm 11, whose `minimumReleaseAge` supply-chain policy may block a
60
- > freshly published version with `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION` — add the version to
61
- > `minimumReleaseAgeExclude` in `~/.dsh/profiles/web/pnpm-workspace.yaml` to lift the cooling period.
62
-
63
- Manual `link:` registration (alternative to `dsh plugin add`):
64
-
65
- ```bash
66
- # ~/.dsh/profiles/web/package.json dependencies:
67
- # "dsh-thinking-levels": "link:<absolute path to dsh-thinking-levels>"
68
- # ~/.dsh/profiles/web/cordis.patch.yml:
69
- # - insert:
70
- # - id: thinking-levels
71
- # name: dsh-thinking-levels
72
- cd ~/.dsh/profiles/web && pnpm install && dsh web
73
- ```
74
-
75
- ## Configuration
76
-
77
- Two surfaces share one schema:
78
-
79
- - **Assembly** — the plugin row's `config:` in the profile composition (e.g. `cordis.yml`):
80
- ```yaml
81
- config:
82
- level: auto # off | low | high | max | auto — the default level when the session picks nothing
83
- allowDowngrade: true # let the scheduler drop below `high`
84
- allowUpgrade: false # forbid the scheduler lifting to `max`
85
- ```
86
- - **Runtime** — the dsh-settings namespace `thinking-levels` (`level`, `allowDowngrade`, `allowUpgrade`, `enabled`): changes apply to the next model request, no restart needed. A visual editor is available under Settings → Plugins → configurable plugins.
87
-
88
- Defaults: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false }`.
89
-
90
- > Semantics: the model-selector pick outranks the plugin's default level. Pick `auto` (mask) → plugin schedules; pick `off/low/high/max` → applied directly; pick nothing → the plugin's `level` default is used. `allowDowngrade` / `allowUpgrade` constrain `auto` scheduling only.
91
-
92
- ## Dependency note
93
-
94
- 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).
95
-
96
- ## Development
97
-
98
- ```bash
99
- npm run lint # eslint (typescript-eslint flat config)
100
- npm run typecheck # tsc --noEmit
101
- npm test # vitest — 21 tests
102
- ```
103
-
104
- Test coverage: level policy (manual pass-through, auto scheduler, validation, simple-tool boundary), session-event parsing (guards, window cap, malformed records), and the config schema (defaults lockstep, out-of-band rejection).
105
-
106
- ## License
107
-
108
- 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
+ - [中文 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
+ ## Levels
22
+
23
+ | Level | Meaning | Where |
24
+ |---|---|---|
25
+ | `off` | thinking disabled (manual only — never auto-picked) | model selector / default level |
26
+ | `on` | thinking enabled (toggle-only models only): sends `enable_thinking`, never a think effort | model selector / default level |
27
+ | `minimal` | least effort (very light tasks) | model selector / default level |
28
+ | `low` | manual pick for simple chat tasks (cheap rounds stay cheap) | model selector / default level |
29
+ | `medium` | medium effort | model selector / default level |
30
+ | `high` | the official default effort | model selector / default level |
31
+ | `xhigh` | extra high effort | model selector / default level |
32
+ | `max` | heavy work | model selector / default level |
33
+ | `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 |
34
+
35
+ 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.
36
+
37
+ ## Custom wire mapping
38
+
39
+ 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".
40
+
41
+ - Official preset: `Off / High / Max` (official DeepSeek style)
42
+ - Generic preset: `Off / Low / Medium / High`
43
+
44
+ ## Model-aware guard (v0.5.0)
45
+
46
+ The plugin never sends a `reasoning_effort` to a model that does not advertise one. Custom
47
+ openai-completions routes (e.g. a local Qwen3.6 without `reasoningEfforts`) are classified
48
+ non-reasoning via `ctx.llm.resolveModelInfo`, and any effort — inherited or scheduled — is
49
+ **stripped** instead of sent, so dsh's per-request `UNSUPPORTED_REASONING_EFFORT` rejection
50
+ cannot fire. Unsupported fields are never passed to an API that cannot take them.
51
+
52
+ Version behavior:
53
+
54
+ | dsh version | `low` handling |
55
+ |---|---|
56
+ | 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 |
57
+ | rc.7+ (new) | native: the plugin neither rewrites nor re-injects it; a manual `low` pick passes through unchanged |
58
+
59
+ The auto scheduler may still pick `low` for supporting models — the capability guard above is
60
+ what keeps it away from models that cannot take it.
61
+
62
+ ## Model-selector Auto
63
+
64
+ The session model selector (next to the model) now offers **Auto** after the wire levels (injected into the model-directory metadata by the plugin):
65
+
66
+ | Model-selector pick | Behavior |
67
+ |---|---|
68
+ | **Auto** | plugin schedules via tool history + the upgrade/downgrade toggles, resolves to `low` / `high` / `max` before submission |
69
+ | `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) |
70
+ | unset | the plugin's default level applies (below) |
71
+
72
+ ## Auto scheduler
73
+
74
+ The hub is `high` (the official default). `auto` schedules between `low` / `high` / `max`; it never picks `off`.
75
+
76
+ | Recent tool calls | Level |
77
+ |---|---|
78
+ | none (fresh prompt, pure chat) | `low` |
79
+ | ≥75% simple tools, small args, downgrades allowed | `low` |
80
+ | mixed / heavy tools | `high` |
81
+ | very heavy payloads, upgrades allowed | `max` |
82
+
83
+ 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).
84
+
85
+ ## Install
86
+
87
+ See [INSTALL.md](./INSTALL.md) for the full official-CLI guide (profile discovery, upgrade, migration, verification, troubleshooting). Quick start:
88
+
89
+ ```bash
90
+ # 1. install the plugin into a profile from npm (web shown; any profile works)
91
+ # (the web profile is a pnpm workspace root, so -w is required)
92
+ dsh plugin --profile web add dsh-thinking-levels -w
93
+ # GitHub alternative:
94
+ # dsh plugin --profile web add https://github.com/drscrewdriver/dsh-thinking-levels.git -w
95
+ # local-path alternative (no network needed):
96
+ # dsh plugin --profile web add /absolute/path/to/dsh-thinking-levels
97
+
98
+ # 2. restart dsh web (a running instance does not hot-load new bundle layers)
99
+ dsh web
100
+ ```
101
+
102
+ > Note: the dsh runtime uses pnpm 11, whose `minimumReleaseAge` supply-chain policy may block a
103
+ > freshly published version with `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION` — add the version to
104
+ > `minimumReleaseAgeExclude` in `~/.dsh/profiles/web/pnpm-workspace.yaml` to lift the cooling period.
105
+
106
+ Manual `link:` registration (alternative to `dsh plugin add`):
107
+
108
+ ```bash
109
+ # ~/.dsh/profiles/web/package.json dependencies:
110
+ # "dsh-thinking-levels": "link:<absolute path to dsh-thinking-levels>"
111
+ # ~/.dsh/profiles/web/cordis.patch.yml:
112
+ # - insert:
113
+ # - id: thinking-levels
114
+ # name: dsh-thinking-levels
115
+ cd ~/.dsh/profiles/web && pnpm install && dsh web
116
+ ```
117
+
118
+ ## Configuration
119
+
120
+ Two surfaces share one schema:
121
+
122
+ - **Assembly** — the plugin row's `config:` in the profile composition (e.g. `cordis.yml`):
123
+ ```yaml
124
+ config:
125
+ level: auto # off | on | minimal | low | medium | high | xhigh | max | auto — the default level when the session picks nothing
126
+ allowDowngrade: true # let the scheduler drop below `high`
127
+ allowUpgrade: false # forbid the scheduler lifting to `max`
128
+ ```
129
+ - **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.
130
+
131
+ Per-model capability overrides (`models`, keyed `provider/model`) confirm what auto-detection
132
+ finds; the configurer has the final word:
133
+
134
+ ```yaml
135
+ config:
136
+ level: auto
137
+ models:
138
+ llm-pi-ai/Qwen3.6-35B-A3B: # non-reasoning thinking model (thinking toggle + budget)
139
+ vision: false
140
+ thinking: true
141
+ efforts: false # never send reasoning_effort (stripped at request time)
142
+ llm-pi-ai/Qwen3.8-27B: # effort-capable model (rc.6-era adapter without low)
143
+ efforts: [low, high] # confirm low → advertised in the selector + passed through
144
+ ```
145
+
146
+ > For Qwen thinking on/off + budget, configure the **llm-pi-ai** route instead:
147
+ > `compat.thinkingFormat: qwen` (→ wire `enable_thinking` + `thinking_budget` via
148
+ > `thinkingBudgets`), or `qwen-chat-template` (→ `chat_template_kwargs.enable_thinking`) for
149
+ > effort models like Qwen3.8-27B.
150
+
151
+ Defaults: `{ enabled: true, level: 'auto', allowDowngrade: true, allowUpgrade: false, models: {} }`.
152
+
153
+ > 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.
154
+
155
+ ## Auto-takeover of dsh-llm-openai-completions (v0.5.2)
156
+
157
+ Custom gateways (vLLM / LM Studio / self-hosted OpenAI-compatible proxies) must be served by
158
+ [dsh-llm-openai-completions](https://github.com/drscrewdriver/dsh-llm-openai-completions) once
159
+ they declare thinking (`reasoningEfforts` table in `llm-pi-ai`) — otherwise pi-ai sends
160
+ `role: "developer"` (400) or drops `enable_thinking`. This plugin **maintains the takeover list
161
+ automatically**:
162
+
163
+ - Scans `llm-pi-ai.providers` for providers that are custom openai-completions gateways
164
+ (`api: openai-completions` or a non-official baseURL) **and** declare a `reasoningEfforts`
165
+ table on any model;
166
+ - Merges them into `llm-openai-completions.providers` with `enabled: true` (existing manual
167
+ entries are preserved, deduplicated);
168
+ - Triggers on plugin start, `llm/adapters-updated`, and settings changes to `llm-pi-ai` or the
169
+ takeover list — no manual config editing;
170
+ - Soft-coupled: skips the write silently when `llm-openai-completions` is not installed (its
171
+ namespace is unregistered).
172
+
173
+ The takeover mechanism as a whole — control-plane contract (who is taken over,
174
+ how a control-layer plugin decides and injects) and transport-plane wire
175
+ contract — is standardized in the
176
+ **[Takeover Control Spec](https://github.com/drscrewdriver/dsh-llm-openai-completions/blob/main/docs/takeover-spec.md)**;
177
+ this plugin is the reference control-layer implementation of it.
178
+
179
+ ## Dependency note
180
+
181
+ 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).
182
+
183
+ ## Development
184
+
185
+ ```bash
186
+ npm run lint # eslint (typescript-eslint flat config)
187
+ npm run typecheck # tsc --noEmit
188
+ npm test # vitest — 46 tests
189
+ ```
190
+
191
+ 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).
192
+
193
+ ## License
194
+
195
+ MIT