dsh-lean-router 0.0.0-stage → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.md +23 -0
- package/README.en.md +73 -0
- package/README.md +72 -2
- package/cordis.patch.yml +870 -0
- package/docs/adr/0001-token-ledger-durable-usage.md +11 -0
- package/docs/agents/domain.md +38 -0
- package/docs/agents/issue-tracker.md +44 -0
- package/docs/agents/release.md +24 -0
- package/docs/agents/triage-labels.md +13 -0
- package/docs/agents/verification.md +32 -0
- package/docs/architecture.en.md +67 -0
- package/docs/architecture.md +66 -0
- package/docs/changelog.en.md +266 -0
- package/docs/changelog.md +269 -0
- package/docs/configuration.en.md +57 -0
- package/docs/configuration.md +57 -0
- package/docs/install.en.md +60 -0
- package/docs/install.md +60 -0
- package/docs/quickstart.en.md +75 -0
- package/docs/quickstart.md +75 -0
- package/docs/release-checklist.en.md +82 -0
- package/docs/release-checklist.md +131 -0
- package/docs//345/244/215/346/240/270-/345/205/263/346/217/222/344/273/266/346/270/205/345/215/225.md +108 -0
- package/docs//345/267/245/345/205/267/351/201/256/350/224/275-/346/216/245/347/272/277/350/257/264/346/230/216.md +140 -0
- package/docs//350/267/257/347/224/261-/350/256/276/350/256/241/350/257/264/346/230/216.md +104 -0
- package/lib/bands.js +149 -0
- package/lib/index.js +12 -0
- package/lib/lean/compaction.js +119 -0
- package/lib/lean/delivery-gate.js +312 -0
- package/lib/lean/disabled.js +61 -0
- package/lib/lean/history-budget.js +301 -0
- package/lib/lean/history-downgrade.js +345 -0
- package/lib/lean/index.js +19 -0
- package/lib/lean/output-slim.js +271 -0
- package/lib/lean/persona-text.js +111 -0
- package/lib/lean/plan-mode.js +31 -0
- package/lib/lean/pruner.js +75 -0
- package/lib/lean/tool-concurrency.js +319 -0
- package/lib/lean/usage-ledger.js +442 -0
- package/lib/router.js +287 -0
- package/lib/token-ledger/index.js +147 -0
- package/lib/token-ledger/live.js +193 -0
- package/lib/toolface/discovery.js +297 -0
- package/lib/toolface/executor.js +323 -0
- package/lib/toolface/index.js +242 -0
- package/lib/toolface/pool.js +160 -0
- package/lib/toolface/retention.js +187 -0
- package/lib/toolface/rules.js +395 -0
- package/lib/toolface/scope.js +188 -0
- package/lib/toolface/transport.js +335 -0
- package/package.json +65 -4
- package/presets/base/frag-lean.patch.yml +459 -0
- package/presets/base/frag-preset.patch.yml +274 -0
- package/presets/base/frag-router.patch.yml +17 -0
- package/presets/base/frag-toolface.patch.yml +73 -0
- package/presets/base/lean-router.patch.yml +44 -0
- package/scripts/build-bundle.mjs +45 -0
- package/scripts/doctor.mjs +35 -0
- package/scripts/install-profile.mjs +113 -0
- package/scripts/install.mjs +20 -0
- package/scripts/integrate-preset.mjs +107 -0
- package/scripts/release.mjs +145 -0
- package/scripts/verify.mjs +8 -0
- package/test/build.test.mjs +7 -0
- package/test/history-budget.test.mjs +210 -0
- package/test/history-downgrade.test.mjs +379 -0
- package/test/integration-preset.test.mjs +59 -0
- package/test/lean-compaction.test.mjs +47 -0
- package/test/lean-concurrency.test.mjs +117 -0
- package/test/lean-delivery-gate.test.mjs +75 -0
- package/test/lean-frag.test.mjs +132 -0
- package/test/lean-modules.test.mjs +112 -0
- package/test/lean-pruner.test.mjs +42 -0
- package/test/output-slim.test.mjs +212 -0
- package/test/package.test.mjs +20 -0
- package/test/patch-yaml.test.mjs +45 -0
- package/test/plugin-entry.test.mjs +26 -0
- package/test/router-bands.test.mjs +98 -0
- package/test/router.test.mjs +215 -0
- package/test/token-ledger-live.test.mjs +351 -0
- package/test/token-ledger.test.mjs +264 -0
- package/test/toolface-executor.test.mjs +302 -0
- package/test/toolface-mask.test.mjs +258 -0
- package/test/toolface-rules.test.mjs +177 -0
- package/test/toolface-runtime.test.mjs +466 -0
- package/test/toolface-wiring.test.mjs +272 -0
- package/test/usage-ledger-inject.test.mjs +50 -0
- package/test/usage-ledger.test.mjs +399 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: accepted
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Token 账本以 durable session/event 为真相源
|
|
6
|
+
|
|
7
|
+
cost-meter 的 `ledger.json` 是按天、会话和模型聚合的快照,没有逐 request 记录;lean-router 又需要把真实 Usage 与 RequestSnapshot、任务结果关联起来做回放。因此第一版不修改宿主:以 `session/event` 的 durable `assistant/message` 作为 Usage 主账本,`llm/stream` 只提供实时辅助,costMeter Remote 用于对账;Usage 保留宿主原始字段并显式计算 `prompt = input + cacheRead + cacheWrite`。
|
|
8
|
+
|
|
9
|
+
第一版只做 durable Usage 回放,不重跑模型。RequestSnapshot 用于归因,不产出 token 真值;live shadow A/B 被推迟到账本可信之后。这样能先验证字段、去重、对账和任务结果关联,但暂不能证明新压缩策略的 token 节省。
|
|
10
|
+
|
|
11
|
+
当前实现增量先落地为独立库与 fixture adapter,用来验证 Usage 归一化、快照隐私边界、显式断言与报表契约;实时 `session/event`/`llm/stream`/costMeter adapter 与真机 E2E 不属于本增量,待库契约稳定后接入。
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# 领域文档
|
|
2
|
+
|
|
3
|
+
工程技能探索本仓库领域文档的方式。**布局:单上下文(single-context)。**
|
|
4
|
+
|
|
5
|
+
## 探索前先读
|
|
6
|
+
|
|
7
|
+
- 根目录 **`GLOSSARY.md`**(若存在)
|
|
8
|
+
- **`docs/adr/`** 下与你要动的区域相关的 ADR
|
|
9
|
+
- `docs/` 下已有的设计说明(架构、配置、路由、工具遮蔽等),与当前课题相关时读
|
|
10
|
+
|
|
11
|
+
以上任一不存在就**静默继续**:不要提它们的缺失,也不要主动建议先建。`/domain-modeling`(经 `/grilling --docs` 与 `/improve-codebase-architecture` 到达)在术语或决策真正定案时才惰性创建。
|
|
12
|
+
|
|
13
|
+
## 文件结构
|
|
14
|
+
|
|
15
|
+
单上下文(本仓库):
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
/
|
|
19
|
+
├── GLOSSARY.md
|
|
20
|
+
├── docs/adr/
|
|
21
|
+
│ ├── 0001-<决定>.md
|
|
22
|
+
│ └── 0002-<决定>.md
|
|
23
|
+
└── lib/ ← 实现
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
只有本仓库变成多包仓库(`pnpm-workspace.yaml` / `workspaces` / `packages/*`)时才改多上下文:根 `GLOSSARY-MAP.md` 指向各上下文的 `GLOSSARY.md`,`docs/adr/` 存系统级决策,`src/<context>/docs/adr/` 存局部决策。
|
|
27
|
+
|
|
28
|
+
## 用词表里的词汇
|
|
29
|
+
|
|
30
|
+
输出产物(issue 标题、重构提案、假设、测试名)里出现领域概念时,用 `GLOSSARY.md` 定义的那个词,不要漂移到它明确避开的同义词。
|
|
31
|
+
|
|
32
|
+
需要的概念词表里没有,这本身是信号:要么你在发明项目不用的语言(重新考虑),要么真有缺口(留给 `/domain-modeling`)。
|
|
33
|
+
|
|
34
|
+
## 撞 ADR 要显式指出
|
|
35
|
+
|
|
36
|
+
输出与既有 ADR 冲突时,明说,不要静默覆盖:
|
|
37
|
+
|
|
38
|
+
> _与 ADR-0007(<决定>)冲突,但值得重开,因为……_
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Issue tracker: GitHub
|
|
2
|
+
|
|
3
|
+
本仓库的 issue 与 spec 都放在 GitHub Issues。所有操作走 `gh` CLI。
|
|
4
|
+
|
|
5
|
+
## 约定
|
|
6
|
+
|
|
7
|
+
- **新建**:`gh issue create --title "..." --body "..."`(多行正文用 heredoc)
|
|
8
|
+
- **读取**:`gh issue view <n> --json number,title,body,labels,comments`
|
|
9
|
+
- **列出**:`gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'`
|
|
10
|
+
- **评论**:`gh issue comment <n> --body "..."`
|
|
11
|
+
- **加/删标签**:`gh issue edit <n> --add-label "..."` / `--remove-label "..."`
|
|
12
|
+
- **关闭**:先 `gh issue comment <n> --body "..."` 写说明,再 `gh issue close <n>`
|
|
13
|
+
|
|
14
|
+
### 子 issue 与阻塞
|
|
15
|
+
|
|
16
|
+
- **子 issue**:`gh issue create --parent <parent> ...`,或 `gh issue edit <parent> --add-sub-issue <child>`(gh 2.94+)。旧版:`gh api --method POST repos/<owner>/<repo>/issues/<parent>/sub_issues -F sub_issue_id=<child-db-id>`。用不了子 issue 时,子 issue 正文开头写 `Part of #<parent>`。
|
|
17
|
+
- **阻塞**:用 GitHub 原生 issue dependency(UI 可见)。`gh issue create --blocked-by <n>,<n> ...` 或 `gh issue edit <child> --add-blocked-by <blocker>`(gh 2.94+)。旧版:`gh api --method POST repos/<owner>/<repo>/issues/<child>/dependencies/blocked_by -F issue_id=<blocker-db-id>`,db-id 取 `gh api repos/<owner>/<repo>/issues/<n> --jq .id`。功能不可用时退化为正文开头写 `Blocked by: #<n>, #<n>`;所有阻塞者关闭才算解锁。
|
|
18
|
+
- **数未关闭阻塞者**:`gh api repos/<owner>/<repo>/issues/<n> --jq .issue_dependencies_summary.blocked_by`(0 即可开工)。用 `gh issue view <n> --json blockedBy` 时要过滤 `select(.state == "OPEN")`,否则会把已关闭的算进去。
|
|
19
|
+
|
|
20
|
+
## 安全边界
|
|
21
|
+
|
|
22
|
+
- 仓库由 `git remote -v` 推断;在克隆目录内运行 `gh` 会自动取。
|
|
23
|
+
- issue 只写进用户自己的仓库,不要写进 `mattpocock/skills`。
|
|
24
|
+
- fork 里 `gh` 可能默认指向 upstream,首次 `gh issue create` 前先 `gh repo view --json nameWithOwner` 核对。
|
|
25
|
+
|
|
26
|
+
## PR 作为分诊入口
|
|
27
|
+
|
|
28
|
+
**PR 作为请求入口:否。**(`/triage` 读这个开关;把外部 PR 当功能请求处理时改成 `yes`。)
|
|
29
|
+
|
|
30
|
+
设为 `yes` 时 PR 走同一套标签与状态机:`gh pr view <n> --comments`、`gh pr diff <n>`、`gh pr comment`、`gh pr edit --add-label`、`gh pr close`。GitHub 的 issue 与 PR 共用编号空间,裸 `#42` 先用 `gh pr view 42`、回落 `gh issue view 42`。
|
|
31
|
+
|
|
32
|
+
## 技能措辞对照
|
|
33
|
+
|
|
34
|
+
- "publish to the issue tracker" → 建一个 GitHub issue。
|
|
35
|
+
- "fetch the relevant ticket" → 按上面 **读取** 取。
|
|
36
|
+
|
|
37
|
+
## 寻路(wayfinder)操作
|
|
38
|
+
|
|
39
|
+
**地图**:单个 issue,带 `wayfinder:map` 标签,正文存 Notes / Decisions-so-far / Fog。
|
|
40
|
+
**子票**:作为地图的子 issue 挂上,带 `wayfinder:<type>` 标签(`research` / `prototype` / `grilling` / `task`);认领时 assign 给开工人。
|
|
41
|
+
|
|
42
|
+
- **前沿查询**:列出地图下未关闭的子票,丢掉有未关闭阻塞者或已有 assignee 的,按地图顺序取第一个。
|
|
43
|
+
- **认领**:`gh issue edit <n> --add-assignee @me`(会话的第一次写操作)。
|
|
44
|
+
- **解决**:`gh issue comment <n> --body "<答案>"` → `gh issue close <n>` → 把上下文指针(gist + 链接)追加到地图的 Decisions-so-far。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 发布(release)
|
|
2
|
+
|
|
3
|
+
一条命令发布:`node scripts/release.mjs <version>`。加 `--dry-run` 只跑测试与 verify,不改版本、不发布。
|
|
4
|
+
|
|
5
|
+
脚本只做机械步骤:校验 semver 与工作树、跑 `npm test` 与 `npm run verify`、改 `package.json`、提交、`npm publish --registry https://registry.npmjs.org`、轮询可见性(最长 5 分钟)、临时目录 `npm install` 验证版本。
|
|
6
|
+
|
|
7
|
+
**changelog 必须先人工写。** 脚本会检查 `docs/changelog.md` 与 `docs/changelog.en.md` 都已有 `## <version>` 标题,缺一个就中止——中英两份都要写,不要只改中文。
|
|
8
|
+
|
|
9
|
+
## 本机环境陷阱
|
|
10
|
+
|
|
11
|
+
- 默认 registry 是 `registry.npmmirror.com`,那是只读镜像。`npm whoami` 会因此返回 `ENEEDAUTH`,**不代表没登录**;用 `npm whoami --registry https://registry.npmjs.org` 复核。发布一律显式带 `--registry`。
|
|
12
|
+
- `npm pack --dry-run` / `npm publish` 把 notice 写到 stderr,PowerShell 会把它当错误并使退出码变成 1。用 `cmd /c "npm ... 2>&1"` 或只看 stdout 判断。
|
|
13
|
+
- `npm publish` 返回成功后 registry 仍要约 90 秒才可见,立刻 `npm view` 会 404。不要把 404 当发布失败。
|
|
14
|
+
- `npm.ps1` 在本机可能因 `npmNodeDir` 为空失败,一律用 `npm.cmd`。
|
|
15
|
+
- 发版后升级本机 profile,一律用 `node scripts/install-profile.mjs <version>`。它会拉包、替换 `node_modules`、用 Node 写回清单版本并自检(无 BOM、可解析、版本一致)。**不要手工用 PowerShell 改 profile 清单**。
|
|
16
|
+
- profile 的 `package.json` 一旦带 UTF-8 BOM,内核 `JSON.parse` 直接抛 `Unexpected token '', "{ "depe"... is not valid JSON`,desktop 配置档加载失败,所有会话起不来(对话界面表现为热重载后每个进行中的对话都报这句)。PowerShell 5.1 的 `Set-Content -Encoding utf8` / `Out-File -Encoding utf8` 会写 BOM;必须写时的安全写法:
|
|
17
|
+
- PowerShell:`[IO.File]::WriteAllText($p, $text, (New-Object System.Text.UTF8Encoding($false)))`
|
|
18
|
+
- Node:`writeFileSync(p, JSON.stringify(manifest, null, 2) + '\n')`
|
|
19
|
+
写完后必须复核:文件头 3 字节不得是 `EF BB BF`,且 `JSON.parse` 通过。
|
|
20
|
+
- 不要在 DSH 运行中替换 profile 的 `node_modules`:文件监听会触发客户端插件热重载,正在进行的对话会重读缓存并报错。正确顺序是**先完全退出 DSH → 再装 → 再启动**。
|
|
21
|
+
|
|
22
|
+
## 版本号判断
|
|
23
|
+
|
|
24
|
+
新增功能发 minor,修复与内部优化发 patch;先 `npm view <pkg> version` 确认远端当前版本,避免重发已存在的号。
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# 分诊标签
|
|
2
|
+
|
|
3
|
+
技能用五个规范角色说话;本文件把角色映射到本仓库实际使用的标签串。
|
|
4
|
+
|
|
5
|
+
| 规范角色 | 本仓库标签 | 含义 |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| `needs-triage` | `needs-triage` | 维护者需要评估 |
|
|
8
|
+
| `needs-info` | `needs-info` | 等报告者补充信息 |
|
|
9
|
+
| `ready-for-agent` | `ready-for-agent` | 规格已完整,可交给 AFK 代理 |
|
|
10
|
+
| `ready-for-human` | `ready-for-human` | 需要人来实现 |
|
|
11
|
+
| `wontfix` | `wontfix` | 不处理 |
|
|
12
|
+
|
|
13
|
+
技能提到某个角色(如 "apply the AFK-ready triage label")时,用上表对应的标签串。要改词表就改「本仓库标签」列。`wontfix` 此前已存在,其余四个由本次 setup 创建。
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# 验证与复核(verification)
|
|
2
|
+
|
|
3
|
+
## 子代理自报的数字必须复测
|
|
4
|
+
|
|
5
|
+
子代理报告的字符数、压缩率、测试数都要用**生产形状**的样本独立复测一次,再写进提交说明或对外结论。
|
|
6
|
+
|
|
7
|
+
只测"契约形状"不够:真实 `code_run` 的输出是 JSON,重复日志表现为 `logs` 字符串数组里的多个相同元素,而不是单个字符串内部的多行。用字符串内重复行去测,会得到漂亮的压缩率,却对真实输出零效果。
|
|
8
|
+
|
|
9
|
+
复测的做法:从宿主类型定义或现有实现里确认真实结构,构造同样的形状跑一遍,对比前后长度、可解析性、关键字段是否保留。
|
|
10
|
+
|
|
11
|
+
## PowerShell 会谎报退出码
|
|
12
|
+
|
|
13
|
+
原生命令只要往 stderr 写任何东西(`npm` 的 notice/progress、Node 的 `DeprecationWarning`、`git push` 的进度行),PowerShell 就会把它包成 `NativeCommandError`,工具层看到的退出码变成 1——**即使命令实际完全成功**。
|
|
14
|
+
|
|
15
|
+
判据:不要只信退出码,用能独立复核的状态判断。
|
|
16
|
+
|
|
17
|
+
- git 推送:看 `git status -sb` 还有没有 `ahead`,而不是看 `git push` 的退出码。
|
|
18
|
+
- npm 发布:看 `npm view <pkg>@<ver> version`,而不是看 `npm publish` 的退出码。
|
|
19
|
+
- 脚本内部:Windows 上避免 `execFileSync` + `shell:true` + args 数组(会触发 DEP0190 警告写 stderr),改用 `execSync` 的字符串形式。
|
|
20
|
+
|
|
21
|
+
## 用结构验证,不要用 grep 验证
|
|
22
|
+
|
|
23
|
+
`grep` 到关键词只证明这段文字在文件里存在,不证明它生效:它可能整行被注释掉、可能在错误的缩进层级、可能被后面的定义覆盖。
|
|
24
|
+
|
|
25
|
+
验证配置类文件时,解析它、取出**最终生效的那一份**、断言字段存在。补丁 YAML 的典型陷阱是同一个 `id` 有多个定义,最后写入的才生效。
|
|
26
|
+
|
|
27
|
+
`.arch/` 是架构引擎自己的 shadow Git,不要 `git add` 进去;仓库已用 `.gitignore` 忽略,克隆后它不存在,需要时重新 `arch init`。
|
|
28
|
+
|
|
29
|
+
- `activate --node X --before Y` 只加 X→Y 这一条边,上游边不会自动出现。要落在两个节点之间,同时写 `--after A --before B`。
|
|
30
|
+
- `activate` 之后必须 `focus --node X` 核对 `upstream_edges` 与 `downstream_edges` 都不为空,再继续。
|
|
31
|
+
- 已经在主干的节点没有"只改接线"的命令;绕法是 `deactivate` 再 `activate`,但 `deactivate` 会把它移进迷雾区,之后要确认状态不是 `fog`。
|
|
32
|
+
- `collapse` 之后用 `focus` 确认 `spec` 已更新;如果仍显示旧 spec,说明写入没生效,不要假设成功。
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
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).
|
|
4
|
+
|
|
5
|
+
~~~text
|
|
6
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
7
|
+
│ DSH host (engines >=0.2.1-rc.5 <0.2.4-0) │
|
|
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
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
26
|
+
~~~
|
|
27
|
+
|
|
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.
|
|
29
|
+
|
|
30
|
+
## 1) lean layer (lib/lean/)
|
|
31
|
+
|
|
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.
|
|
39
|
+
|
|
40
|
+
## 2) toolface layer (lib/toolface/)
|
|
41
|
+
|
|
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).
|
|
48
|
+
|
|
49
|
+
## 3) router layer (lib/router.js - lib/bands.js)
|
|
50
|
+
|
|
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.
|
|
56
|
+
|
|
57
|
+
## File responsibilities
|
|
58
|
+
|
|
59
|
+
| File | Responsibility |
|
|
60
|
+
|---|---|
|
|
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 |
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# 架构(architecture)
|
|
2
|
+
|
|
3
|
+
> 三层一图:**lean → toolface → router**,全部收敛在一张 cordis 插件卡(一个预设 + 少量顶层行)。中文为主,英文版是 [architecture.en.md](./architecture.en.md)。
|
|
4
|
+
|
|
5
|
+
~~~text
|
|
6
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
7
|
+
│ DSH 宿主(engines >=0.2.1-rc.5 <0.2.4-0) │
|
|
8
|
+
├─────────────────────────────────────────────────────────────────────┤
|
|
9
|
+
│ 预设 preset-lean-router(frag-preset.patch.yml 并集快照 = 唯一生效行) │
|
|
10
|
+
│ │
|
|
11
|
+
│ ① lean 层(票 03) │
|
|
12
|
+
│ - 轮次压缩:thresholdRatio 0.25 / retainTokens 20000 / retries 1 │
|
|
13
|
+
│ - 工具输出裁剪:8192 / 4096 / 1024 + marker │
|
|
14
|
+
│ - 关 6 个冗余插件;行为纪律双档(lean 13 / balance 3) │
|
|
15
|
+
│ - plan-mode v1 并入 │
|
|
16
|
+
│ ② toolface 层(票 04) │
|
|
17
|
+
│ - describe() 只留预设自有工具 + code_run(遮蔽 mcp__ 与预设外) │
|
|
18
|
+
│ - execute() 拒绝直呼被遮蔽名;程序内经 code_tools_search 发现调用 │
|
|
19
|
+
│ ③ router 层(票 05) │
|
|
20
|
+
│ - 首轮捕获 [router] band=…;三带近场引导;/band │
|
|
21
|
+
├─────────────────────────────────────────────────────────────────────┤
|
|
22
|
+
│ 顶层行:preset-lean-router-balance / lean-delivery-gate / │
|
|
23
|
+
│ lean-concurrency / lean-router-router / lean-router-commands │
|
|
24
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
25
|
+
~~~
|
|
26
|
+
|
|
27
|
+
> 2.0.0 移除了原 ④ skillgate、⑤ audit、⑥ panel 三层:不再内置 31 技能、不再每轮打分门控、不再有审计通道与技能面板 UI。
|
|
28
|
+
|
|
29
|
+
## ① lean 层(lib/lean/)
|
|
30
|
+
|
|
31
|
+
- **入口**:`lib/lean/index.js`,由预设并集快照内的行加载。
|
|
32
|
+
- **轮次压缩**:`compaction.js`,阈值 0.25 / 保留 20000 tokens / 重试 1 次 / 自动触发。
|
|
33
|
+
- **输出裁剪**:`pruner.js`,按工具分档 8192 / 4096 / 1024 字符并加截断 marker。
|
|
34
|
+
- **关插件**:`disabled.js` 列出并关掉 6 个冗余插件。
|
|
35
|
+
- **行为纪律**:`persona-text.js` 提供 lean 13 条与 balance 3 条两档 suffix。
|
|
36
|
+
- **plan-mode v1**:`plan-mode.js`(照抄上游 flash 政策段)。
|
|
37
|
+
- **加料件**:`delivery-gate.js`(默认关,2 轮交付门)与 `tool-concurrency.js`(glob/grep 并发标记,默认开),各自独立顶层行。
|
|
38
|
+
|
|
39
|
+
## ② toolface 层(lib/toolface/)
|
|
40
|
+
|
|
41
|
+
- **规则**:`rules.js` —— 遮蔽判据(`hiddenPrefixes` 默认 `['mcp__']`)与 `normalizeConfig` 校验。
|
|
42
|
+
- **作用域**:`scope.js` —— 决定哪些工具属于「预设自有」。
|
|
43
|
+
- **发现**:`discovery.js` —— 4 个 meta 工具(`code_tools_search` 等)。
|
|
44
|
+
- **传输**:`transport.js` —— `code_run` 把 TypeScript 程序交给 `ptcRuntime` 服务执行;子调用经注册表公开 `execute()` 走完整管线(校验/策略/审批)。
|
|
45
|
+
- **池**:`pool.js` —— 有序并发池(parallel 上限 10,exclusive 障碍);程序结束 `abandon()+drain()` 防迟到子调用。
|
|
46
|
+
- **执行器**:`executor.js` —— `describe()` 是模型请求面本身;`execute()` 派发前拒绝直呼被遮蔽名;真正的执行委托给 `@deepseek-ai/dsh-tool-executor-native`(缺失时退化为安装提示 stub)。
|
|
47
|
+
|
|
48
|
+
## ③ router 层(lib/router.js · lib/bands.js)
|
|
49
|
+
|
|
50
|
+
- **三带**:`bands.js` —— spec(先查后改,读优先)/ react(直接产出,写优先)/ weak(交给模型自判)。
|
|
51
|
+
- **首轮捕获**:`agent/inbox/claimed` 只认 `source.kind === 'user'`;`[router] band=… task=…` 显式指令优先于关键词分类。
|
|
52
|
+
- **近场引导**:`ctx.systemPrompt.context()` 注册 dynamic context(order 220);同一带内文本恒定,宿主判等零写入。
|
|
53
|
+
- **勤勉自检**:每 `diligenceEvery`(默认 10)轮在引导文本尾部追加轮次提醒。
|
|
54
|
+
- **命令**:`/band`(L249-260);预设内两实例分流:`lean-router-router`(hooks:true, commands:false, diligenceEvery:10)+ `lean-router-commands`(hooks:false, commands:true)(frag-router.patch.yml)。
|
|
55
|
+
|
|
56
|
+
## 文件职责
|
|
57
|
+
|
|
58
|
+
| 文件 | 职责 |
|
|
59
|
+
|---|---|
|
|
60
|
+
| lib/index.js | cordis 插件入口(包根;2.0.0 起为空实现,只保留合法插件形状) |
|
|
61
|
+
| lib/bands.js | 三带定义与关键词分类 |
|
|
62
|
+
| lib/router.js | 路由层:捕获 / 近场引导 / 勤勉自检 / `/band` |
|
|
63
|
+
| lib/lean/* | 轮次压缩、输出裁剪、关插件、行为纪律、plan-mode、交付门、并发标记 |
|
|
64
|
+
| lib/toolface/* | 工具遮蔽、`code_run` 传输、发现工具、并发池、执行器 |
|
|
65
|
+
| presets/base/*.patch.yml | 分片;`scripts/build-bundle.mjs` 拼成 cordis.patch.yml |
|
|
66
|
+
| scripts/ | build-bundle / doctor / verify / install / integrate-preset |
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
> English version of [changelog.md](./changelog.md). Versions follow package.json (currently 0.2.3).
|
|
4
|
+
|
|
5
|
+
## 0.2.3 (2026-11-30)
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **Version line switched back**: from `2.2.x` to `0.2.x`, which now owns the `latest` tag. The earlier 1.x / 2.x increments never reflected real compatibility promises and the package is still experimental; resetting to 0.x keeps the major slot honest for future breaking changes.
|
|
10
|
+
- **Content is identical to 2.2.8**, with no functional difference: it includes the `history_budget` threshold lowered from 12000 to 4000 (the host `tool-result-pruner` already compresses anything over 8192 into 5159 characters, so the old threshold never fired), old tool-result downgrade, concrete parallel-call guidance, the ledger snapshot and `/token-report json`.
|
|
11
|
+
- Existing `2.2.x` releases stay on the registry, so consumers on `^2.2` will not follow automatically; install `0.2.3` explicitly to move to the new line.
|
|
12
|
+
|
|
13
|
+
## 2.2.8 (2026-11-30)
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **history_budget threshold lowered from 12000 to 4000**: reading a real session back showed the 12000 threshold introduced in 2.2.4 **never fired** — the host's `tool-result-pruner` first compresses any tool result over 8192 characters into 4096 + marker + 1024 = 5159 characters. On the live session surface, 183 of 204 tool results were already under 200 characters and the largest was exactly 5159, so nothing could ever reach 12000. At 4000 (head 2400 + tail 1600, 400-character tail floor unchanged) this module now runs before the host pruner. A measured 41889-character sample collapses to 4000 (-90.5%).
|
|
18
|
+
- Recorded as a hard constraint: after shipping any size-cap optimization, read a real session back and confirm the number of **times it fired**; a passing unit test is not evidence that it took effect.
|
|
19
|
+
|
|
20
|
+
### Tests
|
|
21
|
+
|
|
22
|
+
- 269 tests, 268 passing, 0 failing, 1 skipped; `verify` passes.
|
|
23
|
+
|
|
24
|
+
## 2.2.7 (2026-11-30)
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **Ledger snapshot on disk**: after recording one usage entry, the ledger atomically writes an aggregate to `<DSH_HOME>/storages/lean-router/token-report.json` (`DSH_HOME` defaults to `~/.dsh`; override with `config.snapshotPath`, disable with `config.snapshot: false`). The agent can now `read` the same data the command shows instead of asking the user to copy it. The snapshot holds totals plus per-session records/prompt/input/cacheRead/cacheWrite/output/reasoning and the latest turn/step/seq.
|
|
29
|
+
- **`/token-report json` scope**: the command gains `json`, which prints the snapshot file content byte for byte; a missing file yields `{"error":"snapshot missing","path":"..."}`. The `session` and `all` text formats are unchanged.
|
|
30
|
+
- Writes are atomic (`.tmp` then rename) and the directory is created on demand; any write failure warns once and never affects recording or the command.
|
|
31
|
+
|
|
32
|
+
### Tests
|
|
33
|
+
|
|
34
|
+
- 6 new cases (default path and config resolution, single-record shape, cross-session aggregation, disable switch, write failure not throwing, `json` matching the file bytes); the full suite is 269 tests, 268 passing, 0 failing, 1 skipped.
|
|
35
|
+
|
|
36
|
+
## 2.2.6 (2026-11-29)
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- **Old tool-result downgrade**: new `lean-history-downgrade` plugin. On `agent/pre-step` (before history is finalized) it inspects the model-visible tool results and, once the number of un-downgraded ones strictly exceeds 32, downgrades them in one batch while always keeping the 6 most recent intact; error results and already-downgraded results are skipped. Rewrites go through `session.append` with `surfaceOp: replace`, so the original events stay in the log and remain replayable, paired with a `compaction/prune` record. The plugin is fail-safe end to end: the hook body is wrapped in try/catch, failures only warn once and never block a step; missing `surface` capabilities are skipped silently; nothing throws at construction; `DSH_LEAN_ROUTER_DOWNGRADE=0` disables it entirely.
|
|
41
|
+
- **Why 32/6**: recomputed against the measured ~155k-token prefix per turn and the cache price gap, 16/6 amortizes to roughly 30k tokens saved per turn (19%) while 32/6 yields about 52k (34%), so 32/6 was chosen. A real Session test downgraded 33 of 39 results (each 12000 chars), saving 391,974 characters in one batch with surface length and order unchanged, and a second run changed nothing.
|
|
42
|
+
|
|
43
|
+
### Tests
|
|
44
|
+
|
|
45
|
+
- 23 new cases (9 pure-function, 14 plugin); the full suite is 263 tests, 262 passing, 0 failing, 1 skipped, with `verify` passing.
|
|
46
|
+
|
|
47
|
+
## 2.2.5 (2026-11-29)
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- **Concrete parallel-call guidance**: the generic "Batch independent calls into one step" line in persona rule 6 proved ineffective in practice — across 22165 assistant messages in the corpus, 91.65% carried a single tool call and only 4.68% carried two or more (10.88% under the lean-router preset). It is replaced by a 306-character block: independent `read`/`grep`/`glob`/`read_image` calls in one message really do overlap; `pwsh`/`edit`/`write` are serialized within a batch but still cost only one round trip; and a masked tool name must never be batched, because it rejects the whole batch and no sibling call runs.
|
|
52
|
+
- **No façade tool added**: tool calls are already a first-class batch primitive in the host (array input, default concurrency cap 10, results written back in model order) and nothing in this repo restricts parallelism, so this release changes guidance text only.
|
|
53
|
+
- persona suffix grows from 3862 to 4130 characters (+268), still inside the 4200-character ceiling.
|
|
54
|
+
|
|
55
|
+
### Tests
|
|
56
|
+
|
|
57
|
+
- 12 new assertions (four read-only tool names, three write-oriented names, masked-name whole-batch rejection, block ≤320 characters, suffix ≤4200); the full suite is 240 tests, 239 passing, 0 failing, 1 skipped.
|
|
58
|
+
|
|
59
|
+
## 2.2.4 (2026-11-29)
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
|
|
63
|
+
- **History size budget**: tool results now get a 12000-character ceiling before they enter the conversation history — anything larger keeps the first 60% and last 40%, with the middle replaced by a single marker that reports how many characters were elided and tells the model to re-read via offset/limit or a narrower query. Whole lines in the dropped middle that match error/failure/exit-code/conclusion patterns are carried back, at most 20 lines. Valid JSON is never truncated (stays parseable), and the result is always shorter than the input and idempotent. It runs as a second stage after the existing output compaction (`lib/toolface/executor.js`), still touching only content and never the value.
|
|
64
|
+
- **Why this target**: measured across 221 sessions and 21844 usage records on this machine — 96.6% of prompt tokens are cacheRead (131.8k per turn), fresh input is only 4.6k per turn and output 1.0k; the first-turn prompt (static base) has a median of 23.4k and history accounts for roughly 83% of each turn's prompt. This release therefore attacks history size rather than squeezing the 17% static base further.
|
|
65
|
+
|
|
66
|
+
### Tests
|
|
67
|
+
|
|
68
|
+
- New `test/history-budget.test.mjs` adds 13 cases; the full suite is 239 tests, 238 passing, 0 failing, 1 skipped, and `verify` passes.
|
|
69
|
+
- Production-shaped recheck: a 128k-character sample collapses to 12000 (-90.6%), head and tail preserved verbatim, and a second call returns the same reference.
|
|
70
|
+
|
|
71
|
+
## 2.2.3 (2026-11-29)
|
|
72
|
+
|
|
73
|
+
### Changed
|
|
74
|
+
|
|
75
|
+
- **Removed the forced opener**: the `spec` band no longer asks reasoning and the first reply to start with "We need …", and `react` no longer asks for "I'm doing …". Real-world use showed no benefit to routing or output quality — only extra fixed tokens and stylistic noise. `guideText` now keeps just the task tone plus the fixed convergence and anti-drift anchors (`GUIDE_TAIL`). `personaText`, `ROUTER_PROMPT` and the preset shards are untouched.
|
|
76
|
+
- **Tests inverted**: `test/router-bands.test.mjs` now asserts that every band's `guideText` contains neither "We need", "I'm doing", nor any first-reply constraint, so the opener cannot creep back in.
|
|
77
|
+
|
|
78
|
+
## 2.2.2 (2026-11-29)
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
|
|
82
|
+
- **Session creation failed outright (`agent-preset/invalid`)**: after 2.2.1 moved `lean-usage-ledger` into the presets' `plugins` array, the plugin read `ctx.commands` directly inside `apply`; cordis 4 requires a declared injection before that read, so it threw `cannot get property "commands" without inject` and both creating and restoring sessions failed. The plugin now declares `inject: ['commands']` (named export and default export alike): while `commands` is missing cordis waits instead of loading, and when the command seam never appears the plugin simply does not mount — neither path disturbs the host anymore, and `/token-report` behaves as before.
|
|
83
|
+
- **Regression test**: new `test/usage-ledger-inject.test.mjs` loads the plugin with real cordis in the "plugin first, `commands` later" order and asserts it does not throw and registers `/token-report` once the service appears.
|
|
84
|
+
|
|
85
|
+
## 2.2.1 (2026-11-29)
|
|
86
|
+
|
|
87
|
+
### Fixed
|
|
88
|
+
|
|
89
|
+
- **`/token-report` never appeared in a real session**: `lean-usage-ledger` was registered as a top-level add-on (the same layer as `lean-delivery-gate` and `lean-concurrency`), but the `ctx.commands` service is provided inside the preset scope, so the top-level row never received it and the plugin silently took its degraded path. It now lives in the `plugins` array of both the `lean` and `balance` presets, next to `command-goal`, so the command actually registers.
|
|
90
|
+
|
|
91
|
+
## 2.2.0 (2026-11-29)
|
|
92
|
+
|
|
93
|
+
### Added
|
|
94
|
+
|
|
95
|
+
- **`/token-report` ledger command**: new `lib/lean/usage-ledger.js`, mounted as the top-level preset add-on `lean-usage-ledger`. It subscribes to the host's `session/event` feed and keeps only `assistant/message` events that carry `usage`. The command reports the record count, the `prompt` total (input+cacheRead+cacheWrite), all five usage fields, and the latest record's `turn/step/seq`; with no records it says so explicitly. Every failure path only warns, and unloading releases the subscription.
|
|
96
|
+
|
|
97
|
+
### Improved
|
|
98
|
+
|
|
99
|
+
- **Lazy parameter schemas in `search`**: `code_tools_search` no longer returns the full `parameters` and `output` schemas, but a `params` array of argument names (`noParams` when nothing is enumerable); the complete schema comes from `code_tools_describe`. A full 8-row page measured 8380 to 1924 characters (-77%).
|
|
100
|
+
- **Lean persona no-op audit**: removed the language requirement the host already injects, the `DELIVER` gate duplicated by rule 4, and the `Diligence` hook overlapping rule 1, then tightened wording: 4581 to 3862 characters (-15.7%). All 13 numbered rules and their criteria remain.
|
|
101
|
+
|
|
102
|
+
### Notes
|
|
103
|
+
|
|
104
|
+
- All three changes are static or output-side; real gains need a restart to be observed inside the host, and no device verification has been done yet.
|
|
105
|
+
- Since `search` now returns only argument names, call `describe` before invoking an unfamiliar tool; the SDK text has been rewritten to say so.
|
|
106
|
+
|
|
107
|
+
## 2.1.1 (2026-11-29)
|
|
108
|
+
|
|
109
|
+
### Improved
|
|
110
|
+
|
|
111
|
+
- **Static tool surface slimmed**: the `code_run` description drops from 459 to 298 characters and the SDK explanation from 2340 to 1738, for 3346 to 2526 in total (-24.5%). Required fields, enums, property names and the conditional `timeoutMs` semantics are all locked by new structural contract assertions, cutting roughly 820 characters of per-turn resident injection.
|
|
112
|
+
- **Conservative tool-output compaction**: new `lib/lean/output-slim.js`, wired into `lib/toolface/executor.js` by wrapping each visible definition's `finalizeContent` in place. Compaction only engages above 2000 characters: adjacent duplicate lines collapse, and adjacent duplicate elements of a string array collapse to the first element plus one marker element. Error, exception, failure, exit-code, path and conclusion lines are never folded. JSON output stays parseable with unchanged keys and types, only the model-visible content changes, the program-visible value never does, and any pre-existing `finalizeContent` is chained rather than replaced.
|
|
113
|
+
|
|
114
|
+
### Notes
|
|
115
|
+
|
|
116
|
+
- Both changes are static or output-side; real gains need a restart to be observed inside the host, and no device verification has been done yet.
|
|
117
|
+
- Compaction pays off on repetitive log output (example: 3788 to 172 characters) and is a no-op for output without repetition.
|
|
118
|
+
|
|
119
|
+
## 2.1.0 (2026-11-29)
|
|
120
|
+
|
|
121
|
+
### Added
|
|
122
|
+
|
|
123
|
+
- **Standalone token ledger** under `lib/token-ledger/`: `createMemoryUsageAdapter` (dedupe and sort by session/turn/step/seq, range reads and subscriptions), `captureRequestSnapshot` (metadata and hashes only; raw prompts and tool output are rejected) and `createTokenReport` (real Usage kept apart from attribution, explicit assertions produce `pass`/`successRate`/`reasons`).
|
|
124
|
+
- **Live Usage adapter** in `lib/token-ledger/live.js`: subscribes to the host's `session/event` and keeps only `assistant/message` events that carry `usage`; `hydrate` backfills through the half-open `snapshotEvents` range; missing services, logger failures and subscription errors all degrade to skip, and `dispose` is idempotent.
|
|
125
|
+
- **Package exports** `./token-ledger` and `./token-ledger/live`.
|
|
126
|
+
|
|
127
|
+
### Changed
|
|
128
|
+
|
|
129
|
+
- **Band-specific reasoning opener**: the spec `guideText` now asks reasoning and the first reply to start with "We need …" and name the gap before acting; react asks to start with "I'm doing …" and name the action; weak adds no forced opener. `personaText`, `ROUTER_PROMPT` and the preset shards are untouched.
|
|
130
|
+
|
|
131
|
+
### Notes
|
|
132
|
+
|
|
133
|
+
- The ledger only replays durable Usage and never re-runs a model; the live adapter is not mounted in the preset yet, so nothing is captured at runtime.
|
|
134
|
+
- Host 0.2.2-rc.5 has no costMeter service, so per-request Usage must come from `session/event`, never from cost-meter aggregates.
|
|
135
|
+
|
|
136
|
+
## 2.0.0 (2026-11-29)
|
|
137
|
+
|
|
138
|
+
**Breaking: the skills subsystem is removed.** Three layers remain - lean token saving, router thinking-chain routing and toolface tool masking.
|
|
139
|
+
|
|
140
|
+
### Removed
|
|
141
|
+
|
|
142
|
+
- **mattpocock skill collaboration**: `lib/skillgate.js` (per-turn scoring of all 31 skills, tiering, ds-* arbitration, 8k soft degrade), `lib/skill-provider.js` (rank-350 provider, two-level sources), `lib/gate-runner.js` (pre-step gating), `assets/skills/` (the 31 bundled skill bodies), `assets/skills.matrix.json`, `assets/gating.weights.json` and `skills.manifest.json` are gone, and the `skill-lean-router` provider row is dropped from the preset union snapshot.
|
|
143
|
+
- **Audit and panel**: `lib/audit-sink.js`, `lib/audit-commands.js` and `ui/go.json` are gone; the `/lean-audit` command is retired.
|
|
144
|
+
- **Skills panel UI**: `lib/skills-panel.js` and `lib/client.js` are gone; the `/panel` command is retired; `package.json` no longer declares `exports["./client"]` or `dsh.client`, so no client bundle is produced.
|
|
145
|
+
- **The `/skill` command** is retired; the router keeps only `/band`.
|
|
146
|
+
- The `npm run drift` script and `scripts/check-drift.mjs` are gone (there are no skill copies left to drift).
|
|
147
|
+
- Docs `docs/matrix.md`, `docs/matrix.en.md`, `docs/技能门控-设计说明.md`, `docs/面板-设计说明.md` and `docs/HANDOFF-2026-11-22.md` are deleted.
|
|
148
|
+
|
|
149
|
+
### Changed
|
|
150
|
+
|
|
151
|
+
- `lib/index.js` is now a valid no-op plugin (`inject = []`, `apply()` returns undefined); the host no longer needs a `lean-router-client-host` row.
|
|
152
|
+
- `lib/router.js` drops `skills` from its `inject` list (`["agents","systemPrompt","commands"]`). `gate` / `audit` / `auditPath` / `weightsPath` are still accepted with no behaviour, so an old patch config cannot stop the plugin from starting.
|
|
153
|
+
- doctor grew from 7 checks to 11, including two anti-regression checks: the patch must not contain `skill-lean-router` or `lean-router-client-host` again.
|
|
154
|
+
|
|
155
|
+
### Tests
|
|
156
|
+
|
|
157
|
+
- Nine skill-related test files were deleted; the router, plugin-entry and integration-preset assertions were narrowed accordingly. Current `npm test`: 157 tests / 156 pass / 1 skip / 0 fail; `npm run verify` PASS.
|
|
158
|
+
|
|
159
|
+
## 1.1.0 (2026-11-25)
|
|
160
|
+
|
|
161
|
+
- Changed (surface, decided by the user): the skills panel moves from "header button + body overlay" to a **right sidebar tab**. The overlay had to be opened, covered the conversation and could not sit side by side, so it was never a usable form; the 1.0.9 `#lean-router-panel` overlay is dropped entirely.
|
|
162
|
+
- New: the right-sidebar contract follows the real examples `@modusensus/dsh-mneme` and `dsh-cost-meter` - the tab type and its guide entry go to `sidebarRightTabs.register({ id, kind, title, guide })` (checked with `get(id)` first, because the host throws `tab type id … is already registered`), and the body and title go to `sidebar.right.pane.tab` / `sidebar.right.pane.tab.title` with a `{ name, key }` spec.
|
|
163
|
+
- New: the header "Skills" button stays as a shortcut and opens the tab through `ctx.get("sidebarRight").openTab(kind)`.
|
|
164
|
+
- Fixed: the opener now resolves `sidebarRight` from the scoped ctx delivered by `ctx.inject(["slots"])`, so it cannot hit the "service not registered yet" timing trap again.
|
|
165
|
+
- Constraint: nothing is appended to `document.body` any more; this version is the shell only (a title and two lines), and every style inherits host theme tokens instead of hard-coded colours. 224 tests green.
|
|
166
|
+
|
|
167
|
+
## 1.0.9 (2026-11-24)
|
|
168
|
+
|
|
169
|
+
- Fixed (real install, rendering): the header button appeared, but clicking it drew only a thin black bar across that row. The panel used to render as a React component inside the header slot, so `position: fixed` was confined to that row by an ancestor's `transform` / `overflow`. It is now a plain DOM overlay appended to `document.body` (`#lean-router-panel`), with only the button left in the slot; the overlay sits at `z-index: 2147483000`, closes on backdrop or ✕ click, and the button toggles it.
|
|
170
|
+
- Tests: new assertion that clicking the button mounts the panel on `body` and clicking again removes it; 222 tests green.
|
|
171
|
+
|
|
172
|
+
## 1.0.8 (2026-11-24)
|
|
173
|
+
|
|
174
|
+
- Fixed (real install, client timing): `apply` in `lib/client.js` ran before the `slots` service was registered. `ctx.get("slots")` was therefore `undefined`, so 1.0.7 went straight to the DOM fallback - and at that moment `document.body` did not exist yet, so `domFallback()` returned silently. On a real host that looks like "bundle loaded, zero console errors, nothing on screen". It now mirrors how `dsh-cost-meter` uses `e.inject(["locale"], …)`: `ctx.inject(["slots"], cb)` waits for the service and re-runs when it changes.
|
|
175
|
+
- Improved: the `register` spec now carries an `inject: () => ({})` props factory (cost-meter passes that field on every registration).
|
|
176
|
+
- Improved: the fallback is now "insert the pure-DOM button only if nothing registered after 2 seconds", so a failure to mount is visible instead of silent.
|
|
177
|
+
- Tests: `test/client-plugin.test.mjs` now covers three paths - registration once `ctx.inject(["slots"])` resolves, direct registration when `ctx.inject` is absent, and the 2-second DOM fallback when slots never appears. 221 tests green.
|
|
178
|
+
|
|
179
|
+
## 1.0.7 (2026-11-24)
|
|
180
|
+
|
|
181
|
+
- Fixed (critical, client side, on a real install): how `lib/client.js` obtains the slot service. In the client-side cordis, `slots` and `register` are **services**: reading `ctx.register` / `ctx.slots` directly throws `Error: cannot get property "register" without inject`. The old code performed that property access outside a `try`, so the whole `apply` failed and even the pure-DOM fallback never ran - which is exactly why the header "Skills" button never appeared (real 0.2.3 console text: `dsh-lean-router: failed: Error: cannot get property "register" without inject`). It now follows the `dsh-cost-meter` shape: `const slots = ctx.get("slots")`, then `slots.inject(slot, () => slots.register(spec, Component))`; the DOM fallback only runs when the service is missing.
|
|
182
|
+
- New regression: `test/client-plugin.test.mjs` loads the real `lib/client.js` behind a fake `window.__ModuleLoader__`, with a ctx whose `register` / `slots` properties throw on read; it asserts registration goes through `ctx.get("slots")` and returns a disposer, and that the missing-service path really appends `#lean-router-dom-fallback`. 220 tests green.
|
|
183
|
+
|
|
184
|
+
## 1.0.6 (2026-11-23)
|
|
185
|
+
|
|
186
|
+
> 1.0.5 is already on npm, but the two defects below only surfaced the first time it was activated on a real 0.2.3 host. Use 1.0.6 instead.
|
|
187
|
+
|
|
188
|
+
- Fixed (critical, on a real install): the `inject` shape in `lib/index.js`. cordis accepts only two shapes - an array of service names, or a "service name to intercept config" map (`registry.ts: Inject<M> = (keyof M)[] | { [K in keyof M]?: M[K] }`). The `{ required: [], optional: ["skills"] }` written in 1.0.5 was parsed as two services named `required` and `optional`, so the host row `lean-router-client-host` stayed PENDING forever (real diagnostic: `pending (waiting for services: required, optional)`) and `apply` never ran: `dsh-client-modules` never scanned the client bundle (no header button) and the boot self-check `boot.log` was never written. Now `inject = []` with `ctx.inject(["skills"], cb)` inside `apply`: the host row activates immediately and the preset row registers the provider once `skills` is available.
|
|
189
|
+
- Fixed (critical, on a real install): `/panel` had an empty `input.hint`. On 0.2.3 `@deepseek-ai/dsh-commands` throws `TypeError: command "panel" input hint must not be empty` from `normalizeDefinition`, which kept the whole `lean-router-commands` entry from activating. It is now `[summary|skills|round|stats|never] [all]`, matching what `parsePanelArgs` actually accepts.
|
|
190
|
+
- New regressions: `test/plugin-entry.test.mjs` asserts the inject shape (no `required`/`optional` keys), that the host scope never touches `skills`, that the preset scope goes through `ctx.inject`, and the no-`ctx.inject` fallback; `test/router.test.mjs` asserts every command's input hint is non-empty. 218 tests green.
|
|
191
|
+
|
|
192
|
+
## 1.0.5 (2026-11-23)
|
|
193
|
+
|
|
194
|
+
### Adapt to the DSH 0.2.3 kernel (measured baseline 0.2.3-alpha.2)
|
|
195
|
+
|
|
196
|
+
- Fixed (critical): the `engines.dsh` upper bound goes from `<0.2.3-0` to `<0.2.4-0`. DSH's compatibility check (`evaluatePluginCompatibility` in `@deepseek-ai/dsh-app-boot`) calls `semver.satisfies(runtime, range, { includePrerelease: true })`; by semver prerelease precedence `0.2.3-0 < 0.2.3-alpha.2`, so the old range judged 0.2.3-alpha.2 incompatible and blocked both installation and activation. The widened range covers the whole 0.2.1-rc.5 through 0.2.3 line.
|
|
197
|
+
- Change: the `@deepseek-ai/dsh-tool-executor-native` dependency goes from `^0.2.2-alpha.3` to `>=0.2.2-alpha.3 <0.2.4-0`. Measured: 0.2.3-alpha.2 and 0.2.2-rc.5 are byte-identical in implementation (SHA256 over every file; only `package.json` differs), so the vendored executor needs no change.
|
|
198
|
+
- Change: the `@deepseek-ai/cordis` peer goes from `~4.1.0` to `>=4.1.0-0 <4.3.0-0`. The 0.2.3-alpha.2 host ships cordis 4.2.0-alpha.1, which the old range excluded (prerelease). cordis 4.2 only renames internal symbols (`symbols.config` to `symbols.metadata`) and reworks `ValidationError` issue paths; the **effect contract is unchanged**, and this package never imports cordis at runtime - it only uses its plugin shape - so no code change was needed.
|
|
199
|
+
- Re-checked, nothing broken: the client loading contract (`dsh-client-modules` scanning `dsh.client` plus `exports["./client"]`) is identical to 0.2.2, and all 26 `@deepseek-ai/dsh-*` plugins referenced by the patches still exist in 0.2.3.
|
|
200
|
+
|
|
201
|
+
### Skills panel, stage 1 (1.0.5 content that had only lived in commits, never published)
|
|
202
|
+
|
|
203
|
+
- New: the `/panel` command as the usable form of the skills panel (server-rendered, so it does not depend on a client slot); the client overlay now groups by scenario, adds sub-views, hides skills that are off everywhere and fixes column alignment.
|
|
204
|
+
- Fixed (on a real install): the package now loads at host scope so `dsh-client-modules` actually scans its client bundle; `react-dom` was dropped in favour of `ctx.inject`/`ctx.register`; a pure-DOM fallback tells "bundle never loaded" apart from "slot never mounted".
|
|
205
|
+
- Fixed: skill injection is now optional, so the host's patch row really applies; the per-turn skill gate is enabled.
|
|
206
|
+
|
|
207
|
+
## 1.0.4 (2026-11-22)
|
|
208
|
+
|
|
209
|
+
- New (skills panel, stage 1): client plugin skeleton - a "Skills" button in the session header plus a placeholder overlay panel (`lib/client.js`, `dsh.client.platform=web`, `exports['./client']`). The loading contract follows dsh's `window.__ModuleLoader__.load({ id, factory })`, UI registration goes through `ctx.slots.register`, and the panel is portalled onto `body` so it never depends on a sidebar. Stage 1 only proves the wiring; real data and one-click workflows arrive in later versions.
|
|
210
|
+
- Improved (visibility): `/band` output goes from three lines of plain English to a scannable layout - a one-line status first (e.g. `▲ react · 已按首条消息分类,关键词不再改带 · 可选 spec / react / weak`), a band comparison table in the middle (the current band marked `**▲ spec**` in bold), and "the last automatic classification" with its evidence (build/fix hit counts plus the matched words) at the end.
|
|
211
|
+
- New: `lib/bands.js` exports `explainClassification(text)`, returning the band, both hit counts and up to three matched words; `classifyTask` is now a thin wrapper over it, so results are identical to 1.0.3.
|
|
212
|
+
- New: the routing state gains `manual` and `last` fields, telling "explicitly set / auto-classified from the first message / not classified yet" apart. The near-field guide text is unchanged (the zero-write contract still holds).
|
|
213
|
+
- Change: `/band` with no arguments now equals `/band help` and prints the status panel; the set confirmation changes from `Router band set to x.` to `▲ x · 已切换`.
|
|
214
|
+
- Tests: the `/band` assertions now check "first line is the status / the band table exists / the current band is bold ▲ / a clear note when no message has arrived"; 203 tests green.
|
|
215
|
+
|
|
216
|
+
## 1.0.3 (2026-11-22)
|
|
217
|
+
|
|
218
|
+
- Fix (fatal on a real host): the preset's plugins list wrongly carried the **host-level service plugin** `ptc-runtime` (`@deepseek-ai/dsh-ptc-runtime-node`). A preset activates in its own scope, so mounting that service twice fails → `agentPresets.register` throws → the whole `preset-lean-router` is never registered (observed: only balance was listed). The host already mounts the row in `dsh-base/cordis.patch.yml` L407-408, and `code_run`'s `ctx.get('ptcRuntime')` resolves upward, so the preset must not declare it.
|
|
219
|
+
- Change: the `frag-preset` union drops from 22 to 21 rows (overrides 20 + toolface); `cordis.patch.yml` rebuilt.
|
|
220
|
+
- Add: `integration-preset` and `patch-yaml` now assert `ptc-runtime` never appears inside a preset.
|
|
221
|
+
|
|
222
|
+
## 1.0.2 (2026-11-22)
|
|
223
|
+
|
|
224
|
+
- Fix (fatal on a real host): `lib/lean/tool-concurrency.js` had `apply()` return a plain object; cordis validates an apply's return value as an effect and accepts only a dispose function / null / undefined / thenable, so the host threw `Invalid effect` — the plugin showed as "error" and the `preset-lean-router` row declared after it in the same overlay was never registered (only balance appeared in the preset list).
|
|
225
|
+
- Add: one "apply's return value must satisfy the cordis effect contract" assertion in each of the `tool-concurrency` / `delivery-gate` / `router` / `toolface` suites.
|
|
226
|
+
|
|
227
|
+
## 1.0.1 (2026-11-22)
|
|
228
|
+
|
|
229
|
+
- Fix: `cordis.patch.yml` had a mis-indented `ptc-runtime` row (dsh refused to parse the overlay; installs rolled back).
|
|
230
|
+
- Fix: `npm test` uses `node --test "test/*.test.mjs"` (directory argument breaks on Node 24).
|
|
231
|
+
- Add: regression test parses every patch with js-yaml and the `!!js` tag, matching dsh's overlay loader.
|
|
232
|
+
- Chore: js-yaml added as a devDependency; version references bumped.
|
|
233
|
+
|
|
234
|
+
## v1.0.0 (2026-11-21)
|
|
235
|
+
|
|
236
|
+
All six layers of one plugin card have landed (tickets 02-06 delivered + master integration); the audit panel (ticket 07) is in flight and the real installer (ticket 09) is pending.
|
|
237
|
+
|
|
238
|
+
### Added
|
|
239
|
+
|
|
240
|
+
- **Lean layer, four mechanisms** (ticket 03, lib/lean/): turn compaction (thresholdRatio 0.25 / retainTokens 20000 / retries 1 / auto), output pruning (8192/4096/1024 + marker), six disabled plugins (the disabled list), the dual-tier discipline persona (lean 13 rules + 3 soft gates + self-check hooks / balance 3 rules); add-ons delivery-gate (off by default, 2 rounds) and the glob/grep concurrency marker (on by default).
|
|
241
|
+
- **plan-mode v1 folded in** (lib/lean/plan-mode.js): a line-for-line copy of flash L93-107.
|
|
242
|
+
- **Toolface layer** (ticket 04, lib/toolface/): vendored dsh-codemode 0.3.0 (main @ f9758ec), 8 modules file-for-file with adaptation points annotated; masking of ['mcp__'] + everything outside the preset, the code_run transport, four meta tools, direct-call denial, retention dual cleanup, maxParallelSubCalls 10.
|
|
243
|
+
- **Router layer** (ticket 05, lib/router.js + lib/bands.js): spec/react/weak bands, the [router] explicit directive, keyword auto-classification, near-field guides (lean-router:guide, order 220), the diligence self-check (every 10 turns), /band and /skill commands, inherited-session skip.
|
|
244
|
+
- **Skillgate layer** (ticket 06, lib/skillgate.js + lib/skill-provider.js): per-turn scoring of all 31 skills (scenario mapping + keyword dual signals), autoScore 2 / hintScore 1 tiering, ds-* scene arbitration, tokenBudget 8000 soft degradation, near-field rendering, the in-memory audit ring buffer, the rank-350 provider, two-tier source resolution.
|
|
245
|
+
- **31 bundled skill copies** (assets/skills/ + skills.matrix.json + skills.manifest.json): the owner-decided model/user matrix (13 both / 10 model-only / 8 user-only).
|
|
246
|
+
- **Build & checks** (scripts/): build-bundle (base + 4 fragments into cordis.patch.yml), check-drift (warn-only), doctor (7 checks), integrate-preset (generates the frag-preset union snapshot), verify (build --check + doctor), install (prints install steps).
|
|
247
|
+
- **Four exports subpaths** (package.json): ./router, ./toolface, ./lean/delivery-gate, ./lean/tool-concurrency.
|
|
248
|
+
- **Bilingual docs** (this directory + README.md/README.en.md/NOTICE.md): the five topics bilingual and the four-upstream acknowledgment table (ticket 08).
|
|
249
|
+
|
|
250
|
+
### Rulings (recorded as v1 facts)
|
|
251
|
+
|
|
252
|
+
- **The frag-preset union snapshot is the sole effective preset row**: cordis patches replace preset rows as whole keys, so the same-id overrides in frag-lean/frag-toolface wipe each other; scripts/integrate-preset.mjs generates the union snapshot and is declared last in FRAGMENTS.
|
|
253
|
+
- **The balance preset row carries no routing directive for now**: the lean row's suffix already has ROUTER_PROMPT spliced in; the balance row keeps the placeholder comment line.
|
|
254
|
+
- **The plan-mode PTC sentence keeps the flash wording**: the trailing "Under programmatic tool mode ... run_code" sentence is unchanged (master ruling: run_code remains the built-in PTC transport).
|
|
255
|
+
- **Gating runs through the injection seam instead of re-calling list()**: when the host SkillRegistry.collect() cache is serving, audits are labeled mode "fallback-cached-list".
|
|
256
|
+
- **8k soft degradation**: tokenBudget 8000 with no count cap — only a total-volume soft guard.
|
|
257
|
+
|
|
258
|
+
### Engine and dependencies
|
|
259
|
+
|
|
260
|
+
- engines: `>=0.2.1-rc.5 <0.2.3-0` (measured baseline 0.2.2-rc.5).
|
|
261
|
+
- dependencies: `@deepseek-ai/dsh-tool-executor-native ^0.2.2-alpha.3` — when missing, the executor degrades to an install-hint stub (describe throws / execute rejects), never silent.
|
|
262
|
+
|
|
263
|
+
### In flight (not promised by this release)
|
|
264
|
+
|
|
265
|
+
- Ticket 07: persisting the audit JSONL, the ui/go.json panel card (decision rows + score table + token comparison + warning banner), hit statistics + manual weight configuration.
|
|
266
|
+
- Ticket 09: the real installer, fixture-path notes, --uninstall rollback.
|