@wwkit/harness 1.0.9 → 1.0.11
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/extract.md +2 -14
- package/agents/lint.md +368 -0
- package/agents/pyit.md +361 -0
- package/agents/pyut.md +347 -0
- package/agents/query.md +2 -14
- package/agents/revise.md +2 -14
- package/agents/work.md +631 -0
- package/commands/fix.md +77 -0
- package/commands/git-sync.md +218 -0
- package/commands/net-port.md +364 -0
- package/commands/pyit.md +6 -0
- package/commands/pyut.md +6 -0
- package/commands/resume.md +104 -0
- package/package.json +4 -2
- 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/better-skill/SKILL.md +124 -0
- package/skills/blame-skill/SKILL.md +201 -0
- package/skills/lint-ai-fix/SKILL.md +141 -0
- package/skills/lint-config-setup/SKILL.md +106 -0
- package/skills/lint-config-setup/references/languages/js.md +110 -0
- package/skills/lint-config-setup/references/languages/py.md +89 -0
- package/skills/lint-env-ensure/SKILL.md +92 -0
- package/skills/lint-env-ensure/references/config.md +65 -0
- package/skills/lint-language-detect/SKILL.md +79 -0
- package/skills/lint-language-detect/references/detect-language.js +65 -0
- package/skills/lint-rules-analyze/SKILL.md +129 -0
- package/skills/lint-suitability-check/SKILL.md +84 -0
- package/skills/lint-tool-fix/SKILL.md +94 -0
- package/skills/new-skill/SKILL.md +227 -0
- package/skills/new-skill/references/template.md +53 -0
- package/skills/new-skill/references/workflow-patterns.md +104 -0
- package/skills/pytest-case-create/SKILL.md +327 -0
- package/skills/pytest-case-create/references/test-standards.md +244 -0
- package/skills/pytest-case-fix/SKILL.md +274 -0
- package/skills/pytest-coverage-analyze/SKILL.md +226 -0
- package/skills/pytest-coverage-analyze/references/scoring-rules.md +57 -0
- package/skills/pytest-env-ensure/SKILL.md +198 -0
- package/skills/pytest-env-ensure/references/config.md +145 -0
- package/skills/pytest-execute/SKILL.md +155 -0
- package/skills/pytest-sample/SKILL.md +164 -0
- package/skills/pytest-sample/references/src/pytest-sample/Calculator.py +67 -0
- package/skills/pytest-sample/references/src/pytest-sample/ConfigManager.py +68 -0
- package/skills/pytest-sample/references/src/pytest-sample/FileProcessor.py +53 -0
- package/skills/pytest-sample/references/src/pytest-sample/OrderService.py +82 -0
- package/skills/pytest-sample/references/src/pytest-sample/TokenGenerator.py +50 -0
- package/skills/pytest-sample/references/src/pytest-sample/UserService.py +45 -0
- package/skills/pytest-sample/references/src/pytest-sample/__init__.py +0 -0
- package/skills/pytest-suitability-check/SKILL.md +224 -0
- package/skills/read-docs/SKILL.md +134 -0
- package/skills/read-docs/references/opencode/agents/cases.md +206 -0
- package/skills/read-docs/references/opencode/agents/design-pattern.md +47 -0
- package/skills/read-docs/references/opencode/agents/detail.md +191 -0
- package/skills/read-docs/references/opencode/agents/examples.md +100 -0
- package/skills/read-docs/references/opencode/agents/index.md +309 -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/opencode/agents/workflow.md +161 -0
- package/skills/read-docs/references/opencode/cli/commands/acp.md +32 -0
- package/skills/read-docs/references/opencode/cli/commands/agent.md +16 -0
- package/skills/read-docs/references/opencode/cli/commands/attach.md +20 -0
- package/skills/read-docs/references/opencode/cli/commands/mcp.md +37 -0
- package/skills/read-docs/references/opencode/cli/commands/others.md +49 -0
- package/skills/read-docs/references/opencode/cli/commands/plugin.md +13 -0
- package/skills/read-docs/references/opencode/cli/commands/provider.md +44 -0
- package/skills/read-docs/references/opencode/cli/commands/run.md +81 -0
- package/skills/read-docs/references/opencode/cli/commands/serve.md +84 -0
- package/skills/read-docs/references/opencode/cli/commands/session.md +38 -0
- package/skills/read-docs/references/opencode/cli/commands/web.md +15 -0
- package/skills/read-docs/references/opencode/cli/env.md +39 -0
- package/skills/read-docs/references/opencode/cli/index.md +19 -0
- package/skills/read-docs/references/opencode/cli/tui.md +35 -0
- package/skills/read-docs/references/opencode/commands/examples.md +42 -0
- package/skills/read-docs/references/opencode/commands/index.md +185 -0
- package/skills/read-docs/references/opencode/config/provider.md +152 -0
- package/skills/read-docs/references/opencode/formatter/index.md +71 -0
- package/skills/read-docs/references/opencode/guide/config.md +419 -0
- package/skills/read-docs/references/opencode/guide/formatters.md +70 -0
- package/skills/read-docs/references/opencode/guide/index.md +37 -0
- package/skills/read-docs/references/opencode/guide/providers.md +31 -0
- package/skills/read-docs/references/opencode/guide/rules.md +63 -0
- package/skills/read-docs/references/opencode/plugins/examples.md +75 -0
- package/skills/read-docs/references/opencode/plugins/index.md +188 -0
- package/skills/read-docs/references/opencode/reference/index.md +119 -0
- package/skills/read-docs/references/opencode/rule/index.md +78 -0
- package/skills/read-docs/references/opencode/skills/detail.md +113 -0
- package/skills/read-docs/references/opencode/skills/examples.md +141 -0
- package/skills/read-docs/references/opencode/skills/index.md +126 -0
- package/skills/read-docs/references/opencode/skills/workflow.md +146 -0
- package/skills/read-docs/references/opencode/tests/agent.md +10 -0
- package/skills/read-docs/references/opencode/tests/config.md +60 -0
- package/skills/read-docs/references/opencode/tests/file.md +12 -0
- package/skills/read-docs/references/opencode/tests/serve.md +18 -0
- package/skills/read-docs/references/opencode/tests/session.md +31 -0
- package/skills/read-docs/references/opencode/tests/web.md +17 -0
- package/skills/read-docs/references/opencode/tools/arguments.md +305 -0
- package/skills/read-docs/references/opencode/tools/context.md +18 -0
- package/skills/read-docs/references/opencode/tools/custom.md +111 -0
- package/skills/read-docs/references/opencode/tools/detail.md +104 -0
- package/skills/read-docs/references/opencode/tools/examples.md +71 -0
- package/skills/read-docs/references/opencode/tools/index.md +56 -0
- package/skills/read-docs/references/opencode/tools/lsp.md +26 -0
- package/skills/read-docs/references/opencode/tools/mcp.md +132 -0
- package/skills/read-docs/references/opencode/train/README.md +135 -0
- package/skills/read-docs/references/opencode/train/agent-basic.md +772 -0
- package/skills/read-docs/references/opencode/train/command-basic.md +668 -0
- package/skills/read-docs/references/opencode/train/config-basic.md +509 -0
- package/skills/read-docs/references/opencode/train/index.md +164 -0
- package/skills/read-docs/references/opencode/train/practice.md +873 -0
- package/skills/read-docs/references/opencode/train/skill-basic.md +608 -0
- package/skills/read-docs/references/opencode/tui/commands/config.md +32 -0
- package/skills/read-docs/references/opencode/tui/commands/editor.md +47 -0
- package/skills/read-docs/references/opencode/tui/commands/index.md +125 -0
- package/skills/read-docs/references/opencode/tui/commands/init.md +5 -0
- package/skills/read-docs/references/opencode/tui/index.md +26 -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,125 @@
|
|
|
1
|
+
# Commands
|
|
2
|
+
Type `/` followed by a command name to execute
|
|
3
|
+
```
|
|
4
|
+
/help
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Most commands also have keyboard shortcuts using `ctrl+x` as the default leader key.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## connect
|
|
11
|
+
Add a provider to OpenCode. Allows you to select from available providers and add their API keys.
|
|
12
|
+
```
|
|
13
|
+
/connect
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## compact
|
|
17
|
+
Compact the current session:
|
|
18
|
+
```
|
|
19
|
+
/compact
|
|
20
|
+
|
|
21
|
+
// alias
|
|
22
|
+
/summarize
|
|
23
|
+
|
|
24
|
+
// keybind
|
|
25
|
+
ctrl+x c
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## details
|
|
29
|
+
Toggle tool execution details.
|
|
30
|
+
```
|
|
31
|
+
/details
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## exit
|
|
35
|
+
Exit OpenCode. Aliases: `/quit`, `/q`
|
|
36
|
+
```
|
|
37
|
+
/exit
|
|
38
|
+
|
|
39
|
+
// keybind
|
|
40
|
+
ctrl+x q
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## export
|
|
44
|
+
Export current conversation to Markdown and open in your default editor.
|
|
45
|
+
```
|
|
46
|
+
/export
|
|
47
|
+
|
|
48
|
+
// keybind
|
|
49
|
+
ctrl+x x
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## models
|
|
53
|
+
List available models.
|
|
54
|
+
```
|
|
55
|
+
/models
|
|
56
|
+
|
|
57
|
+
// keybind
|
|
58
|
+
ctrl+x m
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## new
|
|
62
|
+
Start a new session. Alias: `/clear`
|
|
63
|
+
```
|
|
64
|
+
/new
|
|
65
|
+
|
|
66
|
+
// keybind
|
|
67
|
+
ctrl+x n
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## redo
|
|
71
|
+
Redo a previously undone message. Only available after using `/undo`.
|
|
72
|
+
```
|
|
73
|
+
/redo
|
|
74
|
+
|
|
75
|
+
// keybind
|
|
76
|
+
ctrl+x r
|
|
77
|
+
```
|
|
78
|
+
Uses Git to manage the file changes. So your project needs to be a Git repository.
|
|
79
|
+
|
|
80
|
+
## undo
|
|
81
|
+
Undo last message in the conversation.
|
|
82
|
+
```
|
|
83
|
+
/undo
|
|
84
|
+
|
|
85
|
+
// keybind
|
|
86
|
+
ctrl+x u
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Removes the most recent user message, all subsequent responses, and any file changes.
|
|
90
|
+
|
|
91
|
+
## sessions
|
|
92
|
+
List and switch between sessions. Aliases: `/resume`, `/continue`
|
|
93
|
+
```
|
|
94
|
+
/resume
|
|
95
|
+
|
|
96
|
+
// keybind
|
|
97
|
+
ctrl+x l
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## themes
|
|
101
|
+
List available themes.
|
|
102
|
+
```
|
|
103
|
+
/themes
|
|
104
|
+
|
|
105
|
+
// keybind
|
|
106
|
+
ctrl+x t
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## thinking
|
|
110
|
+
Toggle the visibility of thinking/reasoning blocks in the conversation. When enabled, you can see the model’s reasoning process for models that support extended thinking.
|
|
111
|
+
```
|
|
112
|
+
/thinking
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## share
|
|
116
|
+
Share current session.
|
|
117
|
+
```
|
|
118
|
+
/share
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## unshare
|
|
122
|
+
Unshare current session.
|
|
123
|
+
```
|
|
124
|
+
/unshare
|
|
125
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# TUI
|
|
2
|
+
Using the OpenCode terminal user interface.
|
|
3
|
+
|
|
4
|
+
```
|
|
5
|
+
opencode
|
|
6
|
+
|
|
7
|
+
// start with a specific working dir
|
|
8
|
+
opencode /path/to/project
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## File references
|
|
12
|
+
Using `@` to reference files in the current working dir.
|
|
13
|
+
- The content of the file is added to the conversation automatically.
|
|
14
|
+
```
|
|
15
|
+
How is auth handled in @packages/functions/src/api/index.ts
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Bash commands
|
|
20
|
+
Start with `!` to run a shell command.
|
|
21
|
+
- The output of the command is added to the conversation as a tool result.
|
|
22
|
+
```
|
|
23
|
+
!ls -la
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
|
|
@@ -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 可能有系统性错误
|