dsh-lean-router 0.0.0-stage → 0.2.4

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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +23 -0
  3. package/README.en.md +73 -0
  4. package/README.md +72 -2
  5. package/cordis.patch.yml +870 -0
  6. package/docs/adr/0001-token-ledger-durable-usage.md +11 -0
  7. package/docs/agents/domain.md +38 -0
  8. package/docs/agents/issue-tracker.md +44 -0
  9. package/docs/agents/release.md +24 -0
  10. package/docs/agents/triage-labels.md +13 -0
  11. package/docs/agents/verification.md +32 -0
  12. package/docs/architecture.en.md +67 -0
  13. package/docs/architecture.md +66 -0
  14. package/docs/changelog.en.md +279 -0
  15. package/docs/changelog.md +282 -0
  16. package/docs/configuration.en.md +57 -0
  17. package/docs/configuration.md +57 -0
  18. package/docs/install.en.md +60 -0
  19. package/docs/install.md +60 -0
  20. package/docs/quickstart.en.md +75 -0
  21. package/docs/quickstart.md +75 -0
  22. package/docs/release-checklist.en.md +82 -0
  23. package/docs/release-checklist.md +131 -0
  24. 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
  25. 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
  26. package/docs//350/267/257/347/224/261-/350/256/276/350/256/241/350/257/264/346/230/216.md +104 -0
  27. package/lib/bands.js +149 -0
  28. package/lib/index.js +12 -0
  29. package/lib/lean/compaction.js +119 -0
  30. package/lib/lean/delivery-gate.js +312 -0
  31. package/lib/lean/disabled.js +61 -0
  32. package/lib/lean/history-budget.js +301 -0
  33. package/lib/lean/history-downgrade.js +345 -0
  34. package/lib/lean/index.js +19 -0
  35. package/lib/lean/output-slim.js +271 -0
  36. package/lib/lean/persona-text.js +111 -0
  37. package/lib/lean/plan-mode.js +31 -0
  38. package/lib/lean/pruner.js +75 -0
  39. package/lib/lean/tool-concurrency.js +319 -0
  40. package/lib/lean/usage-ledger.js +442 -0
  41. package/lib/router.js +287 -0
  42. package/lib/token-ledger/index.js +147 -0
  43. package/lib/token-ledger/live.js +193 -0
  44. package/lib/toolface/desc-slim.js +140 -0
  45. package/lib/toolface/discovery.js +297 -0
  46. package/lib/toolface/executor.js +333 -0
  47. package/lib/toolface/index.js +250 -0
  48. package/lib/toolface/pool.js +160 -0
  49. package/lib/toolface/retention.js +187 -0
  50. package/lib/toolface/rules.js +435 -0
  51. package/lib/toolface/scope.js +188 -0
  52. package/lib/toolface/transport.js +335 -0
  53. package/package.json +65 -4
  54. package/presets/base/frag-lean.patch.yml +459 -0
  55. package/presets/base/frag-preset.patch.yml +274 -0
  56. package/presets/base/frag-router.patch.yml +17 -0
  57. package/presets/base/frag-toolface.patch.yml +73 -0
  58. package/presets/base/lean-router.patch.yml +44 -0
  59. package/scripts/build-bundle.mjs +45 -0
  60. package/scripts/doctor.mjs +35 -0
  61. package/scripts/install-profile.mjs +113 -0
  62. package/scripts/install.mjs +20 -0
  63. package/scripts/integrate-preset.mjs +107 -0
  64. package/scripts/release.mjs +146 -0
  65. package/scripts/verify.mjs +8 -0
  66. package/test/build.test.mjs +7 -0
  67. package/test/history-budget.test.mjs +210 -0
  68. package/test/history-downgrade.test.mjs +379 -0
  69. package/test/integration-preset.test.mjs +59 -0
  70. package/test/lean-compaction.test.mjs +47 -0
  71. package/test/lean-concurrency.test.mjs +117 -0
  72. package/test/lean-delivery-gate.test.mjs +75 -0
  73. package/test/lean-frag.test.mjs +132 -0
  74. package/test/lean-modules.test.mjs +112 -0
  75. package/test/lean-pruner.test.mjs +42 -0
  76. package/test/output-slim.test.mjs +212 -0
  77. package/test/package.test.mjs +20 -0
  78. package/test/patch-yaml.test.mjs +45 -0
  79. package/test/plugin-entry.test.mjs +26 -0
  80. package/test/router-bands.test.mjs +98 -0
  81. package/test/router.test.mjs +215 -0
  82. package/test/token-ledger-live.test.mjs +351 -0
  83. package/test/token-ledger.test.mjs +264 -0
  84. package/test/toolface-desc-slim.test.mjs +255 -0
  85. package/test/toolface-executor.test.mjs +302 -0
  86. package/test/toolface-mask.test.mjs +258 -0
  87. package/test/toolface-rules.test.mjs +177 -0
  88. package/test/toolface-runtime.test.mjs +466 -0
  89. package/test/toolface-wiring.test.mjs +272 -0
  90. package/test/usage-ledger-inject.test.mjs +50 -0
  91. package/test/usage-ledger.test.mjs +399 -0
@@ -0,0 +1,282 @@
1
+ # 变更记录(changelog)
2
+
3
+ > 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 0.2.4)。
4
+
5
+ ## 0.2.4 (2026-11-30)
6
+
7
+ ### 变更
8
+
9
+ - **工具定义体积从 21,123 字符降到约 12,122(−42.6%)**,两个手段并用:
10
+ - **压缩描述**(`lib/toolface/desc-slim.js`):`pwsh` 3495→1265、`subagent` 1972→949、`ask_user_question` 1419→663、`edit` 1151→565,另含 `present`/`list_agents`/`subagent_fork`/`update_goal` 共 8 个,六个主要工具合计降 55.7%。压缩时保留全部会导致误用的硬约束:PowerShell 与 cmd 的 `;`/`&&` 差异、Windows 沙箱只读模式下 `.NET` 静态调用与 `Add-Type` 不可用、`run_in_background` 用法,以及 `ask_user_question` 的「必须走工具提问」和「空 selected 即跳过、不得再问」语义。
11
+ - **遮蔽低频核心工具**:`update_goal`、`list_agents`、`present`、`subagent_fork` 不再出现在请求的工具列表里,但仍可经 `code_run` 的 `search` / `describe` 发现与调用。`subagent`、`ask_user_question`、`pwsh`、`edit`、`write`、`read`、`grep`、`glob` 不受影响。
12
+ - 环境开关:`DSH_LEAN_ROUTER_DESC_SLIM=0` 关闭描述压缩,`DSH_LEAN_ROUTER_MASK_CORE=0` 放行被遮蔽的四个工具。两者都在调用时读取,可即时生效。
13
+
14
+ ### 测试
15
+
16
+ - 新增 10 项(压缩后的体积与关键词保留、fail-safe 原样返回、两个开关、遮蔽名单、以及 `describe` 确实把精简文本交给下游);全量 279 项、278 通过、0 失败、1 skip。
17
+
18
+ ## 0.2.3 (2026-11-30)
19
+
20
+ ### 变更
21
+
22
+ - **版本线切换**:从 `2.2.x` 切回 `0.2.x` 并接任 `latest`。此前的 1.x / 2.x 递增并不对应真实的兼容性承诺,包仍是实验性的;语义归零后,后续破坏性变更才敢正常用 major 表达。
23
+ - **内容与 2.2.8 完全一致**,无功能差异:包含 `history_budget` 阈值从 12000 下调到 4000(宿主 `tool-result-pruner` 会先把超 8192 的结果压成 5159,原阈值从未触发)、旧工具结果降级、并行调用引导、账本快照与 `/token-report json` 等。
24
+ - 既有 `2.2.x` 版本仍留在 registry 上,使用 `^2.2` 的消费者不会自动跟进;需要新线请显式安装 `0.2.3`。
25
+
26
+ ## 2.2.8 (2026-11-30)
27
+
28
+ ### 修复
29
+
30
+ - **history_budget 阈值从 12000 下调到 4000**:真机回读发现 2.2.4 引入的 12000 阈值**从未触发过**——宿主的 `tool-result-pruner` 会先把超过 8192 字符的工具结果压成 4096 + 标记 + 1024 = 5159 字符,实测当前会话表面上 204 条工具结果里 183 条已短于 200 字符、最大正好 5159,没有任何一条能超过 12000。降到 4000(头 2400 + 尾 1600,尾部下限 400 不变)后,本模块才会先于宿主生效。实测 41889 字符样本压到 4000(-90.5%)。
31
+ - 这个教训登记为硬约束:体积上限类优化上线后必须回读真实会话确认**触发次数**,不得以单测通过代替生效验证。
32
+
33
+ ### 测试
34
+
35
+ - 全量 269 项、268 通过、0 失败、1 skip,verify 全 PASS。
36
+
37
+ ## 2.2.7 (2026-11-30)
38
+
39
+ ### 新增
40
+
41
+ - **账本快照落盘**:账本每记录一条 usage,就把汇总原子写入 `<DSH_HOME>/storages/lean-router/token-report.json`(`DSH_HOME` 缺省为 `~/.dsh`;可用 `config.snapshotPath` 覆盖路径、`config.snapshot: false` 关闭)。这样代理用 `read` 就能直接读到与命令同源的数据,不必再由用户复制粘贴。快照含 totals 与按会话聚合的 records/prompt/input/cacheRead/cacheWrite/output/reasoning 及最近 turn/step/seq。
42
+ - **`/token-report json` 口径**:命令新增 `json`,直接输出快照文件内容(与文件字节一致);文件不存在时返回 `{"error":"snapshot missing","path":"..."}`。`session` 与 `all` 的文本格式不变。
43
+ - 写入是原子的(先写 `.tmp` 再 rename),目录自动创建;任何写入失败只 warn 一次,不影响记录与命令。
44
+
45
+ ### 测试
46
+
47
+ - 新增 6 项(默认路径与配置解析、单条记录结构、跨会话聚合、关闭开关、写失败不抛、`json` 与文件字节一致);全量 269 项、268 通过、0 失败、1 skip。
48
+
49
+ ## 2.2.6 (2026-11-29)
50
+
51
+ ### 新增
52
+
53
+ - **旧工具结果降级**:新增 `lean-history-downgrade` 插件,在 `agent/pre-step`(历史定稿前)检查模型可见的工具结果——未降级条数严格超过 32 条时批量降级,最近 6 条永远保留原样,错误结果与已降级结果跳过。改写走 `session.append` 的 `surfaceOp: replace`,原始事件保留在日志里可重放,并配套写一条 `compaction/prune`。插件全链路失败安全:钩子体整体 try/catch,异常只 warn 一次、绝不阻断 step;缺少 `surface` 相关能力时静默跳过;构造期不抛任何异常;`DSH_LEAN_ROUTER_DOWNGRADE=0` 可整体关闭。
54
+ - **为什么是 32/6**:按实测前缀约 155k token/轮与缓存价差重算,16/6 摊销后净省约 30k/轮(19%),32/6 约 52k/轮(34%),因此取 32/6。真实 Session 复测:39 条 × 12000 字符 → 选中并降级 33 条,本批省 391,974 字符,surface 长度与顺序不变,二次运行零变更。
55
+
56
+ ### 测试
57
+
58
+ - 新增 23 项(纯函数 9 项、插件 14 项);全量 263 项、262 通过、0 失败、1 skip,verify 全 PASS。
59
+
60
+ ## 2.2.5 (2026-11-29)
61
+
62
+ ### 变更
63
+
64
+ - **并行调用引导具体化**:persona 第 6 条里那句泛泛的 "Batch independent calls into one step" 实测无效——全语料 22165 条 assistant 消息中 91.65% 只携带一个工具调用,带两个及以上的仅 4.68%(lean-router 预设下 10.88%)。现改为一段 306 字符的具体引导:只读工具 `read`/`grep`/`glob`/`read_image` 的独立调用放进同一条消息可以真正重叠执行;`pwsh`/`edit`/`write` 同批虽被串行,但仍只花一次往返;不要把被遮挡的工具名混进同一批,否则整批被拒、兄弟调用都不执行。
65
+ - **不新增 façade 工具**:宿主侧 tool-calls 本身就是批量原语(数组入参、默认并发上限 10、结果按模型顺序写回),仓库侧没有任何代码限制并行,因此这一版只改引导文本。
66
+ - persona suffix 3862 → 4130 字符(+268),仍在 4200 字符上限内。
67
+
68
+ ### 测试
69
+
70
+ - 新增 12 条断言(四个只读工具名、三个写向工具名、遮挡整批拒绝、并行块 ≤320 字符、suffix ≤4200);全量 240 项、239 通过、0 失败、1 skip。
71
+
72
+ ## 2.2.4 (2026-11-29)
73
+
74
+ ### 新增
75
+
76
+ - **历史体积预算**:工具结果进入会话历史前施加 12000 字符上限——超出时保留头 60% 与尾部 40%,中段替换为一行标记,标记含被省略字符数并提示用 offset/limit 或更窄查询回读;被丢弃中段里命中错误/失败/异常/退出码/结论特征的整行最多带回 20 行。合法 JSON 不截断(保持可解析),结果恒短于原文且幂等。它接在既有输出压缩之后串联执行(`lib/toolface/executor.js`),仍只改 content 不改 value。
77
+ - **选点依据**:本机 221 个会话、21844 轮 usage 实测——prompt 的 96.6% 是 cacheRead(每轮均值 131.8k),fresh input 仅 4.6k/轮、output 1.0k/轮;首轮 prompt(静态底座)中位数 23.4k,历史部分约占每轮 83%。因此这一版打在历史体积上,而不是继续压只占 17% 的静态文本。
78
+
79
+ ### 测试
80
+
81
+ - 新增 `test/history-budget.test.mjs` 13 条;全量 239 项、238 通过、0 失败、1 skip,verify 全 PASS。
82
+ - 生产形状复测:128k 字符样本压到 12000(-90.6%),头尾逐字保留,二次调用返回同一引用。
83
+
84
+ ## 2.2.3 (2026-11-29)
85
+
86
+ ### 变更
87
+
88
+ - **移除强制开头句式**:`spec` 带不再要求推理与回复首句以 "We need …" 开头,`react` 带不再要求 "I'm doing …"。实机使用后判定该句式对路由与产出无收益,只额外增加固定 token 与表达噪音;`guideText` 现只保留任务基调与固定的收敛/反跑题锚(`GUIDE_TAIL`)。`personaText`、`ROUTER_PROMPT` 与分片均未改动。
89
+ - **测试改为反向断言**:`test/router-bands.test.mjs` 现在断言三条带的 `guideText` 都不含 "We need"、"I'm doing" 或对首句的约束,防止句式被重新加回。
90
+
91
+ ## 2.2.2 (2026-11-29)
92
+
93
+ ### 修复
94
+
95
+ - **创建会话直接失败(`agent-preset/invalid`)**:2.2.1 把 `lean-usage-ledger` 移进 preset 的 `plugins` 后,插件在 `apply` 里直接读 `ctx.commands`;cordis 4 要求先声明注入,未声明就读取会抛 `cannot get property "commands" without inject`,宿主新建与恢复会话都因此失败。插件现声明 `inject: ['commands']`(命名导出与默认导出同体):`commands` 未就绪时 cordis 等待而不是加载,命令缝始终缺席时插件静默不挂载,两种情况下都不再打断宿主;`/token-report` 行为不变。
96
+ - **回归测试**:新增 `test/usage-ledger-inject.test.mjs`,用真实 cordis 复现“先加载插件、后提供 `commands`”的顺序,断言不抛错、`commands` 出现后注册 `/token-report`。
97
+
98
+ ## 2.2.1 (2026-11-29)
99
+
100
+ ### 修复
101
+
102
+ - **`/token-report` 在真实环境不出现**:`lean-usage-ledger` 原先注册为顶层加料件(与 `lean-delivery-gate`、`lean-concurrency` 同层),但 `ctx.commands` 服务是在 preset scope 内提供的,顶层行拿不到,插件会按降级路径静默跳过。现已移入 `lean` 与 `balance` 两个 preset 的 `plugins` 数组(与 `command-goal` 同层),命令因此能真正注册。
103
+
104
+ ## 2.2.0 (2026-11-29)
105
+
106
+ ### 新增
107
+
108
+ - **`/token-report` 账本命令**:新增 `lib/lean/usage-ledger.js`,以预设顶层加料件 `lean-usage-ledger` 生效,订阅宿主的 `session/event` 并只收 `assistant/message` 且带 `usage` 的事件。命令输出记录条数、`prompt` 总量(input+cacheRead+cacheWrite)、五项分项与最近一条的 `turn/step/seq`;没有任何记录时明确说明尚未采集。所有失败路径只 warn 不抛,卸载时释放订阅。
109
+
110
+ ### 优化
111
+
112
+ - **`search` 懒取参数 schema**:`code_tools_search` 不再返回完整 `parameters` 与 `output` schema,改为返回 `params` 参数名数组(无可枚举属性时给 `noParams`);完整 schema 由 `code_tools_describe` 提供。8 行满页实测输出 8380→1924 字符(-77%)。
113
+ - **lean persona no-op 审查**:删去宿主已注入的语言要求、与规则 4 重复的 `DELIVER` 软门、与规则 1 重叠的 `Diligence` 钩子并压缩措辞,4581→3862 字符(-15.7%);13 条规则编号与全部判据保留。
114
+
115
+ ### 说明
116
+
117
+ - 三项都是静态或输出侧改动,真实收益需重启后在宿主里观察,尚未做真机验证。
118
+ - `search` 只给参数名后,调用不熟悉参数形状的工具前应先 `describe`;SDK 文本已同步改写。
119
+
120
+ ## 2.1.1 (2026-11-29)
121
+
122
+ ### 优化
123
+
124
+ - **静态工具面瘦身**:`code_run` 的 description 459→298 字符、SDK 说明 2340→1738,合计 3346→2526(-24.5%);required/enum/属性名与 `timeoutMs` 条件语义均由新增的结构契约断言锁定,每轮常驻注入因此减少约 820 字符。
125
+ - **工具输出保守压缩**:新增 `lib/lean/output-slim.js`,并在 `lib/toolface/executor.js` 的 `describe()` 里给每个可见工具就地包装 `finalizeContent`。压缩只在输出超过 2000 字符时启用:折叠相邻重复行,以及字符串数组里相邻重复元素(保留首个 + 一个 marker 元素);错误、异常、失败、退出码、路径与结论行永不折叠。JSON 输出保持可解析、键与类型不变,只改模型可见 content,不改程序内 value;原有 `finalizeContent` 会被串联而不是覆盖。
126
+
127
+ ### 说明
128
+
129
+ - 两项都是静态或输出侧的改动,真实收益需重启后在宿主里观察,尚未做真机验证。
130
+ - 输出压缩对重复日志类输出收益明显(示例 3788→172 字符),对无重复的输出不生效。
131
+
132
+ ## 2.1.0 (2026-11-29)
133
+
134
+ ### 新增
135
+
136
+ - **独立 token 账本库** `lib/token-ledger/`:`createMemoryUsageAdapter`(按 session/turn/step/seq 去重排序、范围读取与订阅)、`captureRequestSnapshot`(只保留元数据与哈希,拒绝原始 prompt 与工具输出)、`createTokenReport`(真实 Usage 与归因分离,显式断言产出 `pass`/`successRate`/`reasons`)。
137
+ - **live Usage adapter** `lib/token-ledger/live.js`:订阅宿主 `session/event`,只收带 `usage` 的 `assistant/message`;`hydrate` 用 `snapshotEvents` 半开区间补录;服务缺失、logger 异常与订阅失败均降级跳过,`dispose` 幂等。
138
+ - **包导出** `./token-ledger` 与 `./token-ledger/live`。
139
+
140
+ ### 变更
141
+
142
+ - **思考句式按 band 分流**:spec 带 `guideText` 末尾要求推理与回复第一句以 "We need …" 开头并先陈述缺口;react 带要求以 "I'm doing …" 开头并直接说明动作;weak 不加强制句式。`personaText`、`ROUTER_PROMPT` 与分片未改动。
143
+
144
+ ### 说明
145
+
146
+ - 账本当前只做 durable Usage 回放,不重跑模型;live adapter 尚未挂载到预设,运行时不会自动采集。
147
+ - 本机宿主 0.2.2-rc.5 无 costMeter 服务,历史记录不得以 cost-meter 聚合数据充当逐请求 Usage。
148
+
149
+ ## 2.0.0 (2026-11-29)
150
+
151
+ **破坏性变更:技能子系统整体移除。** 这一版只剩三层——lean 省 token、router 思考链路由、toolface 工具遮蔽。
152
+
153
+ ### 移除
154
+
155
+ - **mattpocock 技能深度合作**:`lib/skillgate.js`(每轮 31 技能全量打分、分档、ds-* 裁决、8k 软降级)、`lib/skill-provider.js`(rank 350 provider、两级来源)、`lib/gate-runner.js`(pre-step 门控接线)、`assets/skills/`(31 个技能正文副本)、`assets/skills.matrix.json`、`assets/gating.weights.json`、`skills.manifest.json` 全部删除;预设并集快照里的 `skill-lean-router` provider 行一并摘掉。
156
+ - **审计与面板**:`lib/audit-sink.js`、`lib/audit-commands.js`、`ui/go.json` 删除;`/lean-audit` 命令下线。
157
+ - **技能面板 UI**:`lib/skills-panel.js`、`lib/client.js` 删除;`/panel` 命令下线;`package.json` 去掉 `exports["./client"]` 与 `dsh.client` 声明(不再产出客户端 bundle)。
158
+ - **`/skill` 命令**下线;router 只保留 `/band`。
159
+ - `npm run drift` 脚本与 `scripts/check-drift.mjs` 删除(不再有技能副本可漂移)。
160
+ - 文档 `docs/matrix.md`、`docs/matrix.en.md`、`docs/技能门控-设计说明.md`、`docs/面板-设计说明.md`、`docs/HANDOFF-2026-11-22.md` 删除。
161
+
162
+ ### 变更
163
+
164
+ - `lib/index.js` 收敛为合法空插件(`inject = []`、`apply()` 返回 undefined);宿主层不再需要 `lean-router-client-host` 行。
165
+ - `lib/router.js` 的 `inject` 从 `["agents","systemPrompt","commands","skills"]` 收为前三项;`gate` / `audit` / `auditPath` / `weightsPath` 仍被接受但无行为(兼容旧 patch 配置,不再让插件启动失败)。
166
+ - doctor 从 7 项改为 11 项,并新增两条防回流检查:patch 不得再出现 `skill-lean-router` 与 `lean-router-client-host`。
167
+
168
+ ### 测试
169
+
170
+ - 删除 9 个技能相关测试文件;router / plugin-entry / integration-preset 断言同步收敛。当前 `npm test`:157 tests / 156 pass / 1 skip / 0 fail;`npm run verify` PASS。
171
+
172
+ ## 1.1.0 (2026-11-25)
173
+
174
+ - 变更(形态,用户拍板):技能面板从「顶栏按钮 + body 浮层」改为**右侧栏标签页**。浮层要点开、会遮挡主对话、不能并排,本身就不是可用形态,1.0.9 的 `#lean-router-panel` 浮层实现整体废弃。
175
+ - 新增:按真机范例 `@modusensus/dsh-mneme` 与 `dsh-cost-meter` 的契约接入右栏 —— 类型与引导挂 `sidebarRightTabs.register({ id, kind, title, guide })`(注册前先 `get(id)` 查重,宿主对重复 id 会抛 `tab type id … is already registered`);正文与标题挂 `sidebar.right.pane.tab` / `sidebar.right.pane.tab.title`,spec 用 `{ name, key }` 关联类型。
176
+ - 新增:顶栏「技能」按钮保留为快捷入口,点击走 `ctx.get("sidebarRight").openTab(kind)` 直接打开右栏标签。
177
+ - 修复:opener 改用 `ctx.inject(["slots"])` 就绪后的 scoped ctx 取 `sidebarRight`,避免又踩「服务还没注册」的时机坑。
178
+ - 约束:不再往 `document.body` 追加任何元素;当前版本只做壳(标题 + 两行说明),样式全部继承宿主主题 token,不写死颜色。224 测试全绿。
179
+
180
+ ## 1.0.9 (2026-11-24)
181
+
182
+ - 修复(真机,渲染):顶栏按钮能出现,但点击后面板只在那一行显示成「一条黑条」。原因是面板原先作为 React 组件渲染在顶栏 slot 内部,`position: fixed` 被祖先元素的 `transform` / `overflow` 限制在那一行里。改为挂到 `document.body` 的纯 DOM 浮层(`#lean-router-panel`),slot 里只留按钮;浮层层级提到 `2147483000`,点遮罩或 ✕ 关闭,再点按钮收起。
183
+ - 测试:新增「点按钮把面板挂到 body、再点一次移除」断言;222 测试全绿。
184
+
185
+ ## 1.0.8 (2026-11-24)
186
+
187
+ - 修复(真机,客户端时机):`lib/client.js` 的 `apply` 执行得比 `slots` 服务注册还早。此时 `ctx.get("slots")` 是 `undefined`,1.0.7 直接走 DOM 兜底,而那时 `document.body` 尚未建立 → `domFallback()` 静默 return。真机表现就是「bundle 已加载、控制台零报错、界面上什么都没有」。改为与 `dsh-cost-meter` 用 `e.inject(["locale"], …)` 同款写法:`ctx.inject(["slots"], cb)` 等服务就绪后再注册,服务变化时自动重跑。
188
+ - 改进:`register` 的 spec 补上 `inject: () => ({})` props 工厂(cost-meter 每次注册都带该字段)。
189
+ - 改进:兜底改为「2 秒后仍未注册成功才插入纯 DOM 按钮」,让「没挂上」可见,不再静默消失。
190
+ - 测试:`test/client-plugin.test.mjs` 改为覆盖三条路径——`ctx.inject(["slots"])` 就绪注册、无 `ctx.inject` 时直接注册、slots 永不出现时 2 秒后插兜底。221 测试全绿。
191
+
192
+ ## 1.0.7 (2026-11-24)
193
+
194
+ - 修复(真机致命,客户端):`lib/client.js` 取 slot 服务的方式。客户端 cordis 里 `slots` / `register` 都是**服务**,直接读 `ctx.register` / `ctx.slots` 会抛 `Error: cannot get property "register" without inject`;旧代码把这个属性访问写在 `try` 之外,一抛就整个 `apply` 失败,连纯 DOM 兜底都跑不到 —— 这正是顶栏「技能」按钮一直不出现的真因(0.2.3 控制台原文:`dsh-lean-router: failed: Error: cannot get property "register" without inject`)。改为与 `dsh-cost-meter` 一致的写法:`const slots = ctx.get("slots")`,再 `slots.inject(slot, () => slots.register(spec, Component))`;服务缺失时才退回 DOM 兜底。
195
+ - 新增回归:`test/client-plugin.test.mjs` 用假 `window.__ModuleLoader__` 加载真实 `lib/client.js`,ctx 的 `register` / `slots` 属性被故意设成「一读就抛」,断言注册只走 `ctx.get("slots")` 且返回 disposer;另一条断言服务缺失时确实插入了 `#lean-router-dom-fallback` 按钮。220 测试全绿。
196
+
197
+ ## 1.0.6 (2026-11-23)
198
+
199
+ > 1.0.5 已发到 npm,但下面两处缺陷是它在 0.2.3 真机**首次激活**时才暴露的,请直接用 1.0.6。
200
+
201
+ - 修复(真机致命):`lib/index.js` 的 `inject` 形状。cordis 的 inject 只有两种形状 —— 服务名数组,或「服务名 → 拦截配置」映射(`registry.ts: Inject<M> = (keyof M)[] | { [K in keyof M]?: M[K] }`)。1.0.5 写的 `{ required: [], optional: ["skills"] }` 被解析成两个叫 `required` / `optional` 的服务,宿主层 `lean-router-client-host` 永远 PENDING(实机诊断:`pending (waiting for services: required, optional)`),`apply` 不执行 → 客户端 bundle 不被 `dsh-client-modules` 扫描(顶栏按钮不出现)、启动自检 `boot.log` 从不生成。改为 `inject = []` + `apply` 内 `ctx.inject(["skills"], cb)`:宿主层立即激活,预设层等 skills 就绪后再注册 provider。
202
+ - 修复(真机致命):`/panel` 的 `input.hint` 是空字符串。0.2.3 的 `@deepseek-ai/dsh-commands` 在 `normalizeDefinition` 里对空 hint 抛 `TypeError: command "panel" input hint must not be empty`,整条 `lean-router-commands` 因此不激活。改为 `[summary|skills|round|stats|never] [all]`(与 `parsePanelArgs` 实际接受的参数一致)。
203
+ - 新增回归:`test/plugin-entry.test.mjs` 断言 inject 形状(不得出现 required/optional 键)、宿主作用域不碰 skills、预设作用域走 `ctx.inject`、无 `ctx.inject` 时退化;`test/router.test.mjs` 增加「每个命令的 input hint 都非空」断言。218 测试全绿。
204
+
205
+ ## 1.0.5 (2026-11-23)
206
+
207
+ ### 适配 DSH 0.2.3 内核(实测基线 0.2.3-alpha.2)
208
+
209
+ - 修复(致命):`engines.dsh` 上限 `<0.2.3-0` → `<0.2.4-0`。DSH 的兼容性校验(`@deepseek-ai/dsh-app-boot` 的 `evaluatePluginCompatibility`)用 `semver.satisfies(runtime, range, { includePrerelease: true })`;按 semver 预发布优先级 `0.2.3-0 < 0.2.3-alpha.2`,旧范围把 0.2.3-alpha.2 判为不兼容,安装与激活都会被拦。放宽后 0.2.1-rc.5 至 0.2.3 全系列都满足。
210
+ - 变更:`dependencies` 的 `@deepseek-ai/dsh-tool-executor-native` 从 `^0.2.2-alpha.3` 放宽为 `>=0.2.2-alpha.3 <0.2.4-0`。实测 0.2.3-alpha.2 与 0.2.2-rc.5 的实现逐字节相同(全文件 SHA256 对比,仅 `package.json` 变),vendored executor 无需改动。
211
+ - 变更:`peerDependencies` 的 `@deepseek-ai/cordis` 从 `~4.1.0` 放宽为 `>=4.1.0-0 <4.3.0-0`。宿主 0.2.3-alpha.2 装的是 cordis 4.2.0-alpha.1,旧区间不含 4.2 的预发布。cordis 4.2 只改内部符号(`symbols.config` → `symbols.metadata`)与 `ValidationError` 的 issue 路径处理,**effect 契约未变**;本包运行时不 import cordis,仅用其插件形状,故无需改代码。
212
+ - 复核无破坏:客户端加载契约(`dsh-client-modules` 扫描 `dsh.client` + `exports["./client"]`)与 0.2.2 一致;补丁里引用的 26 个 `@deepseek-ai/dsh-*` 插件在 0.2.3 全部仍存在。
213
+
214
+ ### 技能面板阶段 1(1.0.5 内容,此前只在提交里、未发布)
215
+
216
+ - 新增:`/panel` 命令作为技能面板的可用形态(服务端渲染,不依赖客户端 slot),并在客户端浮层上按场景分组、加子视图、隐藏全关技能、修列对齐。
217
+ - 修复(真机):包改在宿主作用域加载,客户端 bundle 才会被 `dsh-client-modules` 扫到;去掉 `react-dom` 依赖,改走 `ctx.inject`/`ctx.register`;补纯 DOM 兜底,用于区分「bundle 没加载」与「slot 没挂上」两种失败。
218
+ - 修复:技能注入改为可选,宿主那一行 patch 才真正 apply 成功;逐轮技能门控已启用。
219
+
220
+ ## 1.0.4 (2026-11-22)
221
+
222
+ - 新增(技能面板阶段 1):客户端插件骨架 —— 顶栏「技能」按钮 + 占位浮层面板(`lib/client.js`、`dsh.client.platform=web`、`exports['./client']`)。加载契约对齐 dsh 的 `window.__ModuleLoader__.load({ id, factory })`,UI 注册走 `ctx.slots.register`;面板用 `ReactDOM.createPortal` 挂 body,不依赖侧边栏。本阶段只验链路,真实数据与一键工作流在后续版本接入。
223
+ - 改进(可视化):`/band` 从「三段英文纯文本」改成一眼看清的排版 —— 第一行一行状态(如 `▲ react · 已按首条消息分类,关键词不再改带 · 可选 spec / react / weak`),中间是三带差异表格(当前档位用 `**▲ spec**` 粗体标记),末尾是「最近一次自动分类」及其依据(build/fix 词命中数 + 命中的词)。
224
+ - 新增:`lib/bands.js` 导出 `explainClassification(text)`,返回带号 + 两路命中数 + 词样例(最多 3 个);`classifyTask` 改为它的薄封装,分类结果与 1.0.3 完全一致。
225
+ - 新增:路由状态增加 `manual` 与 `last` 字段,用于区分「手动指定 / 按首条消息自动分类 / 还没分类」三种来源。近场引导文本不变(零写入契约不变)。
226
+ - 变更:`/band`(无参)与 `/band help` 等价,都输出状态面板;改档确认从 `Router band set to x.` 改为 `▲ x · 已切换`。
227
+ - 测试:`/band` 断言升级为
228
+ 「第一行是状态 / 有三带表格 / 当前档位粗体 ▲ / 无消息时明确说明」,203 测试全绿。
229
+
230
+ ## 1.0.3 (2026-11-22)
231
+
232
+ - 修复(真机致命):preset 的 plugins 列表里误挂了**宿主层服务插件** `ptc-runtime`(`@deepseek-ai/dsh-ptc-runtime-node`)。dsh 的 preset 在独立 scope 里激活,重复挂载该服务会失败 → `agentPresets.register` 抛错 → 整条 `preset-lean-router` 不注册(真机现象:预设列表只剩 balance)。该行本就由宿主 `dsh-base/cordis.patch.yml` L407-408 挂载,`code_run` 依赖的 `ctx.get('ptcRuntime')` 会向宿主层查找,preset 内无需重复声明。
233
+ - 变更:`frag-preset` 并集行 22 → 21(覆写块 20 + toolface),`cordis.patch.yml` 同步重建。
234
+ - 新增回归:`integration-preset` 与 `patch-yaml` 两处断言 preset 内不得出现 `ptc-runtime`。
235
+
236
+ ## 1.0.2 (2026-11-22)
237
+
238
+ - 修复(真机致命):`lib/lean/tool-concurrency.js` 的 `apply()` 返回了普通对象;cordis 的 effect 校验只接受 dispose 函数 / null / undefined / thenable,于是真宿主抛 `Invalid effect` —— 插件列表标红「异常」,且同一 overlay 里排在它之后的 `preset-lean-router` 行不再注册(预设列表只剩 balance)。
239
+ - 新增:`tool-concurrency` / `delivery-gate` / `router` / `toolface` 四套测试各加一条「apply 返回值必须满足 cordis effect 契约」断言,防回归。
240
+
241
+ ## 1.0.1 (2026-11-22)
242
+
243
+ - 修复:`cordis.patch.yml` 里 `ptc-runtime` 行缩进错误(dsh 解析 overlay 失败、安装被回滚)。
244
+ - 修复:`npm test` 改为 `node --test "test/*.test.mjs"`(目录参数在 Node 24 报错)。
245
+ - 新增:回归测试用 js-yaml + `!!js` 标签解析全部补丁,对齐 dsh 的 overlay 装载器。
246
+ - 杂项:js-yaml 加入 devDependencies;版本引用更新。
247
+
248
+ ## v1.0.0(2026-11-21)
249
+
250
+ 一张插件卡六个层全部落地(票 02–06 交付 + master 集成),audit 面板(票 07)进行中、真安装器(票 09)待做。
251
+
252
+ ### 新增
253
+
254
+ - **lean 层四机制**(票 03,lib/lean/):轮次压缩(thresholdRatio 0.25 / retainTokens 20000 / retries 1 / auto)、工具输出裁剪(8192/4096/1024 + marker)、关 6 插件(disabled 清单)、行为纪律双档(lean 13 条 + 3 软门 + 自检钩 / balance 3 条);加料件 delivery-gate(默认关,2 轮)与 glob/grep 并发标记(默认开)。
255
+ - **plan-mode v1 并入**(lib/lean/plan-mode.js):逐行照抄 flash L93-107。
256
+ - **toolface 层**(票 04,lib/toolface/):vendored dsh-codemode 0.3.0(main @ f9758ec)8 模块 file-for-file,适配点以注释标明;遮蔽 ['mcp__'] + 预设外全部、code_run 传输、meta 4 工具、直呼拒绝、retention 双清理、maxParallelSubCalls 10。
257
+ - **router 层**(票 05,lib/router.js + lib/bands.js):spec/react/weak 三带、[router] 显式指令、关键词自动分类、近场引导(lean-router:guide,order 220)、勤勉自检(每 10 轮)、/band 与 /skill 命令、继承会话跳过。
258
+ - **skillgate 层**(票 06,lib/skillgate.js + lib/skill-provider.js):31 技能全量每轮打分(场景映射 + 关键词双信号)、autoScore 2 / hintScore 1 分档、ds-* 场景裁决、tokenBudget 8000 软降级、近场渲染、内存审计环形缓冲、rank 350 provider、两级来源解析。
259
+ - **31 技能内置副本**(assets/skills/ + skills.matrix.json + skills.manifest.json):主人逐条拍板的双开矩阵(13 双开 / 10 仅模型 / 8 仅用户)。
260
+ - **构建与自检**(scripts/):build-bundle(base + 4 分片拼 cordis.patch.yml)、check-drift(warn-only)、doctor(7 项)、integrate-preset(生成 frag-preset 并集快照)、verify(build --check + doctor)、install(安装说明输出)。
261
+ - **exports 四子路径**(package.json):./router、./toolface、./lean/delivery-gate、./lean/tool-concurrency。
262
+ - **双语文档**(本目录 + README.md/README.en.md/NOTICE.md):五主题双语与四上游致谢表(票 08)。
263
+
264
+ ### 裁定(v1 如实记录)
265
+
266
+ - **frag-preset 并集快照 = 唯一生效 preset 行**:cordis patch 对 preset 行键级整体替换,frag-lean/frag-toolface 同 id 覆写互相清场;scripts/integrate-preset.mjs 生成并集快照、排在 FRAGMENTS 最后。
267
+ - **balance 预设行暂不含路由指令**:lean 行 suffix 已拼接 ROUTER_PROMPT,balance 行末行保留占位注释。
268
+ - **plan-mode PTC 句保留 flash 原文**:末段 "Under programmatic tool mode ... run_code" 不改(master 裁定:run_code 仍为内置 PTC 传输)。
269
+ - **门控走注入缝而非重调 list()**:宿主 SkillRegistry.collect() 缓存生效时审计标注 mode "fallback-cached-list"。
270
+ - **8k 软降级**:tokenBudget 8000,降级个数不设上限,只设总量软保险。
271
+ - **四篇中文设计说明保持中文(v1)**:docs/复核-关插件清单.md、工具遮蔽-接线说明.md、技能门控-设计说明.md、路由-设计说明.md 为内部工程文档;英文用户读 README.en.md 与 docs 五主题。
272
+ - **ptc-runtime 服务行由 master 补挂**:codemode 上游补丁不带此行,而 code_run 的 transport 依赖 ctx.get('ptcRuntime')(lib/toolface/transport.js:221-224);按宿主 dsh-base/cordis.patch.yml L407-408 同款行挂进并集快照(frag-preset 22 行,scripts/integrate-preset.mjs EXTRA_ROWS)。
273
+
274
+ ### 引擎与依赖
275
+
276
+ - engines:`>=0.2.1-rc.5 <0.2.3-0`(实测基线 0.2.2-rc.5)。
277
+ - dependencies:`@deepseek-ai/dsh-tool-executor-native ^0.2.2-alpha.3`——缺失时 executor 退化为安装提示 stub(describe 抛错 / execute 拒绝),不静默。
278
+
279
+ ### 进行中(不在本版承诺内)
280
+
281
+ - 票 07:审计流 JSONL 落盘、ui/go.json 面板卡片(决策行 + 得分表 + token 对比 + 黄条)、命中统计 + 手动权重配置。
282
+ - 票 09:真安装器、fixture 路径注意事项、--uninstall 回滚。
@@ -0,0 +1,57 @@
1
+ # Configuration reference
2
+
3
+ > **Plugin-row config**, **commands and environment variables**, **exports subpaths**. Every option reaches `apply(ctx, options)` through a patch row's config, and an unknown key is an error (fail early). Chinese original: [configuration.md](./configuration.md).
4
+
5
+ > Since 2.0.0 the skills subsystem's gate weights and audit settings are gone. `gate` / `audit` / `auditPath` / `weightsPath` are still accepted but do nothing, so an old patch config cannot stop the plugin from starting.
6
+
7
+ ## Plugin-row config (patch row -> module)
8
+
9
+ | patch row id | name | config keys | defaults |
10
+ |---|---|---|---|
11
+ | lean-router-router | dsh-lean-router/router | diligenceEvery / hooks / commands / guideOrder / skipInherited | 10 / true / false / 220 / true |
12
+ | lean-router-commands | dsh-lean-router/router | same | 10 / false / true / 220 / true |
13
+ | lean-delivery-gate | dsh-lean-router/lean/delivery-gate | enabled / scripts / maxRounds / timeoutMs / tailChars | false / [verify.ps1,verify.sh] / 2 / 900000 / 1200 |
14
+ | lean-concurrency | dsh-lean-router/lean/tool-concurrency | toolConcurrency{enabled, tools, sweepMs} | true / [glob,grep] / 500 |
15
+ | toolface | dsh-lean-router/toolface | hiddenPrefixes / metaTools / runToolName / guard / sdkSection / debug / searchLimit / maxDescriptionChars / maxParallelSubCalls / nativeScope / nativeTools / hiddenTools | ['mcp__'] / four meta tools / code_run / true / true / true / 8 / 240 / 10 / true / [] / [] (listed in full in frag-preset.patch.yml) |
16
+
17
+ Tool-surface config validation: `normalizeConfig` (rules.js L88-125; fewer than two `metaTools` falls back to the whole default table).
18
+
19
+ ## Commands and environment variables
20
+
21
+ ### npm scripts (package.json)
22
+
23
+ | Command | What it does |
24
+ |---|---|
25
+ | npm test | `node --test "test/*.test.mjs"` |
26
+ | npm run build | rebuild cordis.patch.yml (base + 4 fragments, fixed order) |
27
+ | npm run doctor | 11 structural checks |
28
+ | npm run verify | build --check (cordis.patch.yml byte-identical) + doctor |
29
+
30
+ doctor's 11 checks: package.name, package.engines.dsh, cordis.patch.yml exists, patch has the preset row, patch has the router row, patch has no skill-provider row, patch has no client-host row, lib/router.js exists, lib/lean/index.js exists, lib/toolface/index.js exists, the client bundle is gone (scripts/doctor.mjs).
31
+
32
+ ### Session commands
33
+
34
+ | Command | Layer | What it does |
35
+ |---|---|---|
36
+ | /band | router | view or switch the band; `/band spec`, `/band auto`, `/band react task <one line>` |
37
+ | /compact | lean | trigger context compaction manually |
38
+
39
+ ### First-message directive
40
+
41
+ ~~~text
42
+ [router] band=spec|react|weak|auto [task=<one line>]
43
+ ~~~
44
+
45
+ The explicit directive wins over keyword classification (human in the loop); `auto` clears the override and returns to automatic classification.
46
+
47
+ ### Environment variables
48
+
49
+ | Variable | Effect |
50
+ |---|---|
51
+ | DSH_DELIVERY_GATE=0 | force the delivery gate off |
52
+ | DSH_DELIVERY_GATE=1 | force it on when config.enabled is absent |
53
+ | DSH_LEAN_ROUTER_CONCURRENCY=0 | turn the concurrency markers off (also accepts DSH_FLASH_PRESETS_CONCURRENCY=0) |
54
+
55
+ ## Exports subpaths (package.json)
56
+
57
+ `.` / `./package.json` / `./router` / `./toolface` / `./lean/delivery-gate` / `./lean/tool-concurrency` — the four functional subpaths match the `name` fields of the router's two instances and the two add-on rows (`dsh-lean-router/router` and friends).
@@ -0,0 +1,57 @@
1
+ # 配置参考(configuration)
2
+
3
+ > **插件行 config**、**命令与环境变量**、**exports 子路径**。所有配置经 patch 行 config 传入 `apply(ctx, options)`,未知键一律报错(失败尽早)。英文版:[configuration.en.md](./configuration.en.md)。
4
+
5
+ > 2.0.0 起技能子系统的门控权重与审计配置已移除;`gate` / `audit` / `auditPath` / `weightsPath` 仍被接受但无行为,只为兼容旧 patch 配置而不让插件启动失败。
6
+
7
+ ## 插件行 config 一览(patch 行 → 模块)
8
+
9
+ | patch 行 id | name | config 键 | 默认 |
10
+ |---|---|---|---|
11
+ | lean-router-router | dsh-lean-router/router | diligenceEvery / hooks / commands / guideOrder / skipInherited | 10 / true / false / 220 / true |
12
+ | lean-router-commands | dsh-lean-router/router | 同上 | 10 / false / true / 220 / true |
13
+ | lean-delivery-gate | dsh-lean-router/lean/delivery-gate | enabled / scripts / maxRounds / timeoutMs / tailChars | false / [verify.ps1,verify.sh] / 2 / 900000 / 1200 |
14
+ | lean-concurrency | dsh-lean-router/lean/tool-concurrency | toolConcurrency{enabled, tools, sweepMs} | true / [glob,grep] / 500 |
15
+ | toolface | dsh-lean-router/toolface | hiddenPrefixes / metaTools / runToolName / guard / sdkSection / debug / searchLimit / maxDescriptionChars / maxParallelSubCalls / nativeScope / nativeTools / hiddenTools | ['mcp__'] / 四 meta / code_run / true / true / true / 8 / 240 / 10 / true / [] / [](frag-preset.patch.yml 显式全列) |
16
+
17
+ 工具面 config 校验:`normalizeConfig`(rules.js L88-125,`metaTools` 少于 2 个整表回落默认)。
18
+
19
+ ## 命令与环境变量
20
+
21
+ ### npm scripts(package.json)
22
+
23
+ | 命令 | 作用 |
24
+ |---|---|
25
+ | npm test | `node --test "test/*.test.mjs"` |
26
+ | npm run build | 重拼 cordis.patch.yml(base + 4 分片固定顺序) |
27
+ | npm run doctor | 11 项结构自检 |
28
+ | npm run verify | build --check(cordis.patch.yml 反向逐字节一致)+ doctor |
29
+
30
+ doctor 11 项:package.name、package.engines.dsh、cordis.patch.yml 存在、patch 含预设行、patch 含路由行、patch 无技能 provider 行、patch 无客户端宿主行、lib/router.js 存在、lib/lean/index.js 存在、lib/toolface/index.js 存在、客户端 bundle 已移除(scripts/doctor.mjs)。
31
+
32
+ ### 会话命令
33
+
34
+ | 命令 | 层 | 说明 |
35
+ |---|---|---|
36
+ | /band | router | 查看/切换路由带;`/band spec`、`/band auto`、`/band react task <一行>` |
37
+ | /compact | lean | 手动触发上下文压缩 |
38
+
39
+ ### 首条用户消息指令
40
+
41
+ ~~~text
42
+ [router] band=spec|react|weak|auto [task=<一行>]
43
+ ~~~
44
+
45
+ 显式指令优先于关键词分类(人在回路);`auto` 清除覆盖回退自动。
46
+
47
+ ### 环境变量
48
+
49
+ | 变量 | 作用 |
50
+ |---|---|
51
+ | DSH_DELIVERY_GATE=0 | 强制关交付门 |
52
+ | DSH_DELIVERY_GATE=1 | config.enabled 缺省时强制开 |
53
+ | DSH_LEAN_ROUTER_CONCURRENCY=0 | 关并发标记(兼容 DSH_FLASH_PRESETS_CONCURRENCY=0) |
54
+
55
+ ## exports 子路径(package.json)
56
+
57
+ `.` / `./package.json` / `./router` / `./toolface` / `./lean/delivery-gate` / `./lean/tool-concurrency`——四个功能子路径分别对应 router 两实例与两个加料件插件行的 `name` 字段(`dsh-lean-router/router` 等)。
@@ -0,0 +1,60 @@
1
+ # Install · dsh-lean-router
2
+
3
+ > English companion of [install.md](./install.md). Release steps live in [release-checklist.en.md](./release-checklist.en.md).
4
+
5
+ ## Option 1: global npm install + DSH mount (recommended)
6
+
7
+ ```powershell
8
+ npm i -g dsh-lean-router
9
+ dsh plugin install dsh-lean-router
10
+ dsh --dump-config | Select-String "lean-router-router"
11
+ ```
12
+
13
+ ## Option 2: local tarball (offline / pre-release self-test)
14
+
15
+ ```powershell
16
+ npm pack # produces dsh-lean-router-1.0.0.tgz
17
+ npm i -g .\dsh-lean-router-1.0.0.tgz
18
+ dsh plugin install dsh-lean-router
19
+ ```
20
+
21
+ Import smoke (no conversation needed):
22
+
23
+ ```powershell
24
+ node -e "const m=require('dsh-lean-router'); console.log(Object.keys(m))"
25
+ # => [ 'apply', 'inject', 'name' ]
26
+ ```
27
+
28
+ ## Option 3: in-repo development
29
+
30
+ ```powershell
31
+ git clone https://github.com/ShawnSun-Debug/dsh-lean-router.git
32
+ cd dsh-lean-router
33
+ npm test # 200 tests / 199 pass / 1 skipped (host yaml-asar unreadable)
34
+ npm run doctor # 7 PASS
35
+ npm run build # generate bundle (cordis.patch.yml)
36
+ ```
37
+
38
+ ## Uninstall
39
+
40
+ ```powershell
41
+ dsh plugin uninstall dsh-lean-router
42
+ npm uninstall -g dsh-lean-router
43
+ dsh --dump-config | Select-String "lean-router-router" # expect no output
44
+ ```
45
+
46
+ ## Requirements
47
+
48
+ | Item | Value |
49
+ |---|---|
50
+ | Node.js | 24 (CI baseline; 22.12+ locally for `require` of ESM packages) |
51
+ | DSH | `>=0.2.1-rc.5 <0.2.4-0` (`package.json#engines.dsh`) |
52
+ | Platform | Windows / macOS / Linux (CI verifies ubuntu-latest) |
53
+
54
+ ## Troubleshooting
55
+
56
+ | Symptom | Cause | Fix |
57
+ |---|---|---|
58
+ | `ERR_PACKAGE_PATH_NOT_EXPORTED` | Subpath not in the `exports` allowlist (e.g. `dsh-lean-router/lean/persona-text`) | Use exported entries: `.`, `./router`, `./toolface`, `./lean/delivery-gate`, `./lean/tool-concurrency`, `./package.json` |
59
+ | Plugin missing from `--dump-config` | Not installed via `dsh plugin install`, or profile disabled | Reinstall and check profile config |
60
+ | 1 skipped test | Host yaml-asar unreadable (known limitation, static assertions cover it) | Nothing to do |
@@ -0,0 +1,60 @@
1
+ # 安装 · dsh-lean-router
2
+
3
+ > 中文先行,英文版见 [install.en.md](./install.en.md)。发布清单见 [release-checklist.md](./release-checklist.md)。
4
+
5
+ ## 方式一:npm 全局安装 + DSH 挂载(推荐)
6
+
7
+ ```powershell
8
+ npm i -g dsh-lean-router
9
+ dsh plugin install dsh-lean-router
10
+ dsh --dump-config | Select-String "lean-router-router"
11
+ ```
12
+
13
+ ## 方式二:本地 tarball 安装(离线 / 首发前自测)
14
+
15
+ ```powershell
16
+ npm pack # 产出 dsh-lean-router-1.0.0.tgz
17
+ npm i -g .\dsh-lean-router-1.0.0.tgz
18
+ dsh plugin install dsh-lean-router
19
+ ```
20
+
21
+ 冒烟命令(不启动对话,只验证包能导入):
22
+
23
+ ```powershell
24
+ node -e "const m=require('dsh-lean-router'); console.log(Object.keys(m))"
25
+ # => [ 'apply', 'inject', 'name' ]
26
+ ```
27
+
28
+ ## 方式三:仓库内联调(开发)
29
+
30
+ ```powershell
31
+ git clone https://github.com/ShawnSun-Debug/dsh-lean-router.git
32
+ cd dsh-lean-router
33
+ npm test # 200 tests / 199 pass / 1 skipped(宿主 yaml-asar 不可读)
34
+ npm run doctor # 7 PASS
35
+ npm run build # 生成 bundle(cordis.patch.yml)
36
+ ```
37
+
38
+ ## 卸载
39
+
40
+ ```powershell
41
+ dsh plugin uninstall dsh-lean-router
42
+ npm uninstall -g dsh-lean-router
43
+ dsh --dump-config | Select-String "lean-router-router" # 期望无输出
44
+ ```
45
+
46
+ ## 要求
47
+
48
+ | 项 | 值 |
49
+ |---|---|
50
+ | Node.js | 24(CI 口径;本地 22.12+ 起支持 `require` ESM 包) |
51
+ | DSH | `>=0.2.1-rc.5 <0.2.4-0`(`package.json#engines.dsh`) |
52
+ | 平台 | Windows / macOS / Linux(CI 在 ubuntu-latest 验证) |
53
+
54
+ ## 排错
55
+
56
+ | 现象 | 原因 | 处理 |
57
+ |---|---|---|
58
+ | `ERR_PACKAGE_PATH_NOT_EXPORTED` | 用了未在 `exports` 白名单里的子路径(如 `dsh-lean-router/lean/persona-text`) | 改用已导出的入口:`.`、`./router`、`./toolface`、`./lean/delivery-gate`、`./lean/tool-concurrency`、`./package.json` |
59
+ | `--dump-config` 查不到插件 | 未 `dsh plugin install` 或 profile 未启用 | 重新 install 并检查 profile 配置 |
60
+ | 测试 1 skipped | 宿主 yaml-asar 不可读(已知限制,静态断言已覆盖) | 无需处理 |
@@ -0,0 +1,75 @@
1
+ # Quickstart
2
+
3
+ > **dsh-lean-router** is one DeepSeek Harness (DSH) cordis plugin card: lean token saving, thinking-chain routing and `code_run` tool masking combined in a single preset. English is secondary here; the Chinese original is [quickstart.md](./quickstart.md).
4
+
5
+ ## Prerequisites
6
+
7
+ - DSH `>=0.2.1-rc.5 <0.2.4-0` (measured baseline 0.2.3-alpha.2; see the engines field in package.json).
8
+ - The package is published on npm (`dsh-lean-router`), so Path B is recommended; use Path A when you edit the code. DSH is in developer preview; engine drift is handled by the engines gate and the doctor self-check, never by silent degradation.
9
+
10
+ ## Install
11
+
12
+ ### Path A: local link (for development)
13
+
14
+ ~~~powershell
15
+ dsh plugin --profile desktop add "link:D:\path\to\dsh-lean-router"
16
+ ~~~
17
+
18
+ After restarting DSH, pick **Lean router** (lean tier) or **Lean router (balance)** (weaker-constraint tier) for new sessions.
19
+
20
+ ### Path B: npm install (recommended)
21
+
22
+ ~~~powershell
23
+ dsh plugin --profile desktop add npm:dsh-lean-router@2.0.0
24
+ ~~~
25
+
26
+ ### Stub behaviour when the dependency is missing
27
+
28
+ The package depends on `@deepseek-ai/dsh-tool-executor-native` (package.json dependencies). If that dependency is not resolved with the package (e.g. a manual directory copy), the tool-masking layer fails loudly instead of silently: the executor degrades to an install-hint stub, and the first `describe` call throws an error containing the install guidance (lib/toolface/executor.js L57-63):
29
+
30
+ > dsh-lean-router/toolface requires the dependency "@deepseek-ai/dsh-tool-executor-native". Install dsh-lean-router together with its dependencies (dsh plugin add resolves them) or upgrade the package; ...
31
+
32
+ To repair by hand, run `npm install` in the package directory or reinstall with `dsh plugin add` so the host resolves the dependency tree.
33
+
34
+ ## First use
35
+
36
+ 1. Choose a preset for the new session: **Lean router** (13 rules + 3 soft gates + routing) or **Lean router (balance)** (3 rules, no routing directives yet).
37
+ 2. Optional explicit routing directive, written in the first real user message:
38
+
39
+ ~~~text
40
+ [router] band=spec
41
+ [router] band=react task=split the home page into components
42
+ [router] band=auto
43
+ ~~~
44
+
45
+ Without the directive the band is classified from keywords; ties fall back to `weak` (model-routed).
46
+ 3. Commands:
47
+ - `/band`: view or switch the routing band (spec/react/weak/auto).
48
+ - `/compact`: trigger context compaction manually.
49
+ 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(...)`. Calling a masked name directly is refused with a hint to search first.
50
+
51
+ ## Self-check
52
+
53
+ ~~~powershell
54
+ node scripts/doctor.mjs # 11 structural checks (name / engines / patch / preset row / router row / no skill-provider row / no client-host row / three entry files / client bundle removed)
55
+ npm run verify # build --check (byte-identical) + doctor
56
+ npm test # node --test "test/*.test.mjs"
57
+ ~~~
58
+
59
+ ## Glossary
60
+
61
+ | Term | Meaning |
62
+ |---|---|
63
+ | lean | the four token-saving mechanisms (turn compaction, output pruning, disabled plugins, behaviour discipline) plus two add-ons (delivery gate, concurrency markers) |
64
+ | masking | hiding tools the preset does not own from the model-facing request while programs can still call them (toolface) |
65
+ | routing | classifying the task into one of three bands and injecting that band's guide near-field (router) |
66
+ | band | spec (inspect-and-plan) / react (hands-on-production) / weak (model-routed) |
67
+ | near-field guide | fixed text injected through a dynamic context: constant within a band, so the host's equality check writes nothing |
68
+
69
+ ## Current state (stated plainly)
70
+
71
+ - The balance preset carries no routing directives yet.
72
+ - The plan-mode policy paragraph keeps the upstream flash text (including the PTC `run_code` sentence).
73
+ - Since 2.0.0 the skills subsystem (31 skills, per-turn gate, audit, panel) is gone entirely.
74
+
75
+ See [architecture.en.md](./architecture.en.md), [configuration.en.md](./configuration.en.md) and [changelog.en.md](./changelog.en.md).