ai-dev-requirements 0.1.9 → 0.1.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.
@@ -1,162 +1,334 @@
1
- # 工作流定义
1
+ # Agent Harness Workflow
2
2
 
3
- > 10 步端到端开发工作流
3
+ > Controlled lifecycle for AI coding agents: intake, context load, normalization, harness plan, coverage validation, gated execution, verification, review, and handoff.
4
4
 
5
5
  ---
6
6
 
7
- ## 完整流程
8
-
7
+ ## End-to-End Flow
8
+
9
+ ```text
10
+ 1. Intake
11
+ |
12
+ v
13
+ 2. Context Load -> requirements.md
14
+ |
15
+ v
16
+ 3. Normalize -> user-stories.md
17
+ |
18
+ v
19
+ 4. Harness Plan -> implementation-plan.md
20
+ |
21
+ v
22
+ 5. Coverage Validation -> validation-report.md
23
+ |
24
+ v
25
+ +--------------------------+
26
+ | 6. Execute Behind Gates |
27
+ | | |
28
+ | v |
29
+ | 7. Verify |
30
+ | | |
31
+ | v |
32
+ | 8. Review |
33
+ +--------------------------+
34
+ |
35
+ v
36
+ 9. Handoff -> handoff.md
9
37
  ```
10
- ① 需求输入
11
-
12
- ② 需求获取 ──→ requirements.md
13
-
14
- ③ 技术设计 ──→ design.md + tasks.md (前后端拆分)
15
-
16
- 技能匹配 ──→ 五级查找机制
17
-
18
- 最佳实践 ──→ 应用匹配的 skills,更新 design
19
-
20
- 需求符合性校验 ──→ 追踪矩阵 + 校验报告
21
-
22
- ┌────────────────────────────┐
23
- │ ⑦ 代码实现 │
24
- │ ↓ │
25
- │ ⑧ 交互验证 (前端项目) │←──┐
26
- │ ↓ │ │ 循环
27
- │ ⑨ 代码审查 │───┘
28
- └────────────────────────────┘
29
-
30
- ⑩ 质量检查 (lint → type → build)
31
-
32
- ✅ 完成
38
+
39
+ ## Artifact Contract
40
+
41
+ ```text
42
+ docs/plans/{feature-name}/
43
+ ├── requirements.md
44
+ ├── user-stories.md
45
+ ├── implementation-plan.md
46
+ ├── validation-report.md
47
+ ├── execution-log.md
48
+ └── handoff.md
33
49
  ```
34
50
 
35
- ## 阶段详情
51
+ Optional UI artifacts:
36
52
 
37
- | 阶段 | 名称 | 触发条件 | 使用工具 |
38
- |:---:|------|---------|---------|
39
- | ① | 需求输入 | 必须 | — |
40
- | ② | 需求获取 | 必须 | `requirements-mcp` |
41
- | ③ | 技术设计 | 必须 | Plan 工具 |
42
- | ④ | 技能匹配 | 必须 | 五级查找机制 |
43
- | ⑤ | 最佳实践 | 必须 | 动态加载匹配的 skills |
44
- | ⑥ | 需求符合性校验 | 必须 | 追踪矩阵 + 校验报告,详见 [requirement-validation.md](./requirement-validation.md) |
45
- | ⑦ | 代码实现 | 必须 | Subagent 并行开发 |
46
- | ⑧ | 交互验证 | **仅前端项目** | Playwright MCP |
47
- | ⑨ | 代码审查 | 必须 | Code review |
48
- | ⑩ | 质量检查 | 必须 | lint + type + build |
53
+ ```text
54
+ docs/plans/{feature-name}/ui-references/
55
+ ├── figma-notes.md
56
+ └── screenshots/
57
+ ```
49
58
 
50
- ## 阶段说明
59
+ ## Phase Table
51
60
 
52
- ### 需求输入
61
+ | Phase | Name | Required | Harness Output | Pause |
62
+ |:---:|------|:---:|------|------|
63
+ | 1 | Intake | Yes | Source inventory and `docs/plans/{feature-name}/` path | Only if the request has no actionable source or goal |
64
+ | 2 | Context Load | Yes | `requirements.md` | Conditional when required context is missing |
65
+ | 3 | Normalize | Yes | `user-stories.md` | Yes, developer confirms stories and UI needs |
66
+ | 4 | Harness Plan | Yes | `implementation-plan.md` | Conditional when scope or risk changes |
67
+ | 5 | Coverage Validation | Yes | `validation-report.md` | Yes when coverage is incomplete or risky |
68
+ | 6 | Execute Behind Gates | Yes | Changed artifacts and `execution-log.md` | On blocker, conflict, or unclear instruction |
69
+ | 7 | Verify | Yes | Verification evidence | On failed or unavailable gate |
70
+ | 8 | Review | Yes | Review notes and risk list | On blocking finding |
71
+ | 9 | Handoff | Yes | `handoff.md` or final response | No |
53
72
 
54
- 用户提供需求单号或需求描述,可以是:
55
- - 需求管理平台ID(如 ONES 工单号、Jira Issue Key、GitHub Issue 编号)
56
- - 自然语言描述
57
- - 需求文档链接
73
+ ## Default Execution Policy
58
74
 
59
- ### 需求获取
75
+ When the dev-workflow harness is active, planning is the default. The developer does not need to repeat "generate user stories and an implementation plan before coding."
60
76
 
61
- 通过 `ai-dev-requirements` 自动获取需求详情,输出 `requirements.md`。
77
+ Default behavior:
62
78
 
63
- ### 技术设计
79
+ - Normalize raw context into user stories.
80
+ - Pause for developer confirmation after user stories.
81
+ - Generate an implementation plan.
82
+ - Pause for developer confirmation before implementation.
83
+ - Start coding only after confirmation, or when the developer explicitly bypasses the planning gate.
64
84
 
65
- 基于需求,生成技术设计方案:
85
+ Explicit bypass examples:
66
86
 
87
+ ```text
88
+ Use dev-workflow harness, but skip the planning gate and directly implement this small docs change.
67
89
  ```
68
- docs/plans/{需求单号}/
69
- ├── requirements.md # 原始需求
70
- ├── analysis.md # 需求分析(前后端拆分结果)
71
- ├── frontend/
72
- │ ├── design.md # 前端设计方案
73
- │ └── tasks.md # 前端任务列表
74
- ├── backend/
75
- │ ├── design.md # 后端设计方案
76
- │ └── tasks.md # 后端任务列表
77
- └── shared/
78
- └── api-contract.md # 接口契约
90
+
91
+ ```text
92
+ 直接开写,不需要等我确认计划。
79
93
  ```
80
94
 
81
- ### 技能匹配 — 五级查找
95
+ ## Blueprint Model
82
96
 
83
- ```
84
- Level 1: 项目内 skills/ → 项目专属规范(最高优先级)
85
- Level 2: 全局 skills → superpowers 等通用开发规范
86
- Level 3: 开放生态 (skills.sh) → 社区 skills
87
- Level 4: Context7 MCP → 框架/库官方文档
88
- Level 5: WebSearch → 网络最佳实践(兜底)
89
- ```
97
+ The harness is a hybrid Blueprint: deterministic nodes handle repeatable control flow, while agent-loop nodes handle reasoning and repair.
98
+
99
+ | Node Type | Examples | Rule |
100
+ |-----------|----------|------|
101
+ | Deterministic | install, lint, typecheck, build, tests, diff checks | Always run when declared; do not leave to agent memory |
102
+ | Agent Loop | understand, plan, implement, repair, review | Agent may reason and iterate within the declared gate |
103
+
104
+ Deterministic nodes save context and reduce preventable errors. Agent-loop nodes are useful only inside explicit inputs, outputs, isolation keys, and verification gates.
105
+
106
+ ## Phase Details
107
+
108
+ ### 1. Intake
109
+
110
+ Accepted inputs:
111
+
112
+ - Requirement management ID, such as ONES task ID, Jira issue key, or GitHub issue number.
113
+ - Issue, document, Figma, or screenshot link.
114
+ - Natural language requirement from the developer.
115
+
116
+ The agent identifies the requested outcome, source type, expected deliverable, and a stable `{feature-name}` for artifact paths.
117
+
118
+ ### 2. Context Load
119
+
120
+ The harness may load context through:
121
+
122
+ - Bundled Requirements MCP Server for ONES.
123
+ - External GitHub or Jira MCP servers for issue context.
124
+ - Figma MCP server for design context.
125
+ - Local repository files.
126
+ - User-provided text.
90
127
 
91
- ### 最佳实践
128
+ The output is raw context in `requirements.md`. The agent must keep raw context distinct from interpretation so later coverage validation can trace back to the original input.
92
129
 
93
- 将匹配到的 skills 应用到设计方案中,更新 `design.md`。
130
+ #### Context Quality
94
131
 
95
- ### 需求符合性校验
132
+ Record source quality before normalization:
96
133
 
97
- [requirement-validation.md](./requirement-validation.md) 规范执行,核心步骤:
134
+ | Status | Meaning | Allowed Next Step |
135
+ |--------|---------|-------------------|
136
+ | `ok` | Source content was loaded and is usable | Normalize |
137
+ | `user_supplied` | Developer pasted or described the content | Normalize with source note |
138
+ | `blocked_by_verification` | Source returned a captcha or verification page | Ask for paste, screenshot, export, or summary |
139
+ | `login_required` | Source requires auth the agent does not have | Ask for accessible context |
140
+ | `unavailable` | Source cannot be fetched | Ask for fallback or stop |
98
141
 
99
- 1. **构建追踪矩阵** 逐条提取需求点,建立 需求 用户故事 设计 任务 的映射
100
- 2. **逐项校验** — 对每个需求点检查:故事覆盖、验收标准完整、设计落地、任务分解、边界覆盖
101
- 3. **输出校验报告** — 生成 `validation-report.md`,包含覆盖统计、未覆盖项、风险项
102
- 4. **暂停确认** — 将报告呈现给开发者,等待确认后再进入代码实现
142
+ If source status is not `ok` or `user_supplied`, do not infer content from the URL, title, or surrounding metadata. Ask for fallback context and record the fallback used.
103
143
 
104
- 判定规则:
105
- - ✅ 通过:所有需求点已覆盖,无高风险项 → 进入 ⑦
106
- - ⚠️ 有条件通过:覆盖率 ≥ 90%,未覆盖项为低优先级 → 与开发者确认后进入 ⑦
107
- - ❌ 不通过:核心需求未覆盖或高风险未解决 → 回退 ③ 补充设计
144
+ ### 3. Normalize
108
145
 
109
- ### 代码实现
146
+ The agent converts raw context into user stories:
110
147
 
111
- 按任务类型调度并行/串行执行,详见 [task-types.md](./task-types.md)。
148
+ ```markdown
149
+ ### US-1: <story title>
150
+ **As a** <role>,
151
+ **I want** <goal>,
152
+ **So that** <value>.
112
153
 
113
- **前后端并行策略:**
154
+ #### Acceptance Criteria
155
+ - [ ] Given <precondition>, When <action>, Then <expected result>
114
156
 
157
+ #### Dependencies
158
+ - UI: Figma link, screenshot path, text description, or "No UI dependency"
159
+ - Backend: API or service dependency
160
+ - Data: schema, fixture, migration, or "No data dependency"
161
+ - External: third-party service, MCP source, or "No external dependency"
115
162
  ```
116
- ┌─────────────┐
117
- 接口契约确定
118
- └──────┬──────┘
119
-
120
- ┌────────────┴────────────┐
121
- ↓ ↓
122
- ┌─────────┐ ┌─────────┐
123
- 前端开发 │ 并行执行 │ 后端开发 │
124
- (Mock) │ │ (API) │
125
- └────┬────┘ └────┬────┘
126
- └───────────┬───────────┘
127
-
128
- ┌─────────────┐
129
- │ 联调测试 │
130
- └─────────────┘
163
+
164
+ The harness pauses after normalization so the developer can confirm scope and UI references.
165
+
166
+ ### 4. Harness Plan
167
+
168
+ The plan turns user stories into a task graph. Every task records:
169
+
170
+ - Task type.
171
+ - Agent role.
172
+ - Scheduler mode.
173
+ - Isolation key.
174
+ - Dependencies.
175
+ - Inputs.
176
+ - Outputs.
177
+ - Verification gate.
178
+ - Review level.
179
+
180
+ Use `task-types.md` for valid task types and scheduling rules. Use the templates directory for task declarations.
181
+
182
+ The harness pauses after the plan. This pause is mandatory by default because it is the final point where the developer can adjust scope, task boundaries, verification gates, and risk before code changes begin.
183
+
184
+ ### 5. Coverage Validation
185
+
186
+ Build a traceability matrix:
187
+
188
+ ```markdown
189
+ | Requirement | User Story | Harness Task | Verification Gate | Status |
190
+ |-------------|------------|--------------|-------------------|--------|
191
+ | R1 | US-1 | HT-1 | `pnpm test -- auth` | Covered |
131
192
  ```
132
193
 
133
- ### 交互验证
194
+ Check each requirement for:
195
+
196
+ - Story coverage.
197
+ - Acceptance criteria completeness.
198
+ - Implementation task coverage.
199
+ - Edge case and error path coverage.
200
+ - Verification gate coverage.
201
+
202
+ Coverage validation should include three sensor classes:
203
+
204
+ | Sensor Class | Checks | Examples |
205
+ |--------------|--------|----------|
206
+ | Maintainability | internal quality | lint, typecheck, duplication, complexity, docs consistency |
207
+ | Architecture | structural boundaries | dependency direction, module ownership, public contracts |
208
+ | Behavior | user-visible correctness | unit tests, integration tests, UI automation, acceptance checks |
209
+
210
+ Coverage outcomes:
211
+
212
+ | Result | Condition | Next Action |
213
+ |--------|-----------|-------------|
214
+ | Pass | All requirements covered and no high-risk gaps | Execute |
215
+ | Conditional | Low-risk gap is documented and accepted | Execute after developer confirmation |
216
+ | Fail | Core requirement missing or high-risk ambiguity remains | Revise stories or plan |
217
+
218
+ ### 6. Execute Behind Gates
219
+
220
+ Execution follows the scheduler:
221
+
222
+ - `parallel`: independent tasks may run concurrently up to `parallel_limit`.
223
+ - `isolated`: tasks sharing an isolation key run serially; different keys may run in parallel.
224
+ - `serial`: global lock; one task at a time.
134
225
 
135
- 仅前端项目,使用 Playwright MCP 进行自动化交互验证。
226
+ Execution rules:
136
227
 
137
- ### 代码审查
228
+ - Prefer subagent-driven execution when available.
229
+ - Use inline execution with checkpoints when subagents are unavailable or not requested.
230
+ - Do not revert unrelated user changes.
231
+ - Record meaningful notes, blockers, and verification results in `execution-log.md`.
138
232
 
139
- 根据任务类型的 review_level 进行代码审查:
140
- - `light` — 文档/调研类,快速检查
141
- - `standard` — 修复/测试类,标准检查
142
- - `strict` — 新功能/重构,严格检查
233
+ ### 7. Verify
143
234
 
144
- ### 质量检查
235
+ Verification comes from the plan. Common gates:
145
236
 
146
237
  ```bash
147
- pnpm lint # ESLint 检查
148
- pnpm type # TypeScript 类型检查
149
- pnpm build # 构建验证
238
+ pnpm lint
239
+ pnpm typecheck
240
+ pnpm build
241
+ pnpm test:run
150
242
  ```
151
243
 
152
- ## 项目类型判断
244
+ For documentation-only changes, verification may be targeted content review plus repository lint. For frontend behavior, use browser automation where available.
153
245
 
154
- ```yaml
155
- project_type: frontend | backend | fullstack | library
246
+ The agent must read command output and report actual evidence. A gate that cannot run must be listed as a skipped check with the reason.
247
+
248
+ #### Backpressure
249
+
250
+ Good backpressure is fast, quiet on success, precise on failure.
251
+
252
+ - Run targeted gates before full gates when the plan identifies an owner area.
253
+ - On success, record only the gate name and pass status unless full output is requested.
254
+ - On failure, expose the command, key error, likely owner task, and repair instruction.
255
+ - Default retry limit is 2 repair attempts before human escalation.
256
+ - Avoid dumping large passing logs into the active context; store longer evidence in `execution-log.md` when needed.
257
+
258
+ ### 8. Review
259
+
260
+ Review checks:
261
+
262
+ - Requirement coverage.
263
+ - User-visible behavior.
264
+ - Changed file scope.
265
+ - Error handling and edge cases.
266
+ - Test or verification adequacy.
267
+ - Residual risk.
268
+
269
+ Review level:
270
+
271
+ - `light`: documentation, research, and low-risk artifacts.
272
+ - `standard`: fixes, tests, and bounded behavior changes.
273
+ - `strict`: new features, refactors, shared contracts, and high-impact changes.
274
+
275
+ ### 9. Handoff
276
+
277
+ The handoff contains:
278
+
279
+ - Summary of changed artifacts.
280
+ - Verification commands and results.
281
+ - Requirement coverage status.
282
+ - Residual risks or skipped checks.
283
+ - Concrete follow-up actions, if any.
284
+
285
+ Use `handoff.md` when the project needs a persistent artifact. Otherwise include the same facts in the final agent response.
286
+
287
+ ## MCP Boundary
288
+
289
+ MCP is a context input layer. It may fetch requirements, issue details, related work, test cases, and design context. The harness uses that context to create artifacts and make decisions.
290
+
291
+ MCP is not the implementation target unless the requested feature explicitly asks for MCP server changes. When MCP server changes are out of scope, do not edit adapters, auth, config loading, tool definitions, package exports, or runtime behavior.
292
+
293
+ ## Recovery Rules
156
294
 
157
- # 自动判断逻辑:
158
- # - 存在 src/views/ 或 src/components/ → frontend
159
- # - 存在 package.json + vue/react 依赖 frontend
160
- # - 存在 src/api/ 或 src/services/ 无前端框架 → backend
161
- # - 两者都有 → fullstack
295
+ ### Missing Context
296
+
297
+ Pause and ask for the source or permission to proceed from the current user-provided description. Record the missing context in `requirements.md` or `execution-log.md`.
298
+
299
+ ### Protected Source
300
+
301
+ If a URL, MCP source, or document returns verification, login, or access-control content, mark `source_status` as `blocked_by_verification`, `login_required`, or `unavailable`. Request pasted text, screenshot, exported Markdown, exported PDF, or a concise user summary before normalization.
302
+
303
+ ### Missing UI Reference
304
+
305
+ If visual fidelity matters, pause before implementation. If the developer confirms no visual reference is available, record the chosen text-based design assumptions.
306
+
307
+ ### Coverage Validation Failure
308
+
309
+ Do not execute. Revise user stories, plan tasks, or verification gates until every core requirement is mapped.
310
+
311
+ ### Verification Failure
312
+
313
+ Capture the failing command and relevant output. Fix the task that owns the failure, then rerun the same gate before moving forward. Stop after the declared retry limit and ask for human direction.
314
+
315
+ ### Parallel Conflict
316
+
317
+ Stop the affected task group. Serialize work within the conflicting isolation key and document the conflict in `execution-log.md`.
318
+
319
+ ## Project Type Detection
320
+
321
+ Use project files to choose verification gates and task boundaries:
322
+
323
+ ```yaml
324
+ project_type: frontend | backend | fullstack | library | documentation
325
+
326
+ detection:
327
+ frontend: src/components, src/views, React, Vue, Svelte, Next.js, or browser tests
328
+ backend: src/api, src/services, server runtime, database access, or API tests
329
+ fullstack: both frontend and backend indicators
330
+ library: package exports, build artifacts, public types, or reusable modules
331
+ documentation: markdown-only changes with no runtime behavior change
162
332
  ```
333
+
334
+ For this repository, the default project type is `library` with a bundled `documentation` skill artifact.