ai-dev-harness 0.1.1 → 0.1.3
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/COLLEAGUE_TRIAL_GUIDE.md +44 -16
- package/ONLINE_INSTALL_GUIDE.md +458 -0
- package/README.md +157 -22
- package/dist/agent.js +38 -19
- package/dist/approval.js +64 -0
- package/dist/audit.js +1 -0
- package/dist/checkpoint.js +83 -0
- package/dist/cli.js +322 -81
- package/dist/config.js +39 -1
- package/dist/context.js +14 -5
- package/dist/contextScore.js +44 -0
- package/dist/diagnostics.js +58 -0
- package/dist/doctor.js +100 -0
- package/dist/feedback.js +5 -0
- package/dist/integration.js +62 -2
- package/dist/loop.js +116 -0
- package/dist/mcp.js +1 -1
- package/dist/metrics.js +91 -0
- package/dist/replay.js +27 -0
- package/dist/runPaths.js +30 -0
- package/dist/summarize.js +139 -11
- package/package.json +3 -2
- package/scripts/read-evidence.ps1 +37 -1
- package/scripts/run-harness.ps1 +1 -1
- package/templates/default-project/TOOLS.md +6 -3
- package/templates/default-project/skills/add_feature/context.yaml +18 -15
- package/templates/default-project/skills/fix_bug/context.yaml +18 -15
- package/templates/default-project/skills/update_docs/context.yaml +16 -12
- package/templates/default-project/skills/write_tests/context.yaml +17 -14
- package/templates/integrations/claude/SKILL.md +47 -11
- package/templates/integrations/codex/AGENTS_BLOCK.md +42 -11
- package/templates/integrations/cursor/ai-dev-harness.mdc +55 -0
- package/templates/integrations/gemini/GEMINI_BLOCK.md +46 -0
package/COLLEAGUE_TRIAL_GUIDE.md
CHANGED
|
@@ -20,11 +20,17 @@ Run inside a Git repository:
|
|
|
20
20
|
harness init
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
This creates Harness config, project skills, Claude/Codex conversation integration, and helper scripts.
|
|
23
|
+
This creates Harness config, project skills, Claude/Codex/Cursor/Gemini conversation integration, and helper scripts.
|
|
24
|
+
|
|
25
|
+
Check local pilot readiness:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
harness doctor
|
|
29
|
+
```
|
|
24
30
|
|
|
25
31
|
## 3. Configure MCP Sources
|
|
26
32
|
|
|
27
|
-
Configure MCP in
|
|
33
|
+
Configure MCP in the execution agent so it can call the tools directly. Keep the same source metadata in `harness.yaml` for audit:
|
|
28
34
|
|
|
29
35
|
```yaml
|
|
30
36
|
mcp:
|
|
@@ -46,25 +52,32 @@ Set secrets outside Git:
|
|
|
46
52
|
$env:OKF_TOKEN="your-token"
|
|
47
53
|
```
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
The execution agent should call MCP tools before triggering Harness and include important findings in the task text. Harness records MCP source configuration for audit, but does not implement MCP transport itself.
|
|
50
56
|
|
|
51
57
|
## 4. Run A Smoke Test
|
|
52
58
|
|
|
53
59
|
```bash
|
|
54
|
-
harness
|
|
60
|
+
harness smoke --agent claude --live
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
With Codex:
|
|
58
64
|
|
|
59
65
|
```bash
|
|
60
|
-
harness
|
|
66
|
+
harness smoke --agent codex --live
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Cursor / Gemini:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
harness smoke --agent cursor --live
|
|
73
|
+
harness smoke --agent gemini --live
|
|
61
74
|
```
|
|
62
75
|
|
|
63
76
|
`--live` streams Harness lifecycle logs and agent output in the current terminal.
|
|
64
77
|
|
|
65
|
-
## 5. Use From Claude/Codex Conversation
|
|
78
|
+
## 5. Use From Claude/Codex/Cursor/Gemini Conversation
|
|
66
79
|
|
|
67
|
-
After `harness init`, open Claude Code or
|
|
80
|
+
After `harness init`, open Claude Code, Codex, Cursor, or Gemini in the repository and say:
|
|
68
81
|
|
|
69
82
|
```text
|
|
70
83
|
Use AI Dev Harness to run fix_bug: fix the download resume progress issue.
|
|
@@ -83,14 +96,20 @@ The agent should:
|
|
|
83
96
|
```text
|
|
84
97
|
## MCP Preflight Findings
|
|
85
98
|
- CodeGraph tools used:
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
99
|
+
- CodeGraph primary query:
|
|
100
|
+
- Source grouped by file:
|
|
101
|
+
- Current line-numbered source:
|
|
102
|
+
- Call paths:
|
|
103
|
+
- Dynamic dispatch hops:
|
|
104
|
+
- Blast-radius summary:
|
|
90
105
|
- Knowledge Graph tools used:
|
|
106
|
+
- Candidate concept_ids:
|
|
107
|
+
- Read tools used:
|
|
108
|
+
- Evidence sections/chunks:
|
|
91
109
|
- ADRs / decisions:
|
|
92
110
|
- Module notes:
|
|
93
111
|
- API notes / runbooks:
|
|
112
|
+
- Audit/backlink findings:
|
|
94
113
|
- Missing context:
|
|
95
114
|
```
|
|
96
115
|
|
|
@@ -102,12 +121,21 @@ Each run writes `runs/<run_id>/`:
|
|
|
102
121
|
intake.json Task, skill, agent, Git state
|
|
103
122
|
mcp_queries.jsonl Agent-driven MCP source records
|
|
104
123
|
context_pack.md Context assembly protocol and local fallback context
|
|
105
|
-
agent_prompt.md Final prompt sent to
|
|
124
|
+
agent_prompt.md Final prompt sent to the execution agent
|
|
106
125
|
plan.md Harness execution-stage protocol
|
|
107
126
|
execution.log Agent stdout/stderr
|
|
108
127
|
agent_contract.json Required-section contract check
|
|
109
128
|
git_diff.patch Code changes
|
|
110
129
|
verify.json Verification results
|
|
130
|
+
verify_diagnostics.json Verification failure diagnostics
|
|
131
|
+
context_score.json Context evidence score
|
|
132
|
+
approval_required.json Approval gate result
|
|
133
|
+
feedback.jsonl Harness-visible machine feedback events
|
|
134
|
+
checkpoint.json Git checkpoint and restore support
|
|
135
|
+
pre_iteration_diff.patch Diff before the iteration
|
|
136
|
+
post_iteration_diff.patch Diff after the iteration
|
|
137
|
+
loop_review.json Per-iteration evaluation and failure diagnosis
|
|
138
|
+
loop_report.md Human-readable correction-loop report
|
|
111
139
|
summary.md Review/PR summary
|
|
112
140
|
persist_suggestions.md Knowledge persistence suggestions
|
|
113
141
|
audit.jsonl Full audit event log
|
|
@@ -129,7 +157,7 @@ If `harness run must execute inside a Git repository`, run inside a business Git
|
|
|
129
157
|
git status
|
|
130
158
|
```
|
|
131
159
|
|
|
132
|
-
If
|
|
160
|
+
If the current Agent cannot see MCP tools, check that Agent's MCP configuration first:
|
|
133
161
|
|
|
134
162
|
- Wrong MCP URL
|
|
135
163
|
- Missing bearer token
|
|
@@ -140,8 +168,8 @@ Harness can still run with local repository fallback context, but the agent shou
|
|
|
140
168
|
|
|
141
169
|
## 9. Acceptance Checklist
|
|
142
170
|
|
|
143
|
-
- `harness init` creates config, skills, and Claude/Codex integration.
|
|
144
|
-
- Claude/Codex can trigger Harness from conversation.
|
|
171
|
+
- `harness init` creates config, skills, and Claude/Codex/Cursor/Gemini integration.
|
|
172
|
+
- Claude/Codex/Cursor/Gemini can trigger Harness from conversation.
|
|
145
173
|
- Agent reports MCP preflight findings.
|
|
146
174
|
- `agent_contract.json` shows whether required sections were produced.
|
|
147
|
-
- `verify.json`, `summary.md`, and `audit.jsonl` are generated.
|
|
175
|
+
- `verify.json`, `loop_review.json`, `summary.md`, and `audit.jsonl` are generated.
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
# AI Dev Harness 线上安装使用手册
|
|
2
|
+
|
|
3
|
+
## 1. 适用对象
|
|
4
|
+
|
|
5
|
+
本手册面向需要在业务 Git 仓库中使用 AI Dev Harness 的研发同学。
|
|
6
|
+
|
|
7
|
+
AI Dev Harness 的定位是:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
Codex / Claude / Cursor / Gemini 负责理解任务、调用 MCP、使用 Skill、修改代码。
|
|
11
|
+
Harness 负责执行闭环、日志、验证、审计、总结和知识沉淀建议。
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Harness 不是 MCP Client。CodeGraph / Knowledge Graph MCP 由当前执行器自己调用。
|
|
15
|
+
|
|
16
|
+
## 2. 环境要求
|
|
17
|
+
|
|
18
|
+
- Node.js >= 20
|
|
19
|
+
- npm
|
|
20
|
+
- Git
|
|
21
|
+
- Claude Code、Codex CLI、Cursor Agent、Gemini CLI 至少安装一个
|
|
22
|
+
- 业务仓库已经是 Git 仓库
|
|
23
|
+
|
|
24
|
+
检查命令:
|
|
25
|
+
|
|
26
|
+
```powershell
|
|
27
|
+
node -v
|
|
28
|
+
npm -v
|
|
29
|
+
git status
|
|
30
|
+
claude --version
|
|
31
|
+
codex --version
|
|
32
|
+
cursor-agent --version
|
|
33
|
+
gemini --version
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`claude`、`codex`、`cursor-agent`、`gemini` 任一执行器可用即可;具体命令可在 `harness.yaml` 覆盖。
|
|
37
|
+
|
|
38
|
+
## 3. 线上安装
|
|
39
|
+
|
|
40
|
+
全局安装:
|
|
41
|
+
|
|
42
|
+
```powershell
|
|
43
|
+
npm install -g ai-dev-harness
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
检查是否安装成功:
|
|
47
|
+
|
|
48
|
+
```powershell
|
|
49
|
+
harness --help
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
正确入口是:
|
|
53
|
+
|
|
54
|
+
```powershell
|
|
55
|
+
harness
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
不要在业务仓库中执行:
|
|
59
|
+
|
|
60
|
+
```powershell
|
|
61
|
+
node dist/cli.js init
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`node dist/cli.js` 只适用于 AI Dev Harness 源码仓,不适用于普通业务仓。
|
|
65
|
+
|
|
66
|
+
## 4. 在业务仓库初始化
|
|
67
|
+
|
|
68
|
+
进入业务仓库:
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
cd C:\yuntun_app\360download_mobile
|
|
72
|
+
git status
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
初始化 Harness:
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
harness init
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
检查本地试点环境:
|
|
82
|
+
```powershell
|
|
83
|
+
harness doctor
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`doctor` 只检查 Git、配置、Skill、Agent 命令、MCP source metadata 和验证命令强度,不会连接 MCP,也不会调用 Agent。
|
|
87
|
+
|
|
88
|
+
初始化后会生成:
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
harness.yaml
|
|
92
|
+
AGENTS.md
|
|
93
|
+
TOOLS.md
|
|
94
|
+
SKILLS.md
|
|
95
|
+
skills/
|
|
96
|
+
.claude/skills/ai-dev-harness/SKILL.md
|
|
97
|
+
.cursor/rules/ai-dev-harness.mdc
|
|
98
|
+
GEMINI.md
|
|
99
|
+
.harness/ai-dev-harness/scripts/run-harness.ps1
|
|
100
|
+
.harness/ai-dev-harness/scripts/read-evidence.ps1
|
|
101
|
+
runs/
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`harness init` 默认会安装 Claude/Codex/Cursor/Gemini 对话集成。
|
|
105
|
+
|
|
106
|
+
如果只想初始化 CLI 配置,不安装对话集成:
|
|
107
|
+
|
|
108
|
+
```powershell
|
|
109
|
+
harness init --no-integration
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 5. 配置 MCP
|
|
113
|
+
|
|
114
|
+
Claude/Codex 的 MCP 配置示例:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"mcpServers": {
|
|
119
|
+
"okf-360": {
|
|
120
|
+
"url": "http://10.41.83.107:9200/mcp",
|
|
121
|
+
"headers": {
|
|
122
|
+
"Authorization": "Bearer ${OKF_TOKEN}"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"code-graph": {
|
|
126
|
+
"type": "sse",
|
|
127
|
+
"url": "http://10.41.83.107:7878/mcp"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
业务仓库中的 `harness.yaml` 也保留 MCP source metadata,用于审计记录:
|
|
134
|
+
|
|
135
|
+
```yaml
|
|
136
|
+
mcp:
|
|
137
|
+
codegraph:
|
|
138
|
+
type: sse
|
|
139
|
+
url: http://10.41.83.107:7878/mcp
|
|
140
|
+
headers: {}
|
|
141
|
+
knowledgeGraph:
|
|
142
|
+
type: http
|
|
143
|
+
url: http://10.41.83.107:9200/mcp
|
|
144
|
+
headers:
|
|
145
|
+
Authorization: Bearer ${OKF_TOKEN}
|
|
146
|
+
timeoutMs: 15000
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
设置 token:
|
|
150
|
+
|
|
151
|
+
```powershell
|
|
152
|
+
$env:OKF_TOKEN="your-token"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
长期生效可以使用:
|
|
156
|
+
|
|
157
|
+
```powershell
|
|
158
|
+
setx OKF_TOKEN "your-token"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
注意:不要把真实 token 提交到 Git。
|
|
162
|
+
|
|
163
|
+
## 6. 命令行使用
|
|
164
|
+
|
|
165
|
+
推荐先跑只读冒烟:
|
|
166
|
+
|
|
167
|
+
```powershell
|
|
168
|
+
harness smoke --agent claude --live
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
这等价于执行一个 `update_docs` 只读任务,用来确认本地闭环、日志和证据目录都正常。
|
|
172
|
+
|
|
173
|
+
只读分析:
|
|
174
|
+
|
|
175
|
+
```powershell
|
|
176
|
+
harness run --task "分析下载模块启动流程。Do not modify repository files." --skill update_docs --agent claude --live
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
修 bug:
|
|
180
|
+
|
|
181
|
+
```powershell
|
|
182
|
+
harness run --task "修复下载续传进度异常问题" --skill fix_bug --agent claude --live
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
写测试:
|
|
186
|
+
|
|
187
|
+
```powershell
|
|
188
|
+
harness run --task "为下载任务状态流转补充测试" --skill write_tests --agent claude --live
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
使用 Codex:
|
|
192
|
+
|
|
193
|
+
```powershell
|
|
194
|
+
harness run --task "分析下载模块启动流程。Do not modify repository files." --skill update_docs --agent codex --live
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Cursor / Gemini:
|
|
198
|
+
|
|
199
|
+
```powershell
|
|
200
|
+
harness run --task "修复下载续传进度异常问题" --skill fix_bug --agent cursor --live
|
|
201
|
+
harness run --task "修复下载续传进度异常问题" --skill fix_bug --agent gemini --live
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## 7. 在 Claude/Codex/Cursor/Gemini 对话中使用
|
|
205
|
+
|
|
206
|
+
初始化后,可以直接在 Claude Code、Codex、Cursor 或 Gemini 对话中说:
|
|
207
|
+
|
|
208
|
+
```text
|
|
209
|
+
Use AI Dev Harness to run update_docs: 分析下载模块启动流程。Do not modify repository files.
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
或者:
|
|
213
|
+
|
|
214
|
+
```text
|
|
215
|
+
Use AI Dev Harness to run fix_bug: 修复下载续传进度异常问题。
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Agent 应该执行以下流程:
|
|
219
|
+
|
|
220
|
+
1. 先调用 CodeGraph MCP / Knowledge Graph MCP。
|
|
221
|
+
2. 在当前对话中输出 MCP Preflight Findings。
|
|
222
|
+
3. 调用 Harness CLI。
|
|
223
|
+
4. 实时展示 Harness 生命周期日志。
|
|
224
|
+
5. 读取并总结 `runs/<run_id>/` 证据目录。
|
|
225
|
+
|
|
226
|
+
## 8. MCP Preflight 输出格式
|
|
227
|
+
|
|
228
|
+
Agent 在触发 Harness 前,应按以下格式汇报:
|
|
229
|
+
|
|
230
|
+
如果 CodeGraph 使用的是 `colbymchenry/codegraph`,默认优先调用 `codegraph_explore`。用任务里的业务流程、文件路径、函数/类/符号名或错误现象作为 query,并重点读取它返回的 grouped source、line-numbered source、call paths、dynamic dispatch hops 和 blast-radius summary。
|
|
231
|
+
|
|
232
|
+
如果 Knowledge Graph 使用的是 `browser_knowledge_service`,推荐读取顺序:
|
|
233
|
+
|
|
234
|
+
1. 用 `list_path`、`search_docs`、`search_sections`、`search_chunks` 缩小范围。
|
|
235
|
+
2. RAG 场景优先用 `answer_context`;需要自控排序时用 `hybrid_search`。
|
|
236
|
+
3. 定位 concept_id 后先用 `read_doc_outline` 看结构。
|
|
237
|
+
4. 再用 `read_section`、`read_doc_range`、`read_chunk`、`get_related_chunks` 精读证据。
|
|
238
|
+
5. 需要关系时用 `get_backlinks`,需要近期变更记录时用 `get_audit_log`。
|
|
239
|
+
6. v1 不直接调用 `propose_doc` 写入知识库;只生成 `persist_suggestions.md`。
|
|
240
|
+
|
|
241
|
+
```text
|
|
242
|
+
## MCP Preflight Findings
|
|
243
|
+
- CodeGraph tools used:
|
|
244
|
+
- CodeGraph primary query:
|
|
245
|
+
- Source grouped by file:
|
|
246
|
+
- Current line-numbered source:
|
|
247
|
+
- Call paths:
|
|
248
|
+
- Dynamic dispatch hops:
|
|
249
|
+
- Blast-radius summary:
|
|
250
|
+
- Knowledge Graph tools used:
|
|
251
|
+
- Candidate concept_ids:
|
|
252
|
+
- Read tools used:
|
|
253
|
+
- Evidence sections/chunks:
|
|
254
|
+
- ADRs / decisions:
|
|
255
|
+
- Module notes:
|
|
256
|
+
- API notes / runbooks:
|
|
257
|
+
- Audit/backlink findings:
|
|
258
|
+
- Missing context:
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
这些发现应写入 Harness 的 task 文本,进入审计证据。
|
|
262
|
+
|
|
263
|
+
## 9. OKF 知识沉淀建议
|
|
264
|
+
|
|
265
|
+
`persist_suggestions.md` 只生成可评审的 OKF 候选内容,不自动写入 Knowledge Graph。
|
|
266
|
+
|
|
267
|
+
- 候选文档路径应落到 `/<project>/overview/`、`/<project>/features/`、`/<project>/metrics/`、`/<project>/api/`、`/<project>/playbooks/` 或 `/<project>/references/`。
|
|
268
|
+
- 每个候选 concept 应包含 `type`、`title`、`description`、`tags`、`timestamp`;API/数据类建议补充 `resource`。
|
|
269
|
+
- `## 相关` 必须使用有效 Markdown 链接,推荐 bundle 根相对路径。
|
|
270
|
+
- `type: API Reference` 需要包含 `## 关键实现锚点` 和 `### Agent 使用建议`。
|
|
271
|
+
- 合入知识库前应同步更新对应目录的 `index.md` 和 `log.md`。
|
|
272
|
+
- 不要写入密钥、Token、明文密码、未脱敏用户数据、未公开内网 IP。
|
|
273
|
+
|
|
274
|
+
## 10. 运行证据目录
|
|
275
|
+
|
|
276
|
+
每次运行会生成:
|
|
277
|
+
|
|
278
|
+
```text
|
|
279
|
+
runs/<run_id>/
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
核心文件:
|
|
283
|
+
|
|
284
|
+
```text
|
|
285
|
+
intake.json 任务、Skill、Agent、Git 状态
|
|
286
|
+
mcp_queries.jsonl Agent-driven MCP source metadata
|
|
287
|
+
context_pack.md 上下文组装协议和本地兜底上下文
|
|
288
|
+
agent_prompt.md 发给当前执行器的最终提示词
|
|
289
|
+
plan.md Harness 执行阶段协议
|
|
290
|
+
execution.log Agent stdout/stderr
|
|
291
|
+
agent_contract.json Agent 输出契约检查
|
|
292
|
+
git_diff.patch 代码变更
|
|
293
|
+
verify.json 验证结果
|
|
294
|
+
verify_diagnostics.json 验证失败诊断
|
|
295
|
+
context_score.json 上下文证据评分
|
|
296
|
+
approval_required.json 审批门禁结果
|
|
297
|
+
feedback.jsonl Harness 可见机器反馈事件
|
|
298
|
+
checkpoint.json Git checkpoint 和 restore 支持状态
|
|
299
|
+
pre_iteration_diff.patch 本轮前 diff
|
|
300
|
+
post_iteration_diff.patch 本轮后 diff
|
|
301
|
+
loop_review.json 每轮评估、失败归因和下一步动作
|
|
302
|
+
loop_report.md 自纠偏循环报告
|
|
303
|
+
summary.md 评审/PR 总结
|
|
304
|
+
persist_suggestions.md 知识沉淀建议
|
|
305
|
+
audit.jsonl 完整审计事件流
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
读取证据:
|
|
309
|
+
|
|
310
|
+
```powershell
|
|
311
|
+
powershell -ExecutionPolicy Bypass -File ".harness/ai-dev-harness/scripts/read-evidence.ps1" -Run <run_id>
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## 11. 自纠偏循环
|
|
315
|
+
|
|
316
|
+
默认只跑 1 轮,行为等同普通执行。需要允许 Harness 在低风险失败后自动 rework,可在 `harness.yaml` 中配置:
|
|
317
|
+
|
|
318
|
+
```yaml
|
|
319
|
+
loop:
|
|
320
|
+
maxIterations: 2
|
|
321
|
+
stopOn:
|
|
322
|
+
- same_failure_repeated
|
|
323
|
+
- max_iterations_reached
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
自动 rework 的典型触发条件:
|
|
327
|
+
|
|
328
|
+
- Agent 命令失败。
|
|
329
|
+
- Agent 输出不符合固定报告契约。
|
|
330
|
+
- 验证命令失败。
|
|
331
|
+
|
|
332
|
+
停止并人工评审的典型条件:
|
|
333
|
+
|
|
334
|
+
- 连续两轮同类失败。
|
|
335
|
+
- 达到最大轮次。
|
|
336
|
+
- 需要扩大范围、修改公共接口、安全策略,或目标本身不明确。
|
|
337
|
+
|
|
338
|
+
## 12. 重新验证和总结
|
|
339
|
+
|
|
340
|
+
重新运行验证:
|
|
341
|
+
|
|
342
|
+
```powershell
|
|
343
|
+
harness verify --run <run_id>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
重新生成总结:
|
|
347
|
+
|
|
348
|
+
```powershell
|
|
349
|
+
harness summarize --run <run_id>
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
恢复 clean baseline 下的某轮修改:
|
|
353
|
+
|
|
354
|
+
```powershell
|
|
355
|
+
harness restore --run <run_id> --iteration 1
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
查看本地 runs 指标:
|
|
359
|
+
|
|
360
|
+
```powershell
|
|
361
|
+
harness runs metrics
|
|
362
|
+
harness runs metrics --json
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
回放历史任务:
|
|
366
|
+
|
|
367
|
+
```powershell
|
|
368
|
+
harness replay --run <run_id> --dry
|
|
369
|
+
harness replay --run <run_id> --agent claude
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## 13. 常见问题
|
|
373
|
+
|
|
374
|
+
### 1. `Cannot find module '...\dist\cli.js'`
|
|
375
|
+
|
|
376
|
+
原因:在业务仓库里执行了错误命令:
|
|
377
|
+
|
|
378
|
+
```powershell
|
|
379
|
+
node dist/cli.js init
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
解决:
|
|
383
|
+
|
|
384
|
+
```powershell
|
|
385
|
+
harness init
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### 2. `harness` 命令不存在
|
|
389
|
+
|
|
390
|
+
重新安装:
|
|
391
|
+
|
|
392
|
+
```powershell
|
|
393
|
+
npm install -g ai-dev-harness
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
检查 npm 全局 bin 是否在 `PATH`。
|
|
397
|
+
|
|
398
|
+
### 3. `harness run 必须在 Git 仓库内执行`
|
|
399
|
+
|
|
400
|
+
进入业务 Git 仓库后再执行:
|
|
401
|
+
|
|
402
|
+
```powershell
|
|
403
|
+
git status
|
|
404
|
+
harness run --task "..." --skill update_docs --agent claude --live
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### 4. Claude/Codex 看不到 MCP 工具
|
|
408
|
+
|
|
409
|
+
优先检查 Claude/Codex 的 MCP 配置,而不是 Harness:
|
|
410
|
+
|
|
411
|
+
- MCP URL 是否正确
|
|
412
|
+
- token 是否有效
|
|
413
|
+
- 服务是否可访问
|
|
414
|
+
- CodeGraph 是否配置为 `type: sse`
|
|
415
|
+
- Knowledge Graph 是否带 Authorization header
|
|
416
|
+
|
|
417
|
+
### 5. Agent 输出不符合要求
|
|
418
|
+
|
|
419
|
+
查看:
|
|
420
|
+
|
|
421
|
+
```text
|
|
422
|
+
runs/<run_id>/agent_contract.json
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Harness 会检查 Agent 是否输出:
|
|
426
|
+
|
|
427
|
+
- `Impact Analysis`
|
|
428
|
+
- `Plan`
|
|
429
|
+
- `Execution Notes`
|
|
430
|
+
- `Verification Notes`
|
|
431
|
+
- `Final Report`
|
|
432
|
+
|
|
433
|
+
## 14. 推荐团队使用方式
|
|
434
|
+
|
|
435
|
+
第一次接入:
|
|
436
|
+
|
|
437
|
+
```powershell
|
|
438
|
+
npm install -g ai-dev-harness
|
|
439
|
+
cd <business-repo>
|
|
440
|
+
harness init
|
|
441
|
+
harness doctor
|
|
442
|
+
harness smoke --agent claude --live
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
日常使用:
|
|
446
|
+
|
|
447
|
+
```text
|
|
448
|
+
在 Claude/Codex 对话中说:
|
|
449
|
+
Use AI Dev Harness to run <skill>: <task>
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
推荐从只读任务开始:
|
|
453
|
+
|
|
454
|
+
```text
|
|
455
|
+
Use AI Dev Harness to run update_docs: 分析下载模块启动流程。Do not modify repository files.
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
确认流程稳定后,再用于 `fix_bug`、`write_tests`、`add_feature`。
|