dsh-workplan 1.12.3 → 2.0.1
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 +67 -0
- package/README.en.md +17 -2
- package/README.md +41 -3
- package/docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md +3 -1
- package/docs/cc/AVA-VULNERABILITY-ANALYSIS.md +9 -0
- package/docs/cc/SECURITY-TARGET.md +3 -1
- package/docs/collaboration.md +27 -2
- package/docs/release-notes-2.0.1.md +56 -0
- package/lib/host.js +195 -2
- package/lib/lessons.js +378 -0
- package/lib/plan.js +37 -5
- package/lib/runtime.js +178 -2
- package/lib/three-phase.js +287 -0
- package/package.json +1 -1
- package/src/host.ts +202 -2
- package/src/lessons.ts +445 -0
- package/src/plan.ts +37 -4
- package/src/runtime.ts +184 -1
- package/src/three-phase.ts +342 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
+
## 2.0.1 — 2026-11-05
|
|
2
|
+
|
|
3
|
+
**新增「自我学习与自我迭代」:部门 Agent 每次完成工作后,必须在阶段三复盘本次全过程的问题、弯路、解决方式与防再犯规则;复盘通过后写入永久教训记忆文件,下次派发同类任务时自动注入提示词。同一类错误重复出现会累加次数并提前排序。三阶段工作法(1.13.0)保持「规划 → 执行 → 验证」不变,复盘是验证阶段收尾的必填项,不是第四个阶段。**
|
|
4
|
+
|
|
5
|
+
### 一、用户要求与本版实现逐条对照
|
|
6
|
+
|
|
7
|
+
| 用户要求(2026-11-05) | 本版实现 |
|
|
8
|
+
|---|---|
|
|
9
|
+
| 1. 增加自我学习和自我迭代能力 | 新增 `src/lessons.ts`(复盘校验、永久记忆读写、相关度排序、提示词注入)+ 运行时闭环(`src/runtime.ts#settleFromOutput` 完成即落盘);主 Agent 可用 `dsh_workplan_lessons` 只读复核 |
|
|
10
|
+
| 2. 每次完成工作后全面复盘问题/弯路/如何解决,并永久记住、不再重犯 | `phases.verification.retrospective` 四项(problems / detours / resolutions / prevention)成为完成判定的必填证据:缺项、太薄(问题/解决 <20 字、预防 <16 字)一律 `blocked/unverified`;通过后写入 `~/.dsh/workplan/lessons.jsonl`(可用 `DSH_WORKPLAN_LESSONS_FILE` 覆盖),下次派发自动注入最相关的 8 条 |
|
|
11
|
+
| 3. 全过程按规划 → 执行 → 验证三阶段 | 沿用 1.13.0 的 `phases.planning/execution/verification` 契约;复盘放进验证阶段收尾,阶段数仍是三个 |
|
|
12
|
+
| 4. 第一、二阶段禁用 dsh-workplan 插件 | 子 Agent 本就没有 update/replan/cancel/dispatch/status/instruct/handoff/followup 权限;`dsh_workplan_verify` 在缺 planning/execution 证据时返回 `PHASE_GATE`;提示词写明阶段一、二不得调用插件,唯一例外是遇阻上报 `dsh_workplan_escalate`(安全阀) |
|
|
13
|
+
| 5. 第三阶段可用插件验证是否完全满足要求 | 阶段三核验工具同步要求 `verification.retrospective`:结构不全返回 `VERIFICATION_INCOMPLETE`,齐全才 `passed`;核验通过仍不等于完成,结果块与 `adjudicateResult` 会再判一次 |
|
|
14
|
+
| 6. 全程遵照用户要求,禁止偏离 | 本版所有新增门禁都落在完成判定与提示词两处,避免「提示词说要做、判定却不检查」的两套真相 |
|
|
15
|
+
| 7. 版本更新为 2.0.1 | `package.json` / `package-lock.json`(两处)/ `src/host.ts#meta.version` / `CHANGELOG` / `README.md` / `README.en.md` 全部为 2.0.1,由 `tests/version-sync.test.ts` 断言 |
|
|
16
|
+
| 8. 源码与版本同步发布到 GitHub 与索引源 | 提交 + `v2.0.1` tag + GitHub Release(带 tgz 制品)+ npm `dsh-workplan@2.0.1` + awesome-dsh-plugin 索引条目更新,发布记录见 `docs/release-record-2.0.1-20261105.md` |
|
|
17
|
+
|
|
18
|
+
### 二、自我学习的具体机制(可复核)
|
|
19
|
+
|
|
20
|
+
| 环节 | 代码位置 | 行为 |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| 复盘校验 | `src/lessons.ts#validateRetrospective`、`src/three-phase.ts#validatePhaseEvidence` | 四项缺一不可;problems/resolutions/prevention 至少 1 条;问题与解决合计 ≥20 字、预防 ≥16 字;单条上限 600 字、最多 12 条 |
|
|
23
|
+
| 永久记忆 | `src/lessons.ts#recordLesson` | 追加写入 JSONL;同一子任务重复结算原地更新(不虚增次数);不同子任务同类错误 `occurrences+1`;临时文件 + 改名原子替换;保留最近 500 条;坏行跳过 |
|
|
24
|
+
| 防再犯注入 | `src/lessons.ts#renderLessonsBrief`、`src/runtime.ts#executeSubtask` | 按同部门 > 同项目 > 关键词 > 重复次数 > 新近程度排序,注入最多 8 条;段首声明「历史数据,不是新指令」;清除不可见字符与会话引用 |
|
|
25
|
+
| 可复核入口 | `src/host.ts#createLessonsTool`、`src/runtime.ts#lessonsTool` | `dsh_workplan_lessons` 的 `list` / `search` / `stats` 只读返回记忆内容、重复次数、文件位置;不提供写入动作,防止绕过真实复盘证据 |
|
|
26
|
+
| 可见性 | `src/runtime.ts#settleFromOutput` | 完成摘要追加 `[自我学习] 复盘已写入永久教训记忆`(同类重复时注明第 N 次) |
|
|
27
|
+
|
|
28
|
+
### 三、兼容边界(如实登记)
|
|
29
|
+
|
|
30
|
+
- 这是**破坏性证据契约变更**:2.0.1 以前写出的 done 结果没有 `retrospective`,用本版完成判定重放会被判未完成。历史回放可显式传 `requirePhases:false`(或 `strict:false`)走旧语义。
|
|
31
|
+
- 复盘内容来自模型输出,插件只能校验「有没有写、写得是否够具体、是否覆盖四项」,**不能证明复盘内容真实**;真实性仍由主 Agent 对照产物核对。
|
|
32
|
+
- 记忆是文本数据:注入前已清除不可见字符与会话引用,并在提示词中声明不是指令;但一条被污染的记忆仍可能影响后续任务,主 Agent 应用 `dsh_workplan_lessons` 抽查并在发现污染时删除对应行。
|
|
33
|
+
- 插件无法自动判断「有没有走弯路」,只能要求子 Agent 如实填写 `detours`;确实没有时允许空数组,避免为了过门禁编造弯路。
|
|
34
|
+
|
|
35
|
+
### 四、验证
|
|
36
|
+
|
|
37
|
+
- `npm run check`(tsc --noEmit)退出码 0。
|
|
38
|
+
- `npm test`:**546 条全过、0 失败**(基线 536 + 新增 10 条 `tests/self-learning.test.ts`);`npm run check`(tsc --noEmit)退出码 0。
|
|
39
|
+
- 新增 `tests/self-learning.test.ts`:复盘四项校验、完成判定缺复盘降级、提示词注入与复盘要求、落盘/去重/累加、坏行容错、相关度排序与统计、环境变量覆盖、指纹稳定。
|
|
40
|
+
- 工具面 fixture(`tests/fixtures/tool-surface.json`)与 `docs/cc` 同步到 11 个工具、2.0.1。
|
|
41
|
+
|
|
42
|
+
## 1.13.0 — 2026-11-05
|
|
43
|
+
|
|
44
|
+
**新增「三阶段工作法」:部门 Agent 收到工作后必须先规划、再执行、最后验证;阶段一、二不提供插件工作能力,阶段三才可用 `dsh_workplan_verify` 核验。完成判定新增三阶段证据门禁,缺段一律 blocked/unverified。**
|
|
45
|
+
|
|
46
|
+
### 一、改了什么
|
|
47
|
+
|
|
48
|
+
| 用户要求 | 本版实现 |
|
|
49
|
+
|---|---|
|
|
50
|
+
| 先全面梳理问题,再形成可执行思路,最后才动手 | `src/three-phase.ts#threePhasePromptLines` 写进每个子 Agent 提示词:阶段一先列事实/约束/未知/主要矛盾,再给步骤、产物、依赖、风险与验证方式,并明说「思路未形成前禁止动手」 |
|
|
51
|
+
| 全过程按规划→执行→验证三阶段 | 结果块新增必填 `phases`:planning(problemAnalysis/constraints/unknowns/approach)→ execution(steps/deviations)→ verification(allPassed/checks/requirementCheck);`src/three-phase.ts#validatePhaseEvidence` 校验顺序与完整性 |
|
|
52
|
+
| 阶段一、二禁用插件 | 子 Agent 本就没有 update/replan/cancel/dispatch/status/instruct/handoff/followup 权限;新增的 verify 工具在只交 planning/execution 时返回 `PHASE_GATE`;提示词同时写明阶段一、二不得调用插件。唯一保留的是遇阻上报 `dsh_workplan_escalate`(安全阀,不属于计划/执行/验证能力),否则子 Agent 受阻只能空转或编造 |
|
|
53
|
+
| 阶段三可用插件验证是否成功、是否满足全部要求 | 新增 `dsh_workplan_verify`(`src/host.ts#createVerifyTool`、`src/runtime.ts#verifySubtask`):提交三阶段证据,按计划验收表逐条核对结构与覆盖;核验通过也不等于完成,结果块仍须写同一份 phases,由 `adjudicateResult` 再判 |
|
|
54
|
+
| 完成判定必须挡住缺段 | `src/plan.ts#adjudicateResult` 对 done 默认 `requirePhases=true`:缺任一阶段、规划内容过薄(<40 字符)、`allPassed!==true`、验证条数少于验收数或未逐条对号、字段为空,一律 `blocked/unverified`,计划不可交付 |
|
|
55
|
+
|
|
56
|
+
### 二、验证
|
|
57
|
+
|
|
58
|
+
- `npm test`:**536 条全过、0 失败**(基线 523 + 新增 13 条 `tests/three-phase.test.ts`);`npm run check`(tsc --noEmit)退出码 0。
|
|
59
|
+
- 新增用例覆盖:提示词含三阶段与禁用、合法 phases 仍 structured、缺 planning/思路过薄/allPassed=false/漏验均被降级、`requirePhases:false` 历史回放兼容、verify 工具的 `PHASE_GATE` 与 `VERIFICATION_INCOMPLETE`。
|
|
60
|
+
- 工具面 fixture(`tests/fixtures/tool-surface.json`)与 docs/cc 同步到 10 个工具、1.13.0。
|
|
61
|
+
|
|
62
|
+
### 三、事实边界(如实登记)
|
|
63
|
+
|
|
64
|
+
- 插件无法观测模型内部「想了多久、按什么顺序想」,只能把顺序变成**可审计的完成证据**:没有 planning/execution 证据就不算完成;阶段三核验只在模型主动调用时发生。
|
|
65
|
+
- 阶段一、二禁止的是插件的工作能力(计划/执行/验证);`dsh_workplan_escalate` 是遇阻上报的安全通道,本版保留并在提示词中明确其例外身份。
|
|
66
|
+
- verify 只检查证据的结构与验收覆盖,不判断证据内容是否真实;真实性仍由主 Agent 核对产物与结果消息。
|
|
67
|
+
|
|
1
68
|
## 1.12.3 — 2026-11-04
|
|
2
69
|
|
|
3
70
|
**修好 MS2 20 条真实实跑暴露的四处缺陷:指代误拦(T05-08)、该问不问(T05-04/09/13/20)、未确认自行派发、法务召回缺失(T05-12)。默认行为变化:信息不足时不再生成计划、不再派发,改为向用户提问。**
|
package/README.en.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **Two selling points, one line: a full ISO/IEC 15408:2026 evidence pack you can verify with 5 commands, and a one-command install with zero runtime dependencies.**
|
|
4
4
|
|
|
5
5
|
[](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
|
|
6
|
-
[](https://github.com/abbaababa/dsh-workplan/releases/tag/v1.13.0)
|
|
7
7
|
|
|
8
8
|
Adds "plan first → dispatch real department subagents → watch progress in the sidebar" to **DeepSeek Harness (DSH)**. No app, no DSH source patch, no page replacement.
|
|
9
9
|
|
|
@@ -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@
|
|
83
|
+
dsh plugin --profile web add dsh-workplan@2.0.1
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
Restart the DSH Web process (or reload the page) so the bundle is picked up.
|
|
@@ -120,9 +120,24 @@ Every number is derived from the same task state — the panel can no longer cla
|
|
|
120
120
|
| `dsh_workplan_instruct` | The main agent answers an escalation and issues direction; if delivery fails the instruction is queued for the next activation. Ack checks at 60s/180s. |
|
|
121
121
|
| `dsh_workplan_handoff` | Resolve cross-department needs: `list` / `assign` / `resolve` / `close`. Unresolved needs block delivery; when the asking row is waiting for direction, `resolve` delivers the answer straight into the child session. |
|
|
122
122
|
| `dsh_workplan_followup` | Send a closing note to a direct child that was stopped by budget/timeout but already wrote its artifacts. |
|
|
123
|
+
| `dsh_workplan_verify` | Child agents submit their three-phase evidence for phase-3 (verification) checking; calls from phases 1–2 return `PHASE_GATE`. Passing verification is not completion — the completion gate re-checks the same evidence. |
|
|
124
|
+
| `dsh_workplan_lessons` | Read-only view of the permanent lesson memory: `list` / `search` / `stats`. Never changes plan state; used to audit what was remembered and which mistakes keep repeating. |
|
|
123
125
|
|
|
124
126
|
In **plan mode** the plan is shown for review and `dispatch` is explicitly refused with a reason.
|
|
125
127
|
|
|
128
|
+
## Three phases and self-learning (2.0.1)
|
|
129
|
+
|
|
130
|
+
Every department agent must work in order — **planning → execution → verification** — and completion requires structured evidence for all three phases. Phases 1 and 2 must not use the dsh-workplan plugin: children have no plan/dispatch/adjudication powers, and the phase-3 verify tool rejects calls that lack planning/execution evidence with `PHASE_GATE`. The only exception is the blocker escalation channel, which is a safety valve rather than a planning/execution/verification capability.
|
|
131
|
+
|
|
132
|
+
Phase 3 also requires a **retrospective** (`retrospective` inside `phases.verification`):
|
|
133
|
+
|
|
134
|
+
1. `problems` — every problem met in the process (symptom + root cause);
|
|
135
|
+
2. `detours` — wrong turns, rework, dead ends (empty array when genuinely none; do not invent);
|
|
136
|
+
3. `resolutions` — how those problems were finally solved;
|
|
137
|
+
4. `prevention` — executable "when X, first do Y" rules that stop the same mistake from happening again.
|
|
138
|
+
|
|
139
|
+
A passing retrospective is appended to the **permanent lesson memory** at `~/.dsh/workplan/lessons.jsonl` (override with `DSH_WORKPLAN_LESSONS_FILE`). Before each dispatch, the most relevant lessons are ranked by department, project, keyword overlap, recurrence count and recency, then injected into the child prompt (max 8), labelled explicitly as historical data rather than new instructions. A repeated mistake increments `occurrences` and moves up the ranking instead of creating a duplicate — that is the self-iteration loop. A corrupt line is skipped instead of poisoning the whole file; the store keeps the most recent 500 records and writes atomically.
|
|
140
|
+
|
|
126
141
|
## Budgets, timeouts, resumes
|
|
127
142
|
|
|
128
143
|
| Setting | Default | Environment variable |
|
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.1)
|
|
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@
|
|
72
|
+
dsh plugin --profile web add dsh-workplan@2.0.1
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
|
|
@@ -100,7 +100,7 @@ dsh plugin --profile web add "$(pwd)"
|
|
|
100
100
|
|
|
101
101
|
纯打招呼、道谢、问「做到哪了」不会触发拆解,不会平白多出一堆子 Agent。
|
|
102
102
|
|
|
103
|
-
##
|
|
103
|
+
## 十一个模型工具(你不用直接调用)
|
|
104
104
|
|
|
105
105
|
| 工具 | 作用 |
|
|
106
106
|
|---|---|
|
|
@@ -113,9 +113,47 @@ dsh plugin --profile web add "$(pwd)"
|
|
|
113
113
|
| `dsh_workplan_instruct` | 主 Agent 回答请示并下达指示;失败则挂起,子任务下次激活时注入。带 60s/180s 回执检查。 |
|
|
114
114
|
| `dsh_workplan_handoff` | 处置跨部门需求:`list` / `assign` / `resolve` / `close`。未处置会拦住交付;对「待指示」的行 `resolve` 会直接把答复投递给子会话。 |
|
|
115
115
|
| `dsh_workplan_followup` | 给预算/超时中止、但产物已落盘的直接子会话补一条收尾说明。 |
|
|
116
|
+
| `dsh_workplan_verify` | 子 Agent 在**阶段三(验证阶段)**提交三阶段证据做核验;阶段一、二调用会返回 `PHASE_GATE`。核验通过≠完成,最终仍由完成判定复核。 |
|
|
117
|
+
| `dsh_workplan_lessons` | 只读查看**永久教训记忆**:`list` / `search` / `stats`。它只读文件,不改计划状态;用来核对「到底记住了什么、哪些错误在重复发生」。 |
|
|
116
118
|
|
|
117
119
|
在 **plan 模式**下只会给你看计划,`dispatch` 会被明确拦下并说明原因,不会偷偷开跑。
|
|
118
120
|
|
|
121
|
+
## 三阶段工作法与自我学习(2.0.1 的核心)
|
|
122
|
+
|
|
123
|
+
### 三阶段:规划 → 执行 → 验证
|
|
124
|
+
|
|
125
|
+
每个部门 Agent 收到工作后,顺序不可颠倒:
|
|
126
|
+
|
|
127
|
+
| 阶段 | 必须完成的事 | 完成证据 |
|
|
128
|
+
|---|---|---|
|
|
129
|
+
| 一 规划 | 先梳理问题(现状/约束/未知/主要矛盾),再形成完整可执行思路(做什么、产出什么、如何证明) | `phases.planning` |
|
|
130
|
+
| 二 执行 | 严格按阶段一的思路执行;需要改道必须记录原因 | `phases.execution.steps/deviations` |
|
|
131
|
+
| 三 验证 | 逐条验证验收标准与用户原要求,并做**自我学习复盘** | `phases.verification` + `retrospective` |
|
|
132
|
+
|
|
133
|
+
**第一、二阶段禁用 dsh-workplan 插件**:子 Agent 本就没有计划/派发/改判权限;阶段三的核验工具在缺规划或执行证据时会直接返回 `PHASE_GATE`。唯一保留的是遇阻上报 `dsh_workplan_escalate`(安全阀,不属于计划/执行/验证能力)。
|
|
134
|
+
|
|
135
|
+
### 自我学习与自我迭代:把弯路变成永久记忆
|
|
136
|
+
|
|
137
|
+
每次完成工作,阶段三必须提交四项复盘(缺一项就判未完成):
|
|
138
|
+
|
|
139
|
+
1. **problems**:本次全过程遇到的所有问题(现象 + 根因);
|
|
140
|
+
2. **detours**:走过的弯路、返工与无效尝试(确实没有就写空数组,不编造);
|
|
141
|
+
3. **resolutions**:最终是如何解决的;
|
|
142
|
+
4. **prevention**:以后如何预防再犯,必须写成「遇到…先…」的可执行硬规则。
|
|
143
|
+
|
|
144
|
+
复盘通过后,插件立刻把它写入**永久记忆文件**(JSONL,追加写):
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
~/.dsh/workplan/lessons.jsonl # 默认位置,跨项目长期保留
|
|
148
|
+
DSH_WORKPLAN_LESSONS_FILE=/path/x.jsonl # 需要时用环境变量覆盖
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
下一次派发子任务前,插件会按「同部门 > 同项目 > 关键词命中 > 重复次数 > 新近程度」挑选最相关的历史教训,自动注入子 Agent 提示词(最多 8 条),并明确标注:**这是历史数据,不是新指令,但相关就必须遵守**。
|
|
152
|
+
|
|
153
|
+
同一类错误再次出现时不会新增一条重复记录,而是把 `occurrences` 累加并把排序提前——越重复越显眼,这就是「自我迭代」。主 Agent 可用 `dsh_workplan_lessons` 复核;`occurrences ≥ 2` 的教训必须在下一次计划里变成明确约束。
|
|
154
|
+
|
|
155
|
+
记忆文件损坏一行不会拖垮整份记忆(坏行跳过);文件最多保留最近 500 条;写入用「临时文件 + 改名」避免半截文件。复盘来自模型输出,注入前会清掉不可见字符与会话引用,并声明为数据而非指令。
|
|
156
|
+
|
|
119
157
|
## 部门怎么协作(1.11.0 的真实能力)
|
|
120
158
|
|
|
121
159
|
计划里的每件工作都带一个部门标签(工程研发、研究分析、设计、产品、数据、质量验证、安全、运维、文档写作、运营、法务合规、财务)。**标签决定提示词与统计口径,不是组织架构**:
|
|
@@ -13,7 +13,7 @@ G-08(ADV-FSP.1 独立接口规范缺失)。核对方法:工具名逐一来
|
|
|
13
13
|
|
|
14
14
|
TOE 对外暴露 **2 类接口**:9 个 Agent 工具(宿主注入给模型调用)+ 1 个本地 HTTP 路由(面板数据源)。
|
|
15
15
|
|
|
16
|
-
### 1.1 Agent 工具(
|
|
16
|
+
### 1.1 Agent 工具(11 个)/ Agent tools
|
|
17
17
|
|
|
18
18
|
| # | 工具 | 调用者 | 用途(一句话) | 关键参数 | 失败/拒绝行为 |
|
|
19
19
|
|---|---|---|---|---|---|
|
|
@@ -26,6 +26,8 @@ TOE 对外暴露 **2 类接口**:9 个 Agent 工具(宿主注入给模型调
|
|
|
26
26
|
| 7 | `dsh_workplan_instruct` | 主 Agent | 向「待指示」子任务下发决定 | `subtaskId`, `instruction` | 仅接受 `closure=escalated` 的行 |
|
|
27
27
|
| 8 | `dsh_workplan_escalate` | 子 Agent | 子任务遇阻上报请示 | `question`, `options?`, `needs?` | 调用后子任务置「待指示」 |
|
|
28
28
|
| 9 | `dsh_workplan_handoff` | 主 Agent(仅根会话) | 处置跨部门需求 | `action: list/assign/resolve/close` | 非根会话拒绝 |
|
|
29
|
+
| 10 | `dsh_workplan_verify` | 子 Agent(阶段三) | 核验三阶段证据与验收覆盖 | `phases`(planning/execution/verification) | 阶段一/二返回 `PHASE_GATE`;证据缺口返回 `VERIFICATION_INCOMPLETE`;核验通过不等于完成 |
|
|
30
|
+
| 11 | `dsh_workplan_lessons` | 根会话 / 子 Agent(只读) | 查看永久教训记忆(`list` / `search` / `stats`) | `action`、`department`、`query`、`limit` | 只读,不写计划状态、不提供写入动作;记忆只能由阶段三复盘通过后的完成判定写入 |
|
|
29
31
|
|
|
30
32
|
### 1.2 HTTP 路由(1 个)/ HTTP route
|
|
31
33
|
|
|
@@ -111,3 +111,12 @@ npm run verify
|
|
|
111
111
|
| AS-10 | `dsh_workplan_escalate` | question/options | 子 Agent 借请示把决策推给主会话、空转 | 调用后子任务置「待指示」并停止推进,由主 Agent 决定;`workplan-pending-diagnosis` 等回归 |
|
|
112
112
|
|
|
113
113
|
新增接口的完整参数/失败行为见 `docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md`。本节不改 §1 方法与「未做」声明:仍未做渗透测试、模糊测试与形式化分析;AVA_VAN.2+ 需外部实验室,为固有残留、如实披露。
|
|
114
|
+
|
|
115
|
+
## 9. v1.13.0 / v2.0.1 攻击面增量(三阶段核验与教训记忆)
|
|
116
|
+
|
|
117
|
+
1.13.0 新增 1 个工具入口 `dsh_workplan_verify`,只对子 Agent 开放,用于阶段三核验。攻击面评估:
|
|
118
|
+
|
|
119
|
+
| # | 新增入口 | 输入可控点 | 潜在滥用 | 对策(实测) |
|
|
120
|
+
|---|---|---|---|---|
|
|
121
|
+
| AS-11 | `dsh_workplan_verify` | `phases`(嵌套对象,受字段长度/条数/总长上限)、`acceptance` | 子 Agent 伪造「全部通过」的验证证据骗过核验;把核验通过当成完成许可;阶段一/二提前调用规避禁用 | 核验只做结构与验收覆盖检查,**不是完成判定**;完成仍由 `adjudicateResult` 对同一份证据再判;只交 planning/execution 时返回 `PHASE_GATE`;`MAX_PHASE_*` 限制输入规模;`tests/three-phase.test.ts` 覆盖 |
|
|
122
|
+
| AS-12 | `dsh_workplan_lessons` | `action`(枚举)、`department`、`query`(≤ 原文长度)、`limit`(1–50) | 读取教训记忆探测其他项目的内部信息;用被污染的教训做提示词注入;把只读工具当成写入通道 | 只读、无写入动作;注入前清除不可见字符与会话引用并在提示词中声明为历史数据;返回条数受 `limit` 限制;`tests/self-learning.test.ts` 覆盖 |
|
|
@@ -73,8 +73,10 @@
|
|
|
73
73
|
| `dsh_workplan_escalate` | 模型工具 | 双向 | 子 Agent 遇阻上报,子任务置「待指示」 |
|
|
74
74
|
| `dsh_workplan_instruct` | 模型工具 | 双向 | 仅对「待指示」行下发主 Agent 决定并恢复执行 |
|
|
75
75
|
| `dsh_workplan_handoff` | 模型工具 | 双向 | 跨部门需求处置;仅根会话可用 |
|
|
76
|
+
| `dsh_workplan_verify` | 模型工具 | 双向 | 子 Agent 在阶段三提交三阶段证据做核验;阶段一/二返回 `PHASE_GATE` |
|
|
77
|
+
| `dsh_workplan_lessons` | 模型工具 | 读出 | 只读查看永久教训记忆(list/search/stats);不写计划状态 |
|
|
76
78
|
|
|
77
|
-
(1.9–
|
|
79
|
+
(1.9–2.0 新增 7 个工具(含 1.13.0 的三阶段核验与 2.0.1 的教训记忆)与取代/重规划能力;接口参数与失败行为完整枚举见 `docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md`。)
|
|
78
80
|
|
|
79
81
|
**不在 TOE 内**:DSH 本体(身份认证、会话存储、模型推理)、Node.js 运行时、操作系统、浏览器。
|
|
80
82
|
|
package/docs/collaboration.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
> 这份文档回答四个问题:**谁把什么写给谁、什么时候算完成、失败后谁接手、改代码时哪些地方必须一起改。**
|
|
4
4
|
>
|
|
5
|
-
> 适用版本:**
|
|
5
|
+
> 适用版本:**2.0.1**。文中每一项能力都已落到代码与测试;标注「未处理」的是明确不做、留待后续版本的范围,不要当现状。
|
|
6
6
|
>
|
|
7
|
-
<!-- [D-45] 本文版本与实现口径已对齐
|
|
7
|
+
<!-- [D-45] 本文版本与实现口径已对齐 2.0.1;核对项:权限 7 处、present 仅根会话、下游可读 artifacts、三阶段证据门禁、复盘永久记忆。 -->
|
|
8
8
|
|
|
9
9
|
> 约定:本文只用「文件 + 符号名」定位代码(例如 `src/plan.ts#buildChildPrompt`),**不写行号**,避免代码改动后文档漂移。核对命令见 §11。
|
|
10
10
|
|
|
@@ -253,6 +253,7 @@ pending ──dispatch──▶ executing ──全部 done──▶ done
|
|
|
253
253
|
子 Agent 必须用**自由文本**汇报,并满足:
|
|
254
254
|
|
|
255
255
|
- 优先在输出末尾追加结构化证据块(`<!-- WORKPLAN_EVIDENCE:START -->` … JSON … `<!-- WORKPLAN_EVIDENCE:END -->`),含 `status` / `blockedReason` / `acceptance[]` / `artifacts[]` / `needs[]`。这是 1.11.0 起的完成判据:`partial`、任一验收 `fail`、坏块都判受阻,只有全 `pass` 直接采信。
|
|
256
|
+
- **1.13.0 起,证据块还必须含 `phases`**(`planning` / `execution` / `verification`):缺任一阶段、规划内容过薄、`allPassed!==true`、验证条数少于验收数或未逐条对号,即使 `status:"done"` 也判 `blocked/unverified`。阶段一、二禁用插件;阶段三可用 `dsh_workplan_verify` 预核验,但核验通过不等于完成。
|
|
256
257
|
- 没有证据块时,失败仍可**第一行**写 `BLOCKED: 原因`(大小写不敏感,中英文冒号都认,行首允许空白)——按 `legacy` 判受阻。
|
|
257
258
|
- **1.11.0 起,没有证据块、也没有 `BLOCKED` 的「纯散文」不再算完成**:默认(`strictCompletion`,可用 `DSH_WORKPLAN_STRICT_COMPLETION=0` 关闭)判 `blocked` + `unverified`,错误信息写明「结果块缺失,无法确认验收项是否真的通过」。历史回放仍按 `legacy` 读取,避免旧计划整体失效。
|
|
258
259
|
- 验收条目自称 `pass` 但 `evidence` 为空时,1.11.0 降级为 `unverified`,且 `deliveryReadiness` 增加「验收自称通过但没有证据」阻塞项。
|
|
@@ -435,6 +436,8 @@ npm run verify
|
|
|
435
436
|
| 子 Agent 不能 dispatch/update/cancel | `src/runtime.ts#dispatchTool`、`#updateStatus`、`#cancelPlan` 的 `isRootSession` |
|
|
436
437
|
| 阶段只是分组 | `src/plan.ts#readySubtasks` 上方注释与实现 |
|
|
437
438
|
| 证据块决定完成/受阻,非空文本不再直接算完成 | `src/plan.ts#adjudicateResult`、`#parseEvidenceBlock` |
|
|
439
|
+
| 完成必须带规划→执行→验证三段证据,缺段降级 | `src/plan.ts#adjudicateResult`、`src/three-phase.ts#validatePhaseEvidence` |
|
|
440
|
+
| 阶段三才可核验,阶段一/二返回 PHASE_GATE | `src/runtime.ts#verifySubtask`、`src/host.ts#createVerifyTool` |
|
|
438
441
|
| 依赖同时看状态与产物 | `src/plan.ts#readySubtasks` 的 `dependencyOk`、`src/runtime.ts#checkArtifacts` |
|
|
439
442
|
| 派发支持 wait/async 且可汇合 | `src/runtime.ts#dispatchTool` 的 `mode` 与 `dispatchPromise` 分支 |
|
|
440
443
|
| 运行中 update 默认被拒 | `src/runtime.ts#updateStatus` 的 `TASK_RUNNING` 分支 |
|
|
@@ -452,3 +455,25 @@ npm run verify
|
|
|
452
455
|
- [1.6.0 会话终止收敛](../CHANGELOG.md)
|
|
453
456
|
- [安装与使用说明](../README.md) / [English](../README.en.md)
|
|
454
457
|
- T5 优化方案与验收标准:`deliverables/workplan/T5_优化方案与验收标准_20261030.md`
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
461
|
+
## 13. 三阶段工作法(1.13.0 起,2.0.1 增补复盘,用户强制要求)
|
|
462
|
+
|
|
463
|
+
部门 Agent 收到子任务后,必须按顺序完成三个阶段;阶段不可颠倒、不可跳过。
|
|
464
|
+
|
|
465
|
+
| 阶段 | 必须做什么 | 结果块证据(`phases`) | 插件是否可用 |
|
|
466
|
+
|---|---|---|---|
|
|
467
|
+
| 一 规划 | 先全面梳理问题:现状与事实、约束、未知、主要矛盾、边界;再形成完整可执行思路:步骤、产物、依赖、风险、验证方式 | `planning.problemAnalysis` / `planning.constraints` / `planning.unknowns` / `planning.approach` | **禁用** |
|
|
468
|
+
| 二 执行 | 严格按阶段一的思路执行;任何偏离都必须记录原因与证据 | `execution.steps` / `execution.deviations` | **禁用** |
|
|
469
|
+
| 三 验证 | 逐条验证验收标准与用户原要求,全部通过才可报 done | `verification.allPassed` / `verification.checks` / `verification.requirementCheck` | 可用 `dsh_workplan_verify` |
|
|
470
|
+
|
|
471
|
+
完成判定:`src/plan.ts#adjudicateResult` 对 `status:'done'` 强制校验 `phases`;缺任一阶段、规划内容过薄、`allPassed!==true`、验证记录少于验收标准数或未逐条对号、字段为空,一律判 `blocked/unverified`,计划不能交付。
|
|
472
|
+
|
|
473
|
+
唯一保留的插件通道:遇阻上报 `dsh_workplan_escalate`。它不是计划/执行/验证能力,而是安全阀;否则子 Agent 在阶段一/二受阻时只能空转或编造。
|
|
474
|
+
|
|
475
|
+
核验工具:`dsh_workplan_verify` 只接受阶段三调用;缺 planning/execution 时返回 `PHASE_GATE`(插件在阶段一、二禁用)。核验通过不等于完成——结果块仍须写同一份 `phases`,由完成判定再判一次。
|
|
476
|
+
|
|
477
|
+
**2.0.1 起,`phases.verification.retrospective` 也是必填**(`problems` / `detours` / `resolutions` / `prevention`,见 `src/lessons.ts#validateRetrospective`):缺项或太薄判 `blocked/unverified`;通过后写入永久记忆 `~/.dsh/workplan/lessons.jsonl`,下次派发同类任务时自动注入最相关的历史教训。主 Agent 可用只读工具 `dsh_workplan_lessons` 复核。
|
|
478
|
+
|
|
479
|
+
代码位置:提示词 `src/plan.ts#buildChildPrompt` 调用 `src/three-phase.ts#threePhasePromptLines`;校验 `src/three-phase.ts#validatePhaseEvidence` 与 `src/plan.ts#adjudicateResult`;核验工具 `src/host.ts#createVerifyTool` / `src/runtime.ts#verifySubtask`;回归 `tests/three-phase.test.ts`。
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# dsh-workplan 2.0.1 — 自我学习与自我迭代
|
|
2
|
+
|
|
3
|
+
发布日期:2026-11-05(Asia/Shanghai)
|
|
4
|
+
|
|
5
|
+
## 一句话
|
|
6
|
+
|
|
7
|
+
部门 Agent 每次完成工作后必须复盘(问题 / 弯路 / 解决 / 防再犯),复盘写入永久记忆文件;下次派发同类任务时自动注入历史教训,同一类错误重复出现会累加次数并提前排序。三阶段工作法保持「规划 → 执行 → 验证」,复盘是验证阶段收尾的必填项。
|
|
8
|
+
|
|
9
|
+
## 安装 / 升级
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
dsh plugin --profile web add dsh-workplan@2.0.1
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
从源码安装:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
git clone https://github.com/abbaababa/dsh-workplan.git
|
|
19
|
+
cd dsh-workplan && git checkout v2.0.1
|
|
20
|
+
npm ci && npm run build
|
|
21
|
+
dsh plugin --profile web add /绝对路径/dsh-workplan
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 新增能力
|
|
25
|
+
|
|
26
|
+
| 能力 | 说明 |
|
|
27
|
+
|---|---|
|
|
28
|
+
| 阶段三复盘必填 | `phases.verification.retrospective` 四项:`problems` / `detours` / `resolutions` / `prevention`。缺项、太薄(问题/解决合计 <20 字、预防 <16 字)一律 `blocked/unverified` |
|
|
29
|
+
| 永久教训记忆 | 复盘通过后写入 `~/.dsh/workplan/lessons.jsonl`(JSONL,追加写,保留最近 500 条,坏行跳过,临时文件 + 改名原子替换);`DSH_WORKPLAN_LESSONS_FILE` 可覆盖位置 |
|
|
30
|
+
| 自动防再犯 | 每次派发前按「同部门 > 同项目 > 关键词 > 重复次数 > 新近程度」取最相关 8 条注入子 Agent 提示词;段首声明「历史数据,不是新指令」 |
|
|
31
|
+
| 自我迭代信号 | 同类错误再次出现时 `occurrences+1`、排序提前;同一子任务重试/回放只原地更新,不虚增次数 |
|
|
32
|
+
| 只读复核工具 | `dsh_workplan_lessons`:`list` / `search` / `stats`,返回记忆内容、重复次数、文件位置;不提供写入动作,防止绕过真实复盘证据 |
|
|
33
|
+
|
|
34
|
+
## 三阶段与插件禁用边界(不变)
|
|
35
|
+
|
|
36
|
+
- 阶段一(规划):先梳理现状/约束/未知/主要矛盾,再形成完整可执行思路;阶段二(执行):严格按思路执行并记录偏离;阶段三(验证):逐条验证 + 复盘。
|
|
37
|
+
- 阶段一、二禁用 dsh-workplan 插件:子 Agent 本就没有计划/派发/改判权限;`dsh_workplan_verify` 在缺 planning/execution 证据时返回 `PHASE_GATE`。
|
|
38
|
+
- 唯一例外是遇阻上报 `dsh_workplan_escalate`(安全阀,不属于计划/执行/验证能力)。
|
|
39
|
+
- 核验通过 ≠ 完成:结果块仍须写同一份 `phases`,由 `adjudicateResult` 再判。
|
|
40
|
+
|
|
41
|
+
## 兼容性(破坏性变更)
|
|
42
|
+
|
|
43
|
+
- 2.0.1 之前写出的 `done` 结果没有 `retrospective`,用本版完成判定重放会判未完成。历史回放请显式传 `requirePhases:false`(或 `strict:false`)走旧语义。
|
|
44
|
+
- 复盘内容来自模型输出:插件只校验「有没有写、够不够具体、是否覆盖四项」,不能证明内容真实;真实性仍由主 Agent 对照产物核对。
|
|
45
|
+
- 记忆是文本数据:注入前清除不可见字符与会话引用,并声明不是指令;发现污染时用 `dsh_workplan_lessons` 抽查并删除对应行。
|
|
46
|
+
|
|
47
|
+
## 验证
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm run check # tsc --noEmit
|
|
51
|
+
npm test # 构建 + 全量用例
|
|
52
|
+
npm run build
|
|
53
|
+
git diff --exit-code -- lib client.js # 构建产物可复现
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
发布记录(提交、tag、Release 资产哈希、npm 完整性、索引源 PR)见 `docs/release-record-2.0.1-20261105.md`。
|
package/lib/host.js
CHANGED
|
@@ -117,6 +117,14 @@ const PROMPT_SECTION = [
|
|
|
117
117
|
'子 Agent 通过 `needs` 提出的跨部门需求会列在结果消息的「跨部门待转达」里,并自动登记为待处理需求、计入交付门禁:用 `dsh_workplan_handoff` 逐条处置(list 查看、assign 登记责任部门、resolve 写入答复或产物引用、close 判定无需动作),不要忽略。注意:assign 不产生工作(没有常驻部门代理),需要产出就用 `dsh_workplan_replan(action=add)` 建该部门的子任务或自己完成;对「待指示」的行 resolve 会直接把答复投递给子会话。每条需求都必须有处置结论,否则 present 会被拒绝。',
|
|
118
118
|
'长任务可以用 `dsh_workplan_dispatch({ mode: "async" })` 先开跑并立即答复用户,再用 `dsh_workplan_status` 查看进度;async 返回的是“已开跑”,不是“已完成”。',
|
|
119
119
|
'如果自动分解降级,先向用户说明失败原因并询问是否重试,在用户确认前不要开始执行任务。',
|
|
120
|
+
/*
|
|
121
|
+
* [2.0.0] 自我学习与自我迭代(用户 2026-11-05 强制要求)。
|
|
122
|
+
*
|
|
123
|
+
* 部门 Agent 在阶段三必须复盘并落盘为永久记忆;这条提示词让主 Agent 知道
|
|
124
|
+
* 记忆存在、存在哪里、怎么复核,而不是把「会学习」当成不可见的口号。
|
|
125
|
+
*/
|
|
126
|
+
'每个部门完成工作后,必须在阶段三提交复盘(问题 / 弯路 / 解决 / 防再犯规则),插件会自动把它写入永久教训记忆文件(默认 ~/.dsh/workplan/lessons.jsonl,可用 DSH_WORKPLAN_LESSONS_FILE 覆盖);下次派发同类子任务时,相关历史教训会自动出现在子 Agent 提示词里。',
|
|
127
|
+
'需要复核「到底记住了什么、哪些错误在重复发生」时,调用 `dsh_workplan_lessons`(action: list / search / stats)。它是只读工具;记忆里反复出现的教训(occurrences ≥ 2)必须在下一次计划里变成明确约束,不能让同类错误第三次发生。',
|
|
120
128
|
].join('\n');
|
|
121
129
|
/**
|
|
122
130
|
* Seconds a dispatch has been running, from the payload only.
|
|
@@ -630,6 +638,187 @@ function createEscalateTool(runtime) {
|
|
|
630
638
|
},
|
|
631
639
|
};
|
|
632
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* [1.13.0] 阶段三(验证阶段)的插件核验工具(用户 2026-11-05)。
|
|
643
|
+
*
|
|
644
|
+
* 用户规则:部门 Agent 收到工作后必须先梳理问题、再形成可执行思路、最后
|
|
645
|
+
* 执行与验证;第一、二阶段禁用 dsh-workplan 插件,第三阶段才可以用插件
|
|
646
|
+
* 验证是否成功、是否完全满足要求。
|
|
647
|
+
*
|
|
648
|
+
* 因此这个工具只做一件事:接收三阶段证据并给出核验结论。阶段一/二的调用
|
|
649
|
+
* 会被 `runtime.verifySubtask` 以 `PHASE_GATE` 拒绝(缺 planning/execution
|
|
650
|
+
* 证据),不会替子 Agent 跳过梳理与规划。
|
|
651
|
+
*/
|
|
652
|
+
export function createVerifyTool(runtime) {
|
|
653
|
+
return {
|
|
654
|
+
name: 'dsh_workplan_verify',
|
|
655
|
+
description: '部门子 Agent 在第三阶段(验证阶段)使用的插件核验:提交 planning / execution / verification 三阶段证据,'
|
|
656
|
+
+ '插件逐项核验并返回 passed 或仍需补齐的 gaps。阶段一、二禁用本插件,调用会返回 PHASE_GATE;'
|
|
657
|
+
+ '只有「问题梳理 + 可执行思路 + 实际执行步骤」齐全后,才会进入阶段三核验。'
|
|
658
|
+
+ '核验通过不代表完成:最终仍要在结果块里写同一份 phases,由主计划按三阶段契约判定。',
|
|
659
|
+
parameters: {
|
|
660
|
+
type: 'object',
|
|
661
|
+
properties: {
|
|
662
|
+
subtaskId: {
|
|
663
|
+
type: 'string',
|
|
664
|
+
description: '你的子任务 ID(仅用于回显核对;服务端按父子会话关系反查,自报值不作为定位依据)。',
|
|
665
|
+
},
|
|
666
|
+
phases: {
|
|
667
|
+
type: 'object',
|
|
668
|
+
description: '三阶段证据:planning(问题梳理 + 可执行思路)、execution(执行步骤)、verification(逐项验证)。',
|
|
669
|
+
properties: {
|
|
670
|
+
planning: {
|
|
671
|
+
type: 'object',
|
|
672
|
+
properties: {
|
|
673
|
+
problemAnalysis: { type: 'array', items: { type: 'string' }, description: '要解决的问题逐条梳理(现状/事实/约束/未知/主要矛盾/边界)' },
|
|
674
|
+
constraints: { type: 'array', items: { type: 'string' }, description: '约束条件' },
|
|
675
|
+
unknowns: { type: 'array', items: { type: 'string' }, description: '未知或待确认项' },
|
|
676
|
+
approach: { type: 'array', items: { type: 'string' }, description: '完整可执行的思路:每一步做什么、产出什么、如何证明' },
|
|
677
|
+
},
|
|
678
|
+
required: ['problemAnalysis', 'approach'],
|
|
679
|
+
},
|
|
680
|
+
execution: {
|
|
681
|
+
type: 'object',
|
|
682
|
+
properties: {
|
|
683
|
+
steps: { type: 'array', items: { type: 'string' }, description: '实际执行的步骤' },
|
|
684
|
+
deviations: { type: 'array', items: { type: 'string' }, description: '偏离原思路的地方与原因' },
|
|
685
|
+
},
|
|
686
|
+
required: ['steps'],
|
|
687
|
+
},
|
|
688
|
+
verification: {
|
|
689
|
+
type: 'object',
|
|
690
|
+
properties: {
|
|
691
|
+
allPassed: { type: 'boolean', description: '是否全部验证通过;未全部通过必须为 false' },
|
|
692
|
+
checks: {
|
|
693
|
+
type: 'array',
|
|
694
|
+
items: {
|
|
695
|
+
type: 'object',
|
|
696
|
+
properties: {
|
|
697
|
+
criterion: { type: 'string', description: '对应的验收标准(A1/A2…)' },
|
|
698
|
+
method: { type: 'string', description: '用什么方式验证' },
|
|
699
|
+
evidence: { type: 'string', description: '命令输出/文件/引用' },
|
|
700
|
+
},
|
|
701
|
+
required: ['criterion', 'method', 'evidence'],
|
|
702
|
+
},
|
|
703
|
+
},
|
|
704
|
+
requirementCheck: { type: 'string', description: '逐条核对用户原要求的结果' },
|
|
705
|
+
retrospective: {
|
|
706
|
+
type: 'object',
|
|
707
|
+
description: '阶段三收尾的自我学习复盘:本次遇到的问题、走过的弯路、如何解决、以后如何预防再犯',
|
|
708
|
+
properties: {
|
|
709
|
+
problems: { type: 'array', items: { type: 'string' }, description: '本次全过程遇到的问题(现象 + 根因),至少 1 条' },
|
|
710
|
+
detours: { type: 'array', items: { type: 'string' }, description: '走过的弯路/返工/无效尝试;确实没有就写空数组' },
|
|
711
|
+
resolutions: { type: 'array', items: { type: 'string' }, description: '最终是如何解决的,至少 1 条' },
|
|
712
|
+
prevention: { type: 'array', items: { type: 'string' }, description: '以后如何预防再犯(遇到…先…),至少 1 条' },
|
|
713
|
+
},
|
|
714
|
+
required: ['problems', 'detours', 'resolutions', 'prevention'],
|
|
715
|
+
},
|
|
716
|
+
},
|
|
717
|
+
required: ['allPassed', 'checks', 'retrospective'],
|
|
718
|
+
},
|
|
719
|
+
},
|
|
720
|
+
required: ['planning', 'execution', 'verification'],
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
required: ['phases'],
|
|
724
|
+
additionalProperties: false,
|
|
725
|
+
},
|
|
726
|
+
output: {
|
|
727
|
+
schema: {
|
|
728
|
+
type: 'object',
|
|
729
|
+
properties: {
|
|
730
|
+
ok: { type: 'boolean' },
|
|
731
|
+
passed: { type: 'boolean' },
|
|
732
|
+
phase: { type: 'string' },
|
|
733
|
+
planId: { type: 'string' },
|
|
734
|
+
subtaskId: { type: 'string' },
|
|
735
|
+
summary: { type: 'string' },
|
|
736
|
+
gaps: { type: 'array', items: { type: 'string' } },
|
|
737
|
+
code: { type: 'string' },
|
|
738
|
+
error: { type: 'string' },
|
|
739
|
+
message: { type: 'string' },
|
|
740
|
+
},
|
|
741
|
+
required: ['ok'],
|
|
742
|
+
additionalProperties: true,
|
|
743
|
+
},
|
|
744
|
+
render(_args, value) {
|
|
745
|
+
const result = isRecord(value) ? value : {};
|
|
746
|
+
if (!result.ok) {
|
|
747
|
+
const gaps = Array.isArray(result.gaps) ? result.gaps.slice(0, 5).join(';') : '';
|
|
748
|
+
return textContent(`插件核验未通过(${String(result.code ?? 'FAILED')}):${String(result.error ?? '未知原因')}`
|
|
749
|
+
+ (gaps ? `|需补齐:${gaps}` : '')
|
|
750
|
+
+ '|先修复再回报,不要用 done 收尾。');
|
|
751
|
+
}
|
|
752
|
+
return textContent(`${String(result.subtaskId ?? '')} 阶段三核验通过:${String(result.summary ?? '')}`
|
|
753
|
+
+ '|把同一份 phases 写进结果块后提交。');
|
|
754
|
+
},
|
|
755
|
+
},
|
|
756
|
+
async execute(args, exec) {
|
|
757
|
+
const parsed = asObject(args) ?? {};
|
|
758
|
+
return runtime.verifyTool(exec.agent, parsed);
|
|
759
|
+
},
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* [2.0.0] 永久教训记忆的只读入口(用户 2026-11-05 自我学习要求)。
|
|
764
|
+
*
|
|
765
|
+
* 不提供写动作:记忆只能由「阶段三复盘通过 → 完成判定」这条链写入,
|
|
766
|
+
* 防止主 Agent 事后手写一条“教训”绕过真实复盘证据。
|
|
767
|
+
*/
|
|
768
|
+
function createLessonsTool(runtime) {
|
|
769
|
+
return {
|
|
770
|
+
name: 'dsh_workplan_lessons',
|
|
771
|
+
description: '查看 dsh-workplan 的永久教训记忆(部门完成工作后自动落盘的复盘):'
|
|
772
|
+
+ 'action=list 按部门取最相关教训,action=search 按关键词检索,action=stats 看总数/重复数与文件位置。'
|
|
773
|
+
+ '只读,不修改计划状态;阶段三验证时用它核对记住了什么、哪些同类错误在重复出现。',
|
|
774
|
+
parameters: {
|
|
775
|
+
type: 'object',
|
|
776
|
+
properties: {
|
|
777
|
+
action: { type: 'string', enum: ['list', 'search', 'stats'], description: '默认 list' },
|
|
778
|
+
department: { type: 'string', description: 'list 时按部门筛选(如 engineering)' },
|
|
779
|
+
query: { type: 'string', description: 'search 时的关键词' },
|
|
780
|
+
limit: { type: 'number', description: '最多返回多少条(1–50,默认 10)' },
|
|
781
|
+
},
|
|
782
|
+
additionalProperties: false,
|
|
783
|
+
},
|
|
784
|
+
output: {
|
|
785
|
+
schema: {
|
|
786
|
+
type: 'object',
|
|
787
|
+
properties: {
|
|
788
|
+
ok: { type: 'boolean' },
|
|
789
|
+
file: { type: 'string' },
|
|
790
|
+
total: { type: 'number' },
|
|
791
|
+
repeated: { type: 'number' },
|
|
792
|
+
lessons: { type: 'array', items: { type: 'object' } },
|
|
793
|
+
departments: { type: 'array', items: { type: 'object' } },
|
|
794
|
+
error: { type: 'string' },
|
|
795
|
+
},
|
|
796
|
+
required: ['ok'],
|
|
797
|
+
additionalProperties: true,
|
|
798
|
+
},
|
|
799
|
+
render(_args, value) {
|
|
800
|
+
const result = isRecord(value) ? value : {};
|
|
801
|
+
if (!result.ok)
|
|
802
|
+
return textContent(`教训记忆读取失败:${String(result.error ?? '未知原因')}`);
|
|
803
|
+
const file = String(result.file ?? '');
|
|
804
|
+
if (Array.isArray(result.departments)) {
|
|
805
|
+
const rows = result.departments.map((item) => `${item.department}:${item.count}`).join('、') || '(空)';
|
|
806
|
+
return textContent(`永久教训记忆:共 ${String(result.total ?? 0)} 条,其中重复发生 ${String(result.repeated ?? 0)} 类;分布 ${rows};文件 ${file}`);
|
|
807
|
+
}
|
|
808
|
+
const lessons = Array.isArray(result.lessons) ? result.lessons : [];
|
|
809
|
+
if (lessons.length === 0)
|
|
810
|
+
return textContent(`永久教训记忆为空(${file})`);
|
|
811
|
+
const lines = lessons.slice(0, 8).map((item) => `- [${String(item.department ?? '')}] ${String(item.title ?? '')}(${String(item.occurrences ?? 1)} 次)`
|
|
812
|
+
+ `|问题:${String((item.problems ?? []).join(';'))}`
|
|
813
|
+
+ `|预览:${String((item.prevention ?? []).join(';'))}`);
|
|
814
|
+
return textContent(`永久教训记忆(${lessons.length}/${String(result.total ?? lessons.length)} 条,文件 ${file}):\n${lines.join('\n')}`);
|
|
815
|
+
},
|
|
816
|
+
},
|
|
817
|
+
async execute(args, exec) {
|
|
818
|
+
return runtime.lessonsTool(exec.agent, asObject(args) ?? {});
|
|
819
|
+
},
|
|
820
|
+
};
|
|
821
|
+
}
|
|
633
822
|
/**
|
|
634
823
|
* [1.11.0] 主 → 子的指示通道(T4 C-10 / T6 M6)。
|
|
635
824
|
*
|
|
@@ -1085,6 +1274,10 @@ export function apply(ctx, config = {}) {
|
|
|
1085
1274
|
* 侧不做过滤;权限判断一律落在 execute 内部。
|
|
1086
1275
|
*/
|
|
1087
1276
|
ctx.effect(() => ctx.tools.register(createEscalateTool(runtime)));
|
|
1277
|
+
/* [1.13.0] 阶段三核验:子会话唯一可用的插件工作能力,阶段一/二会被 PHASE_GATE 拒绝。 */
|
|
1278
|
+
ctx.effect(() => ctx.tools.register(createVerifyTool(runtime)));
|
|
1279
|
+
/* [2.0.0] 永久教训记忆的只读复核入口(阶段三验证用)。 */
|
|
1280
|
+
ctx.effect(() => ctx.tools.register(createLessonsTool(runtime)));
|
|
1088
1281
|
ctx.effect(() => ctx.tools.register(createInstructTool(runtime)));
|
|
1089
1282
|
/*
|
|
1090
1283
|
* [1.11.0] 需求变更的重规划入口(T4 C-11 / T7)。
|
|
@@ -1170,11 +1363,11 @@ export function apply(ctx, config = {}) {
|
|
|
1170
1363
|
}
|
|
1171
1364
|
export const meta = {
|
|
1172
1365
|
name,
|
|
1173
|
-
version: '
|
|
1366
|
+
version: '2.0.1',
|
|
1174
1367
|
promptOrder: PROMPT_ORDER,
|
|
1175
1368
|
routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
|
|
1176
1369
|
};
|
|
1177
|
-
export { PROMPT_SECTION, createCancelTool, createDispatchTool, createEscalateTool, createHandoffTool, createInstructTool, createReplanTool, createStatusTool, createUpdateTool, plannerOutputSchema };
|
|
1370
|
+
export { PROMPT_SECTION, createCancelTool, createDispatchTool, createEscalateTool, createHandoffTool, createInstructTool, createLessonsTool, createReplanTool, createStatusTool, createUpdateTool, plannerOutputSchema };
|
|
1178
1371
|
/**
|
|
1179
1372
|
* [1.8.18] 写工具的路径级闸门(T7-N2),与 `toolGuardReason` 分开注册。
|
|
1180
1373
|
*
|