@dommaker/harness 0.7.9 → 0.8.1
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/README.md +149 -217
- package/bin/harness.js +122 -85
- package/dist/cli/commands/acceptance.d.ts +26 -0
- package/dist/cli/commands/acceptance.d.ts.map +1 -0
- package/dist/cli/commands/acceptance.js +130 -0
- package/dist/cli/commands/acceptance.js.map +1 -0
- package/dist/cli/commands/check.js +3 -3
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/contract.d.ts +24 -0
- package/dist/cli/commands/contract.d.ts.map +1 -0
- package/dist/cli/commands/contract.js +182 -0
- package/dist/cli/commands/contract.js.map +1 -0
- package/dist/cli/commands/index.d.ts +5 -3
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +15 -7
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.js +9 -0
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/performance.d.ts +26 -0
- package/dist/cli/commands/performance.d.ts.map +1 -0
- package/dist/cli/commands/performance.js +86 -0
- package/dist/cli/commands/performance.js.map +1 -0
- package/dist/cli/commands/review.d.ts +26 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +137 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/security.d.ts +26 -0
- package/dist/cli/commands/security.d.ts.map +1 -0
- package/dist/cli/commands/security.js +147 -0
- package/dist/cli/commands/security.js.map +1 -0
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +4 -5
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +71 -0
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/gates/command.d.ts +85 -0
- package/dist/gates/command.d.ts.map +1 -0
- package/dist/gates/command.js +392 -0
- package/dist/gates/command.js.map +1 -0
- package/dist/gates/index.d.ts +2 -1
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js +9 -1
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/types.d.ts +23 -0
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/types/constraint.d.ts +1 -1
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,240 +1,163 @@
|
|
|
1
1
|
# @dommaker/harness
|
|
2
2
|
|
|
3
|
-
> AI Agent 的工程约束框架 —
|
|
4
|
-
|
|
5
|
-
## 一句话
|
|
6
|
-
|
|
7
|
-
**harness 让 Agent 不会乱承诺、不会跳过验证、不会简化测试。**
|
|
3
|
+
> AI Agent 的工程约束框架 — 让 Agent 不会乱承诺、不会跳过验证、不会简化测试。
|
|
8
4
|
|
|
9
5
|
---
|
|
10
6
|
|
|
11
|
-
##
|
|
7
|
+
## 🚀 快速开始
|
|
12
8
|
|
|
13
|
-
###
|
|
9
|
+
### 安装
|
|
14
10
|
|
|
15
11
|
```bash
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
npm install -g @dommaker/harness
|
|
13
|
+
```
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
harness init --preset standard
|
|
15
|
+
### 最小工作流
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
```bash
|
|
18
|
+
# 开发前
|
|
23
19
|
harness check
|
|
24
20
|
|
|
25
|
-
#
|
|
26
|
-
harness status
|
|
27
|
-
|
|
28
|
-
# 验证检查点
|
|
29
|
-
harness validate
|
|
21
|
+
# 开发 + 写测试
|
|
30
22
|
|
|
31
|
-
#
|
|
23
|
+
# 提交前
|
|
32
24
|
harness passes-gate
|
|
33
|
-
|
|
34
|
-
# Spec 验证
|
|
35
|
-
harness spec
|
|
36
|
-
|
|
37
|
-
# 一键诊断
|
|
38
|
-
harness flow
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### 最小工作流
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
开始开发
|
|
45
|
-
↓
|
|
46
|
-
harness check (检查铁律)
|
|
47
|
-
↓
|
|
48
|
-
写代码 + 写测试
|
|
49
|
-
↓
|
|
50
|
-
harness passes-gate (验证通过)
|
|
51
|
-
↓
|
|
52
|
-
提交
|
|
53
25
|
```
|
|
54
26
|
|
|
55
27
|
---
|
|
56
28
|
|
|
57
|
-
##
|
|
29
|
+
## 📋 CLI 命令
|
|
58
30
|
|
|
59
|
-
###
|
|
31
|
+
### 日常使用
|
|
60
32
|
|
|
61
|
-
|
|
33
|
+
```bash
|
|
34
|
+
harness check # 检查铁律(开发前后必用)
|
|
35
|
+
harness passes-gate # 测试门控(提交前验证)
|
|
36
|
+
harness status # 查看状态(异常、统计)
|
|
37
|
+
harness flow # 一键诊断 + 提案流程
|
|
38
|
+
```
|
|
62
39
|
|
|
63
|
-
|
|
64
|
-
|--------|------|
|
|
65
|
-
| 工作目录干净? | 无未提交变更 |
|
|
66
|
-
| Roadmap 存在? | 知道要做什么 |
|
|
67
|
-
| Spec 存在? | 知道怎么做 |
|
|
68
|
-
| 依赖满足? | 前置任务完成 |
|
|
40
|
+
### 项目初始化
|
|
69
41
|
|
|
70
42
|
```bash
|
|
71
|
-
harness
|
|
43
|
+
harness init --preset standard # 初始化配置
|
|
44
|
+
harness init --print-snippets # 输出代码片段
|
|
72
45
|
```
|
|
73
46
|
|
|
74
|
-
###
|
|
47
|
+
### 门禁检查
|
|
75
48
|
|
|
76
|
-
|
|
49
|
+
```bash
|
|
50
|
+
# 测试门控
|
|
51
|
+
harness passes-gate # 运行测试
|
|
52
|
+
harness passes-gate --coverage # 检查覆盖率
|
|
53
|
+
harness pg # 别名
|
|
54
|
+
|
|
55
|
+
# 验收标准
|
|
56
|
+
harness acceptance --task-id TASK-001 # 检查指定任务
|
|
57
|
+
harness acceptance --check-all # 检查所有任务
|
|
58
|
+
harness acceptance list # 列出验收标准
|
|
59
|
+
harness acc # 别名
|
|
60
|
+
|
|
61
|
+
# 性能门控
|
|
62
|
+
harness performance --coverage --coverage-threshold 85 # 覆盖率检查
|
|
63
|
+
harness performance --bundle --bundle-threshold 300 # 打包大小检查
|
|
64
|
+
harness perf # 别名
|
|
65
|
+
|
|
66
|
+
# 安全门控
|
|
67
|
+
harness security # npm audit 检查
|
|
68
|
+
harness security --severity critical # 只显示 critical 级别
|
|
69
|
+
harness security audit # 详细漏洞报告
|
|
70
|
+
harness sec # 别名
|
|
71
|
+
|
|
72
|
+
# API 契约
|
|
73
|
+
harness contract # OpenAPI Schema 验证
|
|
74
|
+
harness contract validate # Schema 语法验证
|
|
75
|
+
harness contract --contract-path api/openapi.yaml
|
|
76
|
+
|
|
77
|
+
# 代码审查
|
|
78
|
+
harness review # PR 审查状态检查
|
|
79
|
+
harness review --min-reviewers 2 # 要求 2 个审批
|
|
80
|
+
harness review status # PR 详情
|
|
81
|
+
```
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|---|------|-------------|
|
|
80
|
-
| `no_bypass_checkpoint` | 禁止跳过检查点 | ❌ "先跳过验证" |
|
|
81
|
-
| `no_self_approval` | 禁止自评通过 | ❌ "应该没问题" |
|
|
82
|
-
| `no_completion_without_verification` | 完成必须有验证 | ❌ "任务完成了"(未测试)|
|
|
83
|
-
| `no_test_simplification` | 禁止简化测试 | ❌ "测试太难,先删掉" |
|
|
83
|
+
### Spec 验证
|
|
84
84
|
|
|
85
85
|
```bash
|
|
86
|
-
harness
|
|
86
|
+
harness spec # 验证所有 Spec
|
|
87
|
+
harness spec --staged # 验证暂存文件
|
|
88
|
+
harness spec list # 支持的 Spec 类型
|
|
87
89
|
```
|
|
88
90
|
|
|
89
|
-
###
|
|
91
|
+
### 检查点验证
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
```bash
|
|
94
|
+
harness validate # 验证检查点
|
|
95
|
+
harness validate --strict # 严格模式
|
|
96
|
+
harness validate -f checkpoint.json # 指定文件
|
|
97
|
+
```
|
|
92
98
|
|
|
93
|
-
|
|
94
|
-
|------|---------|
|
|
95
|
-
| PassesGate | 测试必须通过 |
|
|
96
|
-
| ReviewGate | PR 必须有人审核 |
|
|
97
|
-
| SecurityGate | 无高危漏洞 |
|
|
98
|
-
| PerformanceGate | 性能达标 |
|
|
99
|
+
### 报告
|
|
99
100
|
|
|
100
101
|
```bash
|
|
101
|
-
harness
|
|
102
|
+
harness report # 生成 Markdown 报告
|
|
103
|
+
harness report -f json # JSON 格式
|
|
104
|
+
harness report -o report.md # 输出到文件
|
|
102
105
|
```
|
|
103
106
|
|
|
104
|
-
###
|
|
105
|
-
|
|
106
|
-
验证架构文档、API 定义等 Spec 文件:
|
|
107
|
+
### 诊断
|
|
107
108
|
|
|
108
109
|
```bash
|
|
109
|
-
harness
|
|
110
|
-
harness
|
|
111
|
-
harness spec list # 支持的 Spec 类型
|
|
110
|
+
harness flow # 一键诊断 + 提案
|
|
111
|
+
harness flow --auto-apply # 自动应用低风险提案
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
---
|
|
115
115
|
|
|
116
|
-
## 核心概念
|
|
116
|
+
## 🎯 核心概念
|
|
117
117
|
|
|
118
118
|
### 三层约束体系
|
|
119
119
|
|
|
120
|
-
| 层级 |
|
|
121
|
-
|
|
122
|
-
| **Iron Law** |
|
|
123
|
-
| **Guideline** |
|
|
124
|
-
| **Tip** |
|
|
125
|
-
|
|
126
|
-
### 16 条内置约束
|
|
120
|
+
| 层级 | 严重性 | 说明 |
|
|
121
|
+
|------|:------:|------|
|
|
122
|
+
| **Iron Law** | 🔴 error | 绝对禁止,无例外 |
|
|
123
|
+
| **Guideline** | 🟡 warning | 推荐遵守,有例外 |
|
|
124
|
+
| **Tip** | 🔵 info | 信息性提示 |
|
|
127
125
|
|
|
128
|
-
|
|
126
|
+
### 7 条铁律
|
|
129
127
|
|
|
130
128
|
| ID | 规则 |
|
|
131
129
|
|---|------|
|
|
132
130
|
| `no_bypass_checkpoint` | 禁止跳过检查点 |
|
|
133
|
-
| `no_self_approval` |
|
|
131
|
+
| `no_self_approval` | 禁止自评通过(必须测试)|
|
|
134
132
|
| `no_completion_without_verification` | 完成必须验证 |
|
|
135
133
|
| `no_test_simplification` | 禁止简化测试 |
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
|
143
|
-
|
|
144
|
-
| `
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
| ID | 规则 |
|
|
155
|
-
|---|------|
|
|
156
|
-
| `readme_required` | 新模块有 README |
|
|
157
|
-
| `doc_required_for_public_api` | 公共 API 有文档 |
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## 7 种门禁
|
|
162
|
-
|
|
163
|
-
| 门禁 | 类 | 用途 |
|
|
164
|
-
|------|-----|------|
|
|
165
|
-
| PassesGate | 测试门控 | 禁止自评通过 |
|
|
166
|
-
| ReviewGate | 审查门控 | PR 审核检查 |
|
|
167
|
-
| SecurityGate | 安全门控 | npm audit |
|
|
168
|
-
| PerformanceGate | 性能门控 | 响应时间、覆盖率 |
|
|
169
|
-
| ContractGate | 契约门控 | OpenAPI 验证 |
|
|
170
|
-
| CheckpointValidator | 检查点验证 | 步骤结果验证 |
|
|
171
|
-
| SpecAcceptanceGate | 验收门控 | 验收标准检查 |
|
|
134
|
+
| `incremental_progress` | 单任务单会话 |
|
|
135
|
+
| `verify_external_capability` | 外部能力先验证 |
|
|
136
|
+
| `no_implementation_without_requirement_review` | 实现后对比需求 |
|
|
137
|
+
|
|
138
|
+
### 7 种门禁(均有 CLI 命令)
|
|
139
|
+
|
|
140
|
+
| 门禁 | CLI 命令 | 用途 |
|
|
141
|
+
|------|:--------:|------|
|
|
142
|
+
| PassesGate | `passes-gate` / `pg` | 测试门控 |
|
|
143
|
+
| SpecAcceptanceGate | `acceptance` / `acc` | 验收标准检查 |
|
|
144
|
+
| PerformanceGate | `performance` / `perf` | 性能门控 |
|
|
145
|
+
| SecurityGate | `security` / `sec` | 安全检查 |
|
|
146
|
+
| ContractGate | `contract` | API 契约验证 |
|
|
147
|
+
| ReviewGate | `review` | PR 审核检查 |
|
|
148
|
+
| CheckpointValidator | `validate` | 检查点验证 |
|
|
149
|
+
| CheckpointValidator | 检查点验证 |
|
|
150
|
+
| SpecAcceptanceGate | 验收标准检查 |
|
|
172
151
|
|
|
173
152
|
---
|
|
174
153
|
|
|
175
|
-
##
|
|
176
|
-
|
|
177
|
-
| 预设 | 说明 |
|
|
178
|
-
|------|------|
|
|
179
|
-
| `strict` | 所有检查启用 |
|
|
180
|
-
| `standard` | 推荐使用 |
|
|
181
|
-
| `relaxed` | 警告不阻止 |
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
harness init --preset standard
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## 高级功能
|
|
190
|
-
|
|
191
|
-
### CLI 详细命令
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
# 初始化(输出代码片段)
|
|
195
|
-
harness init --print-snippets
|
|
196
|
-
|
|
197
|
-
# 铁律检查
|
|
198
|
-
harness check --list # 列出所有铁律
|
|
199
|
-
harness check --json # JSON 输出
|
|
200
|
-
|
|
201
|
-
# 状态查看
|
|
202
|
-
harness status --detail # 详细状态
|
|
203
|
-
harness status --anomalies # 只显示异常
|
|
204
|
-
|
|
205
|
-
# Trace 分析(已弃用,用 status)
|
|
206
|
-
harness traces stats # 统计
|
|
207
|
-
harness traces anomalies # 异常检测
|
|
208
|
-
|
|
209
|
-
# 诊断流程
|
|
210
|
-
harness diagnose run --hours 24 --save
|
|
211
|
-
harness diagnose list
|
|
212
|
-
harness propose generate --save
|
|
213
|
-
harness propose review --diagnosis <id> --accept
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### 项目自定义约束
|
|
217
|
-
|
|
218
|
-
```yaml
|
|
219
|
-
# .harness/custom-constraints.yml
|
|
220
|
-
custom_constraints:
|
|
221
|
-
no_fix_without_root_cause:
|
|
222
|
-
# 追加例外(保留内置)
|
|
223
|
-
extend_exceptions:
|
|
224
|
-
- my_special_case
|
|
225
|
-
# 或完全覆盖
|
|
226
|
-
exceptions:
|
|
227
|
-
- my_only_exception
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
### 在代码中使用
|
|
154
|
+
## 🔧 代码集成
|
|
231
155
|
|
|
232
156
|
```typescript
|
|
233
157
|
import {
|
|
234
158
|
IronLawChecker,
|
|
235
159
|
PassesGate,
|
|
236
160
|
CheckpointValidator,
|
|
237
|
-
SessionStartup,
|
|
238
161
|
interceptOperation,
|
|
239
162
|
} from '@dommaker/harness';
|
|
240
163
|
|
|
@@ -254,22 +177,23 @@ const result = await validator.validate(checkpoints, context);
|
|
|
254
177
|
await interceptOperation('task_completion_claim', context);
|
|
255
178
|
```
|
|
256
179
|
|
|
257
|
-
|
|
180
|
+
---
|
|
258
181
|
|
|
259
|
-
|
|
260
|
-
|-------------|------|
|
|
261
|
-
| `verify-completion` | 验证完成:运行测试 |
|
|
262
|
-
| `verify-e2e` | E2E 测试验证 |
|
|
263
|
-
| `debug-systematic` | 系统性调试 |
|
|
264
|
-
| `reuse-first` | 复用优先检查 |
|
|
265
|
-
| `update-capabilities` | CAPABILITIES 同步 |
|
|
266
|
-
| `tdd-cycle` | TDD 循环检查 |
|
|
267
|
-
| `passes-gate` | 测试门控 |
|
|
268
|
-
| `checkpoint-required` | 检查点必须通过 |
|
|
182
|
+
## 📁 项目配置
|
|
269
183
|
|
|
270
|
-
|
|
184
|
+
### .harness/config.yml
|
|
185
|
+
|
|
186
|
+
```yaml
|
|
187
|
+
preset: standard
|
|
271
188
|
|
|
272
|
-
|
|
189
|
+
# 自定义约束例外
|
|
190
|
+
custom_constraints:
|
|
191
|
+
no_fix_without_root_cause:
|
|
192
|
+
extend_exceptions:
|
|
193
|
+
- my_special_case
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### CI 集成
|
|
273
197
|
|
|
274
198
|
```yaml
|
|
275
199
|
# .github/workflows/harness-check.yml
|
|
@@ -279,52 +203,60 @@ jobs:
|
|
|
279
203
|
steps:
|
|
280
204
|
- uses: actions/checkout@v4
|
|
281
205
|
- run: npm ci
|
|
282
|
-
- run:
|
|
283
|
-
- run:
|
|
206
|
+
- run: harness check
|
|
207
|
+
- run: harness passes-gate
|
|
284
208
|
```
|
|
285
209
|
|
|
286
210
|
---
|
|
287
211
|
|
|
288
|
-
## Trace
|
|
289
|
-
|
|
290
|
-
### Execution Trace
|
|
212
|
+
## 📊 Trace & 日志
|
|
291
213
|
|
|
292
|
-
|
|
293
|
-
- 统计触发频率
|
|
294
|
-
- 检测异常(高绕过率、失败上升)
|
|
214
|
+
### 目录结构
|
|
295
215
|
|
|
296
216
|
```
|
|
297
|
-
.harness/
|
|
298
|
-
├──
|
|
299
|
-
├──
|
|
217
|
+
.harness/
|
|
218
|
+
├── traces/
|
|
219
|
+
│ ├── execution.log # 约束检查记录(JSON Lines)
|
|
220
|
+
│ └── summary.json # 统计汇总
|
|
221
|
+
└── state.json # Harness 状态
|
|
300
222
|
```
|
|
301
223
|
|
|
302
|
-
###
|
|
224
|
+
### 查看日志
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# 查看状态和统计
|
|
228
|
+
harness status
|
|
303
229
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
- 检测超阈值
|
|
230
|
+
# 查看详细统计
|
|
231
|
+
harness status --detail
|
|
307
232
|
|
|
233
|
+
# 只看异常
|
|
234
|
+
harness status --anomalies
|
|
235
|
+
|
|
236
|
+
# 分析最近 N 小时
|
|
237
|
+
harness status --hours 48
|
|
308
238
|
```
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
239
|
+
|
|
240
|
+
### 日志格式
|
|
241
|
+
|
|
242
|
+
**execution.log**(JSON Lines 格式):
|
|
243
|
+
```json
|
|
244
|
+
{"timestamp":"2026-04-28T15:00:00Z","constraintId":"no_bypass_checkpoint","result":"passed","duration":12}
|
|
245
|
+
{"timestamp":"2026-04-28T15:01:00Z","constraintId":"no_self_approval","result":"bypassed","reason":"hotfix"}
|
|
312
246
|
```
|
|
313
247
|
|
|
314
|
-
|
|
248
|
+
**summary.json**:
|
|
249
|
+
```json
|
|
250
|
+
{"totalChecks":150,"passRate":0.92,"bypassRate":0.08,"anomalies":2}
|
|
251
|
+
```
|
|
315
252
|
|
|
316
|
-
|
|
253
|
+
### 异常检测
|
|
317
254
|
|
|
318
|
-
|
|
319
|
-
|------|------|
|
|
320
|
-
| L1 | 自动重试 |
|
|
321
|
-
| L2 | 人工审核 |
|
|
322
|
-
| L3 | 开会讨论 |
|
|
323
|
-
| L4 | 回滚 |
|
|
255
|
+
当 `harness status --anomalies` 发现异常时,运行 `harness flow` 进行诊断和优化提案。
|
|
324
256
|
|
|
325
257
|
---
|
|
326
258
|
|
|
327
|
-
## 开发
|
|
259
|
+
## 🔧 开发
|
|
328
260
|
|
|
329
261
|
```bash
|
|
330
262
|
npm install
|
|
@@ -334,6 +266,6 @@ npm test
|
|
|
334
266
|
|
|
335
267
|
---
|
|
336
268
|
|
|
337
|
-
##
|
|
269
|
+
## 📝 License
|
|
338
270
|
|
|
339
|
-
MIT © dommaker
|
|
271
|
+
MIT © dommaker
|