@wwkit/harness 1.0.9 → 1.0.10
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 +367 -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 +151 -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 +2 -2
- 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 +307 -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
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Agent
|
|
2
|
+
|
|
3
|
+
Agent 是可配置的专门 AI 助手,用于特定任务和工作流。
|
|
4
|
+
|
|
5
|
+
可以在会话中切换 Agent,或使用 `@` 提及调用。
|
|
6
|
+
|
|
7
|
+
## Agent 类型
|
|
8
|
+
|
|
9
|
+
| 类型 | 说明 |
|
|
10
|
+
|------|------|
|
|
11
|
+
| Primary Agent | 直接交互的主助手 |
|
|
12
|
+
| Subagent | Primary Agent 可调用的专门助手(也可通过 `@` 手动调用) |
|
|
13
|
+
|
|
14
|
+
## 内置 Agent
|
|
15
|
+
|
|
16
|
+
### Primary Agent
|
|
17
|
+
|
|
18
|
+
| Agent | 说明 |
|
|
19
|
+
|-------|------|
|
|
20
|
+
| build | 默认主 Agent,所有工具启用 |
|
|
21
|
+
| plan | 规划和分析专用,文件编辑和 bash 默认需审批 |
|
|
22
|
+
|
|
23
|
+
### Subagent
|
|
24
|
+
|
|
25
|
+
| Agent | 说明 |
|
|
26
|
+
|-------|------|
|
|
27
|
+
| general | 通用多步骤任务,完整工具访问(除 todo),可并行执行 |
|
|
28
|
+
| explore | 快速只读代码探索,查找文件和搜索代码 |
|
|
29
|
+
| scout | 外部文档和依赖研究 |
|
|
30
|
+
|
|
31
|
+
## 使用方式
|
|
32
|
+
|
|
33
|
+
### 切换 Primary Agent
|
|
34
|
+
|
|
35
|
+
使用 Tab 键在会话中切换。
|
|
36
|
+
|
|
37
|
+
### 调用 Subagent
|
|
38
|
+
|
|
39
|
+
- **自动调用**:Primary Agent 根据描述自动选择合适的 Subagent
|
|
40
|
+
- **手动调用**:在消息中 `@` 提及,如 `@general help me search for this function`
|
|
41
|
+
|
|
42
|
+
### 会话导航
|
|
43
|
+
|
|
44
|
+
| 操作 | 快捷键 |
|
|
45
|
+
|------|--------|
|
|
46
|
+
| 进入第一个子会话 | `Leader+Down`(`session_child_first`) |
|
|
47
|
+
| 切换到下一个子会话 | `Right`(`session_child_cycle`) |
|
|
48
|
+
| 切换到上一个子会话 | `Left`(`session_child_cycle_reverse`) |
|
|
49
|
+
| 返回父会话 | `Up`(`session_parent`) |
|
|
50
|
+
|
|
51
|
+
## 配置方式
|
|
52
|
+
|
|
53
|
+
### JSON 配置
|
|
54
|
+
|
|
55
|
+
在 `opencode.json` 中配置:
|
|
56
|
+
|
|
57
|
+
```jsonc
|
|
58
|
+
{
|
|
59
|
+
"$schema": "https://opencode.ai/config.json",
|
|
60
|
+
"agent":{
|
|
61
|
+
"code-reviewer": {
|
|
62
|
+
"description": "Reviews code for best practices and potential issues",
|
|
63
|
+
"mode": "subagent",
|
|
64
|
+
"model": "anthropic/claude-sonnet-4-20250514",
|
|
65
|
+
"prompt": "You are a code reviewer. Focus on security, performance, and maintainability.",
|
|
66
|
+
"permission": {
|
|
67
|
+
"edit": "deny"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Markdown 配置
|
|
75
|
+
|
|
76
|
+
放置在以下位置:
|
|
77
|
+
|
|
78
|
+
- 全局:`~/.config/opencode/agents/`,如 `~/.config/opencode/agents/review.md`
|
|
79
|
+
- 项目级:`.opencode/agents/`
|
|
80
|
+
|
|
81
|
+
```md
|
|
82
|
+
---
|
|
83
|
+
description: Reviews code for quality and best practices
|
|
84
|
+
mode: subagent
|
|
85
|
+
model: anthropic/claude-sonnet-4-20250514
|
|
86
|
+
temperature: 0.1
|
|
87
|
+
permission:
|
|
88
|
+
edit: deny
|
|
89
|
+
bash: deny
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
You are in code review mode. Focus on:
|
|
93
|
+
|
|
94
|
+
- Code quality and best practices
|
|
95
|
+
- Potential bugs and edge cases
|
|
96
|
+
- Performance implications
|
|
97
|
+
- Security considerations
|
|
98
|
+
|
|
99
|
+
Provide constructive feedback without making direct changes.
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
文件名即为 Agent 名称,如 `review.md` 创建 `review` Agent。
|
|
103
|
+
|
|
104
|
+
## 配置选项
|
|
105
|
+
|
|
106
|
+
### Description
|
|
107
|
+
|
|
108
|
+
提供 Agent 的简要描述和使用场景。
|
|
109
|
+
|
|
110
|
+
### Temperature
|
|
111
|
+
|
|
112
|
+
控制 LLM 响应的随机性和创造性:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"agent": {
|
|
117
|
+
"plan": { "temperature": 0.1 },
|
|
118
|
+
"creative": { "temperature": 0.8 }
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Steps
|
|
124
|
+
|
|
125
|
+
控制 Agent 最大迭代次数:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"agent": {
|
|
130
|
+
"quick-thinker": {
|
|
131
|
+
"description": "Fast reasoning with limited iterations",
|
|
132
|
+
"prompt": "You are a quick thinker. Solve problems with minimal steps.",
|
|
133
|
+
"steps": 5
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Disable
|
|
140
|
+
|
|
141
|
+
禁用 Agent:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"agent": {
|
|
146
|
+
"review": { "disable": true }
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Prompt
|
|
152
|
+
|
|
153
|
+
指定自定义系统提示词文件:
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"agent": {
|
|
158
|
+
"review": {
|
|
159
|
+
"prompt": "{file:./prompts/code-review.txt}"
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Model
|
|
166
|
+
|
|
167
|
+
为 Agent 覆盖默认模型:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"agent": {
|
|
172
|
+
"plan": { "model": "anthropic/claude-haiku-4-20250514" }
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Permissions
|
|
178
|
+
|
|
179
|
+
配置 Agent 的操作权限:
|
|
180
|
+
|
|
181
|
+
| 值 | 说明 |
|
|
182
|
+
|----|------|
|
|
183
|
+
| `ask` | 运行前需审批 |
|
|
184
|
+
| `allow` | 允许所有操作 |
|
|
185
|
+
| `deny` | 禁用工具 |
|
|
186
|
+
|
|
187
|
+
权限键值表:
|
|
188
|
+
|
|
189
|
+
| 键 | 控制的工具 |
|
|
190
|
+
|----|-----------|
|
|
191
|
+
| read | read |
|
|
192
|
+
| edit | write, edit, apply_patch |
|
|
193
|
+
| glob | glob |
|
|
194
|
+
| grep | grep |
|
|
195
|
+
| list | list |
|
|
196
|
+
| bash | bash |
|
|
197
|
+
| task | task |
|
|
198
|
+
| external_directory | 读写项目工作树外的文件 |
|
|
199
|
+
| todowrite | todowrite, todoread |
|
|
200
|
+
| webfetch | webfetch |
|
|
201
|
+
| websearch | websearch |
|
|
202
|
+
| lsp | lsp |
|
|
203
|
+
| skill | skill |
|
|
204
|
+
| question | question |
|
|
205
|
+
| doom_loop | Agent 卡住时的恢复提示 |
|
|
206
|
+
|
|
207
|
+
`read`、`edit`、`glob`、`grep`、`list`、`bash`、`task`、`external_directory`、`lsp`、`skill` 支持简写操作或 glob/模式到操作的对象映射。
|
|
208
|
+
|
|
209
|
+
按 Agent 覆盖权限:
|
|
210
|
+
|
|
211
|
+
```jsonc
|
|
212
|
+
{
|
|
213
|
+
"$schema": "https://opencode.ai/config.json",
|
|
214
|
+
"permission": { "edit": "deny" },
|
|
215
|
+
"agent": {
|
|
216
|
+
"build": { "permission": { "edit": "ask" } }
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Markdown Agent 中配置权限:
|
|
222
|
+
|
|
223
|
+
```md
|
|
224
|
+
---
|
|
225
|
+
description: Code review without edits
|
|
226
|
+
mode: subagent
|
|
227
|
+
permission:
|
|
228
|
+
edit: deny
|
|
229
|
+
bash:
|
|
230
|
+
"*": ask
|
|
231
|
+
"git diff": allow
|
|
232
|
+
"git log*": allow
|
|
233
|
+
"grep *": allow
|
|
234
|
+
webfetch: deny
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
Only analyze code and suggest changes.
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Mode
|
|
241
|
+
|
|
242
|
+
控制 Agent 模式:`primary`、`subagent` 或 `all`(默认)。
|
|
243
|
+
|
|
244
|
+
### Hidden
|
|
245
|
+
|
|
246
|
+
隐藏 Subagent(不在 `@` 自动补全中显示):
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"agent": {
|
|
251
|
+
"internal-helper": { "mode": "subagent", "hidden": true }
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
仅对 `mode: subagent` 的 Agent 有效。
|
|
257
|
+
|
|
258
|
+
### Additional
|
|
259
|
+
|
|
260
|
+
其他选项将直接传递给 Provider 作为模型选项:
|
|
261
|
+
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"agent": {
|
|
265
|
+
"deep-thinker": {
|
|
266
|
+
"description": "Agent that uses high reasoning effort for complex problems",
|
|
267
|
+
"model": "openai/gpt-5",
|
|
268
|
+
"reasoningEffort": "high",
|
|
269
|
+
"textVerbosity": "low"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## 创建 Agent
|
|
276
|
+
|
|
277
|
+
使用命令创建:
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
opencode agent create
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
交互式流程:
|
|
284
|
+
|
|
285
|
+
1. 选择保存位置(全局或项目级)
|
|
286
|
+
2. 描述 Agent 功能
|
|
287
|
+
3. 生成系统提示词和标识符
|
|
288
|
+
4. 选择允许的权限
|
|
289
|
+
5. 创建 Markdown 配置文件
|
|
290
|
+
|
|
291
|
+
## 常见用例
|
|
292
|
+
|
|
293
|
+
| Agent | 用途 |
|
|
294
|
+
|-------|------|
|
|
295
|
+
| Build | 全功能开发,所有工具启用 |
|
|
296
|
+
| Plan | 分析和规划,不修改文件 |
|
|
297
|
+
| Review | 代码审查,只读 + 文档工具 |
|
|
298
|
+
| Debug | 调查问题,bash + read 工具 |
|
|
299
|
+
| Docs | 文档编写,文件操作但无系统命令 |
|
|
300
|
+
|
|
301
|
+
## 更多内容
|
|
302
|
+
|
|
303
|
+
- [Agent 详解](/agents/detail) — 父子协作、提示词组装、权限设计
|
|
304
|
+
- [Agent 工作流](/agents/workflow) — 5 种工作流模式
|
|
305
|
+
- [Agent 设计模式](/agents/design-pattern) — 核心设计原则
|
|
306
|
+
- [Agent 示例](/agents/examples) — 实用示例
|
|
307
|
+
- [Agent 案例](/agents/cases) — 完整系统设计案例
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Agent 工作流
|
|
2
|
+
|
|
3
|
+
## 模式 1:Prompt Chaining(提示链)
|
|
4
|
+
|
|
5
|
+
将任务分解为顺序执行的步骤,每一步的输出是下一步的输入。
|
|
6
|
+
|
|
7
|
+
**适用场景**:任务可清晰分解为固定子任务,需要用延迟换取准确性。
|
|
8
|
+
|
|
9
|
+
```md
|
|
10
|
+
---
|
|
11
|
+
description: 多步骤翻译处理
|
|
12
|
+
mode: subagent
|
|
13
|
+
steps: 10
|
|
14
|
+
---
|
|
15
|
+
# 任务流程
|
|
16
|
+
按以下步骤执行,每步完成后再进行下一步:
|
|
17
|
+
## 步骤 1:直译
|
|
18
|
+
将原文逐句翻译成中文,保持原意。
|
|
19
|
+
## 步骤 2:意译润色
|
|
20
|
+
在直译基础上,调整为通顺的中文表达。
|
|
21
|
+
## 步骤 3:专业术语检查
|
|
22
|
+
检查专业术语是否准确,必要时保留英文。
|
|
23
|
+
## 步骤 4:格式化
|
|
24
|
+
按照目标格式(Markdown)整理输出。
|
|
25
|
+
# 输出要求
|
|
26
|
+
每个步骤都输出中间结果,最后给出最终版本。
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 模式 2:Routing(路由)
|
|
30
|
+
|
|
31
|
+
根据输入特征,将任务导向不同的专门处理流程。
|
|
32
|
+
|
|
33
|
+
**适用场景**:不同类别需要不同处理方式,分类可以准确完成。
|
|
34
|
+
|
|
35
|
+
```md
|
|
36
|
+
---
|
|
37
|
+
description: 代码问题分类路由器
|
|
38
|
+
mode: subagent
|
|
39
|
+
---
|
|
40
|
+
# 角色
|
|
41
|
+
你是代码问题分类专家,负责将问题路由到正确的处理流程。
|
|
42
|
+
# 分类规则
|
|
43
|
+
分析用户的代码问题,判断属于以下哪一类:
|
|
44
|
+
1. **Bug 修复** → 调用 @bug-fixer
|
|
45
|
+
2. **性能优化** → 调用 @performance-optimizer
|
|
46
|
+
3. **安全审计** → 调用 @security-auditor
|
|
47
|
+
4. **代码重构** → 调用 @refactor-expert
|
|
48
|
+
5. **新功能开发** → 不路由,直接处理
|
|
49
|
+
# 输出格式
|
|
50
|
+
先说明分类理由,然后调用相应的 subagent。
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 模式 3:Parallelization(并行化)
|
|
54
|
+
|
|
55
|
+
多个任务同时执行,最后汇总结果。
|
|
56
|
+
|
|
57
|
+
**两种变体**:
|
|
58
|
+
- **Sectioning(分片)**:独立子任务并行
|
|
59
|
+
- **Voting(投票)**:同一任务多视角验证
|
|
60
|
+
|
|
61
|
+
**适用场景**:子任务相互独立,需要多视角提高准确性,时间敏感需要加速。
|
|
62
|
+
|
|
63
|
+
```md
|
|
64
|
+
---
|
|
65
|
+
description: 代码质量并行检查器
|
|
66
|
+
mode: subagent
|
|
67
|
+
---
|
|
68
|
+
# 任务
|
|
69
|
+
对给定代码同时进行多维度检查。
|
|
70
|
+
# 并行任务
|
|
71
|
+
**同时**调用以下 subagent(使用多个 Task tool 调用):
|
|
72
|
+
1. @security-auditor - 安全漏洞检查
|
|
73
|
+
2. @performance-reviewer - 性能分析
|
|
74
|
+
3. @style-checker - 代码风格检查
|
|
75
|
+
4. @test-coverage-analyzer - 测试覆盖分析
|
|
76
|
+
# 汇总规则
|
|
77
|
+
收集所有结果后,生成综合报告:
|
|
78
|
+
## 综合评分
|
|
79
|
+
- 安全性:X/10
|
|
80
|
+
- 性能:X/10
|
|
81
|
+
- 代码风格:X/10
|
|
82
|
+
- 测试覆盖:X/10
|
|
83
|
+
- **总分**:X/40
|
|
84
|
+
## 问题汇总
|
|
85
|
+
按严重程度排序所有发现的问题。
|
|
86
|
+
## 优先修复建议
|
|
87
|
+
给出最应该优先处理的 3 个问题。
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 模式 4:Orchestrator-Workers(编排-工人)
|
|
91
|
+
|
|
92
|
+
中央 LLM(编排器)动态分析任务,将其分解并分配给专门的 Worker Agent。
|
|
93
|
+
|
|
94
|
+
**适用场景**:无法预测需要哪些子任务,任务复杂度不确定,需要灵活应对。
|
|
95
|
+
|
|
96
|
+
```md
|
|
97
|
+
---
|
|
98
|
+
description: 项目分析编排器,动态分配分析任务
|
|
99
|
+
mode: primary
|
|
100
|
+
---
|
|
101
|
+
# 角色
|
|
102
|
+
你是项目分析编排器,负责理解用户需求并协调专家团队。
|
|
103
|
+
# 可用专家
|
|
104
|
+
- @architecture-analyst - 架构分析
|
|
105
|
+
- @dependency-auditor - 依赖审计
|
|
106
|
+
- @security-auditor - 安全审计
|
|
107
|
+
- @performance-profiler - 性能分析
|
|
108
|
+
- @docs-reviewer - 文档评审
|
|
109
|
+
- @test-analyzer - 测试分析
|
|
110
|
+
# 工作流程
|
|
111
|
+
1. **理解需求**:分析用户想知道什么
|
|
112
|
+
2. **制定计划**:决定需要调用哪些专家
|
|
113
|
+
3. **执行分析**:调用选定的专家
|
|
114
|
+
4. **整合结果**:汇总所有专家的发现
|
|
115
|
+
5. **给出建议**:基于整体分析给出行动建议
|
|
116
|
+
# 原则
|
|
117
|
+
- 不要过度分析,根据用户需求选择必要的专家
|
|
118
|
+
- 如果用户问题简单,可能不需要任何专家
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 模式 5:Evaluator-Optimizer(评估-优化)
|
|
122
|
+
|
|
123
|
+
一个 Agent 生成内容,另一个 Agent 评估,循环直到满足标准。
|
|
124
|
+
|
|
125
|
+
**适用场景**:有明确的评估标准,迭代改进有价值,类似人类的"写作-修改"过程。
|
|
126
|
+
|
|
127
|
+
```md
|
|
128
|
+
---
|
|
129
|
+
description: 迭代代码优化器
|
|
130
|
+
mode: subagent
|
|
131
|
+
steps: 15
|
|
132
|
+
---
|
|
133
|
+
# 角色
|
|
134
|
+
你是代码优化专家,通过迭代改进代码质量。
|
|
135
|
+
# 优化循环
|
|
136
|
+
## 1. 分析阶段
|
|
137
|
+
- 阅读当前代码
|
|
138
|
+
- 识别可优化点
|
|
139
|
+
- 评估当前质量分数
|
|
140
|
+
## 2. 优化阶段
|
|
141
|
+
- 选择影响最大的优化点
|
|
142
|
+
- 实施优化
|
|
143
|
+
- 确保不破坏功能
|
|
144
|
+
## 3. 验证阶段
|
|
145
|
+
- 运行测试确保功能正常
|
|
146
|
+
- 重新评估质量分数
|
|
147
|
+
## 4. 决策阶段
|
|
148
|
+
- 如果质量分数 >= 8,停止优化
|
|
149
|
+
- 如果质量分数提升 < 0.5,停止
|
|
150
|
+
- 否则,继续下一轮
|
|
151
|
+
# 质量评分标准
|
|
152
|
+
| 分数 | 可读性 | 性能 | 安全性 | 测试覆盖 |
|
|
153
|
+
|------|--------|------|--------|---------|
|
|
154
|
+
| 9-10 | 命名清晰、注释完整 | O(n)或更优 | 无漏洞 | >90% |
|
|
155
|
+
| 7-8 | 命名合理、关键注释 | O(n log n) | 低风险 | 70-90% |
|
|
156
|
+
| 5-6 | 基本可读 | O(n²) | 中风险 | 50-70% |
|
|
157
|
+
| <5 | 难以理解 | O(n³)+ | 高风险 | <50% |
|
|
158
|
+
# 失败处理
|
|
159
|
+
- 测试失败:立即回滚本轮修改,尝试其他方向
|
|
160
|
+
- 步数耗尽:输出当前最佳版本和剩余优化建议
|
|
161
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# acp
|
|
2
|
+
Start an ACP (Agent Client Protocol) server that communicates via stdin/stdout using nd-JSON.
|
|
3
|
+
```
|
|
4
|
+
opencode acp
|
|
5
|
+
|
|
6
|
+
# 指定工作目录
|
|
7
|
+
opencode acp --cwd D:\jsapp\wego_oc
|
|
8
|
+
|
|
9
|
+
# 用 HTTP 方式
|
|
10
|
+
opencode acp --port 8080 --hostname 0.0.0.0
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Flags
|
|
14
|
+
- `--cwd` : working directory
|
|
15
|
+
- `--port` : Port to listen on
|
|
16
|
+
- `--hostname` : Hostname to listen on
|
|
17
|
+
- `--mdns`
|
|
18
|
+
- `--mdns-domain`
|
|
19
|
+
- `--cors`
|
|
20
|
+
|
|
21
|
+
## ACP vs MCP
|
|
22
|
+
- mcp : 让Agent调用外部工具
|
|
23
|
+
- acp : 让外部程序调用Agent,适用场景:IDE 插件、CI/CD 流水线、自定义客户端等需要程序化调用 OpenCode Agent 能力的场景。
|
|
24
|
+
|
|
25
|
+
## apis vs acp
|
|
26
|
+
- apis: OpenAPI3.1 http协议,http rest通信,适合web应用、脚本、通用集成
|
|
27
|
+
- acp: acp协议,stdin/stdout通信,适合IDE插件、Agent编排、流水线
|
|
28
|
+
|
|
29
|
+
## serve and client
|
|
30
|
+
- `opencode` : 自动启动server,客户端为TUI
|
|
31
|
+
- `opencode serve` : 单独启动server,无客户端,提供 HTTP Rest API
|
|
32
|
+
- `opencode acp` : 单独启动server,无客户端,提供acp
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## agent
|
|
2
|
+
Manage agents for OpenCode (`create` or `list`).
|
|
3
|
+
```
|
|
4
|
+
opencode agent [command]
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Create a new agent with custom configuration.
|
|
8
|
+
```
|
|
9
|
+
opencode agent create
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
List all available agents.
|
|
13
|
+
```
|
|
14
|
+
opencode agent list
|
|
15
|
+
```
|
|
16
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# attach
|
|
2
|
+
Attach a terminal to an already running OpenCode backend server started via serve or web commands.
|
|
3
|
+
|
|
4
|
+
```
|
|
5
|
+
opencode attach [url]
|
|
6
|
+
|
|
7
|
+
// start the backend server for web access
|
|
8
|
+
opencode web --port 4096 --hostname 0.0.0.0
|
|
9
|
+
|
|
10
|
+
// in another terminal, attach the TUI to the running backend
|
|
11
|
+
opencode attach http://10.20.30.40:4096
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Flags
|
|
15
|
+
- `--dir` Working directory to start TUI in
|
|
16
|
+
- `-c` Continue the last session
|
|
17
|
+
- `-s` Session ID to continue
|
|
18
|
+
- `--fork` Fork the session when continuing (use with --continue or --session)
|
|
19
|
+
- `-p` Basic auth password (defaults to OPENCODE_SERVER_PASSWORD)
|
|
20
|
+
- `-u` Basic auth username (defaults to OPENCODE_SERVER_USERNAME or opencode)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# mcp
|
|
2
|
+
Manage Model Context Protocol servers.
|
|
3
|
+
```
|
|
4
|
+
opencode mcp [command]
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## add
|
|
8
|
+
Add an MCP server to your configuration.
|
|
9
|
+
```
|
|
10
|
+
opencode mcp add
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## list
|
|
14
|
+
List all configured MCP servers and their connection status.
|
|
15
|
+
```
|
|
16
|
+
opencode mcp list
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## auth
|
|
20
|
+
Authenticate with an OAuth-enabled MCP server.
|
|
21
|
+
```
|
|
22
|
+
opencode mcp auth [name]
|
|
23
|
+
|
|
24
|
+
opencode mcp auth list
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## logout
|
|
28
|
+
Remove OAuth credentials for an MCP server.
|
|
29
|
+
```
|
|
30
|
+
opencode mcp logout [name]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## debug
|
|
34
|
+
Debug OAuth connection issues for an MCP server.
|
|
35
|
+
```
|
|
36
|
+
opencode mcp debug <name>
|
|
37
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# stats
|
|
2
|
+
Show token usage and cost statistics for your sessions.
|
|
3
|
+
```
|
|
4
|
+
opencode stats
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## Flags:
|
|
8
|
+
- `--days` : last N days
|
|
9
|
+
- `--tools` : Number of tools to show
|
|
10
|
+
- `--models` : Show model usage breakdown
|
|
11
|
+
- `--project` : Filter by project
|
|
12
|
+
|
|
13
|
+
# db
|
|
14
|
+
Dtabase tools
|
|
15
|
+
```
|
|
16
|
+
opencode db [query]
|
|
17
|
+
```
|
|
18
|
+
## Flags
|
|
19
|
+
- `--format` : Output format, json or tsv
|
|
20
|
+
|
|
21
|
+
# debug
|
|
22
|
+
Debugging and troubleshooting tools
|
|
23
|
+
```
|
|
24
|
+
opencode debug [command]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
# uninstall
|
|
28
|
+
Uninstall OpenCode and remove all related files.
|
|
29
|
+
```
|
|
30
|
+
opencode uninstall
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Flags
|
|
34
|
+
- `--keep-config` `-c` : Keep config files
|
|
35
|
+
- `--keep-data` `-d` : Keep session data and snapshots
|
|
36
|
+
- `--dry-run` : Show what would be removed without removing
|
|
37
|
+
- `--force` `-f` : Skip confirmation prompts
|
|
38
|
+
|
|
39
|
+
# upgrade
|
|
40
|
+
Updates opencode to the latest version or a specific version
|
|
41
|
+
```
|
|
42
|
+
// latest
|
|
43
|
+
opencode upgrade
|
|
44
|
+
|
|
45
|
+
// specific
|
|
46
|
+
opencode upgrade v0.1.48
|
|
47
|
+
```
|
|
48
|
+
## Flags
|
|
49
|
+
- `--method` `-m` : The installation method, curl/npm/pnmp/bun/brew
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# auth
|
|
2
|
+
Command to manage credentials and login for providers.
|
|
3
|
+
```
|
|
4
|
+
opencode auth [command]
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## login
|
|
8
|
+
|
|
9
|
+
OpenCode is powered by the provider list at Models.dev, so you can use opencode auth login to configure API keys for any provider you’d like to use. This is stored in ~/.local/share/opencode/auth.json.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
opencode auth login
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
When OpenCode starts up it loads the providers from the credentials file. And if there are any keys defined in your environments or a .env file in your project.
|
|
16
|
+
|
|
17
|
+
Flags
|
|
18
|
+
- `--provider` `-p` : Provider ID or name to log in to
|
|
19
|
+
- `--method` `-m` : Login method label to use, skipping method selection
|
|
20
|
+
|
|
21
|
+
## list
|
|
22
|
+
Lists all the authenticated providers as stored in the credentials file.
|
|
23
|
+
```
|
|
24
|
+
opencode auth list
|
|
25
|
+
opencode auth ls
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## logout
|
|
29
|
+
Logs you out of a provider by clearing it from the credentials file.
|
|
30
|
+
```
|
|
31
|
+
opencode auth logout
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
# models
|
|
35
|
+
List all available models from configured providers in the format provider/model.
|
|
36
|
+
```
|
|
37
|
+
opencode models [provider]
|
|
38
|
+
|
|
39
|
+
opencode models anthropic
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Flags
|
|
43
|
+
- `--refresh` : Refresh the models cache form models.dev
|
|
44
|
+
- `--verbose` : Use more verbose model output (includes metadata like costs)
|