qfai 1.2.0 → 1.2.2

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 (30) hide show
  1. package/README.md +45 -26
  2. package/assets/init/.qfai/assistant/prompts/{qfai-scenario-test.md → qfai-atdd.md} +12 -11
  3. package/assets/init/.qfai/assistant/prompts/qfai-spec.md +1 -1
  4. package/assets/init/.qfai/assistant/prompts/{qfai-implement.md → qfai-tdd-green.md} +11 -11
  5. package/assets/init/.qfai/assistant/prompts/{qfai-unit-test.md → qfai-tdd-red.md} +8 -8
  6. package/assets/init/.qfai/assistant/prompts/qfai-tdd-refactor.md +344 -0
  7. package/assets/init/.qfai/specs/README.md +3 -2
  8. package/assets/init/root/.claude/commands/{qfai-implement.md → qfai-atdd.md} +2 -2
  9. package/assets/init/root/.claude/commands/{qfai-unit-test.md → qfai-tdd-green.md} +2 -2
  10. package/assets/init/root/.claude/commands/{qfai-scenario-test.md → qfai-tdd-red.md} +2 -2
  11. package/assets/init/root/.claude/commands/qfai-tdd-refactor.md +14 -0
  12. package/assets/init/root/.codex/skills/{qfai-unit-test → qfai-atdd}/SKILL.md +4 -4
  13. package/assets/init/root/.codex/skills/{qfai-implement → qfai-tdd-green}/SKILL.md +4 -4
  14. package/assets/init/root/.codex/skills/{qfai-scenario-test → qfai-tdd-red}/SKILL.md +4 -4
  15. package/assets/init/root/.codex/skills/qfai-tdd-refactor/SKILL.md +18 -0
  16. package/assets/init/root/.github/prompts/{qfai-implement.prompt.md → qfai-atdd.prompt.md} +2 -2
  17. package/assets/init/root/.github/prompts/{qfai-unit-test.prompt.md → qfai-tdd-green.prompt.md} +2 -2
  18. package/assets/init/root/.github/prompts/{qfai-scenario-test.prompt.md → qfai-tdd-red.prompt.md} +2 -2
  19. package/assets/init/root/.github/prompts/qfai-tdd-refactor.prompt.md +17 -0
  20. package/dist/cli/index.cjs +784 -260
  21. package/dist/cli/index.cjs.map +1 -1
  22. package/dist/cli/index.mjs +776 -252
  23. package/dist/cli/index.mjs.map +1 -1
  24. package/dist/index.cjs +759 -233
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +22 -1
  27. package/dist/index.d.ts +22 -1
  28. package/dist/index.mjs +756 -232
  29. package/dist/index.mjs.map +1 -1
  30. package/package.json +1 -1
package/README.md CHANGED
@@ -62,9 +62,10 @@ QFAI includes a small set of custom prompts (stored under `.qfai/assistant/promp
62
62
  - **qfai-require**: Produce `require.md` in the requirements directory from your idea or discussion output.
63
63
  - **qfai-spec**: Produce `.qfai/specs/*` and `.qfai/contracts/*` from the requirements, including traceability scaffolding.
64
64
  - Includes a preflight step that bootstraps missing `qfai.config.yaml` and `assistant/steering/*` when run directly after init.
65
- - **qfai-scenario-test**: Implement acceptance tests (ATDD) driven by specs/scenarios.
66
- - **qfai-unit-test**: Implement unit tests (TDD) driven by specs/scenarios.
67
- - **qfai-implement**: Implement the feature; iterate test→fix until all quality gates are green.
65
+ - **qfai-atdd**: Implement acceptance tests (ATDD) driven by specs/scenarios.
66
+ - **qfai-tdd-red**: Implement fast tests first (unit/component/integration).
67
+ - **qfai-tdd-green**: Implement production code to make the tests pass.
68
+ - **qfai-tdd-refactor**: Refactor safely after tests are green.
68
69
  - **qfai-verify**: Run/interpret the local quality gates and produce a PR-ready summary.
69
70
 
70
71
  ### Workflow sequence (example)
@@ -103,23 +104,28 @@ AG->>Q: Read .qfai/assistant/prompts/qfai-spec.md
103
104
  AG->>R: Create specs + contracts + scenario.feature
104
105
  AG-->>U: SDD artifacts ready
105
106
 
106
- U->>AG: Run /qfai-scenario-test
107
- AG->>Q: Read .qfai/assistant/prompts/qfai-scenario-test.md
107
+ U->>AG: Run /qfai-atdd
108
+ AG->>Q: Read .qfai/assistant/prompts/qfai-atdd.md
108
109
  AG->>R: Implement acceptance tests
109
- AG-->>U: Scenario tests ready
110
+ AG-->>U: Acceptance tests ready
110
111
 
111
- U->>AG: Run /qfai-unit-test
112
- AG->>Q: Read .qfai/assistant/prompts/qfai-unit-test.md
113
- AG->>R: Implement unit tests
114
- AG-->>U: Unit tests ready
112
+ U->>AG: Run /qfai-tdd-red
113
+ AG->>Q: Read .qfai/assistant/prompts/qfai-tdd-red.md
114
+ AG->>R: Implement fast tests (RED)
115
+ AG-->>U: RED tests ready
115
116
 
116
- U->>AG: Run /qfai-implement
117
- AG->>Q: Read .qfai/assistant/prompts/qfai-implement.md
117
+ U->>AG: Run /qfai-tdd-green
118
+ AG->>Q: Read .qfai/assistant/prompts/qfai-tdd-green.md
118
119
  loop Implement and fix until green
119
120
  AG->>R: Implement code changes
120
121
  AG->>R: Run project tests locally
121
122
  end
122
- AG-->>U: Working implementation (quality gates passing)
123
+ AG-->>U: Working implementation (tests green)
124
+
125
+ U->>AG: Run /qfai-tdd-refactor
126
+ AG->>Q: Read .qfai/assistant/prompts/qfai-tdd-refactor.md
127
+ AG->>R: Refactor safely
128
+ AG-->>U: Refactor complete
123
129
 
124
130
  U->>R: Run npx qfai validate
125
131
  U->>R: Run npx qfai report
@@ -221,6 +227,14 @@ QFAI uses a small, opinionated set of artifacts to reduce ambiguity and prevent
221
227
 
222
228
  Traceability is validated across these artifacts, so code changes remain grounded in the specs and the tests prove compliance.
223
229
 
230
+ ### Test strategy tags (optional)
231
+
232
+ You can annotate scenarios with lightweight test strategy metadata to keep the test pyramid/trophy healthy.
233
+ These tags are opt-in and only produce warnings, so you can roll them out gradually without breaking existing specs.
234
+
235
+ - Layer tags: `@layer-unit`, `@layer-component`, `@layer-integration`, `@layer-api`, `@layer-e2e`
236
+ - Size tags: `@size-s`, `@size-m`, `@size-l`
237
+
224
238
  ## Continuous integration (GitHub Actions)
225
239
 
226
240
  (GitHub Actions)
@@ -260,11 +274,12 @@ Typical customizations.
260
274
  │ └── commands
261
275
  │ ├── qfai-configure.md
262
276
  │ ├── qfai-discuss.md
263
- │ ├── qfai-implement.md
277
+ │ ├── qfai-atdd.md
264
278
  │ ├── qfai-require.md
265
- │ ├── qfai-scenario-test.md
266
279
  │ ├── qfai-spec.md
267
- │ ├── qfai-unit-test.md
280
+ │ ├── qfai-tdd-green.md
281
+ │ ├── qfai-tdd-red.md
282
+ │ ├── qfai-tdd-refactor.md
268
283
  │ └── qfai-verify.md
269
284
  ├── .codex
270
285
  │ └── skills
@@ -272,15 +287,17 @@ Typical customizations.
272
287
  │ │ └── SKILL.md
273
288
  │ ├── qfai-discuss
274
289
  │ │ └── SKILL.md
275
- │ ├── qfai-implement
290
+ │ ├── qfai-atdd
276
291
  │ │ └── SKILL.md
277
292
  │ ├── qfai-require
278
293
  │ │ └── SKILL.md
279
- │ ├── qfai-scenario-test
280
- │ │ └── SKILL.md
281
294
  │ ├── qfai-spec
282
295
  │ │ └── SKILL.md
283
- │ ├── qfai-unit-test
296
+ │ ├── qfai-tdd-green
297
+ │ │ └── SKILL.md
298
+ │ ├── qfai-tdd-red
299
+ │ │ └── SKILL.md
300
+ │ ├── qfai-tdd-refactor
284
301
  │ │ └── SKILL.md
285
302
  │ └── qfai-verify
286
303
  │ └── SKILL.md
@@ -288,11 +305,12 @@ Typical customizations.
288
305
  │ ├── prompts
289
306
  │ │ ├── qfai-configure.prompt.md
290
307
  │ │ ├── qfai-discuss.prompt.md
291
- │ │ ├── qfai-implement.prompt.md
308
+ │ │ ├── qfai-atdd.prompt.md
292
309
  │ │ ├── qfai-require.prompt.md
293
- │ │ ├── qfai-scenario-test.prompt.md
294
310
  │ │ ├── qfai-spec.prompt.md
295
- │ │ ├── qfai-unit-test.prompt.md
311
+ │ │ ├── qfai-tdd-green.prompt.md
312
+ │ │ ├── qfai-tdd-red.prompt.md
313
+ │ │ ├── qfai-tdd-refactor.prompt.md
296
314
  │ │ └── qfai-verify.prompt.md
297
315
  │ ├── workflows
298
316
  │ │ └── qfai.yml
@@ -325,11 +343,12 @@ Typical customizations.
325
343
  │ │ │ ├── README.md
326
344
  │ │ │ ├── qfai-configure.md
327
345
  │ │ │ ├── qfai-discuss.md
328
- │ │ │ ├── qfai-implement.md
346
+ │ │ │ ├── qfai-atdd.md
329
347
  │ │ │ ├── qfai-require.md
330
- │ │ │ ├── qfai-scenario-test.md
331
348
  │ │ │ ├── qfai-spec.md
332
- │ │ │ ├── qfai-unit-test.md
349
+ │ │ │ ├── qfai-tdd-green.md
350
+ │ │ │ ├── qfai-tdd-red.md
351
+ │ │ │ ├── qfai-tdd-refactor.md
333
352
  │ │ │ └── qfai-verify.md
334
353
  │ │ ├── prompts.local
335
354
  │ │ │ └── README.md
@@ -6,25 +6,25 @@ QFAI Prompt Body (SSOT)
6
6
 
7
7
  ---
8
8
 
9
- id: qfai-scenario-test
10
- title: QFAI Scenario Test (ATDD executable)
11
- description: "Implement executable scenario tests from spec pack and scenario.feature; includes review and quality checks."
9
+ id: qfai-atdd
10
+ title: QFAI ATDD (Executable acceptance tests)
11
+ description: "Implement automated acceptance tests (E2E/API/Integration) aligned with scenario.feature and specs."
12
12
  argument-hint: "<spec-id> [--auto]"
13
13
  allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
- roles: [TestEngineer, DevOpsCIEngineer, QAEngineer, CodeReviewer, Planner]
14
+ roles: [TestEngineer, QAEngineer, BackendEngineer, FrontendEngineer, CodeReviewer, DevOpsCIEngineer]
15
15
  mode: execution-focused
16
16
 
17
17
  ---
18
18
 
19
- # /qfai-scenario-test — Implement Executable Scenario Tests (ATDD)
19
+ # /qfai-atdd — Implement Automated Acceptance Tests (ATDD)
20
20
 
21
21
  ## Purpose
22
22
 
23
- Turn `.qfai/specs/spec-XXXX/scenario.feature` into **runnable scenario tests** in this repository (terminal + CI).
23
+ Turn `.qfai/specs/spec-XXXX/scenario.feature` into **runnable acceptance tests** (E2E/API/Integration) in this repository (terminal + CI).
24
24
 
25
25
  ## Success Criteria (Definition of Done)
26
26
 
27
- - Scenario tests exist and are runnable via documented commands.
27
+ - Acceptance tests exist and are runnable via documented commands.
28
28
  - Tests are stable (no flakiness) and diagnostic (failures explain why).
29
29
  - Existing acceptance automation (if any) is reused; no new framework is added without approval.
30
30
  - Quality checks (lint/typecheck/tests) pass in the repo’s standard way.
@@ -193,7 +193,7 @@ Read:
193
193
 
194
194
  **Rationale:** QFAI validate rules require unique SC tags per file, and large scenario counts should be split to keep traceability clear.
195
195
 
196
- ## Step 2 — Choose (or detect) scenario test harness
196
+ ## Step 2 — Choose (or detect) acceptance test harness
197
197
 
198
198
  Prefer existing project tooling. Determine:
199
199
 
@@ -218,13 +218,14 @@ When approval is granted:
218
218
 
219
219
  - Add minimal dependencies and configuration.
220
220
  - Implement steps mapped to `scenario.feature`.
221
- - Integrate a single command to run scenario tests.
221
+ - Integrate a single command to run acceptance tests.
222
222
 
223
- ## Step 3 — Implement scenario tests (Test Engineer)
223
+ ## Step 3 — Implement acceptance tests (Test Engineer)
224
224
 
225
225
  Rules:
226
226
 
227
227
  - Scenarios must map to executable steps.
228
+ - Prioritize Scenario tags that carry @layer-api / @layer-e2e / @layer-integration.
228
229
  - Keep step definitions reusable but not overly generic.
229
230
  - Ensure each scenario asserts observable behavior.
230
231
 
@@ -316,7 +317,7 @@ If you cannot run these commands (environment limitation):
316
317
 
317
318
  ## Output
318
319
 
319
- - Scenario test implementation files (with SC annotations)
320
+ - Acceptance test implementation files (with SC annotations)
320
321
  - "Runbook" snippet (copy‑paste command)
321
322
  - Short verification evidence summary
322
323
  - Gate results: all PASS
@@ -730,4 +730,4 @@ If you cannot run these commands (environment limitation):
730
730
  - `.qfai/specs/spec-*/traceability-matrix.md`
731
731
  - (If needed) updated `.qfai/contracts/**`
732
732
  - Validation evidence: command outputs showing PASS
733
- - Next recommended command: /qfai-scenario-test and/or /qfai-unit-test
733
+ - Next recommended command: /qfai-atdd and/or /qfai-tdd-red
@@ -6,33 +6,33 @@ QFAI Prompt Body (SSOT)
6
6
 
7
7
  ---
8
8
 
9
- id: qfai-implement
10
- title: QFAI Implement (Spec-driven implementation)
11
- description: "Implement the program feature according to specs/contracts/scenario; includes review and full quality gate."
9
+ id: qfai-tdd-green
10
+ title: QFAI TDD Green (Implement to pass tests)
11
+ description: "Implement production code to make TDD RED tests pass, then keep gates green."
12
12
  argument-hint: "<spec-id> [--auto]"
13
13
  allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
- roles: [Planner, Architect, BackendEngineer, FrontendEngineer, TestEngineer, QAEngineer, RuntimeGatekeeper, CodeReviewer, DevOpsCIEngineer]
14
+ roles: [BackendEngineer, FrontendEngineer, QAEngineer, CodeReviewer, DevOpsCIEngineer]
15
15
  mode: iterative
16
16
 
17
17
  ---
18
18
 
19
- # /qfai-implement — Implement Feature (Spec‑Driven)
19
+ # /qfai-tdd-green — Implement to Green (TDD)
20
20
 
21
21
  ## Purpose
22
22
 
23
- Implement the required feature/changes according to **spec + contracts + scenario**, then reach a **green quality gate**.
23
+ Implement production code according to **spec + contracts + scenario** so the RED tests pass and the **green quality gate** is reached.
24
24
 
25
25
  ## Guardrails
26
26
 
27
27
  - Do not invent DB/API/infra. If missing, return to Contracts and fix them.
28
28
  - Do not mark "done" without runtime evidence.
29
- - Do NOT write unit tests here; delegate to `/qfai-unit-test` or `/qfai-scenario-test`.
29
+ - Do NOT write new tests here; delegate to `/qfai-tdd-red` (fast tests) or `/qfai-atdd` (acceptance tests).
30
30
  - Stubs/mocks are allowed only for clearly defined external dependencies and must be documented as such.
31
31
 
32
32
  ## Success Criteria (Definition of Done)
33
33
 
34
34
  - Implementation matches the spec and contracts.
35
- - Scenario tests + unit tests pass.
35
+ - TDD tests pass (and ATDD tests pass when applicable).
36
36
  - Repo quality gates pass (lint/type/build/pack as applicable).
37
37
  - Verification evidence is recorded (commands + results).
38
38
  - Program is runnable; runtime evidence is recorded and meets project-type expectations.
@@ -216,8 +216,8 @@ Rules:
216
216
 
217
217
  ## Step 4 — Keep tests aligned (Test Engineer)
218
218
 
219
- - Do NOT write unit tests here. If tests are missing or need coverage, run `/qfai-unit-test` first.
220
- - For acceptance tests, use `/qfai-scenario-test` instead of adding them here.
219
+ - Do NOT write new tests here. If fast tests are missing or need coverage, run `/qfai-tdd-red` first.
220
+ - For acceptance tests, use `/qfai-atdd` instead of adding them here.
221
221
  - Exception: if existing tests are broken and gates cannot pass, apply the minimal fix. Avoid creating new tests.
222
222
 
223
223
  ## Step 5 — Review & QA checks
@@ -342,4 +342,4 @@ All must pass; otherwise, report as not complete.
342
342
  - Runtime evidence summary (commands + outcomes)
343
343
  - DoD section (required)
344
344
  - Gate results: all PASS
345
- - Suggested next command: /qfai-verify (if not already done)
345
+ - Suggested next command: /qfai-tdd-refactor (then /qfai-verify)
@@ -6,21 +6,21 @@ QFAI Prompt Body (SSOT)
6
6
 
7
7
  ---
8
8
 
9
- id: qfai-unit-test
10
- title: QFAI Unit Test (TDD executable)
11
- description: "Implement CI-runnable unit tests derived from spec/scenario; includes review and quality checks."
9
+ id: qfai-tdd-red
10
+ title: QFAI TDD Red (Test-first)
11
+ description: "Implement fast tests first (unit/component/integration) and stop at RED."
12
12
  argument-hint: "<spec-id> [--auto]"
13
13
  allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
- roles: [TestEngineer, BackendEngineer, FrontendEngineer, QAEngineer, UnitTestScopeEnforcer, CodeReviewer]
14
+ roles: [UnitTestScopeEnforcer, TestEngineer, QAEngineer, CodeReviewer]
15
15
  mode: test-first
16
16
 
17
17
  ---
18
18
 
19
- # /qfai-unit-test — Implement Unit Tests (TDD)
19
+ # /qfai-tdd-red — Implement Tests First (TDD Red)
20
20
 
21
21
  ## Purpose
22
22
 
23
- Implement **unit tests** that enforce the spec and provide fast feedback.
23
+ Implement **fast tests** (unit/component/integration) that enforce the spec and provide fast feedback.
24
24
 
25
25
  ## Scope Guardrails (tests-only)
26
26
 
@@ -62,7 +62,7 @@ Without approval, do not proceed.
62
62
  If tests cannot proceed because implementation is missing:
63
63
 
64
64
  - Stop after writing failing tests (RED).
65
- - Instruct the user to run `/qfai-implement` next.
65
+ - Instruct the user to run `/qfai-tdd-green` next.
66
66
  - Record blockers as Open Question / TODO.
67
67
  - Capture failing test evidence and do not run full repository gates.
68
68
 
@@ -231,7 +231,7 @@ QFAI expects `assistant/steering/` to contain **project‑specific facts** so al
231
231
 
232
232
  ## Blocked States (hard stop)
233
233
 
234
- - If the required test surface is missing and would require new production artifacts, stop and request `/qfai-implement`.
234
+ - If the required test surface is missing and would require new production artifacts, stop and request `/qfai-tdd-green`.
235
235
  - If production code changes are required for testability without explicit approval, stop and request approval.
236
236
 
237
237
  ## Step 2 — Identify units and boundaries (Test Engineer + Architect mindset)
@@ -0,0 +1,344 @@
1
+ <!--
2
+ QFAI Prompt Body (SSOT)
3
+ - This file is intended to be referenced by tool-specific custom prompt definitions (e.g., Copilot .prompt.md, Claude Code slash commands).
4
+ - Keep tool-specific wrappers thin: "Read this file and follow it."
5
+ -->
6
+
7
+ ---
8
+
9
+ id: qfai-tdd-refactor
10
+ title: QFAI TDD Refactor (Improve structure safely)
11
+ description: "Refactor code without behavior change after tests are green."
12
+ argument-hint: "<spec-id> [--auto]"
13
+ allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
+ roles: [ArchitectReviewer, BackendEngineer, FrontendEngineer, QAEngineer, CodeReviewer]
15
+ mode: refactor
16
+
17
+ ---
18
+
19
+ # /qfai-tdd-refactor — Refactor Safely (TDD Refactor)
20
+
21
+ ## Purpose
22
+
23
+ Refactor the codebase **without behavior change** after tests are green, preserving spec and contract intent.
24
+
25
+ ## Guardrails
26
+
27
+ - Do not invent DB/API/infra. If missing, stop and raise Open Questions.
28
+ - Do NOT add new tests here; this step is refactor-only.
29
+ - Do NOT change externally visible behavior or specs/contracts.
30
+ - Keep refactors minimal and reversible; prefer small, reviewable changes.
31
+
32
+ ## Success Criteria (Definition of Done)
33
+
34
+ - Behavior remains unchanged and matches the spec and contracts.
35
+ - TDD/ATDD tests remain green after refactor.
36
+ - Repo quality gates pass (lint/type/build/pack as applicable).
37
+ - Verification evidence is recorded (commands + results).
38
+
39
+ ## Non‑Negotiable Principles (QFAI Articles)
40
+
41
+ These principles are inspired by “constitution / articles” patterns used by other agent frameworks, but tailored to QFAI.
42
+
43
+ 1. **SDD First (Specification is the source of truth)**
44
+ If there is a conflict between code and spec, treat the spec as authoritative and either (a) fix code or (b) raise an explicit Open Question to change the spec.
45
+
46
+ 2. **Traceability is mandatory**
47
+ Every meaningful change must be traceable: **Require → Spec → Scenario → Tests → Code → Verification evidence**.
48
+
49
+ 3. **Evidence over confidence**
50
+ Prefer observable proof (logs, commands, file diffs, test results). If you cannot verify, say so and record it.
51
+
52
+ 4. **Minimize scope, but never hide gaps**
53
+ Keep changes minimal, but do not “paper over” missing decisions. If something blocks correctness, stop and ask.
54
+
55
+ 5. **Quality gates are the decision mechanism**
56
+ Use tests/lint/typecheck/build/pack verification (whatever the repo defines) as the primary guardrail. Fix until PASS.
57
+
58
+ 6. **Make it runnable**
59
+ Outputs must be executable in terminal/CI. Provide copy‑paste commands.
60
+
61
+ 7. **User time is expensive**
62
+ Ask only the questions that are truly blocking. Everything else: make reasonable assumptions and label them clearly.
63
+
64
+ ## README Rule
65
+
66
+ Do not edit any `.qfai/**/README.md` file; raise an Open Question instead.
67
+
68
+ - READMEs are reference guides. Follow their structure, templates, and checklists.
69
+
70
+ ## Absolute Rule — Output Language
71
+
72
+ **All outputs MUST be written in the user’s working language for this session.**
73
+
74
+ - If the user writes in Japanese, output Japanese.
75
+ - If the user writes in English, output English.
76
+ - If the user mixes languages, prefer the dominant language unless explicitly instructed otherwise.
77
+ This rule overrides all other stylistic preferences.
78
+
79
+ ## Multi‑Role Orchestration (Subagents)
80
+
81
+ This workflow assumes the environment _may_ support subagents (e.g., Claude Code “Task” tool) or may not.
82
+
83
+ ### If subagents are supported
84
+
85
+ Delegate to multiple roles and then merge the results. Use a “real‑world workflow” order:
86
+
87
+ - Facilitator → Interviewer → Requirements Analyst → Planner → Architect → (Contract Designer) → Test Engineer → QA Engineer → Runtime Gatekeeper → Code Reviewer → DevOps/CI Engineer
88
+
89
+ **Pseudo‑invocation pattern** (adjust to your tool):
90
+
91
+ ```text
92
+ Task(
93
+ subagent_type="planner",
94
+ description="Create an execution plan and DoD",
95
+ prompt="Context: ...\nGoal: ...\nConstraints: ...\nReturn: phases + risks + DoD"
96
+ )
97
+ ```
98
+
99
+ ### If subagents are NOT supported
100
+
101
+ Simulate roles by running the same sequence yourself:
102
+
103
+ - Write a short “role output” section per role, then consolidate into the final deliverable(s).
104
+
105
+ ## Step 0 — Load Context (always)
106
+
107
+ 1. Read relevant **project steering** (if present):
108
+ - `.qfai/assistant/steering/structure.md`
109
+ - `.qfai/assistant/steering/tech.md`
110
+ - `.qfai/assistant/steering/product.md`
111
+ - any additional files under `.qfai/assistant/steering/`
112
+
113
+ 2. Read **project constitution / instructions** (if present):
114
+ - `.qfai/assistant/instructions/constitution.md`
115
+ - `.qfai/assistant/instructions/workflow.md` (or equivalent)
116
+
117
+ 3. Read existing artifacts for the current work item (if present):
118
+ - `.qfai/require/`
119
+ - `.qfai/specs/spec-*/`
120
+ - `.qfai/contracts/`
121
+
122
+ 4. Inspect repo conventions:
123
+ - package manager (pnpm/npm/yarn), test runner, lint/typecheck scripts, CI definitions
124
+ - existing test patterns (unit/integration/e2e)
125
+
126
+ ## Step 0 — Project Analysis (mandatory)
127
+
128
+ Before producing any deliverable, **thoroughly analyze the current project** so your outputs fit the repo’s:
129
+
130
+ - background and goals
131
+ - directory structure and conventions
132
+ - chosen technologies and versions (runtime, package manager, test runner)
133
+ - architecture boundaries (packages, CLI, core modules)
134
+ - existing patterns for tests, docs, and CI
135
+
136
+ ### Minimum analysis checklist
137
+
138
+ - [ ] Read key repo docs: README / CHANGELOG / RELEASE (if present)
139
+ - [ ] Inspect `.qfai/` layout and existing SDD/ATDD/TDD artifacts (if present)
140
+ - [ ] Inspect `packages/qfai` structure (CLI entrypoints, core modules, validators, assets/init)
141
+ - [ ] Identify standard gate commands (format/lint/type/test/verify-pack) and where they are defined
142
+ - [ ] Search for existing examples/patterns of similar changes in tests (if available)
143
+ - [ ] Note constraints: Node versions, CI matrix, packaging rules, verify-pack expectations
144
+
145
+ If analysis cannot be performed (missing access), clearly state what could not be verified and proceed with minimal-risk assumptions.
146
+
147
+ ## Step 0.5 — Steering Bootstrap / Refresh (mandatory when incomplete)
148
+
149
+ QFAI expects `assistant/steering/` to contain **project‑specific facts** so all subsequent design/test/implementation fits this repository.
150
+
151
+ ### What to do
152
+
153
+ 1. Open these files:
154
+
155
+ - `.qfai/assistant/steering/product.md`
156
+ - `.qfai/assistant/steering/tech.md`
157
+ - `.qfai/assistant/steering/structure.md`
158
+
159
+ 2. If they are missing, mostly empty, or still have placeholders (e.g., `- ` only), **populate them by analyzing the current repository**:
160
+
161
+ - derive “what/why/users/success/non-goals” from README/docs/issues (product.md)
162
+ - derive runtime/tooling versions + constraints from package.json, CI config, lockfiles (tech.md)
163
+ - derive repo layout + key directories + gate commands from the file tree and scripts (structure.md)
164
+
165
+ 3. Do **not** invent facts. If something cannot be verified, write it as:
166
+
167
+ - `TBD` + what evidence is missing, or
168
+ - an Open Question (if it blocks correctness)
169
+
170
+ ### Steering refresh checklist
171
+
172
+ - [ ] product.md: what we build / users / success / non-goals / release posture
173
+ - [ ] tech.md: Node / package manager / TS / test / lint / CI constraints
174
+ - [ ] structure.md: repo layout, key packages, entrypoints, standard gate commands, how to run locally
175
+
176
+ ## Step 1 — Confirm prerequisites
177
+
178
+ ### 1.1 Read delta decision log (mandatory)
179
+
180
+ Before implementing, read `.qfai/specs/spec-XXXX/delta.md` and treat it as authoritative for:
181
+
182
+ - what options were considered (Decision Table)
183
+ - what options were rejected or deferred (Decision Guardrails)
184
+
185
+ Hard rule:
186
+
187
+ - Do not implement rejected/deferred options unless the spec/delta is explicitly updated.
188
+ - If you need an exception, raise an Open Question and propose a spec change first.
189
+
190
+ Must exist:
191
+
192
+ - `.qfai/specs/spec-XXXX/spec.md`
193
+ - `.qfai/specs/spec-XXXX/delta.md`
194
+ - `.qfai/specs/spec-XXXX/scenario.feature`
195
+ If missing, stop and request /qfai-spec.
196
+
197
+ ## Step 2 — Plan the implementation (Planner + Architect)
198
+
199
+ Create a short plan:
200
+
201
+ - Tasks (ordered)
202
+ - Files likely affected
203
+ - Risks + mitigations
204
+ - Definition of Done (commands that must pass)
205
+
206
+ If tool supports TodoWrite, record tasks.
207
+
208
+ ## Step 3 — Implement in small increments (Engineers)
209
+
210
+ Rules:
211
+
212
+ - Prefer small, reviewable commits (even if local).
213
+ - Keep changes minimal and aligned with spec.
214
+ - If spec is ambiguous, do not guess silently: record an Open Question and/or propose a spec update.
215
+
216
+ ## Step 4 — Keep tests aligned (Test Engineer)
217
+
218
+ - Do NOT write new tests here. If tests are missing or need coverage, run `/qfai-tdd-red` first.
219
+ - For acceptance tests, use `/qfai-atdd` instead of adding them here.
220
+ - Exception: if existing tests are broken and gates cannot pass, apply the minimal fix. Avoid creating new tests.
221
+
222
+ ## Step 5 — Review & QA checks
223
+
224
+ - Code Reviewer reviews diffs for maintainability and risk.
225
+ - QA Engineer checks acceptance criteria coverage and failure handling.
226
+
227
+ ## Runtime Evidence (MANDATORY)
228
+
229
+ Determine project type and provide evidence accordingly:
230
+
231
+ ### CLI tool
232
+
233
+ - command executes without crash
234
+ - expected outputs observed for at least:
235
+ - normal case
236
+ - invalid input case
237
+
238
+ ### Web/API service
239
+
240
+ - service boots successfully
241
+ - at least one contract path is exercised (local run or integration test)
242
+ - request/response matches contract (status codes, schemas)
243
+
244
+ ### Library
245
+
246
+ - build succeeds
247
+ - a small integration "smoke usage" exists (example test or minimal consumer snippet)
248
+ - public API compiles and behaves per acceptance criteria
249
+
250
+ You must record:
251
+
252
+ - exact commands executed
253
+ - expected vs observed outcomes
254
+
255
+ ## Prohibited "done" criteria
256
+
257
+ You must NOT declare completion based on:
258
+
259
+ - code compilation only
260
+ - unit tests only
261
+ - spec text satisfaction without runtime run
262
+ - mocked acceptance tests presented as real runtime (unless explicitly approved)
263
+
264
+ ## Step 6 — Integration checks (DevOps/CI Engineer)
265
+
266
+ - ensure compilation/type checks pass
267
+ - ensure runtime wiring exists (entrypoints, configuration)
268
+
269
+ ## Step 7 — Runtime evidence (Runtime Gatekeeper)
270
+
271
+ - execute the runtime evidence commands above
272
+ - capture expected vs observed outcomes
273
+
274
+ ## Step 8 — Run quality gates (DevOps/CI Engineer)
275
+
276
+ Run the repo’s standard commands. At minimum:
277
+
278
+ - formatting
279
+ - lint
280
+ - typecheck (if applicable)
281
+ - unit tests
282
+ - scenario tests (if applicable)
283
+
284
+ Record:
285
+
286
+ - commands
287
+ - outputs (summary)
288
+ - PASS/FAIL
289
+
290
+ ## Step 9 — If any gate fails: fix loop
291
+
292
+ Iterate until all gates pass, prioritizing:
293
+
294
+ 1. correctness vs spec
295
+ 2. test determinism
296
+ 3. maintainability
297
+
298
+ ## Completion Criteria (Final Gate)
299
+
300
+ **Before declaring implementation complete, you MUST verify:**
301
+
302
+ 1. Runtime evidence commands executed and outcomes recorded.
303
+
304
+ 2. Run QFAI validation:
305
+
306
+ ```bash
307
+ qfai validate --fail-on error
308
+ ```
309
+
310
+ 3. Run repository standard gates (discover from package.json/CI/docs):
311
+ - format check
312
+ - lint
313
+ - typecheck
314
+ - tests
315
+ - pack/verify (if distributed)
316
+
317
+ Record the exact commands and results.
318
+
319
+ 4. All gates must PASS.
320
+
321
+ If you cannot run these commands (environment limitation):
322
+
323
+ - Request the user to run them and provide the output.
324
+ - Do NOT assume PASS without evidence.
325
+
326
+ ## Definition of Done (Mandatory Output)
327
+
328
+ Include a **DoD** section with:
329
+
330
+ - Commands executed (format/lint/type/unit/integration/verify-pack/dry-run as applicable)
331
+ - Runtime evidence commands and results
332
+ - A note on any mocks/stubs and why they are acceptable
333
+
334
+ All must pass; otherwise, report as not complete.
335
+
336
+ ## Output
337
+
338
+ - Implementation diffs
339
+ - Updated tests (if needed)
340
+ - Verification evidence (commands + results)
341
+ - Runtime evidence summary (commands + outcomes)
342
+ - DoD section (required)
343
+ - Gate results: all PASS
344
+ - Suggested next command: /qfai-verify (if not already done)