dsh-cohub 0.8.1 → 0.8.2
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.md +222 -233
- package/lib/index.js +59 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,57 +1,17 @@
|
|
|
1
1
|
# dsh-cohub
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
把「纯调度模式 + 13 个 co-* 技能(12 专职代理 + `co-cordis` 创造模式)+ 多模型共识 + 运行期调度韧性」移植到 DSH 原生能力之上。
|
|
3
|
+
> 本文对应 **v0.8.2**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
DeepSeek Harness 版(对照 [OpenCode 版](../oh-my-opencode-cohub/)):中文智能体编排插件。
|
|
6
|
+
把「纯调度模式 + 13 个技能(12 个代理编排体系 + co-cordis 组合创作)+ 多模型共识 + 运行期调度韧性」移植到 DSH 原生能力之上。
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|---|---|
|
|
10
|
-
| 12 个 agent 注册(双重注册 + config hook) | 13 个 runtime skills(本插件 apply 时注册) |
|
|
11
|
-
| 中文注入 experimental.chat.system.transform | ctx.systemPrompt.section |
|
|
12
|
-
| task 工具 + 并行派发 | DSH 原生 subagent 工具(后台/续聊) |
|
|
13
|
-
| todowrite | DSH 原生 todo_write |
|
|
14
|
-
| Background Job Board(消息注入) | DSH 原生 job board(删除) |
|
|
15
|
-
| ContextEngine 上下文提取 | subagent_fork 继承会话(删除) |
|
|
16
|
-
| council_session 工具 | M4:workflow 并行 + provider/model 覆盖 |
|
|
17
|
-
| TUI 面板 | DSH Web GUI 原生面板(删除) |
|
|
18
|
-
| CLI 安装器 | dsh plugin add(转发 pnpm) |
|
|
19
|
-
| **M2/M3/M4 调度韧性**(N2 停滞检测 / N3 调度参数) | **P3-1/P3-3 切片**(stall 检测器 + schedule 配置 + systemPrompt 段) |
|
|
20
|
-
| **环境契约一次学习持续使用**(N1) | **P3-2 切片**(envSignatures 模块 + 缓存到 `~/.dsh/cohub/env-signatures.json`) |
|
|
21
|
-
|
|
22
|
-
> 注:`dsh plugin add` 不是 CLI 独立子命令,而是把参数转发给 profile 目录内的 `pnpm`(`dsh plugin --profile <name> add <pkg>` ≡ 在该 profile 执行 `pnpm add <pkg>`),安装后自动把声明 `dsh.bundle` 的依赖加入 `dsh.profile.bundles`。
|
|
23
|
-
|
|
24
|
-
## 技能清单(13 个)
|
|
25
|
-
|
|
26
|
-
co-orchestrator(调度)/ co-planner(方案)/ co-oracle(审查)/
|
|
27
|
-
co-explorer(搜索)/ co-librarian(研究)/ co-observer(视觉)/
|
|
28
|
-
co-fixer(执行)/ co-designer(UI)/ co-council(共识)/
|
|
29
|
-
co-rule-user / co-rule-project / co-rule-app(规范分析)/
|
|
30
|
-
co-cordis(Cordis 插件与 preset 组合创造 —— 第 13 个,需读写+Bash 权限)
|
|
31
|
-
|
|
32
|
-
> 前 12 个是「专职代理」,`co-cordis` 是 v0.4.7 起新增的创造模式角色(修插件 / 改 harness 组合 / 写 preset)。
|
|
33
|
-
> `test/unit.ts` 断言的正是这 13 个名字,改动技能清单需同步 `scripts/generate-skills.ts` 与测试。
|
|
8
|
+
## 快速开始
|
|
34
9
|
|
|
35
|
-
|
|
10
|
+
### 1. 前置条件
|
|
36
11
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
cd dsh-cohub
|
|
41
|
-
npm run build
|
|
42
|
-
# 等价于:
|
|
43
|
-
# bun run scripts/generate-skills.ts # ① 生成 src/skills.ts(.md → 技能定义,必须先跑)
|
|
44
|
-
# bun run scripts/guard-schema.ts # ② 校验 Config / ScheduleConfig schema 与 cordis.patch.yml 一致
|
|
45
|
-
# bun build src/index.ts --outdir lib --target node --format esm \
|
|
46
|
-
# --external @deepseek-ai/cordis --external @deepseek-ai/schemastery \
|
|
47
|
-
# --external @deepseek-ai/dsh-tools --external @deepseek-ai/dsh-system-prompt \
|
|
48
|
-
# --external @deepseek-ai/dsh-skill --external @deepseek-ai/dsh-home-paths
|
|
49
|
-
# bun build src/co-cordis-plugin.ts --outdir lib --target node --format esm \
|
|
50
|
-
# --external @deepseek-ai/dsh-tools # co-cordis 专用插件(第 13 个技能)
|
|
51
|
-
# bun run scripts/build-client.js # src/client/index.js → lib/client.js
|
|
52
|
-
```
|
|
12
|
+
宿主 DSH ≥ `0.2.0-rc.2`(peer 依赖锁定);其中子代理读写硬隔离(per-child `agentPreset`)需 ≥ `0.2.1`。不支持 DSH 0.1。
|
|
53
13
|
|
|
54
|
-
|
|
14
|
+
### 2. 安装
|
|
55
15
|
|
|
56
16
|
```bash
|
|
57
17
|
dsh plugin --profile web add dsh-cohub
|
|
@@ -65,6 +25,8 @@ dsh plugin --profile web add <monorepo>/packages/dsh-cohub
|
|
|
65
25
|
|
|
66
26
|
或手动:profile 的 package.json
|
|
67
27
|
|
|
28
|
+
以下为**本地开发/离线**安装方式,日常使用请用上面的 npm 安装:
|
|
29
|
+
|
|
68
30
|
```json
|
|
69
31
|
{
|
|
70
32
|
"dependencies": { "dsh-cohub": "file:../dsh-cohub" },
|
|
@@ -72,6 +34,130 @@ dsh plugin --profile web add <monorepo>/packages/dsh-cohub
|
|
|
72
34
|
}
|
|
73
35
|
```
|
|
74
36
|
|
|
37
|
+
### 3. 选择工作模式
|
|
38
|
+
|
|
39
|
+
- **`co-orchestrator`**:纯调度,自己不动手,只委派子代理——适合长链调度、多模型共识。
|
|
40
|
+
- **`cohub-cordis`**:标准模式全工具面 + 中文身份 + 组合创作技能——适合直接动手、插件开发。
|
|
41
|
+
- preset 在会话首个 turn 后即锁定,切换需新建会话。
|
|
42
|
+
|
|
43
|
+
完整说明见下文「工作模式与 preset」。
|
|
44
|
+
|
|
45
|
+
### 4. 验证安装
|
|
46
|
+
|
|
47
|
+
重启 DSH 后确认三点:
|
|
48
|
+
|
|
49
|
+
1. 技能列表中能看到 13 个 `co-*` / cohub 相关技能;
|
|
50
|
+
2. 设置页出现「CoHub 代理模型」区块;
|
|
51
|
+
3. preset 选择器里能看到 `co-orchestrator` 与 `cohub-cordis`;若看不到,说明 preset 未安装,见下文「工作模式与 preset」的手动兜底步骤。
|
|
52
|
+
|
|
53
|
+
### 5. 首次调用
|
|
54
|
+
|
|
55
|
+
先新建一个会话并在 preset 选择器里选中 `co-orchestrator`(preset 在会话首个 turn 后即锁定,中途无法切换):
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
用 co-orchestrator 帮我审查 packages/dsh-cohub 的 README 结构
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
预期产出:主调度先派探索子代理(co-explorer)定位结构与引用,再把结果汇总成审查结论,全程不直接读写文件。
|
|
62
|
+
|
|
63
|
+
## 工作模式与 preset
|
|
64
|
+
|
|
65
|
+
### co-orchestrator(纯调度)
|
|
66
|
+
|
|
67
|
+
`presets/co-orchestrator/` 提供调度者主代理身份(persona + 调度工具面:subagent/fork/workflow/skill/todo/jobs/ask-user/goal + compaction)。
|
|
68
|
+
|
|
69
|
+
**自动安装**:本包在 `apply` 时会把内置 preset 复制到 `~/.dsh/.agent-presets/co-orchestrator/`(幂等,不覆盖你已修改的同名 preset)。`dsh plugin --profile web add dsh-cohub` 装完重启后,即可在 GUI 的 agent preset 选择器中切换,无需手动操作。
|
|
70
|
+
|
|
71
|
+
若 preset 未出现(例如本地源码开发、或想手动摆放),可兜底执行:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
mkdir -p ~/.dsh/.agent-presets/co-orchestrator
|
|
75
|
+
cp presets/co-orchestrator/* ~/.dsh/.agent-presets/co-orchestrator/
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> ⚠️ 上面的 `cp presets/<name>/*` **不会带上子目录**。带 `skills/` 的 preset(如 `cohub-cordis`)必须整目录复制,否则技能丢失;Windows 上推荐直接用随仓库提供的脚本(递归复制 + 防 `Copy-Item` 同名嵌套陷阱):
|
|
79
|
+
>
|
|
80
|
+
> ```powershell
|
|
81
|
+
> pwsh -File scripts/deploy-preset.ps1 # 默认 cohub-cordis
|
|
82
|
+
> pwsh -File scripts/deploy-preset.ps1 -PresetName co-orchestrator
|
|
83
|
+
> ```
|
|
84
|
+
|
|
85
|
+
在 GUI 的 agent preset 选择器中切换。注意:**DSH 0.2.1 起支持 per-child `agentPreset`**(`SubagentStartRequest.agentPreset` 为一等字段,子代理经 `presets.mount()` 独立组装),子代理不再继承父代理的 preset 组合与工具表——cohub 已用两个独立精简 preset(`cohub-subagent-readonly` / `cohub-subagent-write`)对子代理做**硬隔离**,故「绝不亲自操作文件」「只读代理不写文件」由工具面物理保证,不再只靠提示词。`toolFilter` 仍保留作为补充收窄手段(但它对子代理 own 层挂载的工具无效)。主代理侧「绝不亲自操作文件」继续由 co-orchestrator 技能在提示词层约束(与 OpenCode 原版一致)。
|
|
86
|
+
|
|
87
|
+
完整变更历史(含 v0.3.0–v0.8.1 全部条目)见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
88
|
+
|
|
89
|
+
> 迁移提示:若你曾手动改造过 ~/.dsh/.agent-presets/cohub-standard/,需自行删除该目录。
|
|
90
|
+
|
|
91
|
+
### cohub-cordis(创造模式)
|
|
92
|
+
|
|
93
|
+
`presets/cohub-cordis/` 是 **DSH 官方「创造模式」(`cordis` preset)的骨架 + cohub 中文身份与委派指引**:标准模式的全部工具面、`present` 产物交付、组合创作技能,加上直接可用的 cohub `delegate` / `delegate_batch`。
|
|
94
|
+
|
|
95
|
+
**⚠️ 本 preset 不含运行时自改能力(`cordis_*` 工具由官方「创造模式」提供);需要读写 harness 组合请直接用官方创造模式。**
|
|
96
|
+
|
|
97
|
+
**两者定位**:
|
|
98
|
+
|
|
99
|
+
| preset | 工具模式 | 委派 | 运行时自改 | 适用场景 |
|
|
100
|
+
|---|---|---|---|---|
|
|
101
|
+
| co-orchestrator | 纯调度(不挂 fs/shell/web + persona 软约束) | ✅ delegate | ✗ | 长链调度 / 多模型共识 / 严格自律 |
|
|
102
|
+
| **cohub-cordis** | **标准模式 + 中文身份 + 组合创作技能** | ✅ delegate | ✗(用官方创造模式) | 直接动手 + 委派混合、插件开发日常 |
|
|
103
|
+
| 官方 **创造模式**(`cordis`) | 标准 + **Cordis 自指工具面** | ✅ delegate(host plane,同样可用) | ✅ | 自改 harness / preset 创作 / 插件实验 |
|
|
104
|
+
|
|
105
|
+
**cohub 能力从哪来**:13 个 co-* 技能与 `delegate` / `delegate_batch` 工具由 dsh-cohub bundle 在 **host plane 全局注册**,与 preset 解耦——所以本 preset 不需要(也没有)额外的委派工具行。已实测确认:`delegate` 与 `delegate_batch` 都出现在会话工具表中,任何 preset 的会话(含创造模式)都能直接用,只要 dsh-cohub 挂在该 profile 上。
|
|
106
|
+
|
|
107
|
+
**使用方式**:agent preset 在会话**首次 turn 之后即锁定**(`agent-preset/locked: session has already started; its agent preset is fixed`),所以创造模式只能**新建会话**时选择,不能中途切换。
|
|
108
|
+
|
|
109
|
+
**自包含技能**:本 preset 自带 `skills/`(`cordis-plugin-development`、`editing-cordis-compositions` 两份组合创作指导),通过 `customSkillDirs` 指向 preset 自身目录,因此无论安装到哪里都能解析。
|
|
110
|
+
|
|
111
|
+
> **TRUST**:`cordis_mount` 会对模型写出的 JavaScript 求值并在活动运行时里执行,且本 agent 写出的组合会成为其他会话可挂载的 preset。请把使用本 preset 的会话**等同于 shell 访问权限**对待。
|
|
112
|
+
|
|
113
|
+
### 子代理 preset(读写硬隔离)
|
|
114
|
+
|
|
115
|
+
`cohub-subagent-readonly` 与 `cohub-subagent-write` 是 0.8.0 起新增的支撑性 preset,服务于委派机制本身,用户不需要也无需手动选择。
|
|
116
|
+
DSH 0.2.1 起 `SubagentStartRequest.agentPreset` 是一等字段,`delegate` / `delegate_batch` 会按目标技能的读写需求自动挂载对应 preset。
|
|
117
|
+
只读类代理(co-explorer / co-oracle / co-librarian / co-observer / co-rule-* 等)的工具面**不含 write / shell**;只有写类代理(co-fixer / co-designer / co-cordis)才具备文件写入与 build / test 能力。
|
|
118
|
+
因此「只读代理不写文件」由工具面物理保证,不再只靠提示词层软约束;`toolFilter` 仅作为补充收窄手段保留。
|
|
119
|
+
手动 `subagent` 委派时也可显式指定这两个 preset 之一,但常规链路无需关心。
|
|
120
|
+
|
|
121
|
+
## 技能清单(13 个)
|
|
122
|
+
|
|
123
|
+
co-orchestrator(调度)/ co-planner(方案)/ co-oracle(审查)/
|
|
124
|
+
co-explorer(搜索)/ co-librarian(研究)/ co-observer(视觉)/
|
|
125
|
+
co-fixer(执行)/ co-designer(UI)/ co-council(共识)/
|
|
126
|
+
co-rule-user / co-rule-project / co-rule-app(规范分析)/
|
|
127
|
+
co-cordis(Cordis 插件与 preset 组合创造 —— 第 13 个,需读写+Bash 权限)
|
|
128
|
+
|
|
129
|
+
> 前 12 个即代理编排体系,`co-cordis` 是组合创作角色(修插件 / 改 harness 组合 / 写 preset)。
|
|
130
|
+
> `test/unit.ts` 断言的正是这 13 个名字,改动技能清单需同步 `scripts/generate-skills.ts` 与测试。
|
|
131
|
+
|
|
132
|
+
## 使用
|
|
133
|
+
|
|
134
|
+
1. 主会话中让模型加载 co-orchestrator 技能(skill 工具)
|
|
135
|
+
2. 按提示词流程:信息收集(并行 subagent)→ co-planner 方案 → 审核 → 执行 → 验证
|
|
136
|
+
3. 子代理统一通过 DSH 原生 subagent 工具委派,后台任务走 job board
|
|
137
|
+
|
|
138
|
+
### settings 卡片
|
|
139
|
+
|
|
140
|
+
**DSH 0.2 起**:本插件**注册独立的设置页**「CoHub 代理模型」——客户端模块
|
|
141
|
+
(`src/client/index.js`)向 `settings.section` slot 注册一个 section(`order: 12`,插在
|
|
142
|
+
「模型」10 与「插件」15 之间),13 个代理每个一行:供应商下拉 + 模型下拉(可降级手填)。
|
|
143
|
+
页面通过 `configForms` 读写 Config 的 volatile `skills` 字段(走 `mutate` 提交,携带读取时的
|
|
144
|
+
revision 做冲突栅栏),因此改完保存即生效,无需重启。
|
|
145
|
+
|
|
146
|
+
`reasoningEffort` 仍通过官方表单(`SettingsForms.describe()` 从真实 Loader entry 的
|
|
147
|
+
`fiber.runtime.Config` 投影)配置,在官方表单里是文本字段(档位随模型变化,静态枚举无法表达),
|
|
148
|
+
留空 = 不覆盖;可填档位见上文
|
|
149
|
+
[按代理配置推理强度](#按代理配置推理强度reasoningeffort)。
|
|
150
|
+
|
|
151
|
+
`npm run test:client`(`test/client-runtime-0.2.ts`,84 条断言)覆盖该页的渲染契约与写回契约:
|
|
152
|
+
`value=""` 继承占位项、目录加载中/失败降级手填、已存值不可用时 disabled 回显、只读连接、
|
|
153
|
+
revision 冲突拒绝保存、只写显式配置的代理等。
|
|
154
|
+
|
|
155
|
+
官方表单提交后无需重启即生效:Config 的 `skills` / `schedule` / `delegateRetry` 是 `.volatile()` 字段,
|
|
156
|
+
官方设置页按**活动 profile entry id** 投影这些字段,改动经 `entry.update({config})` 写入 profile patch 后,
|
|
157
|
+
由 Loader 以 `loader/volatile-update` 提交到运行中的同一 Volatile 引用(无需重挂载);
|
|
158
|
+
插件每次 delegate 工具 execute 时 `get()` 当前快照,因此下一次工具调用即见更新,正在执行的一次使用起始快照。
|
|
159
|
+
`test/host-integration.ts` 用真实 Loader + `SettingsForms.describe()` 验证了这条链路(含提交后 describe 的 value 与 `config.get()` 一致)。
|
|
160
|
+
|
|
75
161
|
## 配置(profile 的 cordis.patch.yml,按行 id "cohub" 覆盖)
|
|
76
162
|
|
|
77
163
|
最小配置(不开 council):
|
|
@@ -86,7 +172,7 @@ dsh plugin --profile web add <monorepo>/packages/dsh-cohub
|
|
|
86
172
|
# 每条路由可配 provider/model/maxTokens/reasoningEffort,见下节「skills 字段」
|
|
87
173
|
```
|
|
88
174
|
|
|
89
|
-
|
|
175
|
+
**启用 council**(councillors 非空时自动注册 council_session 工具):
|
|
90
176
|
|
|
91
177
|
```yaml
|
|
92
178
|
- id: cohub
|
|
@@ -98,7 +184,7 @@ dsh plugin --profile web add <monorepo>/packages/dsh-cohub
|
|
|
98
184
|
- { name: expert3, provider: deepseek-official, model: deepseek-v4-pro, prompt: 你是首席架构师,先列风险再给结论 }
|
|
99
185
|
```
|
|
100
186
|
|
|
101
|
-
|
|
187
|
+
**完整配置**(cordis.patch.yml 第 18 行起所有注释块都是可选 profile 覆盖):
|
|
102
188
|
|
|
103
189
|
```yaml
|
|
104
190
|
- id: cohub
|
|
@@ -107,7 +193,7 @@ dsh plugin --profile web add <monorepo>/packages/dsh-cohub
|
|
|
107
193
|
# delegateEnvContract:环境契约注入(默认开)。部署已知环境可覆盖 text 跳过探测:
|
|
108
194
|
delegateEnvContract: { enabled: true }
|
|
109
195
|
# delegateRetry:中止/失败自动重试。默认不重试(保持现状)。
|
|
110
|
-
#
|
|
196
|
+
# 停滞检测:默认关闭(enabled=false),启用后在 spawn 子代理时挂 StallWatchdog,
|
|
111
197
|
# 按 session/event 在线估计 S1-S4 信号并提前中止(复用 delegateRetry 重试预算)。
|
|
112
198
|
delegateRetry:
|
|
113
199
|
maxRetries: 2
|
|
@@ -121,13 +207,13 @@ dsh plugin --profile web add <monorepo>/packages/dsh-cohub
|
|
|
121
207
|
loopCount: 3 # S4 同工具名 + 同参数重复次数
|
|
122
208
|
graceMs: 30000 # 宽限窗口
|
|
123
209
|
recoverable: true # 触发后按 retryableReasons 判定
|
|
124
|
-
#
|
|
210
|
+
# 环境契约持久化:默认 auto(无缓存时行为不变)。
|
|
125
211
|
# 累计同一归一化签名达 confirmCount 次后写入 dshHomePath("cohub","env-signatures.json")。
|
|
126
212
|
envSignatures:
|
|
127
213
|
use: auto # auto / off / manual
|
|
128
214
|
ttlMs: 604800000 # 7 天
|
|
129
215
|
confirmCount: 2
|
|
130
|
-
#
|
|
216
|
+
# 调度参数:通过 systemPrompt.section 注入实际生效值(cohub:schedule),子代理可见。
|
|
131
217
|
# ⚠️ useJobTracking 与 adaptiveBatch 已于 2026-09-03 移除(声明了但代码不读的死参数),不要再配。
|
|
132
218
|
schedule:
|
|
133
219
|
maxParallelBatch: 3
|
|
@@ -136,7 +222,7 @@ dsh plugin --profile web add <monorepo>/packages/dsh-cohub
|
|
|
136
222
|
|
|
137
223
|
完整字段含义与缺省见 [`cordis.patch.yml`](cordis.patch.yml) 顶部注释块。
|
|
138
224
|
|
|
139
|
-
###
|
|
225
|
+
### 按代理配置推理强度(reasoningEffort)
|
|
140
226
|
|
|
141
227
|
每条 skill 路由可写的字段:`name`(必填)、`provider`、`model`、`maxTokens`、`reasoningEffort`。
|
|
142
228
|
|
|
@@ -168,53 +254,34 @@ skills:
|
|
|
168
254
|
- 空串与纯空白视为「未配置」(官方设置页清空文本字段会写回 `""`)。
|
|
169
255
|
- 本字段可选、无默认值:不配置时解析结果不含该键,官方表单也不会把默认档写回每条路由。
|
|
170
256
|
|
|
171
|
-
##
|
|
172
|
-
|
|
173
|
-
1. 主会话中让模型加载 co-orchestrator 技能(skill 工具)
|
|
174
|
-
2. 按提示词流程:信息收集(并行 subagent)→ co-planner 方案 → 审核 → 执行 → 验证
|
|
175
|
-
3. 子代理统一通过 DSH 原生 subagent 工具委派,后台任务走 job board
|
|
257
|
+
## 升级与卸载
|
|
176
258
|
|
|
177
|
-
###
|
|
259
|
+
### 升级
|
|
178
260
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
「模型」10 与「插件」15 之间),13 个代理每个一行:供应商下拉 + 模型下拉(可降级手填)。
|
|
182
|
-
页面通过 `configForms` 读写 Config 的 volatile `skills` 字段(走 `mutate` 提交,携带读取时的
|
|
183
|
-
revision 做冲突栅栏),因此改完保存即生效,无需重启。
|
|
261
|
+
- 通过插件市场/安装命令升级:`dsh plugin add dsh-cohub@latest`;离线环境按 profile 的 `package.json` 改版本号后重装。
|
|
262
|
+
- 升级后重启 DSH。preset 内容有变化时,**老会话不会自动生效**——preset 在会话首个 turn 后锁定,需新建会话。
|
|
184
263
|
|
|
185
|
-
|
|
186
|
-
> 该理由**不成立**——官方 0.2 的 settings 导航与页面全部由客户端插件注册
|
|
187
|
-
> (general / models / plugins / agent-presets / account 都是这么做的),官方 README 亦明说
|
|
188
|
-
> 「目前没有已发布的客户端会那样渲染 volatile 字段」。另:`settingsScope` → `configForms`、
|
|
189
|
-
> `settings.plugin.item` → `plugins.item` / `settings.section` 是**改名**,不是移除。
|
|
264
|
+
### 卸载
|
|
190
265
|
|
|
191
|
-
`
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
[skills 字段:按代理配置推理强度](#skills-字段按代理配置推理强度reasoningeffort)。
|
|
266
|
+
1. 从 profile 的 `cordis.patch.yml` 移除 `cohub` 那一行(或其 `plugins:` 项),或执行 `dsh plugin remove dsh-cohub`。
|
|
267
|
+
2. 删除 `~/.dsh/.agent-presets/` 下的 `co-orchestrator`、`cohub-cordis`、`cohub-subagent-readonly`、`cohub-subagent-write` 目录(若存在)。
|
|
268
|
+
3. 重启 DSH。技能与设置页区块应随之消失。
|
|
195
269
|
|
|
196
|
-
|
|
197
|
-
`value=""` 继承占位项、目录加载中/失败降级手填、已存值不可用时 disabled 回显、只读连接、
|
|
198
|
-
revision 冲突拒绝保存、只写显式配置的代理等。本包 0.5.0 仅面向 DSH 0.2,不支持 0.1。
|
|
270
|
+
### 排查入口
|
|
199
271
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
由 Loader 以 `loader/volatile-update` 提交到运行中的同一 Volatile 引用(无需重挂载);
|
|
203
|
-
插件每次 delegate 工具 execute 时 `get()` 当前快照,因此下一次工具调用即见更新,正在执行的一次使用起始快照。
|
|
204
|
-
`test/host-integration.ts` 用真实 Loader + `SettingsForms.describe()` 验证了这条链路(含提交后 describe 的 value 与 `config.get()` 一致)。
|
|
272
|
+
- 设置页「CoHub 代理模型」区块可确认模型路由是否生效。
|
|
273
|
+
- 行为异常时先确认宿主 DSH 版本(见「快速开始 → 前置条件」),再查看会话日志定位委派链路。
|
|
205
274
|
|
|
206
|
-
##
|
|
275
|
+
## 兼容性
|
|
207
276
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
宿主实测 `4.0.4` / `3.18.4`——lock 解析到最新不代表宿主实测,以宿主为准):
|
|
277
|
+
宿主版本要求见「快速开始 → 前置条件」。`@deepseek-ai/cordis` peer `^4.0.1` / `schemastery` peer `^3.18.1`
|
|
278
|
+
保持合法 range,测试 devDependencies **精确固定**宿主实测 `4.0.4` / `3.18.4`——lock 解析到最新不代表宿主实测,以宿主为准:
|
|
211
279
|
|
|
212
280
|
- **0.1 的 settings namespace 机制已移除**:`installSettingsSection` / `settingsNamespace` 在
|
|
213
281
|
dsh-settings 0.2 已删除。本插件不再注册 `cohub` namespace,改为 Config 的三个动态字段标
|
|
214
282
|
`.volatile()`(见上节)。`settings.yaml` 的 `cohub.*` 段**不会被自动迁移**(旧 importer 是否
|
|
215
283
|
支持自定义 namespace 未证实,明确不触发),请通过设置页或 `cordis.patch.yml` 重新配置。
|
|
216
|
-
- **不兼容 DSH 0.1
|
|
217
|
-
属预期行为。
|
|
284
|
+
- **不兼容 DSH 0.1**:宿主版本要求见「快速开始 → 前置条件」(0.1 宿主上 npm 会拒绝 peer 冲突,属预期行为)。
|
|
218
285
|
- **验证入口**:`npm run test:runtime`(`test/runtime-0.2.ts`,真实 schemastery/Volatile/defineTool
|
|
219
286
|
契约 + 真实 cordis 挂载,离线 stub 子代理)、`npm run test:host`(`test/host-integration.ts`,
|
|
220
287
|
真实 Loader + entry.update volatile 提交 + SettingsForms.describe 投影 + 真实 subagents 服务
|
|
@@ -259,185 +326,107 @@ npm run audit -- <sessionDir> [--rules <json>] [--rules-file <path>] [--json <ou
|
|
|
259
326
|
|
|
260
327
|
输出工具调用/结果/错误、错误类别、通用"重复盲试"、委派树、墙钟超时与环境签名。完整规则与退出码见 `scripts/audit-session.mjs` 顶部注释。
|
|
261
328
|
|
|
262
|
-
##
|
|
263
|
-
|
|
264
|
-
`presets/co-orchestrator/` 提供调度者主代理身份(persona + 调度工具面:subagent/fork/workflow/skill/todo/jobs/ask-user/goal + compaction)。
|
|
265
|
-
|
|
266
|
-
**自动安装**:本包在 `apply` 时会把内置 preset 复制到 `~/.dsh/.agent-presets/co-orchestrator/`(幂等,不覆盖你已修改的同名 preset)。`dsh plugin --profile web add dsh-cohub` 装完重启后,即可在 GUI 的 agent preset 选择器中切换,无需手动操作。
|
|
267
|
-
|
|
268
|
-
若 preset 未出现(例如本地源码开发、或想手动摆放),可兜底执行:
|
|
269
|
-
|
|
270
|
-
```bash
|
|
271
|
-
mkdir -p ~/.dsh/.agent-presets/co-orchestrator
|
|
272
|
-
cp presets/co-orchestrator/* ~/.dsh/.agent-presets/co-orchestrator/
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
> ⚠️ 上面的 `cp presets/<name>/*` **不会带上子目录**。带 `skills/` 的 preset(如 `cohub-cordis`)必须整目录复制,否则技能丢失;Windows 上推荐直接用随仓库提供的脚本(递归复制 + 防 `Copy-Item` 同名嵌套陷阱):
|
|
276
|
-
>
|
|
277
|
-
> ```powershell
|
|
278
|
-
> pwsh -File scripts/deploy-preset.ps1 # 默认 cohub-cordis
|
|
279
|
-
> pwsh -File scripts/deploy-preset.ps1 -PresetName co-orchestrator
|
|
280
|
-
> ```
|
|
329
|
+
## 开发与维护
|
|
281
330
|
|
|
282
|
-
|
|
331
|
+
### 与 OpenCode 版的机制映射
|
|
283
332
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
- **移除 `cohub-standard`**:其工具面是 `cohub-cordis` 的真子集,详见下方说明。
|
|
298
|
-
|
|
299
|
-
**v0.4.9 修复(preset 无法挂载 → 新会话无法创建)**:这一次修的是**两个独立的挂载期故障**,症状相同(preset 不可用 → 以它为默认 preset 时新会话建不出来),日志都在 `%APPDATA%\DSH Desktop\logs\host\dsh-*.log`。
|
|
300
|
-
|
|
301
|
-
**其一:persona 字段名过时。** `@deepseek-ai/dsh-persona` 的 schema 是 `prefix`(required)/ `suffix`,而两个内置 preset 一直沿用旧字段 `text:`:
|
|
302
|
-
|
|
303
|
-
```
|
|
304
|
-
[preset-tree] Error: failed to apply loader entry persona (@deepseek-ai/dsh-persona):
|
|
305
|
-
invalid config: - $.prefix missing required value (at prefix)
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
已把两个 preset 的字段统一为 `prefix`。
|
|
333
|
+
| OpenCode 版(oh-my-opencode-cohub) | DSH 版(本包) |
|
|
334
|
+
|---|---|
|
|
335
|
+
| 12 个 agent 注册(双重注册 + config hook) | 13 个 runtime skills(本插件 apply 时注册) |
|
|
336
|
+
| 中文注入 experimental.chat.system.transform | ctx.systemPrompt.section |
|
|
337
|
+
| task 工具 + 并行派发 | DSH 原生 subagent 工具(后台/续聊) |
|
|
338
|
+
| todowrite | DSH 原生 todo_write |
|
|
339
|
+
| Background Job Board(消息注入) | DSH 原生 job board(删除) |
|
|
340
|
+
| ContextEngine 上下文提取 | subagent_fork 继承会话(删除) |
|
|
341
|
+
| council_session 工具 | workflow 并行 + provider/model 覆盖 |
|
|
342
|
+
| TUI 面板 | DSH Web GUI 原生面板(删除) |
|
|
343
|
+
| CLI 安装器 | dsh plugin add(转发 pnpm) |
|
|
344
|
+
| **调度韧性**(停滞检测 / 调度参数) | **切片**(stall 检测器 + schedule 配置 + systemPrompt 段) |
|
|
345
|
+
| **环境契约一次学习持续使用** | **切片**(envSignatures 模块 + 缓存到 `~/.dsh/cohub/env-signatures.json`) |
|
|
309
346
|
|
|
310
|
-
|
|
347
|
+
> 注:`dsh plugin add` 不是 CLI 独立子命令,而是把参数转发给 profile 目录内的 `pnpm`(`dsh plugin --profile <name> add <pkg>` ≡ 在该 profile 执行 `pnpm add <pkg>`),安装后自动把声明 `dsh.bundle` 的依赖加入 `dsh.profile.bundles`。
|
|
311
348
|
|
|
312
|
-
|
|
313
|
-
[tool-cordis] Error: Host Cordis inspect provider "Service" is already registered
|
|
314
|
-
[preset-tree] Error: failed to apply loader entry tool-cordis (@deepseek-ai/dsh-tool-cordis):
|
|
315
|
-
Host Cordis inspect provider "Service" is already registered
|
|
316
|
-
```
|
|
349
|
+
### 构建
|
|
317
350
|
|
|
318
|
-
|
|
351
|
+
前置:系统 bun(与主仓库一致)。
|
|
319
352
|
|
|
320
|
-
```
|
|
321
|
-
-
|
|
322
|
-
|
|
323
|
-
|
|
353
|
+
```bash
|
|
354
|
+
cd packages/dsh-cohub
|
|
355
|
+
npm run build
|
|
356
|
+
# 等价于:
|
|
357
|
+
# bun run scripts/generate-skills.ts # ① 生成 src/skills.ts(.md → 技能定义,必须先跑)
|
|
358
|
+
# bun run scripts/guard-schema.ts # ② 校验 Config / ScheduleConfig schema 与 cordis.patch.yml 一致
|
|
359
|
+
# bun build src/index.ts --outdir lib --target node --format esm \
|
|
360
|
+
# --external @deepseek-ai/cordis --external @deepseek-ai/schemastery \
|
|
361
|
+
# --external @deepseek-ai/dsh-tools --external @deepseek-ai/dsh-system-prompt \
|
|
362
|
+
# --external @deepseek-ai/dsh-skill --external @deepseek-ai/dsh-home-paths
|
|
363
|
+
# bun build src/co-cordis-plugin.ts --outdir lib --target node --format esm \
|
|
364
|
+
# --external @deepseek-ai/dsh-tools # co-cordis 专用插件(第 13 个技能)
|
|
365
|
+
# bun run scripts/build-client.js # src/client/index.js → lib/client.js
|
|
324
366
|
```
|
|
325
367
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
- 创造模式的 standing mount 失败 → agent 创建在 preset 的 compose 阶段被**回滚** → **每次对话都报 `client api: session/prompt failed: Failed to fetch (gateway/internal)`**;
|
|
329
|
-
- host 同时以 ~10 次/秒重试失败的挂载,日志写到 **10MB/分钟**(一天 200MB+)。
|
|
330
|
-
|
|
331
|
-
所以 v0.4.10 起:**`tool-cordis` 全进程只由官方「创造模式」挂**。`dsh-cohub` 的 bundle patch 不再插入该行,`cohub-cordis` 也不挂它,而 cohub 插件行照常挂载。
|
|
332
|
-
|
|
333
|
-
**v0.4.11 变更(orchestrator 技能瘦身,2026-10-17)**:`skills/orchestrator.md` 20587 → 15532 bytes(约 -24.6%)。主代理保持纯调度,两层并行/聚合、brief 300、planner 237、批次上限 3 均不变;不伪造 runtime 200K,不自动压缩/硬裁 delegate。规格细节见 [skills/orchestrator.md](skills/orchestrator.md)。
|
|
334
|
-
|
|
335
|
-
**v0.5.0 变更(正式面向 DSH 0.2.0-rc.2,2026-10-17)**:本包正式锁定 DSH 0.2 契约(peer/dev 依赖升至 `0.2.0-rc.2`;`@deepseek-ai/cordis` peer `^4.0.1` / `schemastery` peer `^3.18.1` 保持合法 range),**不再支持 DSH 0.1**(0.1 宿主因 peer 冲突被 npm 拒绝安装,属预期)。设置改为 Config 的 `.volatile()` 动态字段,由官方设置页按活动 profile entry id 原生投影(`.volatile()` 取代并删除 0.1 的 `installSettingsSection` / `settingsNamespace` 自定义卡片机制);**不自动迁移**旧 `cohub` settings namespace 与用户 preset(旧配置请经设置页或 `cordis.patch.yml` 重配;preset 由安装台账按「用户是否改过」逐文件保护)。`test/host-integration.ts` 新增运行中取消门禁:真实 SubagentRuntime + in-memory provider 验证 start 已发布后 mid-flight abort 的 result 停止/失败传播(signal 驱动受控 result settle 为 `stopReason=aborted`,非仅断言 `signal.aborted`)与 dispose 资源清理,并验证 delegate 工具 execution 的取消链(父 `exec.signal` → run.result 停止 → 结构化 cause)。
|
|
336
|
-
**v0.5.0 收尾(客户端收敛 + session-projection peer)**:`src/client/index.js` 删除 0.1 `settingsScope` /
|
|
337
|
-
`settings.plugin.item` 兼容死分支与不可达的自定义设置卡片(约 800 行,0.2 下该分支永不执行),
|
|
338
|
-
仅保留 locale 设置字典注册;`dsh.client.inject` 收敛为仅 `@deepseek-ai/dsh-client-locale`,
|
|
339
|
-
peer 移除不再使用的 `react` / `dsh-client-connection` / `dsh-client-ui-settings` /
|
|
340
|
-
`dsh-client-ui-slots` / `dsh-api-remotes`;新增 peer `@deepseek-ai/dsh-session-projection ^0.2.0-rc.2`
|
|
341
|
-
(required,tokenMeter 真实调用 `ctx.sessionProjections.snapshot`)。新增 `npm run test:client`
|
|
342
|
-
(`test/client-runtime-0.2.ts`):执行真实构建产物 `lib/client.js` 的 ModuleLoader 注册,断言
|
|
343
|
-
module id / inject 仅 locale、apply 只访问声明服务、不触碰旧 settingsScope/slot/未声明 remote
|
|
344
|
-
(locale 与 window 为内存 stub,非 React 真实浏览器 UI,浏览器实测留给宿主)。
|
|
345
|
-
|
|
346
|
-
**v0.5.1 变更(恢复「CoHub 代理模型」设置页)**:撤销 v0.5.0 收尾中「删除自定义设置卡片」的决定——
|
|
347
|
-
该决定的理由是「官方设置页会自动按 volatile 字段生成表单」,但官方 README 明说
|
|
348
|
-
「目前没有已发布的客户端会那样渲染 volatile 字段」,官方 settings 导航/页面全部由客户端插件
|
|
349
|
-
注册(general / models / plugins / agent-presets / account 皆然),故该理由不成立。
|
|
350
|
-
`src/client/index.js` 恢复为向 `settings.section` 注册独立设置页(`order: 12`),13 个代理的
|
|
351
|
-
provider/model 双下拉经 `configForms` 读写 volatile `skills`(`mutate` + revision 冲突栅栏);
|
|
352
|
-
`dsh.client.inject` 补回 `@deepseek-ai/dsh-client-ui-settings` / `@deepseek-ai/dsh-api-remotes`
|
|
353
|
-
(由宿主 web 组合提供,本包不直接依赖);`test/client-runtime-0.2.ts` 扩为 84 条断言,
|
|
354
|
-
覆盖渲染契约(`value=""` 继承占位项、目录加载中/失败降级手填、已存值不可用 disabled 回显、
|
|
355
|
-
只读、冲突、保存失败)与写回契约(只写显式配置的代理、空 model 不写键、保留未知 skill 名)。
|
|
356
|
-
|
|
357
|
-
> **`cohub-cordis` 因此不含 `cordis_*` 工具**(`cordis_define` / `cordis_run` / `cordis_mount` / `cordis_inspect_*`)。需要 Cordis 自指能力时,请用官方**创造模式**会话;本 preset 用于"标准能力 + cohub 委派纪律"的日常开发。
|
|
358
|
-
>
|
|
359
|
-
> 也**不要**在 profile 的 `cordis.patch.yml` 里 insert 同 id —— 那会重新制造同一个故障。
|
|
360
|
-
>
|
|
361
|
-
> 需要回退时:把 `dsh-cohub` 从 profile `package.json` 的 `dsh.profile.bundles` 移除即可。
|
|
362
|
-
|
|
363
|
-
`test/preset-schema.ts` 现在同时断言:persona 必须 `prefix` 非空、**不得残留 `text:`**、**preset 不得挂 `tool-cordis`**、关键工具行齐全、无制表符缩进、`cohub-standard` 不得复活。
|
|
364
|
-
|
|
365
|
-
> 升级注意:安装台账按「用户是否改过」逐文件保护。若某个 preset 文件**既被用户改过、又需要跟随上游改名**,台账会判为用户改动而跳过自动更新 —— 此时需手动同步(或删除该 preset 目录让插件重新安装)。本次就是这种情况,已在该机器上手动修正。
|
|
366
|
-
|
|
367
|
-
**v0.5.1 变更(验证范围与证据复用契约化,2026-10-17)**:新增 `test/skills-contract.ts` 契约测试——直接读取 `skills/*.md` 磁盘正文(不依赖生成物 `src/skills.ts`,build 前后均可运行,与调用时 cwd 无关,`node test/skills-contract.ts` 即可),断言四角色验证纪律:orchestrator 验证节(范围 / 负责人 / 扩大条件 / 修改 Wave 不自测、批量改完统一验证)、planner 验证步骤、fixer 委派范围纪律、oracle 成功证据复用安全条件。同步收紧验证纪律:多代理并行修改的 Wave 本轮只改不验证,批量修改全部完成后统一验证;失败先集中归因(真实退出码/错误消息/日志位置)→ 定向修复最小范围 → 验证通过后再按影响面扩大,诊断/交互类问题说明理由可作例外;证据复用仅限成功完成的只读检查且仍覆盖当前输入/源码与测试/配置/范围/环境状态,证据不足就必要重验,失败不是通过证据,无新变更/目标时不机械重跑已知失败。**本版本仅收敛验证范围/证据复用规则并新增对应契约测试,不含新的 API 适配**——0.5.0 的 DSH 0.2 适配与 0.1 不兼容说明见上文,保持有效。
|
|
368
|
-
|
|
369
|
-
### 关于 `cohub-standard`(v0.4.7 移除)
|
|
370
|
-
|
|
371
|
-
原先的 `cohub-standard`(标准模式 + cohub 身份)其 29 行工具面是 `cohub-cordis` 的**真子集**——只少了 `tool-cordis`、`present`、`command-goal`,而两者的 delegate 能力完全相同。因此 v0.4.7 删除该 preset,统一指向 **cohub-cordis**(标准模式全部能力 + 自改运行时)。
|
|
372
|
-
|
|
373
|
-
对已安装的老用户:插件加载时会读取安装台账,自动移除"曾由本插件安装、但已不再随包发布"的目录,所以重启后选择器里不会再出现它。若你**手动改造过** `~/.dsh/.agent-presets/cohub-standard/`,或该目录早于台账机制存在,它不会被自动清理——按需手动删除即可。
|
|
374
|
-
|
|
375
|
-
## cohub-cordis agent preset(Phase 5,v0.4.7 新增;v0.4.10 起不含 tool-cordis)
|
|
376
|
-
|
|
377
|
-
`presets/cohub-cordis/` 是 **DSH 官方「创造模式」(`cordis` preset)的骨架 + cohub 中文身份与委派指引**:标准模式的全部工具面、`present` 产物交付、组合创作技能,加上直接可用的 cohub `delegate` / `delegate_batch`。
|
|
378
|
-
|
|
379
|
-
**⚠️ 它不含运行时自改能力(`cordis_*` 工具)**:`tool-cordis` 在 Host 进程级 inspect 注册表里按 id 占位,全进程只能挂一次,而官方创造模式自带这一行(v0.4.10 撤销了 v0.4.9 的 host 层方案,原因见上)。要读写 harness 组合、做 `cordis_mount` 插件实验、动态定义/运行插件,请用官方**创造模式**;本 preset 用于"标准能力 + cohub 委派纪律"的日常开发。
|
|
380
|
-
|
|
381
|
-
**两者定位**:
|
|
382
|
-
|
|
383
|
-
| preset | 工具模式 | 委派 | 运行时自改 | 适用场景 |
|
|
384
|
-
|---|---|---|---|---|
|
|
385
|
-
| co-orchestrator | 纯调度(不挂 fs/shell/web + persona 软约束) | ✅ delegate | ✗ | 长链调度 / 多模型共识 / 严格自律 |
|
|
386
|
-
| **cohub-cordis** | **标准模式 + 中文身份 + 组合创作技能** | ✅ delegate | ✗(用官方创造模式) | 直接动手 + 委派混合、插件开发日常 |
|
|
387
|
-
| 官方 **创造模式**(`cordis`) | 标准 + **Cordis 自指工具面** | ✅ delegate(host plane,同样可用) | ✅ | 自改 harness / preset 创作 / 插件实验 |
|
|
388
|
-
|
|
389
|
-
**cohub 能力从哪来**:13 个 co-* 技能与 `delegate` / `delegate_batch` 工具由 dsh-cohub bundle 在 **host plane 全局注册**,与 preset 解耦——所以本 preset 不需要(也没有)额外的委派工具行。已实测确认:`delegate` 与 `delegate_batch` 都出现在会话工具表中,任何 preset 的会话(含创造模式)都能直接用,只要 dsh-cohub 挂在该 profile 上。
|
|
390
|
-
|
|
391
|
-
**使用方式**:agent preset 在会话**首次 turn 之后即锁定**(`agent-preset/locked: session has already started; its agent preset is fixed`),所以创造模式只能**新建会话**时选择,不能中途切换。
|
|
392
|
-
|
|
393
|
-
**自包含技能**:本 preset 自带 `skills/`(`cordis-plugin-development`、`editing-cordis-compositions` 两份组合创作指导),通过 `customSkillDirs` 指向 preset 自身目录,因此无论安装到哪里都能解析。
|
|
394
|
-
|
|
395
|
-
> **TRUST**:`cordis_mount` 会对模型写出的 JavaScript 求值并在活动运行时里执行,且本 agent 写出的组合会成为其他会话可挂载的 preset。请把使用本 preset 的会话**等同于 shell 访问权限**对待。
|
|
396
|
-
|
|
397
|
-
## 测试
|
|
368
|
+
### 测试
|
|
398
369
|
|
|
399
370
|
```bash
|
|
400
|
-
node test/unit.ts # 基础集成(13 技能 + 内容 + brief + delegate 注入 +
|
|
371
|
+
node test/unit.ts # 基础集成(13 技能 + 内容 + brief + delegate 注入 + council)
|
|
401
372
|
node test/delegate-p1.ts # P1:环境契约注入 + 重试
|
|
402
|
-
node test/stall-p3.ts #
|
|
403
|
-
node test/schedule-p3.ts #
|
|
404
|
-
node test/env-sig-p3.ts #
|
|
373
|
+
node test/stall-p3.ts # 停滞检测(35 用例)
|
|
374
|
+
node test/schedule-p3.ts # 调度参数(24 用例)
|
|
375
|
+
node test/env-sig-p3.ts # 环境契约持久化(50 用例)
|
|
405
376
|
node test/skills-contract.ts # 技能契约:四角色验证纪律 + 证据复用 + 扩大条件(直接读 skills/*.md)
|
|
406
377
|
npm run test:runtime # DSH 0.2 运行期契约(真实 schemastery/Volatile/defineTool + cordis 挂载)
|
|
407
378
|
npm run test:host # DSH 0.2 宿主集成门禁(真实 Loader/SettingsForms/subagents/app-boot preflight)
|
|
408
379
|
```
|
|
409
380
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
## 目录
|
|
381
|
+
### 目录结构
|
|
413
382
|
|
|
414
383
|
```
|
|
415
384
|
skills/ 提示词源文件(.md,人工编辑;scripts/generate-skills.ts 据此生成 src/skills.ts)
|
|
385
|
+
docs/ 设计文档
|
|
416
386
|
scripts/
|
|
417
387
|
generate-skills.ts .md → src/skills.ts(必须先跑)
|
|
388
|
+
guard-schema.ts Config / ScheduleConfig schema 与 cordis.patch.yml 一致性校验
|
|
418
389
|
build-client.js src/client/index.js → lib/client.js
|
|
419
390
|
audit-session.mjs 会话导出目录审计 / 回归
|
|
420
391
|
deploy-preset.ps1 手动部署内置 preset 到用户 preset root(幂等,防嵌套)
|
|
421
392
|
src/
|
|
422
|
-
index.ts 插件行入口(apply、Config schema
|
|
393
|
+
index.ts 插件行入口(apply、Config schema、三切片 schema、preset 安装接线)
|
|
394
|
+
co-cordis-plugin.ts co-cordis 专用插件(第 13 个技能)
|
|
423
395
|
preset-install.ts 内置 preset 安装/升级台账(未改动则更新、用户改动则跳过、孤儿清理)
|
|
424
|
-
delegate.ts delegate 工具 +
|
|
396
|
+
delegate.ts delegate 工具 + StallWatchdog
|
|
397
|
+
delegate_batch.ts delegate_batch 批量并行派发工具
|
|
398
|
+
council.ts 多模型共识(council_session 工具)
|
|
425
399
|
env-contract.ts 注入子代理的执行器环境契约文本(含「工具批处理」通用原则)
|
|
426
|
-
env-signatures.ts
|
|
400
|
+
env-signatures.ts 环境契约持久化(EnvSignatureLearner + 缓存)
|
|
401
|
+
chinese.ts 中文身份与提示词文本
|
|
402
|
+
result-budget.ts 子代理输出预算裁剪
|
|
403
|
+
text-utils.ts 文本处理小工具
|
|
427
404
|
skills.ts generate-skills.ts 生成物(禁止手编)
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
presets/
|
|
405
|
+
shared/ 主/客户端共享常量
|
|
406
|
+
client/index.js 客户端模块(设置页「CoHub 代理模型」section 注册)
|
|
407
|
+
presets/
|
|
408
|
+
co-orchestrator/ 内置 agent preset(纯调度编排,委派工具面补全 + compaction)
|
|
409
|
+
cohub-cordis/ 内置 agent preset(创造模式 + 中文身份 + 自包含组合创作技能)
|
|
410
|
+
cohub-subagent-readonly/ 子代理只读 preset(工具面硬隔离)
|
|
411
|
+
cohub-subagent-write/ 子代理可写 preset(工具面硬隔离)
|
|
431
412
|
test/
|
|
432
413
|
unit.ts 基础集成
|
|
414
|
+
client-runtime-0.2.ts 设置页渲染 / 写回契约(84 条断言)
|
|
433
415
|
delegate-p1.ts P1 环境契约注入 + 重试 + 模型回退
|
|
434
|
-
stall-p3.ts
|
|
435
|
-
schedule-p3.ts
|
|
436
|
-
env-sig-p3.ts
|
|
416
|
+
stall-p3.ts 停滞检测
|
|
417
|
+
schedule-p3.ts 调度参数
|
|
418
|
+
env-sig-p3.ts 环境契约持久化
|
|
419
|
+
runtime-0.2.ts DSH 0.2 运行期契约
|
|
420
|
+
host-integration.ts 宿主集成门禁(真实 Loader / SettingsForms / subagents)
|
|
421
|
+
skills-contract.ts 技能契约(四角色验证纪律 + 证据复用)
|
|
437
422
|
preset-copy.ts preset 递归复制(含真实 preset 结构断言)
|
|
438
423
|
preset-install.ts preset 安装/升级台账(用户改动保护 + 孤儿清理 + 降级)
|
|
439
424
|
preset-schema.ts preset YAML schema 断言(persona.prefix / 无 text: / 不挂 tool-cordis / 无 tab 缩进)
|
|
440
|
-
|
|
425
|
+
types/ strict 类型检查入口(runtime-0.2.ts)
|
|
426
|
+
cordis.patch.yml bundle patch(含 P1/P3 全部 profile 字段示例)
|
|
427
|
+
CHANGELOG.md 变更历史
|
|
428
|
+
package.json 包定义与脚本
|
|
429
|
+
tsconfig.typecheck.json src 类型检查配置(typecheck:src;0.2 用 test/tsconfig.runtime-0.2.json,见 typecheck:0.2)
|
|
441
430
|
```
|
|
442
431
|
|
|
443
|
-
>
|
|
432
|
+
> 宿主版本要求见「快速开始 → 前置条件」。
|
package/lib/index.js
CHANGED
|
@@ -1894,6 +1894,35 @@ function intersectWithRestrictable(filter, restrictableNames) {
|
|
|
1894
1894
|
};
|
|
1895
1895
|
return next.allow !== undefined || next.deny !== undefined ? next : undefined;
|
|
1896
1896
|
}
|
|
1897
|
+
function describeDegradeReason(error) {
|
|
1898
|
+
const message = error?.message;
|
|
1899
|
+
const raw = typeof message === "string" && message.length > 0 ? message : String(error);
|
|
1900
|
+
const firstLine = (raw.split(/\r?\n/)[0] ?? "").replace(/\s+/g, " ").trim();
|
|
1901
|
+
const text = firstLine.length > 0 ? firstLine : "unknown";
|
|
1902
|
+
return text.length > 200 ? text.slice(0, 200) : text;
|
|
1903
|
+
}
|
|
1904
|
+
function formatDegradeNotes(notes) {
|
|
1905
|
+
if (notes === undefined || notes.length === 0)
|
|
1906
|
+
return "";
|
|
1907
|
+
if (notes.length === 1) {
|
|
1908
|
+
const only = notes[0];
|
|
1909
|
+
return `
|
|
1910
|
+
|
|
1911
|
+
[` + only.what + "," + only.effect + ":" + only.reason + "]";
|
|
1912
|
+
}
|
|
1913
|
+
return `
|
|
1914
|
+
|
|
1915
|
+
[降级提示:` + notes.map((n) => n.what + "," + n.effect + "(" + n.reason + ")").join(";") + "]";
|
|
1916
|
+
}
|
|
1917
|
+
function upsertDegradeNote(notes, note) {
|
|
1918
|
+
if (notes === undefined)
|
|
1919
|
+
return;
|
|
1920
|
+
const index = notes.findIndex((n) => n.id === note.id);
|
|
1921
|
+
if (index >= 0)
|
|
1922
|
+
notes[index] = note;
|
|
1923
|
+
else
|
|
1924
|
+
notes.push(note);
|
|
1925
|
+
}
|
|
1897
1926
|
var PRESET_REJECTED = /PRESET_UNAVAILABLE|agent-preset\/(not-found|invalid)|Unknown agent preset|agent preset|preset revision|preset.*unavailable/i;
|
|
1898
1927
|
var TOOL_FILTER_REJECTED = /unknown global tool|toolFilter|tool filter|capabilit/i;
|
|
1899
1928
|
var RESTRICTABLE_NAMES_IN_ERROR = /known global tools:\s*([^\n;]*)/i;
|
|
@@ -1922,6 +1951,13 @@ async function startSubagentRun(ctx, provider, spec) {
|
|
|
1922
1951
|
const aborted = spec.signal?.aborted === true || /abort/i.test(message);
|
|
1923
1952
|
if (aborted || !PRESET_REJECTED.test(message))
|
|
1924
1953
|
throw error;
|
|
1954
|
+
const reason = describeDegradeReason(error);
|
|
1955
|
+
upsertDegradeNote(spec.degradeNotes, {
|
|
1956
|
+
id: "preset",
|
|
1957
|
+
what: "子代理 preset 未生效",
|
|
1958
|
+
effect: "已降级为继承父 preset",
|
|
1959
|
+
reason
|
|
1960
|
+
});
|
|
1925
1961
|
ctx?.logger?.warn?.('[cohub preset] 子代理 preset "' + spec.agentPreset + '" 不可用,已降级为继承父 preset 重试:' + message.slice(0, 300) + "(委派继续,不阻断)");
|
|
1926
1962
|
return spawnWithToolFilterFallout(ctx, provider, { ...spec, agentPreset: undefined });
|
|
1927
1963
|
}
|
|
@@ -1932,7 +1968,16 @@ async function spawnWithToolFilterFallout(ctx, provider, spec) {
|
|
|
1932
1968
|
let lastFilterError;
|
|
1933
1969
|
for (let attempt = 0;attempt < 3; attempt++) {
|
|
1934
1970
|
try {
|
|
1935
|
-
|
|
1971
|
+
const handle = await startSubagentRunOnce(ctx, provider, { ...spec, toolFilter: filter });
|
|
1972
|
+
if (wanted !== undefined && filter === undefined) {
|
|
1973
|
+
upsertDegradeNote(spec.degradeNotes, {
|
|
1974
|
+
id: "toolfilter",
|
|
1975
|
+
what: "工具裁剪未生效",
|
|
1976
|
+
effect: "子代理使用全量工具",
|
|
1977
|
+
reason: lastFilterError === undefined ? "可限制工具清单交集为空,无可裁项" : describeDegradeReason(lastFilterError)
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
return handle;
|
|
1936
1981
|
} catch (error) {
|
|
1937
1982
|
const message = error instanceof Error ? error.message : String(error);
|
|
1938
1983
|
const aborted = spec.signal?.aborted === true || /abort/i.test(message);
|
|
@@ -2499,21 +2544,21 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
2499
2544
|
const envSig = createEnvSig(config);
|
|
2500
2545
|
return defineTool({
|
|
2501
2546
|
name: "delegate",
|
|
2502
|
-
description: "
|
|
2547
|
+
description: "委派单一子代理:按 skill 路由模型并注入角色指令后运行。" + "background:true=强制后台返 jobId;false=强制前台;缺省=按配置。",
|
|
2503
2548
|
parameters: {
|
|
2504
2549
|
skill: {
|
|
2505
2550
|
type: "string",
|
|
2506
2551
|
required: true,
|
|
2507
|
-
description: "
|
|
2552
|
+
description: "必填,co-* 代理名(如 co-fixer/co-explorer/co-oracle)"
|
|
2508
2553
|
},
|
|
2509
2554
|
prompt: {
|
|
2510
2555
|
type: "string",
|
|
2511
2556
|
required: true,
|
|
2512
|
-
description: "
|
|
2557
|
+
description: "必填,自包含:目标、路径、约束、输出格式"
|
|
2513
2558
|
},
|
|
2514
2559
|
background: {
|
|
2515
2560
|
type: "boolean",
|
|
2516
|
-
description: "true
|
|
2561
|
+
description: "true=强制后台返 jobId;false=强制前台同步;缺省=按配置(enabled && skill 命中 defaultFor)"
|
|
2517
2562
|
}
|
|
2518
2563
|
},
|
|
2519
2564
|
output: DELEGATE_OUTPUT_CONFIG,
|
|
@@ -2538,6 +2583,7 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
2538
2583
|
}
|
|
2539
2584
|
const agentOptions = await buildAgentOptions(route, ctx, skill.name);
|
|
2540
2585
|
const toolFilter = resolveSkillToolFilter(skill.name, config.toolFilter?.enabled ?? true, ctx.logger);
|
|
2586
|
+
const degradeNotes = [];
|
|
2541
2587
|
const agentPreset = resolveSkillAgentPreset(skill.name, subagentPresetEnabled);
|
|
2542
2588
|
const fp = envFingerprint();
|
|
2543
2589
|
const contractResult = resolveContractText({ enabled: envContract.enabled, text: envContract.text }, envSig, ctx, fp);
|
|
@@ -2609,7 +2655,8 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
2609
2655
|
...toolFilter !== undefined ? { toolFilter } : {},
|
|
2610
2656
|
...agentPreset !== undefined ? { agentPreset } : {},
|
|
2611
2657
|
...agentOptions ? { agentOptions } : {},
|
|
2612
|
-
signal
|
|
2658
|
+
signal,
|
|
2659
|
+
degradeNotes
|
|
2613
2660
|
});
|
|
2614
2661
|
} catch (error) {
|
|
2615
2662
|
if (watchdog)
|
|
@@ -2655,12 +2702,13 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
2655
2702
|
} catch {}
|
|
2656
2703
|
}
|
|
2657
2704
|
if (outcome?.stopReason === "completed") {
|
|
2658
|
-
|
|
2705
|
+
const budgeted = await budgetSubagentResult(ctx, exec, contentText(outcome.output), {
|
|
2659
2706
|
maxChars: resolveSkillResultMaxChars(budget, skill.name),
|
|
2660
2707
|
scope: "delegate",
|
|
2661
2708
|
label: skillTag,
|
|
2662
2709
|
enabled: budget.enabled
|
|
2663
2710
|
});
|
|
2711
|
+
return budgeted + formatDegradeNotes(degradeNotes);
|
|
2664
2712
|
}
|
|
2665
2713
|
lastReason = String(outcome?.stopReason ?? "unknown");
|
|
2666
2714
|
lastDiagnostic = typeof outcome?.diagnostic === "string" ? outcome.diagnostic : undefined;
|
|
@@ -3026,12 +3074,12 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
3026
3074
|
}
|
|
3027
3075
|
return defineTool3({
|
|
3028
3076
|
name: "delegate_batch",
|
|
3029
|
-
description: "
|
|
3077
|
+
description: "并发执行多个子代理任务:一次调用并行派发 N 个无依赖任务,返回各自结果。" + "每项 skill/prompt 必填,单批默认 3(上限 20),不重试。",
|
|
3030
3078
|
parameters: {
|
|
3031
3079
|
tasks: {
|
|
3032
3080
|
type: "array",
|
|
3033
3081
|
required: true,
|
|
3034
|
-
description:
|
|
3082
|
+
description: "任务列表,每项 skill/prompt 必填;上限 schedule.maxParallelBatch(默认 3,最大 20)",
|
|
3035
3083
|
items: {
|
|
3036
3084
|
type: "object",
|
|
3037
3085
|
additionalProperties: false,
|
|
@@ -3040,9 +3088,9 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
3040
3088
|
skill: {
|
|
3041
3089
|
type: "string",
|
|
3042
3090
|
required: true,
|
|
3043
|
-
description: "
|
|
3091
|
+
description: "必填,co-* 代理名(如 co-fixer/co-explorer/co-oracle)"
|
|
3044
3092
|
},
|
|
3045
|
-
prompt: { type: "string", required: true, description: "
|
|
3093
|
+
prompt: { type: "string", required: true, description: "必填,给该代理的具体任务(自包含)" }
|
|
3046
3094
|
}
|
|
3047
3095
|
}
|
|
3048
3096
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cohub",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "DeepSeek Harness 版 CoHub
|
|
3
|
+
"version": "0.8.2",
|
|
4
|
+
"description": "DeepSeek Harness 版 CoHub:中文智能体编排——用户可选 2 种工作模式(co-orchestrator 纯调度 / cohub-cordis 创造模式)+ 13 个专职代理技能 + 多模型共识;另由 cohub-subagent-readonly / cohub-subagent-write 两个支撑 preset 实现子代理读写硬隔离(共 4 个 preset)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|