dsh-think-effort 0.6.0 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0 — 2026-11-27
4
+
5
+ - **并行工作策略(实验,默认关闭)**:新增 `parallelEnabled` 开关。打开后通过 `ctx.systemPrompt.section()` 注入一段策略(order 700),提示模型在合适时把任务拆成互不阻塞的单元:
6
+ - 1–2 个独立单元 → 同一步多个 `subagent` 调用(并发执行);
7
+ - 3 个以上 → `workflow` 的 `parallel()` / `pipeline()`,每个 child 写清目标、允许修改的文件、验证命令和返回 JSON;
8
+ - 写路径不重叠、共享文件单写者、有依赖走顺序阶段;
9
+ - 写任务扇出上限 `parallelWriteFanout`(默认 4)、只读 `parallelReadFanout`(默认 8);
10
+ - 父代理负责集成与验证后才汇报;长全量测试用 `run_in_background`;
11
+ - 明确不用 subagent/workflow 跑测试;子代理只完成自己的单元,不再递归拆分。
12
+ - **独立于档位策略**:不改写任何模型请求、不增加工具权限、不额外发请求;`text` 读取 volatile 配置并在关闭时返回空串,所以开关在**下一次请求装配**生效,不需要重启/重挂。
13
+ - 设置页新增「并行工作(实验)」区块(总开关、写扇出、只读扇出);README / DETAIL(中英)与 `cordis.patch.yml` 同步。
14
+ - 测试:`node --test` **61 项全绿**(新增并行策略文本/开关/扇出 clamp、Host 注入与客户端双语文案测试)。
15
+ - 说明:上一轮验证用的用户全局 `~/.dsh/AGENTS.md` 策略已迁移进插件开关,不再全局常开。
16
+
3
17
  ## 0.6.0 — 2026-11-26
4
18
 
5
19
  - **自动难度(实验,默认关闭)**:新增 `adaptiveEnabled` 总开关。打开后只对模型选择器里的 `Auto` 生效:
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **中文(默认)** · [English](#english)
4
4
 
5
- 给 DeepSeek Harness(DSH)加一套**声明式自动思考档位**:模型选择器里出现 `Auto`,普通步骤落到模型声明的默认档(DeepSeek 为 `high`),会话标题、上下文压缩、自动复审这类由 Harness 自己发起的廉价调用自动用 `low`。打开调试开关后,每次请求的档位决策会实时出现在会话界面的悬浮窗里,子代理的决策也在其中。
5
+ 给 DeepSeek Harness(DSH)加一套**声明式自动思考档位**:模型选择器里出现 `Auto`,普通步骤落到模型声明的默认档(DeepSeek 为 `high`),会话标题、上下文压缩、自动复审这类由 Harness 自己发起的廉价调用自动用 `low`。打开调试开关后,每次请求的档位决策会实时出现在会话界面的悬浮窗里,子代理的决策也在其中。另有可选的**并行工作策略**开关:打开后提示模型在合适时把任务拆给并行的 subagent / workflow,而不是全部串行。
6
6
 
7
7
  ## 快速开始
8
8
 
@@ -109,6 +109,19 @@ DSH Desktop → **插件市场**搜索 `dsh-think-effort` 安装;或 **插件
109
109
 
110
110
  > 这是从 Reasonix 的实验性 reasoning governor 移植过来的机制(其 v1.39.11 已退役 enforcement,只留 shadow 遥测),所以这里也默认关闭、标注实验:纯思考型任务在探索阶段降档可能降低质量。失败升档、按子代理深度/preset 的多层映射不在本版本范围。
111
111
 
112
+ ### 并行工作(实验)
113
+
114
+ 默认**关闭**,与档位策略独立:打开后向每个会话的系统提示注入一段“先拆分、再并行”的规则。它只改变模型的行为,不增加工具权限,也不额外发请求;开关是 volatile 的,**下一次请求就生效,不需要重启**。
115
+
116
+ - **1–2 个独立单元**:提示模型在同一个 step 里发多个 `subagent` 调用(它们并发执行);
117
+ - **3 个以上**:提示模型用 `workflow` 的 `parallel()` / `pipeline()`,每个 child 写清目标、允许改的文件、验证命令,并返回 JSON;
118
+ - **写范围**:共享文件(lockfile、snapshot、生成文件、迁移)只能一个写者;有依赖用顺序阶段;
119
+ - **扇出上限**:写任务 `parallelWriteFanout`(默认 4),只读任务 `parallelReadFanout`(默认 8);
120
+ - **集成**:父代理等全部 child 结束,检查 diff/冲突,跑合并后的验证(优先 affected 测试)后才汇报;长全量测试用 `run_in_background`;
121
+ - **明确不要**:用 subagent/workflow 跑测试;小任务、同文件耦合、共享状态无隔离时不要并行。
122
+
123
+ 设置页「并行工作(实验)」:总开关、写扇出上限、只读扇出上限。适合“一个前端工程很多独立 spec/模块”这类任务;如果发现模型拆得太碎,先把上限调小或关掉。
124
+
112
125
  ### 本插件的第一次使用
113
126
 
114
127
  装上后不需要额外配置:`Auto` 与档位由插件自动声明。选中 `Auto` 即按默认档运行;选 `Low / High / Max` 即固定该档;不选(原生「提供方默认」)在普通步骤上与 `Auto` 等效。
@@ -164,6 +177,9 @@ DSH Desktop → **插件市场**搜索 `dsh-think-effort` 安装;或 **插件
164
177
  adaptiveMinRounds: 1
165
178
  adaptivePlanMode: true
166
179
  adaptivePlanLevel: high
180
+ parallelEnabled: false
181
+ parallelWriteFanout: 4
182
+ parallelReadFanout: 8
167
183
  debugOverlay: false
168
184
  trace: false
169
185
  ```
@@ -183,6 +199,9 @@ DSH Desktop → **插件市场**搜索 `dsh-think-effort` 安装;或 **插件
183
199
  | `auxLevel` | `low` | 廉价调用用的档位 |
184
200
  | `autoScope` | `all` | `all` / `declared` / `off` |
185
201
  | `subagentLevel` | `inherit` | 子代理档位:`inherit` / `auto` / `low`…`max`;固定档会覆盖子代理自身或继承的选择 |
202
+ | `parallelEnabled` | `false` | 注入并行工作策略(实验;只改模型行为) |
203
+ | `parallelWriteFanout` | `4` | 策略里写任务的扇出上限(1–8) |
204
+ | `parallelReadFanout` | `8` | 策略里只读任务的扇出上限(1–12) |
186
205
  | `debugOverlay` | `false` | 在会话界面显示实时档位切换日志(只记录,不改请求) |
187
206
  | `trace` | `false` | 把决策写到 stderr(排查用) |
188
207
 
@@ -300,6 +319,19 @@ Settings → Automatic thinking depth → **Automatic difficulty (experimental)*
300
319
 
301
320
  > This ports Reasonix's experimental reasoning governor (v1.39.11 retired its enforcement path and kept only shadow telemetry), so it stays opt-in and marked experimental: downgrading pure-reasoning tasks during exploration can hurt quality. Failure escalation and depth/preset maps are out of scope for this release.
302
321
 
322
+ ### Parallel work (experimental)
323
+
324
+ Off by default and independent of the depth policy: when on, a short “split first, run independent units in parallel” rule is injected into every session's system prompt. It only changes model behavior; it grants no tool permissions and sends no extra requests. The switch is volatile, so the **next request** picks it up without a restart.
325
+
326
+ - **1–2 independent units**: the model is told to emit several `subagent` calls in the same step (they run concurrently);
327
+ - **3+ units**: use `workflow` with `parallel()` / `pipeline()`; every child gets a goal, allowed files, a verification command, and returns JSON;
328
+ - **Write scopes**: shared files (lockfiles, snapshots, generated files, migrations) have exactly one writer; dependent work uses ordered stages;
329
+ - **Fan-out caps**: `parallelWriteFanout` (default 4) for writes, `parallelReadFanout` (default 8) for read-only work;
330
+ - **Integration**: the parent waits for every child, reviews diffs/conflicts, runs the merged verification (affected tests first), and only then reports done; long full suites go to `run_in_background`;
331
+ - **Explicitly not**: using subagent/workflow to run tests; small tasks, same-file coupling, or shared state without isolation.
332
+
333
+ Settings → Parallel work (experimental): master switch, write fan-out cap, read-only fan-out cap. Designed for tasks like a frontend project with many independent specs/modules; if the model splits too aggressively, lower the caps or turn it off.
334
+
303
335
  ### Features
304
336
 
305
337
  - Declares `reasoningEfforts` for DeepSeek models that carry none (gateway aliases included), so the selector finally has levels.
@@ -309,6 +341,7 @@ Settings → Automatic thinking depth → **Automatic difficulty (experimental)*
309
341
  - Idempotent: a second boot writes nothing; unload restores the original adapter registrations and retires a durable `auto`.
310
342
  - **Live debug window**: an opt-in, bounded, in-memory journal served over a Host route and rendered as a movable log over the conversation, subagent decisions included.
311
343
  - **Automatic difficulty (experimental)**: an opt-in exploration downgrade and plan-mode elevation for `Auto`, with explicit selections, cheap calls, and fixed subagent depths always taking precedence.
344
+ - **Parallel work (experimental)**: an independent opt-in system-prompt policy that tells the model when to split a task across parallel subagents/workflow, with write-scope, dependency, fan-out and integration rules.
312
345
 
313
346
  ### Configuration
314
347
 
package/client.js CHANGED
@@ -112,6 +112,15 @@ window.__ModuleLoader__.load({
112
112
  adaptivePlanRow: '计划模式使用高档',
113
113
  adaptivePlanHint: '计划模式下显式提高档位,避免把“探索”误降;不想要可以关闭。',
114
114
  adaptivePlanLevelRow: '计划模式使用的档位',
115
+ sectionParallel: '并行工作(实验)',
116
+ parallelSectionHint: '独立于档位策略:开启后向每个会话的系统提示注入一段“先拆分、再并行”的规则,让模型在合适时用 subagent / workflow 并行,而不是串行做完所有事。',
117
+ parallelEnabledRow: '启用并行工作策略',
118
+ parallelEnabledHint: '默认关闭;切换后下一步请求即生效,不需要重启。只改变模型行为,不给额外工具权限。',
119
+ parallelWriteFanoutRow: '写任务扇出上限',
120
+ parallelWriteFanoutHint: '建议 2–4;策略会提示模型不要超过这个数量,避免同文件/共享状态冲突。',
121
+ parallelReadFanoutRow: '只读任务扇出上限',
122
+ parallelReadFanoutHint: '建议 4–8;只读调研/审查可以比写任务更宽。',
123
+ parallelFanoutInvalid: '扇出上限必须是 1–8(写)/ 1–12(只读)之间的整数。',
115
124
  debugReasonExploration: '探索',
116
125
  debugReasonPlan: '计划',
117
126
  debugSection: '调试',
@@ -227,6 +236,15 @@ window.__ModuleLoader__.load({
227
236
  adaptivePlanRow: 'Use a higher depth in plan mode',
228
237
  adaptivePlanHint: 'Plan mode raises the depth explicitly so exploration is not downgraded there; turn it off if not wanted.',
229
238
  adaptivePlanLevelRow: 'Depth used in plan mode',
239
+ sectionParallel: 'Parallel work (experimental)',
240
+ parallelSectionHint: 'Independent of the depth policy: when on, a short “split first, run independent units in parallel” rule is injected into every session\'s system prompt, so the model uses subagent / workflow where it fits instead of doing everything serially.',
241
+ parallelEnabledRow: 'Enable the parallel-work policy',
242
+ parallelEnabledHint: 'Off by default; the next request picks up the change without a restart. It only changes model behavior; it grants no extra tool permissions.',
243
+ parallelWriteFanoutRow: 'Write-task fan-out cap',
244
+ parallelWriteFanoutHint: '2–4 is a good default; the policy tells the model not to exceed it, limiting same-file and shared-state conflicts.',
245
+ parallelReadFanoutRow: 'Read-only fan-out cap',
246
+ parallelReadFanoutHint: '4–8 is a good default; read-only research and review can run wider than write tasks.',
247
+ parallelFanoutInvalid: 'Fan-out caps must be integers: 1–8 for writes, 1–12 for read-only.',
230
248
  debugReasonExploration: 'explore',
231
249
  debugReasonPlan: 'plan',
232
250
  debugSection: 'Debug',
@@ -288,6 +306,7 @@ window.__ModuleLoader__.load({
288
306
  'adaptiveEnabled', 'adaptiveExploration', 'adaptiveExplorationLevel',
289
307
  'adaptiveTrigger', 'adaptiveReasoningThreshold', 'adaptiveMinRounds',
290
308
  'adaptivePlanMode', 'adaptivePlanLevel',
309
+ 'parallelEnabled', 'parallelWriteFanout', 'parallelReadFanout',
291
310
  'debugOverlay', 'trace',
292
311
  ];
293
312
 
@@ -499,6 +518,10 @@ window.__ModuleLoader__.load({
499
518
  if (typeof threshold !== 'number' || !Number.isFinite(threshold) || threshold < 0) return t('adaptiveThresholdInvalid');
500
519
  const rounds = current.adaptiveMinRounds;
501
520
  if (typeof rounds !== 'number' || !Number.isFinite(rounds) || rounds < 1) return t('adaptiveRoundsInvalid');
521
+ const writeFanout = current.parallelWriteFanout;
522
+ if (typeof writeFanout !== 'number' || !Number.isInteger(writeFanout) || writeFanout < 1 || writeFanout > 8) return t('parallelFanoutInvalid');
523
+ const readFanout = current.parallelReadFanout;
524
+ if (typeof readFanout !== 'number' || !Number.isInteger(readFanout) || readFanout < 1 || readFanout > 12) return t('parallelFanoutInvalid');
502
525
  for (const entry of asArray(current.declareModels)) {
503
526
  if (entry.includes('/')) continue;
504
527
  if (!validPattern(entry)) return t('invalidPattern');
@@ -841,6 +864,48 @@ window.__ModuleLoader__.load({
841
864
  }),
842
865
  ],
843
866
  }),
867
+ Section({
868
+ title: t('sectionParallel'),
869
+ hint: t('parallelSectionHint'),
870
+ children: [
871
+ Row({
872
+ key: 'parallelEnabled',
873
+ label: t('parallelEnabledRow'),
874
+ hint: t('parallelEnabledHint'),
875
+ children: Switch({ checked: current.parallelEnabled === true, disabled: busy, label: current.parallelEnabled === true ? t('on') : t('off'), onChange: (next) => patch('parallelEnabled', next) }),
876
+ }),
877
+ Row({
878
+ key: 'parallelWriteFanout',
879
+ label: t('parallelWriteFanoutRow'),
880
+ hint: t('parallelWriteFanoutHint'),
881
+ children: h('input', {
882
+ className: 'dte-input dte-input-number',
883
+ type: 'number',
884
+ min: 1,
885
+ max: 8,
886
+ step: 1,
887
+ value: current.parallelWriteFanout ?? 4,
888
+ disabled: busy,
889
+ onChange: (event) => patch('parallelWriteFanout', event.target.value === '' ? 1 : Number(event.target.value)),
890
+ }),
891
+ }),
892
+ Row({
893
+ key: 'parallelReadFanout',
894
+ label: t('parallelReadFanoutRow'),
895
+ hint: t('parallelReadFanoutHint'),
896
+ children: h('input', {
897
+ className: 'dte-input dte-input-number',
898
+ type: 'number',
899
+ min: 1,
900
+ max: 12,
901
+ step: 1,
902
+ value: current.parallelReadFanout ?? 8,
903
+ disabled: busy,
904
+ onChange: (event) => patch('parallelReadFanout', event.target.value === '' ? 1 : Number(event.target.value)),
905
+ }),
906
+ }),
907
+ ],
908
+ }),
844
909
  Section({
845
910
  title: t('debugSection'),
846
911
  hint: t('debugSectionHint'),
package/cordis.patch.yml CHANGED
@@ -60,6 +60,13 @@
60
60
  # Plan mode is an explicit signal: map it to its own depth.
61
61
  adaptivePlanMode: true
62
62
  adaptivePlanLevel: high
63
+ # Optional parallel-work policy (experimental; off by default). When on,
64
+ # a short system-prompt section tells the model to split independent
65
+ # work across subagents/workflow instead of running everything serially.
66
+ parallelEnabled: false
67
+ # Fan-out caps advertised by that policy (write 1-8, read-only 1-12).
68
+ parallelWriteFanout: 4
69
+ parallelReadFanout: 8
63
70
  # Record every effort decision for the conversation's floating debug
64
71
  # log (Settings -> Automatic thinking depth -> Debug). Off by default;
65
72
  # turning it on never changes a request.
package/docs/DETAIL.en.md CHANGED
@@ -43,6 +43,19 @@ The opt-in `adaptiveEnabled` switch. When on it applies only to the selector's `
43
43
  - **Observability**: the floating log tags these rows `explore` / `plan`, and the journal records `reason`/`phase`.
44
44
  - **Scope**: no failure escalation and no depth/preset maps in this release; it never guesses from prompt text or tool names.
45
45
 
46
+ ## Parallel work (experimental)
47
+
48
+ An independent `parallelEnabled` master switch, off by default. When on, the Host contributes `ctx.systemPrompt.section({ name: 'think-effort:parallel-work', order: 700, text })`. The text is a function over the volatile row config and returns an empty string while off, so a switch takes effect on the **next prompt assembly** without remounting a service.
49
+
50
+ The policy only teaches the model *when* and *how* to split; execution still uses DSH's existing `subagent` / `workflow`:
51
+
52
+ - 1–2 independent units → several `subagent` calls in one step;
53
+ - 3+ → `workflow` with `parallel()` / `pipeline()`;
54
+ - disjoint write paths; one writer per shared file; ordered stages for dependencies;
55
+ - fan-out caps `parallelWriteFanout` (default 4) / `parallelReadFanout` (default 8);
56
+ - the parent integrates and verifies before reporting; long full suites use `run_in_background`;
57
+ - never uses subagent/workflow to run tests.
58
+
46
59
  ## Where the settings page comes from
47
60
 
48
61
  - The row page registers into the plugin manager's `plugins.row.config`, keyed `dsh-think-effort#think-effort`.
@@ -79,6 +92,9 @@ The opt-in `adaptiveEnabled` switch. When on it applies only to the selector's `
79
92
  | `adaptiveTrigger` | `auto` | `auto` / `rounds` / `reasoning` |
80
93
  | `adaptiveReasoningThreshold` | `1500` | Threshold for the reasoning rule |
81
94
  | `adaptiveMinRounds` | `1` | Round count for the rounds rule |
95
+ | `parallelEnabled` | `false` | Parallel-work policy switch (experimental; model behavior only) |
96
+ | `parallelWriteFanout` | `4` | Write-task fan-out cap (1–8) |
97
+ | `parallelReadFanout` | `8` | Read-only fan-out cap (1–12) |
82
98
  | `adaptivePlanMode` | `true` | Map plan mode to a higher depth |
83
99
  | `adaptivePlanLevel` | `high` | Depth used in plan mode |
84
100
  | `debugOverlay` | `false` | Live effort-switch log over the conversation (records only, never rewrites; 300 records in Host memory) |
package/docs/DETAIL.zh.md CHANGED
@@ -43,6 +43,19 @@
43
43
  - **可观测**:调试悬浮窗给这类行加「探索 / 计划」标记,journal 记录 `reason`/`phase`。
44
44
  - **范围**:本版本不含失败升档、按深度/preset 的多层映射,也不按提示词/工具名猜难度。
45
45
 
46
+ ## 并行工作(实验)
47
+
48
+ 独立的 `parallelEnabled` 总开关,默认关闭。打开后由 Host 通过 `ctx.systemPrompt.section({ name: 'think-effort:parallel-work', order: 700, text })` 注入一段策略文本;`text` 是读取 volatile 配置的函数,关闭时返回空串,因此切换在**下一次请求装配**时生效,不重挂任何服务。
49
+
50
+ 策略只教模型“何时拆、怎么拆、何时不要拆”,执行仍然走 DSH 已有的 `subagent` / `workflow`:
51
+
52
+ - 1–2 个独立单元 → 同一步多个 `subagent` 调用;
53
+ - 3+ → `workflow` 的 `parallel()` / `pipeline()`;
54
+ - 写路径不重叠;共享文件单写者;有依赖走顺序阶段;
55
+ - 扇出上限 `parallelWriteFanout`(默认 4)/ `parallelReadFanout`(默认 8);
56
+ - 父代理集成、验证后才汇报;长全量测试用 `run_in_background`;
57
+ - 不拿 subagent/workflow 跑测试。
58
+
46
59
  ## 设置页从哪里来
47
60
 
48
61
  - 插件行页面注册进插件管理器的 `plugins.row.config`,键为 `dsh-think-effort#think-effort`;
@@ -79,6 +92,9 @@
79
92
  | `adaptiveTrigger` | `auto` | `auto` / `rounds` / `reasoning` |
80
93
  | `adaptiveReasoningThreshold` | `1500` | reasoning 规则的触发阈值 |
81
94
  | `adaptiveMinRounds` | `1` | rounds 规则的触发轮次 |
95
+ | `parallelEnabled` | `false` | 并行工作策略总开关(实验;只改模型行为) |
96
+ | `parallelWriteFanout` | `4` | 写任务扇出上限(1–8) |
97
+ | `parallelReadFanout` | `8` | 只读任务扇出上限(1–12) |
82
98
  | `adaptivePlanMode` | `true` | 计划模式映射高档 |
83
99
  | `adaptivePlanLevel` | `high` | 计划模式档位 |
84
100
  | `debugOverlay` | `false` | 会话界面的实时档位切换日志(只记录,不改请求;Host 内存最多 300 条) |
package/index.js CHANGED
@@ -51,6 +51,7 @@ import {
51
51
  withAutoEffort,
52
52
  } from './src/policy.js';
53
53
  import { createAdaptivePolicy } from './src/adaptive.js';
54
+ import { buildParallelPolicy } from './src/parallel.js';
54
55
  import { createDebugJournal, registerDebugRoutes } from './src/debug.js';
55
56
 
56
57
  /** The llm-pi-ai settings entry id in a composed profile. */
@@ -107,6 +108,12 @@ export const Config = z.object({
107
108
  adaptivePlanMode: z.boolean().default(DEFAULT_CONFIG.adaptivePlanMode).volatile(),
108
109
  /** Depth used while plan mode is active. */
109
110
  adaptivePlanLevel: z.string().default(DEFAULT_CONFIG.adaptivePlanLevel).volatile(),
111
+ /** Inject an optional parallel-work policy into the system prompt. */
112
+ parallelEnabled: z.boolean().default(DEFAULT_CONFIG.parallelEnabled).volatile(),
113
+ /** Fan-out cap for write tasks named by that policy. */
114
+ parallelWriteFanout: z.number().default(DEFAULT_CONFIG.parallelWriteFanout).volatile(),
115
+ /** Fan-out cap for read-only tasks named by that policy. */
116
+ parallelReadFanout: z.number().default(DEFAULT_CONFIG.parallelReadFanout).volatile(),
110
117
  /**
111
118
  * Record every effort decision in a bounded in-memory journal and serve it to
112
119
  * the conversation's floating debug log. Off by default; when off the journal
@@ -463,6 +470,27 @@ export function apply(ctx, rawConfig) {
463
470
  return decision;
464
471
  };
465
472
 
473
+ // ── optional parallel-work policy ────────────────────────────────────────
474
+ // A system-prompt section, not a tool: the policy changes how the model
475
+ // plans, while the existing workflow/subagent tools stay the execution path.
476
+ // The section text is a function over the live row config, so the switch
477
+ // takes effect on the next assembled step without a remount.
478
+ const systemPrompt = ctx.get('systemPrompt');
479
+ if (systemPrompt?.section !== undefined) {
480
+ ctx.effect(() => systemPrompt.section({
481
+ name: 'think-effort:parallel-work',
482
+ order: 700,
483
+ text: () => {
484
+ const policy = readConfig(config);
485
+ const text = buildParallelPolicy(policy);
486
+ if (policy.trace === true) {
487
+ trace('parallel-policy: enabled=%s chars=%d', String(policy.parallelEnabled), text.length);
488
+ }
489
+ return text;
490
+ },
491
+ }), 'think-effort: parallel work');
492
+ }
493
+
466
494
  // ── capability declaration ───────────────────────────────────────────────
467
495
  /** Serialize settings writes; a boot burst must not stack whole-section updates. */
468
496
  let syncTail = Promise.resolve();
@@ -626,6 +654,7 @@ export function apply(ctx, rawConfig) {
626
654
  debugRecord('config', {
627
655
  enabled: config.enabled,
628
656
  adaptiveEnabled: config.adaptiveEnabled,
657
+ parallelEnabled: config.parallelEnabled,
629
658
  debugOverlay: config.debugOverlay,
630
659
  autoLevel: config.autoLevel,
631
660
  defaultEffort: config.defaultEffort,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-think-effort",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
- "description": "Automatic thinking depth for DeepSeek routes in DeepSeek Harness: declare the model's effort vocabulary, add Auto to the model selector, resolve it to the declared default, give subagents their own depth, drop cheap host-owned calls to Low, edit every rule on a live visual settings page, watch each request's effort decision in a floating debug log, and optionally lower depth during exploration with the experimental adaptive policy.",
5
+ "description": "Automatic thinking depth for DeepSeek routes in DeepSeek Harness: declare the model's effort vocabulary, add Auto to the model selector, resolve it to the declared default, give subagents their own depth, drop cheap host-owned calls to Low, edit every rule on a live visual settings page, watch each request's effort decision in a floating debug log, optionally lower depth during exploration with the experimental adaptive policy, and optionally inject a parallel-work policy that tells the model to split independent work across subagents/workflow.",
6
6
  "icon": "./icon.svg",
7
7
  "license": "MIT",
8
8
  "author": "mhlywxl",
@@ -18,7 +18,9 @@
18
18
  "debug-overlay",
19
19
  "live-log",
20
20
  "adaptive-effort",
21
- "exploration"
21
+ "exploration",
22
+ "parallel-work",
23
+ "task-orchestration"
22
24
  ],
23
25
  "exports": {
24
26
  ".": "./index.js",
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The optional parallel-work policy injected into the system prompt.
3
+ *
4
+ * This module owns only the instruction text: it has no Host access and no
5
+ * tool permissions. The switch lives in the row config, so turning it off
6
+ * removes the text from the next assembled prompt without remounting anything.
7
+ */
8
+
9
+ /**
10
+ * Clamp one fan-out limit to the range the policy advertises.
11
+ * @param {unknown} value raw config value.
12
+ * @param {number} fallback default when the value is not a finite number.
13
+ * @param {number} max largest allowed fan-out.
14
+ * @returns {number} a positive integer.
15
+ */
16
+ function fanout(value, fallback, max) {
17
+ if (typeof value !== 'number' || !Number.isFinite(value)) return fallback;
18
+ return Math.min(max, Math.max(1, Math.round(value)));
19
+ }
20
+
21
+ /**
22
+ * Build the parallel-work section text.
23
+ *
24
+ * The text is deliberately short: it is re-sent on every model request while
25
+ * the switch is on, and long policy prose costs more than it saves.
26
+ * @param {object} [config] normalized plugin config.
27
+ * @returns {string} the system-prompt section, or an empty string when off.
28
+ */
29
+ export function buildParallelPolicy(config) {
30
+ if (config?.parallelEnabled !== true) return '';
31
+ const write = fanout(config.parallelWriteFanout, 4, 8);
32
+ const read = fanout(config.parallelReadFanout, 8, 12);
33
+ return [
34
+ '## 并行工作(可选策略)',
35
+ '开始多步骤编码/实现任务前,先判断能否拆成互不阻塞的单元;能并行就不要串行。',
36
+ '',
37
+ '**何时并行**:独立文件/模块/包(写路径不重叠);互不相关的失败测试或诊断方向;只读调研不同区域;不同验证层(typecheck/lint/unit/e2e)。',
38
+ '',
39
+ '**怎么拆**:',
40
+ '1. 先列单元、允许写的路径、依赖关系;共享文件(lockfile、snapshot、生成文件、迁移)只能有一个写者。',
41
+ '2. 1–2 个独立单元:在同一步里发多个 `subagent` 调用(会并发执行),不要串行发。',
42
+ '3. 3 个以上:用 `workflow` 的 `parallel()` / `pipeline()`;每个 child 的 prompt 写清目标、允许修改的文件、验证命令,并返回 JSON(改了哪些文件/测试结果/风险)。',
43
+ '4. 有依赖的用顺序阶段;不要让 B 等 A 的结果却并行启动。',
44
+ `5. 扇出上限:写任务 ${write} 个,只读任务 ${read} 个;每个 child 都有 token 与上下文成本。`,
45
+ '6. 父代理负责集成:等所有 child 结束,检查 diff 与冲突,跑合并后的验证(优先 affected 测试),确认后才汇报完成。长全量测试用 `run_in_background`,最后 `job_output`。',
46
+ '7. 如果你是被委派的子代理:只完成分配给你的单元,不再拆分子任务、不再并行委派。',
47
+ '',
48
+ '**何时不要**:改动集中在一两个文件或同文件耦合;共享状态(数据库、迁移、锁、快照、端口、缓存)没有隔离;设计还没定;小任务(拆分开销大于收益)。',
49
+ '',
50
+ '**不要**:用 `subagent`/`workflow` 来跑测试(测试用一条 affected/`--changed` 命令);未检查子代理结果、未跑验证就宣称完成。',
51
+ ].join('\n');
52
+ }
package/src/policy.js CHANGED
@@ -108,6 +108,12 @@ export const DEFAULT_CONFIG = {
108
108
  adaptivePlanMode: true,
109
109
  /** Depth used while plan mode is active. */
110
110
  adaptivePlanLevel: 'high',
111
+ /** Inject the optional parallel-work policy into the system prompt. */
112
+ parallelEnabled: false,
113
+ /** Fan-out cap for write tasks named by the policy. */
114
+ parallelWriteFanout: 4,
115
+ /** Fan-out cap for read-only tasks named by the policy. */
116
+ parallelReadFanout: 8,
111
117
  /** Record every effort decision for the conversation's floating debug log. */
112
118
  debugOverlay: false,
113
119
  /** Diagnostic stderr trace of each decision. */
@@ -136,6 +142,14 @@ export function normalizeConfig(raw) {
136
142
  || config.adaptiveMinRounds < 1) {
137
143
  config.adaptiveMinRounds = DEFAULT_CONFIG.adaptiveMinRounds;
138
144
  }
145
+ // The fan-out caps are advertised in the prompt text, so keep them in the
146
+ // range the policy can honestly claim rather than passing a wild number on.
147
+ for (const [key, max] of [['parallelWriteFanout', 8], ['parallelReadFanout', 12]]) {
148
+ const value = config[key];
149
+ config[key] = typeof value === 'number' && Number.isFinite(value)
150
+ ? Math.min(max, Math.max(1, Math.round(value)))
151
+ : DEFAULT_CONFIG[key];
152
+ }
139
153
  return config;
140
154
  }
141
155