dsh-thinking-levels 4.4.13 → 4.4.14

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/lib/index.d.ts CHANGED
@@ -71,6 +71,12 @@ export interface ThinkingLevelsConfig {
71
71
  allowDowngrade: boolean | Volatile<boolean>;
72
72
  /** Scheduler preference: allow lifting above the `high` hub to `max`. */
73
73
  allowUpgrade: boolean | Volatile<boolean>;
74
+ /**
75
+ * Extra tool names the auto scheduler also treats as cheap-and-deterministic,
76
+ * merged with the built-in set (issue #8). Each is matched after the `ops_`
77
+ * namespace strip, exactly like a built-in token.
78
+ */
79
+ simpleTools: string[] | Volatile<string[]>;
74
80
  /**
75
81
  * Master takeover switch: mirrored into the openai-completions transport's
76
82
  * own section (`llm-openai-completions.enabled`) when it flips. The
@@ -107,6 +113,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
107
113
  level: z<"off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "volatile-defined">;
108
114
  allowDowngrade: z<boolean, boolean, "volatile-defined">;
109
115
  allowUpgrade: z<boolean, boolean, "volatile-defined">;
116
+ simpleTools: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
110
117
  takeover: z<boolean, boolean, "volatile-defined">;
111
118
  takeoverUi: z<boolean, boolean, "volatile-defined">;
112
119
  defaultPricing: z<"off" | "custom" | "estimate" | "cn" | "global", "off" | "custom" | "estimate" | "cn" | "global", "volatile-defined">;
@@ -126,6 +133,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
126
133
  level: z<"off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "volatile-defined">;
127
134
  allowDowngrade: z<boolean, boolean, "volatile-defined">;
128
135
  allowUpgrade: z<boolean, boolean, "volatile-defined">;
136
+ simpleTools: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
129
137
  takeover: z<boolean, boolean, "volatile-defined">;
130
138
  takeoverUi: z<boolean, boolean, "volatile-defined">;
131
139
  defaultPricing: z<"off" | "custom" | "estimate" | "cn" | "global", "off" | "custom" | "estimate" | "cn" | "global", "volatile-defined">;
@@ -153,6 +161,7 @@ export declare const LegacyConfig: z<Schemastery.ObjectS<NoInfer<{
153
161
  level: z<"off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "defined">;
154
162
  allowDowngrade: z<boolean, boolean, "defined">;
155
163
  allowUpgrade: z<boolean, boolean, "defined">;
164
+ simpleTools: z<string[], string[], "defined">;
156
165
  takeover: z<boolean, boolean, "defined">;
157
166
  takeoverUi: z<boolean, boolean, "defined">;
158
167
  defaultPricing: z<"off" | "custom" | "estimate" | "cn" | "global", "off" | "custom" | "estimate" | "cn" | "global", "defined">;
@@ -172,6 +181,7 @@ export declare const LegacyConfig: z<Schemastery.ObjectS<NoInfer<{
172
181
  level: z<"off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "off" | "on" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "auto", "defined">;
173
182
  allowDowngrade: z<boolean, boolean, "defined">;
174
183
  allowUpgrade: z<boolean, boolean, "defined">;
184
+ simpleTools: z<string[], string[], "defined">;
175
185
  takeover: z<boolean, boolean, "defined">;
176
186
  takeoverUi: z<boolean, boolean, "defined">;
177
187
  defaultPricing: z<"off" | "custom" | "estimate" | "cn" | "global", "off" | "custom" | "estimate" | "cn" | "global", "defined">;
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@ export const Config = z.object({
31
31
  level: z.union(['off', 'on', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'auto']).default('auto').volatile(),
32
32
  allowDowngrade: z.boolean().default(true).volatile(),
33
33
  allowUpgrade: z.boolean().default(false).volatile(),
34
+ simpleTools: z.array(z.string()).default([]).volatile(),
34
35
  takeover: z.boolean().default(false).volatile(),
35
36
  takeoverUi: z.boolean().default(false).volatile(),
36
37
  defaultPricing: defaultPricingSchema.volatile(),
@@ -48,6 +49,7 @@ export const LegacyConfig = z.object({
48
49
  level: z.union(['off', 'on', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'auto']).default('auto'),
49
50
  allowDowngrade: z.boolean().default(true),
50
51
  allowUpgrade: z.boolean().default(false),
52
+ simpleTools: z.array(z.string()).default([]),
51
53
  takeover: z.boolean().default(false),
52
54
  takeoverUi: z.boolean().default(false),
53
55
  defaultPricing: defaultPricingSchema,
@@ -59,6 +61,7 @@ export const DEFAULT_CONFIG = {
59
61
  level: 'auto',
60
62
  allowDowngrade: true,
61
63
  allowUpgrade: false,
64
+ simpleTools: [],
62
65
  takeover: false,
63
66
  takeoverUi: false,
64
67
  defaultPricing: 'estimate',
@@ -88,6 +91,7 @@ function resolveLiveConfig(config) {
88
91
  level: readVolatile(config.level, 'auto'),
89
92
  allowDowngrade: readVolatile(config.allowDowngrade, true),
90
93
  allowUpgrade: readVolatile(config.allowUpgrade, false),
94
+ simpleTools: readVolatile(config.simpleTools, []),
91
95
  takeover: readVolatile(config.takeover, false),
92
96
  takeoverUi: readVolatile(config.takeoverUi, false),
93
97
  defaultPricing: readVolatile(config.defaultPricing, 'estimate'),
@@ -337,6 +341,7 @@ export function installLegacySection(ctx, config, hooks) {
337
341
  level: readVolatile(config.level, 'auto'),
338
342
  allowDowngrade: readVolatile(config.allowDowngrade, true),
339
343
  allowUpgrade: readVolatile(config.allowUpgrade, false),
344
+ simpleTools: readVolatile(config.simpleTools, []),
340
345
  takeover: readVolatile(config.takeover, false),
341
346
  takeoverUi: readVolatile(config.takeoverUi, false),
342
347
  models: config.models,
@@ -509,6 +514,7 @@ export function apply(ctx, config = DEFAULT_CONFIG) {
509
514
  samples: state?.samples ?? [],
510
515
  allowDowngrade: cfg.allowDowngrade,
511
516
  allowUpgrade: cfg.allowUpgrade,
517
+ extraSimpleTools: cfg.simpleTools,
512
518
  supportsReasoning: capabilityFor.supportsReasoning,
513
519
  efforts: capabilityFor.efforts,
514
520
  toggleOnly: capabilityFor.toggleOnly,
@@ -661,6 +667,7 @@ export function apply(ctx, config = DEFAULT_CONFIG) {
661
667
  recentCalls: calls,
662
668
  allowDowngrade: cfg.allowDowngrade,
663
669
  allowUpgrade: cfg.allowUpgrade,
670
+ extraSimpleTools: cfg.simpleTools,
664
671
  efforts: capabilityFor.efforts,
665
672
  toggleOnly: capabilityFor.toggleOnly,
666
673
  });
@@ -64,6 +64,8 @@ export interface StrictStepInput {
64
64
  allowDowngrade: boolean;
65
65
  /** Scheduler preference: may lift above the hub to `max`. */
66
66
  allowUpgrade: boolean;
67
+ /** Extra tool names merged into the built-in cheap-and-deterministic set (issue #8 `Config.simpleTools`). */
68
+ extraSimpleTools?: readonly string[];
67
69
  /** Whether the target model advertises reasoning-effort support at all. */
68
70
  supportsReasoning: boolean;
69
71
  /** The model's advertised effort ids (including plugin masks like `auto`). */
@@ -80,6 +80,7 @@ export function planStrictStep(input) {
80
80
  recentCalls: input.samples,
81
81
  allowDowngrade: input.allowDowngrade,
82
82
  allowUpgrade: input.allowUpgrade,
83
+ extraSimpleTools: input.extraSimpleTools,
83
84
  efforts: input.efforts,
84
85
  toggleOnly: input.toggleOnly,
85
86
  });
@@ -63,6 +63,12 @@ export interface EffortDecisionInput {
63
63
  allowDowngrade: boolean;
64
64
  /** User preference: allow the scheduler to lift above the hub to `max`. */
65
65
  allowUpgrade: boolean;
66
+ /**
67
+ * Extra tool names treated as cheap-and-deterministic, merged with the
68
+ * built-in set (each matched after the `ops_` namespace strip). Empty/omitted
69
+ * leaves the built-in classification untouched (issue #8 `Config.simpleTools`).
70
+ */
71
+ extraSimpleTools?: readonly string[];
66
72
  }
67
73
  /**
68
74
  * Map the user's selected level to the level injected into the next
@@ -112,6 +118,11 @@ export interface EffortInjectionInput {
112
118
  allowDowngrade: boolean;
113
119
  /** Scheduler preference: allow lifting above `high` to `max`. */
114
120
  allowUpgrade: boolean;
121
+ /**
122
+ * Extra tool names merged into the built-in cheap-and-deterministic set for
123
+ * the `auto` scheduler (issue #8 `Config.simpleTools`).
124
+ */
125
+ extraSimpleTools?: readonly string[];
115
126
  /** The model's advertised effort ids (including plugin masks like `auto`). */
116
127
  efforts: readonly string[];
117
128
  /**
@@ -49,15 +49,59 @@ export function assertEffortId(value, where) {
49
49
  + '(expected off | on | minimal | low | medium | high | xhigh | max | auto)');
50
50
  }
51
51
  }
52
- /** Deterministic tool names that are cheap to reason about (word-boundary anchored). */
53
- const SIMPLE_TOOL_RE = /^(?:fs|bash|terminal|code|text|todo|job|skill|read|list|search|write|grep|glob|edit|ls|cat|rm|mv|cp|touch|mkdir|pwd|head|tail)(?:_|$)/i;
52
+ /**
53
+ * Deterministic tool names that are cheap to reason about (word-boundary
54
+ * anchored). `shell`/`pwsh`/`cmd`/`sh` sit alongside `bash`/`terminal` — every
55
+ * one of them is a "run this command" entry, so a step made only of short calls
56
+ * to any of them is cheap-and-deterministic (issue #8 follow-up: on hosts whose
57
+ * command tool is named `shell`/`pwsh` rather than `bash`, auto used to sit
58
+ * permanently on `high`).
59
+ */
60
+ const SIMPLE_TOOL_RE = /^(?:fs|bash|terminal|shell|pwsh|cmd|sh|code|text|todo|job|skill|read|list|search|write|grep|glob|edit|ls|cat|rm|mv|cp|touch|mkdir|pwd|head|tail)(?:_|$)/i;
61
+ /**
62
+ * Known tool-wrapper namespaces (issue #8). `ops_` is the prefix the dsh-ops
63
+ * plugin family puts on its tools (`ops_bash`, `ops_grep`, `ops_shell`,
64
+ * `ops_read_files`); the wrapped tool is just as cheap-and-deterministic as its
65
+ * bare name, so the prefix is stripped before the simple-tool check. Only an
66
+ * explicit table is stripped: a generic `word_` catch-all would misread
67
+ * look-alike heavy names such as `codebase_search` as simple (see the
68
+ * classification-boundary test).
69
+ */
70
+ const TOOL_NAMESPACE_RE = /^(?:ops_)+/i;
54
71
  /** Hefty payloads signal non-trivial work no matter the tool name. */
55
72
  const HEAVY_ARGS = 800;
73
+ /** Escape a user-supplied token for embedding in a RegExp source. */
74
+ function escapeRe(source) {
75
+ return source.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
76
+ }
77
+ /**
78
+ * Compiled `extraSimpleTools` matchers, memoised by content. The config array
79
+ * may be a fresh reference on every read (volatile `.get()`), so key on the
80
+ * joined names rather than identity to avoid recompiling per request.
81
+ */
82
+ const EXTRA_SIMPLE_RE_CACHE = new Map();
83
+ function compileExtraSimpleTools(tokens) {
84
+ if (tokens === undefined || tokens.length === 0)
85
+ return null;
86
+ const key = tokens.join('\u0000');
87
+ const hit = EXTRA_SIMPLE_RE_CACHE.get(key);
88
+ if (hit !== undefined)
89
+ return hit;
90
+ const cleaned = tokens.map(token => token.trim()).filter(token => token !== '');
91
+ const re = cleaned.length === 0 ? null : new RegExp(`^(?:${cleaned.map(escapeRe).join('|')})(?:_|$)`, 'i');
92
+ EXTRA_SIMPLE_RE_CACHE.set(key, re);
93
+ return re;
94
+ }
95
+ /** Whether a tool name (namespace prefix removed) looks cheap-and-deterministic. */
96
+ function isSimpleToolName(name, extra) {
97
+ const bare = name.replace(TOOL_NAMESPACE_RE, '');
98
+ return SIMPLE_TOOL_RE.test(bare) || (extra !== undefined && extra !== null && extra.test(bare));
99
+ }
56
100
  /** Count how many of the recent calls look cheap-and-deterministic. */
57
- function simpleRatio(calls) {
101
+ function simpleRatio(calls, extra) {
58
102
  if (calls.length === 0)
59
103
  return 1;
60
- const simple = calls.filter(call => SIMPLE_TOOL_RE.test(call.name) && call.argsSize < HEAVY_ARGS).length;
104
+ const simple = calls.filter(call => isSimpleToolName(call.name, extra) && call.argsSize < HEAVY_ARGS).length;
61
105
  return simple / calls.length;
62
106
  }
63
107
  /**
@@ -88,12 +132,12 @@ function simpleRatio(calls) {
88
132
  * @param allowUpgrade - may lift above `high`.
89
133
  * @returns a wire level; never `off` (off is manual-only) and never `auto`.
90
134
  */
91
- function scheduleEffort(calls, allowDowngrade, allowUpgrade) {
135
+ function scheduleEffort(calls, allowDowngrade, allowUpgrade, extra) {
92
136
  // The no-sample branch is the first request of the session: start at the hub
93
137
  // regardless of `allowDowngrade` (see the rationale above).
94
138
  if (calls.length === 0)
95
139
  return 'high';
96
- const ratio = simpleRatio(calls);
140
+ const ratio = simpleRatio(calls, extra);
97
141
  const heaviest = calls.reduce((max, call) => Math.max(max, call.argsSize), 0);
98
142
  if (ratio >= 0.75 && allowDowngrade)
99
143
  return 'low';
@@ -111,10 +155,10 @@ function scheduleEffort(calls, allowDowngrade, allowUpgrade) {
111
155
  * @returns The level to inject; `auto` is resolved before returning.
112
156
  */
113
157
  export function decideEffort(input) {
114
- const { recentCalls, selected, allowDowngrade, allowUpgrade } = input;
158
+ const { recentCalls, selected, allowDowngrade, allowUpgrade, extraSimpleTools } = input;
115
159
  if (selected !== 'auto')
116
160
  return selected;
117
- return scheduleEffort(recentCalls, allowDowngrade, allowUpgrade);
161
+ return scheduleEffort(recentCalls, allowDowngrade, allowUpgrade, compileExtraSimpleTools(extraSimpleTools));
118
162
  }
119
163
  /**
120
164
  * Whether a model's resolved metadata advertises reasoning-effort support.
@@ -207,6 +251,7 @@ export function resolveEffortInjection(input) {
207
251
  selected: 'auto',
208
252
  allowDowngrade: input.allowDowngrade,
209
253
  allowUpgrade: input.allowUpgrade,
254
+ extraSimpleTools: input.extraSimpleTools,
210
255
  });
211
256
  const clamped = clampToEfforts(level, efforts);
212
257
  return clamped === undefined ? { inject: false } : { inject: true, level: clamped };
package/locale/de.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Denkstufen",
4
+ "description": "Wählen Sie Auto im Modellselektor: Das Plugin plant low / high / max anhand des Tool-Aufrufverlaufs, bevor der API-Aufwand übermittelt wird. Hier konfigurieren Sie die Standardstufe, Planer-Grenzen und Modellfähigkeiten (Stufe → Gateway-Drahtwert-Zuordnung)."
5
+ }
6
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Thinking Levels",
4
+ "description": "Pick Auto in the model selector: the plugin schedules low / high / max per tool round before submitting the API effort. Here you configure the default level, scheduler bounds, and per-model capabilities (level → gateway wire value mapping)."
5
+ }
6
+ }
package/locale/es.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Niveles de razonamiento",
4
+ "description": "Elige Auto en el selector de modelo: el plugin planifica low / high / max según el historial de llamadas de herramientas antes de enviar el effort a la API. Aquí configuras el nivel predeterminado, los límites del planificador y las capacidades por modelo (nivel → valor wire enviado al gateway)."
5
+ }
6
+ }
package/locale/fr.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Niveaux de réflexion",
4
+ "description": "Choisissez Auto dans le sélecteur de modèle : le plugin planifie low / high / max selon l\\'historique des appels d\\'outils avant de soumettre l\\'effort à l\\'API. Configurez ici le niveau par défaut, les limites du planificateur et les capacités par modèle (niveau → valeur envoyée à la passerelle)."
5
+ }
6
+ }
package/locale/it.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Livelli di ragionamento",
4
+ "description": "Scegli Auto nel selettore del modello: il plugin pianifica low / high / max in base alla cronologia delle chiamate degli strumenti prima di inviare l\\'effort all\\'API. Qui configuri il livello predefinito, i limiti dello scheduler e le capacità per modello (livello → valore wire inviato al gateway)."
5
+ }
6
+ }
package/locale/ja.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "思考レベル",
4
+ "description": "モデルセレクターで Auto(マスク)を選択すると、ツール呼び出し履歴から low / high / max を自動スケジュールして API に送信します。ここでは既定レベル、スケジューラーの境界、モデル能力(レベル → ゲートウェイ送信値のマッピング)を設定します。"
5
+ }
6
+ }
package/locale/ko.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "사고 수준",
4
+ "description": "모델 선택기에서 Auto(마스크)를 선택하면 도구 호출 기록을 기반으로 low / high / max 를 자동 스케줄링하여 API에 제출합니다. 여기서 기본 수준, 스케줄러 경계, 모델 기능(수준 → 게이트웨이 전송 값 매핑)을 구성합니다."
5
+ }
6
+ }
package/locale/ru.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Уровни мышления",
4
+ "description": "Выберите Auto в селекторе модели: плагин планирует low / high / max по истории вызовов инструментов перед отправкой effort в API. Здесь настраивается уровень по умолчанию, границы планировщика и возможности модели (уровень → значение, отправляемое шлюзу)."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "思考档位",
4
+ "description": "在模型选择器中可选 Auto(mask):按工具调用历史自动在 low / high / max 间调度后提交 API。此处配置默认档位、调度边界与模型能力(档位 → 网关线上值映射)。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-thinking-levels",
3
- "version": "4.4.13",
3
+ "version": "4.4.14",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public",
@@ -41,7 +41,8 @@
41
41
  "CHANGELOG.de.md",
42
42
  "CHANGELOG.it.md",
43
43
  "CHANGELOG.ru.md",
44
- "CHANGELOG.es.md"
44
+ "CHANGELOG.es.md",
45
+ "locale"
45
46
  ],
46
47
  "main": "lib/index.js",
47
48
  "types": "lib/index.d.ts",
@@ -57,6 +58,7 @@
57
58
  "./client": {
58
59
  "default": "./lib/client.js"
59
60
  },
61
+ "./locale/*.json": "./locale/*.json",
60
62
  "./package.json": "./package.json"
61
63
  },
62
64
  "engines": {