dsh-lean-router 0.2.4 → 0.2.6

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/cordis.patch.yml CHANGED
@@ -108,7 +108,9 @@
108
108
  from files with grep/scripts instead of re-reading them into context. Keep NOTES short and
109
109
  factual (<=60 lines).
110
110
  9. Author incrementally: create a file once (skeleton), then extend it with edit. Never re-emit an
111
- unchanged file. After two failed shell patches, switch to the editor.
111
+ unchanged file. After two failed shell patches, switch to the editor. Tool-call arguments are
112
+ ~42% of this history and are re-read every turn: prefer edit over a whole-file write, never paste
113
+ back content you already have on disk, and keep subagent briefs short - they are history forever.
112
114
 
113
115
  SAFETY
114
116
  10. Honour scope literally (a new project means do not read or copy old-project files). Use
@@ -647,7 +649,9 @@
647
649
  from files with grep/scripts instead of re-reading them into context. Keep NOTES short and
648
650
  factual (<=60 lines).
649
651
  9. Author incrementally: create a file once (skeleton), then extend it with edit. Never re-emit an
650
- unchanged file. After two failed shell patches, switch to the editor.
652
+ unchanged file. After two failed shell patches, switch to the editor. Tool-call arguments are
653
+ ~42% of this history and are re-read every turn: prefer edit over a whole-file write, never paste
654
+ back content you already have on disk, and keep subagent briefs short - they are history forever.
651
655
 
652
656
  SAFETY
653
657
  10. Honour scope literally (a new project means do not read or copy old-project files). Use
@@ -1,6 +1,29 @@
1
1
  # Changelog
2
2
 
3
- > English version of [changelog.md](./changelog.md). Versions follow package.json (currently 0.2.4).
3
+ > English version of [changelog.md](./changelog.md). Versions follow package.json (currently 0.2.6).
4
+
5
+ ## 0.2.6 (2026-11-30)
6
+
7
+ ### Changed
8
+
9
+ - **The authoring cost is now measured and turned into a persona rule**: on the current session surface of 452,094 characters, **tool-call arguments account for 42.4%** (`pwsh` 79,081, `edit` 44,987, `write` 41,782, `subagent` 14,837), while tool results are only 17.9%, injected reminders 22.4% and assistant prose 7.4%. The most expensive part of the history is what the model itself typed into arguments, not what the tools returned — there is no cheap code fix for that, only discipline.
10
+ - Rule 9 grew from "author incrementally" into an executable constraint: prefer `edit` over rewriting a whole file, never paste back content that is already on disk, and keep subagent briefs short because they stay in history forever. The persona suffix moves from 4130 to 4356 characters and the test ceiling is relaxed to 4450.
11
+
12
+ ### Tests
13
+
14
+ - Fragment indentation was corrected so it matches the module character for character again; the full suite is 279 tests, 278 passing, 0 failing, 1 skipped, and `build --check` passes.
15
+
16
+ ## 0.2.5 (2026-11-30)
17
+
18
+ ### Changed
19
+
20
+ - **Five more low-frequency tools masked**: `interrupt_agent`, `list_subagent_models`, `get_goal`, `job_kill` and `job_list` no longer appear in the request, taking the tool definitions from 17,164 to about 15,482 characters (−1,682 characters, roughly 0.42k tokens per turn).
21
+ - **The masking trade-off is now quantified**: masking a tool only saves its own bytes (read once per turn as part of the cached prefix), but the moment it is actually needed the model must `search` and then `describe` first — a single extra round trip over a six-figure-token prefix wipes out a hundred turns of savings. Only tools that are effectively never used are masked; `create_goal`, `send_message`, `wait_agent` and `job_output` are larger but genuinely used, so they stay visible on purpose.
22
+ - This is the practical floor for shrinking the tool surface: about seventy percent of the remaining bytes live in parameter schemas, not description text.
23
+
24
+ ### Tests
25
+
26
+ - The masked-name assertion was updated (nine names that must be masked, thirteen that must stay visible); the full suite is 279 tests, 278 passing, 0 failing, 1 skipped.
4
27
 
5
28
  ## 0.2.4 (2026-11-30)
6
29
 
package/docs/changelog.md CHANGED
@@ -1,6 +1,29 @@
1
1
  # 变更记录(changelog)
2
2
 
3
- > 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 0.2.4)。
3
+ > 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 0.2.6)。
4
+
5
+ ## 0.2.6 (2026-11-30)
6
+
7
+ ### 变更
8
+
9
+ - **量化了「作者成本」并写进 persona 规则**:实测当前会话表面 452,094 字符里,**工具调用参数占 42.4%**(`pwsh` 79,081、`edit` 44,987、`write` 41,782、`subagent` 14,837),工具结果只占 17.9%,注入提醒 22.4%,助手正文 7.4%。也就是说历史里最贵的是模型自己敲进去的内容,而不是工具返回的东西——这类成本没有便宜的代码解法,只能靠约束写作习惯。
10
+ - 规则 9 从「增量写作」扩成可执行约束:能 `edit` 就不要整篇 `write`、不重复贴已有文件内容、子代理提示要短(它们会永久留在历史里)。persona suffix 4130 → 4356 字符,测试上限相应放宽到 4450。
11
+
12
+ ### 测试
13
+
14
+ - 同步修正分片缩进后与模块重新逐字一致;全量 279 项、278 通过、0 失败、1 skip,`build --check` PASS。
15
+
16
+ ## 0.2.5 (2026-11-30)
17
+
18
+ ### 变更
19
+
20
+ - **再遮蔽五个低频工具**:`interrupt_agent`、`list_subagent_models`、`get_goal`、`job_kill`、`job_list` 不再出现在请求里,工具定义从 17,164 字符降到约 15,482(−1,682 字符,约 0.42k token/轮)。
21
+ - **遮蔽的取舍被量化**:遮蔽一个工具只省它的整块字符(每轮一次,进入 cacheRead),而一旦真的用到,模型必须先 `search` 再 `describe`,一次额外往返在十几万 token 的前缀上就抵掉上百轮的节省。因此只遮「整局基本不会用到」的工具;`create_goal`、`send_message`、`wait_agent`、`job_output` 虽然体积更大,但实际会用,故意保持可见。
22
+ - 这是工具面继续下压的实际上限:剩余体积的七成在参数 schema 里,不再是描述文本。
23
+
24
+ ### 测试
25
+
26
+ - 同步更新遮蔽名单断言(含九个必遮名与十三个必须保持可见的名字);全量 279 项、278 通过、0 失败、1 skip。
4
27
 
5
28
  ## 0.2.4 (2026-11-30)
6
29
 
@@ -71,7 +71,9 @@ export const LEAN_PERSONA_SUFFIX = [
71
71
  ' from files with grep/scripts instead of re-reading them into context. Keep NOTES short and',
72
72
  ' factual (<=60 lines).',
73
73
  '9. Author incrementally: create a file once (skeleton), then extend it with edit. Never re-emit an',
74
- ' unchanged file. After two failed shell patches, switch to the editor.',
74
+ ' unchanged file. After two failed shell patches, switch to the editor. Tool-call arguments are',
75
+ ' ~42% of this history and are re-read every turn: prefer edit over a whole-file write, never paste',
76
+ ' back content you already have on disk, and keep subagent briefs short - they are history forever.',
75
77
  '',
76
78
  'SAFETY',
77
79
  '10. Honour scope literally (a new project means do not read or copy old-project files). Use',
@@ -30,7 +30,20 @@ export const DEFAULT_HIDDEN_PREFIXES = ['mcp__'];
30
30
  * Deliberately NOT listed: `subagent`, `ask_user_question`, `pwsh`, `edit`,
31
31
  * `write`, `read`, `grep`, `glob` — these are the loop itself.
32
32
  */
33
- export const DEFAULT_HIDDEN_CORE_TOOLS = ['update_goal', 'list_agents', 'present', 'subagent_fork'];
33
+ // 只遮「整局基本不会用到」的工具。遮蔽不是免费的:一旦用到,模型必须先 search 再 describe,
34
+ // 一次额外往返在十几万 token 的前缀上就抵掉上百轮省下的字符。create_goal / send_message /
35
+ // wait_agent / job_output 都属常用,故意不在此列。
36
+ export const DEFAULT_HIDDEN_CORE_TOOLS = [
37
+ 'update_goal',
38
+ 'list_agents',
39
+ 'present',
40
+ 'subagent_fork',
41
+ 'interrupt_agent',
42
+ 'list_subagent_models',
43
+ 'get_goal',
44
+ 'job_kill',
45
+ 'job_list',
46
+ ];
34
47
 
35
48
  /** Environment switch: `0` keeps the core tools visible. */
36
49
  export const CORE_MASK_ENV = 'DSH_LEAN_ROUTER_MASK_CORE';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-lean-router",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "lean 省 token × 思考链路由 × code_run 工具遮蔽的 DSH cordis 插件(单 bundle:预设)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -61,7 +61,9 @@
61
61
  from files with grep/scripts instead of re-reading them into context. Keep NOTES short and
62
62
  factual (<=60 lines).
63
63
  9. Author incrementally: create a file once (skeleton), then extend it with edit. Never re-emit an
64
- unchanged file. After two failed shell patches, switch to the editor.
64
+ unchanged file. After two failed shell patches, switch to the editor. Tool-call arguments are
65
+ ~42% of this history and are re-read every turn: prefer edit over a whole-file write, never paste
66
+ back content you already have on disk, and keep subagent briefs short - they are history forever.
65
67
 
66
68
  SAFETY
67
69
  10. Honour scope literally (a new project means do not read or copy old-project files). Use
@@ -51,7 +51,9 @@
51
51
  from files with grep/scripts instead of re-reading them into context. Keep NOTES short and
52
52
  factual (<=60 lines).
53
53
  9. Author incrementally: create a file once (skeleton), then extend it with edit. Never re-emit an
54
- unchanged file. After two failed shell patches, switch to the editor.
54
+ unchanged file. After two failed shell patches, switch to the editor. Tool-call arguments are
55
+ ~42% of this history and are re-read every turn: prefer edit over a whole-file write, never paste
56
+ back content you already have on disk, and keep subagent briefs short - they are history forever.
55
57
 
56
58
  SAFETY
57
59
  10. Honour scope literally (a new project means do not read or copy old-project files). Use
@@ -108,6 +108,10 @@ try {
108
108
  console.log("[install-profile] 完成:" + PKG + "@" + version + " -> " + target);
109
109
  console.log("[install-profile] 清单 " + manifestPath + " 无 BOM、可解析、版本一致");
110
110
  console.log("[install-profile] 下一步:完全退出并重启 DSH,然后在宿主运行时不要替换这些文件(热重载会重读缓存)。");
111
+ } catch (error) {
112
+ // 拉包失败(版本还没在 registry 上可见、网络中断等)时给一句人话,
113
+ // 而不是把 child_process 的原始错误对象整个倾倒出来。
114
+ fail('安装失败:' + (error?.message ?? String(error)).split('\n')[0]);
111
115
  } finally {
112
116
  rmSync(stage, { recursive: true, force: true });
113
117
  }
@@ -50,7 +50,7 @@ test('persona-text.js 独立加载:lean 13 条 + 2 软门 + 自检题钩子 +
50
50
  assert.equal(m.PERSONA_PREFIX, 'You are a coding agent powered by the {{model}} model.');
51
51
  });
52
52
 
53
- test('persona 并行调用引导:只读并发 + 写向同批省往返 + 遮挡整批拒绝(块 <=320,suffix <=4200)', async () => {
53
+ test('persona 并行调用引导:只读并发 + 写向同批省往返 + 遮挡整批拒绝(块 <=320,suffix <=4450)', async () => {
54
54
  const m = await mod('persona-text.js');
55
55
  const s = m.LEAN_PERSONA_SUFFIX;
56
56
  // 事实 1:只读工具可真正重叠执行(tool-concurrency.js 给 glob/grep 打了 isConcurrencySafe)
@@ -70,7 +70,7 @@ test('persona 并行调用引导:只读并发 + 写向同批省往返 + 遮挡
70
70
  assert.ok(end > start, '并行引导块须位于规则 6 与规则 7 之间');
71
71
  const block = s.slice(start, end).replace(/\n+$/, '');
72
72
  assert.ok(block.length <= 320, '并行引导块须 <=320 字符,实为 ' + block.length);
73
- assert.ok(s.length <= 4200, 'persona suffix 总长须 <=4200,实为 ' + s.length);
73
+ assert.ok(s.length <= 4450, 'persona suffix 总长须 <=4450,实为 ' + s.length);
74
74
  });
75
75
 
76
76
  test('plan-mode.js 独立加载:v1 政策段原文要点', async () => {
@@ -169,13 +169,13 @@ test('DSH_LEAN_ROUTER_DESC_SLIM=0 disables every rewrite', () => {
169
169
 
170
170
  test('the four low-frequency core tools are masked by default; the loop tools are not', () => {
171
171
  const options = normalizeConfig({});
172
- for (const name of ['update_goal', 'list_agents', 'present', 'subagent_fork']) {
172
+ for (const name of ['update_goal', 'list_agents', 'present', 'subagent_fork', 'interrupt_agent', 'list_subagent_models', 'get_goal', 'job_kill', 'job_list']) {
173
173
  assert.equal(isMaskedName(name, options), true, `${name} must be masked`);
174
174
  }
175
- for (const name of ['subagent', 'ask_user_question', 'pwsh', 'edit', 'write', 'read', 'grep', 'glob', 'code_run']) {
175
+ for (const name of ['subagent', 'ask_user_question', 'pwsh', 'edit', 'write', 'read', 'grep', 'glob', 'code_run', 'create_goal', 'send_message', 'wait_agent', 'job_output']) {
176
176
  assert.equal(isMaskedName(name, options), false, `${name} must stay visible`);
177
177
  }
178
- assert.deepEqual([...DEFAULT_HIDDEN_CORE_TOOLS].sort(), ['list_agents', 'present', 'subagent_fork', 'update_goal']);
178
+ assert.deepEqual([...DEFAULT_HIDDEN_CORE_TOOLS].sort(), ['get_goal', 'interrupt_agent', 'job_kill', 'job_list', 'list_agents', 'list_subagent_models', 'present', 'subagent_fork', 'update_goal']);
179
179
  // Merging must not disturb explicitly configured names.
180
180
  const configured = normalizeConfig({ hiddenTools: ['custom_tool'] });
181
181
  assert.equal(isMaskedName('custom_tool', configured), true, 'configured names still hide');