dsh-lean-router 1.0.9 → 2.0.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.
Files changed (148) hide show
  1. package/NOTICE.md +2 -4
  2. package/README.en.md +47 -43
  3. package/README.md +45 -41
  4. package/cordis.patch.yml +4 -26
  5. package/docs/agents/domain.md +1 -1
  6. package/docs/architecture.en.md +51 -86
  7. package/docs/architecture.md +46 -77
  8. package/docs/changelog.en.md +32 -1
  9. package/docs/changelog.md +32 -1
  10. package/docs/configuration.en.md +25 -56
  11. package/docs/configuration.md +14 -45
  12. package/docs/install.en.md +2 -2
  13. package/docs/install.md +2 -2
  14. package/docs/quickstart.en.md +29 -34
  15. package/docs/quickstart.md +11 -16
  16. package/docs/release-checklist.en.md +3 -4
  17. package/docs/release-checklist.md +5 -6
  18. package/docs//350/267/257/347/224/261-/350/256/276/350/256/241/350/257/264/346/230/216.md +2 -2
  19. package/lib/index.js +9 -61
  20. package/lib/router.js +15 -148
  21. package/package.json +4 -15
  22. package/presets/base/frag-lean.patch.yml +1 -5
  23. package/presets/base/frag-preset.patch.yml +1 -3
  24. package/presets/base/frag-router.patch.yml +1 -12
  25. package/presets/base/frag-toolface.patch.yml +0 -2
  26. package/presets/base/lean-router.patch.yml +1 -4
  27. package/scripts/doctor.mjs +15 -10
  28. package/test/integration-preset.test.mjs +4 -3
  29. package/test/plugin-entry.test.mjs +15 -50
  30. package/test/router.test.mjs +7 -47
  31. package/assets/gating.weights.json +0 -13
  32. package/assets/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
  33. package/assets/skills/ask-matt/SKILL.md +0 -80
  34. package/assets/skills/ask-matt/agents/openai.yaml +0 -5
  35. package/assets/skills/chief-of-staff/SKILL.md +0 -76
  36. package/assets/skills/chief-of-staff/agents/openai.yaml +0 -5
  37. package/assets/skills/code-review/SKILL.md +0 -91
  38. package/assets/skills/code-review/agents/openai.yaml +0 -5
  39. package/assets/skills/codebase-design/DEEPENING.md +0 -37
  40. package/assets/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
  41. package/assets/skills/codebase-design/SKILL.md +0 -116
  42. package/assets/skills/codebase-design/agents/openai.yaml +0 -5
  43. package/assets/skills/diagnosing-bugs/SKILL.md +0 -140
  44. package/assets/skills/diagnosing-bugs/agents/openai.yaml +0 -5
  45. package/assets/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -44
  46. package/assets/skills/domain-modeling/ADR-FORMAT.md +0 -47
  47. package/assets/skills/domain-modeling/GLOSSARY-FORMAT.md +0 -60
  48. package/assets/skills/domain-modeling/SKILL.md +0 -76
  49. package/assets/skills/domain-modeling/agents/openai.yaml +0 -5
  50. package/assets/skills/grilling/SKILL.md +0 -52
  51. package/assets/skills/grilling/agents/openai.yaml +0 -5
  52. package/assets/skills/handoff/SKILL.md +0 -17
  53. package/assets/skills/handoff/agents/openai.yaml +0 -5
  54. package/assets/skills/implement/SKILL.md +0 -55
  55. package/assets/skills/implement/agents/openai.yaml +0 -5
  56. package/assets/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
  57. package/assets/skills/improve-codebase-architecture/SKILL.md +0 -72
  58. package/assets/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
  59. package/assets/skills/loop-me/SKILL.md +0 -33
  60. package/assets/skills/loop-me/agents/openai.yaml +0 -5
  61. package/assets/skills/pr/CREDITS.md +0 -3
  62. package/assets/skills/pr/SKILL.md +0 -172
  63. package/assets/skills/pr/agents/openai.yaml +0 -5
  64. package/assets/skills/prototype/LOGIC.md +0 -67
  65. package/assets/skills/prototype/SKILL.md +0 -28
  66. package/assets/skills/prototype/UI.md +0 -112
  67. package/assets/skills/prototype/agents/openai.yaml +0 -5
  68. package/assets/skills/research/SKILL.md +0 -14
  69. package/assets/skills/research/agents/openai.yaml +0 -5
  70. package/assets/skills/retro/SKILL.md +0 -45
  71. package/assets/skills/retro/agents/openai.yaml +0 -5
  72. package/assets/skills/setup-matt-pocock-skills/SKILL.md +0 -121
  73. package/assets/skills/setup-matt-pocock-skills/agents/openai.yaml +0 -5
  74. package/assets/skills/setup-matt-pocock-skills/domain.md +0 -51
  75. package/assets/skills/setup-matt-pocock-skills/issue-tracker-github.md +0 -50
  76. package/assets/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +0 -46
  77. package/assets/skills/setup-matt-pocock-skills/issue-tracker-local.md +0 -30
  78. package/assets/skills/setup-matt-pocock-skills/triage-labels.md +0 -15
  79. package/assets/skills/setup-ts-deep-modules/SKILL.md +0 -103
  80. package/assets/skills/setup-ts-deep-modules/agents/openai.yaml +0 -5
  81. package/assets/skills/setup-ts-deep-modules/dependency-cruiser.config.cjs +0 -95
  82. package/assets/skills/software-factory/EXAMPLE-TASKS.md +0 -80
  83. package/assets/skills/software-factory/GIT-HOSTS.md +0 -84
  84. package/assets/skills/software-factory/OBSERVABILITY-PLATFORMS.md +0 -75
  85. package/assets/skills/software-factory/RUNNERS.md +0 -94
  86. package/assets/skills/software-factory/SKILL.md +0 -99
  87. package/assets/skills/software-factory/TICKET-TRACKERS.md +0 -85
  88. package/assets/skills/tdd/SKILL.md +0 -40
  89. package/assets/skills/tdd/agents/openai.yaml +0 -5
  90. package/assets/skills/tdd/mocking.md +0 -59
  91. package/assets/skills/tdd/tests.md +0 -77
  92. package/assets/skills/teach/GLOSSARY-FORMAT.md +0 -35
  93. package/assets/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
  94. package/assets/skills/teach/MISSION-FORMAT.md +0 -31
  95. package/assets/skills/teach/RESOURCES-FORMAT.md +0 -32
  96. package/assets/skills/teach/SKILL.md +0 -141
  97. package/assets/skills/teach/agents/openai.yaml +0 -5
  98. package/assets/skills/to-questionnaire/SKILL.md +0 -55
  99. package/assets/skills/to-questionnaire/agents/openai.yaml +0 -5
  100. package/assets/skills/to-spec/SKILL.md +0 -76
  101. package/assets/skills/to-spec/agents/openai.yaml +0 -5
  102. package/assets/skills/to-tickets/SKILL.md +0 -106
  103. package/assets/skills/to-tickets/agents/openai.yaml +0 -5
  104. package/assets/skills/triage/AGENT-BRIEF.md +0 -207
  105. package/assets/skills/triage/OUT-OF-SCOPE.md +0 -105
  106. package/assets/skills/triage/SKILL.md +0 -113
  107. package/assets/skills/triage/agents/openai.yaml +0 -5
  108. package/assets/skills/wait-what/SKILL.md +0 -8
  109. package/assets/skills/wait-what/agents/openai.yaml +0 -5
  110. package/assets/skills/wayfinder/SKILL.md +0 -129
  111. package/assets/skills/wayfinder/agents/openai.yaml +0 -5
  112. package/assets/skills/wizard/SKILL.md +0 -46
  113. package/assets/skills/wizard/agents/openai.yaml +0 -5
  114. package/assets/skills/wizard/template.sh +0 -223
  115. package/assets/skills/writing-beats/SKILL.md +0 -44
  116. package/assets/skills/writing-beats/agents/openai.yaml +0 -5
  117. package/assets/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
  118. package/assets/skills/writing-for-agents/SKILL.md +0 -83
  119. package/assets/skills/writing-for-agents/agents/openai.yaml +0 -5
  120. package/assets/skills/writing-fragments/SKILL.md +0 -80
  121. package/assets/skills/writing-fragments/agents/openai.yaml +0 -5
  122. package/assets/skills/writing-shape/SKILL.md +0 -59
  123. package/assets/skills/writing-shape/agents/openai.yaml +0 -5
  124. package/assets/skills.matrix.json +0 -311
  125. package/docs/HANDOFF-2026-11-22.md +0 -155
  126. package/docs/matrix.en.md +0 -57
  127. package/docs/matrix.md +0 -57
  128. package/docs//346/212/200/350/203/275/351/227/250/346/216/247-/350/256/276/350/256/241/350/257/264/346/230/216.md +0 -134
  129. package/docs//351/235/242/346/235/277-/350/256/276/350/256/241/350/257/264/346/230/216.md +0 -205
  130. package/lib/audit-commands.js +0 -289
  131. package/lib/audit-sink.js +0 -137
  132. package/lib/client.js +0 -276
  133. package/lib/gate-runner.js +0 -179
  134. package/lib/skill-provider.js +0 -167
  135. package/lib/skillgate.js +0 -396
  136. package/lib/skills-panel.js +0 -322
  137. package/scripts/check-drift.mjs +0 -24
  138. package/skills.manifest.json +0 -287
  139. package/test/audit-commands.test.mjs +0 -325
  140. package/test/audit-sink.test.mjs +0 -150
  141. package/test/client-plugin.test.mjs +0 -123
  142. package/test/gate-run.test.mjs +0 -173
  143. package/test/manifest.test.mjs +0 -25
  144. package/test/provider.test.mjs +0 -21
  145. package/test/skillgate-provider.test.mjs +0 -122
  146. package/test/skillgate.test.mjs +0 -217
  147. package/test/skills-panel.test.mjs +0 -114
  148. package/ui/go.json +0 -19
package/NOTICE.md CHANGED
@@ -1,15 +1,14 @@
1
1
  # NOTICE
2
2
 
3
- 本包(dsh-lean-router)站在四个上游的肩膀上,均按 MIT 或其声明的许可条款再分发。本表是**贡献映射表**:上游 → 贡献到本包的层 → 本包中的承载文件。各上游的 LICENSE 全文保留在其原仓库;以下仅摘录 MIT 声明的版权行(非全文)。
3
+ 本包(dsh-lean-router)站在三个上游的肩膀上,均按 MIT 或其声明的许可条款再分发。本表是**贡献映射表**:上游 → 贡献到本包的层 → 本包中的承载文件。各上游的 LICENSE 全文保留在其原仓库;以下仅摘录 MIT 声明的版权行(非全文)。
4
4
 
5
- ## 四上游致谢表
5
+ ## 三上游致谢表
6
6
 
7
7
  | 上游 | 版本 / 基线 | 贡献到本包的层 | 本包承载位置 | 许可(版权行摘录) |
8
8
  |---|---|---|---|---|
9
9
  | dsh-flash-presets(LarryE135) | 0.3.2 | lean 四机制(轮次压缩/输出裁剪/关插件/行为纪律)、plan-mode v1、delivery-gate、glob/grep 并发标记、preset 双档形态 | lib/lean/*(compaction/pruner/disabled/persona-text/plan-mode/delivery-gate/tool-concurrency)、presets/base/frag-lean.patch.yml | MIT — Copyright (c) 2026 LarryE135 |
10
10
  | dsh-codemode(dsh-codemode contributors) | 0.3.0,main @ f9758ec | toolface 掩蔽接缝(ToolExecutor describe/execute)、code_run 传输与并发池、meta 发现 4 工具、三视图 scope 归因、retention 双清理 | lib/toolface/*(8 模块 file-for-file vendored,适配点以注释标注)、presets/base/frag-toolface.patch.yml | MIT — Copyright (c) 2026 dsh-codemode contributors |
11
11
  | dsh-routing-suite(yjh051108) | 0.3.3(@dsh-external/dsh-super-injector) | 思考链路由**思想**(行为带分类、近场引导、反稀释勤勉自检的轻量化)——只移植实测结论,未搬运其旧线代码 | lib/router.js、lib/bands.js(实现重写,头部注明思想来源) | MIT — Copyright (c) 2026 yjh051108 |
12
- | mattpocock skills | 31 个技能正文 | skills 数据源与内置副本兜底、门控层评分数据 | assets/skills/(31 目录)、assets/skills.matrix.json、skills.manifest.json | MIT(沿用既有 NOTICE 口径;正文经主人引入本地 ~/.dsh/skills,本包以内置副本作 vendored fallback) |
13
12
 
14
13
  ## 逐文件 vendored 映射(摘要)
15
14
 
@@ -20,6 +19,5 @@
20
19
  - **lib/lean/disabled.js**:flash-lean-ptc-v3.patch.yml L155-202 的 6 行 disabled 清单照抄。
21
20
  - **lib/toolface/**(8 模块):upstream dsh-codemode 0.3.0 lib/{index,rules,executor,discovery,scope,pool,retention,transport}.js,file-for-file vendored @ f9758ec;适配:插件名/日志前缀改本包、native executor 依赖动态 import + 安装提示 stub、Symbol 键与 TAG 标注。
22
21
  - **lib/router.js / lib/bands.js**:routing-suite 思想移植(非代码);关键实测结论(三带 persona 非连续、V4.1 Flash 阈值型最优解)已在 bands.js L1-7 头注注明。
23
- - **assets/skills/**:mattpocock 31 技能正文副本(tier bundled 兜底;一级来源仍是 ~/.dsh/skills 同名目录)。
24
22
 
25
23
  按 MIT 要求,各上游的版权与许可声明随再分发保留;对本包的修改(适配点)均在文件头部注明,未删除上游署名信息。
package/README.en.md CHANGED
@@ -1,69 +1,73 @@
1
1
  # dsh-lean-router
2
2
 
3
- [![CI](https://github.com/ShawnSun-Debug/dsh-lean-router/actions/workflows/ci.yml/badge.svg)](https://github.com/ShawnSun-Debug/dsh-lean-router/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Node](https://img.shields.io/badge/node-24-brightgreen.svg)](https://nodejs.org)
3
+ A DeepSeek Harness (DSH) cordis plugin tuned for DeepSeek V4.1 Flash: **one plugin card** fusing three layers — the lean token-saving four mechanisms (flash-presets measured tuning), `code_run` tool masking (the codemode seam), and thinking-chain routing across three bands (routing-suite ideas).
4
4
 
5
- A DeepSeek Harness (DSH) cordis plugin tuned for DeepSeek V4.1 Flash: **one plugin card** fusing six layers — the lean token-saving four mechanisms (flash-presets measured tuning), `code_run` tool masking (the codemode seam), thinking-chain routing across three bands (routing-suite ideas), gated auto-invocation of 31 mattpocock skills, an audit channel and a (in-progress) panel.
5
+ Chinese version: [README.md](./README.md).
6
6
 
7
- > This package documents bilingually with the **"Chinese default + English `.en.md` files"** scheme: Chinese is the first language (README.md and docs/*.md), English lives in same-directory `.en.md` files (this file ↔ [README.md](./README.md)). All three upstream projects follow the same "Chinese README + README.en.md" convention.
7
+ ## The three layers
8
8
 
9
- > Status: **v1.0.4 published** (npm: [dsh-lean-router](https://www.npmjs.com/package/dsh-lean-router) · GitHub Release [v1.0.4](https://github.com/ShawnSun-debug/dsh-lean-router/releases/tag/v1.0.4) · CI green; real-machine DSH profile install smoke record: [docs/release-checklist.md](docs/release-checklist.md)).
10
-
11
- ## Layers at a glance
12
-
13
- | Layer | Modules | One line |
9
+ | Layer | Code | Job |
14
10
  |---|---|---|
15
- | lean (ticket 03) | lib/lean/ | turn compaction 0.25/20000 · output pruning 8192/4096/1024 · six disabled plugins · dual-tier discipline (lean 13 + 3 soft gates / balance 3) + delivery gate + glob/grep concurrency marking |
16
- | toolface (ticket 04) | lib/toolface/ | tools outside the preset (MCP etc.) are hidden from the request surface, discovered via `code_tools_search` inside programs; the `code_run` transport |
17
- | router (ticket 05) | lib/router.js · lib/bands.js | spec/react/weak bands + the `[router] band=` directive + near-field guides (zero-write) + /band /skill |
18
- | skillgate (ticket 06) | lib/skillgate.js · lib/skill-provider.js | scores all 31 skills per turn -> tier -> ds-* arbitration -> 8k soft degrade -> near-field mount/hint |
19
- | audit (ticket 07, in flight) | audit channel in lib/skillgate.js | in-memory ring buffer (256) + subscription; JSONL persistence and the ui panel are in flight |
20
- | panel (ticket 07, in flight) | ui/ | panel card (decision rows + score table + token comparison + banner), **not accepted yet** |
11
+ | lean | lib/lean/ | turn compaction (thresholdRatio 0.25 / retainTokens 20000), tool-output pruning (8192/4096/1024), six redundant plugins turned off, two behaviour-discipline tiers (lean 13 rules / balance 3 rules), plan-mode v1, plus two add-ons: the delivery gate and glob/grep concurrency markers |
12
+ | toolface | lib/toolface/ | hides every tool the preset does not own from the **model-facing request** (`mcp__` prefix plus everything outside the preset) and keeps `code_run` as the only transport; a program can still discover and call the masked tools |
13
+ | router | lib/router.js · lib/bands.js | spec/react/weak bands + the `[router] band=` directive + near-field guides (zero-write) + a diligence reminder every 10 turns + the `/band` command |
14
+
15
+ > Since 2.0.0 the **skills subsystem is gone entirely**: no bundled mattpocock 31 skills, no per-turn scoring gate, no audit channel and no skills panel UI. See the [changelog](./docs/changelog.en.md).
21
16
 
22
17
  ## Target DSH
23
18
 
24
- engines: `>=0.2.1-rc.5 <0.2.4-0` (measured baseline 0.2.3-alpha.2, still compatible back to 0.2.1-rc.5). DSH is in developer preview; breaking changes are handled by the engines gate + the doctor self-check + a warn banner, never by silent degradation.
19
+ engines: `>=0.2.1-rc.5 <0.2.4-0` (measured baseline 0.2.3-alpha.2, still compatible back to 0.2.1-rc.5). DSH is in developer preview; breaking changes are handled by the engines gate and the doctor self-check, never by silent degradation.
25
20
 
26
21
  ## Install
27
22
 
28
- Not published yet; start with a local link (both paths in [docs/quickstart.en.md](docs/quickstart.en.md)):
29
-
30
23
  ~~~powershell
31
- dsh plugin --profile desktop add "link:D:\path\to\dsh-lean-router"
32
- # once published: dsh plugin --profile desktop add npm:dsh-lean-router@1.0.4
24
+ dsh plugin --profile desktop add npm:dsh-lean-router@2.0.0
33
25
  ~~~
34
26
 
35
- The package depends on `@deepseek-ai/dsh-tool-executor-native`; if missing, the masking layer fails loudly — the executor stub throws an error with install guidance on the first `describe` (lib/toolface/executor.js L57-63). Follow it with `npm install` or re-add via `dsh plugin add`.
27
+ After restarting DSH, pick **Lean router** (the lean tier) or **Lean router (balance)** (the weaker-constraint tier) for new sessions. For local development install from a `link:` path; see [quickstart](docs/quickstart.en.md).
28
+
29
+ ## Usage
36
30
 
37
- ## Quick start
31
+ 1. Presets: **Lean router** (13 rules + 3 soft gates + routing) or **Lean router (balance)** (3 rules, no routing directives yet).
32
+ 2. Explicit routing directive, written in the first real user message:
38
33
 
39
- 1. Restart DSH, pick the **Lean router** preset (or **Lean router (balance)**) for new sessions.
40
- 2. Optional: start the first message with `[router] band=spec|react|weak|auto [task=<one line>]`.
41
- 3. Commands: `/band` to view/switch the band, `/skill` to list skills, `/compact` for manual compaction.
42
- 4. Health check: `node scripts/doctor.mjs` (7 checks) -> `npm run verify` (includes the build --check reversal check; 8 gates together with doctor) -> `npm test`.
34
+ ~~~text
35
+ [router] band=spec
36
+ [router] band=react task=split the home page into components
37
+ [router] band=auto
38
+ ~~~
43
39
 
44
- ## Documentation
40
+ 3. Commands: `/band` to view or switch the band, `/compact` for manual compaction.
41
+ 4. Masking is automatic: the model's tool list only contains the preset's own tools plus `code_run`; MCP and out-of-preset tools are discovered inside a `code_run` program with `tools.code_tools_search(...)`.
45
42
 
46
- Five topics bilingual (Chinese default, `*.en.md` in English):
43
+ ## Docs
47
44
 
48
- | Topic | Chinese | English |
45
+ | Topic | English | 中文 |
49
46
  |---|---|---|
50
- | Quickstart | [docs/quickstart.md](docs/quickstart.md) | [docs/quickstart.en.md](docs/quickstart.en.md) |
51
- | Architecture | [docs/architecture.md](docs/architecture.md) | [docs/architecture.en.md](docs/architecture.en.md) |
52
- | Configuration | [docs/configuration.md](docs/configuration.md) | [docs/configuration.en.md](docs/configuration.en.md) |
53
- | Skill matrix | [docs/matrix.md](docs/matrix.md) | [docs/matrix.en.md](docs/matrix.en.md) |
54
- | Changelog | [docs/changelog.md](docs/changelog.md) | [docs/changelog.en.md](docs/changelog.en.md) |
47
+ | Architecture | [architecture.en.md](docs/architecture.en.md) | [architecture.md](docs/architecture.md) |
48
+ | Configuration | [configuration.en.md](docs/configuration.en.md) | [configuration.md](docs/configuration.md) |
49
+ | Quickstart | [quickstart.en.md](docs/quickstart.en.md) | [quickstart.md](docs/quickstart.md) |
50
+ | Install | [install.en.md](docs/install.en.md) | [install.md](docs/install.md) |
51
+ | Changelog | [changelog.en.md](docs/changelog.en.md) | [changelog.md](docs/changelog.md) |
52
+ | Release checklist | [release-checklist.en.md](docs/release-checklist.en.md) | [release-checklist.md](docs/release-checklist.md) |
55
53
 
56
- The 4 Chinese design notes from earlier tickets stay in docs/: [routing](docs/路由-设计说明.md) · [skill gating](docs/技能门控-设计说明.md) · [tool masking wiring](docs/工具遮蔽-接线说明.md) · [disabled-plugin review](docs/复核-关插件清单.md).
54
+ Internal engineering notes are Chinese only: [routing](docs/路由-设计说明.md) · [tool-masking wiring](docs/工具遮蔽-接线说明.md) · [disabled-plugin review](docs/复核-关插件清单.md).
55
+
56
+ ## Self-check
57
+
58
+ ~~~powershell
59
+ npm test # node --test "test/*.test.mjs"
60
+ npm run build # rebuild cordis.patch.yml (base + 4 fragments, fixed order)
61
+ npm run doctor # 11 structural checks
62
+ npm run verify # build --check (byte-identical) + doctor
63
+ ~~~
57
64
 
58
- ## v1 status (stated honestly)
65
+ ## Current state (stated plainly)
59
66
 
60
- - **Audit panel in flight** (ticket 07): the audit channel is ready; the `ui/go.json` panel is not accepted yet.
61
- - **The balance preset row carries no routing directive** (v1 ruling; the lean row already has ROUTER_PROMPT spliced in).
62
- - **The plan-mode section keeps the flash wording verbatim** (including the PTC `run_code` sentence).
63
- - **Gate fallback mode**: when the host skill-registry cache is serving, per-turn gating runs through the injection seam and audits are labeled `mode: "fallback-cached-list"`.
64
- - **8k soft degradation**: when the gate injection estimate exceeds `tokenBudget 8000`, low-score skills drop a tier with no count cap.
65
- - **Sole effective preset row**: the frag-preset.patch.yml union snapshot is the only effective preset row (cordis patches replace preset rows as whole keys).
67
+ - The balance preset carries no routing directives yet.
68
+ - The plan-mode policy paragraph keeps the upstream flash text (including the PTC `run_code` sentence).
69
+ - Tool masking depends on `@deepseek-ai/dsh-tool-executor-native`; when it is missing the executor degrades to an install-hint stub and the first `describe` throws instead of failing silently.
66
70
 
67
- ## License and acknowledgments
71
+ ## License and credits
68
72
 
69
- MIT, see [LICENSE](LICENSE). The four-upstream contribution map and license statements are in [NOTICE.md](NOTICE.md): dsh-flash-presets (LarryE135) · dsh-codemode (dsh-codemode contributors) · dsh-routing-suite (yjh051108) · mattpocock skills (the 31 skill bodies).
73
+ MIT, see [LICENSE](LICENSE). The upstream contribution map and license statements are in [NOTICE.md](NOTICE.md): dsh-flash-presets (LarryE135) · dsh-codemode (dsh-codemode contributors) · dsh-routing-suite (yjh051108).
package/README.md CHANGED
@@ -1,69 +1,73 @@
1
1
  # dsh-lean-router
2
2
 
3
- [![CI](https://github.com/ShawnSun-Debug/dsh-lean-router/actions/workflows/ci.yml/badge.svg)](https://github.com/ShawnSun-Debug/dsh-lean-router/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Node](https://img.shields.io/badge/node-24-brightgreen.svg)](https://nodejs.org)
3
+ 为 DeepSeek V4.1 Flash 调校的 DeepSeek Harness(DSH)cordis 插件:**一张插件卡**里融合三层——lean 省 token 四机制(flash-presets 实测口径)、`code_run` 工具遮蔽(codemode 接缝)、思考链路由三带(routing-suite 思想)。
4
4
 
5
- 为 DeepSeek V4.1 Flash 调校的 DeepSeek Harness(DSH)cordis 插件:**一张插件卡**里融合六层——lean 省 token 四机制(flash-presets 实测口径)、code_run 工具遮蔽(codemode 接缝)、思考链路由三带(routing-suite 思想)、mattpocock 31 技能门控自动调用、审计通道与(进行中的)面板。
5
+ 英文版:[README.en.md](./README.en.md)。
6
6
 
7
- > 本包双语文档采用 **「中文默认 + 英文 `.en.md` 独立文件」** 方案:中文是第一语言(README.md 与 docs/*.md),英文版同目录 `.en.md`(本文件 ↔ [README.en.md](./README.en.md))。三个上游项目也遵循「中文 README + README.en.md」惯例。
7
+ ## 三层一览
8
8
 
9
- > 状态:**v1.0.4 已发布**(npm:[dsh-lean-router](https://www.npmjs.com/package/dsh-lean-router) · GitHub Release [v1.0.4](https://github.com/ShawnSun-debug/dsh-lean-router/releases/tag/v1.0.4) · CI 绿;真机安装冒烟记录见 [docs/release-checklist.md](docs/release-checklist.md))。
10
-
11
- ## 功能一图
12
-
13
- | 层 | 模块 | 一句话 |
9
+ | 层 | 代码 | 职责 |
14
10
  |---|---|---|
15
- | lean(票 03) | lib/lean/ | 轮次压缩 0.25/20000 · 输出裁剪 8192/4096/1024 · 关 6 插件 · 纪律双档(lean 13+3 软门 / balance 3)+ 交付门 + glob/grep 并发标记 |
16
- | toolface(票 04) | lib/toolface/ | 预设外工具(MCP 等)从请求面隐藏,程序内 `code_tools_search` 发现后调用;`code_run` 传输 |
17
- | router(票 05) | lib/router.js · lib/bands.js | spec/react/weak 三带 + `[router] band=` 显式指令 + 近场引导(零写入)+ /band /skill |
18
- | skillgate(票 06) | lib/skillgate.js · lib/skill-provider.js | 每轮 31 技能全量打分 → 分档 → ds-* 裁决 → 8k 软降 → 近场挂载/提示 |
19
- | audit(票 07 进行中) | lib/skillgate.js 审计通道 | 内存环形缓冲(256 条)+ 订阅;JSONL 落盘与 ui 面板在飞 |
20
- | panel(票 07 进行中) | ui/ | 面板卡片(决策行 + 得分表 + token 对比 + 黄条),**未验收** |
11
+ | lean | lib/lean/ | 轮次压缩(thresholdRatio 0.25 / retainTokens 20000)、工具输出裁剪(8192/4096/1024)、关 6 个冗余插件、行为纪律双档(lean 13 条 / balance 3 条)、plan-mode v1,外加两个加料件:交付门与 glob/grep 并发标记 |
12
+ | toolface | lib/toolface/ | 把预设不拥有的工具从**模型请求面**隐藏(`mcp__` 前缀 + 预设外全部),`code_run` 作为唯一传输;程序内仍可发现并调用被遮蔽的工具 |
13
+ | router | lib/router.js · lib/bands.js | spec/react/weak 三带 + `[router] band=` 显式指令 + 近场引导(零写入)+ 每 10 轮勤勉自检 + `/band` 命令 |
14
+
15
+ > 2.0.0 起**技能子系统已整体移除**:不再内置 mattpocock 31 技能、不再每轮打分门控、不再有审计通道与技能面板 UI。变更见 [changelog](./changelog.md)。
21
16
 
22
17
  ## 目标 DSH
23
18
 
24
- engines:`>=0.2.1-rc.5 <0.2.4-0`(实测基线 0.2.3-alpha.2,兼容回 0.2.1-rc.5)。DSH 处于 developer preview,破坏性变更将以 engines 闸 + doctor 自检 + warn 黄条应对,不做静默降级。
19
+ engines:`>=0.2.1-rc.5 <0.2.4-0`(实测基线 0.2.3-alpha.2,兼容回 0.2.1-rc.5)。DSH 处于 developer preview,破坏性变更将以 engines 闸 + doctor 自检应对,不做静默降级。
25
20
 
26
21
  ## 安装
27
22
 
28
- 未发布,先本地 link(两条路径详见 [docs/quickstart.md](docs/quickstart.md)):
29
-
30
23
  ~~~powershell
31
- dsh plugin --profile desktop add "link:D:\path\to\dsh-lean-router"
32
- # 发布后:dsh plugin --profile desktop add npm:dsh-lean-router@1.0.4
24
+ dsh plugin --profile desktop add npm:dsh-lean-router@2.0.0
33
25
  ~~~
34
26
 
35
- 依赖 `@deepseek-ai/dsh-tool-executor-native`;缺失时工具遮蔽层不静默——executor stub 首次 `describe` 抛出含安装指引的错误(lib/toolface/executor.js L57-63),按提示 `npm install` 或用 `dsh plugin add` 重装即可。
27
+ 重启 DSH 后,新会话在预设列表选择 **Lean router**(lean 档)或 **Lean router (balance)**(弱约束精简档)。本地开发用 `link:` 路径安装,见 [quickstart](docs/quickstart.md)。
36
28
 
37
- ## 快速上手
29
+ ## 用法
38
30
 
39
- 1. 重启 DSH,新会话选预设 **Lean router**(或 **Lean router (balance)**)。
40
- 2. 可选:首条消息带 `[router] band=spec|react|weak|auto [task=<一行>]`。
41
- 3. 命令:`/band` 看切带、`/skill` 列技能、`/compact` 手动压缩。
42
- 4. 体检:`node scripts/doctor.mjs`(7 项自检)→ `npm run verify`(含 build --check 反向一致,与 doctor 合计 8 道把关)→ `npm test`。
31
+ 1. 预设:**Lean router**(13 条纪律 + 3 软门 + 路由)或 **Lean router (balance)**(3 条纪律,暂不含路由指令)。
32
+ 2. 显式路由指令(写在首条真实用户消息里):
43
33
 
44
- ## 文档
34
+ ~~~text
35
+ [router] band=spec
36
+ [router] band=react task=把首页拆成组件
37
+ [router] band=auto
38
+ ~~~
45
39
 
46
- 五主题双语(中文默认,`*.en.md` 为英文版):
40
+ 3. 命令:`/band` 看切带、`/compact` 手动压缩。
41
+ 4. 工具遮蔽是自动的:模型工具列表只出现预设自有工具 + `code_run`;MCP 与预设外插件工具在 `code_run` 程序内用 `tools.code_tools_search(...)` 发现后调用。
42
+
43
+ ## 文档
47
44
 
48
45
  | 主题 | 中文 | English |
49
46
  |---|---|---|
50
- | 快速上手 | [docs/quickstart.md](docs/quickstart.md) | [docs/quickstart.en.md](docs/quickstart.en.md) |
51
- | 架构六层 | [docs/architecture.md](docs/architecture.md) | [docs/architecture.en.md](docs/architecture.en.md) |
52
- | 配置参考 | [docs/configuration.md](docs/configuration.md) | [docs/configuration.en.md](docs/configuration.en.md) |
53
- | 技能矩阵 | [docs/matrix.md](docs/matrix.md) | [docs/matrix.en.md](docs/matrix.en.md) |
54
- | 变更记录 | [docs/changelog.md](docs/changelog.md) | [docs/changelog.en.md](docs/changelog.en.md) |
47
+ | 架构 | [architecture.md](docs/architecture.md) | [architecture.en.md](docs/architecture.en.md) |
48
+ | 配置 | [configuration.md](docs/configuration.md) | [configuration.en.md](docs/configuration.en.md) |
49
+ | 快速上手 | [quickstart.md](docs/quickstart.md) | [quickstart.en.md](docs/quickstart.en.md) |
50
+ | 安装 | [install.md](docs/install.md) | [install.en.md](docs/install.en.md) |
51
+ | 变更记录 | [changelog.md](docs/changelog.md) | [changelog.en.md](docs/changelog.en.md) |
52
+ | 发布清单 | [release-checklist.md](docs/release-checklist.md) | [release-checklist.en.md](docs/release-checklist.en.md) |
53
+
54
+ 内部工程说明(中文):[路由-设计说明](docs/路由-设计说明.md) · [工具遮蔽-接线说明](docs/工具遮蔽-接线说明.md) · [复核-关插件清单](docs/复核-关插件清单.md)。
55
+
56
+ ## 自检
55
57
 
56
- 上游票产出的 4 篇中文设计说明保留在 docs/:[路由-设计说明](docs/路由-设计说明.md) · [技能门控-设计说明](docs/技能门控-设计说明.md) · [工具遮蔽-接线说明](docs/工具遮蔽-接线说明.md) · [复核-关插件清单](docs/复核-关插件清单.md)。
58
+ ~~~powershell
59
+ npm test # node --test "test/*.test.mjs"
60
+ npm run build # 重拼 cordis.patch.yml(base + 4 分片固定顺序)
61
+ npm run doctor # 11 项结构自检
62
+ npm run verify # build --check(cordis.patch.yml 反向逐字节一致)+ doctor
63
+ ~~~
57
64
 
58
- ## v1 现状(如实标注)
65
+ ## 现状(如实标注)
59
66
 
60
- - **audit 面板进行中**(票 07 在飞):审计通道已就绪,`ui/go.json` 面板未验收。
61
- - **balance 预设行暂不含路由指令**(v1 裁定;lean 行已拼接 ROUTER_PROMPT)。
62
- - **plan-mode 政策段保留 flash 原文**(含 PTC `run_code` 句)。
63
- - **门控回退模式**:宿主技能目录缓存生效时,每轮门控走注入缝,审计标注 `mode: "fallback-cached-list"`。
64
- - **8k 软降级**:门控注入估算超 `tokenBudget 8000` 时低分技能降档,个数不设上限。
65
- - **预设行唯一生效**:frag-preset.patch.yml 并集快照是唯一生效 preset 行(cordis patch 键级整体替换语义)。
67
+ - balance 预设行暂不含路由指令。
68
+ - plan-mode 政策段保留 flash 原文(含 PTC `run_code` 句)。
69
+ - 工具遮蔽依赖 `@deepseek-ai/dsh-tool-executor-native`;缺失时 executor 退化为安装提示 stub,首次 `describe` 抛错而不静默。
66
70
 
67
71
  ## 许可与致谢
68
72
 
69
- MIT,见 [LICENSE](LICENSE)。四上游贡献映射与许可声明见 [NOTICE.md](NOTICE.md):dsh-flash-presets(LarryE135)· dsh-codemode(dsh-codemode contributors)· dsh-routing-suite(yjh051108)· mattpocock skills(31 技能正文)。
73
+ MIT,见 [LICENSE](LICENSE)。上游贡献映射与许可声明见 [NOTICE.md](NOTICE.md):dsh-flash-presets(LarryE135)· dsh-codemode(dsh-codemode contributors)· dsh-routing-suite(yjh051108)。
package/cordis.patch.yml CHANGED
@@ -5,14 +5,13 @@
5
5
  # TODO(ticket-03 lean 层):compaction 0.25/20000、tool-result pruner 4096/1024、关 6 插件、lean13/balance3 persona、plan-mode v1、delivery-gate、glob/grep 并发标记
6
6
  # TODO(ticket-04 工具遮蔽层):codemode executor 遮蔽行 + code_run 传输 + meta 4 工具 + 常驻 ptc-runtime
7
7
  # TODO(ticket-05 路由层):首轮 inbox.claim 捕获 + [router] band/task 分类指令 + pre-step 近场引导 + 3 软门 + /band
8
- # TODO(ticket-06 技能门控层):skill provider rank 配置 + 每轮评分放行 + 8k 软降级 + 审计
9
8
  - insert:
10
9
  - id: preset-lean-router
11
10
  name: '@deepseek-ai/dsh-agent-preset'
12
11
  config:
13
12
  id: lean-router
14
13
  name: Lean router
15
- description: "lean 省 token × 思考链路由 × code_run 遮蔽 × mattpocock 技能自动调用(v1.0.0 骨架)"
14
+ description: "lean 省 token × 思考链路由 × code_run 遮蔽(2.0.0)"
16
15
  order: 30
17
16
  plugins:
18
17
  - id: persona
@@ -40,8 +39,6 @@
40
39
  name: '@deepseek-ai/dsh-tool-jobs'
41
40
  - id: skill-filesystem
42
41
  name: '@deepseek-ai/dsh-skill-filesystem'
43
- - id: skill-lean-router
44
- name: dsh-lean-router
45
42
  - id: tool-skill
46
43
  name: '@deepseek-ai/dsh-tool-skill'
47
44
  - id: command-goal
@@ -67,7 +64,7 @@
67
64
  config:
68
65
  id: lean-router
69
66
  name: Lean router
70
- description: "lean 省 token × 思考链路由 × code_run 遮蔽 × mattpocock 技能自动调用(lean 档:13 条纪律 + 3 软门 + 自检题钩子)。"
67
+ description: "lean 省 token × 思考链路由 × code_run 遮蔽(lean 档:13 条纪律 + 3 软门 + 自检题钩子)。"
71
68
  order: 30
72
69
  plugins:
73
70
  # 机制 4 · 行为纪律(persona 双档;lean 档 13 条硬规则 + 3 软门 + 自检题钩子)
@@ -156,8 +153,6 @@
156
153
  name: '@deepseek-ai/dsh-tool-jobs'
157
154
  - id: skill-filesystem
158
155
  name: '@deepseek-ai/dsh-skill-filesystem'
159
- - id: skill-lean-router
160
- name: dsh-lean-router
161
156
  - id: tool-skill
162
157
  name: '@deepseek-ai/dsh-tool-skill'
163
158
  - id: command-goal
@@ -334,8 +329,6 @@
334
329
  name: '@deepseek-ai/dsh-tool-jobs'
335
330
  - id: skill-filesystem
336
331
  name: '@deepseek-ai/dsh-skill-filesystem'
337
- - id: skill-lean-router
338
- name: dsh-lean-router
339
332
  - id: tool-skill
340
333
  name: '@deepseek-ai/dsh-tool-skill'
341
334
  - id: command-goal
@@ -527,8 +520,6 @@
527
520
  name: '@deepseek-ai/dsh-tool-jobs'
528
521
  - id: skill-filesystem
529
522
  name: '@deepseek-ai/dsh-skill-filesystem'
530
- - id: skill-lean-router
531
- name: dsh-lean-router
532
523
  - id: tool-skill
533
524
  name: '@deepseek-ai/dsh-tool-skill'
534
525
  - id: command-goal
@@ -565,32 +556,21 @@
565
556
  debug: true
566
557
  # dsh-lean-router 票 05 路由层分片(顶层列表续项;由 scripts/build-bundle.mjs 续接进 cordis.patch.yml)
567
558
  # 钩子行:agent/inbox/claimed 首轮捕获 + 近场引导 dynamic context + 勤勉自检
568
- # 命令行:/band 显式改档、/skill 技能与 invocation 列表(宿主 ctx.commands 缝)
559
+ # 命令行:/band 显式改档(宿主 ctx.commands 缝)
569
560
  # 入口子路径 dsh-lean-router/router 需要 package.json exports 增补 "./router": "./lib/router.js"
570
561
  # (package.json 为共享文件,由 master 统一集成;见 lib/router.js ROUTER_INJECTION_NOTES.patchEntry)
571
562
  - insert:
572
- # 1.0.5 修:宿主层裸包名行(对照 dsh-cost-meter 的 "one host row")。
573
- # 没有这一行,客户端模块扫描看不到 dsh.client -> 客户端 bundle 不加载 -> 无顶栏按钮。
574
- # config.provider=false:不重复注册 skill provider(预设层已注册)。
575
- - id: lean-router-client-host
576
- name: dsh-lean-router
577
563
  - id: lean-router-router
578
564
  name: dsh-lean-router/router
579
565
  config:
580
566
  hooks: true
581
567
  commands: false
582
568
  diligenceEvery: 10
583
- # 1.0.5 修:每轮门控必须开,否则 skillgate 不跑 -> 审计零条目、审计文件从不生成。
584
- # 依据 lib/router.js:345(cfg.hooks && cfg.gate 才建 runner)与 lib/router.js:194。
585
- gate: true
586
569
  - id: lean-router-commands
587
570
  name: dsh-lean-router/router
588
571
  config:
589
572
  hooks: false
590
573
  commands: true
591
- # master 集成(票 07 §9.1):审计落盘开;auditPath/weightsPath 省略 = 默认值
592
- # (注意不能传空串:lib/router.js:145-149 对空串抛错,缺省语义见 §9.1 修正版)
593
- audit: true
594
574
  # dsh-lean-router frag-preset.patch.yml - master 集成产物(票 03/04/05/06 preset 行收敛)
595
575
  # 唯一生效 owner:cordis patch 键级整体替换 + 本片在 FRAGMENTS 最后 → apply 时以本片为准。
596
576
  # frag-lean / frag-toolface 的同 id 覆写保留原文件(其自测不动),apply 时被本片覆盖。
@@ -602,7 +582,7 @@
602
582
  config:
603
583
  id: lean-router
604
584
  name: Lean router
605
- description: "lean 省 token × 思考链路由 × code_run 遮蔽 × mattpocock 技能自动调用(lean 档:13 条纪律 + 3 软门 + 自检题钩子)。"
585
+ description: "lean 省 token × 思考链路由 × code_run 遮蔽(lean 档:13 条纪律 + 3 软门 + 自检题钩子)。"
606
586
  order: 30
607
587
  plugins:
608
588
  - id: persona
@@ -693,8 +673,6 @@
693
673
  name: '@deepseek-ai/dsh-tool-jobs'
694
674
  - id: skill-filesystem
695
675
  name: '@deepseek-ai/dsh-skill-filesystem'
696
- - id: skill-lean-router
697
- name: dsh-lean-router
698
676
  - id: tool-skill
699
677
  name: '@deepseek-ai/dsh-tool-skill'
700
678
  - id: command-goal
@@ -6,7 +6,7 @@
6
6
 
7
7
  - 根目录 **`GLOSSARY.md`**(若存在)
8
8
  - **`docs/adr/`** 下与你要动的区域相关的 ADR
9
- - `docs/` 下已有的设计说明(架构、配置、路由、工具遮蔽、技能门控等),与当前课题相关时读
9
+ - `docs/` 下已有的设计说明(架构、配置、路由、工具遮蔽等),与当前课题相关时读
10
10
 
11
11
  以上任一不存在就**静默继续**:不要提它们的缺失,也不要主动建议先建。`/domain-modeling`(经 `/grilling --docs` 与 `/improve-codebase-architecture` 到达)在术语或决策真正定案时才惰性创建。
12
12
 
@@ -1,102 +1,67 @@
1
1
  # Architecture
2
2
 
3
- > One diagram, six layers: **lean → toolface → router → skillgate → audit → panel**, all collapsed into a single cordis plugin card (one preset plus a few top-level rows). English version of [architecture.md](./architecture.md).
4
-
5
- ## Six-layer diagram
3
+ > Three layers in one picture: **lean -> toolface -> router**, all inside a single cordis plugin card (one preset plus a few top-level rows). Chinese original: [architecture.md](./architecture.md).
6
4
 
7
5
  ~~~text
8
- ┌──────────────────────────────────────────────────────────────────────┐
6
+ ┌─────────────────────────────────────────────────────────────────────┐
9
7
  │ DSH host (engines >=0.2.1-rc.5 <0.2.4-0) │
10
- ├──────────────────────────────────────────────────────────────────────┤
11
- │ preset preset-lean-router (frag-preset.patch.yml snapshot = sole owner)│
12
- │ │
13
- │ (1) lean layer (ticket 03) compaction + delegation groups + persona│
14
- │ - mech 1 turn compaction thresholdRatio 0.25 / retainTokens 20000│
15
- │ - mech 2 output pruning 8192/4096/1024 (host executes) │
16
- │ - mech 3 six disabled delegation group + top tool-plugin-manager│
17
- │ - mech 4 discipline lean 13 rules + 3 soft gates + hooks / │
18
- │ balance 3 rules │
19
- │ - add-on delivery gate lean-delivery-gate (enabled:false, 2) │
20
- │ - add-on concurrency lean-concurrency (glob/grep isConcurrencySafe)│
21
- │ (2) toolface layer (ticket 04) dsh-lean-router/toolface │
22
- │ - mask ['mcp__'] + everything outside preset scope; code_run │
23
- │ transport; four meta tools │
24
- │ - executor: describe() masks + execute() denies direct calls │
25
- │ (3) router layer (ticket 05) two instances lean-router-router / │
26
- │ lean-router-commands │
27
- │ - first-turn [router] band=... capture; band near-field guides; │
28
- │ /band /skill │
29
- │ (4) skillgate layer (ticket 06) skill-lean-router provider + per-turn │
30
- │ - score all 31 -> tier -> ds-* arbitration -> 8k soft degrade -> │
31
- │ near-field render │
32
- │ (5) audit (ticket 07, in flight) in-memory ring buffer (256) + subs │
33
- │ (6) panel (ticket 07, in flight) ui/go.json panel card (in progress) │
34
- └──────────────────────────────────────────────────────────────────────┘
8
+ ├─────────────────────────────────────────────────────────────────────┤
9
+ │ preset preset-lean-router (the union snapshot in frag-preset.patch.yml)│
10
+ │ │
11
+ │ 1) lean layer (ticket 03) │
12
+ │ - turn compaction: thresholdRatio 0.25 / retainTokens 20000 │
13
+ │ - tool-output pruning: 8192 / 4096 / 1024 + marker │
14
+ │ - six redundant plugins off; two discipline tiers (lean 13 / balance 3) │
15
+ │ - plan-mode v1 folded in │
16
+ │ 2) toolface layer (ticket 04) │
17
+ │ - describe() keeps only preset tools + code_run │
18
+ │ - execute() refuses direct calls to masked names │
19
+ │ 3) router layer (ticket 05) │
20
+ │ - first-turn [router] band= capture; three-band guides; /band │
21
+ ├─────────────────────────────────────────────────────────────────────┤
22
+ │ top-level rows: preset-lean-router-balance / lean-delivery-gate / │
23
+ │ lean-concurrency / lean-router-router / │
24
+ │ lean-router-commands │
25
+ └─────────────────────────────────────────────────────────────────────┘
35
26
  ~~~
36
27
 
37
- ### (1) lean layer (lib/lean/, parameters + pure-function ports; execution lives in host plugins)
38
-
39
- - **Mech 1, turn compaction**: lib/lean/compaction.js L20-25 pins the tuning `thresholdRatio: 0.25, retainTokens: 20000, compactionRetries: 1, auto: true` (copied from the flash measurements); actual compaction is done by the host `@deepseek-ai/dsh-compaction-basic`. The host default is 0.8 (an 800k trigger on a 1M window); lean uses 0.25 = 250k. Measured 2026-11-09 over 109 runs: peak context median 20k, max 126k — this knob is currently a safety net, not the token saver (cordis.patch.yml L197-200 comment, same text at frag-lean.patch.yml L147-150).
40
- - **Mech 2, output pruning**: lib/lean/pruner.js L22-26 pins `thresholdChars: 8192, headChars: 4096, tailChars: 1024`; keep head (structure) + tail (conclusion), replace the middle with a fixed marker (`PRUNE_MARKER`, L19). Execution belongs to the host `dsh-compaction-tool-result-pruner`; `pruneText()` is a same-criteria pure-function port.
41
- - **Mech 3, six disabled plugins**: lib/lean/disabled.js L16-23 lists `tool-subagent-codex`, `tool-subagent-claude-code`, `workflow-ptc`, `tool-workflow`, `tool-ralph`, `tool-plugin-manager`; `disabled: true` rows do not load and their schemas never reach the system prompt.
42
- - **Mech 4, discipline persona**: lib/lean/persona-text.js — lean tier: 13 hard rules + 3 soft gates (CLARIFY→PLAN→DELIVER) + self-check hooks (diligence ~every 10 turns / close-the-book); balance tier: 3 rules. Rule 7 drops the flash-only "run_code is the only tool" clause (this package is native+code_run); everything else is verbatim.
43
- - **plan-mode v1**: lib/lean/plan-mode.js is a line-for-line copy of the flash section (L93-107); the trailing PTC `run_code` sentence is **kept verbatim** (v1 ruling, see changelog).
44
- - **Add-on, delivery gate**: lib/lean/delivery-gate.js — when the workspace has verify.ps1/verify.sh, the harness runs it when a turn stops; on failure it steers back the tail output, at most `maxRounds` (default 2) times per session; at least `MIN_GAP_MS = 15000` between runs (L55); off by default (`enabled: false`; `DSH_DELIVERY_GATE=0/1` overrides); with the host `dsh-llm` package missing, scripts still run and the steer-back is explicitly skipped.
45
- - **Add-on, concurrency marking**: lib/lean/tool-concurrency.js — adds `isConcurrencySafe = () => true` to the registered glob/grep definitions so native multi-calls truly parallelize; 500ms fast sweep (first 60s) then a 5s backstop; disable with `DSH_LEAN_ROUTER_CONCURRENCY=0` (also accepts `DSH_FLASH_PRESETS_CONCURRENCY=0`).
46
-
47
- ### (2) toolface layer (lib/toolface/, vendored codemode 0.3.0 @ f9758ec)
48
-
49
- Four jobs (lib/toolface/index.js L17-27): register the discovery tools, register the `code_run` transport, install the masking executor, and supply the Code Mode instructions.
50
-
51
- - **Masking rules**: rules.js L16 `DEFAULT_HIDDEN_PREFIXES = ['mcp__']`; L19 the four meta tools `code_tools_list / code_tools_search / code_tools_describe / code_debug`; L45 `DEFAULT_RUN_TOOL_NAME = 'code_run'` (`run_code` is reserved by DSH and the registry refuses to register it); L69 `maxParallelSubCalls: 10`. A second, scope-based rule (`nativeScope: true`) masks everything outside the preset scope (global MCP/bundles, per-agent tool sets).
52
- - **Three-view attribution**: scope.js L87-113 resolves global/preset/agent name sets through the registry's public `get(name, scope)` to answer "does the preset own this tool?"; without a scope tag attribution is inert and only the name rules apply.
53
- - **Executor seam**: executor.js L124-188 — `describe()` filters with `isMaskedName` before delegating (the request surface = preset composition + transport); `execute()` denies model-direct calls to masked names **before dispatch**, hinting `code_tools_search` (L226-228); `code_run` itself is always allowed (L222). Program sub-calls are admitted via the `Symbol.for('dsh-codemode.nested')` signal marker plus the `:ptc:` call-id suffix (L92-97).
54
- - **Transport**: transport.js — the `code_run` tool hands the TypeScript program to the `ptcRuntime` service; sub-calls go through the registry's public `execute()` with the full pipeline (validation/policy/approval), and pool.js reproduces the ordering contract (parallel cap 10, exclusive barrier); `abandon()+drain()` at program end stops late sub-calls (L317-323).
55
- - **Retention**: retention.js — retained REPL environments are tracked per (agent, provider) with two cleanup layers (agent-scope effect + plugin-scope dispose), making the leak unrepresentable.
56
- - **Missing-dependency stub**: see "Stub behavior" in [quickstart.en.md](./quickstart.en.md).
57
-
58
- ### (3) router layer (lib/router.js + lib/bands.js)
59
-
60
- - **Three bands**: bands.js L10 `BAND_IDS = ["spec","react","weak"]`. spec = inspect-and-plan (read-first, narrow); react = hands-on-production (write-first, wide); weak = model-routed (the only inner-routing window, few-shot classification). The ideas are ported from routing-suite measurements (V4.1 Flash: neutral + classify few-shot + three anchors = 96% routing, 100% single-task completion); the **implementation is rewritten, no upstream code copied**.
61
- - **Explicit directive**: bands.js L114-124 parses `[router] band=<spec|react|weak|auto> [task=...]`; `auto` clears the override and returns to automatic classification.
62
- - **First-turn capture**: router.js L234 listens on `agent/inbox/claimed` and only accepts `message.source.kind === 'user'`; once routed, the band is kept (keywords never change it).
63
- - **Near-field guide**: router.js L237-245 registers the dynamic context `lean-router:guide` (order 220); text is constant within a band → the host's equality check makes it a zero-write → cache stays warm. It deliberately avoids the pre-step append channel (which would durably write history).
64
- - **Diligence self-check**: `diligenceEvery` defaults to 10 (L36); the turn number is embedded so text only changes when the check fires.
65
- - **Commands**: `/band`, `/skill` (L249-260); the preset mounts two instances: `lean-router-router` (hooks:true, commands:false, diligenceEvery:10) + `lean-router-commands` (hooks:false, commands:true) (frag-router.patch.yml).
66
- - **Inherited sessions**: `skipInherited` defaults to true — subagents/forks with inherited history skip routing.
28
+ > 2.0.0 removed the former 4) skillgate, 5) audit and 6) panel layers: no bundled 31 skills, no per-turn scoring gate, no audit channel and no skills panel UI.
67
29
 
68
- ### (4) skillgate layer (lib/skillgate.js + lib/skill-provider.js)
30
+ ## 1) lean layer (lib/lean/)
69
31
 
70
- - **Provider**: skill-provider.js L22 `DEFAULT_RANK = 350` (overrides the default 400 of ~/.dsh/skills so this package owns same-named skills' invocation flags). Two-tier sources: same-named skills prefer `~/.dsh/skills` (tier user), falling back to the `assets/skills` copies (tier bundled); invocation always follows `assets/skills.matrix.json` (model/user flags decided by the owner).
71
- - **Gate off = nothing changes**: `list()` returns all 31 skills by default; gating only engages when the caller passes `list({ leanGate: state })` explicitly (L141-147).
72
- - **Per-turn pipeline** (skillgate.js L286-331): `scoreSkills` (score all 31: signal A scenario mapping + complexBoost + signal B keyword hits +1 each) → `classifyTiers` (`autoScore 2` / `hintScore 1`, L44-45) → `arbitrate` (when ds-* are active, engineering-scene mattpocock skills drop auto→hint, L55-58) → `degrade` (when the injection estimate exceeds `tokenBudget 8000` (L46), low-score autos drop to hint; no count cap) → `renderAdmission` (English near-field text on the `lean-router:skills` channel) → audit trail.
73
- - **Cache fallback**: the host `SkillRegistry.collect()` caches per (cwd, scopeChain, revision) and calls `provider.list()` only on a miss — so per-turn gating runs through the injection seam instead of re-calling list, and audit entries carry `mode: "fallback-cached-list"` (L311).
74
- - **Audit**: `AUDIT_FORMAT_VERSION = 1` (L26); `createAuditChannel` (L250-279) is an in-memory ring buffer (default 256) with subscriptions, **not persisted** — panel consumption belongs to ticket 07.
32
+ - **Entry**: `lib/lean/index.js`, loaded by a row inside the preset union snapshot.
33
+ - **Turn compaction**: `compaction.js`, ratio 0.25 / retain 20000 tokens / one retry / automatic.
34
+ - **Output pruning**: `pruner.js`, 8192 / 4096 / 1024 characters per tool class with a truncation marker.
35
+ - **Disabled plugins**: `disabled.js` turns six redundant plugins off.
36
+ - **Behaviour discipline**: `persona-text.js` supplies the lean 13-rule and balance 3-rule suffixes.
37
+ - **plan-mode v1**: `plan-mode.js` (the upstream flash policy text).
38
+ - **Add-ons**: `delivery-gate.js` (off by default, two-round delivery gate) and `tool-concurrency.js` (glob/grep concurrency markers, on by default), each on its own top-level row.
75
39
 
76
- ### (5) audit + (6) panel (ticket 07, in flight)
40
+ ## 2) toolface layer (lib/toolface/)
77
41
 
78
- - Audit side: attaching the skillgate decision stream to a sink and persisting the audit JSONL is ticket 07's in-flight work; the v1 code ships the in-memory channel described above.
79
- - Panel side: the `ui/go.json` panel card (decision rows + collapsed full-score table + token comparison + warning banner) is **in progress, not accepted**; this ticket (08) does not touch `ui/**`.
42
+ - **Rules**: `rules.js` - the masking predicate (`hiddenPrefixes`, default `['mcp__']`) and `normalizeConfig` validation.
43
+ - **Scope**: `scope.js` - decides which tools count as the preset's own.
44
+ - **Discovery**: `discovery.js` - the four meta tools (`code_tools_search` and friends).
45
+ - **Transport**: `transport.js` - `code_run` hands a TypeScript program to the `ptcRuntime` service; sub-calls go through the registry's public `execute()` so they keep the full pipeline (validation/policy/approval).
46
+ - **Pool**: `pool.js` - an ordered concurrency pool (parallel cap 10, exclusive barrier); a finished program runs `abandon()+drain()` against late sub-calls.
47
+ - **Executor**: `executor.js` - `describe()` *is* the model-facing request surface; `execute()` refuses direct calls to masked names before dispatch; real execution is delegated to `@deepseek-ai/dsh-tool-executor-native` (a missing dependency degrades to an install-hint stub).
80
48
 
81
- ## Preset rows and patch assembly
49
+ ## 3) router layer (lib/router.js - lib/bands.js)
82
50
 
83
- - scripts/build-bundle.mjs concatenates HEADER + presets/base/lean-router.patch.yml + `frag-lean → frag-toolface → frag-router → frag-preset` into the root cordis.patch.yml (847 lines); `npm run build -- --check` verifies it byte-identically in reverse.
84
- - **frag-preset.patch.yml is the sole effective preset row** (master's integration product, generated by scripts/integrate-preset.mjs): cordis patches replace preset rows as whole keys, so the same-id overrides in frag-lean/frag-toolface wipe each other; frag-preset folds the base 12 rows + lean rows + toolface row into one union snapshot and is declared last. Its lean persona suffix already has ROUTER_PROMPT spliced in (Routing: before acting on any new task, classify it...).
85
- - **Balance row** (inserted by frag-lean) has 3 rules and **no routing directive** in v1 (its suffix ends with a placeholder comment).
86
- - Beyond the preset there are 4 top-level rows: `lean-delivery-gate` (enabled:false, maxRounds:2), `lean-concurrency` (enabled:true), `lean-router-router`, `lean-router-commands`.
51
+ - **Three bands**: `bands.js` - spec (inspect first, read-first) / react (produce directly, write-first) / weak (model-routed).
52
+ - **First-turn capture**: `agent/inbox/claimed` only accepts `source.kind === 'user'`; the `[router] band=... task=...` directive wins over keyword classification.
53
+ - **Near-field guide**: `ctx.systemPrompt.context()` registers a dynamic context (order 220); the text is constant within a band, so the host's equality check writes nothing.
54
+ - **Diligence reminder**: appended every `diligenceEvery` (default 10) turns.
55
+ - **Commands**: `/band`; the preset splits two instances: `lean-router-router` (hooks:true, commands:false, diligenceEvery:10) and `lean-router-commands` (hooks:false, commands:true) in frag-router.patch.yml.
87
56
 
88
- ## Directory index
57
+ ## File responsibilities
89
58
 
90
- | Path | Contents |
59
+ | File | Responsibility |
91
60
  |---|---|
92
- | lib/index.js | cordis plugin entry (skill provider mount, rank 350) |
93
- | lib/lean/ | 8 lean-layer modules (parameters/pure functions/plugin objects) |
94
- | lib/toolface/ | 8 toolface-layer modules (vendored codemode) |
95
- | lib/router.js, lib/bands.js | router layer |
96
- | lib/skillgate.js, lib/skill-provider.js | gate + provider |
97
- | presets/base/ | 1 template + 4 fragments (frag-lean/frag-toolface/frag-router/frag-preset) |
98
- | scripts/ | build-bundle / check-drift / doctor / integrate-preset / install / verify |
99
- | assets/skills/ + skills.matrix.json + skills.manifest.json | 31 bundled skill copies and the model/user matrix |
100
- | test/ | 20 test files |
101
- | docs/ | bilingual docs (this directory) + 4 Chinese design notes (from upstream tickets, kept in Chinese) |
102
- | ui/ | ticket 07 panel (in progress; untouched by this ticket) |
61
+ | lib/index.js | cordis plugin entry (package root; a no-op since 2.0.0, kept as a valid plugin shape) |
62
+ | lib/bands.js | band definitions and keyword classification |
63
+ | lib/router.js | routing: capture / near-field guide / diligence / `/band` |
64
+ | lib/lean/* | compaction, pruning, disabled plugins, discipline, plan-mode, delivery gate, concurrency markers |
65
+ | lib/toolface/* | masking, `code_run` transport, discovery tools, pool, executor |
66
+ | presets/base/*.patch.yml | fragments that `scripts/build-bundle.mjs` assembles into cordis.patch.yml |
67
+ | scripts/ | build-bundle / doctor / verify / install / integrate-preset |