@chenguangyao/devflow-kit 0.1.43

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.
Files changed (198) hide show
  1. package/CHANGELOG.md +232 -0
  2. package/LICENSE +21 -0
  3. package/README.md +539 -0
  4. package/bin/devflow.js +9 -0
  5. package/docs/RFC-001-devflow-kit.md +617 -0
  6. package/docs/RFC-002-workflow-kernel.md +134 -0
  7. package/docs/enterprise-integration-supplement.md +274 -0
  8. package/docs/internal-gitlab-setup.md +426 -0
  9. package/docs/marketplace-skills.md +231 -0
  10. package/docs/migration-from-arb.md +232 -0
  11. package/docs/tooling-overview.md +774 -0
  12. package/docs/workflow-orchestration.md +695 -0
  13. package/docs/workflow-ui-prototype.html +271 -0
  14. package/package.json +52 -0
  15. package/schemas/config.schema.json +51 -0
  16. package/schemas/delta.schema.json +22 -0
  17. package/schemas/state.schema.json +130 -0
  18. package/schemas/status-surface.schema.json +197 -0
  19. package/schemas/workflow-confirmation-surface.schema.json +70 -0
  20. package/schemas/workflow-picker.schema.json +94 -0
  21. package/scripts/postinstall.js +101 -0
  22. package/scripts/render-workflow-ui-prototype.js +271 -0
  23. package/skills/apply/SKILL.md +313 -0
  24. package/skills/apply/references/discipline-checklist.md +145 -0
  25. package/skills/apply/references/subagent-implementer-prompt.md +113 -0
  26. package/skills/apply/references/subagent-orchestration.md +150 -0
  27. package/skills/apply/references/subagent-reviewer-prompt.md +180 -0
  28. package/skills/apply/references/tdd-loop.md +287 -0
  29. package/skills/apply/references/when-plan-is-wrong.md +279 -0
  30. package/skills/apply/references/worktree-swarm.md +292 -0
  31. package/skills/archive/SKILL.md +229 -0
  32. package/skills/archive/references/conflict-resolution.md +336 -0
  33. package/skills/archive/references/knowledge-deposit.md +381 -0
  34. package/skills/archive/references/spec-merge.md +365 -0
  35. package/skills/brainstorm/SKILL.md +123 -0
  36. package/skills/brainstorm/references/proposal-template.md +244 -0
  37. package/skills/brainstorm/references/question-catalog.md +168 -0
  38. package/skills/brainstorm/references/session-template.md +184 -0
  39. package/skills/ci-fix/SKILL.md +63 -0
  40. package/skills/ci-fix/references/loop.md +25 -0
  41. package/skills/code-review/SKILL.md +279 -0
  42. package/skills/code-review/references/escalation-playbook.md +192 -0
  43. package/skills/code-review/references/language-cheatsheets/go.md +175 -0
  44. package/skills/code-review/references/language-cheatsheets/java-spring-mybatis.md +246 -0
  45. package/skills/code-review/references/language-cheatsheets/python.md +170 -0
  46. package/skills/code-review/references/language-cheatsheets/vue.md +199 -0
  47. package/skills/code-review/references/output-template.md +275 -0
  48. package/skills/code-review/references/review-checklist.md +251 -0
  49. package/skills/complexity-grading/SKILL.md +259 -0
  50. package/skills/deliver/SKILL.md +271 -0
  51. package/skills/deliver/references/delivery-modes.md +299 -0
  52. package/skills/deliver/references/notify.md +359 -0
  53. package/skills/deliver/references/pr-description.md +319 -0
  54. package/skills/dependency-upgrade/SKILL.md +57 -0
  55. package/skills/dependency-upgrade/references/risk-matrix.md +38 -0
  56. package/skills/df-orchestrator/SKILL.md +407 -0
  57. package/skills/df-orchestrator/references/complexity-grading.md +177 -0
  58. package/skills/df-orchestrator/references/escalation-matrix.md +191 -0
  59. package/skills/df-orchestrator/references/routing-rules.md +290 -0
  60. package/skills/df-orchestrator/references/workflow-state-machine.md +208 -0
  61. package/skills/frontend-quality/SKILL.md +61 -0
  62. package/skills/frontend-quality/references/checklist.md +35 -0
  63. package/skills/handoff-resume/SKILL.md +59 -0
  64. package/skills/handoff-resume/references/handoff-template.md +54 -0
  65. package/skills/plan/SKILL.md +166 -0
  66. package/skills/plan/references/task-breakdown.md +207 -0
  67. package/skills/plan/references/task-sequencing.md +143 -0
  68. package/skills/plan/references/task-template.md +248 -0
  69. package/skills/requirement-analysis/SKILL.md +499 -0
  70. package/skills/requirement-analysis/references/acceptance-criteria.md +183 -0
  71. package/skills/requirement-analysis/references/code-recon.md +151 -0
  72. package/skills/requirement-analysis/references/edge-case-catalog.md +164 -0
  73. package/skills/requirement-analysis/references/requirement-template.md +339 -0
  74. package/skills/requirement-analysis/references/scope-negotiation.md +162 -0
  75. package/skills/security-hardening/SKILL.md +60 -0
  76. package/skills/security-hardening/references/checklist.md +42 -0
  77. package/skills/tech-spec/SKILL.md +388 -0
  78. package/skills/tech-spec/references/api-contract-design.md +172 -0
  79. package/skills/tech-spec/references/decision-records.md +110 -0
  80. package/skills/tech-spec/references/design-template.md +301 -0
  81. package/skills/tech-spec/references/rollout-and-rollback.md +203 -0
  82. package/skills/tech-spec/references/spec-delta-conventions.md +250 -0
  83. package/skills/tech-spec/references/transaction-patterns.md +212 -0
  84. package/skills/test-spec/SKILL.md +219 -0
  85. package/skills/test-spec/references/coverage-strategy.md +218 -0
  86. package/skills/test-spec/references/edge-case-to-test.md +143 -0
  87. package/skills/test-spec/references/test-case-template.md +276 -0
  88. package/skills/verify/SKILL.md +232 -0
  89. package/skills/verify/references/nfr-verification.md +292 -0
  90. package/skills/verify/references/report-templates.md +510 -0
  91. package/skills/verify/references/self-test-guide.md +240 -0
  92. package/skills/verify/references/verify-rollback-map.md +247 -0
  93. package/src/cli/commands/_helpers.js +108 -0
  94. package/src/cli/commands/_submit.js +718 -0
  95. package/src/cli/commands/apply.js +198 -0
  96. package/src/cli/commands/archive.js +180 -0
  97. package/src/cli/commands/checkpoint.js +113 -0
  98. package/src/cli/commands/deliver.js +377 -0
  99. package/src/cli/commands/deploy.js +504 -0
  100. package/src/cli/commands/design.js +158 -0
  101. package/src/cli/commands/disable.js +21 -0
  102. package/src/cli/commands/doctor.js +178 -0
  103. package/src/cli/commands/enable.js +21 -0
  104. package/src/cli/commands/flow.js +645 -0
  105. package/src/cli/commands/help.js +93 -0
  106. package/src/cli/commands/ingest.js +602 -0
  107. package/src/cli/commands/init.js +341 -0
  108. package/src/cli/commands/knowledge.js +523 -0
  109. package/src/cli/commands/logs.js +43 -0
  110. package/src/cli/commands/new.js +202 -0
  111. package/src/cli/commands/plan.js +49 -0
  112. package/src/cli/commands/propose.js +27 -0
  113. package/src/cli/commands/provider.js +698 -0
  114. package/src/cli/commands/report.js +143 -0
  115. package/src/cli/commands/requirement.js +227 -0
  116. package/src/cli/commands/review.js +301 -0
  117. package/src/cli/commands/skills.js +457 -0
  118. package/src/cli/commands/status.js +925 -0
  119. package/src/cli/commands/switch.js +27 -0
  120. package/src/cli/commands/sync.js +47 -0
  121. package/src/cli/commands/test.js +366 -0
  122. package/src/cli/commands/uninstall.js +32 -0
  123. package/src/cli/commands/update.js +74 -0
  124. package/src/cli/commands/verify.js +354 -0
  125. package/src/cli/commands/worktree.js +78 -0
  126. package/src/cli/index.js +72 -0
  127. package/src/cli/parse-args.js +102 -0
  128. package/src/core/autodetect.js +271 -0
  129. package/src/core/change.js +208 -0
  130. package/src/core/checkpoint.js +217 -0
  131. package/src/core/config.js +60 -0
  132. package/src/core/delta.js +290 -0
  133. package/src/core/markers.js +59 -0
  134. package/src/core/paths.js +173 -0
  135. package/src/core/plan-tasks.js +36 -0
  136. package/src/core/project-routing.js +285 -0
  137. package/src/core/projects.js +200 -0
  138. package/src/core/state.js +200 -0
  139. package/src/core/workflow-check.js +177 -0
  140. package/src/core/workflow-init.js +34 -0
  141. package/src/core/workflow-picker.js +154 -0
  142. package/src/core/workflow-policy.js +119 -0
  143. package/src/core/workflow-suggest.js +181 -0
  144. package/src/core/workflow-verify.js +88 -0
  145. package/src/core/workflow.js +433 -0
  146. package/src/core/worktree.js +241 -0
  147. package/src/knowledge/categories.js +107 -0
  148. package/src/knowledge/classify.js +125 -0
  149. package/src/knowledge/deposit.js +414 -0
  150. package/src/knowledge/migrate.js +149 -0
  151. package/src/knowledge/mr.js +219 -0
  152. package/src/knowledge/query.js +131 -0
  153. package/src/knowledge/registry.js +151 -0
  154. package/src/knowledge/sync.js +179 -0
  155. package/src/providers/base.js +74 -0
  156. package/src/providers/drivers/api-yapi.js +78 -0
  157. package/src/providers/drivers/ci-jenkins.js +109 -0
  158. package/src/providers/drivers/intake-confluence.js +544 -0
  159. package/src/providers/drivers/kb-git.js +549 -0
  160. package/src/providers/drivers/kb-weknora.js +472 -0
  161. package/src/providers/drivers/notify-smtp.js +515 -0
  162. package/src/providers/drivers/observability-oss.js +43 -0
  163. package/src/providers/drivers/observability-sls.js +50 -0
  164. package/src/providers/lifecycle.js +135 -0
  165. package/src/providers/loader.js +132 -0
  166. package/src/providers/local.js +190 -0
  167. package/src/providers/userconfig.js +283 -0
  168. package/src/reports/aggregate.js +185 -0
  169. package/src/reports/coverage.js +163 -0
  170. package/src/reports/detect.js +143 -0
  171. package/src/reports/parse.js +236 -0
  172. package/src/templates/files/ci/github.yml +38 -0
  173. package/src/templates/files/ci/gitlab.yml +27 -0
  174. package/src/templates/files/design.md +63 -0
  175. package/src/templates/files/ide/devflow-workflow.md +58 -0
  176. package/src/templates/files/ide/project-overview-reference.md +1 -0
  177. package/src/templates/files/ide/project-overview.md +27 -0
  178. package/src/templates/files/knowledge-index.json +17 -0
  179. package/src/templates/files/knowledge.md +28 -0
  180. package/src/templates/files/meta.json +8 -0
  181. package/src/templates/files/plan.md +38 -0
  182. package/src/templates/files/proposal.md +33 -0
  183. package/src/templates/files/reports/contract-test.md +40 -0
  184. package/src/templates/files/reports/e2e-test.md +30 -0
  185. package/src/templates/files/reports/integration-test.md +36 -0
  186. package/src/templates/files/reports/joint-test.md +58 -0
  187. package/src/templates/files/reports/perf.md +24 -0
  188. package/src/templates/files/reports/regression.md +20 -0
  189. package/src/templates/files/reports/remote-test.md +55 -0
  190. package/src/templates/files/reports/self-test.md +43 -0
  191. package/src/templates/files/reports/smoke-test.md +22 -0
  192. package/src/templates/files/reports/unit-test.md +36 -0
  193. package/src/templates/files/requirement.md +51 -0
  194. package/src/templates/files/review.md +38 -0
  195. package/src/templates/files/tests.md +36 -0
  196. package/src/templates/files/verify.md +32 -0
  197. package/src/templates/index.js +21 -0
  198. package/src/utils/log.js +37 -0
@@ -0,0 +1,510 @@
1
+ # verify / report-templates
2
+
3
+ 每种报告的模板、frontmatter 字段语义、测试框架与 coverage 解析规则。
4
+
5
+ ---
6
+
7
+ ## frontmatter 字段
8
+
9
+ ### 必填
10
+
11
+ | 字段 | 类型 | 说明 |
12
+ | --- | --- | --- |
13
+ | `slug` | string | change 的 slug(如 `coupon-batch-grant`) |
14
+ | `kind` | enum | `unit` / `integration` / `e2e` / `joint` / `remote` / `smoke` / `self-test` / `regression` / `perf` |
15
+ | `status` | enum | `pass` / `fail` / `partial` / `blocked` |
16
+ | `failureType` | enum | `code_error` / `env_error` / `-` |
17
+ | `ts` | ISO datetime | 报告生成时间(不是测试运行时间的开始时间,是记录时间) |
18
+
19
+ `status` 语义:
20
+
21
+ - `pass`:全部通过(允许少量已审计跳过)
22
+ - `fail`:至少 1 个 fail,无法发布
23
+ - `partial`:部分通过,需用户 / orchestrator 判断是否接受(如跨 day 跑时部分环境不可达)
24
+ - `blocked`:测试未能有效执行,通常是环境、URL、浏览器工具或账号权限问题
25
+
26
+ `failureType` 用来指导回流:
27
+
28
+ - `code_error`:测试已运行但断言失败或命令退出非 0,下一步回 apply 修代码并重跑
29
+ - `env_error`:测试环境、API 地址、浏览器自动化工具、账号或网络不可用,下一步先修环境再重跑
30
+ - `-`:未失败或暂不分类
31
+
32
+ ### 推荐
33
+
34
+ | 字段 | 类型 | 说明 |
35
+ | --- | --- | --- |
36
+ | `total` | int | 测试总数 |
37
+ | `passed` | int | 通过数 |
38
+ | `failed` | int | 失败数 |
39
+ | `skipped` | int | 跳过数(含 quarantined) |
40
+ | `duration_ms` | int | 测试执行耗时 |
41
+ | `command` | string | 真正执行的命令(便于重跑) |
42
+ | `coverage.lines` | float | 行覆盖率(百分比) |
43
+ | `coverage.branches` | float | 分支覆盖率 |
44
+ | `coverage.functions` | float | 函数覆盖率 |
45
+ | `coveragePath` | string | coverage 源文件路径 |
46
+ | `runner` | string | 识别的测试框架(jest / pytest / junit / go ...) |
47
+
48
+ ### 可选字段(按 kind)
49
+
50
+ **perf-test**:
51
+
52
+ ```yaml
53
+ perf:
54
+ p50_ms: 80
55
+ p95_ms: 150
56
+ p99_ms: 180
57
+ throughput_qps: 5400
58
+ concurrent_users: 100
59
+ baseline_p99_ms: 200 # 来自 design.md 的 NFR
60
+ ```
61
+
62
+ **e2e-test**:
63
+
64
+ ```yaml
65
+ browser: chromium
66
+ viewport: "1920x1080"
67
+ screenshots: reports/screenshots/e2e/
68
+ videoPath: reports/videos/e2e-session.mp4
69
+ ```
70
+
71
+ **joint-test**:
72
+
73
+ ```yaml
74
+ backendUrl: http://localhost:8080
75
+ frontendUrl: http://localhost:3000
76
+ browserTool: agent-browser | chrome-devtools-mcp | playwright | -
77
+ preflightStatus: pass | blocked | -
78
+ database: staging-mysql
79
+ ```
80
+
81
+ **remote-test**:
82
+
83
+ ```yaml
84
+ apiBaseUrl: https://test-api.example.com
85
+ preflightStatus: pass | blocked | -
86
+ ```
87
+
88
+ **self-test**:
89
+
90
+ ```yaml
91
+ acCovered: 12 # tests.md 里总共多少条 AC
92
+ acPassed: 12
93
+ evidence: reports/evidence/
94
+ ```
95
+
96
+ ---
97
+
98
+ ## unit / integration section 模板
99
+
100
+ ```markdown
101
+ ---
102
+ slug: coupon-batch-grant
103
+ kind: unit
104
+ status: pass
105
+ ts: 2026-04-24T14:32:11Z
106
+ command: "mvn -pl coupon-service test"
107
+ runner: junit
108
+ total: 243
109
+ passed: 243
110
+ failed: 0
111
+ skipped: 0
112
+ duration_ms: 142300
113
+ coverage:
114
+ lines: 86.4
115
+ branches: 78.1
116
+ coveragePath: coupon-service/target/site/jacoco/jacoco.xml
117
+ ---
118
+
119
+ # 单元测试报告 — coupon-batch-grant
120
+
121
+ ## 概要
122
+
123
+ 全部通过,line 覆盖 86.4%,branch 78.1%,达标(目标 ≥ 80% / ≥ 70%)。
124
+
125
+ ## 失败详情
126
+
127
+ 无。
128
+
129
+ ## 跳过项
130
+
131
+ 无。
132
+
133
+ ## 覆盖率低点
134
+
135
+ 以下类 branch 覆盖率 < 70%,下一个迭代补:
136
+
137
+ - `CouponGrantService.validateBatch`(65%)— 异常分支未测
138
+
139
+ ## 命令与重跑
140
+
141
+ ```bash
142
+ mvn -pl coupon-service test
143
+ ```
144
+
145
+ ## 附件
146
+
147
+ - 完整 report: `target/site/surefire-report.html`
148
+ - Coverage: `target/site/jacoco/index.html`
149
+ ```
150
+
151
+ ---
152
+
153
+ ## e2e section 模板
154
+
155
+ ```markdown
156
+ ---
157
+ slug: coupon-batch-grant
158
+ kind: e2e
159
+ status: pass
160
+ ts: 2026-04-24T15:10:00Z
161
+ total: 18
162
+ passed: 18
163
+ failed: 0
164
+ duration_ms: 325000
165
+ browser: chromium
166
+ screenshots: reports/screenshots/e2e/
167
+ ---
168
+
169
+ # 端到端测试报告 — coupon-batch-grant
170
+
171
+ ## 测试场景覆盖
172
+
173
+ - 登录 → 进入后台 → 批量发放 1000 张 → 校验 DB 落库 → 验证用户收到
174
+ - 失败场景:上传错误 CSV / 权限不足 / 超过单次上限
175
+
176
+ ## 场景明细
177
+
178
+ | 场景 | 状态 | 截图 |
179
+ | --- | --- | --- |
180
+ | 成功路径(admin, 1000 用户) | pass | ![sc1](screenshots/e2e/sc1.png) |
181
+ | 上传错误格式 CSV | pass | ![sc2](screenshots/e2e/sc2.png) |
182
+ | 无权限用户(operator) | pass | 权限错误页 |
183
+ | 超过单次上限(10001 条) | pass | 400 + 明确 error message |
184
+
185
+ ## 视频回放
186
+
187
+ - `reports/videos/e2e-sc1.mp4`
188
+
189
+ ## 命令
190
+
191
+ ```bash
192
+ npx playwright test --project=chromium --reporter=html
193
+ ```
194
+ ```
195
+
196
+ ---
197
+
198
+ ## joint section 模板
199
+
200
+ `joint` 是前后端联调报告,吸收 arb-workflow-kit 的 test-executor 思路:先做浏览器工具和 URL 预检,再把测试用例转成打开页面、点击、填写、截图、断言的步骤。它不是 L1/L2 的硬性产物,但一旦本 change 涉及前端页面、跳转、轮询、缓存 key、回调参数或跨项目消费者适配,就应该生成。
201
+
202
+ ```markdown
203
+ ---
204
+ slug: coupon-batch-grant
205
+ kind: joint
206
+ status: pass
207
+ failureType: -
208
+ ts: 2026-04-24T15:20:00Z
209
+ total: 6
210
+ passed: 6
211
+ failed: 0
212
+ backendUrl: http://localhost:8080
213
+ frontendUrl: http://localhost:3000
214
+ browserTool: agent-browser
215
+ preflightStatus: pass
216
+ ---
217
+
218
+ # 联调测试报告 — coupon-batch-grant
219
+
220
+ ## 环境信息
221
+
222
+ | 项 | 值 |
223
+ | --- | --- |
224
+ | 后端地址 | http://localhost:8080 |
225
+ | 前端地址 | http://localhost:3000 |
226
+ | 浏览器工具 | agent-browser |
227
+ | 预检结果 | pass |
228
+
229
+ ## 用例执行详情
230
+
231
+ | 用例 | 步骤 | 期望 | 实际 | 状态 |
232
+ | --- | --- | --- | --- | --- |
233
+ | 支付签约成功 | 打开收银台 → 选择渠道 → 确认签约 | 返回支付成功页 | 成功页展示正确 | pass |
234
+
235
+ ## 截图与证据
236
+
237
+ - `reports/screenshots/joint/pay-success.png`
238
+
239
+ ## 失败详情
240
+
241
+ 无。
242
+ ```
243
+
244
+ 预检失败时也要写报告,但 `status: blocked`、`failureType: env_error`,并把缺失的 browser tool、backend-url、frontend-url 写进"预检详情"。
245
+
246
+ ---
247
+
248
+ ## remote section 模板
249
+
250
+ `remote` 是已部署测试环境 API 验收,适合纯后端或服务端变更已经部署到测试环境、需要绕过本地 Mock 直接验证真实接口的场景。它同样来自 arb-workflow-kit 的 remote API 测试实践。
251
+
252
+ ```markdown
253
+ ---
254
+ slug: coupon-batch-grant
255
+ kind: remote
256
+ status: pass
257
+ failureType: -
258
+ ts: 2026-04-24T15:25:00Z
259
+ total: 8
260
+ passed: 8
261
+ failed: 0
262
+ apiBaseUrl: https://test-api.example.com
263
+ preflightStatus: pass
264
+ ---
265
+
266
+ # 远程 API 测试报告 — coupon-batch-grant
267
+
268
+ ## 环境信息
269
+
270
+ | 项 | 值 |
271
+ | --- | --- |
272
+ | API Base URL | https://test-api.example.com |
273
+ | 预检结果 | pass |
274
+
275
+ ## 用例执行详情
276
+
277
+ | 用例 | 请求 | 期望 | 实际 | 状态 |
278
+ | --- | --- | --- | --- | --- |
279
+ | 创建批次 | POST /api/v1/coupons/batch-grant | HTTP 200,grantedCount=100 | HTTP 200,grantedCount=100 | pass |
280
+
281
+ ## 失败详情
282
+
283
+ 无。
284
+ ```
285
+
286
+ 预检失败时写 `status: blocked`、`failureType: env_error`;命令执行失败时写 `status: fail`、`failureType: code_error`。
287
+
288
+ ---
289
+
290
+ ## smoke section 模板
291
+
292
+ 手工写。重点是"新发布的 change 真正被用起来的关键路径"。
293
+
294
+ ```markdown
295
+ ---
296
+ slug: coupon-batch-grant
297
+ kind: smoke
298
+ status: pass
299
+ ts: 2026-04-24T15:30:00Z
300
+ executor: @eng-a
301
+ environment: staging
302
+ ---
303
+
304
+ # 冒烟测试报告 — coupon-batch-grant
305
+
306
+ ## 场景
307
+
308
+ 新 API `/api/v1/coupons/batch-grant` 上线后,运营最常用的路径:
309
+
310
+ 1. 登录管理后台
311
+ 2. 选择活动 "双十一优惠券"
312
+ 3. 上传 100 用户的 CSV
313
+ 4. 点击"批量发放"
314
+ 5. 看到 toast "已发放 100 张"
315
+ 6. 抽样检查 3 个用户,DB 里有记录
316
+
317
+ ## 执行
318
+
319
+ ### Step 1-5
320
+
321
+ ![成功路径](screenshots/smoke/1-5.png)
322
+
323
+ ### Step 6(抽样)
324
+
325
+ ```sql
326
+ select * from coupon_log where user_id in ('u_100', 'u_500', 'u_999');
327
+ ```
328
+
329
+ 三条都在,时间戳 2026-04-24 15:28,status=granted。
330
+
331
+ ## 结论
332
+
333
+ **pass**。staging 上核心路径通。
334
+ ```
335
+
336
+ ---
337
+
338
+ ## self-test section 模板
339
+
340
+ ```markdown
341
+ ---
342
+ slug: coupon-batch-grant
343
+ kind: self-test
344
+ status: pass
345
+ ts: 2026-04-24T15:45:00Z
346
+ acCovered: 12
347
+ acPassed: 12
348
+ evidence: reports/evidence/
349
+ ---
350
+
351
+ # 提测自测报告 — coupon-batch-grant
352
+
353
+ 覆盖 tests.md 里所有 F-ID 和 AC,逐项核验。
354
+
355
+ ## F-01: 批量发放优惠券
356
+
357
+ ### AC1: 提交 1000 条用户 → 返回 grantedCount=1000
358
+
359
+ - **执行方式**: postman 批量提交 `/api/v1/coupons/batch-grant`
360
+ - **输入**: `reports/evidence/F-01-AC1-input.json`(1000 用户)
361
+ - **期望**: response.grantedCount=1000
362
+ - **实际**: 1000 ✅
363
+ - **DB 校验**: `select count(*) from coupon_log where activity_id = 'act_1' and batch_id = 'b_xxx'` → 1000
364
+ - **证据**: `reports/evidence/F-01-AC1-response.json`, `reports/evidence/F-01-AC1-db.png`
365
+
366
+ ### AC2: 含 10 条风控失败用户 → 返回 grantedCount=990, failedCount=10
367
+
368
+ - **执行方式**: postman 批量提交,其中 10 个 user_id 命中风控规则
369
+ - **期望**: grantedCount=990, failedCount=10,failedReasons 明确
370
+ - **实际**: grantedCount=990, failedCount=10, 10 条 reason 都是 `RISK_BLOCKED:user_in_blacklist` ✅
371
+ - **证据**: `reports/evidence/F-01-AC2-response.json`
372
+
373
+ ### AC3: 单批次超过 10000 → 返回 400 BAD_REQUEST
374
+
375
+ - **执行方式**: postman,10001 条
376
+ - **期望**: HTTP 400,error.code=BATCH_TOO_LARGE
377
+ - **实际**: 400, code=BATCH_TOO_LARGE, message=最大支持 10000 条 ✅
378
+ - **证据**: `reports/evidence/F-01-AC3-response.json`
379
+
380
+ ## F-02: 发放结果查询
381
+
382
+ ...
383
+
384
+ ## 结论
385
+
386
+ 所有 12 条 AC 均满足,12/12 pass。
387
+ ```
388
+
389
+ ---
390
+
391
+ ## perf-test.md 模板
392
+
393
+ ```markdown
394
+ ---
395
+ slug: coupon-batch-grant
396
+ kind: perf
397
+ status: pass
398
+ ts: 2026-04-24T16:30:00Z
399
+ command: "k6 run perf/batch-grant.js"
400
+ runner: k6
401
+ duration_ms: 600000
402
+ perf:
403
+ p50_ms: 78
404
+ p95_ms: 150
405
+ p99_ms: 180
406
+ throughput_qps: 5400
407
+ concurrent_users: 100
408
+ baseline_p99_ms: 200
409
+ error_rate: 0.0003
410
+ ---
411
+
412
+ # 性能测试报告 — coupon-batch-grant
413
+
414
+ ## 测试场景
415
+
416
+ - 工具:k6
417
+ - 场景:模拟 100 并发用户,每用户 300s 持续调用 `/api/v1/coupons/batch-grant`(每次 100 条)
418
+ - 环境:staging + 独立压测数据库
419
+ - 数据:10 万用户池 + 5 活动池
420
+
421
+ ## 结果
422
+
423
+ | 指标 | 实际 | NFR 基线 | 状态 |
424
+ | --- | --- | --- | --- |
425
+ | P50 | 78 ms | — | — |
426
+ | P95 | 150 ms | 180 ms | ✅ |
427
+ | P99 | 180 ms | 200 ms | ✅ |
428
+ | 吞吐 | 5,400 qps | 5,000 qps | ✅ |
429
+ | 错误率 | 0.03% | < 0.1% | ✅ |
430
+
431
+ ## 图表
432
+
433
+ - QPS 曲线: `reports/perf/qps.png`
434
+ - 延迟分布: `reports/perf/latency-dist.png`
435
+ - 资源监控: CPU 峰值 65%,内存稳定 1.2GB
436
+
437
+ ## 结论
438
+
439
+ 所有 NFR 满足,pass。
440
+ ```
441
+
442
+ ---
443
+
444
+ ## 9 种测试框架识别规则
445
+
446
+ `devflow test <kind> --cmd <...>` 会尝试解析 stdout,识别下列框架输出并填充 frontmatter:
447
+
448
+ | 框架 | 识别信号 | 解析字段 |
449
+ | --- | --- | --- |
450
+ | Jest | `Tests: 243 passed, 243 total` | total / passed / failed / skipped |
451
+ | Vitest | `Test Files 15 passed (15)` + `Tests 243 passed (243)` | 同上 |
452
+ | Mocha | ` 243 passing (142s)` | 同上 |
453
+ | Tap | `# tests 243` `# pass 243` | 同上 |
454
+ | node:test | `ok 243 ...` + `# tests 243` | 同上 |
455
+ | Go | `--- PASS: TestXXX (0.00s)` + `PASS\nok\tpkg` | 逐测试累加 |
456
+ | Pytest | `============== 243 passed in 142.30s ==============` | 同上 |
457
+ | unittest | `Ran 243 tests in 142.300s\n\nOK` | 同上 |
458
+ | JUnit | XML 报告(surefire-reports / build/test-results) | 读 XML `<testsuite>` |
459
+
460
+ 识别失败时填 `runner: unknown`,字段留 null,要求用户手动补(或用 `devflow test <kind> --parse <format>` 指定)。
461
+
462
+ ---
463
+
464
+ ## 5 种 coverage 格式识别
465
+
466
+ | 格式 | 文件名 |
467
+ | --- | --- |
468
+ | JSON summary | `coverage/coverage-summary.json` |
469
+ | LCOV | `coverage/lcov.info` |
470
+ | Cobertura XML | `coverage/cobertura.xml` |
471
+ | Go profile | `coverage.out`(`go tool cover -func`) |
472
+ | JaCoCo XML | `target/site/jacoco/jacoco.xml` |
473
+
474
+ 自动扫描常见路径,或用 `--coverage-path <path>` 显式指定。解析后填:
475
+
476
+ ```yaml
477
+ coverage:
478
+ lines: 86.4
479
+ branches: 78.1
480
+ functions: 90.2
481
+ coveragePath: <path>
482
+ ```
483
+
484
+ ---
485
+
486
+ ## 自定义扩展
487
+
488
+ - **加一种 frontmatter 字段**:直接写,finalize 不会因为额外字段报错
489
+ - **接入新测试框架**:PR 加到 `src/core/report/parsers/<framework>.js`(实现 `parse(stdout) => { total, passed, failed, skipped, duration_ms }`)
490
+ - **接入新 coverage 格式**:类似,加到 `src/core/report/coverage/<format>.js`
491
+
492
+ ---
493
+
494
+ ## 报告命名约定
495
+
496
+ - 默认唯一:`test-report.md` 里的 `#<kind>` section(不要再生成一堆 `unit-test-v2.md`)
497
+ - 兼容旧工具:显式加 `--split-report` 时才额外生成 `<kind>-test.md`
498
+ - 一次性多份(如 perf 多场景):加 `perf-test-<scenario>.md`,finalize 按 glob 读
499
+ - 截图:`reports/screenshots/<kind>/...`
500
+ - 附件:`reports/evidence/<kind>/...`
501
+ - 日志:`reports/logs/<kind>.log`
502
+
503
+ ---
504
+
505
+ ## 常见坑
506
+
507
+ - **skipped 不报告**:frontmatter 必须如实写 skipped 数;review / finalize 会比对 tests.md 总数
508
+ - **partial 当 pass 写**:禁止;partial 要附"剩余 N 个不通过的处置 checklist"
509
+ - **reports/ 外部链接路径错误**:用**相对于 `devflow/changes/<slug>/` 的相对路径**,不要用绝对路径或 http(部分环境不联网)
510
+ - **coverage 只报 line 不报 branch**:L2/L3 推荐两者都报,不然回归时不知道哪些逻辑分支没测