dsh-lean-router 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/cordis.patch.yml +0 -3
- package/docs/changelog.en.md +16 -1
- package/docs/changelog.md +17 -1
- package/docs/quickstart.en.md +1 -1
- package/docs/quickstart.md +1 -1
- package/lib/bands.js +18 -6
- package/lib/client.js +127 -0
- package/lib/router.js +64 -15
- package/package.json +8 -2
- package/presets/base/frag-preset.patch.yml +0 -3
- package/scripts/integrate-preset.mjs +6 -8
- package/test/integration-preset.test.mjs +3 -2
- package/test/patch-yaml.test.mjs +2 -3
- package/test/router.test.mjs +5 -1
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.
|
|
9
|
+
> Status: **v1.0.4 published** (npm: [dsh-lean-router](https://www.npmjs.com/package/dsh-lean-router) · GitHub Release [v1.0.4](https://github.com/ShawnSun-debug/dsh-lean-router/releases/tag/v1.0.4) · 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.
|
|
32
|
+
# once published: dsh plugin --profile desktop add npm:dsh-lean-router@1.0.4
|
|
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.
|
|
9
|
+
> 状态:**v1.0.4 已发布**(npm:[dsh-lean-router](https://www.npmjs.com/package/dsh-lean-router) · GitHub Release [v1.0.4](https://github.com/ShawnSun-debug/dsh-lean-router/releases/tag/v1.0.4) · 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.
|
|
32
|
+
# 发布后:dsh plugin --profile desktop add npm:dsh-lean-router@1.0.4
|
|
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:
|
package/docs/changelog.en.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
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.4).
|
|
4
|
+
|
|
5
|
+
## 1.0.4 (2026-11-22)
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
- 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.
|
|
9
|
+
- 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.
|
|
10
|
+
- 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).
|
|
11
|
+
- 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 · 已切换`.
|
|
12
|
+
- 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.
|
|
13
|
+
|
|
14
|
+
## 1.0.3 (2026-11-22)
|
|
15
|
+
|
|
16
|
+
- 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.
|
|
17
|
+
- Change: the `frag-preset` union drops from 22 to 21 rows (overrides 20 + toolface); `cordis.patch.yml` rebuilt.
|
|
18
|
+
- Add: `integration-preset` and `patch-yaml` now assert `ptc-runtime` never appears inside a preset.
|
|
4
19
|
|
|
5
20
|
## 1.0.2 (2026-11-22)
|
|
6
21
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
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.4)。
|
|
4
|
+
|
|
5
|
+
## 1.0.4 (2026-11-22)
|
|
6
|
+
|
|
7
|
+
- 新增(技能面板阶段 1):客户端插件骨架 —— 顶栏「技能」按钮 + 占位浮层面板(`lib/client.js`、`dsh.client.platform=web`、`exports['./client']`)。加载契约对齐 dsh 的 `window.__ModuleLoader__.load({ id, factory })`,UI 注册走 `ctx.slots.register`;面板用 `ReactDOM.createPortal` 挂 body,不依赖侧边栏。本阶段只验链路,真实数据与一键工作流在后续版本接入。
|
|
8
|
+
- 改进(可视化):`/band` 从「三段英文纯文本」改成一眼看清的排版 —— 第一行一行状态(如 `▲ react · 已按首条消息分类,关键词不再改带 · 可选 spec / react / weak`),中间是三带差异表格(当前档位用 `**▲ spec**` 粗体标记),末尾是「最近一次自动分类」及其依据(build/fix 词命中数 + 命中的词)。
|
|
9
|
+
- 新增:`lib/bands.js` 导出 `explainClassification(text)`,返回带号 + 两路命中数 + 词样例(最多 3 个);`classifyTask` 改为它的薄封装,分类结果与 1.0.3 完全一致。
|
|
10
|
+
- 新增:路由状态增加 `manual` 与 `last` 字段,用于区分「手动指定 / 按首条消息自动分类 / 还没分类」三种来源。近场引导文本不变(零写入契约不变)。
|
|
11
|
+
- 变更:`/band`(无参)与 `/band help` 等价,都输出状态面板;改档确认从 `Router band set to x.` 改为 `▲ x · 已切换`。
|
|
12
|
+
- 测试:`/band` 断言升级为
|
|
13
|
+
「第一行是状态 / 有三带表格 / 当前档位粗体 ▲ / 无消息时明确说明」,203 测试全绿。
|
|
14
|
+
|
|
15
|
+
## 1.0.3 (2026-11-22)
|
|
16
|
+
|
|
17
|
+
- 修复(真机致命):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 内无需重复声明。
|
|
18
|
+
- 变更:`frag-preset` 并集行 22 → 21(覆写块 20 + toolface),`cordis.patch.yml` 同步重建。
|
|
19
|
+
- 新增回归:`integration-preset` 与 `patch-yaml` 两处断言 preset 内不得出现 `ptc-runtime`。
|
|
4
20
|
|
|
5
21
|
## 1.0.2 (2026-11-22)
|
|
6
22
|
|
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 (once published)
|
|
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.4
|
|
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.4
|
|
24
24
|
~~~
|
|
25
25
|
|
|
26
26
|
(两条路径与 scripts/install.mjs 输出的说明一致;真安装器、认领边界与 `--uninstall` 回滚归票 09。)
|
package/lib/bands.js
CHANGED
|
@@ -78,6 +78,23 @@ function countHits(regex, text) {
|
|
|
78
78
|
return [...text.matchAll(regex)].length;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* 分类的可解释版本(供 /band 展示"最近一次分类结果与依据"):
|
|
83
|
+
* 返回带号 + 两路命中数 + 命中的词样例(去重,最多 3 个)。
|
|
84
|
+
* @param {string} text 用户消息全文
|
|
85
|
+
* @returns {{band: "spec"|"react"|"weak", reactHits: number, specHits: number, signals: string[]}}
|
|
86
|
+
*/
|
|
87
|
+
export function explainClassification(text) {
|
|
88
|
+
if (typeof text !== "string" || text.length === 0) return { band: "weak", reactHits: 0, specHits: 0, signals: [] };
|
|
89
|
+
const reactWords = [...text.matchAll(REACT_HINT_RE)].map((m) => m[0]);
|
|
90
|
+
const specWords = [...text.matchAll(SPEC_HINT_RE)].map((m) => m[0]);
|
|
91
|
+
const reactHits = reactWords.length;
|
|
92
|
+
const specHits = specWords.length;
|
|
93
|
+
const band = reactHits > specHits ? "react" : specHits > reactHits ? "spec" : "weak";
|
|
94
|
+
const signals = [...new Set([...reactWords, ...specWords])].slice(0, 3);
|
|
95
|
+
return { band, reactHits, specHits, signals };
|
|
96
|
+
}
|
|
97
|
+
|
|
81
98
|
/**
|
|
82
99
|
* 按首条真实用户消息分类任务带(思想移植、实现重写):
|
|
83
100
|
* build 类证据占优 -> react;fix 类证据占优 -> spec;平票或无匹配 -> weak
|
|
@@ -86,12 +103,7 @@ function countHits(regex, text) {
|
|
|
86
103
|
* @returns {"spec"|"react"|"weak"}
|
|
87
104
|
*/
|
|
88
105
|
export function classifyTask(text) {
|
|
89
|
-
|
|
90
|
-
const react = countHits(REACT_HINT_RE, text);
|
|
91
|
-
const spec = countHits(SPEC_HINT_RE, text);
|
|
92
|
-
if (react > spec) return "react";
|
|
93
|
-
if (spec > react) return "spec";
|
|
94
|
-
return "weak";
|
|
106
|
+
return explainClassification(text).band;
|
|
95
107
|
}
|
|
96
108
|
|
|
97
109
|
/** 架构型词(深度任务启发):命中或长文本视为复杂任务(深度引导变体)。 */
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// dsh-lean-router - 客户端 UI 层(技能面板)
|
|
2
|
+
//
|
|
3
|
+
// 加载契约(逆向自 dsh-cost-meter / dsh-ops 的产物,dsh 客户端模块系统 dsh-client-modules):
|
|
4
|
+
// 1. 入口文件是 lib/client.js,package.json 用 dsh.client.platform = "web" 声明;
|
|
5
|
+
// 2. 文件形如 window.__ModuleLoader__.load({ id, factory }),factory(require) 内
|
|
6
|
+
// require 宿主提供的模块(react / react-dom / @deepseek-ai/dsh-client-ui-*),
|
|
7
|
+
// 插件自身的依赖不打包,全部走宿主;
|
|
8
|
+
// 3. factory 返回插件模块,导出 apply(cordis 插件形;generator 形式 = effect 生命周期)。
|
|
9
|
+
//
|
|
10
|
+
// 阶段 1(骨架):顶栏工具区一个「技能」按钮,点开全屏门户面板,面板内容暂为占位;
|
|
11
|
+
// 面板与按钮同组件、用 ReactDOM.createPortal 挂到 body,不依赖第二个 slot,
|
|
12
|
+
// 也不受任何 slot 容器的布局/裁剪影响。
|
|
13
|
+
//
|
|
14
|
+
// 阶段 2:接宿主数据(31 技能 + 审计统计);阶段 3:分组表 + 开关 + 一键工作流。
|
|
15
|
+
window.__ModuleLoader__.load({
|
|
16
|
+
id: "dsh-lean-router",
|
|
17
|
+
factory: (require) => {
|
|
18
|
+
const React = require("react");
|
|
19
|
+
const ReactDOM = require("react-dom");
|
|
20
|
+
const h = React.createElement;
|
|
21
|
+
|
|
22
|
+
const btnStyle = {
|
|
23
|
+
display: "inline-flex",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
gap: 4,
|
|
26
|
+
height: 26,
|
|
27
|
+
padding: "0 10px",
|
|
28
|
+
marginLeft: 6,
|
|
29
|
+
borderRadius: 6,
|
|
30
|
+
border: "1px solid var(--dsh-border, rgba(128,128,128,.35))",
|
|
31
|
+
background: "var(--dsh-surface, transparent)",
|
|
32
|
+
color: "inherit",
|
|
33
|
+
fontSize: 12,
|
|
34
|
+
lineHeight: "24px",
|
|
35
|
+
cursor: "pointer",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const overlayStyle = {
|
|
39
|
+
position: "fixed",
|
|
40
|
+
inset: 0,
|
|
41
|
+
zIndex: 1000,
|
|
42
|
+
display: "flex",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
justifyContent: "center",
|
|
45
|
+
background: "rgba(0,0,0,.45)",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const cardStyle = {
|
|
49
|
+
position: "relative",
|
|
50
|
+
width: "min(920px, 92vw)",
|
|
51
|
+
maxHeight: "82vh",
|
|
52
|
+
overflow: "auto",
|
|
53
|
+
padding: "20px 22px",
|
|
54
|
+
borderRadius: 12,
|
|
55
|
+
background: "var(--dsh-surface, #1b1b1f)",
|
|
56
|
+
color: "var(--dsh-text, inherit)",
|
|
57
|
+
boxShadow: "0 18px 60px rgba(0,0,0,.45)",
|
|
58
|
+
fontSize: 13,
|
|
59
|
+
lineHeight: 1.6,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const closeStyle = {
|
|
63
|
+
position: "absolute",
|
|
64
|
+
top: 10,
|
|
65
|
+
right: 12,
|
|
66
|
+
border: "none",
|
|
67
|
+
background: "transparent",
|
|
68
|
+
color: "inherit",
|
|
69
|
+
fontSize: 18,
|
|
70
|
+
lineHeight: "20px",
|
|
71
|
+
cursor: "pointer",
|
|
72
|
+
opacity: 0.7,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** 技能面板(阶段 1 占位;阶段 2/3 接真实数据)。 */
|
|
76
|
+
function SkillsPanel(props) {
|
|
77
|
+
return h(
|
|
78
|
+
"div",
|
|
79
|
+
{ style: overlayStyle, onClick: props.onClose },
|
|
80
|
+
h(
|
|
81
|
+
"div",
|
|
82
|
+
{ style: cardStyle, onClick: (event) => event.stopPropagation() },
|
|
83
|
+
h("button", { type: "button", style: closeStyle, onClick: props.onClose, title: "关闭" }, "✕"),
|
|
84
|
+
h("div", { style: { fontSize: 15, fontWeight: 600, marginBottom: 8 } }, "技能面板 · 骨架"),
|
|
85
|
+
h(
|
|
86
|
+
"div",
|
|
87
|
+
{ style: { opacity: 0.75 } },
|
|
88
|
+
"链路已通:这个面板由 dsh-lean-router 的客户端插件渲染。",
|
|
89
|
+
h("br"),
|
|
90
|
+
"阶段 2 接入 31 个技能与审计统计,阶段 3 加分组表格、开关与一键工作流。"
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** 顶栏「技能」按钮:点开/关闭门户面板。 */
|
|
97
|
+
function SkillsButton() {
|
|
98
|
+
const [open, setOpen] = React.useState(false);
|
|
99
|
+
const close = React.useCallback(() => setOpen(false), []);
|
|
100
|
+
return h(
|
|
101
|
+
React.Fragment,
|
|
102
|
+
null,
|
|
103
|
+
h(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
type: "button",
|
|
107
|
+
style: btnStyle,
|
|
108
|
+
title: "lean-router 技能面板",
|
|
109
|
+
onClick: () => setOpen((value) => !value),
|
|
110
|
+
},
|
|
111
|
+
"技能"
|
|
112
|
+
),
|
|
113
|
+
open ? ReactDOM.createPortal(h(SkillsPanel, { onClose: close }), document.body) : null
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** cordis 插件入口:注册顶栏按钮(generator = effect,卸载时自动注销)。 */
|
|
118
|
+
function* apply(ctx) {
|
|
119
|
+
yield ctx.slots.register(
|
|
120
|
+
{ name: "conversation.session.header.utilities", id: "lean-router.skills", order: 60 },
|
|
121
|
+
SkillsButton
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return { apply };
|
|
126
|
+
},
|
|
127
|
+
});
|
package/lib/router.js
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
TASK_ECHO_PREFIX,
|
|
27
27
|
classifyTask,
|
|
28
28
|
diligenceReminder,
|
|
29
|
+
explainClassification,
|
|
29
30
|
parseRouterDirective,
|
|
30
31
|
} from "./bands.js";
|
|
31
32
|
import { defaultAuditPath, wireAuditSink } from "./audit-sink.js";
|
|
@@ -111,12 +112,34 @@ function capture(states, agent, message, turn, skipInherited) {
|
|
|
111
112
|
const directive = parseRouterDirective(text);
|
|
112
113
|
if (directive !== null) {
|
|
113
114
|
const band = directive.band === "auto" ? null : directive.band;
|
|
114
|
-
const next = {
|
|
115
|
+
const next = {
|
|
116
|
+
band,
|
|
117
|
+
task: directive.task ?? previous?.task ?? null,
|
|
118
|
+
turn,
|
|
119
|
+
// /band 展示用:manual 区分「手动指定」与「按首条消息自动分类」;
|
|
120
|
+
// last 只记最近一次关键词自动分类的结果(用于"最近一次自动分类"那一行)。
|
|
121
|
+
manual: directive.band !== "auto",
|
|
122
|
+
last: previous?.last ?? null,
|
|
123
|
+
};
|
|
115
124
|
states.set(agent, next);
|
|
116
125
|
return previous === null ? band !== null : previous.band !== band;
|
|
117
126
|
}
|
|
118
127
|
if (previous === null) {
|
|
119
|
-
|
|
128
|
+
const explained = explainClassification(text);
|
|
129
|
+
states.set(agent, {
|
|
130
|
+
band: explained.band,
|
|
131
|
+
task: null,
|
|
132
|
+
turn,
|
|
133
|
+
manual: false,
|
|
134
|
+
last: {
|
|
135
|
+
via: "keywords",
|
|
136
|
+
band: explained.band,
|
|
137
|
+
reactHits: explained.reactHits,
|
|
138
|
+
specHits: explained.specHits,
|
|
139
|
+
signals: explained.signals,
|
|
140
|
+
at: Date.now(),
|
|
141
|
+
},
|
|
142
|
+
});
|
|
120
143
|
return true;
|
|
121
144
|
}
|
|
122
145
|
if (previous.turn !== turn) states.set(agent, { ...previous, turn });
|
|
@@ -180,18 +203,43 @@ function executeBandCommand(states, invocation) {
|
|
|
180
203
|
if (!agent) return { kind: "error", text: "/band has no active agent to route." };
|
|
181
204
|
const raw = (invocation.rawInput ?? "").trim();
|
|
182
205
|
const state = stateOf(states, agent);
|
|
183
|
-
if (raw.length === 0) {
|
|
206
|
+
if (raw.length === 0 || raw.toLowerCase() === "help") {
|
|
184
207
|
const band = state?.band ?? null;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
208
|
+
const current = band ?? "auto";
|
|
209
|
+
// 一眼看清:一行状态在前,三带差异用表格,当前档位加 ▲ 粗体标记。
|
|
210
|
+
const cell = (id) => (id === current ? "**▲ " + id + "**" : id);
|
|
211
|
+
const table = [
|
|
212
|
+
"| 档位 | 定位 | 工具面 |",
|
|
213
|
+
"|---|---|---|",
|
|
214
|
+
"| " + cell("auto") + " | 按首条用户消息自动分类 | — |",
|
|
215
|
+
"| " + cell("spec") + " | 先查后改(读优先) | 窄 |",
|
|
216
|
+
"| " + cell("react") + " | 直接产出(写优先) | 宽 |",
|
|
217
|
+
"| " + cell("weak") + " | 交给模型自判 | 窄 |",
|
|
218
|
+
].join("\n");
|
|
219
|
+
// 来源说明用中文,区分「还没分类」「自动分类锁定」「手动指定」三种状态。
|
|
220
|
+
const sourceNote =
|
|
221
|
+
band === null
|
|
222
|
+
? "下一条消息自动分类"
|
|
223
|
+
: state?.manual === true
|
|
224
|
+
? "手动指定,关键词不再改带"
|
|
225
|
+
: "已按首条消息分类,关键词不再改带";
|
|
226
|
+
const head = "▲ " + current + " · " + sourceNote + " · 可选 spec / react / weak";
|
|
227
|
+
const last = state?.last ?? null;
|
|
228
|
+
const lastLine =
|
|
229
|
+
last === null || last.band === null
|
|
230
|
+
? "最近一次自动分类:暂无(等待下一条用户消息)"
|
|
231
|
+
: "最近一次自动分类:" +
|
|
232
|
+
last.band +
|
|
233
|
+
"(build 词 " +
|
|
234
|
+
last.reactHits +
|
|
235
|
+
" · fix 词 " +
|
|
236
|
+
last.specHits +
|
|
237
|
+
(last.signals.length > 0 ? ";命中 " + last.signals.join("、") : "") +
|
|
238
|
+
")";
|
|
239
|
+
const parts = [head, "", table, "", lastLine];
|
|
240
|
+
if (state?.task) parts.push(TASK_ECHO_PREFIX + state.task);
|
|
241
|
+
parts.push("用法:/band spec | react | weak | auto · /band react task=发布 MVP · /band help");
|
|
242
|
+
return { kind: "success", text: parts.join("\n") };
|
|
195
243
|
}
|
|
196
244
|
const tokens = raw.split(/[ \t]+/);
|
|
197
245
|
const head = tokens[0].toLowerCase();
|
|
@@ -206,10 +254,11 @@ function executeBandCommand(states, invocation) {
|
|
|
206
254
|
}
|
|
207
255
|
const band = head === "auto" ? null : head;
|
|
208
256
|
const turn = state?.turn ?? 0;
|
|
209
|
-
|
|
257
|
+
// 走命令改档 = 人在回路:manual 置真(auto 回退置假),并保留上一次自动分类结果。
|
|
258
|
+
states.set(agent, { band, task: taskArg ?? state?.task ?? null, turn, manual: band !== null, last: state?.last ?? null });
|
|
210
259
|
return {
|
|
211
260
|
kind: "success",
|
|
212
|
-
text: "
|
|
261
|
+
text: "▲ " + (band ?? "auto") + " · 已切换" + (taskArg ? "\n" + TASK_ECHO_PREFIX + taskArg : ""),
|
|
213
262
|
};
|
|
214
263
|
}
|
|
215
264
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-lean-router",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "lean 省 token × 思考链路由 × code_run 工具遮蔽 × mattpocock 技能自动调用的 DSH cordis 插件(单 bundle:预设+配套技能)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"./router": "./lib/router.js",
|
|
11
11
|
"./toolface": "./lib/toolface/index.js",
|
|
12
12
|
"./lean/delivery-gate": "./lib/lean/delivery-gate.js",
|
|
13
|
-
"./lean/tool-concurrency": "./lib/lean/tool-concurrency.js"
|
|
13
|
+
"./lean/tool-concurrency": "./lib/lean/tool-concurrency.js",
|
|
14
|
+
"./client": {
|
|
15
|
+
"default": "./lib/client.js"
|
|
16
|
+
}
|
|
14
17
|
},
|
|
15
18
|
"files": [
|
|
16
19
|
"lib",
|
|
@@ -46,6 +49,9 @@
|
|
|
46
49
|
"dsh": {
|
|
47
50
|
"bundle": {
|
|
48
51
|
"patch": "./cordis.patch.yml"
|
|
52
|
+
},
|
|
53
|
+
"client": {
|
|
54
|
+
"platform": "web"
|
|
49
55
|
}
|
|
50
56
|
},
|
|
51
57
|
"keywords": [
|
|
@@ -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)+
|
|
71
|
-
// ptc-runtime
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
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,
|
|
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
|
-
|
|
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 内');
|
package/test/patch-yaml.test.mjs
CHANGED
|
@@ -35,12 +35,11 @@ test("全部 presets/base 补丁片段可解析", () => {
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
test("ptc-runtime
|
|
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.
|
|
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
|
});
|
package/test/router.test.mjs
CHANGED
|
@@ -185,7 +185,11 @@ test("/band:显示/改档/auto 回退/非法值报错", async () => {
|
|
|
185
185
|
// 无参显示
|
|
186
186
|
const shown = band.handler({ agent: agentA, rawInput: "" });
|
|
187
187
|
assert.equal(shown.kind, "success");
|
|
188
|
-
assert.ok(shown.text.includes("auto
|
|
188
|
+
assert.ok(shown.text.includes("▲ auto"), "第一行必须是一行状态");
|
|
189
|
+
assert.ok(shown.text.includes("| 档位 |"), "三带差异必须用表格展示");
|
|
190
|
+
assert.ok(shown.text.includes("最近一次自动分类:暂无"), "没有用户消息时给出明确说明");
|
|
191
|
+
assert.ok(shown.text.includes("下一条消息自动分类"), "未分类时来源说明为自动");
|
|
192
|
+
assert.ok(shown.text.includes("**▲ auto**"), "当前档位在表格里用 ▲ 粗体标记");
|
|
189
193
|
// 改档
|
|
190
194
|
const set = band.handler({ agent: agentA, rawInput: "react task = 发布 MVP" });
|
|
191
195
|
assert.equal(set.kind, "success");
|