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.
- 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 +279 -0
- package/docs/changelog.md +282 -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/desc-slim.js +140 -0
- package/lib/toolface/discovery.js +297 -0
- package/lib/toolface/executor.js +333 -0
- package/lib/toolface/index.js +250 -0
- package/lib/toolface/pool.js +160 -0
- package/lib/toolface/retention.js +187 -0
- package/lib/toolface/rules.js +435 -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 +146 -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-desc-slim.test.mjs +255 -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,75 @@
|
|
|
1
|
+
# 快速上手(quickstart)
|
|
2
|
+
|
|
3
|
+
> 本包 **dsh-lean-router** 是一张 DeepSeek Harness(DSH)cordis 插件卡:lean 省 token × 思考链路由 × `code_run` 工具遮蔽,三个机制合并在一个预设里。中文为第一语言,英文版见 [quickstart.en.md](./quickstart.en.md)。
|
|
4
|
+
|
|
5
|
+
## 前置条件
|
|
6
|
+
|
|
7
|
+
- DSH `>=0.2.1-rc.5 <0.2.4-0`(实测基线 0.2.3-alpha.2;见 package.json engines 字段)。
|
|
8
|
+
- 本包已发布到 npm(`dsh-lean-router`),推荐路径 B;改代码调试走路径 A。DSH 处于 developer preview,版本越界将以 engines 闸 + doctor 自检应对,不做静默降级。
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
### 路径 A:本地 link(开发调试)
|
|
13
|
+
|
|
14
|
+
~~~powershell
|
|
15
|
+
dsh plugin --profile desktop add "link:D:\path\to\dsh-lean-router"
|
|
16
|
+
~~~
|
|
17
|
+
|
|
18
|
+
重启 DSH 后,新会话在预设列表选择 **Lean router**(lean 档)或 **Lean router (balance)**(弱约束精简档)。
|
|
19
|
+
|
|
20
|
+
### 路径 B:npm 安装(推荐)
|
|
21
|
+
|
|
22
|
+
~~~powershell
|
|
23
|
+
dsh plugin --profile desktop add npm:dsh-lean-router@2.0.0
|
|
24
|
+
~~~
|
|
25
|
+
|
|
26
|
+
### 缺依赖时的 stub 引导行为
|
|
27
|
+
|
|
28
|
+
本包依赖 `@deepseek-ai/dsh-tool-executor-native`(package.json dependencies)。若该依赖未随包解析(如手动复制目录安装),工具遮蔽层不会静默坏掉:executor 会退化为安装提示 stub——首次调用 `describe` 直接抛出含安装指引的错误(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
|
+
手动补装:在该包目录 `npm install`,或用 `dsh plugin add` 重装以让宿主解析依赖树。
|
|
33
|
+
|
|
34
|
+
## 首次使用
|
|
35
|
+
|
|
36
|
+
1. 新会话选择预设:**Lean router**(13 条纪律 + 3 软门 + 路由)或 **Lean router (balance)**(3 条纪律,暂不含路由指令)。
|
|
37
|
+
2. 可选显式路由指令(写在首条真实用户消息里):
|
|
38
|
+
|
|
39
|
+
~~~text
|
|
40
|
+
[router] band=spec
|
|
41
|
+
[router] band=react task=把首页拆成组件
|
|
42
|
+
[router] band=auto
|
|
43
|
+
~~~
|
|
44
|
+
|
|
45
|
+
省略指令时按关键词自动分类,平票归 `weak`(模型自分类)。
|
|
46
|
+
3. 常用命令:
|
|
47
|
+
- `/band`:查看或切换路由带(spec/react/weak/auto)。
|
|
48
|
+
- `/compact`:手动触发上下文压缩(compaction 组)。
|
|
49
|
+
4. 工具遮蔽是自动的:模型工具列表只出现预设自有工具 + `code_run`;MCP 与预设外插件工具在 `code_run` 程序内用 `tools.code_tools_search(...)` 发现后调用。直呼被遮蔽名会被拒绝并提示先搜索。
|
|
50
|
+
|
|
51
|
+
## 体检
|
|
52
|
+
|
|
53
|
+
~~~powershell
|
|
54
|
+
node scripts/doctor.mjs # 11 项结构自检(包名/engines/patch/预设行/路由行/无技能 provider 行/无客户端宿主行/三个入口文件/客户端 bundle 已移除)
|
|
55
|
+
npm run verify # build --check(cordis.patch.yml 反向逐字节一致)+ doctor
|
|
56
|
+
npm test # node --test "test/*.test.mjs"
|
|
57
|
+
~~~
|
|
58
|
+
|
|
59
|
+
## 术语表(全包统一)
|
|
60
|
+
|
|
61
|
+
| 术语 | 含义 |
|
|
62
|
+
|---|---|
|
|
63
|
+
| lean | 省 token 的四机制总称(轮次压缩/输出裁剪/关插件/行为纪律),外加两个加料件(交付门/并发标记) |
|
|
64
|
+
| 遮蔽(masking) | 把预设不拥有的工具从模型请求面隐藏,程序内仍可调用(toolface 层) |
|
|
65
|
+
| 路由(routing) | 把任务分到三条行为带并在近场注入对应引导(router 层) |
|
|
66
|
+
| 带(band) | spec(inspect-and-plan)/ react(hands-on-production)/ weak(model-routed)三带 |
|
|
67
|
+
| 近场引导 | 通过 dynamic context 注入的固定文本:同一带内文本恒定、宿主判等零写入 |
|
|
68
|
+
|
|
69
|
+
## 现状(如实标注,勿当承诺)
|
|
70
|
+
|
|
71
|
+
- balance 预设行暂不含路由指令。
|
|
72
|
+
- plan-mode 政策段保留 flash 原文(含 PTC `run_code` 句)。
|
|
73
|
+
- 2.0.0 起技能子系统(31 技能、每轮门控、审计、面板)已整体移除。
|
|
74
|
+
|
|
75
|
+
详见 [architecture.md](./architecture.md)、[configuration.md](./configuration.md)、[changelog.md](./changelog.md)。
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
|
|
2
|
+
## Execution record (2026-11-22)
|
|
3
|
+
|
|
4
|
+
- ✅ npm publish `dsh-lean-router@1.0.0` done (bypass-2FA granular token; verify with `npm view dsh-lean-router@1.0.0`)
|
|
5
|
+
- ✅ `git push` done (remote `ShawnSun-debug/dsh-lean-router`, main @ d3ffe1d)
|
|
6
|
+
- ✅ GitHub Release `v1.0.0` created
|
|
7
|
+
- ✅ CI green after fixing `npm test` to `node --test "test/*.test.mjs"` (directory arg breaks on Node 24)
|
|
8
|
+
- ⚠️ registry still lists npm's auto-generated placeholder `0.0.0-stage` (latest points to 1.0.0; deletion requires web UI + OTP, safe to ignore)
|
|
9
|
+
- ⏳ Remaining manual step: real-machine DSH profile install smoke
|
|
10
|
+
|
|
11
|
+
# Release checklist · dsh-lean-router v1.0.0
|
|
12
|
+
|
|
13
|
+
> Owner-manual steps only. The release subagent must **never** run `npm publish`, `npm login` or `git push` (ledger constraints/forbidden).
|
|
14
|
+
> Chinese version: [release-checklist.md](./release-checklist.md).
|
|
15
|
+
|
|
16
|
+
Package `dsh-lean-router` · version `1.0.0` · repo https://github.com/ShawnSun-Debug/dsh-lean-router
|
|
17
|
+
|
|
18
|
+
## 0. Pre-flight (already verified, re-runnable)
|
|
19
|
+
|
|
20
|
+
| Check | Command | Pass |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| Tests | `npm test` | `tests 200 / pass 199 / fail 0 / skipped 1` |
|
|
23
|
+
| Doctor | `npm run doctor` | 7 PASS |
|
|
24
|
+
| Build | `npm run build -- --check` | PASS, no rewrite |
|
|
25
|
+
| CI YAML | `python -c "import yaml; yaml.safe_load(open(r'.github/workflows/ci.yml', encoding='utf-8')); print('YAML_OK')"` | prints `YAML_OK` |
|
|
26
|
+
| Pack smoke | `npm pack` → temp dir `npm i <tgz>` → `node -e "require('dsh-lean-router')"` | installs, 3 exports |
|
|
27
|
+
|
|
28
|
+
> **Confirm the name before publishing**: `npm view dsh-lean-router version` reaches the registry and returns `E404 Not found` (name currently unpublished). Re-confirm before the real publish.
|
|
29
|
+
|
|
30
|
+
## 1. npm login (manual)
|
|
31
|
+
|
|
32
|
+
```powershell
|
|
33
|
+
npm login
|
|
34
|
+
npm whoami # verify: prints your npm username
|
|
35
|
+
npm config get registry
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 2. Publish (manual, irreversible)
|
|
39
|
+
|
|
40
|
+
```powershell
|
|
41
|
+
cd "D:\Agent Workspace\dsh-lean-router"
|
|
42
|
+
npm test # final gate: 200/199/0/1
|
|
43
|
+
npm publish
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Verify: `npm view dsh-lean-router version` → `1.0.0`; `npm view dsh-lean-router dist.tarball`.
|
|
47
|
+
Rollback: `npm unpublish dsh-lean-router@1.0.0` (within 72h) or `npm deprecate`.
|
|
48
|
+
|
|
49
|
+
## 3. Remote + push (manual)
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
git remote add origin https://github.com/ShawnSun-Debug/dsh-lean-router.git
|
|
53
|
+
git branch -M main
|
|
54
|
+
git push -u origin main
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Verify: `git remote -v`, `git ls-remote --heads origin main`. CI (`.github/workflows/ci.yml`) then runs on ubuntu-latest + node 24.
|
|
58
|
+
|
|
59
|
+
## 4. Tag + GitHub Release (manual)
|
|
60
|
+
|
|
61
|
+
```powershell
|
|
62
|
+
git tag -a v1.0.0 -m "dsh-lean-router v1.0.0"
|
|
63
|
+
git push origin v1.0.0
|
|
64
|
+
gh release create v1.0.0 --title "v1.0.0" --notes-file docs/changelog.md
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Verify: `git tag -l "v1.0.0"`, `gh release view v1.0.0`.
|
|
68
|
+
|
|
69
|
+
## 5. DSH profile install smoke (manual)
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
dsh plugin install dsh-lean-router
|
|
73
|
+
dsh --dump-config | Select-String "lean-router-router"
|
|
74
|
+
dsh plugin uninstall dsh-lean-router
|
|
75
|
+
dsh --dump-config | Select-String "lean-router-router" # expect no output
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Pass: install exits 0; `--dump-config` shows `lean-router-router`; after uninstall it disappears with no leftover files. Do not restart a running DSH app.
|
|
79
|
+
|
|
80
|
+
## Scope guard
|
|
81
|
+
|
|
82
|
+
No changes to `D:\Deepseek Harness`, `lib/`, `test/`, `engineer-mode`, `engineer-lean`. Published content = `package.json#files` allowlist only.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
|
|
2
|
+
## 执行记录(2026-11-22)
|
|
3
|
+
|
|
4
|
+
- ✅ npm publish `dsh-lean-router@1.0.0` 完成(bypass-2FA granular token;`npm view dsh-lean-router@1.0.0` 可验)
|
|
5
|
+
- ✅ `git push` 完成(远程 `ShawnSun-debug/dsh-lean-router`,main @ d3ffe1d 起)
|
|
6
|
+
- ✅ GitHub Release `v1.0.0` 已创建
|
|
7
|
+
- ✅ CI 首轮修复(`npm test` 改用 `node --test "test/*.test.mjs"`,目录参数在 Node 24 不可用)后 green
|
|
8
|
+
- ⚠️ registry 上残留 npm 自动生成的占位版本 `0.0.0-stage`(latest 已指向 1.0.0;需网页+OTP 才能删除,可忽略)
|
|
9
|
+
- ⏳ 剩余人工项:DSH profile 真机安装冒烟(见下文第 93/103 行附近命令)
|
|
10
|
+
|
|
11
|
+
# 发布清单 · dsh-lean-router v1.0.0
|
|
12
|
+
|
|
13
|
+
> 本文件只列**主人手动执行**的动作。负责发布票的子对话**不得**执行 `npm publish` / `npm login` / `git push`(台账 constraints 3、forbidden 4)。
|
|
14
|
+
> 中文先行,英文版见 [release-checklist.en.md](./release-checklist.en.md)。
|
|
15
|
+
|
|
16
|
+
包名:`dsh-lean-router` · 版本:`1.0.0` · 仓库:https://github.com/ShawnSun-Debug/dsh-lean-router
|
|
17
|
+
|
|
18
|
+
## 0. 发布前预检(已由子对话核实,可复跑)
|
|
19
|
+
|
|
20
|
+
| 检查 | 命令 | 通过判据 |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| 全仓测试 | `npm test` | `tests 157 / pass 156 / fail 0 / skipped 1`(1 skip = 宿主 yaml-asar 不可读,已知限制) |
|
|
23
|
+
| 体检 | `npm run doctor` | 11 PASS |
|
|
24
|
+
| 构建一致性 | `npm run build -- --check` | PASS,无重写 |
|
|
25
|
+
| CI YAML | `python -c "import yaml; yaml.safe_load(open(r'.github/workflows/ci.yml', encoding='utf-8')); print('YAML_OK')"` | 打印 `YAML_OK` |
|
|
26
|
+
| 打包冒烟 | `npm pack` → 临时目录 `npm i <tgz>` → `node -e "require('dsh-lean-router')"` | 安装成功且导入返回 3 个导出 |
|
|
27
|
+
|
|
28
|
+
> **发布前需主人确认名称**:`npm view dsh-lean-router version` 实测可连通 registry 并返回 `E404 Not found`,说明该名当前**未被发布**;正式 publish 前请再确认一次(避免同名抢注或私有 scope 归属问题)。
|
|
29
|
+
|
|
30
|
+
## 1. npm 登录(手动)
|
|
31
|
+
|
|
32
|
+
```powershell
|
|
33
|
+
npm login # 浏览器/一次性密码走 npm 官方流程
|
|
34
|
+
npm whoami # 验证:打印你的 npm 用户名
|
|
35
|
+
npm config get registry # 期望 https://registry.npmjs.org/
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**验证**:`npm whoami` 输出用户名且退出码 0。
|
|
39
|
+
|
|
40
|
+
## 2. 发布到 npm(手动,不可逆)
|
|
41
|
+
|
|
42
|
+
```powershell
|
|
43
|
+
cd "D:\Agent Workspace\dsh-lean-router"
|
|
44
|
+
npm test # 发布前最后一道闸:必须 200/199/0/1
|
|
45
|
+
npm pack --dry-run # 先看一眼 inclusions 是否只含 lib/presets/assets/ui/docs/scripts/test/清单文件
|
|
46
|
+
npm publish # 首发不需要 --tag;后续预发用 npm publish --tag next
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**验证**:
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
npm view dsh-lean-router version # 期望 1.0.0
|
|
53
|
+
npm view dsh-lean-router dist.tarball # 返回 https://registry.npmjs.org/dsh-lean-router/-/dsh-lean-router-1.0.0.tgz
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**回滚**(72 小时内可 unpublish):`npm unpublish dsh-lean-router@1.0.0`;更稳的是发补丁版 1.0.1 并 `npm deprecate dsh-lean-router@1.0.0 "msg"`。
|
|
57
|
+
|
|
58
|
+
## 3. 建远端并推送(手动)
|
|
59
|
+
|
|
60
|
+
git 仓库已在本地初始化并完成首发提交(见 `git log`)。远端需主人手动推送:
|
|
61
|
+
|
|
62
|
+
```powershell
|
|
63
|
+
cd "D:\Agent Workspace\dsh-lean-router"
|
|
64
|
+
git remote add origin https://github.com/ShawnSun-Debug/dsh-lean-router.git
|
|
65
|
+
git branch -M main
|
|
66
|
+
git push -u origin main
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**验证**:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
git remote -v # origin 指向上述地址
|
|
73
|
+
git ls-remote --heads origin main # 返回 main 的 SHA
|
|
74
|
+
git log --oneline -1 # 与远端 HEAD 一致
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
推送后 GitHub Actions 会自动跑 `.github/workflows/ci.yml`(ubuntu-latest + node 24 + npm install + npm test)。
|
|
78
|
+
|
|
79
|
+
**验证 CI**:仓库 Actions 页首个 run 绿;或 `gh run list --workflow=ci.yml --limit 1`。
|
|
80
|
+
|
|
81
|
+
## 4. 打 tag 并建 GitHub Release(手动)
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
git tag -a v1.0.0 -m "dsh-lean-router v1.0.0"
|
|
85
|
+
git push origin v1.0.0
|
|
86
|
+
gh release create v1.0.0 --title "v1.0.0" --notes-file docs/changelog.md # 或网页端创建
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**验证**:
|
|
90
|
+
|
|
91
|
+
```powershell
|
|
92
|
+
git tag -l "v1.0.0" # 打印 v1.0.0
|
|
93
|
+
gh release view v1.0.0 # 标题/正文与 v1.0.0 一致
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 5. DSH profile 真机安装冒烟(手动)
|
|
97
|
+
|
|
98
|
+
在真实 DSH 用户环境里验证「装得上、卸得净、配置装得对」:
|
|
99
|
+
|
|
100
|
+
```powershell
|
|
101
|
+
# 5.1 安装
|
|
102
|
+
dsh plugin install dsh-lean-router
|
|
103
|
+
# 或:npm i -g dsh-lean-router 后按 DSH 文档挂到 profile
|
|
104
|
+
|
|
105
|
+
# 5.2 装配检查(不启动对话,只看配置合成结果)
|
|
106
|
+
dsh --dump-config | Select-String "lean-router-router|dsh-lean-router"
|
|
107
|
+
|
|
108
|
+
# 5.3 卸载
|
|
109
|
+
dsh plugin uninstall dsh-lean-router
|
|
110
|
+
|
|
111
|
+
# 5.4 卸载后确认无残留
|
|
112
|
+
dsh --dump-config | Select-String "lean-router-router" # 期望无输出
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**验证判据**:
|
|
116
|
+
1. 安装命令退出码 0;
|
|
117
|
+
2. `--dump-config` 输出里能查到本插件(plugin 名 `lean-router-router`);
|
|
118
|
+
3. 卸载后 `--dump-config` 不再出现该插件,且 profile 配置目录无残留文件;
|
|
119
|
+
4. 期间**不重启**正在运行的 DSH 应用、不写 `~/.dsh`(如必须,由主人手动执行)。
|
|
120
|
+
|
|
121
|
+
## 6. 发布后
|
|
122
|
+
|
|
123
|
+
- 按 `docs/changelog.md` 校对 Release 正文;
|
|
124
|
+
- README 徽章里若需 npm 版本徽章,可在发布后追加;
|
|
125
|
+
- 记录首发版本号与 tarball shasum 到项目日志。
|
|
126
|
+
|
|
127
|
+
## 附:本仓库发布相关的界定
|
|
128
|
+
|
|
129
|
+
- 只发布 `package.json#files` 白名单内容(lib/ presets/ assets/ ui/ docs/ scripts/ test/ + 清单与 LICENSE/NOTICE/README);
|
|
130
|
+
- `fixtures/`、`node_modules/`、`.git/`、`.github/` 不随包发布(见 `.npmignore`);
|
|
131
|
+
- 宿主仓库 `D:\Deepseek Harness` 与 engineer-mode / engineer-lean 预设不在发布范围内,禁止触碰。
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# 复核:关 6 插件清单 × codemode 遮蔽面(native + code_run)
|
|
2
|
+
|
|
3
|
+
> 票 03-lean-layer(taskId=t3)产物 · 约束台账 v1 验收项 1
|
|
4
|
+
> 口径:上游 flash-presets 0.3.2 lean v3 关闭清单;本包遮蔽面 = vendored codemode 0.3.x(票 04)。
|
|
5
|
+
> 复核问题(约束台账第 2 条):六件 disabled 与 codemode 遮蔽面是否重复 / 冲突。
|
|
6
|
+
|
|
7
|
+
## 结论(先说结果)
|
|
8
|
+
|
|
9
|
+
**六件全部与 codemode 遮蔽面互补、零重复、零冲突;本包逐件保留 flash 的关闭口径。**
|
|
10
|
+
机制上两者正交:
|
|
11
|
+
|
|
12
|
+
- **关插件(disabled)在注册表加载层移除**:插件不加载,其工具定义根本不注册——不进系统提示,
|
|
13
|
+
code_run 也发现不到、调用不到(上游四机制文档 L130-135:「disabled: true 的插件不加载,工具
|
|
14
|
+
定义不进系统提示」)。
|
|
15
|
+
- **codemode 遮蔽在呈现层移除**:注册表从未改动,被遮蔽的工具仍在其中;executor.describe()
|
|
16
|
+
就是请求面(= 标准工具 + code_run),被遮工具程序内部经 code_run 仍可完整调用
|
|
17
|
+
(codemode docs/internals.md L11-25)。
|
|
18
|
+
|
|
19
|
+
叠加后的净效果:
|
|
20
|
+
|
|
21
|
+
| 层 | 工具 | 请求面 | code_run 程序内 |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| 预设活跃行(含六件以外的全部) | 标准工具 | 原生可见 | 可调 |
|
|
24
|
+
| MCP / profile bundle / agent 层 | 被遮层 | 剥掉 | 经 code_tools_* 发现后可调 |
|
|
25
|
+
| 六件 disabled | 被关层 | 不存在 | 不存在 |
|
|
26
|
+
|
|
27
|
+
补充一个关键点:**遮蔽替代不了关插件**。codemode 的归属判定把「预设视图内注册的工具」保持
|
|
28
|
+
原生(internals L38-47),所以预设自带的工具若不关,schema 照样进请求面付税;关闭是遮蔽之外
|
|
29
|
+
唯一能同时从请求面与程序面移除的手段。反过来,关插件也替代不了遮蔽(MCP/profile 层工具
|
|
30
|
+
不归本预设管,只能靠遮蔽收口)。
|
|
31
|
+
|
|
32
|
+
## 六件逐项复核
|
|
33
|
+
|
|
34
|
+
### 1. tool-subagent-codex(subagent_codex,调 Codex CLI 子代理)
|
|
35
|
+
|
|
36
|
+
- 上游出处:flash-lean-ptc-v3.patch.yml L155-161(delegation 组内 disabled: true,config
|
|
37
|
+
provider: codex / toolName: subagent_codex / maxDepth: provider-managed)。
|
|
38
|
+
- 若不关(本包 native+code_run 面下):预设作用域行 → codemode 判「预设所有」保持原生 →
|
|
39
|
+
subagent_codex 的 schema 进请求面付税(每个工具定义几百到一千多 token,四机制文档 L132-134)。
|
|
40
|
+
- 关掉的净效果:不注册 → 请求面与 code_run 都不可达;省一份固定 schema 税。
|
|
41
|
+
- **复核结论:互补不冲突,保留关闭。** 能力代价:失去 Codex 子代理(能力缺失边界与 flash
|
|
42
|
+
相同,四机制文档 L137-140「它是能力和成本的交换」)。
|
|
43
|
+
|
|
44
|
+
### 2. tool-subagent-claude-code(subagent_claude_code,调 Claude Code 子代理)
|
|
45
|
+
|
|
46
|
+
- 上游出处:flash-lean-ptc-v3.patch.yml L162-168(同组 disabled: true,provider: claude-code)。
|
|
47
|
+
- 分析与第 1 件完全同构(同为预设作用域子代理行)。
|
|
48
|
+
- **复核结论:互补不冲突,保留关闭。** 能力代价:失去 Claude Code 子代理。
|
|
49
|
+
|
|
50
|
+
### 3. workflow-ptc(@deepseek-ai/dsh-workflow-ptc,PTC 版工作流引擎)
|
|
51
|
+
|
|
52
|
+
- 上游出处:flash-lean-ptc-v3.patch.yml L169-173(disabled: true,config provider: spawn)。
|
|
53
|
+
- 关键对照:**codemode 自己的预设反而启用它**(codemode/cordis.patch.yml L124-127 无
|
|
54
|
+
disabled)——说明在 native+code_run 面下工作流引擎与遮蔽层可以共存,关闭是 lean 省
|
|
55
|
+
schema 的选择,不是兼容性冲突。
|
|
56
|
+
- 与常驻 PTC 无重叠(易混点澄清):ptc-runtime 是 run_code/code_run 的**执行模式配置行**
|
|
57
|
+
(executionMode: persistent-in-memory,flash cordis.patch.yml L376-378;本包该行归票 04),
|
|
58
|
+
workflow-ptc 是**工作流引擎插件**。上游同时保留 ptc-runtime 配置并关闭 workflow-ptc,
|
|
59
|
+
两件事互不影响。
|
|
60
|
+
- **复核结论:互补不冲突,保留关闭。** 若未来需要 workflow 编排,去掉该行 disabled 即恢复,
|
|
61
|
+
遮蔽层无需任何改动。
|
|
62
|
+
|
|
63
|
+
### 4. tool-workflow(工作流编排工具组)
|
|
64
|
+
|
|
65
|
+
- 上游出处:flash-lean-ptc-v3.patch.yml L174-176(disabled: true,无 config)。
|
|
66
|
+
- 对照:codemode 预设同样启用它(cordis.patch.yml L128-129)。
|
|
67
|
+
- **复核结论:互补不冲突,保留关闭。** 与第 3 件同组同理由;恢复方式相同。
|
|
68
|
+
|
|
69
|
+
### 5. tool-ralph(ralph 循环执行工具)
|
|
70
|
+
|
|
71
|
+
- 上游出处:flash-lean-ptc-v3.patch.yml L177-182(disabled: true,config subagentProvider:
|
|
72
|
+
spawn / maxRounds: 64)。codemode 预设无此行。
|
|
73
|
+
- 与 code_run 的功能重叠辨析:ralph 是 fresh-agent 多轮循环(每轮新代理、共享工作区),
|
|
74
|
+
code_run 是单程序内的批量子调用(maxParallelSubCalls: 10)——两者都服务「批量执行」,
|
|
75
|
+
机制不同,不构成遮蔽层冲突。
|
|
76
|
+
- **复核结论:互补不冲突,保留关闭。** 省 schema,且与本包「程序化批量由 run_code/code_run
|
|
77
|
+
承担」的定位一致。
|
|
78
|
+
|
|
79
|
+
### 6. tool-plugin-manager(插件市场/管理工具)
|
|
80
|
+
|
|
81
|
+
- 上游出处:flash-lean-ptc-v3.patch.yml L200-202(预设顶层 disabled: true,恒关)。
|
|
82
|
+
- 对照:codemode **条件关**(disabled: !!js "!ctx.get('profileContext')",cordis.patch.yml
|
|
83
|
+
L143-145),另恒关 tool-plugin-market(L146-148)。
|
|
84
|
+
- **复核结论:互补不冲突,本包保留恒关(比 codemode 的条件关更保守)。** 理由:会话内装卸
|
|
85
|
+
插件会改变 bundle 完整性,与计划的风险条款(头号风险=误挂,回滚=整卡移除 + config 双保险)
|
|
86
|
+
冲突;装卸需求走 profile 层操作(dsh plugin add/remove),不依赖会话内工具。
|
|
87
|
+
|
|
88
|
+
## 证据索引(上游 文件:行号)
|
|
89
|
+
|
|
90
|
+
| # | 证据 | 位置 |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| E1 | 六件 disabled 行原文 | .scratch/upstream/flash-presets/presets/flash-lean-ptc-v3.patch.yml L155-202 |
|
|
93
|
+
| E2 | 机制 3 说明:disabled 不加载、schema 不进系统提示;六件清单与代价 | .scratch/upstream/flash-presets/docs/技术文档-省token四机制.md L119-140 |
|
|
94
|
+
| E3 | 遮蔽面定义:describe() 即请求面、注册表不动、程序内可调 | .scratch/upstream/codemode/docs/internals.md L11-25 |
|
|
95
|
+
| E4 | 归属判定:预设视图内保持原生、其余遮蔽 | .scratch/upstream/codemode/docs/internals.md L38-47 |
|
|
96
|
+
| E5 | codemode 预设启用 workflow-ptc / tool-workflow | .scratch/upstream/codemode/cordis.patch.yml L124-129 |
|
|
97
|
+
| E6 | codemode 条件关 plugin-manager、恒关 plugin-market | .scratch/upstream/codemode/cordis.patch.yml L143-148 |
|
|
98
|
+
| E7 | ptc-runtime 配置行与 workflow-ptc disabled 并存 | .scratch/upstream/flash-presets/cordis.patch.yml L177-179、L376-378 |
|
|
99
|
+
| E8 | code_run 命名与 native/ptc 互斥背景 | .scratch/upstream/codemode/docs/internals.md L63-71 |
|
|
100
|
+
|
|
101
|
+
## 边界与未验证项
|
|
102
|
+
|
|
103
|
+
- 本文档是**静态复核**(配置层语义对照),未在宿主上做 --dump-config 实测:合并复验由
|
|
104
|
+
master 执行(约束台账验收项 2 已标注待复验)。
|
|
105
|
+
- 「若不关会付 schema 税」的推论依赖 codemode 的归属判定规则(E4);票 04 集成后可用
|
|
106
|
+
fixtures 端到端复证(一个预设作用域的假工具在请求面出现 = 原生,遮蔽名单不含它)。
|
|
107
|
+
- 能力缺失是交换而非缺陷:任务真的需要 Codex/Claude Code 子代理、workflow 编排、ralph
|
|
108
|
+
循环或会话内插件装卸时,本预设不提供(与 flash lean v3 边界一致,E2 L137-140)。
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# 工具遮蔽层接线说明(票 04 · toolface)
|
|
2
|
+
|
|
3
|
+
> 状态:t4 交付稿(master 验收前)。上游来源:dsh-codemode 0.3.x main f9758ec1061a9a0af4f1dfefbacc19c5987b11d1(version 0.3.0)。
|
|
4
|
+
|
|
5
|
+
## 1. 这一层做什么
|
|
6
|
+
|
|
7
|
+
lean-router 预设下的会话运行在 Code Mode:预设自身清单里的工具照常直接调用;
|
|
8
|
+
预设之外的工具(全局层 MCP 服务端与 bundle、agent 层工具集)不进模型上下文,
|
|
9
|
+
由插件自带的 code_run 程序传输按需发现并调用。四件套:
|
|
10
|
+
|
|
11
|
+
1. 发现工具 code_tools_list / code_tools_search / code_tools_describe / code_debug
|
|
12
|
+
——注册在预设作用域内的普通工具,只能从程序内部调用;
|
|
13
|
+
2. 程序传输 code_run(保留名 run_code 归 DSH 内建 PTC,注册表拒绝注册);
|
|
14
|
+
3. 预设作用域的 ToolExecutor:describe() 把预设外工具从请求面遮蔽,
|
|
15
|
+
execute() 在派发前拒绝模型直呼被遮蔽名并给自愈提示;
|
|
16
|
+
4. Code Mode 指令文本以 executor 的 tools:sdk 段提供(替代 DSH 自己的 SDK 段)。
|
|
17
|
+
|
|
18
|
+
注册表从未被改动:被遮蔽的工具仍可从程序内部经注册表公共 execute() 调用
|
|
19
|
+
(子调用 signal 打 Symbol.for('dsh-codemode.nested') 标记 + :ptc: 调用 id 双证)。
|
|
20
|
+
|
|
21
|
+
## 2. vendored 文件映射表
|
|
22
|
+
|
|
23
|
+
| vendored(lib/toolface/) | upstream(dsh-codemode 0.3.0 main @ f9758ec) | 改动性质 |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| rules.js | lib/rules.js | 原样(含 hiddenPrefixes=['mcp__']、meta 工具 4 个、runToolName='code_run'、nativeScope=true、maxParallelSubCalls=10 等默认) |
|
|
26
|
+
| scope.js | lib/scope.js | 原样('dsh.scope' 符号描述归属不变) |
|
|
27
|
+
| pool.js | lib/pool.js | 原样(DEFAULT_MAX_PARALLEL=10) |
|
|
28
|
+
| retention.js | lib/retention.js | 原样(agent 销毁 + 插件卸载双清理;Symbol.for('cordis.original') 剥代理;effect 标签保留 upstream 'dsh-codemode retained environments') |
|
|
29
|
+
| discovery.js | lib/discovery.js | 原样 |
|
|
30
|
+
| transport.js | lib/transport.js | 原样(code_run、嵌套信号、pool abandon/drain) |
|
|
31
|
+
| executor.js | lib/executor.js | 适配:原生执行器依赖改动态加载 + 显式 stub;其余(NESTED_MARK、describe 遮蔽、派发前直呼拒绝)原样 |
|
|
32
|
+
| index.js | lib/index.js | 适配:插件名 dsh-lean-router/toolface、日志前缀同名、apply 改 async 且动态加载依赖;四步结构与全部 hooks 原样 |
|
|
33
|
+
|
|
34
|
+
每个文件头部有 [vendored @ upstream dsh-codemode 0.3.x main f9758ec…] 注明版本线与来源。
|
|
35
|
+
|
|
36
|
+
## 3. 缺依赖降级(stub 路径)
|
|
37
|
+
|
|
38
|
+
vendored 版去掉了上游对 @deepseek-ai/dsh-tool-executor-native 的顶层静态 import:
|
|
39
|
+
|
|
40
|
+
- loadNativeExecutorModule() 动态 import,在 apply() 里 setExecutor 之前完成
|
|
41
|
+
(describe() 是同步签名,模块必须在挂载时可用);
|
|
42
|
+
- 依赖缺失时(或测试显式注入)走 stub delegate:describe/execute 被真正调用
|
|
43
|
+
即抛出引导安装错误(消息含包名与安装方式),模块加载与本包 import 不受影响;
|
|
44
|
+
- 执行管线不重写:policy/approval/around-dispatch/post-execute 全部由
|
|
45
|
+
@deepseek-ai/dsh-tool-executor-native 的 NativeToolExecutor 承担,跨模块图驱动宿主
|
|
46
|
+
注册表(宿主现装 0.2.2-rc.5,依赖区间 ^0.2.2-alpha.3 覆盖之)。
|
|
47
|
+
|
|
48
|
+
## 4. 直呼拒绝路径
|
|
49
|
+
|
|
50
|
+
executor.execute() 对批量内每个 call 判定:嵌套调用(标记 signal 或 :ptc: id)、
|
|
51
|
+
guard:false、传输名本身豁免;被遮蔽名在派发前整批拒绝,被拒调用给自愈提示
|
|
52
|
+
(引导先 tools.code_tools_search 再经 code_run 调用),同批被牵连的合法调用
|
|
53
|
+
各自拿到「单独重发」提示。拒绝发生在注册表管线之外、派发之前——遮蔽名不在
|
|
54
|
+
模型拿到的目录里,tools.guard()(管线内)拦不住它。
|
|
55
|
+
|
|
56
|
+
## 5. 预设接线(frag-toolface.patch.yml)
|
|
57
|
+
|
|
58
|
+
presets/base/frag-toolface.patch.yml 是顶层列表续项("- id: preset-lean-router" 键级
|
|
59
|
+
override,形态对齐上游样本)。cordis patch override 是键级整体替换、预设行不是
|
|
60
|
+
group,无法向 plugins 数组增量插入,故本分片把 config.plugins 整快照重声明:
|
|
61
|
+
base 全部行原样保留 + 追加 toolface 行(name: 'dsh-lean-router/toolface',config
|
|
62
|
+
显式写出全部默认值)。防漂移由 test/toolface-wiring.test.mjs 锁定(frag 行集合 =
|
|
63
|
+
base 行集合 + toolface)。
|
|
64
|
+
|
|
65
|
+
集成注意:票 03/05 若也需改 preset 行(persona suffix、加行)与本分片是同一接缝,
|
|
66
|
+
整键 override 后写者覆盖先写者;由 master 统一裁决(可把 toolface 行并入
|
|
67
|
+
presets/base/lean-router.patch.yml、本分片只留校验)。cordis.patch.yml 由
|
|
68
|
+
scripts/build-bundle.mjs 生成,master 已合入并通过 build --check 反向一致与 doctor。
|
|
69
|
+
|
|
70
|
+
## 6. package.json 需 master 新增(本票禁改共享文件,由 master 统一加)
|
|
71
|
+
|
|
72
|
+
- dependencies: "@deepseek-ai/dsh-tool-executor-native": ">=0.2.2-alpha.3 <0.2.4-0"
|
|
73
|
+
(1.0.5 起放宽到 0.2.3 线;0.2.3-alpha.2 与 0.2.2-rc.5 的实现逐字节相同,仅 package.json 变)
|
|
74
|
+
- peerDependencies(建议): "@deepseek-ai/cordis": ">=4.1.0-0 <4.3.0-0"
|
|
75
|
+
(宿主 0.2.3-alpha.2 装 cordis 4.2.0-alpha.1;旧 ~4.1.0 不含 4.2 预发布)
|
|
76
|
+
- exports 增加: "./toolface": "./lib/toolface/index.js"
|
|
77
|
+
(frag 行 name 'dsh-lean-router/toolface' 依赖 exports 子路径,
|
|
78
|
+
同形先例:@deepseek-ai/dsh-plugin-manager 的 './tools')
|
|
79
|
+
|
|
80
|
+
## 7. fixture 参照件
|
|
81
|
+
|
|
82
|
+
fixtures/verify-codemode.patch.yml(参照上游同形):把 lean-router 设为默认预设 +
|
|
83
|
+
宿主层挂载本地假 MCP 服务器 fixtures/fake-mcp-server.mjs(上游样本原样副本,
|
|
84
|
+
stdio、不联网、3 工具)。预期:3 个 mcp__fake__* 工具不进模型工具列表,
|
|
85
|
+
code_run 内经 code_tools_search 发现并按名调用。用法:
|
|
86
|
+
|
|
87
|
+
dsh --profile lean-router-verify --patch fixtures/verify-codemode.patch.yml --no-open --port 3099
|
|
88
|
+
|
|
89
|
+
注:patch 内 command/args 是示例路径,安装后按实际环境调整。
|
|
90
|
+
|
|
91
|
+
## 8. 验证记录(2026-11-20)
|
|
92
|
+
|
|
93
|
+
宿主纯 node(C:\Users\charl\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies\node\bin\node.exe):
|
|
94
|
+
|
|
95
|
+
node --test test/toolface-rules.test.mjs test/toolface-mask.test.mjs \
|
|
96
|
+
test/toolface-executor.test.mjs test/toolface-runtime.test.mjs test/toolface-wiring.test.mjs
|
|
97
|
+
→ exit 0,pass 87,fail 0
|
|
98
|
+
|
|
99
|
+
全仓库回归(package/manifest/build/provider + 五个 toolface 文件):
|
|
100
|
+
|
|
101
|
+
node --test test/package.test.mjs test/manifest.test.mjs test/build.test.mjs test/provider.test.mjs <同上五个>
|
|
102
|
+
→ exit 0,pass 91,fail 0
|
|
103
|
+
|
|
104
|
+
node scripts/doctor.mjs → 8 项 PASS(含 build --check 反向逐字节一致)
|
|
105
|
+
|
|
106
|
+
覆盖点:台账默认值契约、名字/作用域双规则、归属三视图、meta 4 工具、
|
|
107
|
+
code_run 参数 schema 与校验、子调用嵌套标记、pool 并发/独占/abandon、
|
|
108
|
+
retention 双清理与去重、直呼拒绝 + 自愈提示、stub 降级路径、
|
|
109
|
+
frag/fixture 形态与防漂移。
|
|
110
|
+
|
|
111
|
+
## 9. 产物文件明细(对应报告 artifacts 的目录级条目)
|
|
112
|
+
|
|
113
|
+
报告 artifacts 按 boundary 校验器的前缀语义以目录/精确条目交付,文件级明细如下
|
|
114
|
+
(sha256,UTF-8 字节数)。
|
|
115
|
+
|
|
116
|
+
lib/toolface/(8 文件,均 vendored @ dsh-codemode 0.3.0 main f9758ec1061a9a0af4f1dfefbacc19c5987b11d1):
|
|
117
|
+
|
|
118
|
+
| 文件 | bytes | sha256 |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| index.js | 11214 | 0876ee55e76bf895c0a7728db00de9a55bf6e720538d8024c270a0393cc7adfb |
|
|
121
|
+
| executor.js | 10860 | 6920c8b94068b80ab886f50134fb47f93db8de104e238d7f4465473ad848a2f1 |
|
|
122
|
+
| rules.js | 18630 | eee1db4b851e64f451f48352bd59f77350c6c852321204c71a2fb767ce58d707 |
|
|
123
|
+
| scope.js | 8580 | b2a29ee3e00ca045e5834f0edb2867530a909bff2fa40a5621931cd94ddab42c |
|
|
124
|
+
| pool.js | 5797 | 86030c8d56afe87f14709c64b6546c24a8e7c4f3c2708eaf96960bb63d983efe |
|
|
125
|
+
| retention.js | 7599 | a58ba48b12a8d4f6980c46068f9558f94b981c1b58a881355e1980e2a16ad341 |
|
|
126
|
+
| discovery.js | 12307 | bf50c4763ecdf73b57e08cd114e35e005b01bc4406ab1b0c37f56fbc29aba489 |
|
|
127
|
+
| transport.js | 14732 | 2cd7ed47e49bdd26cfa39118cb05a02e6da9f4063f646c070a4e6da3507b5961 |
|
|
128
|
+
|
|
129
|
+
test/toolface*.test.mjs(5 文件):
|
|
130
|
+
|
|
131
|
+
| 文件 | bytes | sha256 |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| toolface-rules.test.mjs | 7690 | a6c1a767ba268bc75a1e9fde229031229e7240a7d061904088bd5c549037fc79 |
|
|
134
|
+
| toolface-mask.test.mjs | 11193 | 080a6310290f6f3027fd364efc057425bba7a19ce808d4eba86808efd3bb979f |
|
|
135
|
+
| toolface-executor.test.mjs | 9925 | ce6e908e704e2395513c3990553ac9a2ff6ee08f3f6a76bb4d9caf8cddda5db7 |
|
|
136
|
+
| toolface-runtime.test.mjs | 17189 | b4cc4e628cd72f0edc452d4afaab56a0faad8d7afbb0be5ebffae6c3785b5347 |
|
|
137
|
+
| toolface-wiring.test.mjs | 12155 | 9b1ff2c8e93fa1a57e3cdb68ccab6624320081bea144949bb34ea62f134fb05d |
|
|
138
|
+
|
|
139
|
+
fixtures/(2 文件):verify-codemode.patch.yml(1258B,fc253aad478fbba0eaa9ad734207382c6b49747c80f9196f19642820f7ef40a9)、
|
|
140
|
+
fake-mcp-server.mjs(3063B,b58c2eaa77b8fad98fbae6d5c0024c7a052e1839bc88e3a46e472722f76b0377)。
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# 思考链路由层设计说明(票 05 / dsh-lean-router)
|
|
2
|
+
|
|
3
|
+
> 台账版本 v1 · taskId=t5。本文档是交付物的设计依据与宿主接缝证据汇总。
|
|
4
|
+
> 上游 `dsh-routing-suite`(DSH<0.2.0 旧线)只取思想与实测结论,不搬代码;宿主事件形状以本机 0.2.2-rc.5 node_modules 实读为准。
|
|
5
|
+
|
|
6
|
+
## 1. 目标与思想来源
|
|
7
|
+
|
|
8
|
+
思考链路由层把「模型 persona 轴非连续、分相变」的实测特性量化为三个稳定行为带,
|
|
9
|
+
在会话首轮捕获真实用户消息分类定带,并以缓存友好的近场引导维持带内纪律:
|
|
10
|
+
|
|
11
|
+
| 带 | 语义 | 工具面 | persona 风格 |
|
|
12
|
+
|---|---|---|---|
|
|
13
|
+
| spec | 先读后改(inspect-and-plan) | 窄(读向) | 计划-集体 |
|
|
14
|
+
| react | 直接产出(hands-on production) | 宽(写向) | 执行者 |
|
|
15
|
+
| weak | 模型自分类(self-routed) | 窄 | neutral + classify few-shot |
|
|
16
|
+
|
|
17
|
+
关键实测结论(上游 preset/README.md、docs/STANDARD-PLAN.md,V4.1 Flash):
|
|
18
|
+
|
|
19
|
+
- persona 轴三带量化:spec 0-0.19 / react 0.5-1.0 稳定;mixed 0.2-0.49 是转换陷阱,永不自动选中。
|
|
20
|
+
- Flash 阈值型最优 = neutral + classify few-shot + 三锚(回顾/收敛/反跑题):路由 96%、单任务完成 100%、反稀释。
|
|
21
|
+
- 模型不能自路由:weak persona + few-shot 分类指令是唯一内路由窗口(区分度 +2.3..+3.3,lean 不翻转)。
|
|
22
|
+
- 首轮分类真实生效依赖 `agent/inbox/claimed` 在系统提示装配前捕获(上游 issue #13)。
|
|
23
|
+
- 近场引导必须与用户消息同请求注入且不加第二次 API 调用(上游 issue #34/#36/#55,此前 2× 费用)。
|
|
24
|
+
- 行为路径承诺:带在首轮锁定;中途换 persona 使整个前缀缓存失效(P6 尾部 persona 无效)。
|
|
25
|
+
- 长程任务勤勉度衰减真实存在(上游 graded/STUDY 懈怠观测),对抗机制按轮距注入自检。
|
|
26
|
+
|
|
27
|
+
## 2. 架构与交付物
|
|
28
|
+
|
|
29
|
+
| 交付物 | 内容 |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `lib/bands.js` | 三带配置表 `BANDS`(persona 变体文本常量 + 工具面宽窄标记 + 引导固定文本)、`classifyTask`、`parseRouterDirective`、`isComplexTask`、`diligenceReminder` |
|
|
32
|
+
| `lib/router.js` | 路由插件 `apply`:首轮捕获、指令解析、近场引导注入、勤勉自检、`/band` 命令;导出 `ROUTER_PROMPT` 与 `ROUTER_INJECTION_NOTES` |
|
|
33
|
+
| `presets/base/frag-router.patch.yml` | 顶层列表续项(钩子行 + 命令行),由 `scripts/build-bundle.mjs` 续接 |
|
|
34
|
+
| `test/router-bands.test.mjs` `test/router.test.mjs` | 纯函数与假 ctx 集成单测,21/21 宿主纯 node 全绿 |
|
|
35
|
+
|
|
36
|
+
## 3. 宿主接缝证据(实读 0.2.2-rc.5 源码,文件:行号)
|
|
37
|
+
|
|
38
|
+
| 接缝 | 位置 | 事实 |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| 首轮捕获事件 | `@deepseek-ai/dsh-agent-loop/lib/index.js:103-110` | `inbox.claim()` 同步 emit `agent/inbox/claimed`,payload `{ message, turn }`,发生在系统提示装配之前 |
|
|
41
|
+
| 用户消息判据 | `@deepseek-ai/dsh-api-session-controller/lib/index.js:492` | 宿主以 `event.data.source.kind === "user"` 判定真实用户输入 |
|
|
42
|
+
| 引导注入通道 | `@deepseek-ai/dsh-system-prompt/lib/index.js:281-284` | `ctx.systemPrompt.context({ name, order, text })` 注册动态 context(order 220 避开宿主 CONTEXT_ORDERS 100-210,见 :47-54) |
|
|
43
|
+
| 零写入缓存友好 | `@deepseek-ai/dsh-agent-loop/lib/index.js:341` | `RuntimeContextProjection.project` 对 sections `deepEqualJson` 相等即不写 —— 同带同文本恒定 = 零追加 |
|
|
44
|
+
| pre-step 反例(不采用) | `@deepseek-ai/dsh-agent-loop/lib/index.js:873-878` | pre-step 返回的非 runtime-context 消息会被 durable append 进会话历史,逐步累积,违反「不改写历史」 |
|
|
45
|
+
| persona 拼接点 | `@deepseek-ai/dsh-persona/lib/index.js:42-46` | persona suffix 渲染为 `deployment:persona-suffix` 节(order 10200,见 dsh-system-prompt L10-46 SECTION_ORDERS) |
|
|
46
|
+
| 命令注册缝 | `@deepseek-ai/dsh-commands/lib/index.js:266-269` | `ctx.commands.register(definition)`;`definitionId` 可选(:166),handler 收冻结的 `{ commandId, agent, rawInput, attachments, signal }`(:379-385) |
|
|
47
|
+
| 技能列表 API | `@deepseek-ai/dsh-skill/lib/index.js:224-240, 491-503` | `ctx.skills.list({ scope: agent, signal })` 返回 `{ name, description, invocation: { modelInvocable, userInvocable } }` 摘要 |
|
|
48
|
+
| 请求消息来源 | `@deepseek-ai/dsh-agent-loop/lib/index.js:1091-1100` | LLM 请求 messages 全部来自 durable surface(`session.deriveMessages()`)——论证动态 context 通道的必要 |
|
|
49
|
+
|
|
50
|
+
## 4. 注入通道论证:为什么是 dynamic context 而不是 pre-step append
|
|
51
|
+
|
|
52
|
+
契约要求「近场引导固定文本(缓存友好:不改写历史、不加 API 轮次)」。宿主有三条候选通道:
|
|
53
|
+
|
|
54
|
+
1. **pre-step durable append**(time-context 样板,`@deepseek-ai/dsh-time-context/lib/index.js:265-281`):
|
|
55
|
+
消息随 decision.messages durable append(agent-loop :878)→ 当前请求即包含,但**每步都写历史**,
|
|
56
|
+
重复引导文本会累积膨胀;须自建节流,且语义是「durable 注入」,与「不改写历史」冲突。
|
|
57
|
+
2. **runtime-context 消息**:pre-step 返回 `source.kind === "runtime-context"` 的消息会被宿主跳过不落盘(:873),
|
|
58
|
+
但也不进请求(请求消息来自 surface,:1091)——死通道。
|
|
59
|
+
3. **dynamic context(采用)**:`ctx.systemPrompt.context()` 的 text 函数按 agent 路由状态返回固定文本;
|
|
60
|
+
状态不变 → `deepEqualJson` 相等 → 零写入(:341);改档/勤勉轮 → 文本变化 → 宿主 append 一条新
|
|
61
|
+
system-reminder(supersession 管理,append-only 不改写既有历史)→ durable surface → 下一次请求起包含。
|
|
62
|
+
同带每轮文本恒定 = 前缀缓存稳定;变化频率 = 改档次数 + 勤勉轮距,最小化追加。
|
|
63
|
+
|
|
64
|
+
## 5. 状态与生命周期
|
|
65
|
+
|
|
66
|
+
- 路由状态存 **agent 会话作用域 WeakMap**(keyed by agent),不污染全局(约束 4)。
|
|
67
|
+
- 捕获只认 `source.kind === 'user'`;插件注入/工具消息不触发(约束 5)。
|
|
68
|
+
- 显式 `[router] band=<spec|react|weak|auto>[ task=<...>]]` 指令优先(人在回路);`auto` 清除覆盖回退自动。
|
|
69
|
+
- 无指令且未路由时 `classifyTask` 关键词分类;已路由后关键词**不改带**(路径承诺),仅显式指令与 `/band` 可改。
|
|
70
|
+
- 子代理/fork 继承会话(`agent.session.parentSession` 存在)默认跳过路由(`skipInherited: true`,可关)。
|
|
71
|
+
- 勤勉自检 `diligenceEvery`(默认 10,0 关闭):轮次号入文,非勤勉轮文本不变、零写入。
|
|
72
|
+
- 任务回显:显式 task 文本编进引导文本(上游 v1.19.1 实测:模型每轮看清在为什么事工作)。
|
|
73
|
+
|
|
74
|
+
## 6. persona 拼接点(约束 4:禁直接改 persona)
|
|
75
|
+
|
|
76
|
+
`ROUTER_PROMPT`(lib/router.js 导出常量)是首轮 [router] 分类指令文本,**由 master 拼进**预设 persona 插件行的
|
|
77
|
+
`config.suffix` 文本尾部(票 03 lean 纪律在前、ROUTER_PROMPT 在后,换行续接):
|
|
78
|
+
|
|
79
|
+
- 该 suffix 由 `@deepseek-ai/dsh-persona` 渲染为 `deployment:persona-suffix` 节(order 10200)。
|
|
80
|
+
- 各带 `BANDS[*].personaText` 为 persona 变体文本常量,供 master 在 suffix 里按带选择(或全部常驻由路由引导分流)。
|
|
81
|
+
|
|
82
|
+
## 7. patch 分片与集成须知(master 待办)
|
|
83
|
+
|
|
84
|
+
`presets/base/frag-router.patch.yml` 为顶层列表续项,两条插件行:
|
|
85
|
+
|
|
86
|
+
```yaml
|
|
87
|
+
- insert:
|
|
88
|
+
- id: lean-router-router # 钩子行:捕获 + 引导 + 勤勉
|
|
89
|
+
name: dsh-lean-router/router
|
|
90
|
+
config: { hooks: true, commands: false, diligenceEvery: 10 }
|
|
91
|
+
- id: lean-router-commands # 命令行:/band
|
|
92
|
+
name: dsh-lean-router/router
|
|
93
|
+
config: { hooks: false, commands: true }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**package.json 请求增补**(共享文件,本票不改):`exports` 增加 `"./router": "./lib/router.js"`。
|
|
97
|
+
cordis 插件行 `name` 直接 `import(name)`(cordis-plugin-loader lib/index.js:338-351),子路径必须过 exports。
|
|
98
|
+
|
|
99
|
+
## 8. 验证
|
|
100
|
+
|
|
101
|
+
- `node --test test/router-bands.test.mjs test/router.test.mjs` → 21/21 pass(宿主纯 node 22.x)。
|
|
102
|
+
- 全量回归(package/manifest/build/provider + 路由两组)→ 25/25 pass。
|
|
103
|
+
- `node scripts/build-bundle.mjs`(check 模式)→ PASS,cordis.patch.yml 反向逐字节一致,路由续项已落尾部。
|
|
104
|
+
- 未验证项:真实宿主装配链(需 master 用 `--dump-config` 复验插件行与 exports 增补后启动)。
|