dsh-lean-router 1.0.1 → 1.0.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/README.en.md CHANGED
@@ -6,7 +6,7 @@ A DeepSeek Harness (DSH) cordis plugin tuned for DeepSeek V4.1 Flash: **one plug
6
6
 
7
7
  > This package documents bilingually with the **"Chinese default + English `.en.md` files"** scheme: Chinese is the first language (README.md and docs/*.md), English lives in same-directory `.en.md` files (this file ↔ [README.md](./README.md)). All three upstream projects follow the same "Chinese README + README.en.md" convention.
8
8
 
9
- > Status: **v1.0.0 published** (npm: [dsh-lean-router](https://www.npmjs.com/package/dsh-lean-router) · GitHub Release [v1.0.0](https://github.com/ShawnSun-debug/dsh-lean-router/releases/tag/v1.0.0) · CI green; remaining manual step: real-machine DSH profile install smoke, see [docs/release-checklist.md](docs/release-checklist.md)).
9
+ > Status: **v1.0.3 published** (npm: [dsh-lean-router](https://www.npmjs.com/package/dsh-lean-router) · GitHub Release [v1.0.2](https://github.com/ShawnSun-debug/dsh-lean-router/releases/tag/v1.0.3) · CI green; real-machine DSH profile install smoke record: [docs/release-checklist.md](docs/release-checklist.md)).
10
10
 
11
11
  ## Layers at a glance
12
12
 
@@ -29,7 +29,7 @@ Not published yet; start with a local link (both paths in [docs/quickstart.en.md
29
29
 
30
30
  ~~~powershell
31
31
  dsh plugin --profile desktop add "link:D:\path\to\dsh-lean-router"
32
- # once published: dsh plugin --profile desktop add npm:dsh-lean-router@1.0.1
32
+ # once published: dsh plugin --profile desktop add npm:dsh-lean-router@1.0.3
33
33
  ~~~
34
34
 
35
35
  The package depends on `@deepseek-ai/dsh-tool-executor-native`; if missing, the masking layer fails loudly — the executor stub throws an error with install guidance on the first `describe` (lib/toolface/executor.js L57-63). Follow it with `npm install` or re-add via `dsh plugin add`.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  > 本包双语文档采用 **「中文默认 + 英文 `.en.md` 独立文件」** 方案:中文是第一语言(README.md 与 docs/*.md),英文版同目录 `.en.md`(本文件 ↔ [README.en.md](./README.en.md))。三个上游项目也遵循「中文 README + README.en.md」惯例。
8
8
 
9
- > 状态:**v1.0.0 已发布**(npm:[dsh-lean-router](https://www.npmjs.com/package/dsh-lean-router) · GitHub Release [v1.0.0](https://github.com/ShawnSun-debug/dsh-lean-router/releases/tag/v1.0.0) · CI 绿;剩余人工项:DSH profile 真机安装冒烟,见 [docs/release-checklist.md](docs/release-checklist.md))。
9
+ > 状态:**v1.0.3 已发布**(npm:[dsh-lean-router](https://www.npmjs.com/package/dsh-lean-router) · GitHub Release [v1.0.2](https://github.com/ShawnSun-debug/dsh-lean-router/releases/tag/v1.0.3) · CI 绿;真机安装冒烟记录见 [docs/release-checklist.md](docs/release-checklist.md))。
10
10
 
11
11
  ## 功能一图
12
12
 
@@ -29,7 +29,7 @@ engines:`>=0.2.1-rc.5 <0.2.3-0`(实测基线 0.2.2-rc.5)。DSH 处于 deve
29
29
 
30
30
  ~~~powershell
31
31
  dsh plugin --profile desktop add "link:D:\path\to\dsh-lean-router"
32
- # 发布后:dsh plugin --profile desktop add npm:dsh-lean-router@1.0.1
32
+ # 发布后:dsh plugin --profile desktop add npm:dsh-lean-router@1.0.3
33
33
  ~~~
34
34
 
35
35
  依赖 `@deepseek-ai/dsh-tool-executor-native`;缺失时工具遮蔽层不静默——executor stub 首次 `describe` 抛出含安装指引的错误(lib/toolface/executor.js L57-63),按提示 `npm install` 或用 `dsh plugin add` 重装即可。
package/cordis.patch.yml CHANGED
@@ -818,9 +818,6 @@
818
818
 
819
819
  # ============ 新增行:preset-lean-router-balance(balance 档 3 条;上游双预设形态,flash-lean-ptc-v3-balance 同构)============
820
820
 
821
- - id: ptc-runtime
822
- name: '@deepseek-ai/dsh-ptc-runtime-node'
823
-
824
821
  - id: toolface
825
822
  name: 'dsh-lean-router/toolface'
826
823
  config:
@@ -1,6 +1,17 @@
1
1
  # Changelog
2
2
 
3
- > English version of [changelog.md](./changelog.md). Versions follow package.json (currently 1.0.0).
3
+ > English version of [changelog.md](./changelog.md). Versions follow package.json (currently 1.0.3).
4
+
5
+ ## 1.0.3 (2026-11-22)
6
+
7
+ - 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.
8
+ - Change: the `frag-preset` union drops from 22 to 21 rows (overrides 20 + toolface); `cordis.patch.yml` rebuilt.
9
+ - Add: `integration-preset` and `patch-yaml` now assert `ptc-runtime` never appears inside a preset.
10
+
11
+ ## 1.0.2 (2026-11-22)
12
+
13
+ - 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).
14
+ - Add: one "apply's return value must satisfy the cordis effect contract" assertion in each of the `tool-concurrency` / `delivery-gate` / `router` / `toolface` suites.
4
15
 
5
16
  ## 1.0.1 (2026-11-22)
6
17
 
package/docs/changelog.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # 变更记录(changelog)
2
2
 
3
- > 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 1.0.0)。
3
+ > 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 1.0.3)。
4
+
5
+ ## 1.0.3 (2026-11-22)
6
+
7
+ - 修复(真机致命):preset 的 plugins 列表里误挂了**宿主层服务插件** `ptc-runtime`(`@deepseek-ai/dsh-ptc-runtime-node`)。dsh 的 preset 在独立 scope 里激活,重复挂载该服务会失败 → `agentPresets.register` 抛错 → 整条 `preset-lean-router` 不注册(真机现象:预设列表只剩 balance)。该行本就由宿主 `dsh-base/cordis.patch.yml` L407-408 挂载,`code_run` 依赖的 `ctx.get('ptcRuntime')` 会向宿主层查找,preset 内无需重复声明。
8
+ - 变更:`frag-preset` 并集行 22 → 21(覆写块 20 + toolface),`cordis.patch.yml` 同步重建。
9
+ - 新增回归:`integration-preset` 与 `patch-yaml` 两处断言 preset 内不得出现 `ptc-runtime`。
10
+
11
+ ## 1.0.2 (2026-11-22)
12
+
13
+ - 修复(真机致命):`lib/lean/tool-concurrency.js` 的 `apply()` 返回了普通对象;cordis 的 effect 校验只接受 dispose 函数 / null / undefined / thenable,于是真宿主抛 `Invalid effect` —— 插件列表标红「异常」,且同一 overlay 里排在它之后的 `preset-lean-router` 行不再注册(预设列表只剩 balance)。
14
+ - 新增:`tool-concurrency` / `delivery-gate` / `router` / `toolface` 四套测试各加一条「apply 返回值必须满足 cordis effect 契约」断言,防回归。
4
15
 
5
16
  ## 1.0.1 (2026-11-22)
6
17
 
@@ -20,7 +20,7 @@ After restarting DSH, pick the **Lean router** preset (lean tier) or **Lean rout
20
20
  ### Path B: npm install (once published)
21
21
 
22
22
  ~~~powershell
23
- dsh plugin --profile desktop add npm:dsh-lean-router@1.0.1
23
+ dsh plugin --profile desktop add npm:dsh-lean-router@1.0.3
24
24
  ~~~
25
25
 
26
26
  (Both paths match the output of scripts/install.mjs; the real installer, claim boundaries and `--uninstall` rollback belong to ticket 09.)
@@ -20,7 +20,7 @@ dsh plugin --profile desktop add "link:D:\path\to\dsh-lean-router"
20
20
  ### 路径 B:npm 安装(发布后可用)
21
21
 
22
22
  ~~~powershell
23
- dsh plugin --profile desktop add npm:dsh-lean-router@1.0.1
23
+ dsh plugin --profile desktop add npm:dsh-lean-router@1.0.3
24
24
  ~~~
25
25
 
26
26
  (两条路径与 scripts/install.mjs 输出的说明一致;真安装器、认领边界与 `--uninstall` 回滚归票 09。)
@@ -309,7 +309,10 @@ export default {
309
309
  const tc = cfg.toolConcurrency !== null && typeof cfg.toolConcurrency === 'object' ? cfg.toolConcurrency : {};
310
310
  const result = installToolConcurrency(ctx, { ...tc });
311
311
  try { console.info(TAG + ' 插件行挂载|installed=' + String(result !== null && result.installed === true)); } catch (error) {}
312
- return result;
312
+ // cordis 契约(@deepseek-ai/cordis lib/index.js _execute):apply 的返回值会当作 effect 校验,
313
+ // 只接受 dispose 函数 / null / undefined / thenable;返回普通对象会 throw TypeError("Invalid effect"),
314
+ // 真宿主把插件标红「异常」,且同一 patch 里排在它之后的 preset 行不再注册(1.0.1 实测现象)。
315
+ return undefined;
313
316
  },
314
317
  };
315
318
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-lean-router",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "lean 省 token × 思考链路由 × code_run 工具遮蔽 × mattpocock 技能自动调用的 DSH cordis 插件(单 bundle:预设+配套技能)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -233,9 +233,6 @@
233
233
 
234
234
  # ============ 新增行:preset-lean-router-balance(balance 档 3 条;上游双预设形态,flash-lean-ptc-v3-balance 同构)============
235
235
 
236
- - id: ptc-runtime
237
- name: '@deepseek-ai/dsh-ptc-runtime-node'
238
-
239
236
  - id: toolface
240
237
  name: 'dsh-lean-router/toolface'
241
238
  config:
@@ -67,14 +67,12 @@ for (let i = sufIdx + 1; i < pr.length; i++) {
67
67
  }
68
68
  const newPersona = pr.slice(0, sufIdx + 1).concat(composed.split('\n').map(l => (l.length ? contentIndent + l : '')));
69
69
 
70
- // 5) 并集 = 覆写块全部行(persona 换 composed)+ master 补挂行 + toolface 行收尾
71
- // ptc-runtime 行:宿主 dsh-base/cordis.patch.yml L407-408 同款(0.2.2-rc.5 实读);
72
- // codemode 上游补丁不带此行,而 code_run 的 transport.js:221-224 依赖 ctx.get('ptcRuntime') 服务,
73
- // 缺行会在运行时兜底报错——由 master 集成补挂(票 08 open_question 5 裁定)。
74
- const extraRows = [
75
- { id: 'ptc-runtime', text: [' - id: ptc-runtime', " name: '@deepseek-ai/dsh-ptc-runtime-node'", ''] },
76
- ];
77
- const unionRows = ovRows.map(r => (r.id === 'persona' ? { id: 'persona', text: newPersona } : r)).concat(extraRows).concat([toolfaceRow]);
70
+ // 5) 并集 = 覆写块全部行(persona 换 composed)+ toolface 行收尾
71
+ // 不挂 ptc-runtime(1.0.3 实测修正):官方已在宿主层 dsh-base/cordis.patch.yml L407-408 挂过
72
+ // 这个服务插件;preset 是独立 scope,再挂一次会激活失败,导致整条 preset 不注册
73
+ // (现象:lean-router 从预设列表整体消失,只剩 balance)。code_run 的 transport 依赖的
74
+ // ctx.get('ptcRuntime') 会向宿主层查找,preset 内无需重复声明。
75
+ const unionRows = ovRows.map(r => (r.id === 'persona' ? { id: 'persona', text: newPersona } : r)).concat([toolfaceRow]);
78
76
  const ids = unionRows.map(r => r.id);
79
77
  if (new Set(ids).size !== ids.length) throw new Error('并集行 id 重复: ' + ids.join(','));
80
78
  if (ids[ids.length - 1] !== 'toolface') throw new Error('toolface 行必须收尾');
@@ -28,10 +28,11 @@ function suffixBlock(text) {
28
28
 
29
29
  test('frag-preset 是 preset 行唯一生效 owner:21 行并集、无重复、toolface 收尾', () => {
30
30
  const ids = frag.split(/\r?\n/).filter(l => /^ - id: /.test(l)).map(l => /^ - id: (.+)$/.exec(l)[1].trim());
31
- assert.equal(ids.length, 22, '并集行数 = 覆写块 20 + ptc-runtime(master 补挂)+ toolface');
31
+ assert.equal(ids.length, 21, '并集行数 = 覆写块 20 + toolface(ptc-runtime 属宿主层,不进 preset)');
32
32
  assert.equal(new Set(ids).size, ids.length, '无重复 id');
33
33
  assert.equal(ids[ids.length - 1], 'toolface', 'toolface 最后(遮蔽面与 preset 同行生效)');
34
- for (const id of ['persona', 'agent-instructions', 'skill-filesystem', 'skill-lean-router', 'planning', 'compaction', 'delegation', 'tool-todo', 'tool-web', 'present', 'ptc-runtime', 'toolface']) {
34
+ assert.ok(!ids.includes('ptc-runtime'), 'ptc-runtime 由宿主 dsh-base 挂载,放进 preset 会让整条 preset 激活失败(1.0.3 事故回归)');
35
+ for (const id of ['persona', 'agent-instructions', 'skill-filesystem', 'skill-lean-router', 'planning', 'compaction', 'delegation', 'tool-todo', 'tool-web', 'present', 'toolface']) {
35
36
  assert.ok(ids.includes(id), '缺行: ' + id);
36
37
  }
37
38
  assert.ok(!ids.includes('preset-lean-router-balance'), 'balance 是独立行,不在并集行 id 内');
@@ -108,7 +108,9 @@ test('默认插件导出:apply 走同一 install 路径(config.toolConcurren
108
108
  effect(factory) { disposer = factory(); },
109
109
  };
110
110
  const r = m.default.apply(ctx, { toolConcurrency: { sweepMs: 1000 } });
111
- assert.equal(r.installed, true);
111
+ // cordis effect 契约:apply 返回值只能是 dispose 函数 / null / undefined / thenable。
112
+ // 返回普通对象会 TypeError("Invalid effect"),真宿主标红「异常」(1.0.1 实测)。
113
+ assert.equal(r, undefined, 'apply must not return a plain object (cordis "Invalid effect")');
112
114
  assert.equal(globalDefs.glob.isConcurrencySafe({ pattern: '*' }), true);
113
115
  if (disposer) disposer();
114
116
  });
@@ -26,7 +26,7 @@ test('section:关闭态返回空串(装配时被丢掉),开启态返回
26
26
  delete process.env.DSH_DELIVERY_GATE;
27
27
  let captured = null;
28
28
  const ctx = { systemPrompt: { section: (s) => { captured = s; } }, effect() {} };
29
- m.apply(ctx, {});
29
+ assert.equal(m.apply(ctx, {}), undefined, 'apply must not return a plain object (cordis "Invalid effect")');
30
30
  assert.equal(captured.text(), '', '关闭时一个字都不注入(上游 L217-229)');
31
31
  assert.equal(captured.name, 'lean-delivery-gate');
32
32
  assert.equal(captured.order, 42);
@@ -35,12 +35,11 @@ test("全部 presets/base 补丁片段可解析", () => {
35
35
  }
36
36
  });
37
37
 
38
- test("ptc-runtime 行缩进正确(1.0.0 事故回归)", () => {
38
+ test("ptc-runtime 是宿主层插件,不得出现在 preset 内(1.0.3 事故回归)", () => {
39
39
  const doc = parseFile(join(root, "presets", "base", "frag-preset.patch.yml"));
40
40
  assert.ok(Array.isArray(doc), "frag 是裸行数组");
41
41
  const preset = doc.find((p) => p.id === "preset-lean-router");
42
42
  assert.ok(preset, "preset 行存在");
43
43
  const row = preset.config.plugins.find((p) => p.id === "ptc-runtime");
44
- assert.ok(row, "ptc-runtime 行必须作为合法列表项被解析出来");
45
- assert.equal(row.name, "@deepseek-ai/dsh-ptc-runtime-node");
44
+ assert.equal(row, undefined, "ptc-runtime 由宿主 dsh-base/cordis.patch.yml 挂载;放进 preset 会让整条 preset 激活失败、从预设列表消失");
46
45
  });
@@ -67,7 +67,7 @@ const agentB = { session: {} };
67
67
 
68
68
  async function routedSetup(options) {
69
69
  const { ctx, handlers, contexts, commands } = makeCtx(fakeSkills());
70
- apply(ctx, options);
70
+ assert.equal(apply(ctx, options), undefined, 'apply must not return a plain object (cordis "Invalid effect")');
71
71
  return { ctx, handlers, contexts, commands };
72
72
  }
73
73
 
@@ -92,7 +92,7 @@ async function harness(config = {}, { globalScope = false, noDelegate = false }
92
92
  if (!globalScope) ctx[SCOPE_TAG] = keys.preset;
93
93
  const options = { ...config };
94
94
  if (!noDelegate) options.createDelegate = config.createDelegate ?? (() => delegate);
95
- await apply(ctx, options);
95
+ assert.equal(await apply(ctx, options), undefined, 'apply must not return a plain object (cordis "Invalid effect")');
96
96
  const describeFor = (scope = keys.agent) => executor.describe(visibleLayersFor(keys, scope).flatMap(l => LAYERS[l]).map(n => DEFINITIONS.get(n)));
97
97
  return { registered, logs, forwarded, ctx, keys, executor, describeFor, delegate };
98
98
  }