dsh-lean-router 0.0.0-stage → 0.2.3
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/LICENSE +21 -0
- package/NOTICE.md +23 -0
- package/README.en.md +73 -0
- package/README.md +72 -2
- package/cordis.patch.yml +870 -0
- package/docs/adr/0001-token-ledger-durable-usage.md +11 -0
- package/docs/agents/domain.md +38 -0
- package/docs/agents/issue-tracker.md +44 -0
- package/docs/agents/release.md +24 -0
- package/docs/agents/triage-labels.md +13 -0
- package/docs/agents/verification.md +32 -0
- package/docs/architecture.en.md +67 -0
- package/docs/architecture.md +66 -0
- package/docs/changelog.en.md +266 -0
- package/docs/changelog.md +269 -0
- package/docs/configuration.en.md +57 -0
- package/docs/configuration.md +57 -0
- package/docs/install.en.md +60 -0
- package/docs/install.md +60 -0
- package/docs/quickstart.en.md +75 -0
- package/docs/quickstart.md +75 -0
- package/docs/release-checklist.en.md +82 -0
- package/docs/release-checklist.md +131 -0
- package/docs//345/244/215/346/240/270-/345/205/263/346/217/222/344/273/266/346/270/205/345/215/225.md +108 -0
- package/docs//345/267/245/345/205/267/351/201/256/350/224/275-/346/216/245/347/272/277/350/257/264/346/230/216.md +140 -0
- package/docs//350/267/257/347/224/261-/350/256/276/350/256/241/350/257/264/346/230/216.md +104 -0
- package/lib/bands.js +149 -0
- package/lib/index.js +12 -0
- package/lib/lean/compaction.js +119 -0
- package/lib/lean/delivery-gate.js +312 -0
- package/lib/lean/disabled.js +61 -0
- package/lib/lean/history-budget.js +301 -0
- package/lib/lean/history-downgrade.js +345 -0
- package/lib/lean/index.js +19 -0
- package/lib/lean/output-slim.js +271 -0
- package/lib/lean/persona-text.js +111 -0
- package/lib/lean/plan-mode.js +31 -0
- package/lib/lean/pruner.js +75 -0
- package/lib/lean/tool-concurrency.js +319 -0
- package/lib/lean/usage-ledger.js +442 -0
- package/lib/router.js +287 -0
- package/lib/token-ledger/index.js +147 -0
- package/lib/token-ledger/live.js +193 -0
- package/lib/toolface/discovery.js +297 -0
- package/lib/toolface/executor.js +323 -0
- package/lib/toolface/index.js +242 -0
- package/lib/toolface/pool.js +160 -0
- package/lib/toolface/retention.js +187 -0
- package/lib/toolface/rules.js +395 -0
- package/lib/toolface/scope.js +188 -0
- package/lib/toolface/transport.js +335 -0
- package/package.json +65 -4
- package/presets/base/frag-lean.patch.yml +459 -0
- package/presets/base/frag-preset.patch.yml +274 -0
- package/presets/base/frag-router.patch.yml +17 -0
- package/presets/base/frag-toolface.patch.yml +73 -0
- package/presets/base/lean-router.patch.yml +44 -0
- package/scripts/build-bundle.mjs +45 -0
- package/scripts/doctor.mjs +35 -0
- package/scripts/install-profile.mjs +113 -0
- package/scripts/install.mjs +20 -0
- package/scripts/integrate-preset.mjs +107 -0
- package/scripts/release.mjs +145 -0
- package/scripts/verify.mjs +8 -0
- package/test/build.test.mjs +7 -0
- package/test/history-budget.test.mjs +210 -0
- package/test/history-downgrade.test.mjs +379 -0
- package/test/integration-preset.test.mjs +59 -0
- package/test/lean-compaction.test.mjs +47 -0
- package/test/lean-concurrency.test.mjs +117 -0
- package/test/lean-delivery-gate.test.mjs +75 -0
- package/test/lean-frag.test.mjs +132 -0
- package/test/lean-modules.test.mjs +112 -0
- package/test/lean-pruner.test.mjs +42 -0
- package/test/output-slim.test.mjs +212 -0
- package/test/package.test.mjs +20 -0
- package/test/patch-yaml.test.mjs +45 -0
- package/test/plugin-entry.test.mjs +26 -0
- package/test/router-bands.test.mjs +98 -0
- package/test/router.test.mjs +215 -0
- package/test/token-ledger-live.test.mjs +351 -0
- package/test/token-ledger.test.mjs +264 -0
- package/test/toolface-executor.test.mjs +302 -0
- package/test/toolface-mask.test.mjs +258 -0
- package/test/toolface-rules.test.mjs +177 -0
- package/test/toolface-runtime.test.mjs +466 -0
- package/test/toolface-wiring.test.mjs +272 -0
- package/test/usage-ledger-inject.test.mjs +50 -0
- package/test/usage-ledger.test.mjs +399 -0
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
# dsh-lean-router · frag-lean.patch.yml —— 票 03 lean 层(机制 1-4 + plan-mode v1 + 交付门 + 并发标记)
|
|
2
|
+
# 本分片由 build 脚本按固定顺序续接到顶层 YAML 块序列(scripts/build-bundle.mjs:base 后按
|
|
3
|
+
# frag-lean → frag-toolface → frag-router 合并);顶层为块序列续项,多操作形态参照上游
|
|
4
|
+
# flash-presets/cordis.patch.yml(多个 - insert: 块 + 裸 - id: 调优行)。
|
|
5
|
+
# 合并语义依据(宿主 dsh-app-boot/lib/index.js applyPatches L506-556):
|
|
6
|
+
# - 无 id 的 - insert: = 顶层追加新行;
|
|
7
|
+
# - 裸 - id: 行 = 按 id 寻址已有行,supplied 字段整体替换(config 整键替换,plugins 数组
|
|
8
|
+
# 因此整表重声明)→ 本分片第一行用裸覆写行给主模板的 preset-lean-router 重声明完整 config;
|
|
9
|
+
# - 合并复验由 master 用宿主 --dump-config 做(本票只保证分片形态与模块同源)。
|
|
10
|
+
# 数据同源:persona 双档文本 = lib/lean/persona-text.js;plan-mode v1 = lib/lean/plan-mode.js;
|
|
11
|
+
# 关 6 插件清单 = lib/lean/disabled.js;压缩/裁剪口径 = lib/lean/compaction.js 与 pruner.js。
|
|
12
|
+
|
|
13
|
+
# ============ 裸覆写行:preset-lean-router(lean 档 13 条)============
|
|
14
|
+
|
|
15
|
+
- id: preset-lean-router
|
|
16
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
17
|
+
config:
|
|
18
|
+
id: lean-router
|
|
19
|
+
name: Lean router
|
|
20
|
+
description: "lean 省 token × 思考链路由 × code_run 遮蔽(lean 档:13 条纪律 + 3 软门 + 自检题钩子)。"
|
|
21
|
+
order: 30
|
|
22
|
+
plugins:
|
|
23
|
+
# 机制 4 · 行为纪律(persona 双档;lean 档 13 条硬规则 + 3 软门 + 自检题钩子)
|
|
24
|
+
# 上游:flash-lean-ptc-v3.patch.yml L15-60;suffix 末行留票 05 路由拼接占位。
|
|
25
|
+
- id: persona
|
|
26
|
+
name: '@deepseek-ai/dsh-persona'
|
|
27
|
+
config:
|
|
28
|
+
prefix: "You are a coding agent powered by the {{model}} model."
|
|
29
|
+
# 纪律双档(lean 13 / balance 3)由 lib/lean/persona-text.js 生成,与模块保持同源。
|
|
30
|
+
suffix: |-
|
|
31
|
+
LEAN OPERATING RULES (hard constraints; they override habit and tool default wording):
|
|
32
|
+
|
|
33
|
+
BUDGET FIRST
|
|
34
|
+
1. Turn budget, not step budget. Target <=20 turns; folding calls into one turn is cheap, thrashing
|
|
35
|
+
across turns is not. Past 3x the expected turns (~60), stop and re-plan instead of looping.
|
|
36
|
+
Re-check roughly every 10 turns that this is still the shortest path; if it is not, re-plan.
|
|
37
|
+
2. Deliberate briefly. One short deliberation, then one cheap probe/command to learn the facts;
|
|
38
|
+
do not enumerate an exhaustive design before acting.
|
|
39
|
+
3. Input/answer-type tasks (submit a file or an answer): produce the SMALLEST artifact that
|
|
40
|
+
satisfies the stated constraints first; refine only while you are under the turn budget.
|
|
41
|
+
4. Gate before delivery, not after. Run ONE consolidated acceptance pass over every stated
|
|
42
|
+
criterion, quote the measured numbers, and name what you did not verify. Measure hard limits
|
|
43
|
+
with the command the judge would use (/usr/bin/time -v, ulimit -v). Over-limit is a failure even
|
|
44
|
+
when the answer is otherwise correct. Do not verify claim by claim, do not re-run a check that
|
|
45
|
+
already passed, and once the gate passes stop testing and deliver.
|
|
46
|
+
|
|
47
|
+
5. Tool choice. Inspect files with read/glob/grep; never use the shell to browse a file
|
|
48
|
+
(no cat/head/tail/sed -n/find/ls -R). Piping a command's own output through head is fine.
|
|
49
|
+
6. Output budget. Pipe or redirect long output
|
|
50
|
+
(| head -40; redirect to $env:TEMP/out.log on PowerShell, %TEMP%\out.log in cmd, /tmp/out.log on POSIX).
|
|
51
|
+
Never print a dump you could grep.
|
|
52
|
+
PARALLEL CALLS (tool calls sent together run concurrently)
|
|
53
|
+
read-only read/grep/glob/read_image: independent calls in ONE message overlap truly.
|
|
54
|
+
pwsh/edit/write run serially, yet batched they still cost one round trip.
|
|
55
|
+
Never batch a masked tool name: it rejects the whole batch, siblings never run.
|
|
56
|
+
7. Programmatic tool mode, adaptively. Fold 3+ independent calls of one logical step into ONE
|
|
57
|
+
run_code program; a single call may still go through a one-line program so its noise stays out
|
|
58
|
+
of context. Measured: pays off on multi-file/repo work (up to 8x fewer turns) and is neutral on
|
|
59
|
+
single-file algorithm tasks - there spend the budget on reasoning and testing, not batching.
|
|
60
|
+
8. Context discipline (biggest measured lever). Read only what is new; rebuild derived answers
|
|
61
|
+
from files with grep/scripts instead of re-reading them into context. Keep NOTES short and
|
|
62
|
+
factual (<=60 lines).
|
|
63
|
+
9. Author incrementally: create a file once (skeleton), then extend it with edit. Never re-emit an
|
|
64
|
+
unchanged file. After two failed shell patches, switch to the editor.
|
|
65
|
+
|
|
66
|
+
SAFETY
|
|
67
|
+
10. Honour scope literally (a new project means do not read or copy old-project files). Use
|
|
68
|
+
subagents only when the user asks or the harness delegates; never spawn them to look busy.
|
|
69
|
+
11. Never put secrets, tokens or private raw material into the session; reference by path.
|
|
70
|
+
|
|
71
|
+
WHEN BLOCKED
|
|
72
|
+
12. If two attempts at the same approach fail, change approach once; if that also fails, report the
|
|
73
|
+
blocker with the exact command and observed output instead of continuing.
|
|
74
|
+
13. Route awareness: running on provider "{{provider}}" with model "{{model}}". On a high-latency route
|
|
75
|
+
prefer fewer, larger turns; on a low-latency route more probing is affordable. Never trade
|
|
76
|
+
correctness for turn count.
|
|
77
|
+
|
|
78
|
+
SOFT GATES (each is one pause, never a stall)
|
|
79
|
+
- CLARIFY: if goal, scope, or acceptance is ambiguous in a way that changes the result, ask one consolidated question round before acting; when a cheap read/probe settles it, probe instead of asking.
|
|
80
|
+
- PLAN: work touching more than one file or more than ~8 steps starts with a numbered plan with a check per step; single-file small changes skip this gate.
|
|
81
|
+
|
|
82
|
+
SELF-CHECK HOOKS (questions answered to yourself; speak up only when a check fails)
|
|
83
|
+
- Close-the-book: could I redo the last step with the AI closed - do I actually know this fact, command, or path, or would I have to look it up again? If look-up, fetch it from the source of truth now instead of trusting recall.
|
|
84
|
+
|
|
85
|
+
# [ticket-05] 路由分类指令由票 05 拼接(本行为占位:集成时替换为票 05 的 ROUTER_PROMPT 常量)
|
|
86
|
+
- id: agent-instructions
|
|
87
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
88
|
+
config:
|
|
89
|
+
maxBytes: 65536
|
|
90
|
+
# 平台互斥(!!js 表达式,上游 lean/balance 两档同形)
|
|
91
|
+
- id: tool-bash
|
|
92
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
93
|
+
disabled: !!js process.platform === 'win32'
|
|
94
|
+
- id: tool-pwsh
|
|
95
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
96
|
+
disabled: !!js process.platform !== 'win32'
|
|
97
|
+
- id: tool-fs
|
|
98
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
99
|
+
# 上游 lean 口径:超上限不抽样、直接报告(flash-lean-ptc-v3.patch.yml L73-76;codemode/cordis.patch.yml L50-53 同值)
|
|
100
|
+
- id: tool-fs-search
|
|
101
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
102
|
+
config:
|
|
103
|
+
sampleOverCapGlobResults: false
|
|
104
|
+
- id: tool-jobs
|
|
105
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
106
|
+
- id: skill-filesystem
|
|
107
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
108
|
+
- id: tool-skill
|
|
109
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
110
|
+
- id: command-goal
|
|
111
|
+
name: '@deepseek-ai/dsh-command-goal'
|
|
112
|
+
- id: tool-goal
|
|
113
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
114
|
+
# plan-mode v1 并入(上游 flash-lean-ptc-v3.patch.yml L87-107;section 文本 = lib/lean/plan-mode.js)
|
|
115
|
+
- id: planning
|
|
116
|
+
name: cordis:group
|
|
117
|
+
group: true
|
|
118
|
+
isolate:
|
|
119
|
+
planMode: true
|
|
120
|
+
config:
|
|
121
|
+
- id: plan-mode
|
|
122
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
123
|
+
config:
|
|
124
|
+
section: |-
|
|
125
|
+
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
126
|
+
|
|
127
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
128
|
+
|
|
129
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
130
|
+
|
|
131
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
132
|
+
|
|
133
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
134
|
+
|
|
135
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation. If a review (or an ask_user_question) is aborted or times out, that is not a rejection either: do not resubmit on your own and do not switch modes yourself - tell the user it timed out and wait. Under programmatic tool mode exit_plan_mode (and ask_user_question) is reached through run_code: make it the program's only call and pass timeoutMs: 600000, because the run_code deadline includes the time the user spends reading the plan.
|
|
136
|
+
# 机制 1 + 机制 2(compaction 组;isolate 与上游一致;先裁剪再压缩的顺序由宿主保证)
|
|
137
|
+
- id: compaction
|
|
138
|
+
name: cordis:group
|
|
139
|
+
group: true
|
|
140
|
+
isolate:
|
|
141
|
+
compaction: true
|
|
142
|
+
toolResultPruner: true
|
|
143
|
+
config:
|
|
144
|
+
# FLASH TUNING(上游注释原文):该路由声明 1,000,000 窗口,dsh 默认 0.8 要到 800k 才压缩。
|
|
145
|
+
# 本预设取 0.25(250k 触发)/ 保留 20000 近期轮次。2026-11-09 实测:109 个运行
|
|
146
|
+
# 的上下文峰值中位 20k、p90 34k、最大 126k —— 250k 从未触发,这颗旋钮目前是
|
|
147
|
+
# 安全网而不是降本手段;真正压上下文的是 tool-result-pruner。
|
|
148
|
+
- id: compaction-basic
|
|
149
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
150
|
+
config:
|
|
151
|
+
thresholdRatio: 0.25
|
|
152
|
+
retainTokens: 20000
|
|
153
|
+
compactionRetries: 1
|
|
154
|
+
auto: true
|
|
155
|
+
- id: command-compact
|
|
156
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
157
|
+
# 裁剪口径 8192/4096/1024(上游 L129-133;不变量 head+marker+tail<=threshold 已由 lib/lean/pruner.js 复核)
|
|
158
|
+
- id: tool-result-pruner
|
|
159
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
160
|
+
config:
|
|
161
|
+
thresholdChars: 8192
|
|
162
|
+
headChars: 4096
|
|
163
|
+
tailChars: 1024
|
|
164
|
+
# 委派组(isolate workflowEngine;活跃三件 + 机制 3 关 6 插件清单,逐行照抄上游 L134-182)
|
|
165
|
+
- id: delegation
|
|
166
|
+
name: cordis:group
|
|
167
|
+
group: true
|
|
168
|
+
isolate:
|
|
169
|
+
workflowEngine: true
|
|
170
|
+
config:
|
|
171
|
+
- id: tool-subagent-control
|
|
172
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
173
|
+
- id: tool-subagent
|
|
174
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
175
|
+
config:
|
|
176
|
+
provider: spawn
|
|
177
|
+
toolName: subagent
|
|
178
|
+
modelSelectionSettings: true # DSH <=0.2.1 的旧名(上游注释)
|
|
179
|
+
modelSelection: true # DSH >=0.2.2:能不能选模型
|
|
180
|
+
modelDiscovery: true # DSH >=0.2.2:能不能列可选模型
|
|
181
|
+
- id: tool-subagent-fork
|
|
182
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
183
|
+
config:
|
|
184
|
+
provider: fork
|
|
185
|
+
toolName: subagent_fork
|
|
186
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
187
|
+
- id: tool-subagent-codex
|
|
188
|
+
name: "@deepseek-ai/dsh-tool-subagent"
|
|
189
|
+
disabled: true
|
|
190
|
+
config:
|
|
191
|
+
provider: "codex"
|
|
192
|
+
toolName: "subagent_codex"
|
|
193
|
+
maxDepth: "provider-managed"
|
|
194
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
195
|
+
- id: tool-subagent-claude-code
|
|
196
|
+
name: "@deepseek-ai/dsh-tool-subagent"
|
|
197
|
+
disabled: true
|
|
198
|
+
config:
|
|
199
|
+
provider: "claude-code"
|
|
200
|
+
toolName: "subagent_claude_code"
|
|
201
|
+
maxDepth: "provider-managed"
|
|
202
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
203
|
+
- id: workflow-ptc
|
|
204
|
+
name: "@deepseek-ai/dsh-workflow-ptc"
|
|
205
|
+
disabled: true
|
|
206
|
+
config:
|
|
207
|
+
provider: "spawn"
|
|
208
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
209
|
+
- id: tool-workflow
|
|
210
|
+
name: "@deepseek-ai/dsh-tool-workflow"
|
|
211
|
+
disabled: true
|
|
212
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
213
|
+
- id: tool-ralph
|
|
214
|
+
name: "@deepseek-ai/dsh-tool-ralph"
|
|
215
|
+
disabled: true
|
|
216
|
+
config:
|
|
217
|
+
subagentProvider: "spawn"
|
|
218
|
+
maxRounds: 64
|
|
219
|
+
- id: tool-ask-user
|
|
220
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
221
|
+
- id: tool-todo
|
|
222
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
223
|
+
config:
|
|
224
|
+
allowParallelInProgress: true
|
|
225
|
+
- id: tool-web
|
|
226
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
227
|
+
config:
|
|
228
|
+
fetch: true
|
|
229
|
+
searchTimeoutMs: 60000
|
|
230
|
+
- id: present
|
|
231
|
+
name: '@deepseek-ai/dsh-tool-present'
|
|
232
|
+
# 机制 3 · 第六件:插件管理工具(预设顶层,上游 L200-202)
|
|
233
|
+
- id: tool-plugin-manager
|
|
234
|
+
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
235
|
+
disabled: true
|
|
236
|
+
# live Usage 账本:订阅 session/event 采集带 usage 的 assistant/message,注册 /token-report 命令。
|
|
237
|
+
# 必须留在 preset 的 plugins 内(与 command-goal 同层)才拿得到 ctx.commands;实现 = lib/lean/usage-ledger.js。
|
|
238
|
+
- id: lean-usage-ledger
|
|
239
|
+
name: 'dsh-lean-router/lean/usage-ledger'
|
|
240
|
+
config:
|
|
241
|
+
enabled: true
|
|
242
|
+
# 旧工具结果降级:agent/pre-step(waterfall,历史定稿前)把未降级 tool/result 攒到 >32 条时
|
|
243
|
+
# 批量换成一行占位符,最近 6 条永远保留原样;DSH_LEAN_ROUTER_DOWNGRADE=0 可关。
|
|
244
|
+
# 失败安全:钩子体全包 try/catch,异常只 warn 一次、绝不阻断 step;实现 = lib/lean/history-downgrade.js。
|
|
245
|
+
- id: lean-history-downgrade
|
|
246
|
+
name: 'dsh-lean-router/lean/history-downgrade'
|
|
247
|
+
config:
|
|
248
|
+
enabled: true
|
|
249
|
+
|
|
250
|
+
# ============ 新增行:preset-lean-router-balance(balance 档 3 条;上游双预设形态,flash-lean-ptc-v3-balance 同构)============
|
|
251
|
+
|
|
252
|
+
- insert:
|
|
253
|
+
- id: preset-lean-router-balance
|
|
254
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
255
|
+
config:
|
|
256
|
+
id: lean-router-balance
|
|
257
|
+
name: "Lean router (balance)"
|
|
258
|
+
description: "约束较弱的精简档(balance 3 条纪律),适用于需要模型发挥的场景。"
|
|
259
|
+
order: 29
|
|
260
|
+
plugins:
|
|
261
|
+
# 机制 4 · 行为纪律(persona 双档;lean 档 13 条硬规则 + 3 软门 + 自检题钩子)
|
|
262
|
+
# 上游:flash-lean-ptc-v3.patch.yml L15-60;suffix 末行留票 05 路由拼接占位。
|
|
263
|
+
- id: persona
|
|
264
|
+
name: '@deepseek-ai/dsh-persona'
|
|
265
|
+
config:
|
|
266
|
+
prefix: "You are a coding agent powered by the {{model}} model."
|
|
267
|
+
# 纪律双档(lean 13 / balance 3)由 lib/lean/persona-text.js 生成,与模块保持同源。
|
|
268
|
+
suffix: |-
|
|
269
|
+
CORE RULES (only what the harness cannot enforce for you):
|
|
270
|
+
1. Answer in the user scope. Honour the requested language and the stated scope literally; do not read or copy files outside it.
|
|
271
|
+
2. Never put secrets, tokens or private raw material into the session; reference them by path.
|
|
272
|
+
3. If two attempts at the same approach fail, change approach once; if that also fails, report the blocker with the exact command and the observed output instead of continuing.
|
|
273
|
+
|
|
274
|
+
# [ticket-05] 路由分类指令由票 05 拼接(本行为占位:集成时替换为票 05 的 ROUTER_PROMPT 常量)
|
|
275
|
+
- id: agent-instructions
|
|
276
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
277
|
+
config:
|
|
278
|
+
maxBytes: 65536
|
|
279
|
+
# 平台互斥(!!js 表达式,上游 lean/balance 两档同形)
|
|
280
|
+
- id: tool-bash
|
|
281
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
282
|
+
disabled: !!js process.platform === 'win32'
|
|
283
|
+
- id: tool-pwsh
|
|
284
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
285
|
+
disabled: !!js process.platform !== 'win32'
|
|
286
|
+
- id: tool-fs
|
|
287
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
288
|
+
# 上游 lean 口径:超上限不抽样、直接报告(flash-lean-ptc-v3.patch.yml L73-76;codemode/cordis.patch.yml L50-53 同值)
|
|
289
|
+
- id: tool-fs-search
|
|
290
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
291
|
+
config:
|
|
292
|
+
sampleOverCapGlobResults: false
|
|
293
|
+
- id: tool-jobs
|
|
294
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
295
|
+
- id: skill-filesystem
|
|
296
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
297
|
+
- id: tool-skill
|
|
298
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
299
|
+
- id: command-goal
|
|
300
|
+
name: '@deepseek-ai/dsh-command-goal'
|
|
301
|
+
- id: tool-goal
|
|
302
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
303
|
+
# plan-mode v1 并入(上游 flash-lean-ptc-v3.patch.yml L87-107;section 文本 = lib/lean/plan-mode.js)
|
|
304
|
+
- id: planning
|
|
305
|
+
name: cordis:group
|
|
306
|
+
group: true
|
|
307
|
+
isolate:
|
|
308
|
+
planMode: true
|
|
309
|
+
config:
|
|
310
|
+
- id: plan-mode
|
|
311
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
312
|
+
config:
|
|
313
|
+
section: |-
|
|
314
|
+
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
315
|
+
|
|
316
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
317
|
+
|
|
318
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
319
|
+
|
|
320
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
321
|
+
|
|
322
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
323
|
+
|
|
324
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation. If a review (or an ask_user_question) is aborted or times out, that is not a rejection either: do not resubmit on your own and do not switch modes yourself - tell the user it timed out and wait. Under programmatic tool mode exit_plan_mode (and ask_user_question) is reached through run_code: make it the program's only call and pass timeoutMs: 600000, because the run_code deadline includes the time the user spends reading the plan.
|
|
325
|
+
# 机制 1 + 机制 2(compaction 组;isolate 与上游一致;先裁剪再压缩的顺序由宿主保证)
|
|
326
|
+
- id: compaction
|
|
327
|
+
name: cordis:group
|
|
328
|
+
group: true
|
|
329
|
+
isolate:
|
|
330
|
+
compaction: true
|
|
331
|
+
toolResultPruner: true
|
|
332
|
+
config:
|
|
333
|
+
# FLASH TUNING(上游注释原文):该路由声明 1,000,000 窗口,dsh 默认 0.8 要到 800k 才压缩。
|
|
334
|
+
# 本预设取 0.25(250k 触发)/ 保留 20000 近期轮次。2026-11-09 实测:109 个运行
|
|
335
|
+
# 的上下文峰值中位 20k、p90 34k、最大 126k —— 250k 从未触发,这颗旋钮目前是
|
|
336
|
+
# 安全网而不是降本手段;真正压上下文的是 tool-result-pruner。
|
|
337
|
+
- id: compaction-basic
|
|
338
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
339
|
+
config:
|
|
340
|
+
thresholdRatio: 0.25
|
|
341
|
+
retainTokens: 20000
|
|
342
|
+
compactionRetries: 1
|
|
343
|
+
auto: true
|
|
344
|
+
- id: command-compact
|
|
345
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
346
|
+
# 裁剪口径 8192/4096/1024(上游 L129-133;不变量 head+marker+tail<=threshold 已由 lib/lean/pruner.js 复核)
|
|
347
|
+
- id: tool-result-pruner
|
|
348
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
349
|
+
config:
|
|
350
|
+
thresholdChars: 8192
|
|
351
|
+
headChars: 4096
|
|
352
|
+
tailChars: 1024
|
|
353
|
+
# 委派组(isolate workflowEngine;活跃三件 + 机制 3 关 6 插件清单,逐行照抄上游 L134-182)
|
|
354
|
+
- id: delegation
|
|
355
|
+
name: cordis:group
|
|
356
|
+
group: true
|
|
357
|
+
isolate:
|
|
358
|
+
workflowEngine: true
|
|
359
|
+
config:
|
|
360
|
+
- id: tool-subagent-control
|
|
361
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
362
|
+
- id: tool-subagent
|
|
363
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
364
|
+
config:
|
|
365
|
+
provider: spawn
|
|
366
|
+
toolName: subagent
|
|
367
|
+
modelSelectionSettings: true # DSH <=0.2.1 的旧名(上游注释)
|
|
368
|
+
modelSelection: true # DSH >=0.2.2:能不能选模型
|
|
369
|
+
modelDiscovery: true # DSH >=0.2.2:能不能列可选模型
|
|
370
|
+
- id: tool-subagent-fork
|
|
371
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
372
|
+
config:
|
|
373
|
+
provider: fork
|
|
374
|
+
toolName: subagent_fork
|
|
375
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
376
|
+
- id: tool-subagent-codex
|
|
377
|
+
name: "@deepseek-ai/dsh-tool-subagent"
|
|
378
|
+
disabled: true
|
|
379
|
+
config:
|
|
380
|
+
provider: "codex"
|
|
381
|
+
toolName: "subagent_codex"
|
|
382
|
+
maxDepth: "provider-managed"
|
|
383
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
384
|
+
- id: tool-subagent-claude-code
|
|
385
|
+
name: "@deepseek-ai/dsh-tool-subagent"
|
|
386
|
+
disabled: true
|
|
387
|
+
config:
|
|
388
|
+
provider: "claude-code"
|
|
389
|
+
toolName: "subagent_claude_code"
|
|
390
|
+
maxDepth: "provider-managed"
|
|
391
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
392
|
+
- id: workflow-ptc
|
|
393
|
+
name: "@deepseek-ai/dsh-workflow-ptc"
|
|
394
|
+
disabled: true
|
|
395
|
+
config:
|
|
396
|
+
provider: "spawn"
|
|
397
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
398
|
+
- id: tool-workflow
|
|
399
|
+
name: "@deepseek-ai/dsh-tool-workflow"
|
|
400
|
+
disabled: true
|
|
401
|
+
# 机制 3 · 关插件(上游 flash-lean-ptc-v3.patch.yml 对应行;复核见 docs/复核-关插件清单.md)
|
|
402
|
+
- id: tool-ralph
|
|
403
|
+
name: "@deepseek-ai/dsh-tool-ralph"
|
|
404
|
+
disabled: true
|
|
405
|
+
config:
|
|
406
|
+
subagentProvider: "spawn"
|
|
407
|
+
maxRounds: 64
|
|
408
|
+
- id: tool-ask-user
|
|
409
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
410
|
+
- id: tool-todo
|
|
411
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
412
|
+
config:
|
|
413
|
+
allowParallelInProgress: true
|
|
414
|
+
- id: tool-web
|
|
415
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
416
|
+
config:
|
|
417
|
+
fetch: true
|
|
418
|
+
searchTimeoutMs: 60000
|
|
419
|
+
- id: present
|
|
420
|
+
name: '@deepseek-ai/dsh-tool-present'
|
|
421
|
+
# 机制 3 · 第六件:插件管理工具(预设顶层,上游 L200-202)
|
|
422
|
+
- id: tool-plugin-manager
|
|
423
|
+
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
424
|
+
disabled: true
|
|
425
|
+
# live Usage 账本(balance 档同挂):见 lean 档同名行说明。
|
|
426
|
+
- id: lean-usage-ledger
|
|
427
|
+
name: 'dsh-lean-router/lean/usage-ledger'
|
|
428
|
+
config:
|
|
429
|
+
enabled: true
|
|
430
|
+
# 旧工具结果降级(balance 档同挂):见 lean 档同名行说明。
|
|
431
|
+
- id: lean-history-downgrade
|
|
432
|
+
name: 'dsh-lean-router/lean/history-downgrade'
|
|
433
|
+
config:
|
|
434
|
+
enabled: true
|
|
435
|
+
|
|
436
|
+
# ============ 新增行:交付门(加料件)============
|
|
437
|
+
# 默认关闭(enabled: false):它会执行工作区里的验收脚本,要用户显式打开
|
|
438
|
+
# (上游 cordis.patch.yml L392-400 同口径)。插件实现 = lib/lean/delivery-gate.js;
|
|
439
|
+
# 插件行 name 为包内子路径,需 package.json exports 增加 ./lean/delivery-gate(master 集成)。
|
|
440
|
+
|
|
441
|
+
- insert:
|
|
442
|
+
- id: lean-delivery-gate
|
|
443
|
+
name: 'dsh-lean-router/lean/delivery-gate'
|
|
444
|
+
config:
|
|
445
|
+
enabled: false
|
|
446
|
+
maxRounds: 2
|
|
447
|
+
|
|
448
|
+
# ============ 新增行:glob/grep 只读并发标记(加料件)============
|
|
449
|
+
# 默认开启;关闭优先级从高到低:DSH_LEAN_ROUTER_CONCURRENCY=0(兼容 DSH_FLASH_PRESETS_CONCURRENCY=0)
|
|
450
|
+
# > 本行 config.toolConcurrency.enabled=false > 默认开启。插件实现 = lib/lean/tool-concurrency.js;
|
|
451
|
+
# 插件行 name 为包内子路径,需 package.json exports 增加 ./lean/tool-concurrency(master 集成)。
|
|
452
|
+
|
|
453
|
+
- insert:
|
|
454
|
+
- id: lean-concurrency
|
|
455
|
+
name: 'dsh-lean-router/lean/tool-concurrency'
|
|
456
|
+
config:
|
|
457
|
+
toolConcurrency:
|
|
458
|
+
enabled: true
|
|
459
|
+
|