dsh-lean-router 1.0.5 → 1.0.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/docs/changelog.en.md +9 -1
- package/docs/changelog.md +9 -1
- package/docs/quickstart.en.md +1 -1
- package/docs/quickstart.md +1 -1
- package/lib/index.js +24 -8
- package/lib/router.js +1 -1
- package/package.json +1 -1
- package/test/plugin-entry.test.mjs +61 -0
- package/test/router.test.mjs +12 -0
package/docs/changelog.en.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
> English version of [changelog.md](./changelog.md). Versions follow package.json (currently 1.0.
|
|
3
|
+
> English version of [changelog.md](./changelog.md). Versions follow package.json (currently 1.0.6).
|
|
4
|
+
|
|
5
|
+
## 1.0.6 (2026-11-23)
|
|
6
|
+
|
|
7
|
+
> 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.
|
|
8
|
+
|
|
9
|
+
- 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.
|
|
10
|
+
- 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.
|
|
11
|
+
- 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.
|
|
4
12
|
|
|
5
13
|
## 1.0.5 (2026-11-23)
|
|
6
14
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# 变更记录(changelog)
|
|
2
2
|
|
|
3
|
-
> 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 1.0.
|
|
3
|
+
> 中文为主,英文版:[changelog.en.md](./changelog.en.md)。版本号遵循 package.json(当前 1.0.6)。
|
|
4
|
+
|
|
5
|
+
## 1.0.6 (2026-11-23)
|
|
6
|
+
|
|
7
|
+
> 1.0.5 已发到 npm,但下面两处缺陷是它在 0.2.3 真机**首次激活**时才暴露的,请直接用 1.0.6。
|
|
8
|
+
|
|
9
|
+
- 修复(真机致命):`lib/index.js` 的 `inject` 形状。cordis 的 inject 只有两种形状 —— 服务名数组,或「服务名 → 拦截配置」映射(`registry.ts: Inject<M> = (keyof M)[] | { [K in keyof M]?: M[K] }`)。1.0.5 写的 `{ required: [], optional: ["skills"] }` 被解析成两个叫 `required` / `optional` 的服务,宿主层 `lean-router-client-host` 永远 PENDING(实机诊断:`pending (waiting for services: required, optional)`),`apply` 不执行 → 客户端 bundle 不被 `dsh-client-modules` 扫描(顶栏按钮不出现)、启动自检 `boot.log` 从不生成。改为 `inject = []` + `apply` 内 `ctx.inject(["skills"], cb)`:宿主层立即激活,预设层等 skills 就绪后再注册 provider。
|
|
10
|
+
- 修复(真机致命):`/panel` 的 `input.hint` 是空字符串。0.2.3 的 `@deepseek-ai/dsh-commands` 在 `normalizeDefinition` 里对空 hint 抛 `TypeError: command "panel" input hint must not be empty`,整条 `lean-router-commands` 因此不激活。改为 `[summary|skills|round|stats|never] [all]`(与 `parsePanelArgs` 实际接受的参数一致)。
|
|
11
|
+
- 新增回归:`test/plugin-entry.test.mjs` 断言 inject 形状(不得出现 required/optional 键)、宿主作用域不碰 skills、预设作用域走 `ctx.inject`、无 `ctx.inject` 时退化;`test/router.test.mjs` 增加「每个命令的 input hint 都非空」断言。218 测试全绿。
|
|
4
12
|
|
|
5
13
|
## 1.0.5 (2026-11-23)
|
|
6
14
|
|
package/docs/quickstart.en.md
CHANGED
|
@@ -20,7 +20,7 @@ After restarting DSH, pick the **Lean router** preset (lean tier) or **Lean rout
|
|
|
20
20
|
### Path B: npm install (recommended)
|
|
21
21
|
|
|
22
22
|
~~~powershell
|
|
23
|
-
dsh plugin --profile desktop add npm:dsh-lean-router@1.0.
|
|
23
|
+
dsh plugin --profile desktop add npm:dsh-lean-router@1.0.6
|
|
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.)
|
package/docs/quickstart.md
CHANGED
|
@@ -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.
|
|
23
|
+
dsh plugin --profile desktop add npm:dsh-lean-router@1.0.6
|
|
24
24
|
~~~
|
|
25
25
|
|
|
26
26
|
(两条路径与 scripts/install.mjs 输出的说明一致;真安装器、认领边界与 `--uninstall` 回滚归票 09。)
|
package/lib/index.js
CHANGED
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
// 1.0.5 修:宿主层需要以裸包名 dsh-lean-router 挂一行,否则 dsh-client-modules 扫不到本包
|
|
4
4
|
// 的 dsh.client 声明,客户端 bundle 不会加载(顶栏按钮因此不出现)。
|
|
5
5
|
//
|
|
6
|
-
//
|
|
6
|
+
// 但 inject = ["skills"] 会让宿主层那一行永远停在“等待依赖”——skills 服务由预设里的
|
|
7
7
|
// @deepseek-ai/dsh-skill-filesystem 提供,宿主作用域没有它。插件不 apply,扫描就看不到活跃
|
|
8
|
-
//
|
|
8
|
+
// 条目。
|
|
9
|
+
//
|
|
10
|
+
// 1.0.6 修:cordis 的 inject 只有两种形状——服务名数组,或「服务名 → 拦截配置」映射
|
|
11
|
+
// (registry.ts: Inject<M> = (keyof M)[] | { [K in keyof M]?: M[K] })。写成
|
|
12
|
+
// { required: [], optional: ["skills"] } 会被当成两个叫 required / optional 的服务,
|
|
13
|
+
// 宿主层那行永远 PENDING(0.2.3 实机诊断:pending (waiting for services: required, optional))。
|
|
14
|
+
// 改为「无必需依赖」+ apply 内 ctx.inject(["skills"], …):宿主层立刻激活(客户端 bundle 才会
|
|
15
|
+
// 被 dsh-client-modules 扫到),预设层等 skills 就绪后再注册 provider。
|
|
9
16
|
import { appendFileSync, mkdirSync } from "node:fs";
|
|
10
17
|
import { homedir } from "node:os";
|
|
11
18
|
import { join } from "node:path";
|
|
@@ -13,7 +20,7 @@ import { makeProvider } from "./skill-provider.js";
|
|
|
13
20
|
import { getAuditChannel } from "./skillgate.js";
|
|
14
21
|
|
|
15
22
|
export const name = "skill-lean-router";
|
|
16
|
-
export const inject =
|
|
23
|
+
export const inject = [];
|
|
17
24
|
|
|
18
25
|
/** 启动自检:把宿主层是否 apply、ctx 上有哪些能力,写进 ~/.dsh/lean-router/boot.log。 */
|
|
19
26
|
function probe(line) {
|
|
@@ -39,10 +46,19 @@ export function apply(ctx, options) {
|
|
|
39
46
|
} catch {}
|
|
40
47
|
|
|
41
48
|
if (cfg.provider === false) return;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
const register = (scope) => {
|
|
50
|
+
if (!scope.skills || typeof scope.skills.registerProvider !== "function") {
|
|
51
|
+
probe("skip provider: ctx.skills 不可用(宿主作用域属正常)");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const rank = typeof cfg.rank === "number" ? cfg.rank : 350;
|
|
55
|
+
scope.skills.registerProvider(() => makeProvider({ rank, audit: getAuditChannel() }));
|
|
56
|
+
};
|
|
57
|
+
// ctx.inject(deps, cb):服务可用后运行 cb,服务变化时自动重跑(cordis 官方语义)。
|
|
58
|
+
// 返回值是子 fiber,apply 必须继续返回 undefined,别把 fiber 当 effect 交回去。
|
|
59
|
+
if (typeof ctx.inject === "function") {
|
|
60
|
+
ctx.inject(["skills"], register);
|
|
61
|
+
} else {
|
|
62
|
+
register(ctx);
|
|
45
63
|
}
|
|
46
|
-
const rank = typeof cfg.rank === "number" ? cfg.rank : 350;
|
|
47
|
-
ctx.skills.registerProvider(() => makeProvider({ rank, audit: getAuditChannel() }));
|
|
48
64
|
}
|
package/lib/router.js
CHANGED
|
@@ -397,7 +397,7 @@ export function apply(ctx, options) {
|
|
|
397
397
|
ctx.commands.register({
|
|
398
398
|
name: "panel",
|
|
399
399
|
description: "Skill panel: 31 skills with switches, current round hit scores and history stats",
|
|
400
|
-
input: { hint: "" },
|
|
400
|
+
input: { hint: "[summary|skills|round|stats|never] [all]" },
|
|
401
401
|
handler: (invocation) =>
|
|
402
402
|
executeSkillsPanelCommand(invocation, {
|
|
403
403
|
auditPath: cfg.auditPath ?? defaultAuditPath(),
|
package/package.json
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// dsh-lean-router 1.0.6 —— 包入口(lib/index.js)的 cordis 契约回归。
|
|
2
|
+
// 背景(0.2.3 真机):inject 写成 { required: [], optional: ["skills"] } 会被 cordis 当成
|
|
3
|
+
// 两个叫 required / optional 的服务,宿主层那行永远 PENDING,apply 不跑,客户端 bundle
|
|
4
|
+
// 不被扫描,顶栏按钮不出现。cordis 的 inject 只有两种形状:
|
|
5
|
+
// Inject<M> = (keyof M)[] | { [K in keyof M]?: M[K] } (registry.ts L19)
|
|
6
|
+
import test from "node:test";
|
|
7
|
+
import assert from "node:assert/strict";
|
|
8
|
+
import { tmpdir } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
|
|
11
|
+
import * as entry from "../lib/index.js";
|
|
12
|
+
|
|
13
|
+
/** 把 homedir() 指向临时目录,避免自检日志写进真实用户目录。 */
|
|
14
|
+
function withTempHome(fn) {
|
|
15
|
+
const saved = process.env.USERPROFILE;
|
|
16
|
+
process.env.USERPROFILE = join(tmpdir(), "dsh-lean-router-test-home");
|
|
17
|
+
try {
|
|
18
|
+
return fn();
|
|
19
|
+
} finally {
|
|
20
|
+
if (saved === undefined) delete process.env.USERPROFILE;
|
|
21
|
+
else process.env.USERPROFILE = saved;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
test("inject 是 cordis 认的形状,不能出现 required/optional 键", () => {
|
|
26
|
+
if (Array.isArray(entry.inject)) return;
|
|
27
|
+
assert.equal(typeof entry.inject, "object", "inject 必须是数组或服务名映射");
|
|
28
|
+
const keys = Object.keys(entry.inject);
|
|
29
|
+
assert.ok(
|
|
30
|
+
!keys.includes("required") && !keys.includes("optional"),
|
|
31
|
+
"inject 被当成服务名映射后出现了 required/optional 键:" + keys.join(","),
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("宿主作用域:provider:false 时不碰 skills,apply 返回 undefined", () => {
|
|
36
|
+
withTempHome(() => {
|
|
37
|
+
const ctx = { inject() { throw new Error("provider:false 不该调用 ctx.inject"); } };
|
|
38
|
+
assert.equal(entry.apply(ctx, { provider: false }), undefined);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("预设作用域:用 ctx.inject 等 skills 就绪,而不是把它写进必需依赖", () => {
|
|
43
|
+
withTempHome(() => {
|
|
44
|
+
const calls = [];
|
|
45
|
+
const ctx = { inject(deps, cb) { calls.push({ deps, cb }); } };
|
|
46
|
+
assert.equal(entry.apply(ctx, {}), undefined, "apply 不能把 ctx.inject 的 fiber 当 effect 交回去");
|
|
47
|
+
assert.equal(calls.length, 1);
|
|
48
|
+
assert.deepEqual(calls[0].deps, ["skills"]);
|
|
49
|
+
let registered = null;
|
|
50
|
+
calls[0].cb({ skills: { registerProvider(factory) { registered = factory; } } });
|
|
51
|
+
assert.equal(typeof registered, "function", "skills 就绪后必须注册 provider");
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("没有 ctx.inject 时退化为直接注册(老宿主兼容)", () => {
|
|
56
|
+
withTempHome(() => {
|
|
57
|
+
let registered = null;
|
|
58
|
+
entry.apply({ skills: { registerProvider(factory) { registered = factory; } } }, {});
|
|
59
|
+
assert.equal(typeof registered, "function");
|
|
60
|
+
});
|
|
61
|
+
});
|
package/test/router.test.mjs
CHANGED
|
@@ -79,6 +79,18 @@ test("apply 默认注册 hooks 与 commands", async () => {
|
|
|
79
79
|
assert.ok(commands.has("skill"));
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
+
test("每个命令的 input hint 都非空(宿主 normalizeDefinition 会抛 TypeError)", async () => {
|
|
83
|
+
// 1.0.6 回归:/panel 曾用 input:{hint:""},0.2.3 真机报
|
|
84
|
+
// TypeError: command "panel" input hint must not be empty,整条 lean-router-commands 不激活。
|
|
85
|
+
const { commands } = await routedSetup({});
|
|
86
|
+
assert.ok(commands.size >= 4, "band / skill / panel / lean-audit 都应注册");
|
|
87
|
+
for (const [name, def] of commands) {
|
|
88
|
+
if (def.input === undefined) continue;
|
|
89
|
+
assert.equal(typeof def.input.hint, "string", name + " 的 input.hint 必须是字符串");
|
|
90
|
+
assert.ok(def.input.hint.trim().length > 0, "命令 " + name + " 的 input hint 不能为空");
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
82
94
|
test("options 分流:hooks:false 只留命令;commands:false 只留钩子", async () => {
|
|
83
95
|
const a = await routedSetup({ hooks: false });
|
|
84
96
|
assert.ok(!a.handlers.has("agent/inbox/claimed"));
|