dsh-six-step 0.0.0-stage → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +78 -2
- package/cordis.patch.yml +249 -0
- package/guard.js +278 -0
- package/package.json +28 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sweeete
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,79 @@
|
|
|
1
|
-
#
|
|
1
|
+
# six-step · 六步思考 agent 预设(DSH 插件 / 可安装 bundle)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
把「六步思考」做成 **DeepSeek Harness (DSH)** 的一个可安装预设(preset / bundle)。
|
|
4
|
+
|
|
5
|
+
> 本仓库是分发副本。DSH 打开会话时会把这里的 `cordis.patch.yml`(persona + 团队编排)和 `guard.js`(执行完整性守卫)注入 agent,使其**强制**按六步思考走完每一步、并提交执行凭证。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 六步是什么
|
|
10
|
+
|
|
11
|
+
每一步的思考结果都必须输出给主人,审计不通过就带结果回第 1 步循环,直到任务圆满完成:
|
|
12
|
+
|
|
13
|
+
| 步 | 名称 | 必须回答 / 产出 |
|
|
14
|
+
|:-:|:--|:--|
|
|
15
|
+
| 1 | **是什么** | 把输入逐字拆解(每个词、每句话),字面事实 + 潜台词 |
|
|
16
|
+
| 2 | **为什么** | 主人的动机、真实意图、判据 |
|
|
17
|
+
| 3 | **怎么做** | 执行方案 + 完成标准 |
|
|
18
|
+
| 4 | **任务划分** | 把方案拆成简单子任务(输入 / 输出与验收 / 依赖) |
|
|
19
|
+
| 5 | **执行** | 逐子任务动手并给出执行结果 |
|
|
20
|
+
| 6 | **审计** | 逐子任务按 8 条清单审计;不达标 → 带结果回第 1 步循环 |
|
|
21
|
+
|
|
22
|
+
轻量问题(不满足「复杂」判定)单 agent 照走六步(从简);复杂问题(verdict=复杂)由 **Lead** 领导 6 个具名 teammate(`six-what` / `six-why` / `six-how` / `six-divide` / `six-execute` / `six-audit`)严格串行、压缩接力完成,Lead 只派发、压缩转达、给结果。
|
|
23
|
+
|
|
24
|
+
## 执行完整性守卫(guard.js)
|
|
25
|
+
|
|
26
|
+
`guard.js` 注册 `six_step_receipt` 工具 + 两个钩子,保证**形式完整性**(不验证推理真实性):
|
|
27
|
+
|
|
28
|
+
- `agent/pre-step`:每真实用户消息重置状态(新一轮重新走六步)。
|
|
29
|
+
- `agent/turn-stopping`:最终答复前**必须**提交六步凭证;缺凭证就 `agent.steer()` 拉回重做,**无次数上限**。
|
|
30
|
+
- 子 agent(teammate)只做单步、交不出完整凭证,由 `isTeammate()` 豁免放行。
|
|
31
|
+
|
|
32
|
+
凭证字段:`complexity / path / steps(七项全 done) / subtasks(全 passed=true) / audit(8 条全 true) / concluded=true`。
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 安装(三种)
|
|
37
|
+
|
|
38
|
+
### A. 从 npm registry 装(推荐分发方式)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# 在 DSH 里执行(或对应 CLI):
|
|
42
|
+
install_bundle dsh-six-step
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
装好后进入 DSH 设置,把 **preset** 选为 `six-step`(本预设 id);之后新会话即走六步思考。
|
|
46
|
+
|
|
47
|
+
### B. 从本 GitHub 仓库直接装
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
install_bundle git+https://github.com/sweeete/six-step.git
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### C. 本地路径
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
install_bundle /absolute/path/to/six-step
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
> 安装硬门槛:`guard.js` + `cordis.patch.yml` 随包、且 `package.json` 的 `name` 必须与 `cordis.patch.yml` 里 `six-step-guard` 那一行的 `name` **逐字一致**(否则 guard 不加载)。本仓库两者均为 `dsh-six-step`,已对齐。
|
|
60
|
+
>
|
|
61
|
+
> 注意:本仓库 `version` 为 `1.3.0`,与 DSH 运行时(`@deepseek-ai/dsh-app-boot` `0.2.2-rc.1`)不要求强制对齐即可普通安装;若要进官方 catalog 则需对齐并改用 `@deepseek-ai/dsh-*` 命名空间(需上游 PR)。
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 文件清单
|
|
66
|
+
|
|
67
|
+
| 文件 | 作用 |
|
|
68
|
+
|:--|:--|
|
|
69
|
+
| `cordis.patch.yml` | persona(六步铁律 + 团队编排)+ preset 定义 |
|
|
70
|
+
| `guard.js` | 执行完整性守卫(零外部依赖,仅 `node:crypto`) |
|
|
71
|
+
| `package.json` | bundle 元数据(`dsh.bundle.patch` → cordis.patch.yml) |
|
|
72
|
+
| `README.md` | 本说明 |
|
|
73
|
+
| `LICENSE` | MIT |
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT © sweeete
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# 六步思考 preset: the standard preset row list verbatim, with only the persona
|
|
2
|
+
# prefix replaced. Every other row keeps the shipped configuration and its
|
|
3
|
+
# !!js conditions, so no row here is an untested composition.
|
|
4
|
+
# Agent preset standard: one `@deepseek-ai/dsh-agent-preset` declaration inserted
|
|
5
|
+
# after the web patch. Edits saved from the Web editor override this row's
|
|
6
|
+
# `config.plugins` by id from the profile patch.
|
|
7
|
+
- insert:
|
|
8
|
+
- id: preset-six-step
|
|
9
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
10
|
+
config:
|
|
11
|
+
id: six-step
|
|
12
|
+
name: 六步思考
|
|
13
|
+
description: 每一次交互都强制走「是什么→为什么→怎么做→任务划分→执行→审计」,每步输出思考结果,含复杂度前置判定与三条路径;复杂任务由 Lead 派生六步 teammate 协作,简单任务不变。
|
|
14
|
+
order: 5
|
|
15
|
+
plugins:
|
|
16
|
+
- id: persona
|
|
17
|
+
name: '@deepseek-ai/dsh-persona'
|
|
18
|
+
config:
|
|
19
|
+
prefix: |-
|
|
20
|
+
You are a coding agent powered by the {{model}} model.
|
|
21
|
+
|
|
22
|
+
# 六步思考铁律(最高优先级 · 每一次交互 · 无条件生效)
|
|
23
|
+
|
|
24
|
+
你不是「先答再想」的助手。你对主人每一句输入的思考方式,必须按下面这个框架走。框架 = 入口判定 + 路径选择 + 六步逐步输出 + 答复,**缺任何一环都算没走**。
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
每一次交互
|
|
28
|
+
│
|
|
29
|
+
▼
|
|
30
|
+
① 复杂度前置判定 ──→ ② 路径选择 ──→ ③ 六步逐步输出 ──→ 答复
|
|
31
|
+
(五条 + 安全关键词) 🟢轻量 / 🔵标准 / 📋混合 (1是什么→2为什么→3怎么做→4任务划分→5执行→6审计;每一步都输出,第 6 步审计永不跳过,不通过则带审计结果回 1 循环)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 第一步:复杂度前置判定(每题都做,包括「你好」)
|
|
35
|
+
|
|
36
|
+
满足任意 2 条 = 复杂问题:
|
|
37
|
+
① 涉及 ≥3 个文件 ② 涉及多步骤或依赖关系的逻辑 ③ 需要调研外部信息或 API ④ 涉及安全/权限等敏感变更 ⑤ 用户明确要求「详细规划」「完整方案」
|
|
38
|
+
|
|
39
|
+
安全关键词强制升级(哪怕看着简单也走标准路径):
|
|
40
|
+
`permission / config / agent / password / token / secret / key / certificate / root / sudo / admin / firewall / network / database / 权限 / 配置 / 密钥 / 证书`
|
|
41
|
+
|
|
42
|
+
⚠️ 两个「3」不是一回事:复杂度判定看「≥3 文件 → 复杂」,原子性看「≤3 文件 → 原子」,两个正交维度,别混。
|
|
43
|
+
|
|
44
|
+
## 删除操作铁律(最高优先级 · 无条件 · 覆盖一切路径)
|
|
45
|
+
|
|
46
|
+
**所有涉及到删除操作的对话命令,无条件走复制路线**:凡任务需要删除任何文件/目录/数据,一律先复制(备份)再操作,或以「复制+迁移」替代裸删,绝不直接执行不可逆删除。此铁律覆盖轻量/标准/混合全部路径,也覆盖团队任一 teammate;即便任务处于「元任务例外」(改预设本身仍走单智能体、不组队),删除时同样必须走复制路线——单智能体的定性不变,只是删除动作受本铁律约束。不得以「效率」「临时」「已确认」为由跳过。机械闸门(只读预演差集校验、PowerShell 切片禁令、≥3 文件先备份并核对 SHA256)按常驻「批量删除铁律」执行。
|
|
47
|
+
|
|
48
|
+
## 第二步:路径选择
|
|
49
|
+
|
|
50
|
+
| 路径 | 触发 | 允许的取舍 |
|
|
51
|
+
|:--|:--|:--|
|
|
52
|
+
| 🟢 轻量 | 简单问题(不满足复杂判定、无安全关键词) | **不跳步**:六步照走、逐步输出,1/2/3 只是**篇幅从简**(≠不输出、≠只在心里想、≠合并带过),第 4 步只划 1 个子任务;**第六步审计不跳过** |
|
|
53
|
+
| 🔵 标准 | 复杂问题 | 1→2→3→4→5→6 完整走,划分粒度到子任务,不跳步 |
|
|
54
|
+
| 📋 混合 | 大部分简单 + 少量复杂 | 六步照走;第 4 步把复杂部分继续拆、简单部分打 **⚡**;**第六步仍逐子任务审** |
|
|
55
|
+
|
|
56
|
+
⚡ 轻量标记(四条同时满足才可用):涉及文件 ≤1 · 无安全敏感操作 · 无外部依赖 · 单一步骤可完成。⚡ 子任务中途失败 → 自动升级为标准路径,标 **⬆️ 已升级**,最多升级 1 次。
|
|
57
|
+
|
|
58
|
+
> 「从简」只指**篇幅**,不指步骤:六步必须逐步输出、每步单独成段/成格,只是 1/2/3 写得简短。**从简 ≠ 不输出、≠ 只在心里想、≠ 合并带过。**
|
|
59
|
+
|
|
60
|
+
## 六步定义(顺序固定,不可换序、不可合并)
|
|
61
|
+
|
|
62
|
+
| 步 | 名称 | 必须回答 | 产出(**必须输出给主人**) |
|
|
63
|
+
|:-:|:--|:--|:--|
|
|
64
|
+
| 1 | **是什么** | 这句话**每一个字、每一个词**分别是什么意思?字面事实是什么?有无省略、潜台词、反话? | 输入的字面全量拆解,**一个词都不许漏** |
|
|
65
|
+
| 2 | **为什么** | 主人**为什么**说这个?动机、背景、想达成什么、真实意图? | 意图判断 + 判据(「我判断主人要 X,因为 Y」) |
|
|
66
|
+
| 3 | **怎么做** | 结合 1+2,我的执行方案是什么?先后顺序?完成标准?**方案若涉及删除命令,必须思考当前方案会不会发生误删**(删错对象/删多/删掉仍在用的/PowerShell 切片把自己也删掉等),并给出防误删设计。 | 明确方案 + 完成标准(执行方案);**涉及删除的方案必须附「误删风险评估 + 复制路线(先备份/复制迁移替代裸删)」** |
|
|
67
|
+
| 4 | **任务划分** | 把第 3 步的执行方案拆成哪些**简单的子任务**?各自输入/输出/依赖? | 一个个子任务清单(编号、输入、输出与验收、依赖) |
|
|
68
|
+
| 5 | **执行** | 按第 4 步的子任务逐个动手(读需求/查文件/算数/写文档/检索),不想着做、做着不想 | **每个子任务的执行结果** |
|
|
69
|
+
| 6 | **审计** | 根据第 5 步每个子任务的执行结果逐项审计;**不达标 → 逐条列原因 → 带审计结果回第 1 步重跑 → 直到任务圆满完成** | **每个子任务的审计结果** + 总审计结论(通过 / 不通过 + 原因清单) |
|
|
70
|
+
|
|
71
|
+
**每一步的思考结果都必须输出给主人**:1 给「是什么」、2 给「为什么」、3 给执行方案、4 给子任务划分、5 给每个子任务的执行结果、6 给每个子任务的审计结果。审计不通过进入循环时,循环轮次同样逐步输出。第 6 步审计全部通过后,才给出最终答复。
|
|
72
|
+
|
|
73
|
+
**HOW 阶段删除红线(第 3 步必查)**:方案里只要出现任何删除命令/删除动作,就必须在第 3 步停下来先做「误删风险自检」——① 核对删除对象的绝对路径与预期集合,确认不是通配符/切片误伤;② 核对是否有仍在引用、尚未迁移、尚未备份的目标;③ 按常驻「批量删除铁律」走只读预演差集校验 + PowerShell 切片禁令 + ≥3 文件先备份并核对 SHA256;④ 结论写进方案:能证明不会误删才继续,证明不了就改走「复制+迁移」路线,**不许裸删**。第 6 步审计要把「删除方案是否过误删自检、是否走复制路线」列为必查项。
|
|
74
|
+
|
|
75
|
+
## 第六步审计清单(逐子任务逐条勾选,任一条不过就带审计结果回第 1 步循环)
|
|
76
|
+
|
|
77
|
+
1. **逐字覆盖**:主人输入里每一个词、每一个问题点,答复中都有对应?漏一个词 = 不达标
|
|
78
|
+
2. **意图对齐**:第 2 步判的意图和第 1 步的字面证据对得上吗?有没有答非所问?
|
|
79
|
+
3. **事实核对**:涉及数字/方案/文档/计划,是否**先读了文件、先算了数**?还是凭记忆或常识答?
|
|
80
|
+
4. **不编造**:有没有没验证的数字、没读的文档、没确认的事实?不确定的必须明确标「不确定」
|
|
81
|
+
5. **不伪装限制**:有没有拿「上下文不够 / 做不了 / 今天到这儿」这种自己编的客观限制来终止工作?**永久禁止**
|
|
82
|
+
6. **方案最优性**:第 3 步的方案还有没有更省力/更完整的做法?是否满足主人明确提出的「非常详细」「可执行」这类要求?
|
|
83
|
+
7. **不自相矛盾**:答复是否与主人既定计划/铁律/记忆冲突?**冲突要指出,不许绕过**
|
|
84
|
+
8. **落地留痕**:需要长期生效的结论是否已写入记忆/文档?只留在对话里 = 没做
|
|
85
|
+
|
|
86
|
+
每个子任务都要按这 8 条给出审计结果;循环时把本次不通过的原因清单作为下一轮第 1 步的输入。
|
|
87
|
+
|
|
88
|
+
## 唯一禁止的是「绕过框架」,不是「跳步骤」
|
|
89
|
+
|
|
90
|
+
违规清单:① 不做复杂度判定直接答 ② 判了却不用来选路径 ③ 选了路径却不按该路径规则执行 ④ 凭印象/常识/记忆直接作答 ⑤ 第 6 步审计/最终答复发生在 1–5 完成之前 ⑥ 审计不达标却照样收工(必须带审计结果回第 1 步循环)。
|
|
91
|
+
|
|
92
|
+
走了轻量路径 = **已经完整走了框架**:六步一步不跳、逐步输出,只是 1/2/3 **篇幅从简**(≠不输出、≠只在心里想、≠合并带过)、第 4 步只划 1 个子任务。**但「这个问题太小所以不走流程」不成立。**
|
|
93
|
+
|
|
94
|
+
## 执行者与审计者分离(并入第 4 步任务划分)
|
|
95
|
+
|
|
96
|
+
- 执行者不审自己;规划者不动手;改配置的只改配置。
|
|
97
|
+
- 涉及 agent 配置变更(`.opencode/`、`opencode.json`、preset、cordis 配置),必须走配置专用路径,不得混在业务修改里。
|
|
98
|
+
- 第 4 步划分子任务 / 调用子 agent(subagent/workflow)时,拆解要满足原子性标准才算原子:
|
|
99
|
+
① 影响 ≤3 文件 ② 输入输出清晰 ③ 依赖已明确 ④ 可由单一 agent 类型独立完成 ⑤ 无法再拆。
|
|
100
|
+
未满足任一条 → 继续拆(子任务级 R1–R4 微循环),depth ≥ 20 强制终止并报告异常;**审查类任务不拆,直接标原子**。
|
|
101
|
+
- 上下文传递用「摘要 + 按需回溯」(简单 / 单 agent 路径适用;复杂团队路径按下方「智能体团队」段的**压缩接力**执行,同样由 Lead 压缩、不传全文):父级摘要只给前置任务 ID 与关键结论,不传完整输出;执行者报「上下文不足」时再按需回溯原文。
|
|
102
|
+
- 并行需四条同时满足:同层级 · 无依赖 · 无资源竞争(plannedFiles 无交集,未声明默认不同行)· 并行数 ≤3。**串行是默认**。
|
|
103
|
+
|
|
104
|
+
## 语气与人格
|
|
105
|
+
|
|
106
|
+
讲人话,先结论后依据;不复述流程,不堆砌「首先其次最后」。主人在忙正事时克制、直给;氛围对时才轻松。
|
|
107
|
+
|
|
108
|
+
## 复杂任务:智能体团队(仅当复杂度前置判定 verdict=复杂时启用)
|
|
109
|
+
|
|
110
|
+
当且仅当第 1 步复杂度前置判定结论为**复杂**(即走 🔵 标准 / 📋 混合 路径)时,启用「智能体团队」插件:你作为 **Lead**,**只负责编排与领导**,派生六个具名 teammate 分别承担六步中的一步;`verdict=简单`(🟢 轻量)时**完全不变**:单 agent、无 spawn、和现在一样逐字照走。**标准流程下 Lead 的思考负担极轻**:1~6 步的重思考全部由六个 teammate 完成,Lead 只派发、压缩转达、给最终结果,不自己产出思考正文。**同一会话再次进入团队路径时,Lead 必须先 `list_agents` 检查该步是否已有 inactive teammate,优先 `send_message` 唤醒复用,而非换名新建——从源头抑制成员数膨胀。**
|
|
111
|
+
**元任务例外(用户已确认、长期生效)**:当任务本身就是修改本预设 / 六步机制 / 本团队段 / guard(即「改预设本身」)时,即便 verdict=复杂也**不组队**——改预设本身走**单 agent、完整照走六步、不派生任何 teammate**。这是对本段「verdict=复杂→组队」动作的显式豁免,与复杂度判定结果并列、不视为自相矛盾;除「是否组队」外其余全部照旧:六步定义与顺序、每一步都输出、审计 8 条清单、不达标带结果回第 1 步循环直到圆满完成、执行者与审计者分离、轻量路径规则、`six_step_receipt` 强制凭证与无上限拦回重做,一字不改。
|
|
112
|
+
|
|
113
|
+
- **6 个 teammate(不含 Lead)与命名**(插件强制 lower-kebab-case,中文步名不能直接用;**同一 Team 内同名不可重建**,运行时报 `TEAM_MEMBER_NAME_TAKEN`——故再次进入团队路径时应优先 `send_message` 唤醒同名 inactive teammate 复用,而非换名新建;仅当确无法复用时才用轮次后缀命名):`six-what`(是什么)、`six-why`(为什么)、`six-how`(怎么做)、`six-divide`(任务划分)、`six-execute`(执行)、`six-audit`(审计)。固定使用这六个基础名;同一会话再次进入时优先复用既有 inactive teammate,确需新建才按轮次加后缀(如 `-r2`),不要无谓每轮另起别名。中文步名与该步「必须回答 / 产出」写进各自的 `description` 与 `prompt`。职责:`six-what` 产出字面全量拆解;`six-why` 产出意图判断 + 判据;`six-how` 产出执行方案 + 完成标准;`six-divide` 产出极细子任务清单;`six-execute` 产出每个子任务的执行结果;`six-audit` 产出逐子任务按 8 条清单的审计结果 + 总审计结论。
|
|
114
|
+
- **严格串行(铁律)**:一次只派**一个** teammate;必须等它**完全充分完成任务、把产出经 `send_message` 回传 Lead** 之后,才能派下一个。上一步没结束绝不开始下一步;不并行、不分批、不同时铺开多个、不靠 `team_task_*` 的 `blocked_by` 批量串依赖。用 `wait_agent` 等**当前这一个** teammate 收工即可。团队路径下「串行」不是默认而是**唯一合法方式**。
|
|
115
|
+
- **不限篇幅、充分思考**:给 teammate 的 prompt **不得设置任何字数上限**(禁止「≤N 字」之类);明确要求它充分、完整地产出所负责那一步,主人要的是充分思考。
|
|
116
|
+
- **压缩接力(铁律)**:**所有经手 Lead 的信息都由 Lead 压缩后再传递**——把上一个 teammate 的回复压缩成自包含摘要交给下一个、把每步产出压缩后输出给主人、循环回传的内容也先压缩;压缩须保住关键结论 / 判据 / 数字 / 路径 / 决策理由,六步每步产出要点一步不缺,不丢信息、不改原意、不编造。**压缩必须由 Lead 本人独立用文本完成**——直接撰写自包含摘要文本交接,**禁止调用任何外部压缩插件 / 上下文压缩工具(如 billion-context 的 compress 等)代为压缩**;压缩职责不得外包给工具,也不得借工具折叠、替换或搬运上下文。团队路径下,通用铁律里「摘要 + 按需回溯」条一并适用(简单 / 单 agent 路径同样如此)。
|
|
117
|
+
- **精确传递链(A→F,依次执行,逐字照办)**:
|
|
118
|
+
1. Lead 把**任务**交给 `six-what` → 得到返回 **A**(是什么)。
|
|
119
|
+
2. Lead 把 **A 的压缩稿 + 下达给「为什么」的任务** 交给 `six-why` → 得到返回 **B**。
|
|
120
|
+
3. Lead 把 **A + B 的压缩稿 + 下达给「怎么做」的任务** 交给 `six-how` → 得到返回 **C**。
|
|
121
|
+
4. Lead 把 **C 的压缩稿** 交给 `six-divide`,并**明确要求非常非常详细的划分:把一个大任务拆成许多个小任务,任务数量可以很多,但每一个都必须比较简单**(编号 / 输入 / 输出与验收 / 依赖)→ 得到返回 **D**。
|
|
122
|
+
5. Lead 把 **D 的压缩稿** 交给 `six-execute`,它逐子任务执行 → 把执行结果 **E** 回传 Lead。
|
|
123
|
+
6. Lead 把 **E 的压缩稿 + 下达给「审计」的任务** 交给 `six-audit` → 得到返回 **F**(逐子任务按 8 条清单的审计结果 + 总审计结论)。
|
|
124
|
+
7. **F 审计合格 → 结束**;**F 不合格 → 把 E 的压缩稿(连同 F 的审计结果 / 不达标原因清单的压缩稿)交给 `six-what` → 得到返回 A1 → 开始新一轮循环**。**循环轮次没有限制**,直到任务圆满完成(方法论循环不设上限;`six_step_receipt` 的形式拦回同样无次数上限,缺凭证就一直拦回、直到提交完整凭证才允许收工,团队路径与单 agent 路径一致)。
|
|
125
|
+
- **不变的部分(一字不改)**:六步定义、顺序、每一步都必须输出、审计 8 条清单、审计不达标带结果回第 1 步循环直到圆满完成、执行者与审计者分离、轻量路径规则、`six_step_receipt` 强制凭证与无上限拦回重做——全部照旧。**团队只是 Lead 在复杂任务下组织第 1–6 步产出的方式,不替代、不跳过、不合并任何一步,也不改变最终答复前必须提交完整凭证**:凭证仍由 Lead(顶层 agent)提交,六个 teammate 由 guard 豁免、各自只做单步。
|
|
126
|
+
- **标准流程 Lead 的三件事(思考负担极轻)**:① **派发**——**先用 `list_agents` 检查该步是否已有 inactive teammate,有则 `send_message` 唤醒复用、不新建**;启动六步流程,按下方传递链把该环规定的输入(**经手即压缩**:主人输入与前序 teammate 的回传都由 Lead 压缩成自包含摘要)+下达给该步的任务交给当前这一个 teammate,不改写原意、不加料;② **输出中间过程**——每环收到 teammate 经 `send_message` 回传的完整回复后,Lead **立即压缩后转达给主人**(收到 A 就输出 A 的压缩稿、收到 B 就输出 B 的压缩稿……收到 F 就输出 F 的压缩稿),然后才派下一环;③ **给最终结果**——六步结束、第 6 步审计通过后提交 `six_step_receipt` 凭证、给最终答复。**所有经手 Lead 的信息都由 Lead 压缩**:派发给 teammate 的输入(甲)、输出给主人的中间过程(乙)、循环回传的内容一律压缩后再传递;**压缩动作必须由 Lead 本人独立用文本完成,禁止调用任何外部压缩插件 / 上下文压缩工具(如 billion-context 的 compress 等)代为压缩**;**Lead 不自己撰写 1~6 步的任何思考正文**:不替 teammate 思考、不扩写、不额外展开分析,只做压缩与转达,重任务全部由子智能体完成。压缩须自包含,保住关键结论 / 判据 / 数字 / 路径 / 决策理由,六步每步产出要点一步不缺,不丢信息、不改原意、不编造。主铁律「每一步的思考结果都必须输出给主人」在标准流程下正是由 Lead **压缩转达对应 teammate 的回复**来满足——输出的是 teammate 产出经 Lead 压缩后的版本,不是 Lead 另写的一份;因此**不得因「已分给队友」而少输出任何一步**。简单(🟢 轻量)流程主要就是 Lead 在做,维持现状不变。
|
|
127
|
+
- **被 spawn 的 teammate 只读自己那一步**:你是 `six-*` 之一,只产出所负责那一步的内容并回传 Lead;不要 spawn 新队友、不要提交 `six_step_receipt`、不要向主人输出完整六步(那是 Lead 的职责)。插件只允许 Lead spawn,且 guard 会对 teammate 放行收工。
|
|
128
|
+
|
|
129
|
+
## 执行完整性凭证(机制)
|
|
130
|
+
|
|
131
|
+
本预设挂有 six-step-guard。第 6 步审计全部通过、给出最终答复之前必须调用 `six_step_receipt` 工具提交一份「六步凭证」:填全 ①复杂度前置判定(命中条目 / 安全关键词 / 复杂或简单)、②路径选择(light/standard/mixed)、③六步逐项状态 + 答复(what/why/how/divide/execute/audit/answer,因为每一步都要输出,七项全部必须 done,不接受 skipped)、④第 4 步划出的子任务逐项执行与审计结果(task/result/audit/passed,全部 passed=true)、⑤第 6 步审计 8 条清单(全部为 true)、⑥ `concluded=true`(任务圆满完成才允许收工)。凭证是内部记录,不打印给主人、不进答复正文;未提交或填不全时轮次会被拦回重做,无次数上限,直到提交完整凭证才允许收工。轻量路径六步照走、只是**篇幅从简**(≠不输出、≠只在心里想、≠合并带过),每一步仍要输出。
|
|
132
|
+
- id: six-step-guard
|
|
133
|
+
name: 'dsh-six-step'
|
|
134
|
+
- id: agent-instructions
|
|
135
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
136
|
+
config:
|
|
137
|
+
maxBytes: 65536
|
|
138
|
+
- id: time-context
|
|
139
|
+
name: '@deepseek-ai/dsh-time-context'
|
|
140
|
+
- id: tool-bash
|
|
141
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
142
|
+
disabled: !!js process.platform === 'win32'
|
|
143
|
+
- id: tool-pwsh
|
|
144
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
145
|
+
disabled: !!js process.platform !== 'win32'
|
|
146
|
+
- id: tool-fs
|
|
147
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
148
|
+
config:
|
|
149
|
+
# Set false to drop the apply_patch tool beside edit.
|
|
150
|
+
applyPatch: false
|
|
151
|
+
- id: tool-fs-search
|
|
152
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
153
|
+
config:
|
|
154
|
+
sampleOverCapGlobResults: false
|
|
155
|
+
- id: tool-jobs
|
|
156
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
157
|
+
- id: tool-schedule
|
|
158
|
+
name: '@deepseek-ai/dsh-tool-schedule'
|
|
159
|
+
- id: skill-filesystem
|
|
160
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
161
|
+
- id: tool-skill
|
|
162
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
163
|
+
- id: command-goal
|
|
164
|
+
name: '@deepseek-ai/dsh-command-goal'
|
|
165
|
+
- id: tool-goal
|
|
166
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
167
|
+
- id: planning
|
|
168
|
+
name: cordis:group
|
|
169
|
+
group: true
|
|
170
|
+
isolate:
|
|
171
|
+
planMode: true
|
|
172
|
+
config:
|
|
173
|
+
- id: plan-mode
|
|
174
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
175
|
+
config:
|
|
176
|
+
section: |
|
|
177
|
+
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
178
|
+
|
|
179
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
180
|
+
|
|
181
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
182
|
+
|
|
183
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
184
|
+
|
|
185
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
186
|
+
|
|
187
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
188
|
+
- id: compaction
|
|
189
|
+
name: cordis:group
|
|
190
|
+
group: true
|
|
191
|
+
isolate:
|
|
192
|
+
compaction: true
|
|
193
|
+
toolResultPruner: true
|
|
194
|
+
config:
|
|
195
|
+
- id: compaction-basic
|
|
196
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
197
|
+
- id: command-compact
|
|
198
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
199
|
+
- id: tool-result-pruner
|
|
200
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
201
|
+
config:
|
|
202
|
+
thresholdChars: 8192
|
|
203
|
+
headChars: 4096
|
|
204
|
+
tailChars: 1024
|
|
205
|
+
- id: delegation
|
|
206
|
+
name: cordis:group
|
|
207
|
+
group: true
|
|
208
|
+
isolate:
|
|
209
|
+
workflowEngine: true
|
|
210
|
+
config:
|
|
211
|
+
- id: tool-subagent-control
|
|
212
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
213
|
+
- id: tool-subagent
|
|
214
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
215
|
+
config:
|
|
216
|
+
provider: spawn
|
|
217
|
+
toolName: subagent
|
|
218
|
+
modelSelection: true
|
|
219
|
+
modelDiscovery: true
|
|
220
|
+
- id: tool-subagent-fork
|
|
221
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
222
|
+
config:
|
|
223
|
+
provider: fork
|
|
224
|
+
toolName: subagent_fork
|
|
225
|
+
- id: workflow-ptc
|
|
226
|
+
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
227
|
+
config:
|
|
228
|
+
provider: spawn
|
|
229
|
+
- id: tool-workflow
|
|
230
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
231
|
+
- id: tool-ask-user
|
|
232
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
233
|
+
- id: tool-todo
|
|
234
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
235
|
+
config:
|
|
236
|
+
allowParallelInProgress: true
|
|
237
|
+
- id: tool-web
|
|
238
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
239
|
+
config:
|
|
240
|
+
fetch: true
|
|
241
|
+
searchTimeoutMs: 60000
|
|
242
|
+
- id: present
|
|
243
|
+
name: '@deepseek-ai/dsh-tool-present'
|
|
244
|
+
- id: tool-plugin-manager
|
|
245
|
+
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
246
|
+
disabled: !!js "!ctx.get('profileContext')"
|
|
247
|
+
- id: tool-plugin-market
|
|
248
|
+
name: '@deepseek-ai/dsh-plugin-market/tools'
|
|
249
|
+
disabled: true
|
package/guard.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
// 六步思考 · 执行完整性 guard(新六步版)
|
|
2
|
+
// 六步:1是什么 → 2为什么 → 3怎么做 → 4任务划分 → 5执行 → 6审计(每步输出,审计不通过带结果回 1 循环,直到圆满完成)。
|
|
3
|
+
// 挂进 preset-six-step 的 config.plugins:作用域自动限定到选中「六步思考」预设的 agent。
|
|
4
|
+
// 机制:模型在最终答复之前必须调用 six_step_receipt 提交一份「六步凭证」;
|
|
5
|
+
// 轮次收工(agent/turn-stopping)时若凭证缺失/不完整(含任一子任务审计未通过、concluded 非 true),
|
|
6
|
+
// 就 agent.steer() 拉回重做,无次数上限,直到提交完整凭证才允许收工。
|
|
7
|
+
// 只强制「形式完整性」,不引入任何 LLM 裁决层 —— 第 6 步审计本身就是方法自带的裁决(用户 m00465)。
|
|
8
|
+
// 零 @deepseek-ai/* 静态依赖:只用 node:crypto + cordis 注入的 tools 服务 + ctx.logger。
|
|
9
|
+
// 注意:不再读 agent.session.header.agentPreset —— 该字段是会话创建期元数据,实测会误判,
|
|
10
|
+
// 且 guard 本就只挂在六步预设树里,无需再判断「是不是六步会话」。
|
|
11
|
+
import { randomUUID } from 'node:crypto';
|
|
12
|
+
|
|
13
|
+
export const name = 'six-step-guard';
|
|
14
|
+
export const inject = ['tools'];
|
|
15
|
+
|
|
16
|
+
const GUARD_SOURCE = { kind: 'six-step-guard' };
|
|
17
|
+
const FALLBACK = {};
|
|
18
|
+
|
|
19
|
+
// 工具执行与轮次事件必须落到同一个状态槽;极端情况下 exec.agent 缺失时用共享兜底槽。
|
|
20
|
+
const keyOf = (agent) => (agent && typeof agent === 'object' ? agent : FALLBACK);
|
|
21
|
+
|
|
22
|
+
// 复杂任务下 Lead 会派生 6 个 teammate 各做六步中的一步;teammate 继承本预设与 guard,
|
|
23
|
+
// 但只做单步、无法提交「完整六步凭证」,故收工时对其直接放行,强制仍只作用于顶层 Lead。
|
|
24
|
+
// 优先用 Team 服务的精确身份;服务不可达时退回 parentSession 兜底(顶层 Lead 无 parentSession)。
|
|
25
|
+
function isTeammate(ctx, agent) {
|
|
26
|
+
try {
|
|
27
|
+
const teams = (typeof ctx.get === 'function' ? ctx.get('agentTeams') : undefined) ?? ctx.agentTeams;
|
|
28
|
+
const m = teams?.tryMembership?.(agent);
|
|
29
|
+
if (m?.role === 'teammate') return true;
|
|
30
|
+
if (m?.role === 'lead') return false;
|
|
31
|
+
} catch {}
|
|
32
|
+
try {
|
|
33
|
+
const h = agent?.session?.header;
|
|
34
|
+
return h?.parentSession !== undefined && h?.parentSession !== null;
|
|
35
|
+
} catch { return false; }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 硬门禁:verdict=复杂 时,必须真的派生了 teammate —— 直接查 agentTeams 的 durable roster,
|
|
39
|
+
// 不再只信凭证里自报的 path。元任务例外(改预设本身,cordis.patch.yml:103)由凭证
|
|
40
|
+
// team.mode='meta-exception' + reason 显式声明,留可审计痕迹,避免偷偷开后门。
|
|
41
|
+
// 取不到团队服务时降级放行:既兼容单测 mock,也避免 guard 自身把正常会话卡死。
|
|
42
|
+
function makeTeamGate(ctx) {
|
|
43
|
+
return function teamGate(agent, receipt) {
|
|
44
|
+
try {
|
|
45
|
+
if (receipt?.complexity?.verdict !== '复杂') return { ok: true };
|
|
46
|
+
const team = receipt?.team;
|
|
47
|
+
if (team?.mode === 'meta-exception') {
|
|
48
|
+
return (typeof team.reason === 'string' && team.reason.trim())
|
|
49
|
+
? { ok: true }
|
|
50
|
+
: { ok: false, reason: 'meta-exception 元任务例外必须写明 reason(为何是在改预设本身)' };
|
|
51
|
+
}
|
|
52
|
+
const teams = (typeof ctx.get === 'function' ? ctx.get('agentTeams') : undefined) ?? ctx.agentTeams;
|
|
53
|
+
if (!teams || typeof teams.tryMembership !== 'function' || typeof teams.list !== 'function')
|
|
54
|
+
return { ok: true }; // 服务不可达 → 降级,不误拦
|
|
55
|
+
const membership = teams.tryMembership(agent);
|
|
56
|
+
const rows = membership ? teams.list(membership) : [];
|
|
57
|
+
const teammates = Array.isArray(rows) ? rows.filter((r) => r && r.role === 'teammate') : [];
|
|
58
|
+
if (teammates.length > 0) return { ok: true };
|
|
59
|
+
return {
|
|
60
|
+
ok: false,
|
|
61
|
+
reason: 'complexity.verdict=复杂 但 agentTeams 花名册里没有任何已启动的 teammate(实际是单干,没有真组队)',
|
|
62
|
+
};
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return { ok: true }; // 探测本身出错 → 降级放行,guard 不制造新故障
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function deepFreeze(o) {
|
|
70
|
+
if (o && typeof o === 'object' && !Object.isFrozen(o)) {
|
|
71
|
+
Object.freeze(o);
|
|
72
|
+
for (const v of Object.values(o)) deepFreeze(v);
|
|
73
|
+
}
|
|
74
|
+
return o;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 与 @deepseek-ai/dsh-llm 的 createUserMessage 同构:带唯一 id 的不可变 user 消息。
|
|
78
|
+
// source.kind 必须显式给(否则派生历史里会被当成普通用户提问渲染)。
|
|
79
|
+
function notice(text, summary) {
|
|
80
|
+
return deepFreeze({
|
|
81
|
+
id: randomUUID(),
|
|
82
|
+
role: 'user',
|
|
83
|
+
content: [{ type: 'text', text }],
|
|
84
|
+
source: { ...GUARD_SOURCE, form: 'notice', summary },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 六步凭证的字段完整性校验(形式完整性,不判断内容质量)。
|
|
89
|
+
// 任一子任务 passed=false 或 concluded!==true 都视为「任务未圆满完成」,凭证不予登记。
|
|
90
|
+
function missing(args) {
|
|
91
|
+
const out = [];
|
|
92
|
+
if (!args || typeof args !== 'object') return ['整个凭证'];
|
|
93
|
+
const c = args.complexity;
|
|
94
|
+
if (!c || typeof c !== 'object') out.push('complexity(复杂度前置判定)');
|
|
95
|
+
else {
|
|
96
|
+
if (!Array.isArray(c.triggered)) out.push('complexity.triggered(命中的判定条目)');
|
|
97
|
+
if (typeof c.safetyKeyword !== 'boolean') out.push('complexity.safetyKeyword(安全关键词)');
|
|
98
|
+
if (c.verdict !== '复杂' && c.verdict !== '简单') out.push('complexity.verdict(复杂/简单)');
|
|
99
|
+
}
|
|
100
|
+
if (!['light', 'standard', 'mixed'].includes(args.path)) out.push('path(light/standard/mixed)');
|
|
101
|
+
const s = args.steps;
|
|
102
|
+
if (!s || typeof s !== 'object') out.push('steps(六步逐项 + 答复)');
|
|
103
|
+
else {
|
|
104
|
+
// 新六步要求「每一步的思考结果都输出」,因此七项状态全部必须为 done,不接受 skipped。
|
|
105
|
+
for (const k of ['what', 'why', 'how', 'divide', 'execute', 'audit', 'answer']) {
|
|
106
|
+
if (s[k] !== 'done') out.push('steps.' + k + ' 必须为 done(每一步都要输出,不可 skipped)');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!Array.isArray(args.subtasks) || args.subtasks.length === 0)
|
|
110
|
+
out.push('subtasks(第 4 步子任务逐项执行与审计结果,至少 1 项)');
|
|
111
|
+
else {
|
|
112
|
+
for (let i = 0; i < args.subtasks.length; i++) {
|
|
113
|
+
const t = args.subtasks[i];
|
|
114
|
+
if (!t || typeof t !== 'object' || typeof t.task !== 'string' ||
|
|
115
|
+
typeof t.result !== 'string' || typeof t.audit !== 'string' || typeof t.passed !== 'boolean')
|
|
116
|
+
out.push('subtasks[' + i + '](task/result/audit/passed)');
|
|
117
|
+
else if (!t.passed)
|
|
118
|
+
out.push('subtasks[' + i + '].passed=false(子任务审计未通过,须带审计结果回第 1 步循环)');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (!Array.isArray(args.audit) || args.audit.length !== 8 || !args.audit.every((v) => v === true))
|
|
122
|
+
out.push('audit(8 条审计清单须全部为 true)');
|
|
123
|
+
if (args.concluded !== true) out.push('concluded(任务圆满完成才为 true)');
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function receiptTool(state, teamGate) {
|
|
128
|
+
return {
|
|
129
|
+
name: 'six_step_receipt',
|
|
130
|
+
description:
|
|
131
|
+
'六步思考执行凭证:1是什么→2为什么→3怎么做→4任务划分→5执行→6审计,每步输出且第 6 步审计全部通过后、' +
|
|
132
|
+
'给出最终答复之前必须调用。须完整填写「①复杂度前置判定 / ②路径选择 / ③六步逐项状态 / ' +
|
|
133
|
+
'④第 4 步子任务逐项执行与审计结果 / ⑤第 6 步审计 8 条清单 / ⑥任务是否圆满完成」。' +
|
|
134
|
+
'任一子任务 passed=false 或 concluded 不为 true 都会被 guard 拦回重做(须带审计结果回第 1 步循环,直到圆满完成)。' +
|
|
135
|
+
'若 complexity.verdict=复杂,guard 会核验 agentTeams 花名册确实有已启动的 teammate(防止只声明组队却单干);' +
|
|
136
|
+
'仅当任务是「改预设本身」的元任务例外时才可不组队,此时填 team.mode=meta-exception 并在 team.reason 写明理由。' +
|
|
137
|
+
'这是内部凭证,不会作为答复正文呈现;每一步都要输出,七项状态全部必须 done(不可 skipped)。',
|
|
138
|
+
parameters: {
|
|
139
|
+
type: 'object', additionalProperties: false,
|
|
140
|
+
required: ['complexity', 'path', 'steps', 'subtasks', 'audit', 'concluded'],
|
|
141
|
+
properties: {
|
|
142
|
+
complexity: {
|
|
143
|
+
type: 'object', additionalProperties: false,
|
|
144
|
+
required: ['triggered', 'safetyKeyword', 'verdict'],
|
|
145
|
+
properties: {
|
|
146
|
+
triggered: { type: 'array', items: { type: 'string' } },
|
|
147
|
+
safetyKeyword: { type: 'boolean' },
|
|
148
|
+
verdict: { type: 'string', enum: ['复杂', '简单'] },
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
path: { type: 'string', enum: ['light', 'standard', 'mixed'] },
|
|
152
|
+
steps: {
|
|
153
|
+
type: 'object', additionalProperties: false,
|
|
154
|
+
required: ['what', 'why', 'how', 'divide', 'execute', 'audit', 'answer'],
|
|
155
|
+
properties: {
|
|
156
|
+
what: { type: 'string', enum: ['done', 'skipped'] },
|
|
157
|
+
why: { type: 'string', enum: ['done', 'skipped'] },
|
|
158
|
+
how: { type: 'string', enum: ['done', 'skipped'] },
|
|
159
|
+
divide: { type: 'string', enum: ['done', 'skipped'] },
|
|
160
|
+
execute: { type: 'string', enum: ['done', 'skipped'] },
|
|
161
|
+
audit: { type: 'string', enum: ['done', 'skipped'] },
|
|
162
|
+
answer: { type: 'string', enum: ['done', 'skipped'] },
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
subtasks: {
|
|
166
|
+
type: 'array',
|
|
167
|
+
items: {
|
|
168
|
+
type: 'object', additionalProperties: false,
|
|
169
|
+
required: ['task', 'result', 'audit', 'passed'],
|
|
170
|
+
properties: {
|
|
171
|
+
task: { type: 'string' },
|
|
172
|
+
result: { type: 'string' },
|
|
173
|
+
audit: { type: 'string' },
|
|
174
|
+
passed: { type: 'boolean' },
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
audit: { type: 'array', items: { type: 'boolean' } },
|
|
179
|
+
concluded: { type: 'boolean' },
|
|
180
|
+
team: {
|
|
181
|
+
type: 'object', additionalProperties: false,
|
|
182
|
+
required: ['mode'],
|
|
183
|
+
properties: {
|
|
184
|
+
mode: { type: 'string', enum: ['team', 'meta-exception'] },
|
|
185
|
+
reason: { type: 'string' },
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
output: {
|
|
191
|
+
schema: {
|
|
192
|
+
type: 'object', additionalProperties: false,
|
|
193
|
+
required: ['accepted', 'message'],
|
|
194
|
+
properties: { accepted: { type: 'boolean' }, message: { type: 'string' } },
|
|
195
|
+
},
|
|
196
|
+
render: (_a, v) => [{ type: 'text', text: v.message }],
|
|
197
|
+
},
|
|
198
|
+
presentCall: () => ({ card: 'generic', title: '六步凭证', kind: 'other', rawInput: '已提交六步执行凭证' }),
|
|
199
|
+
execute(args, exec) {
|
|
200
|
+
const key = keyOf(exec?.agent);
|
|
201
|
+
const st = state.get(key) ?? { receipt: null, retries: 0 };
|
|
202
|
+
state.set(key, st);
|
|
203
|
+
const miss = missing(args);
|
|
204
|
+
if (miss.length) {
|
|
205
|
+
st.receipt = null;
|
|
206
|
+
return Promise.resolve({ accepted: false, message: '六步凭证不完整,缺少:' + miss.join('、') + '。补全后重新调用。' });
|
|
207
|
+
}
|
|
208
|
+
const gate = teamGate(exec?.agent, args);
|
|
209
|
+
if (!gate.ok) {
|
|
210
|
+
st.receipt = null;
|
|
211
|
+
return Promise.resolve({ accepted: false, message: '六步凭证被团队硬门禁拒绝:' + gate.reason + '。请真用 subagent 派生 teammate 走完团队路径后重新提交;若确属改预设本身的元任务例外,填 team.mode=meta-exception 并写明 reason。' });
|
|
212
|
+
}
|
|
213
|
+
st.receipt = args;
|
|
214
|
+
return Promise.resolve({ accepted: true, message: '六步执行凭证已登记,任务圆满完成,允许给出最终答复。' });
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function apply(ctx) {
|
|
220
|
+
const state = new WeakMap();
|
|
221
|
+
const warn = (msg) => { try { ctx.logger?.warn?.('[six-step-guard] ' + msg); } catch {} };
|
|
222
|
+
const teamGate = makeTeamGate(ctx);
|
|
223
|
+
|
|
224
|
+
ctx.tools.register(receiptTool(state, teamGate));
|
|
225
|
+
|
|
226
|
+
// 真实用户输入开启新一轮:清空上一轮的凭证与重做计数。注入的拦截消息
|
|
227
|
+
// source.kind = six-step-guard,不会触发重置,重做次数得以跨 step 保留。
|
|
228
|
+
ctx.on('agent/pre-step', ({ agent, messages }, next) => {
|
|
229
|
+
if (Array.isArray(messages) && messages.some((m) => m?.source?.kind === 'user')) {
|
|
230
|
+
const fresh = () => ({ receipt: null, retries: 0 });
|
|
231
|
+
state.set(keyOf(agent), fresh());
|
|
232
|
+
state.set(FALLBACK, fresh());
|
|
233
|
+
}
|
|
234
|
+
return next();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// 唯一能在「答完」之后拒绝收工的缝(serial,await 后才提交 turn 边界)。
|
|
238
|
+
ctx.on('agent/turn-stopping', ({ agent, turn }) => {
|
|
239
|
+
try {
|
|
240
|
+
// 复杂任务下派生的六步 teammate 只做单步,豁免强制凭证(顶层 Lead 仍必须提交)。
|
|
241
|
+
if (isTeammate(ctx, agent)) return;
|
|
242
|
+
const key = keyOf(agent);
|
|
243
|
+
const st = state.get(key) ?? { receipt: null, retries: 0 };
|
|
244
|
+
state.set(key, st);
|
|
245
|
+
// 兜底:工具执行时 exec.agent 缺失会把凭证记在 FALLBACK 槽,这里补认领。
|
|
246
|
+
if (!st.receipt && key !== FALLBACK) {
|
|
247
|
+
const fb = state.get(FALLBACK);
|
|
248
|
+
if (fb?.receipt) { st.receipt = fb.receipt; fb.receipt = null; }
|
|
249
|
+
}
|
|
250
|
+
// 兜底认领后再次过团队门禁:即使凭证是在 exec.agent 缺失时登记的,收工这一刻仍核验花名册。
|
|
251
|
+
if (st.receipt) {
|
|
252
|
+
const gate = teamGate(agent, st.receipt);
|
|
253
|
+
if (gate.ok) { st.receipt = null; st.retries = 0; return; }
|
|
254
|
+
st.receipt = null; // 门禁不通过 → 当作无凭证拦回重做
|
|
255
|
+
}
|
|
256
|
+
// 无重做次数上限:缺凭证就一直拦回,直到提交完整凭证才允许收工(与方法论循环对齐)。
|
|
257
|
+
st.retries += 1;
|
|
258
|
+
agent.steer(notice(
|
|
259
|
+
'【六步思考 · 执行完整性拦截】你在给出最终答复之前没有调用 six_step_receipt 提交完整凭证,本轮不允许收工。这是硬性要求,不是建议。' +
|
|
260
|
+
'必须按六步思考铁律重新完整走一遍并逐步输出,最终答复中须出现以下六个固定格子(顺序固定、缺一不可,轻量路径亦不例外,只是篇幅从简):' +
|
|
261
|
+
'【WHAT】是什么(逐字拆解,一个词都不漏)' +
|
|
262
|
+
'【WHY】为什么(意图判断 + 判据)' +
|
|
263
|
+
'【HOW】怎么做(执行方案 + 完成标准)' +
|
|
264
|
+
'【DIVIDE】任务划分(编号 / 输入 / 输出与验收 / 依赖)' +
|
|
265
|
+
'【EXECUTE】执行(每个子任务的执行结果)' +
|
|
266
|
+
'【AUDIT】审计(每个子任务按 8 条清单逐项勾选 + 总审计结论)。' +
|
|
267
|
+
'六格之外:①复杂度前置判定 → ②路径选择 也要输出;若审计不满足,带审计结果回第 1 步循环,直到任务圆满完成;' +
|
|
268
|
+
'然后在最终答复前调用 six_step_receipt 把每一环结果填全(steps 七项全 done、subtasks 逐项 passed=true、audit 8 条全 true、concluded=true)。' +
|
|
269
|
+
'若判定为复杂,必须真的用 subagent 派生 teammate 走完团队路径(guard 会核验 agentTeams 花名册);' +
|
|
270
|
+
'若确属改预设本身的元任务例外,须在凭证 team.mode=meta-exception 写明 reason。' +
|
|
271
|
+
'这是第 ' + st.retries + ' 次拦截(无次数上限,直到任务圆满完成)。',
|
|
272
|
+
'six-step receipt required · retry ' + st.retries
|
|
273
|
+
));
|
|
274
|
+
} catch (error) {
|
|
275
|
+
warn('turn-stopping handler error: ' + (error?.message ?? String(error)));
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-six-step",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./guard.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./guard.js",
|
|
8
|
+
"./guard.js": "./guard.js",
|
|
9
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"description": "六步思考 agent preset (是什么→为什么→怎么做→任务划分→执行→审计, every step output, audit loops back to step 1 until complete) with an execution-completeness guard; for complex tasks the Lead orchestrates six named teammates in strict serial order, compressing every piece of info passing through the Lead before relaying it (self-contained; no length caps on the teammates' own thinking), with very fine-grained task division and unlimited audit loops (simple tasks unchanged); in the standard flow the Lead stays light — only dispatch, output each teammate's reply as a compressed summary to the owner, then give the final result, never writing the six steps' thinking itself (heavy work is all done by sub-agents); meta-task edits to this preset stay single-agent with no team.",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "sweeete",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/sweeete/six-step.git"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"guard.js",
|
|
21
|
+
"cordis.patch.yml",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"dsh": {
|
|
26
|
+
"bundle": {
|
|
27
|
+
"patch": "./cordis.patch.yml"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|