dsh-workplan 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.en.md +1 -1
- package/README.md +2 -2
- package/docs/release-record-2.0.2-20261105.md +87 -0
- package/lib/host.js +1 -1
- package/lib/runtime.js +84 -3
- package/package.json +1 -1
- package/src/host.ts +1 -1
- package/src/runtime.ts +79 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## 2.0.3 — 2026-11-05
|
|
2
|
+
|
|
3
|
+
**修复「官方 `/goal` 目标指令会让 dsh-workplan 自动分解永远不触发」的真实缺陷:goal 第一轮现在作为合法任务入口参与自动分解;已有进行中计划时 goal 轮次绝不抢跑。**
|
|
4
|
+
|
|
5
|
+
### 一、问题与证据链
|
|
6
|
+
|
|
7
|
+
用户 2026-11-05 报告:使用官方 DeepSeek Harness 的「目标 goal」指令后,dsh-workplan 的自动任务分解似乎不会触发。核查代码后确认这不是猜测,而是一条可复现的契约缺口:
|
|
8
|
+
|
|
9
|
+
| # | 事实 | 证据位置 |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| 1 | `/goal <objective>` 命令只写 goal 领域状态,**不产生** `user/message` | `@deepseek-ai/dsh-command-goal` 的 `create` 分支 |
|
|
12
|
+
| 2 | goal 的自动续跑轮次由 round driver 以 `source.kind = "goal"` 的 user 消息送达,文本形如 `<goal_round>Objective: "…"</goal_round>` | `@deepseek-ai/dsh-goal-round-driver/lib/index.js` 的 `renderGoalRoundPrompt` 与 `createUserMessage` |
|
|
13
|
+
| 3 | 2.0.2 的 `humanMessages()` 只接受 `source.kind === 'user'` 或未标记的消息 | `src/runtime.ts#humanMessages` |
|
|
14
|
+
| 4 | `maybePlan()` 在 `human.length === 0` 时直接返回,不进入规划 | `src/runtime.ts#maybePlan` |
|
|
15
|
+
|
|
16
|
+
1+2+3+4 合并后的结论:如果任务是通过 `/goal` 设置的,整条 goal 生命周期内都不存在「人类消息」,插件永远不会自动分解该任务。人工消息路径(普通输入框任务)不受影响。
|
|
17
|
+
|
|
18
|
+
### 二、改了什么
|
|
19
|
+
|
|
20
|
+
- 新增 `goalRoundPlanningTask(ctx, payload, existing)`:只接受 `source.kind === 'goal'` 且 `round === 1` 的消息作为自动分解入口。
|
|
21
|
+
- `maybePlan()` 在没有任何人工消息时改走该入口;任务文本优先级为:`goals` 领域服务的结构化 `objective` → 从官方 `<goal_round>` 信封解析 JSON objective → 整条消息原文。
|
|
22
|
+
- 防抢跑:会话里存在进行中计划(`executing` / `paused` / `pending` / `verification` 等)时,goal 轮次直接放行不建计划;`done` / `ended` / `cancelled` / `superseded` / `degraded` / `clarify` 属于历史记录,不拦新任务。
|
|
23
|
+
- 人工消息路径、`humanMessages()` 的既有语义、执行中变更(changeRequest)与 replan 规则全部保持不变。
|
|
24
|
+
|
|
25
|
+
### 三、验证
|
|
26
|
+
|
|
27
|
+
- 新增 `tests/goal-round-planning.test.ts`:7 条断言覆盖 round 1/round 2、goals 服务优先、信封解析、无 objective 兜底、进行中计划防抢跑、历史终态放行。
|
|
28
|
+
- `npm test`:553 条用例全过;`npm run check`(tsc --noEmit)退出码 0。
|
|
29
|
+
- `npm run build` 重新生成 `lib/`、`dist/`、`client.js`,与 `src/` 同步。
|
|
30
|
+
|
|
31
|
+
### 四、发布
|
|
32
|
+
|
|
33
|
+
- npm:`dsh-workplan@2.0.3`
|
|
34
|
+
- GitHub Release:`v2.0.3`,附 `dsh-workplan-2.0.3.tgz` 制品
|
|
35
|
+
- 索引源(dsh-plugin-catalog 链路):条目 tarball 指向 `v2.0.3` Release,等待上游 CI 生成 catalog
|
|
36
|
+
|
|
1
37
|
## 2.0.2 — 2026-11-05
|
|
2
38
|
|
|
3
39
|
**更正「第一、二阶段禁用 dsh-workplan 插件」的适用范围:这条只适用于 2026-11-05 本次优化会话,不是对所有后续会话的永久产品规则。2.0.2 起,提示词、工具描述、README 与协作文档不再声明全局禁用;三阶段工作法与「验证工具缺前两阶段证据返回 PHASE_GATE」的证据门禁保持不变。**
|
package/README.en.md
CHANGED
|
@@ -80,7 +80,7 @@ The full contract — roles, data shapes, state machine, recovery, and the three
|
|
|
80
80
|
## Install
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
|
-
dsh plugin --profile web add dsh-workplan@2.0.
|
|
83
|
+
dsh plugin --profile web add dsh-workplan@2.0.3
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
Restart the DSH Web process (or reload the page) so the bundle is picked up.
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **两个卖点,一句话:ISO/IEC 15408:2026 全套安全证据,5 条命令自己验;安装一条命令、零第三方运行时依赖。**
|
|
4
4
|
|
|
5
5
|
[](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
|
|
6
|
-
[](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.0.3)
|
|
7
7
|
|
|
8
8
|
给 **DeepSeek Harness(DSH)** 加一段「先拆计划 → 真派部门子 Agent 去做 → 左侧栏实时看进度」的能力。不装 App、不改 DSH 源码、不换页面。
|
|
9
9
|
|
|
@@ -69,7 +69,7 @@ grep -RInE "child_process|execSync|eval\(|writeFileSync" src || echo "0 命中
|
|
|
69
69
|
## 一键安装
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
|
-
dsh plugin --profile web add dsh-workplan@2.0.
|
|
72
|
+
dsh plugin --profile web add dsh-workplan@2.0.3
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# dsh-workplan 2.0.2 发布记录(可复核)
|
|
2
|
+
|
|
3
|
+
- 发布时间:2026-11-05 13:45–14:10(Asia/Shanghai)
|
|
4
|
+
- 版本:**2.0.2**(`package.json` / `package-lock.json` 两处 / `src/host.ts#meta.version` / CHANGELOG / README 两份安装命令,由 `tests/version-sync.test.ts` 断言一致)
|
|
5
|
+
- 主题:更正「第一、二阶段禁用 dsh-workplan 插件」的适用范围——只适用于 2026-11-05 本次优化会话,不是对所有后续会话的永久产品规则
|
|
6
|
+
|
|
7
|
+
## 1. 为什么发 2.0.2
|
|
8
|
+
|
|
9
|
+
用户在 2.0.1 发布后澄清:原要求 4「第一、二阶段禁用 dsh-workplan 插件」是**本次会话内**对优化过程的约束,不是要求插件对所有未来会话禁用。1.13.0 起该条被写成产品级规则(子 Agent 提示词、`dsh_workplan_verify` 描述、运行时报错、README、协作文档),属于对需求范围的误读;2.0.2 全面更正措辞与说明,三阶段契约与自我学习机制不变。
|
|
10
|
+
|
|
11
|
+
## 2. 提交与 tag
|
|
12
|
+
|
|
13
|
+
| 项 | 值 |
|
|
14
|
+
|---|---|
|
|
15
|
+
| 发布提交 | `17707511cafe2a9772eb630d3d8ccce1c7a22ccd` |
|
|
16
|
+
| commit 标题 | `Release 2.0.2: 更正「第一、二阶段禁用插件」的适用范围(仅 2026-11-05 本次会话,非永久规则)` |
|
|
17
|
+
| tag | `v2.0.2`(annotated,tag 对象 `ae402a8441267983195257f35ecc30644a45d281`) |
|
|
18
|
+
| tag → 提交 | `git rev-list -n 1 v2.0.2` = `17707511cafe2a9772eb630d3d8ccce1c7a22ccd`(一致) |
|
|
19
|
+
| 远端 | `main` 已推送 `ccd362a..1770751`;`git ls-remote --tags origin v2.0.2` 返回 `refs/tags/v2.0.2` |
|
|
20
|
+
|
|
21
|
+
## 3. 干净克隆门禁(tag 构建)
|
|
22
|
+
|
|
23
|
+
在 `/tmp/dsh-workplan-release-2.0.2`(`git clone --depth 1 --branch v2.0.2`)执行:
|
|
24
|
+
|
|
25
|
+
| 命令 | 结果 |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `npm ci` | 退出 0 |
|
|
28
|
+
| `npm run check` | 退出 0(`tsc -p tsconfig.json --noEmit`) |
|
|
29
|
+
| `npm test` | **tests 546 / pass 546 / fail 0**,退出 0 |
|
|
30
|
+
| `npm pack` | `dsh-workplan-2.0.2.tgz`,**1,088,610 B**,sha256 `5e9dcc26a0e1ed204073ac0a1bf9ebc71b43403a1cd50a9ef68925999020f7f2` |
|
|
31
|
+
|
|
32
|
+
包清单 100 个文件;含 `lib/lessons.js`、`docs/release-notes-2.0.2.md`,`version` 为 2.0.2。
|
|
33
|
+
|
|
34
|
+
## 4. GitHub Release
|
|
35
|
+
|
|
36
|
+
- URL:https://github.com/abbaababa/dsh-workplan/releases/tag/v2.0.2
|
|
37
|
+
- 资产:`dsh-workplan-2.0.2.tgz`,state `uploaded`,1,088,610 B
|
|
38
|
+
- 资产 digest(GitHub API 返回):`sha256:5e9dcc26a0e1ed204073ac0a1bf9ebc71b43403a1cd50a9ef68925999020f7f2`(与本地 `shasum -a 256` 一致)
|
|
39
|
+
|
|
40
|
+
## 5. npm 发布
|
|
41
|
+
|
|
42
|
+
- 2026-11-05 14:02 在干净克隆执行 `npm publish`,输出 `+ dsh-workplan@2.0.2`;注册表提示进入处理队列。
|
|
43
|
+
- 复核口径:`npm view dsh-workplan dist-tags version` 与 `GET https://registry.npmjs.org/dsh-workplan/2.0.2` 双证据(2.0.1 的经验:处理需数分钟,期间重复投递会得到 E409)。
|
|
44
|
+
- 发布结果:**2026-11-05 14:08 注册表可见**——`npm view dsh-workplan dist-tags version` 返回 `{ latest: '2.0.2' }`,`GET https://registry.npmjs.org/dsh-workplan/2.0.2` 返回 200。
|
|
45
|
+
- 安装冒烟(npm 公开包):`/tmp/dsh-wp-install-2.0.2` 执行 `npm i dsh-workplan@2.0.2` 后核对——version 2.0.2、`lib/lessons.js` 存在、`lib/three-phase.js` 已不含「阶段一、二:dsh-workplan 插件禁用」、`PHASE_GATE` 与「缺少 planning / execution 证据时返回 PHASE_GATE」文案保留、注册工具 11 个。
|
|
46
|
+
|
|
47
|
+
## 6. 索引源(awesome-dsh-plugin)
|
|
48
|
+
|
|
49
|
+
| 项 | 值 |
|
|
50
|
+
|---|---|
|
|
51
|
+
| PR | https://github.com/awesome-dsh-plugin/awesome-dsh-plugin/pull/12201 |
|
|
52
|
+
| 条目提交 | `377bb700b49b7eb447270132540ea02f77bc1555` |
|
|
53
|
+
| 分支 | `abbaababa:bump-dsh-workplan-2.0.1`(PR 内已更新为 2.0.2) |
|
|
54
|
+
| 变更 | `data/plugins/abbaababa__dsh-workplan.yml` 的 `tarball` 指向 `v2.0.2` Release 资产 |
|
|
55
|
+
| 校验 | 条目 YAML 通过 `js-yaml` 解析;`tarball` 为 GitHub Release 托管 URL;`package.json` 声明 `dsh.bundle` |
|
|
56
|
+
|
|
57
|
+
## 7. 本次改了什么(可复核)
|
|
58
|
+
|
|
59
|
+
| 文件 | 变更 |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `src/three-phase.ts` | 提示词删除「阶段一、二:dsh-workplan 插件禁用」,改为「阶段一、二写全证据;调用 verify 会因缺少前两阶段证据返回 PHASE_GATE(证据门禁,不是禁用插件)」;头部注释同步 |
|
|
62
|
+
| `src/host.ts` | `dsh_workplan_verify` 描述由「阶段一、二禁用本插件」改为「缺少 planning / execution 证据时返回 PHASE_GATE 与待补项」 |
|
|
63
|
+
| `src/runtime.ts` | `PHASE_GATE` 报错文案由「插件在阶段一、二禁用」改为「阶段三核验缺少前两阶段证据」 |
|
|
64
|
+
| `README.md` / `README.en.md` | 增加 2.0.2 更正说明:该约束仅适用于本次会话;主 Agent 任何阶段都可用计划/派发/查询/改判工具 |
|
|
65
|
+
| `docs/collaboration.md`、`docs/cc/AVA-VULNERABILITY-ANALYSIS.md` | 表格与措辞由「禁用」改为「证据门禁」,并加 2.0.2 更正说明 |
|
|
66
|
+
| `tests/three-phase.test.ts` | 断言提示词不再包含「插件禁用」;同时继续断言阶段三门禁与 `PHASE_GATE` |
|
|
67
|
+
| `CHANGELOG.md`、`docs/release-notes-2.0.2.md` | 新增 2.0.2 条目与发布说明;2.0.1 条目加勘误 |
|
|
68
|
+
|
|
69
|
+
## 8. 未变的部分
|
|
70
|
+
|
|
71
|
+
- 三阶段「规划 → 执行 → 验证」仍是产品功能;完成判定仍要求 `phases` 齐全。
|
|
72
|
+
- `dsh_workplan_verify` 仍只接受三阶段齐全的证据;缺 planning/execution 仍返回 `PHASE_GATE`。
|
|
73
|
+
- 阶段三复盘与永久教训记忆机制完全不变;工具面仍是 11 个。
|
|
74
|
+
|
|
75
|
+
## 9. 复核附录
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# 版本与 tag
|
|
79
|
+
cd plugins/dsh-workplan && git rev-parse HEAD && git rev-list -n 1 v2.0.2
|
|
80
|
+
# 干净克隆门禁
|
|
81
|
+
git clone --depth 1 --branch v2.0.2 git@github.com:abbaababa/dsh-workplan.git /tmp/dsh-workplan-release-2.0.2
|
|
82
|
+
cd /tmp/dsh-workplan-release-2.0.2 && npm ci && npm run check && npm test && npm pack
|
|
83
|
+
# 发布核对
|
|
84
|
+
npm view dsh-workplan dist-tags version
|
|
85
|
+
gh api repos/abbaababa/dsh-workplan/releases/tags/v2.0.2 --jq '.assets[] | {name, size, state, digest}'
|
|
86
|
+
gh pr view 12201 --repo awesome-dsh-plugin/awesome-dsh-plugin
|
|
87
|
+
```
|
package/lib/host.js
CHANGED
|
@@ -1363,7 +1363,7 @@ export function apply(ctx, config = {}) {
|
|
|
1363
1363
|
}
|
|
1364
1364
|
export const meta = {
|
|
1365
1365
|
name,
|
|
1366
|
-
version: '2.0.
|
|
1366
|
+
version: '2.0.3',
|
|
1367
1367
|
promptOrder: PROMPT_ORDER,
|
|
1368
1368
|
routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
|
|
1369
1369
|
};
|
package/lib/runtime.js
CHANGED
|
@@ -184,6 +184,82 @@ function taskTextFromMessages(messages) {
|
|
|
184
184
|
}
|
|
185
185
|
return truncate(texts.join('\n\n'), 16000);
|
|
186
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* [2.0.3] `source.kind === 'goal'` 的轮次也是用户的真实任务。
|
|
189
|
+
*
|
|
190
|
+
* 官方 DeepSeek Harness 的 `/goal <objective>` 命令不会产生 `user/message`:
|
|
191
|
+
* 目标文本由 goal-round-driver 以 `source.kind = 'goal'`、`round >= 1` 的
|
|
192
|
+
* 用户消息送达(见 `@deepseek-ai/dsh-goal-round-driver` 的
|
|
193
|
+
* `renderGoalRoundPrompt` / `createUserMessage`)。旧版 `humanMessages()` 只认
|
|
194
|
+
* `source.kind` 为 `user` 或省略的消息,于是 `/goal` 任务在整条 goal 生命周期
|
|
195
|
+
* 内都拿不到任务文本,`maybePlan()` 永远不会触发自动分解。
|
|
196
|
+
*
|
|
197
|
+
* 这里只认每个 goal 的第一轮(`round === 1`),并且只在该会话没有进行中的
|
|
198
|
+
* 计划时放行:
|
|
199
|
+
* - `round === 1` 是目标进入本会话的唯一入口,后续轮次是同一目标的续跑,
|
|
200
|
+
* 不能重复建计划;
|
|
201
|
+
* - 已存在进行中/未派发计划时返回 undefined,避免 goal 轮次与人工计划互相
|
|
202
|
+
* 取消或误记成「执行中新增需求」。
|
|
203
|
+
*
|
|
204
|
+
* 任务文本优先取 goal 领域服务的结构化 objective(干净文本),取不到时再从
|
|
205
|
+
* `<goal_round>` 信封里解析 JSON objective,最后才退回整条消息文本。
|
|
206
|
+
*/
|
|
207
|
+
export function goalRoundPlanningTask(ctx, payload, existing) {
|
|
208
|
+
if (planRecordIsLive(existing))
|
|
209
|
+
return undefined;
|
|
210
|
+
const messages = Array.isArray(payload?.messages) ? payload.messages : [];
|
|
211
|
+
for (const message of messages) {
|
|
212
|
+
if (!message || message.role !== 'user')
|
|
213
|
+
continue;
|
|
214
|
+
const source = message.source ?? {};
|
|
215
|
+
if (source.kind !== 'goal')
|
|
216
|
+
continue;
|
|
217
|
+
if (Number(source.round) !== 1)
|
|
218
|
+
continue;
|
|
219
|
+
const raw = messageText(message).trim();
|
|
220
|
+
const text = goalObjectiveOf(ctx, payload.agent) || goalObjectiveFromText(raw) || raw;
|
|
221
|
+
if (!text)
|
|
222
|
+
continue;
|
|
223
|
+
return { text: truncate(text, 16000), goalId: String(source.goalId ?? ''), round: 1 };
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Whether an existing plan record still owns work in this session.
|
|
229
|
+
*
|
|
230
|
+
* `isTerminalPhase()` 只覆盖 cancelled/superseded(present 门禁的语义);
|
|
231
|
+
* 对 goal 轮次的入口判定,done/ended/degraded/clarify 同样是「这一轮可以
|
|
232
|
+
* 开始新计划」的历史记录,不能把 `/goal` 任务永久挡在自动分解之外。
|
|
233
|
+
*/
|
|
234
|
+
function planRecordIsLive(existing) {
|
|
235
|
+
if (!existing?.plan)
|
|
236
|
+
return false;
|
|
237
|
+
const phase = String(existing.phase ?? '');
|
|
238
|
+
return !['done', 'ended', 'cancelled', 'superseded', 'clarify', 'degraded'].includes(phase);
|
|
239
|
+
}
|
|
240
|
+
/** Read the structured objective of the current goal view, when the service exists. */
|
|
241
|
+
function goalObjectiveOf(ctx, agent) {
|
|
242
|
+
try {
|
|
243
|
+
const view = ctx?.get?.('goals')?.get?.(agent);
|
|
244
|
+
return typeof view?.objective === 'string' ? view.objective.trim() : '';
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return '';
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/** Parse `Objective: "<json string>"` out of the official `<goal_round>` envelope. */
|
|
251
|
+
export function goalObjectiveFromText(text) {
|
|
252
|
+
const match = /<goal_round>[\s\S]*?Objective:\s*("(?:[^"\\]|\\.)*")/.exec(String(text ?? ''));
|
|
253
|
+
if (!match)
|
|
254
|
+
return '';
|
|
255
|
+
try {
|
|
256
|
+
const value = JSON.parse(match[1]);
|
|
257
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return '';
|
|
261
|
+
}
|
|
262
|
+
}
|
|
187
263
|
/*
|
|
188
264
|
* Children start with zero parent context. Without recent turns they cannot
|
|
189
265
|
* resolve "B", "it", "the previous item", so they search blindly and time out.
|
|
@@ -5908,9 +5984,15 @@ async function maybePlan(ctx, state, payload, downstream, options) {
|
|
|
5908
5984
|
return downstream;
|
|
5909
5985
|
const planMode = isPlanModeActive(ctx, session);
|
|
5910
5986
|
const human = humanMessages(payload.messages);
|
|
5911
|
-
|
|
5987
|
+
const existing = state.records.get(session.id);
|
|
5988
|
+
/*
|
|
5989
|
+
* [2.0.3] `/goal` 任务没有 user/message,任务文本只以 `source.kind = 'goal'`
|
|
5990
|
+
* 的轮次消息出现。放宽入口,但只认第一轮且只在该会话没有进行中计划时放行。
|
|
5991
|
+
*/
|
|
5992
|
+
const goalTask = human.length === 0 ? goalRoundPlanningTask(ctx, payload, existing) : undefined;
|
|
5993
|
+
if (human.length === 0 && goalTask === undefined)
|
|
5912
5994
|
return downstream;
|
|
5913
|
-
const taskText = taskTextFromMessages(payload.messages);
|
|
5995
|
+
const taskText = goalTask?.text ?? taskTextFromMessages(payload.messages);
|
|
5914
5996
|
if (!taskText)
|
|
5915
5997
|
return downstream;
|
|
5916
5998
|
if (isSocialMessage(taskText))
|
|
@@ -5931,7 +6013,6 @@ async function maybePlan(ctx, state, payload, downstream, options) {
|
|
|
5931
6013
|
state.activeTurns = new Map();
|
|
5932
6014
|
state.activeTurns.set(session.id, Number(payload.turn ?? 0));
|
|
5933
6015
|
const conversationContext = recentConversation(session);
|
|
5934
|
-
const existing = state.records.get(session.id);
|
|
5935
6016
|
if (existing?.plan?.createdTurn === payload.turn)
|
|
5936
6017
|
return downstream;
|
|
5937
6018
|
/*
|
package/package.json
CHANGED
package/src/host.ts
CHANGED
|
@@ -1490,7 +1490,7 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
|
|
|
1490
1490
|
|
|
1491
1491
|
export const meta = {
|
|
1492
1492
|
name,
|
|
1493
|
-
version: '2.0.
|
|
1493
|
+
version: '2.0.3',
|
|
1494
1494
|
promptOrder: PROMPT_ORDER,
|
|
1495
1495
|
routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
|
|
1496
1496
|
}
|
package/src/runtime.ts
CHANGED
|
@@ -259,6 +259,77 @@ function taskTextFromMessages(messages: any) {
|
|
|
259
259
|
return truncate(texts.join('\n\n'), 16000)
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
/**
|
|
263
|
+
* [2.0.3] `source.kind === 'goal'` 的轮次也是用户的真实任务。
|
|
264
|
+
*
|
|
265
|
+
* 官方 DeepSeek Harness 的 `/goal <objective>` 命令不会产生 `user/message`:
|
|
266
|
+
* 目标文本由 goal-round-driver 以 `source.kind = 'goal'`、`round >= 1` 的
|
|
267
|
+
* 用户消息送达(见 `@deepseek-ai/dsh-goal-round-driver` 的
|
|
268
|
+
* `renderGoalRoundPrompt` / `createUserMessage`)。旧版 `humanMessages()` 只认
|
|
269
|
+
* `source.kind` 为 `user` 或省略的消息,于是 `/goal` 任务在整条 goal 生命周期
|
|
270
|
+
* 内都拿不到任务文本,`maybePlan()` 永远不会触发自动分解。
|
|
271
|
+
*
|
|
272
|
+
* 这里只认每个 goal 的第一轮(`round === 1`),并且只在该会话没有进行中的
|
|
273
|
+
* 计划时放行:
|
|
274
|
+
* - `round === 1` 是目标进入本会话的唯一入口,后续轮次是同一目标的续跑,
|
|
275
|
+
* 不能重复建计划;
|
|
276
|
+
* - 已存在进行中/未派发计划时返回 undefined,避免 goal 轮次与人工计划互相
|
|
277
|
+
* 取消或误记成「执行中新增需求」。
|
|
278
|
+
*
|
|
279
|
+
* 任务文本优先取 goal 领域服务的结构化 objective(干净文本),取不到时再从
|
|
280
|
+
* `<goal_round>` 信封里解析 JSON objective,最后才退回整条消息文本。
|
|
281
|
+
*/
|
|
282
|
+
export function goalRoundPlanningTask(ctx: any, payload: any, existing: any) {
|
|
283
|
+
if (planRecordIsLive(existing)) return undefined
|
|
284
|
+
const messages = Array.isArray(payload?.messages) ? payload.messages : []
|
|
285
|
+
for (const message of messages) {
|
|
286
|
+
if (!message || message.role !== 'user') continue
|
|
287
|
+
const source = message.source ?? {}
|
|
288
|
+
if (source.kind !== 'goal') continue
|
|
289
|
+
if (Number(source.round) !== 1) continue
|
|
290
|
+
const raw = messageText(message).trim()
|
|
291
|
+
const text = goalObjectiveOf(ctx, payload.agent) || goalObjectiveFromText(raw) || raw
|
|
292
|
+
if (!text) continue
|
|
293
|
+
return { text: truncate(text, 16000), goalId: String(source.goalId ?? ''), round: 1 }
|
|
294
|
+
}
|
|
295
|
+
return undefined
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Whether an existing plan record still owns work in this session.
|
|
300
|
+
*
|
|
301
|
+
* `isTerminalPhase()` 只覆盖 cancelled/superseded(present 门禁的语义);
|
|
302
|
+
* 对 goal 轮次的入口判定,done/ended/degraded/clarify 同样是「这一轮可以
|
|
303
|
+
* 开始新计划」的历史记录,不能把 `/goal` 任务永久挡在自动分解之外。
|
|
304
|
+
*/
|
|
305
|
+
function planRecordIsLive(existing: any) {
|
|
306
|
+
if (!existing?.plan) return false
|
|
307
|
+
const phase = String(existing.phase ?? '')
|
|
308
|
+
return !['done', 'ended', 'cancelled', 'superseded', 'clarify', 'degraded'].includes(phase)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Read the structured objective of the current goal view, when the service exists. */
|
|
312
|
+
function goalObjectiveOf(ctx: any, agent: any) {
|
|
313
|
+
try {
|
|
314
|
+
const view = ctx?.get?.('goals')?.get?.(agent)
|
|
315
|
+
return typeof view?.objective === 'string' ? view.objective.trim() : ''
|
|
316
|
+
} catch {
|
|
317
|
+
return ''
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** Parse `Objective: "<json string>"` out of the official `<goal_round>` envelope. */
|
|
322
|
+
export function goalObjectiveFromText(text: any) {
|
|
323
|
+
const match = /<goal_round>[\s\S]*?Objective:\s*("(?:[^"\\]|\\.)*")/.exec(String(text ?? ''))
|
|
324
|
+
if (!match) return ''
|
|
325
|
+
try {
|
|
326
|
+
const value = JSON.parse(match[1] as string)
|
|
327
|
+
return typeof value === 'string' ? value.trim() : ''
|
|
328
|
+
} catch {
|
|
329
|
+
return ''
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
262
333
|
/*
|
|
263
334
|
* Children start with zero parent context. Without recent turns they cannot
|
|
264
335
|
* resolve "B", "it", "the previous item", so they search blindly and time out.
|
|
@@ -5946,8 +6017,14 @@ async function maybePlan(ctx: any, state: any, payload: any, downstream: any, op
|
|
|
5946
6017
|
if (payload.step !== 1) return downstream
|
|
5947
6018
|
const planMode = isPlanModeActive(ctx, session)
|
|
5948
6019
|
const human = humanMessages(payload.messages)
|
|
5949
|
-
|
|
5950
|
-
|
|
6020
|
+
const existing = state.records.get(session.id)
|
|
6021
|
+
/*
|
|
6022
|
+
* [2.0.3] `/goal` 任务没有 user/message,任务文本只以 `source.kind = 'goal'`
|
|
6023
|
+
* 的轮次消息出现。放宽入口,但只认第一轮且只在该会话没有进行中计划时放行。
|
|
6024
|
+
*/
|
|
6025
|
+
const goalTask = human.length === 0 ? goalRoundPlanningTask(ctx, payload, existing) : undefined
|
|
6026
|
+
if (human.length === 0 && goalTask === undefined) return downstream
|
|
6027
|
+
const taskText = goalTask?.text ?? taskTextFromMessages(payload.messages)
|
|
5951
6028
|
if (!taskText) return downstream
|
|
5952
6029
|
if (isSocialMessage(taskText)) return downstream
|
|
5953
6030
|
if (isVagueContinuation(taskText)) return downstream
|
|
@@ -5963,7 +6040,6 @@ async function maybePlan(ctx: any, state: any, payload: any, downstream: any, op
|
|
|
5963
6040
|
if (!state.activeTurns) state.activeTurns = new Map()
|
|
5964
6041
|
state.activeTurns.set(session.id, Number(payload.turn ?? 0))
|
|
5965
6042
|
const conversationContext = recentConversation(session)
|
|
5966
|
-
const existing = state.records.get(session.id)
|
|
5967
6043
|
if (existing?.plan?.createdTurn === payload.turn) return downstream
|
|
5968
6044
|
/*
|
|
5969
6045
|
* [1.11.0] 执行中记录的变更,在本轮结束后仍然没有被 replan 落实时,必须
|