dsh-lean-router 1.0.9 → 2.0.0
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/NOTICE.md +2 -4
- package/README.en.md +47 -43
- package/README.md +45 -41
- package/cordis.patch.yml +4 -26
- package/docs/agents/domain.md +1 -1
- package/docs/architecture.en.md +51 -86
- package/docs/architecture.md +46 -77
- package/docs/changelog.en.md +32 -1
- package/docs/changelog.md +32 -1
- package/docs/configuration.en.md +25 -56
- package/docs/configuration.md +14 -45
- package/docs/install.en.md +2 -2
- package/docs/install.md +2 -2
- package/docs/quickstart.en.md +29 -34
- package/docs/quickstart.md +11 -16
- package/docs/release-checklist.en.md +3 -4
- package/docs/release-checklist.md +5 -6
- package/docs//350/267/257/347/224/261-/350/256/276/350/256/241/350/257/264/346/230/216.md +2 -2
- package/lib/index.js +9 -61
- package/lib/router.js +15 -148
- package/package.json +4 -15
- package/presets/base/frag-lean.patch.yml +1 -5
- package/presets/base/frag-preset.patch.yml +1 -3
- package/presets/base/frag-router.patch.yml +1 -12
- package/presets/base/frag-toolface.patch.yml +0 -2
- package/presets/base/lean-router.patch.yml +1 -4
- package/scripts/doctor.mjs +15 -10
- package/test/integration-preset.test.mjs +4 -3
- package/test/plugin-entry.test.mjs +15 -50
- package/test/router.test.mjs +7 -47
- package/assets/gating.weights.json +0 -13
- package/assets/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
- package/assets/skills/ask-matt/SKILL.md +0 -80
- package/assets/skills/ask-matt/agents/openai.yaml +0 -5
- package/assets/skills/chief-of-staff/SKILL.md +0 -76
- package/assets/skills/chief-of-staff/agents/openai.yaml +0 -5
- package/assets/skills/code-review/SKILL.md +0 -91
- package/assets/skills/code-review/agents/openai.yaml +0 -5
- package/assets/skills/codebase-design/DEEPENING.md +0 -37
- package/assets/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
- package/assets/skills/codebase-design/SKILL.md +0 -116
- package/assets/skills/codebase-design/agents/openai.yaml +0 -5
- package/assets/skills/diagnosing-bugs/SKILL.md +0 -140
- package/assets/skills/diagnosing-bugs/agents/openai.yaml +0 -5
- package/assets/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -44
- package/assets/skills/domain-modeling/ADR-FORMAT.md +0 -47
- package/assets/skills/domain-modeling/GLOSSARY-FORMAT.md +0 -60
- package/assets/skills/domain-modeling/SKILL.md +0 -76
- package/assets/skills/domain-modeling/agents/openai.yaml +0 -5
- package/assets/skills/grilling/SKILL.md +0 -52
- package/assets/skills/grilling/agents/openai.yaml +0 -5
- package/assets/skills/handoff/SKILL.md +0 -17
- package/assets/skills/handoff/agents/openai.yaml +0 -5
- package/assets/skills/implement/SKILL.md +0 -55
- package/assets/skills/implement/agents/openai.yaml +0 -5
- package/assets/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
- package/assets/skills/improve-codebase-architecture/SKILL.md +0 -72
- package/assets/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
- package/assets/skills/loop-me/SKILL.md +0 -33
- package/assets/skills/loop-me/agents/openai.yaml +0 -5
- package/assets/skills/pr/CREDITS.md +0 -3
- package/assets/skills/pr/SKILL.md +0 -172
- package/assets/skills/pr/agents/openai.yaml +0 -5
- package/assets/skills/prototype/LOGIC.md +0 -67
- package/assets/skills/prototype/SKILL.md +0 -28
- package/assets/skills/prototype/UI.md +0 -112
- package/assets/skills/prototype/agents/openai.yaml +0 -5
- package/assets/skills/research/SKILL.md +0 -14
- package/assets/skills/research/agents/openai.yaml +0 -5
- package/assets/skills/retro/SKILL.md +0 -45
- package/assets/skills/retro/agents/openai.yaml +0 -5
- package/assets/skills/setup-matt-pocock-skills/SKILL.md +0 -121
- package/assets/skills/setup-matt-pocock-skills/agents/openai.yaml +0 -5
- package/assets/skills/setup-matt-pocock-skills/domain.md +0 -51
- package/assets/skills/setup-matt-pocock-skills/issue-tracker-github.md +0 -50
- package/assets/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +0 -46
- package/assets/skills/setup-matt-pocock-skills/issue-tracker-local.md +0 -30
- package/assets/skills/setup-matt-pocock-skills/triage-labels.md +0 -15
- package/assets/skills/setup-ts-deep-modules/SKILL.md +0 -103
- package/assets/skills/setup-ts-deep-modules/agents/openai.yaml +0 -5
- package/assets/skills/setup-ts-deep-modules/dependency-cruiser.config.cjs +0 -95
- package/assets/skills/software-factory/EXAMPLE-TASKS.md +0 -80
- package/assets/skills/software-factory/GIT-HOSTS.md +0 -84
- package/assets/skills/software-factory/OBSERVABILITY-PLATFORMS.md +0 -75
- package/assets/skills/software-factory/RUNNERS.md +0 -94
- package/assets/skills/software-factory/SKILL.md +0 -99
- package/assets/skills/software-factory/TICKET-TRACKERS.md +0 -85
- package/assets/skills/tdd/SKILL.md +0 -40
- package/assets/skills/tdd/agents/openai.yaml +0 -5
- package/assets/skills/tdd/mocking.md +0 -59
- package/assets/skills/tdd/tests.md +0 -77
- package/assets/skills/teach/GLOSSARY-FORMAT.md +0 -35
- package/assets/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
- package/assets/skills/teach/MISSION-FORMAT.md +0 -31
- package/assets/skills/teach/RESOURCES-FORMAT.md +0 -32
- package/assets/skills/teach/SKILL.md +0 -141
- package/assets/skills/teach/agents/openai.yaml +0 -5
- package/assets/skills/to-questionnaire/SKILL.md +0 -55
- package/assets/skills/to-questionnaire/agents/openai.yaml +0 -5
- package/assets/skills/to-spec/SKILL.md +0 -76
- package/assets/skills/to-spec/agents/openai.yaml +0 -5
- package/assets/skills/to-tickets/SKILL.md +0 -106
- package/assets/skills/to-tickets/agents/openai.yaml +0 -5
- package/assets/skills/triage/AGENT-BRIEF.md +0 -207
- package/assets/skills/triage/OUT-OF-SCOPE.md +0 -105
- package/assets/skills/triage/SKILL.md +0 -113
- package/assets/skills/triage/agents/openai.yaml +0 -5
- package/assets/skills/wait-what/SKILL.md +0 -8
- package/assets/skills/wait-what/agents/openai.yaml +0 -5
- package/assets/skills/wayfinder/SKILL.md +0 -129
- package/assets/skills/wayfinder/agents/openai.yaml +0 -5
- package/assets/skills/wizard/SKILL.md +0 -46
- package/assets/skills/wizard/agents/openai.yaml +0 -5
- package/assets/skills/wizard/template.sh +0 -223
- package/assets/skills/writing-beats/SKILL.md +0 -44
- package/assets/skills/writing-beats/agents/openai.yaml +0 -5
- package/assets/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
- package/assets/skills/writing-for-agents/SKILL.md +0 -83
- package/assets/skills/writing-for-agents/agents/openai.yaml +0 -5
- package/assets/skills/writing-fragments/SKILL.md +0 -80
- package/assets/skills/writing-fragments/agents/openai.yaml +0 -5
- package/assets/skills/writing-shape/SKILL.md +0 -59
- package/assets/skills/writing-shape/agents/openai.yaml +0 -5
- package/assets/skills.matrix.json +0 -311
- package/docs/HANDOFF-2026-11-22.md +0 -155
- package/docs/matrix.en.md +0 -57
- package/docs/matrix.md +0 -57
- package/docs//346/212/200/350/203/275/351/227/250/346/216/247-/350/256/276/350/256/241/350/257/264/346/230/216.md +0 -134
- package/docs//351/235/242/346/235/277-/350/256/276/350/256/241/350/257/264/346/230/216.md +0 -205
- package/lib/audit-commands.js +0 -289
- package/lib/audit-sink.js +0 -137
- package/lib/client.js +0 -276
- package/lib/gate-runner.js +0 -179
- package/lib/skill-provider.js +0 -167
- package/lib/skillgate.js +0 -396
- package/lib/skills-panel.js +0 -322
- package/scripts/check-drift.mjs +0 -24
- package/skills.manifest.json +0 -287
- package/test/audit-commands.test.mjs +0 -325
- package/test/audit-sink.test.mjs +0 -150
- package/test/client-plugin.test.mjs +0 -123
- package/test/gate-run.test.mjs +0 -173
- package/test/manifest.test.mjs +0 -25
- package/test/provider.test.mjs +0 -21
- package/test/skillgate-provider.test.mjs +0 -122
- package/test/skillgate.test.mjs +0 -217
- package/test/skills-panel.test.mjs +0 -114
- package/ui/go.json +0 -19
package/docs/quickstart.en.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Quickstart
|
|
2
2
|
|
|
3
|
-
> **dsh-lean-router** is one DeepSeek Harness (DSH) cordis plugin card
|
|
3
|
+
> **dsh-lean-router** is one DeepSeek Harness (DSH) cordis plugin card: lean token saving, thinking-chain routing and `code_run` tool masking combined in a single preset. English is secondary here; the Chinese original is [quickstart.md](./quickstart.md).
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
7
|
- DSH `>=0.2.1-rc.5 <0.2.4-0` (measured baseline 0.2.3-alpha.2; see the engines field in package.json).
|
|
8
|
-
- The package is published on npm (`dsh-lean-router`), so Path B is recommended; use Path A when you edit the code. DSH is in developer preview; engine drift is handled by the engines gate
|
|
8
|
+
- The package is published on npm (`dsh-lean-router`), so Path B is recommended; use Path A when you edit the code. DSH is in developer preview; engine drift is handled by the engines gate and the doctor self-check, never by silent degradation.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -15,66 +15,61 @@
|
|
|
15
15
|
dsh plugin --profile desktop add "link:D:\path\to\dsh-lean-router"
|
|
16
16
|
~~~
|
|
17
17
|
|
|
18
|
-
After restarting DSH, pick
|
|
18
|
+
After restarting DSH, pick **Lean router** (lean tier) or **Lean router (balance)** (weaker-constraint tier) for new sessions.
|
|
19
19
|
|
|
20
20
|
### Path B: npm install (recommended)
|
|
21
21
|
|
|
22
22
|
~~~powershell
|
|
23
|
-
dsh plugin --profile desktop add npm:dsh-lean-router@
|
|
23
|
+
dsh plugin --profile desktop add npm:dsh-lean-router@2.0.0
|
|
24
24
|
~~~
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### Stub behavior when the dependency is missing
|
|
26
|
+
### Stub behaviour when the dependency is missing
|
|
29
27
|
|
|
30
28
|
The package depends on `@deepseek-ai/dsh-tool-executor-native` (package.json dependencies). If that dependency is not resolved with the package (e.g. a manual directory copy), the tool-masking layer fails loudly instead of silently: the executor degrades to an install-hint stub, and the first `describe` call throws an error containing the install guidance (lib/toolface/executor.js L57-63):
|
|
31
29
|
|
|
32
30
|
> dsh-lean-router/toolface requires the dependency "@deepseek-ai/dsh-tool-executor-native". Install dsh-lean-router together with its dependencies (dsh plugin add resolves them) or upgrade the package; ...
|
|
33
31
|
|
|
34
|
-
To
|
|
32
|
+
To repair by hand, run `npm install` in the package directory or reinstall with `dsh plugin add` so the host resolves the dependency tree.
|
|
35
33
|
|
|
36
34
|
## First use
|
|
37
35
|
|
|
38
|
-
1.
|
|
39
|
-
2. Optional explicit routing directive in the first real user message:
|
|
36
|
+
1. Choose a preset for the new session: **Lean router** (13 rules + 3 soft gates + routing) or **Lean router (balance)** (3 rules, no routing directives yet).
|
|
37
|
+
2. Optional explicit routing directive, written in the first real user message:
|
|
40
38
|
|
|
41
39
|
~~~text
|
|
42
40
|
[router] band=spec
|
|
43
|
-
[router] band=react task=
|
|
41
|
+
[router] band=react task=split the home page into components
|
|
44
42
|
[router] band=auto
|
|
45
43
|
~~~
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
3.
|
|
45
|
+
Without the directive the band is classified from keywords; ties fall back to `weak` (model-routed).
|
|
46
|
+
3. Commands:
|
|
49
47
|
- `/band`: view or switch the routing band (spec/react/weak/auto).
|
|
50
|
-
- `/
|
|
51
|
-
|
|
52
|
-
4. Tool masking is automatic: the model's tool list shows preset-owned tools + `code_run` only. MCP and out-of-preset plugin tools are discovered inside a `code_run` program via `tools.code_tools_search(...)` and then called by exact name. Direct calls to masked names are rejected with a hint to search first.
|
|
48
|
+
- `/compact`: trigger context compaction manually.
|
|
49
|
+
4. Masking is automatic: the model's tool list only contains the preset's own tools plus `code_run`; MCP and out-of-preset tools are discovered inside a `code_run` program with `tools.code_tools_search(...)`. Calling a masked name directly is refused with a hint to search first.
|
|
53
50
|
|
|
54
|
-
##
|
|
51
|
+
## Self-check
|
|
55
52
|
|
|
56
53
|
~~~powershell
|
|
57
|
-
node scripts/doctor.mjs #
|
|
58
|
-
npm run verify # build --check (
|
|
59
|
-
npm test # node --test test
|
|
54
|
+
node scripts/doctor.mjs # 11 structural checks (name / engines / patch / preset row / router row / no skill-provider row / no client-host row / three entry files / client bundle removed)
|
|
55
|
+
npm run verify # build --check (byte-identical) + doctor
|
|
56
|
+
npm test # node --test "test/*.test.mjs"
|
|
60
57
|
~~~
|
|
61
58
|
|
|
62
|
-
## Glossary
|
|
59
|
+
## Glossary
|
|
63
60
|
|
|
64
61
|
| Term | Meaning |
|
|
65
62
|
|---|---|
|
|
66
|
-
| lean |
|
|
67
|
-
| masking |
|
|
68
|
-
| routing |
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
- The plan-mode section keeps the flash wording verbatim (including the PTC `run_code` sentence).
|
|
78
|
-
- Per-turn gating runs through the injection seam rather than re-calling `list()`: audits are labeled `mode: "fallback-cached-list"` when the host `SkillRegistry.collect()` cache is serving.
|
|
63
|
+
| lean | the four token-saving mechanisms (turn compaction, output pruning, disabled plugins, behaviour discipline) plus two add-ons (delivery gate, concurrency markers) |
|
|
64
|
+
| masking | hiding tools the preset does not own from the model-facing request while programs can still call them (toolface) |
|
|
65
|
+
| routing | classifying the task into one of three bands and injecting that band's guide near-field (router) |
|
|
66
|
+
| band | spec (inspect-and-plan) / react (hands-on-production) / weak (model-routed) |
|
|
67
|
+
| near-field guide | fixed text injected through a dynamic context: constant within a band, so the host's equality check writes nothing |
|
|
68
|
+
|
|
69
|
+
## Current state (stated plainly)
|
|
70
|
+
|
|
71
|
+
- The balance preset carries no routing directives yet.
|
|
72
|
+
- The plan-mode policy paragraph keeps the upstream flash text (including the PTC `run_code` sentence).
|
|
73
|
+
- Since 2.0.0 the skills subsystem (31 skills, per-turn gate, audit, panel) is gone entirely.
|
|
79
74
|
|
|
80
75
|
See [architecture.en.md](./architecture.en.md), [configuration.en.md](./configuration.en.md) and [changelog.en.md](./changelog.en.md).
|
package/docs/quickstart.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# 快速上手(quickstart)
|
|
2
2
|
|
|
3
|
-
> 本包 **dsh-lean-router** 是一张 DeepSeek Harness(DSH)cordis 插件卡:lean 省 token × 思考链路由 × `code_run`
|
|
3
|
+
> 本包 **dsh-lean-router** 是一张 DeepSeek Harness(DSH)cordis 插件卡:lean 省 token × 思考链路由 × `code_run` 工具遮蔽,三个机制合并在一个预设里。中文为第一语言,英文版见 [quickstart.en.md](./quickstart.en.md)。
|
|
4
4
|
|
|
5
5
|
## 前置条件
|
|
6
6
|
|
|
7
7
|
- DSH `>=0.2.1-rc.5 <0.2.4-0`(实测基线 0.2.3-alpha.2;见 package.json engines 字段)。
|
|
8
|
-
- 本包已发布到 npm(`dsh-lean-router`),推荐路径 B;改代码调试走路径 A。DSH 处于 developer preview,版本越界将以 engines 闸 + doctor
|
|
8
|
+
- 本包已发布到 npm(`dsh-lean-router`),推荐路径 B;改代码调试走路径 A。DSH 处于 developer preview,版本越界将以 engines 闸 + doctor 自检应对,不做静默降级。
|
|
9
9
|
|
|
10
10
|
## 安装
|
|
11
11
|
|
|
@@ -20,22 +20,20 @@ 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@
|
|
23
|
+
dsh plugin --profile desktop add npm:dsh-lean-router@2.0.0
|
|
24
24
|
~~~
|
|
25
25
|
|
|
26
|
-
(两条路径与 scripts/install.mjs 输出的说明一致;真安装器、认领边界与 `--uninstall` 回滚归票 09。)
|
|
27
|
-
|
|
28
26
|
### 缺依赖时的 stub 引导行为
|
|
29
27
|
|
|
30
28
|
本包依赖 `@deepseek-ai/dsh-tool-executor-native`(package.json dependencies)。若该依赖未随包解析(如手动复制目录安装),工具遮蔽层不会静默坏掉:executor 会退化为安装提示 stub——首次调用 `describe` 直接抛出含安装指引的错误(lib/toolface/executor.js L57-63),错误信息为:
|
|
31
29
|
|
|
32
30
|
> dsh-lean-router/toolface requires the dependency "@deepseek-ai/dsh-tool-executor-native". Install dsh-lean-router together with its dependencies (dsh plugin add resolves them) or upgrade the package; ...
|
|
33
31
|
|
|
34
|
-
手动补装:在该包目录 `npm install`,或用 `dsh plugin add`
|
|
32
|
+
手动补装:在该包目录 `npm install`,或用 `dsh plugin add` 重装以让宿主解析依赖树。
|
|
35
33
|
|
|
36
34
|
## 首次使用
|
|
37
35
|
|
|
38
|
-
1. 新会话选择预设:**Lean router**(13 条纪律 + 3 软门 + 路由)或 **Lean router (balance)**(3
|
|
36
|
+
1. 新会话选择预设:**Lean router**(13 条纪律 + 3 软门 + 路由)或 **Lean router (balance)**(3 条纪律,暂不含路由指令)。
|
|
39
37
|
2. 可选显式路由指令(写在首条真实用户消息里):
|
|
40
38
|
|
|
41
39
|
~~~text
|
|
@@ -44,19 +42,18 @@ dsh plugin --profile desktop add npm:dsh-lean-router@1.0.9
|
|
|
44
42
|
[router] band=auto
|
|
45
43
|
~~~
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
省略指令时按关键词自动分类,平票归 `weak`(模型自分类)。
|
|
48
46
|
3. 常用命令:
|
|
49
47
|
- `/band`:查看或切换路由带(spec/react/weak/auto)。
|
|
50
|
-
- `/skill`:列出可用技能与 invocation 开关;`/skill <name>` 看单个技能。
|
|
51
48
|
- `/compact`:手动触发上下文压缩(compaction 组)。
|
|
52
49
|
4. 工具遮蔽是自动的:模型工具列表只出现预设自有工具 + `code_run`;MCP 与预设外插件工具在 `code_run` 程序内用 `tools.code_tools_search(...)` 发现后调用。直呼被遮蔽名会被拒绝并提示先搜索。
|
|
53
50
|
|
|
54
51
|
## 体检
|
|
55
52
|
|
|
56
53
|
~~~powershell
|
|
57
|
-
node scripts/doctor.mjs #
|
|
54
|
+
node scripts/doctor.mjs # 11 项结构自检(包名/engines/patch/预设行/路由行/无技能 provider 行/无客户端宿主行/三个入口文件/客户端 bundle 已移除)
|
|
58
55
|
npm run verify # build --check(cordis.patch.yml 反向逐字节一致)+ doctor
|
|
59
|
-
npm test # node --test test
|
|
56
|
+
npm test # node --test "test/*.test.mjs"
|
|
60
57
|
~~~
|
|
61
58
|
|
|
62
59
|
## 术语表(全包统一)
|
|
@@ -66,15 +63,13 @@ npm test # node --test test/(20 个测试文件)
|
|
|
66
63
|
| lean | 省 token 的四机制总称(轮次压缩/输出裁剪/关插件/行为纪律),外加两个加料件(交付门/并发标记) |
|
|
67
64
|
| 遮蔽(masking) | 把预设不拥有的工具从模型请求面隐藏,程序内仍可调用(toolface 层) |
|
|
68
65
|
| 路由(routing) | 把任务分到三条行为带并在近场注入对应引导(router 层) |
|
|
69
|
-
| 门控(gating) | 每轮对 31 技能全量打分、只放行高分技能进近场通道(skillgate 层) |
|
|
70
66
|
| 带(band) | spec(inspect-and-plan)/ react(hands-on-production)/ weak(model-routed)三带 |
|
|
71
67
|
| 近场引导 | 通过 dynamic context 注入的固定文本:同一带内文本恒定、宿主判等零写入 |
|
|
72
68
|
|
|
73
|
-
##
|
|
69
|
+
## 现状(如实标注,勿当承诺)
|
|
74
70
|
|
|
75
|
-
-
|
|
76
|
-
- balance 预设行暂不含路由指令(v1 裁定)。
|
|
71
|
+
- balance 预设行暂不含路由指令。
|
|
77
72
|
- plan-mode 政策段保留 flash 原文(含 PTC `run_code` 句)。
|
|
78
|
-
-
|
|
73
|
+
- 2.0.0 起技能子系统(31 技能、每轮门控、审计、面板)已整体移除。
|
|
79
74
|
|
|
80
75
|
详见 [architecture.md](./architecture.md)、[configuration.md](./configuration.md)、[changelog.md](./changelog.md)。
|
|
@@ -22,7 +22,6 @@ Package `dsh-lean-router` · version `1.0.0` · repo https://github.com/ShawnSun
|
|
|
22
22
|
| Tests | `npm test` | `tests 200 / pass 199 / fail 0 / skipped 1` |
|
|
23
23
|
| Doctor | `npm run doctor` | 7 PASS |
|
|
24
24
|
| Build | `npm run build -- --check` | PASS, no rewrite |
|
|
25
|
-
| Drift | `npm run drift` | no drift |
|
|
26
25
|
| CI YAML | `python -c "import yaml; yaml.safe_load(open(r'.github/workflows/ci.yml', encoding='utf-8')); print('YAML_OK')"` | prints `YAML_OK` |
|
|
27
26
|
| Pack smoke | `npm pack` → temp dir `npm i <tgz>` → `node -e "require('dsh-lean-router')"` | installs, 3 exports |
|
|
28
27
|
|
|
@@ -71,12 +70,12 @@ Verify: `git tag -l "v1.0.0"`, `gh release view v1.0.0`.
|
|
|
71
70
|
|
|
72
71
|
```powershell
|
|
73
72
|
dsh plugin install dsh-lean-router
|
|
74
|
-
dsh --dump-config | Select-String "
|
|
73
|
+
dsh --dump-config | Select-String "lean-router-router"
|
|
75
74
|
dsh plugin uninstall dsh-lean-router
|
|
76
|
-
dsh --dump-config | Select-String "
|
|
75
|
+
dsh --dump-config | Select-String "lean-router-router" # expect no output
|
|
77
76
|
```
|
|
78
77
|
|
|
79
|
-
Pass: install exits 0; `--dump-config` shows `
|
|
78
|
+
Pass: install exits 0; `--dump-config` shows `lean-router-router`; after uninstall it disappears with no leftover files. Do not restart a running DSH app.
|
|
80
79
|
|
|
81
80
|
## Scope guard
|
|
82
81
|
|
|
@@ -19,10 +19,9 @@
|
|
|
19
19
|
|
|
20
20
|
| 检查 | 命令 | 通过判据 |
|
|
21
21
|
|---|---|---|
|
|
22
|
-
| 全仓测试 | `npm test` | `tests
|
|
23
|
-
| 体检 | `npm run doctor` |
|
|
22
|
+
| 全仓测试 | `npm test` | `tests 157 / pass 156 / fail 0 / skipped 1`(1 skip = 宿主 yaml-asar 不可读,已知限制) |
|
|
23
|
+
| 体检 | `npm run doctor` | 11 PASS |
|
|
24
24
|
| 构建一致性 | `npm run build -- --check` | PASS,无重写 |
|
|
25
|
-
| 漂移 | `npm run drift` | 无漂移 |
|
|
26
25
|
| CI YAML | `python -c "import yaml; yaml.safe_load(open(r'.github/workflows/ci.yml', encoding='utf-8')); print('YAML_OK')"` | 打印 `YAML_OK` |
|
|
27
26
|
| 打包冒烟 | `npm pack` → 临时目录 `npm i <tgz>` → `node -e "require('dsh-lean-router')"` | 安装成功且导入返回 3 个导出 |
|
|
28
27
|
|
|
@@ -104,18 +103,18 @@ dsh plugin install dsh-lean-router
|
|
|
104
103
|
# 或:npm i -g dsh-lean-router 后按 DSH 文档挂到 profile
|
|
105
104
|
|
|
106
105
|
# 5.2 装配检查(不启动对话,只看配置合成结果)
|
|
107
|
-
dsh --dump-config | Select-String "
|
|
106
|
+
dsh --dump-config | Select-String "lean-router-router|dsh-lean-router"
|
|
108
107
|
|
|
109
108
|
# 5.3 卸载
|
|
110
109
|
dsh plugin uninstall dsh-lean-router
|
|
111
110
|
|
|
112
111
|
# 5.4 卸载后确认无残留
|
|
113
|
-
dsh --dump-config | Select-String "
|
|
112
|
+
dsh --dump-config | Select-String "lean-router-router" # 期望无输出
|
|
114
113
|
```
|
|
115
114
|
|
|
116
115
|
**验证判据**:
|
|
117
116
|
1. 安装命令退出码 0;
|
|
118
|
-
2. `--dump-config` 输出里能查到本插件(plugin 名 `
|
|
117
|
+
2. `--dump-config` 输出里能查到本插件(plugin 名 `lean-router-router`);
|
|
119
118
|
3. 卸载后 `--dump-config` 不再出现该插件,且 profile 配置目录无残留文件;
|
|
120
119
|
4. 期间**不重启**正在运行的 DSH 应用、不写 `~/.dsh`(如必须,由主人手动执行)。
|
|
121
120
|
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
| 交付物 | 内容 |
|
|
30
30
|
|---|---|
|
|
31
31
|
| `lib/bands.js` | 三带配置表 `BANDS`(persona 变体文本常量 + 工具面宽窄标记 + 引导固定文本)、`classifyTask`、`parseRouterDirective`、`isComplexTask`、`diligenceReminder` |
|
|
32
|
-
| `lib/router.js` | 路由插件 `apply`:首轮捕获、指令解析、近场引导注入、勤勉自检、`/band`
|
|
32
|
+
| `lib/router.js` | 路由插件 `apply`:首轮捕获、指令解析、近场引导注入、勤勉自检、`/band` 命令;导出 `ROUTER_PROMPT` 与 `ROUTER_INJECTION_NOTES` |
|
|
33
33
|
| `presets/base/frag-router.patch.yml` | 顶层列表续项(钩子行 + 命令行),由 `scripts/build-bundle.mjs` 续接 |
|
|
34
34
|
| `test/router-bands.test.mjs` `test/router.test.mjs` | 纯函数与假 ctx 集成单测,21/21 宿主纯 node 全绿 |
|
|
35
35
|
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
- id: lean-router-router # 钩子行:捕获 + 引导 + 勤勉
|
|
89
89
|
name: dsh-lean-router/router
|
|
90
90
|
config: { hooks: true, commands: false, diligenceEvery: 10 }
|
|
91
|
-
- id: lean-router-commands # 命令行:/band
|
|
91
|
+
- id: lean-router-commands # 命令行:/band
|
|
92
92
|
name: dsh-lean-router/router
|
|
93
93
|
config: { hooks: false, commands: true }
|
|
94
94
|
```
|
package/lib/index.js
CHANGED
|
@@ -1,64 +1,12 @@
|
|
|
1
|
-
// dsh-lean-router - cordis
|
|
1
|
+
// dsh-lean-router - cordis 插件入口(包根)
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
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。
|
|
16
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
17
|
-
import { homedir } from "node:os";
|
|
18
|
-
import { join } from "node:path";
|
|
19
|
-
import { makeProvider } from "./skill-provider.js";
|
|
20
|
-
import { getAuditChannel } from "./skillgate.js";
|
|
21
|
-
|
|
22
|
-
export const name = "skill-lean-router";
|
|
3
|
+
// 2.0.0:技能子系统(31 技能、每轮门控打分、审计落盘、技能面板 UI 与客户端 bundle)已整体移除,
|
|
4
|
+
// 这里不再注册任何东西,只保留一个可被加载的合法插件形状:
|
|
5
|
+
// - inject 必须是服务名数组(cordis 的 Inject 只有数组或「服务名 → 拦截配置」映射两种形状;
|
|
6
|
+
// 写成 { required, optional } 会被当成两个服务名,宿主行永远 PENDING)。
|
|
7
|
+
// - apply 必须返回 undefined(返回普通对象会触发 cordis 的 Invalid effect)。
|
|
8
|
+
// 真正的功能挂在 lib/router.js(路由 + /band)、lib/lean/*(省 token)、lib/toolface/*(工具遮蔽)。
|
|
9
|
+
export const name = "lean-router";
|
|
23
10
|
export const inject = [];
|
|
24
11
|
|
|
25
|
-
|
|
26
|
-
function probe(line) {
|
|
27
|
-
try {
|
|
28
|
-
const dir = join(homedir(), ".dsh", "lean-router");
|
|
29
|
-
mkdirSync(dir, { recursive: true });
|
|
30
|
-
appendFileSync(join(dir, "boot.log"), new Date().toISOString() + " " + line + "\n", "utf8");
|
|
31
|
-
} catch {
|
|
32
|
-
// 自检失败绝不影响插件本身
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function apply(ctx, options) {
|
|
37
|
-
const cfg = options ?? {};
|
|
38
|
-
try {
|
|
39
|
-
probe(
|
|
40
|
-
"apply: options=" + JSON.stringify(cfg) +
|
|
41
|
-
" hasSkills=" + Boolean(ctx.skills) +
|
|
42
|
-
" slots=" + typeof ctx.slots +
|
|
43
|
-
" register=" + typeof ctx.register +
|
|
44
|
-
" inject=" + typeof ctx.inject
|
|
45
|
-
);
|
|
46
|
-
} catch {}
|
|
47
|
-
|
|
48
|
-
if (cfg.provider === false) return;
|
|
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);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
12
|
+
export function apply() {}
|
package/lib/router.js
CHANGED
|
@@ -10,11 +10,9 @@
|
|
|
10
10
|
// 每步累积,违反缓存友好约束(证据见 docs/路由-设计说明.md 接缝表)。
|
|
11
11
|
// 3. 勤勉自检:每 diligenceEvery 轮在引导文本尾部追加一段勤勉提醒(轮次号入文,
|
|
12
12
|
// 非 10 的倍数轮文本不变、零写入)。
|
|
13
|
-
// 4. 命令:/band
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// 追加进近场引导文本、决策经共享审计通道发出(接线见 lib/gate-runner.js 与
|
|
17
|
-
// docs/面板-设计说明.md §9.3 已接线);gate 默认关 = 一切不变。
|
|
13
|
+
// 4. 命令:/band 显式改档(人在回路),走 ctx.commands.register 宿主命令缝。
|
|
14
|
+
//
|
|
15
|
+
// 2.0.0:技能子系统(31 技能、每轮门控打分、审计落盘、技能面板 UI)已整体移除。
|
|
18
16
|
//
|
|
19
17
|
// 路由状态存 agent 会话作用域 WeakMap(keyed by agent),不污染全局;
|
|
20
18
|
// 禁直接改 persona —— ROUTER_PROMPT 以导出常量交付,拼接点见 ROUTER_INJECTION_NOTES。
|
|
@@ -29,11 +27,6 @@ import {
|
|
|
29
27
|
explainClassification,
|
|
30
28
|
parseRouterDirective,
|
|
31
29
|
} from "./bands.js";
|
|
32
|
-
import { defaultAuditPath, wireAuditSink } from "./audit-sink.js";
|
|
33
|
-
import { executeAuditCommand } from "./audit-commands.js";
|
|
34
|
-
import { getAuditChannel } from "./skillgate.js";
|
|
35
|
-
import { createGateRunner } from "./gate-runner.js";
|
|
36
|
-
import { executeSkillsPanelCommand } from "./skills-panel.js";
|
|
37
30
|
|
|
38
31
|
/** 三带配置表(re-export,满足单入口消费)。 */
|
|
39
32
|
export { BANDS, BAND_IDS, DIRECTIVE_BAND_IDS, classifyTask, isComplexTask, parseRouterDirective, diligenceReminder } from "./bands.js";
|
|
@@ -76,8 +69,8 @@ export const ROUTER_INJECTION_NOTES = {
|
|
|
76
69
|
/** 插件名(cordis loader 诊断用)。 */
|
|
77
70
|
export const name = "lean-router-router";
|
|
78
71
|
|
|
79
|
-
/** 依赖的宿主服务:agents(ctx.on 事件)、systemPrompt(动态 context)、commands
|
|
80
|
-
export const inject = ["agents", "systemPrompt", "commands"
|
|
72
|
+
/** 依赖的宿主服务:agents(ctx.on 事件)、systemPrompt(动态 context)、commands。 */
|
|
73
|
+
export const inject = ["agents", "systemPrompt", "commands"];
|
|
81
74
|
|
|
82
75
|
/** 从用户消息 content 里提取纯文本(防御嵌套与字符串 content)。 */
|
|
83
76
|
function messageText(message) {
|
|
@@ -149,10 +142,8 @@ function capture(states, agent, message, turn, skipInherited) {
|
|
|
149
142
|
|
|
150
143
|
/**
|
|
151
144
|
* 渲染该 agent 当前应渲染的近场引导文本(含任务回显与勤勉自检;未路由返回空串)。
|
|
152
|
-
* 票 09 加法:第 4 参 gateHint 为每轮门控的 hint 文本(lib/gate-runner.js);空串/
|
|
153
|
-
* 缺省不追加,近场文本与现状逐字符一致;非空时按行续接在勤勉自检之后。
|
|
154
145
|
*/
|
|
155
|
-
function guideTextFor(states, agent, diligenceEvery
|
|
146
|
+
function guideTextFor(states, agent, diligenceEvery) {
|
|
156
147
|
const state = stateOf(states, agent);
|
|
157
148
|
if (state === null || state.band === null) return "";
|
|
158
149
|
const band = BANDS[state.band];
|
|
@@ -162,39 +153,26 @@ function guideTextFor(states, agent, diligenceEvery, gateHint) {
|
|
|
162
153
|
if (diligenceEvery > 0 && Number.isSafeInteger(state.turn) && state.turn > 0 && state.turn % diligenceEvery === 0) {
|
|
163
154
|
text += "\n" + diligenceReminder(state.turn);
|
|
164
155
|
}
|
|
165
|
-
if (typeof gateHint === "string" && gateHint.length > 0) text += "\n" + gateHint;
|
|
166
156
|
return text;
|
|
167
157
|
}
|
|
168
158
|
|
|
169
159
|
/** 校验插件 options(未知键报错;仿宿主 plan-mode resolveConfig 的失败尽早原则)。 */
|
|
170
160
|
function resolveOptions(options) {
|
|
171
161
|
const cfg = options ?? {};
|
|
162
|
+
// 2.0.0:audit / auditPath / weightsPath / gate 只为兼容旧 patch 配置而保留在允许键里,
|
|
163
|
+
// 行为已整体移除(技能门控子系统下线);旧配置不再让插件启动失败。
|
|
172
164
|
const unknown = Object.keys(cfg).filter(
|
|
173
165
|
(key) => !["diligenceEvery", "hooks", "commands", "guideOrder", "skipInherited", "audit", "auditPath", "weightsPath", "gate"].includes(key)
|
|
174
166
|
);
|
|
175
167
|
if (unknown.length > 0) throw new Error("lean-router-router has unknown option(s): " + unknown.join(", "));
|
|
176
168
|
const diligenceEvery = cfg.diligenceEvery ?? DEFAULT_DILIGENCE_EVERY;
|
|
177
169
|
if (!Number.isSafeInteger(diligenceEvery) || diligenceEvery < 0) throw new Error("lean-router-router: diligenceEvery must be a non-negative safe integer");
|
|
178
|
-
if (cfg.auditPath !== undefined && (typeof cfg.auditPath !== "string" || cfg.auditPath.length === 0)) {
|
|
179
|
-
throw new Error("lean-router-router: auditPath must be a non-empty string");
|
|
180
|
-
}
|
|
181
|
-
if (cfg.weightsPath !== undefined && (typeof cfg.weightsPath !== "string" || cfg.weightsPath.length === 0)) {
|
|
182
|
-
throw new Error("lean-router-router: weightsPath must be a non-empty string");
|
|
183
|
-
}
|
|
184
170
|
return {
|
|
185
171
|
diligenceEvery,
|
|
186
172
|
hooks: cfg.hooks !== false,
|
|
187
173
|
commands: cfg.commands !== false,
|
|
188
174
|
guideOrder: cfg.guideOrder ?? 220,
|
|
189
175
|
skipInherited: cfg.skipInherited !== false,
|
|
190
|
-
// 票 07:审计落盘默认关(master 集成在 patch 行加 audit: true + 可选 auditPath;
|
|
191
|
-
// 关闭 = 零行为变化,既有断言不受影响)。weightsPath 仅作 /lean-audit weights 展示。
|
|
192
|
-
audit: cfg.audit === true,
|
|
193
|
-
auditPath: cfg.auditPath ?? null,
|
|
194
|
-
weightsPath: cfg.weightsPath ?? null,
|
|
195
|
-
// 票 09:每轮门控默认关(master 集成在 patch 钩子行加 gate: true);关闭 = 近场
|
|
196
|
-
// 文本与现状逐字符一致、round() 不执行、不发审计(约束台账 3 零副作用锚点)。
|
|
197
|
-
gate: cfg.gate === true,
|
|
198
176
|
};
|
|
199
177
|
}
|
|
200
178
|
|
|
@@ -263,103 +241,26 @@ function executeBandCommand(states, invocation) {
|
|
|
263
241
|
};
|
|
264
242
|
}
|
|
265
243
|
|
|
266
|
-
/**
|
|
267
|
-
* 票 07 加法接线:audit:true 时把 sink 挂上 skillgate 共享审计通道
|
|
268
|
-
* (决策流 -> JSONL;默认路径 <homedir>/.dsh/lean-router/audit.jsonl)。
|
|
269
|
-
* 返回 { channel, sink, unsubscribe };测试可直调(传 auditPath 覆盖到临时目录)。
|
|
270
|
-
* 幂等护栏:patch 两行实例若都开 audit,同一解析路径只挂一次 sink
|
|
271
|
-
* (重复订阅会把每条决策双写进同一 JSONL,统计翻倍);unsubscribe 会清掉注册。
|
|
272
|
-
*/
|
|
273
|
-
const wiredAuditPaths = new Map();
|
|
274
|
-
|
|
275
|
-
function setupAudit(options) {
|
|
276
|
-
const key = options?.auditPath ?? "__default__";
|
|
277
|
-
const existing = wiredAuditPaths.get(key);
|
|
278
|
-
if (existing) return existing;
|
|
279
|
-
const channel = getAuditChannel();
|
|
280
|
-
const auditPath = options?.auditPath ?? null;
|
|
281
|
-
const handle = wireAuditSink(channel, auditPath ? { path: auditPath } : undefined);
|
|
282
|
-
const wired = {
|
|
283
|
-
channel,
|
|
284
|
-
sink: handle.sink,
|
|
285
|
-
unsubscribe: () => {
|
|
286
|
-
handle.unsubscribe();
|
|
287
|
-
wiredAuditPaths.delete(key);
|
|
288
|
-
},
|
|
289
|
-
};
|
|
290
|
-
wiredAuditPaths.set(key, wired);
|
|
291
|
-
return wired;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/** /skill 命令 handler 的共享实现(skills 服务注入;测试可直调假 skills)。 */
|
|
295
|
-
async function executeSkillCommand(ctx, invocation) {
|
|
296
|
-
const agent = invocation?.agent;
|
|
297
|
-
if (!agent) return { kind: "error", text: "/skill has no active agent to list skills for." };
|
|
298
|
-
const raw = (invocation.rawInput ?? "").trim();
|
|
299
|
-
const options = { scope: agent, signal: invocation.signal };
|
|
300
|
-
try {
|
|
301
|
-
if (raw.length === 0) {
|
|
302
|
-
const skills = await ctx.skills.list(options);
|
|
303
|
-
const lines = skills.map((s) => {
|
|
304
|
-
const flags = [s.invocation?.modelInvocable ? "model" : null, s.invocation?.userInvocable ? "user" : null].filter(Boolean).join("+") || "off";
|
|
305
|
-
return s.name + " [" + flags + "] - " + (s.description ?? "");
|
|
306
|
-
});
|
|
307
|
-
return { kind: "success", text: (lines.length === 0 ? "No skills registered." : lines.join("\n")) + "\nUsage: /skill <name>" };
|
|
308
|
-
}
|
|
309
|
-
const skill = await ctx.skills.get(raw, options);
|
|
310
|
-
if (skill === undefined) return { kind: "error", text: "Unknown skill: " + raw };
|
|
311
|
-
const flags = [skill.invocation?.modelInvocable ? "model" : null, skill.invocation?.userInvocable ? "user" : null].filter(Boolean).join("+") || "off";
|
|
312
|
-
return {
|
|
313
|
-
kind: "success",
|
|
314
|
-
text:
|
|
315
|
-
skill.name + " [" + flags + "]\n" +
|
|
316
|
-
(skill.description ?? "") + "\n" +
|
|
317
|
-
"provider: " + (skill.provider ?? "-") + " source: " + (skill.source ?? "-") +
|
|
318
|
-
(skill.resourceBase?.kind === "directory" ? "\nbase: " + skill.resourceBase.path : ""),
|
|
319
|
-
};
|
|
320
|
-
} catch (error) {
|
|
321
|
-
return { kind: "error", text: "Skill lookup failed: " + (error instanceof Error ? error.message : String(error)) };
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
244
|
/**
|
|
326
245
|
* 路由层插件入口(cordis)。
|
|
327
246
|
* options 分流(patch 两实例复用同一入口模块):
|
|
328
247
|
* - hooks: 首轮捕获 + 近场引导 + 勤勉自检(默认 true)
|
|
329
|
-
* - commands: /band
|
|
248
|
+
* - commands: /band 注册(默认 true)
|
|
330
249
|
* - diligenceEvery: 勤勉自检轮距,0 关闭(默认 10)
|
|
331
250
|
* - guideOrder: 引导 context 排位(默认 220,避开宿主 CONTEXT_ORDERS 100-210)
|
|
332
251
|
* - skipInherited: 子代理/fork 继承会话跳过路由(默认 true)
|
|
333
|
-
*
|
|
334
|
-
*
|
|
252
|
+
*
|
|
253
|
+
* 2.0.0:gate / audit / auditPath / weightsPath 已无行为(技能子系统下线),
|
|
254
|
+
* 仅为兼容旧 patch 配置继续接受这些键而不报错。
|
|
335
255
|
*/
|
|
336
256
|
export function apply(ctx, options) {
|
|
337
257
|
const cfg = resolveOptions(options);
|
|
338
258
|
/** agent 会话作用域路由状态(不污染全局)。 */
|
|
339
259
|
const states = new WeakMap();
|
|
340
260
|
|
|
341
|
-
// 票 09 加法接线:gate:true 时 pre-step 每轮门控(设计说明 §9.3)——claimed 捕获
|
|
342
|
-
// 当轮用户消息并异步热读权重/观察 dsActive,近场 text 同步 round() 出 hint 追加进
|
|
343
|
-
// 引导文本,决策经共享审计通道发出(commands 行实例 audit:true 已挂 sink 落盘)。
|
|
344
|
-
// gate 默认关:runner 不创建,text 与现状逐字符一致(约束台账 3)。
|
|
345
|
-
const gateRunner =
|
|
346
|
-
cfg.hooks && cfg.gate
|
|
347
|
-
? createGateRunner({ weightsPath: cfg.weightsPath ?? undefined, skills: ctx.skills ?? null })
|
|
348
|
-
: null;
|
|
349
|
-
|
|
350
261
|
if (cfg.hooks) {
|
|
351
|
-
ctx.on("agent/inbox/claimed",
|
|
262
|
+
ctx.on("agent/inbox/claimed", ({ agent, message, turn }) => {
|
|
352
263
|
capture(states, agent, message, turn, cfg.skipInherited);
|
|
353
|
-
if (
|
|
354
|
-
gateRunner !== null &&
|
|
355
|
-
message &&
|
|
356
|
-
message.source?.kind === "user" &&
|
|
357
|
-
!(cfg.skipInherited && isInherited(agent))
|
|
358
|
-
) {
|
|
359
|
-
try {
|
|
360
|
-
await gateRunner.capture(agent, messageText(message), turn);
|
|
361
|
-
} catch {} // 门控永不破坏路由管线(与审计错误策略同原则)
|
|
362
|
-
}
|
|
363
264
|
});
|
|
364
265
|
ctx.systemPrompt.context({
|
|
365
266
|
name: GUIDE_CONTEXT_NAME,
|
|
@@ -367,17 +268,11 @@ export function apply(ctx, options) {
|
|
|
367
268
|
text: (assembly) => {
|
|
368
269
|
const agent = assembly?.agent;
|
|
369
270
|
if (agent === undefined || (cfg.skipInherited && isInherited(agent))) return "";
|
|
370
|
-
|
|
371
|
-
return guideTextFor(states, agent, cfg.diligenceEvery, hint);
|
|
271
|
+
return guideTextFor(states, agent, cfg.diligenceEvery);
|
|
372
272
|
},
|
|
373
273
|
});
|
|
374
274
|
}
|
|
375
275
|
|
|
376
|
-
// 票 07 加法接线:审计落盘(audit:true 才挂 sink;决策流 = skillgate 共享通道)。
|
|
377
|
-
if (cfg.audit) {
|
|
378
|
-
setupAudit({ auditPath: cfg.auditPath });
|
|
379
|
-
}
|
|
380
|
-
|
|
381
276
|
if (cfg.commands) {
|
|
382
277
|
ctx.commands.register({
|
|
383
278
|
name: "band",
|
|
@@ -385,36 +280,8 @@ export function apply(ctx, options) {
|
|
|
385
280
|
input: { hint: "[spec|react|weak|auto] [task <one line>]" },
|
|
386
281
|
handler: (invocation) => executeBandCommand(states, invocation),
|
|
387
282
|
});
|
|
388
|
-
ctx.commands.register({
|
|
389
|
-
name: "skill",
|
|
390
|
-
description: "List available skills or show one skill's invocation policy",
|
|
391
|
-
input: { hint: "[name]" },
|
|
392
|
-
handler: (invocation) => executeSkillCommand(ctx, invocation),
|
|
393
|
-
});
|
|
394
|
-
// 票 07 加法接线:/lean-audit 双入口之一(命令;实现放 lib/audit-commands.js,
|
|
395
|
-
// 数据源 = 审计 JSONL 回放,不新增内存态)。ui/go.json 面板按钮是另一入口。
|
|
396
|
-
// 1.0.5:技能面板的命令输出形态(客户端插件未修好前的可用形态)。
|
|
397
|
-
ctx.commands.register({
|
|
398
|
-
name: "panel",
|
|
399
|
-
description: "Skill panel: 31 skills with switches, current round hit scores and history stats",
|
|
400
|
-
input: { hint: "[summary|skills|round|stats|never] [all]" },
|
|
401
|
-
handler: (invocation) =>
|
|
402
|
-
executeSkillsPanelCommand(invocation, {
|
|
403
|
-
auditPath: cfg.auditPath ?? defaultAuditPath(),
|
|
404
|
-
}),
|
|
405
|
-
});
|
|
406
|
-
ctx.commands.register({
|
|
407
|
-
name: "lean-audit",
|
|
408
|
-
description: "Show recent skill-gate audit decisions, hit statistics and manual weights",
|
|
409
|
-
input: { hint: "[scores|stats|weights] [N]" },
|
|
410
|
-
handler: (invocation) =>
|
|
411
|
-
executeAuditCommand(invocation, {
|
|
412
|
-
auditPath: cfg.auditPath ?? defaultAuditPath(),
|
|
413
|
-
weightsPath: cfg.weightsPath,
|
|
414
|
-
}),
|
|
415
|
-
});
|
|
416
283
|
}
|
|
417
284
|
}
|
|
418
285
|
|
|
419
286
|
/** 测试与集成内用的内部实现出口(不进公开契约文档)。 */
|
|
420
|
-
export const internals = { capture, guideTextFor, executeBandCommand,
|
|
287
|
+
export const internals = { capture, guideTextFor, executeBandCommand, messageText, resolveOptions };
|