@wwkit/harness 1.0.10 → 1.0.12
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/agents/lint.md +5 -4
- package/agents/work.md +674 -89
- package/commands/fix.md +77 -0
- package/package.json +3 -1
- package/plugins/work-bootstrap.js +77 -0
- package/scripts/work-review-package +50 -0
- package/scripts/work-task-brief +27 -0
- package/scripts/work-workspace +31 -0
- package/skills/lint-env-ensure/references/config.md +2 -2
- package/skills/read-docs/references/opencode/agents/index.md +2 -0
- package/skills/read-docs/references/opencode/agents/parallel-dispatch.md +149 -0
- package/skills/read-docs/references/opencode/agents/subagent-internals.md +217 -0
- package/skills/read-docs/references/superpowers/bootstrap.md +107 -0
- package/skills/read-docs/references/superpowers/comparison.md +77 -0
- package/skills/read-docs/references/superpowers/context.md +71 -0
- package/skills/read-docs/references/superpowers/index.md +58 -0
- package/skills/read-docs/references/superpowers/parallel.md +49 -0
- package/skills/read-docs/references/superpowers/sdd.md +183 -0
- package/skills/read-docs/references/superpowers/skills.md +68 -0
- package/skills/read-docs/references/superpowers/workflow.md +83 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Bootstrap 注入机制
|
|
2
|
+
|
|
3
|
+
## 安装方式
|
|
4
|
+
|
|
5
|
+
在 opencode 的 `opencode.json` 中注册:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"plugin": ["superpowers@git+https://github.com/obra/superpowers.git"]
|
|
10
|
+
}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
或使用本地路径:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"plugin": ["~/.config/opencode/node_modules/superpowers"]
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 插件入口
|
|
22
|
+
|
|
23
|
+
**文件**: `.opencode/plugins/superpowers.js`(`package.json` 的 `"main"`)
|
|
24
|
+
|
|
25
|
+
插件导出 `SuperpowersPlugin`,接收 `{ client, directory }` 参数,返回两个 hook:
|
|
26
|
+
|
|
27
|
+
| Hook | 作用 |
|
|
28
|
+
|------|------|
|
|
29
|
+
| `config` | 将 `skills/` 目录注册到 `config.skills.paths`,让 opencode 发现 superpowers 的 14 个技能 |
|
|
30
|
+
| `experimental.chat.messages.transform` | 将 `using-superpowers/SKILL.md` 的内容注入到会话的第一条 user message 前面 |
|
|
31
|
+
|
|
32
|
+
## Bootstrap 注入逻辑
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
// .opencode/plugins/superpowers.js (简化)
|
|
36
|
+
|
|
37
|
+
const getBootstrapContent = () => {
|
|
38
|
+
// 模块级缓存:SKILL.md 不变,只读一次
|
|
39
|
+
if (_bootstrapCache !== undefined) return _bootstrapCache
|
|
40
|
+
|
|
41
|
+
const skillPath = path.join(skillsDir, 'using-superpowers', 'SKILL.md')
|
|
42
|
+
const fullContent = fs.readFileSync(skillPath, 'utf8')
|
|
43
|
+
const { content } = extractAndStripFrontmatter(fullContent) // 去掉 frontmatter
|
|
44
|
+
|
|
45
|
+
_bootstrapCache = `<EXTREMELY_IMPORTANT>
|
|
46
|
+
You have superpowers.
|
|
47
|
+
|
|
48
|
+
**IMPORTANT: The using-superpowers skill content is included below. It is ALREADY LOADED - you are currently following it. Do NOT use the skill tool to load "using-superpowers" again - that would be redundant.**
|
|
49
|
+
|
|
50
|
+
${content}
|
|
51
|
+
|
|
52
|
+
${toolMapping}
|
|
53
|
+
</EXTREMELY_IMPORTANT>`
|
|
54
|
+
return _bootstrapCache
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
'experimental.chat.messages.transform': async (_input, output) => {
|
|
59
|
+
const bootstrap = getBootstrapContent()
|
|
60
|
+
if (!bootstrap || !output.messages.length) return
|
|
61
|
+
|
|
62
|
+
const firstUser = output.messages.find(m => m.info.role === 'user')
|
|
63
|
+
if (!firstUser || !firstUser.parts.length) return
|
|
64
|
+
|
|
65
|
+
// 幂等检查:已有注入则跳过
|
|
66
|
+
if (firstUser.parts.some(p => p.type === 'text' && p.text.includes('EXTREMELY_IMPORTANT'))) return
|
|
67
|
+
|
|
68
|
+
// 注入到第一条 user message 的 parts 最前面
|
|
69
|
+
const ref = firstUser.parts[0]
|
|
70
|
+
firstUser.parts.unshift({ ...ref, type: 'text', text: bootstrap })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 关键设计决策
|
|
76
|
+
|
|
77
|
+
1. **注入到 user message 而非 system message**:避免 system message 在每轮重复导致的 token 膨胀(#750),以及多 system message 破坏 Qwen 等模型的问题(#894)
|
|
78
|
+
2. **模块级缓存**:`messages.transform` 在每个 agent step 都触发(不只是每轮),缓存避免重复磁盘 IO(#1202)
|
|
79
|
+
3. **幂等检查**:通过 `EXTREMELY_IMPORTANT` 标记防止重复注入
|
|
80
|
+
4. **工具映射**:为 opencode 平台生成特定的工具映射表
|
|
81
|
+
|
|
82
|
+
## 工具映射(opencode 平台)
|
|
83
|
+
|
|
84
|
+
| 技能中的动作 | opencode 工具 |
|
|
85
|
+
|-------------|--------------|
|
|
86
|
+
| Create or update todos | `todowrite` |
|
|
87
|
+
| `Subagent (general-purpose):` | `task` with `subagent_type: "general"` |
|
|
88
|
+
| Invoke a skill | `skill` 工具 |
|
|
89
|
+
| Read files | `read` |
|
|
90
|
+
| Create, edit, or delete files | `apply_patch` |
|
|
91
|
+
| Run shell commands | `bash` |
|
|
92
|
+
| Search files | `grep`, `glob` |
|
|
93
|
+
| Fetch a URL | `webfetch` |
|
|
94
|
+
|
|
95
|
+
## 跨平台注入机制
|
|
96
|
+
|
|
97
|
+
| 平台 | 注入机制 | 触发时机 |
|
|
98
|
+
|------|---------|---------|
|
|
99
|
+
| opencode | `experimental.chat.messages.transform` hook | 每个 agent step |
|
|
100
|
+
| Claude Code | `SessionStart` hook → `additionalContext` | 会话启动/clear/compact |
|
|
101
|
+
| Cursor | `SessionStart` hook → `additional_context` | 会话启动 |
|
|
102
|
+
| Codex | 插件系统 | 插件加载 |
|
|
103
|
+
| Gemini CLI | 扩展系统 | 扩展加载 |
|
|
104
|
+
| Pi | 扩展 + 原生技能 | 会话启动 + compact 后 |
|
|
105
|
+
| Copilot CLI | `additionalContext` (SDK 标准) | 会话启动 |
|
|
106
|
+
|
|
107
|
+
Claude Code 的 session-start hook 是一个 bash 脚本,读取 `using-superpowers/SKILL.md`,JSON 转义后输出为 `additionalContext`。
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# 与 harness work agent 对比
|
|
2
|
+
|
|
3
|
+
## 架构对比
|
|
4
|
+
|
|
5
|
+
| 维度 | Superpowers | harness work agent |
|
|
6
|
+
|------|------------|-------------------|
|
|
7
|
+
| **编排者** | 宿主内置 agent + 技能 prompt | 自定义 `work` agent(`mode: primary`) |
|
|
8
|
+
| **编排指令来源** | `using-superpowers` bootstrap + 技能 | agent 定义文件本身 |
|
|
9
|
+
| **Worker** | 宿主内置 `general-purpose` | 宿主内置 `explore` / `general` |
|
|
10
|
+
| **自定义 agent** | 无 | 7 个(work/extract/revise/query/lint/pyit/pyut) |
|
|
11
|
+
| **技能系统** | 14 个技能,通过 `skill` 工具加载 | harness 自己的技能系统 |
|
|
12
|
+
| **平台** | 跨平台(11+ harness) | 仅 opencode |
|
|
13
|
+
|
|
14
|
+
## 调度策略对比
|
|
15
|
+
|
|
16
|
+
| 维度 | Superpowers SDD | work agent |
|
|
17
|
+
|------|----------------|------------|
|
|
18
|
+
| **任务并行** | ❌ 串行(禁止并行实现) | ✅ 允许 ≤5 并行 |
|
|
19
|
+
| **任务大小** | 2-5 分钟/任务 | ≤5 分钟/任务 |
|
|
20
|
+
| **Review** | 每任务两阶段(spec + quality) | 无强制 review |
|
|
21
|
+
| **Fix Loop** | ≤5 轮,含 model escalation | ≤3 轮重规划 |
|
|
22
|
+
| **状态持久化** | Ledger 文件(抗 compaction) | TodoWrite + 摘要 |
|
|
23
|
+
| **上下文传递** | 文件为主(brief/report/diff) | prompt 内联 |
|
|
24
|
+
| **模型选择** | 精细策略(按任务类型选模型) | 不涉及 |
|
|
25
|
+
| **容忍失败** | BLOCKED → 换模型/拆任务/升级 | failed 只记录不中断 |
|
|
26
|
+
|
|
27
|
+
## 上下文隔离对比
|
|
28
|
+
|
|
29
|
+
两者都利用 opencode 的子会话隔离(subagent 看不到父会话历史),但策略不同:
|
|
30
|
+
|
|
31
|
+
| 维度 | Superpowers | work agent |
|
|
32
|
+
|------|------------|------------|
|
|
33
|
+
| **prompt 自包含** | ✅ 必须自包含 | ✅ 必须自包含 |
|
|
34
|
+
| **上下文通过文件** | ✅ brief/report/diff 都是文件 | ❌ 上下文在 prompt 内 |
|
|
35
|
+
| **返回精简** | ✅ ≤15 行摘要,详情写文件 | ✅ 摘要协议 |
|
|
36
|
+
| **摘要格式** | Status + commits + test summary | status + 结论 + 变更 + 阻塞 + 建议 |
|
|
37
|
+
|
|
38
|
+
## Bootstrap 注入 vs Agent 定义
|
|
39
|
+
|
|
40
|
+
Superpowers 选择**不定义新 agent**,而是通过 `messages.transform` 注入 bootstrap 指令:
|
|
41
|
+
|
|
42
|
+
- **优势**:跨平台(同一套技能适用于 Claude Code/Codex/opencode 等),不需要每个平台定义 agent
|
|
43
|
+
- **代价**:bootstrap 内容在每次 agent step 都存在于 context 中(虽然通过注入到 user message 而非 system message 减少了重复)
|
|
44
|
+
- **限制**:无法使用 agent 级别的配置(如 `temperature`、`permission`、`tools` 限制)
|
|
45
|
+
|
|
46
|
+
harness 的 `work` agent 选择**定义自定义 agent**,获得更精细的控制,但绑定到 opencode 平台。
|
|
47
|
+
|
|
48
|
+
## 关键设计差异
|
|
49
|
+
|
|
50
|
+
### Review 策略
|
|
51
|
+
|
|
52
|
+
Superpowers 的 review 机制比 work agent 更精细:
|
|
53
|
+
- **每任务 review**:spec compliance + code quality 两阶段
|
|
54
|
+
- **Scoped re-review**:fix 后只验证 fix,不重新审查全部
|
|
55
|
+
- **Final review**:全分支审查,最强模型
|
|
56
|
+
- **Adjudication**:controller 在 Round 5 后裁决,每条裁决记入 ledger
|
|
57
|
+
|
|
58
|
+
### 文件传递
|
|
59
|
+
|
|
60
|
+
Superpowers 的一个核心创新是**大量使用文件传递上下文**:
|
|
61
|
+
- `task-brief` 脚本提取任务文本到文件
|
|
62
|
+
- implementer 报告写文件
|
|
63
|
+
- `review-package` 脚本生成 diff 包文件
|
|
64
|
+
- Ledger 记录进度到文件
|
|
65
|
+
|
|
66
|
+
这解决了两个问题:
|
|
67
|
+
1. **Controller context 保护**:大段文本不经过 controller 的 context window
|
|
68
|
+
2. **Compaction 恢复**:文件在 compaction 后仍然存在
|
|
69
|
+
|
|
70
|
+
### 模型分层
|
|
71
|
+
|
|
72
|
+
Superpowers 是少数明确实施模型分层策略的系统:
|
|
73
|
+
- 机械实现用便宜模型
|
|
74
|
+
- 判断任务用标准模型
|
|
75
|
+
- 架构/review 用最强模型
|
|
76
|
+
- Fix loop 升级模型
|
|
77
|
+
- Turn count > token price 的洞察
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# 上下文管理与模型选择
|
|
2
|
+
|
|
3
|
+
## 文件作为上下文媒介
|
|
4
|
+
|
|
5
|
+
Superpowers 的核心设计目标之一是**保护 controller 的 context window**:
|
|
6
|
+
|
|
7
|
+
| 信息 | 传递方式 | 原因 |
|
|
8
|
+
|------|---------|------|
|
|
9
|
+
| 任务详情(brief) | 文件 | 避免粘贴计划全文到 prompt |
|
|
10
|
+
| 实现报告(report) | 文件 | implementer 详情写文件,只返回 ≤15 行摘要 |
|
|
11
|
+
| Review diff | 文件 | `review-package` 生成 diff 包文件,reviewer 一次 Read |
|
|
12
|
+
| Findings | prompt 内联 | 需要精确传递给 fix implementer |
|
|
13
|
+
| Ledger | 文件 | 跨 compaction 持久化 |
|
|
14
|
+
| 上下文/接口 | prompt 内联 | subagent 看不到历史,必须自包含 |
|
|
15
|
+
|
|
16
|
+
**反模式(被明确禁止)**:
|
|
17
|
+
|
|
18
|
+
> A real session's dispatch hit 42k chars of which 99% was pasted history. A fresh subagent needs its task, the interfaces it touches, and the global constraints. Nothing else.
|
|
19
|
+
|
|
20
|
+
## Ledger 机制
|
|
21
|
+
|
|
22
|
+
Ledger 是 SDD 的状态持久化机制,解决 **compaction 导致上下文丢失** 的问题:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
文件: .superpowers/sdd/<plan-name>/progress.md
|
|
26
|
+
|
|
27
|
+
内容示例:
|
|
28
|
+
# SDD ledger — plan: docs/superpowers/plans/feature-plan.md
|
|
29
|
+
Task 1: complete (commits a1b2c3d..d4e5f6a, review clean)
|
|
30
|
+
Task 2: fix round 1/5 (2 addressed, 0 open; commits d4e5f6a..b7c8d9e)
|
|
31
|
+
Task 2: complete (commits d4e5f6a..b7c8d9e, review clean)
|
|
32
|
+
Task 3: parked — magic number — ruling: plan mandates constant, deferred to final review
|
|
33
|
+
Task 3: complete (commits b7c8d9e..e8f9a0b, 1 parked)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**为什么需要 Ledger**:
|
|
37
|
+
|
|
38
|
+
> Conversation memory does not survive compaction. In real sessions, controllers that lost their place have re-dispatched entire completed task sequences — the single most expensive failure observed.
|
|
39
|
+
|
|
40
|
+
Ledger 的恢复逻辑:
|
|
41
|
+
- 第一行命名计划文件 → 确认归属
|
|
42
|
+
- `Task <N>: complete` → 已完成,不重新派发
|
|
43
|
+
- 最后一行是 fix round → 中断在 loop 中,从下一轮恢复
|
|
44
|
+
- 第一行命名不同计划 → 别人的 ledger,不动它,重新开始
|
|
45
|
+
|
|
46
|
+
## Model Selection 策略
|
|
47
|
+
|
|
48
|
+
| 任务类型 | 模型层级 | 理由 |
|
|
49
|
+
|---------|---------|------|
|
|
50
|
+
| 机械实现(1-2 文件,完整 spec) | 最便宜 | 计划已包含完整代码,只是转录+测试 |
|
|
51
|
+
| 集成/判断(多文件协调) | 标准 | 需要理解跨文件影响 |
|
|
52
|
+
| 架构/设计 | 最强 | 需要设计判断 |
|
|
53
|
+
| Task Reviewer | 按难度选择 | 小 diff 用便宜模型,并发/安全用强模型 |
|
|
54
|
+
| Fix Loop Round 4-5 | 比原 implementer 强一级 | fresh eyes + capability bump |
|
|
55
|
+
| Final Review | 最强 | 全分支审查,最重要 |
|
|
56
|
+
| Scoped Re-review | 便宜-中档 | 只验证 fix,范围小 |
|
|
57
|
+
|
|
58
|
+
**关键洞察**:
|
|
59
|
+
|
|
60
|
+
> Turn count beats token price. Wall-clock and context cost scale with how many turns a subagent takes, and the cheapest models routinely take 2-3× the turns on multi-step work — costing more overall.
|
|
61
|
+
|
|
62
|
+
因此:reviewer 和从 prose 描述工作的 implementer 最低用中档模型;计划文本包含完整代码时才用最便宜模型。
|
|
63
|
+
|
|
64
|
+
## Subagent 类型
|
|
65
|
+
|
|
66
|
+
Superpowers 只使用宿主平台的内置 agent,不定义自定义 agent:
|
|
67
|
+
|
|
68
|
+
| subagent_type | 使用场景 | 来源 |
|
|
69
|
+
|---------------|---------|------|
|
|
70
|
+
| `general-purpose` / `general` | 实现、review、fix | opencode 内置 |
|
|
71
|
+
| `explore` | 代码库探索(brainstorming 阶段) | opencode 内置 |
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Superpowers 概述
|
|
2
|
+
|
|
3
|
+
> 基于 superpowers v6.2.0 源码分析。源码位置:`~/.config/opencode/node_modules/superpowers/`
|
|
4
|
+
|
|
5
|
+
## 是什么
|
|
6
|
+
|
|
7
|
+
Superpowers 是一个跨平台的 coding agent 增强插件,通过 **skills(技能)** + **bootstrap 注入** 实现 agent 行为编排。它的核心不是定义新的 agent 类型,而是通过在会话启动时注入一段"元指令"(`using-superpowers`),强制 agent 在执行任何任务前先检查并加载相关技能。
|
|
8
|
+
|
|
9
|
+
## 核心架构
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
用户输入
|
|
13
|
+
│
|
|
14
|
+
▼
|
|
15
|
+
┌─────────────────────────────────────────┐
|
|
16
|
+
│ Bootstrap 注入(messages.transform) │
|
|
17
|
+
│ 将 using-superpowers SKILL.md 内容 │
|
|
18
|
+
│ 注入到第一条 user message 的 parts 前面 │
|
|
19
|
+
└──────────────────┬──────────────────────┘
|
|
20
|
+
│
|
|
21
|
+
▼
|
|
22
|
+
┌─────────────────────────────────────────┐
|
|
23
|
+
│ Agent 看到 bootstrap 指令 │
|
|
24
|
+
│ "你有 superpowers,必须先检查技能" │
|
|
25
|
+
│ │ │
|
|
26
|
+
│ ├─ "构建功能" → 加载 brainstorming 技能 │
|
|
27
|
+
│ ├─ "修 bug" → 加载 systematic-debugging│
|
|
28
|
+
│ └─ "执行计划" → 加载 SDD 或 executing │
|
|
29
|
+
└──────────────────┬──────────────────────┘
|
|
30
|
+
│
|
|
31
|
+
▼
|
|
32
|
+
┌─────────────────────────────────────────┐
|
|
33
|
+
│ 技能驱动的工作流 │
|
|
34
|
+
│ brainstorming → writing-plans → │
|
|
35
|
+
│ subagent-driven-development → │
|
|
36
|
+
│ requesting-code-review → │
|
|
37
|
+
│ finishing-a-development-branch │
|
|
38
|
+
└─────────────────────────────────────────┘
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 与 harness work agent 的区别
|
|
42
|
+
|
|
43
|
+
| 维度 | Superpowers | harness work agent |
|
|
44
|
+
|------|------------|-------------------|
|
|
45
|
+
| 编排者 | 宿主内置 agent + 技能 prompt | 自定义 `work` agent(`mode: primary`) |
|
|
46
|
+
| Worker | 宿主内置 `general-purpose` | 宿主内置 `explore` / `general` |
|
|
47
|
+
| 自定义 agent | 无 | 7 个(work/extract/revise/query/lint/pyit/pyut) |
|
|
48
|
+
| 平台 | 跨平台(11+ harness) | 仅 opencode |
|
|
49
|
+
|
|
50
|
+
## 模块索引
|
|
51
|
+
|
|
52
|
+
- [Bootstrap 注入](/superpowers/bootstrap) — 插件加载、messages.transform hook、跨平台注入
|
|
53
|
+
- [技能体系](/superpowers/skills) — 14 个技能、自动触发、Red Flags
|
|
54
|
+
- [主工作流](/superpowers/workflow) — brainstorming → plans → SDD → review → finish
|
|
55
|
+
- [Subagent-Driven Development](/superpowers/sdd) — SDD 核心流程、implementer/reviewer 模板、fix loop
|
|
56
|
+
- [并行派发](/superpowers/parallel) — dispatching-parallel-agents 技能
|
|
57
|
+
- [上下文管理](/superpowers/context) — 文件传递、Ledger、Model Selection
|
|
58
|
+
- [与 work agent 对比](/superpowers/comparison) — 架构、调度策略、上下文隔离的逐项对比
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# 并行派发(dispatching-parallel-agents)
|
|
2
|
+
|
|
3
|
+
## 与 SDD 的区别
|
|
4
|
+
|
|
5
|
+
| 维度 | SDD | dispatching-parallel-agents |
|
|
6
|
+
|------|-----|---------------------------|
|
|
7
|
+
| 场景 | 执行计划中的串行任务 | 修复多个独立问题 |
|
|
8
|
+
| 并行 | ❌ 禁止并行实现 | ✅ 核心就是并行 |
|
|
9
|
+
| 任务来源 | 实现计划 | 多个独立失败(不同文件/子系统) |
|
|
10
|
+
| Review | 每任务两阶段 review | 返回后统一验证 |
|
|
11
|
+
| 模型选择 | 精细策略 | 统一用 general-purpose |
|
|
12
|
+
|
|
13
|
+
## 使用条件
|
|
14
|
+
|
|
15
|
+
**使用**:
|
|
16
|
+
- 3+ 个独立失败(不同根因)
|
|
17
|
+
- 各问题可独立理解(不需交叉上下文)
|
|
18
|
+
- 无共享状态(不会编辑同一文件)
|
|
19
|
+
|
|
20
|
+
**不使用**:
|
|
21
|
+
- 失败相关(修一个可能修复其他)
|
|
22
|
+
- 需要理解全局系统状态
|
|
23
|
+
- agent 会互相干扰
|
|
24
|
+
|
|
25
|
+
## 派发模式
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
# 3 个独立失败,一条消息 3 个 task 调用
|
|
29
|
+
Subagent (general-purpose): "Fix agent-tool-abort.test.ts failures"
|
|
30
|
+
Subagent (general-purpose): "Fix batch-completion-behavior.test.ts failures"
|
|
31
|
+
Subagent (general-purpose): "Fix tool-approval-race-conditions.test.ts failures"
|
|
32
|
+
# 全部并行执行
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> Multiple dispatch calls in one response = parallel execution. One per response = sequential.
|
|
36
|
+
|
|
37
|
+
## Prompt 结构要求
|
|
38
|
+
|
|
39
|
+
好的并行 agent prompt:
|
|
40
|
+
1. **Focused** — 一个清晰的问题域
|
|
41
|
+
2. **Self-contained** — 理解问题所需的全部上下文
|
|
42
|
+
3. **Specific about output** — agent 应返回什么
|
|
43
|
+
|
|
44
|
+
## 返回后验证
|
|
45
|
+
|
|
46
|
+
1. **Review each summary** — 理解什么变了
|
|
47
|
+
2. **Check for conflicts** — agent 是否编辑了同一代码
|
|
48
|
+
3. **Run full suite** — 验证所有 fix 协同工作
|
|
49
|
+
4. **Spot check** — agent 可能有系统性错误
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Subagent-Driven Development (SDD)
|
|
2
|
+
|
|
3
|
+
## 核心原则
|
|
4
|
+
|
|
5
|
+
> **Fresh subagent per task + task review (spec + quality) + broad final review = high quality, fast iteration**
|
|
6
|
+
|
|
7
|
+
## SDD 完整流程
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
11
|
+
│ Setup │
|
|
12
|
+
│ ├─ 确保在隔离工作区(using-git-worktrees) │
|
|
13
|
+
│ ├─ 创建 SDD 工作区目录: .superpowers/sdd/<plan-name>/ │
|
|
14
|
+
│ ├─ 检查 Ledger(progress.md)确定已完成任务 │
|
|
15
|
+
│ ├─ 读取计划,创建 todos │
|
|
16
|
+
│ └─ 预审计划冲突(任务矛盾、与约束冲突) │
|
|
17
|
+
├─────────────────────────────────────────────────────────────┤
|
|
18
|
+
│ Per Task Loop │
|
|
19
|
+
│ │ │
|
|
20
|
+
│ ├─ 1. 记录 BASE = git rev-parse HEAD │
|
|
21
|
+
│ ├─ 2. 提取任务 brief: scripts/task-brief PLAN N │
|
|
22
|
+
│ │ → .superpowers/sdd/<plan>/task-N-brief.md │
|
|
23
|
+
│ ├─ 3. 派发 implementer subagent │
|
|
24
|
+
│ │ prompt 包含: brief 路径 + report 路径 + 上下文 │
|
|
25
|
+
│ │ (不粘贴计划全文,不让 subagent 读整个计划) │
|
|
26
|
+
│ │ │
|
|
27
|
+
│ ├─ 4. 处理 implementer 报告 │
|
|
28
|
+
│ │ DONE → 生成 review package,派发 task reviewer │
|
|
29
|
+
│ │ DONE_WITH_CONCERNS → 读顾虑,决定是否先处理 │
|
|
30
|
+
│ │ NEEDS_CONTEXT → 补充上下文,重新派发 │
|
|
31
|
+
│ │ BLOCKED → 评估阻塞,换模型/拆任务/升级 │
|
|
32
|
+
│ │ │
|
|
33
|
+
│ ├─ 5. Task Review(两阶段) │
|
|
34
|
+
│ │ a. Spec Compliance: 对照 brief 检查实现 │
|
|
35
|
+
│ │ b. Code Quality: 清洁性/DRY/边界情况 │
|
|
36
|
+
│ │ verdict: ✅ + Approved → 完成任务 │
|
|
37
|
+
│ │ verdict: ❌ 或有 Critical/Important → 进入 fix loop │
|
|
38
|
+
│ │ │
|
|
39
|
+
│ ├─ 6. Fix Loop(最多 5 轮) │
|
|
40
|
+
│ │ Round 1-3: 恢复原 implementer(context 完整) │
|
|
41
|
+
│ │ Round 4-5: 新 implementer + 更强模型(fresh eyes) │
|
|
42
|
+
│ │ 每轮: fix → re-test → scoped re-review │
|
|
43
|
+
│ │ Round 5 仍有 open findings → Adjudicate │
|
|
44
|
+
│ │ │
|
|
45
|
+
│ ├─ 7. Adjudicate(仅 Round 5 触发) │
|
|
46
|
+
│ │ reviewer 错误/可争议 → park with ruling │
|
|
47
|
+
│ │ 真问题但不 load-bearing → park with ruling │
|
|
48
|
+
│ │ 真问题且 load-bearing → STOP, report BLOCKED │
|
|
49
|
+
│ │ │
|
|
50
|
+
│ └─ 8. 完成: 写 ledger, 标记 todo complete │
|
|
51
|
+
│ │
|
|
52
|
+
│ → 下一任务(串行,不并行) │
|
|
53
|
+
├─────────────────────────────────────────────────────────────┤
|
|
54
|
+
│ Final Review │
|
|
55
|
+
│ ├─ 生成全分支 review package (MERGE_BASE..HEAD) │
|
|
56
|
+
│ ├─ 派发 final reviewer(最强模型) │
|
|
57
|
+
│ ├─ 有 findings → 一次 fix dispatch + 一次 scoped re-review │
|
|
58
|
+
│ └─ 残留 load-bearing findings → 报告给用户 │
|
|
59
|
+
├─────────────────────────────────────────────────────────────┤
|
|
60
|
+
│ Finish │
|
|
61
|
+
│ ├─ 删除 SDD 工作区(git 历史是记录) │
|
|
62
|
+
│ └─ 调用 finishing-a-development-branch 技能 │
|
|
63
|
+
└─────────────────────────────────────────────────────────────┘
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Implementer Subagent 派发
|
|
67
|
+
|
|
68
|
+
**模板**: `implementer-prompt.md`
|
|
69
|
+
|
|
70
|
+
派发 prompt 结构:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
Subagent (general-purpose):
|
|
74
|
+
description: "Implement Task N: [task name]"
|
|
75
|
+
model: [MODEL — 必填,按 Model Selection 选择]
|
|
76
|
+
prompt: |
|
|
77
|
+
You are implementing Task N: [task name]
|
|
78
|
+
|
|
79
|
+
## Task Description
|
|
80
|
+
Read your task brief first: [BRIEF_FILE]
|
|
81
|
+
|
|
82
|
+
## Context
|
|
83
|
+
[场景设置:任务在项目中的位置、依赖、架构上下文]
|
|
84
|
+
|
|
85
|
+
## Your Job
|
|
86
|
+
1. Implement exactly what the task specifies
|
|
87
|
+
2. Write tests (following TDD if task says to)
|
|
88
|
+
3. Verify implementation works
|
|
89
|
+
4. Commit your work
|
|
90
|
+
5. Self-review
|
|
91
|
+
6. Report back
|
|
92
|
+
|
|
93
|
+
## Report Format
|
|
94
|
+
Write your full report to [REPORT_FILE].
|
|
95
|
+
|
|
96
|
+
Then report back with ONLY (under 15 lines):
|
|
97
|
+
- Status: DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT
|
|
98
|
+
- Commits created
|
|
99
|
+
- One-line test summary
|
|
100
|
+
- Concerns
|
|
101
|
+
- Report file path
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**关键设计**:
|
|
105
|
+
1. **文件传递上下文**:brief 和 report 都是文件,不经过 controller 的 context window
|
|
106
|
+
2. **简短返回**:implementer 只返回 ≤15 行的状态摘要,详情写文件
|
|
107
|
+
3. **model 必填**:省略 model 会继承 session 最贵模型
|
|
108
|
+
4. **不并行实现任务**:`Never dispatch multiple implementation subagents in parallel (conflicts)`
|
|
109
|
+
|
|
110
|
+
## Task Reviewer Subagent
|
|
111
|
+
|
|
112
|
+
**模板**: `task-reviewer-prompt.md`
|
|
113
|
+
|
|
114
|
+
Reviewer 获取三个文件路径 + 全局约束:
|
|
115
|
+
- BRIEF_FILE — 任务详情
|
|
116
|
+
- REPORT_FILE — implementer 的报告
|
|
117
|
+
- DIFF_FILE — review package(commits + stat + full diff with -U10 context)
|
|
118
|
+
|
|
119
|
+
**两阶段 review**:
|
|
120
|
+
1. **Spec Compliance**:Missing / Extra / Misunderstood
|
|
121
|
+
2. **Code Quality**:Clean separation / Error handling / DRY / Edge cases / Tests verify real behavior
|
|
122
|
+
|
|
123
|
+
**关键原则**:
|
|
124
|
+
- **不信任 implementer 报告**:`Treat the implementer's report as unverified claims`
|
|
125
|
+
- **不重新运行测试**:implementer 已运行并报告,reviewer 只在阅读代码产生具体疑虑时才跑 focused test
|
|
126
|
+
- **不做全库爬取**:`Do not crawl the broader codebase`
|
|
127
|
+
|
|
128
|
+
## Fix Loop 机制
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
Review 有 Critical/Important findings
|
|
132
|
+
│
|
|
133
|
+
▼
|
|
134
|
+
Round 1-3: 恢复原 implementer
|
|
135
|
+
├─ 发送 open findings verbatim
|
|
136
|
+
├─ implementer fix → re-test → append fix report
|
|
137
|
+
├─ 生成 scoped review package (FIX_BASE..HEAD)
|
|
138
|
+
└─ 派发 re-reviewer (re-review-prompt.md)
|
|
139
|
+
├─ ADDRESSED → 该 finding 关闭
|
|
140
|
+
└─ NOT ADDRESSED → 继续 open
|
|
141
|
+
│
|
|
142
|
+
▼ (有 open findings)
|
|
143
|
+
Round 4-5: 新 implementer + 更强模型
|
|
144
|
+
├─ "A prior implementer attempted this task [N] times; you own it now."
|
|
145
|
+
├─ 同样流程: fix → re-test → scoped re-review
|
|
146
|
+
└─ ...
|
|
147
|
+
│
|
|
148
|
+
▼ (Round 5 仍有 open findings)
|
|
149
|
+
Adjudicate (controller 自己裁决)
|
|
150
|
+
├─ reviewer 错误 → park with ruling
|
|
151
|
+
├─ 真但不 load-bearing → park with ruling
|
|
152
|
+
└─ 真且 load-bearing → STOP, report BLOCKED
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Re-review 是 scoped 的**:只验证 findings 是否解决 + 检查 fix diff 是否引入新问题。不重新审查未改动代码。out-of-scope 观察记入 ledger,不扩展 loop。
|
|
156
|
+
|
|
157
|
+
## SDD 工作区
|
|
158
|
+
|
|
159
|
+
每个计划有独立的工作区目录:
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
.superpowers/sdd/
|
|
163
|
+
.gitignore # 内容: *(忽略所有)
|
|
164
|
+
<plan-name>/
|
|
165
|
+
progress.md # Ledger
|
|
166
|
+
task-1-brief.md # 任务 1 的完整文本
|
|
167
|
+
task-1-report.md # 任务 1 implementer 的报告
|
|
168
|
+
review-a1b2..d4e5.diff # 任务 1 的 review package
|
|
169
|
+
...
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**设计原因**:
|
|
173
|
+
- `.superpowers/sdd/` 在 `.gitignore` 中,不污染 git status
|
|
174
|
+
- 不在 `.git/` 下(Claude Code 禁止 agent 写 `.git/`)
|
|
175
|
+
- 每计划独立目录,防止并发计划互相干扰
|
|
176
|
+
|
|
177
|
+
## 辅助脚本
|
|
178
|
+
|
|
179
|
+
| 脚本 | 作用 |
|
|
180
|
+
|------|------|
|
|
181
|
+
| `scripts/task-brief PLAN N` | 从计划文件提取第 N 个任务的完整文本到 `task-N-brief.md` |
|
|
182
|
+
| `scripts/review-package PLAN BASE HEAD` | 生成 diff 包(commits + stat + full diff -U10)到文件 |
|
|
183
|
+
| `scripts/sdd-workspace PLAN` | 解析并创建计划的工作区目录 |
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# 技能体系
|
|
2
|
+
|
|
3
|
+
## 技能列表
|
|
4
|
+
|
|
5
|
+
Superpowers 包含 14 个技能,覆盖完整的软件开发流程:
|
|
6
|
+
|
|
7
|
+
| 技能 | 阶段 | 说明 |
|
|
8
|
+
|------|------|------|
|
|
9
|
+
| `using-superpowers` | 元技能 | Bootstrap:如何发现和使用技能 |
|
|
10
|
+
| `brainstorming` | 需求 | 苏格拉底式设计对话,产出 spec |
|
|
11
|
+
| `writing-plans` | 规划 | 将 spec 拆解为 bite-sized 任务计划 |
|
|
12
|
+
| `using-git-worktrees` | 隔离 | 创建隔离工作区 |
|
|
13
|
+
| `subagent-driven-development` | 执行(SDD) | 每任务一个 subagent + 两阶段 review |
|
|
14
|
+
| `executing-plans` | 执行(inline) | 批量执行 + 检查点(无 subagent 时的替代) |
|
|
15
|
+
| `dispatching-parallel-agents` | 执行(并行) | 并行派发独立问题的修复 |
|
|
16
|
+
| `test-driven-development` | 实现 | RED-GREEN-REFACTOR |
|
|
17
|
+
| `systematic-debugging` | 调试 | 4 阶段根因分析 |
|
|
18
|
+
| `requesting-code-review` | 审查 | 派发 reviewer subagent |
|
|
19
|
+
| `receiving-code-review` | 审查 | 响应 review 反馈 |
|
|
20
|
+
| `verification-before-completion` | 验证 | 完成前验证 |
|
|
21
|
+
| `finishing-a-development-branch` | 收尾 | merge/PR/keep 决策 |
|
|
22
|
+
| `writing-skills` | 元技能 | 创建新技能 |
|
|
23
|
+
|
|
24
|
+
## 技能自动触发
|
|
25
|
+
|
|
26
|
+
`using-superpowers` 是所有技能的入口。它的核心规则:
|
|
27
|
+
|
|
28
|
+
> **Invoke relevant or requested skills BEFORE any response or action** — including clarifying questions, exploring the codebase, or checking files.
|
|
29
|
+
|
|
30
|
+
这意味着 agent 在回答任何问题(包括澄清问题)之前,必须先检查是否有相关技能。技能通过 `<SUBAGENT-STOP>` 标记跳过被派发为 subagent 的会话:
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
<SUBAGENT-STOP>
|
|
34
|
+
If you were dispatched as a subagent to execute a specific task, ignore this skill.
|
|
35
|
+
</SUBAGENT-STOP>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 验收测试
|
|
39
|
+
|
|
40
|
+
> A working integration auto-triggers the `brainstorming` skill before any code is written.
|
|
41
|
+
|
|
42
|
+
用户说 "Let's make a react todo list" 时,agent 应自动触发 `brainstorming` 技能。
|
|
43
|
+
|
|
44
|
+
## Red Flags 表
|
|
45
|
+
|
|
46
|
+
`using-superpowers` 包含一个 Red Flags 表,列出 agent 可能用来"合理化"跳过技能的借口:
|
|
47
|
+
|
|
48
|
+
| Thought | Reality |
|
|
49
|
+
|---------|---------|
|
|
50
|
+
| "This is just a simple question" | Questions are tasks. Check for skills. |
|
|
51
|
+
| "I need more context first" | Skill check comes BEFORE clarifying questions. |
|
|
52
|
+
| "Let me explore the codebase first" | Skills tell you HOW to explore. Check first. |
|
|
53
|
+
| "I can check git/files quickly" | Files lack conversation context. Check for skills. |
|
|
54
|
+
| "This doesn't need a formal skill" | If a skill exists, use it. |
|
|
55
|
+
| "I remember this skill" | Skills evolve. Read current version. |
|
|
56
|
+
| "The skill is overkill" | Simple things become complex. Use it. |
|
|
57
|
+
| "I'll just do this one thing first" | Check BEFORE doing anything. |
|
|
58
|
+
|
|
59
|
+
## 技能优先级
|
|
60
|
+
|
|
61
|
+
> When multiple skills apply, process skills come first — they set the approach, then implementation skills carry it out.
|
|
62
|
+
|
|
63
|
+
- "Let's build X" → `brainstorming` first, then implementation skills
|
|
64
|
+
- "Fix this bug" → `systematic-debugging` first, then domain skills
|
|
65
|
+
|
|
66
|
+
## 用户指令优先级
|
|
67
|
+
|
|
68
|
+
> User instructions (CLAUDE.md, AGENTS.md, GEMINI.md, etc, direct requests) take precedence over skills, which in turn override default behavior. Only skip skill workflows or instructions when your human partner has explicitly told you to.
|