qfai 1.0.4 → 1.0.6

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 (94) hide show
  1. package/README.md +58 -67
  2. package/assets/init/.qfai/README.md +17 -76
  3. package/assets/init/.qfai/assistant/README.md +9 -0
  4. package/assets/init/.qfai/assistant/agents/README.md +36 -0
  5. package/assets/init/.qfai/assistant/agents/architect.md +73 -0
  6. package/assets/init/.qfai/assistant/agents/backend-engineer.md +73 -0
  7. package/assets/init/.qfai/assistant/agents/code-reviewer.md +73 -0
  8. package/assets/init/.qfai/assistant/agents/contract-designer.md +73 -0
  9. package/assets/init/.qfai/assistant/agents/devops-ci-engineer.md +73 -0
  10. package/assets/init/.qfai/assistant/agents/facilitator.md +74 -0
  11. package/assets/init/.qfai/assistant/agents/frontend-engineer.md +73 -0
  12. package/assets/init/.qfai/assistant/agents/interviewer.md +72 -0
  13. package/assets/init/.qfai/assistant/agents/planner.md +73 -0
  14. package/assets/init/.qfai/assistant/agents/qa-engineer.md +73 -0
  15. package/assets/init/.qfai/assistant/agents/requirements-analyst.md +73 -0
  16. package/assets/init/.qfai/assistant/agents/test-engineer.md +73 -0
  17. package/assets/init/.qfai/assistant/instructions/README.md +10 -0
  18. package/assets/init/.qfai/assistant/instructions/agent-selection.md +28 -0
  19. package/assets/init/.qfai/assistant/instructions/communication.md +27 -0
  20. package/assets/init/.qfai/assistant/instructions/constitution.md +131 -0
  21. package/assets/init/.qfai/assistant/instructions/quality.md +27 -0
  22. package/assets/init/.qfai/assistant/instructions/thinking.md +29 -0
  23. package/assets/init/.qfai/assistant/instructions/workflow.md +75 -0
  24. package/assets/init/.qfai/assistant/prompts/README.md +19 -0
  25. package/assets/init/.qfai/assistant/prompts/qfai-discuss.md +173 -0
  26. package/assets/init/.qfai/assistant/prompts/qfai-implement.md +230 -0
  27. package/assets/init/.qfai/assistant/prompts/qfai-pr.md +209 -0
  28. package/assets/init/.qfai/assistant/prompts/qfai-require.md +264 -0
  29. package/assets/init/.qfai/assistant/prompts/qfai-scenario-test.md +220 -0
  30. package/assets/init/.qfai/assistant/prompts/qfai-spec.md +291 -0
  31. package/assets/init/.qfai/assistant/prompts/qfai-unit-test.md +193 -0
  32. package/assets/init/.qfai/assistant/prompts/qfai-verify.md +222 -0
  33. package/assets/init/.qfai/assistant/prompts.local/README.md +8 -0
  34. package/assets/init/.qfai/assistant/steering/README.md +40 -0
  35. package/assets/init/.qfai/assistant/steering/product.md +32 -0
  36. package/assets/init/.qfai/assistant/steering/structure.md +34 -0
  37. package/assets/init/.qfai/assistant/steering/tech.md +37 -0
  38. package/assets/init/.qfai/contracts/README.md +7 -87
  39. package/assets/init/.qfai/contracts/api/README.md +8 -0
  40. package/assets/init/.qfai/contracts/db/README.md +25 -0
  41. package/assets/init/.qfai/contracts/ui/README.md +8 -0
  42. package/assets/init/.qfai/report/README.md +13 -0
  43. package/assets/init/.qfai/require/README.md +4 -26
  44. package/assets/init/.qfai/require/require.md +74 -0
  45. package/assets/init/.qfai/specs/README.md +7 -55
  46. package/assets/init/root/.github/workflows/qfai.yml +1 -1
  47. package/assets/init/root/qfai.config.yaml +3 -3
  48. package/dist/cli/index.cjs +306 -423
  49. package/dist/cli/index.cjs.map +1 -1
  50. package/dist/cli/index.mjs +288 -405
  51. package/dist/cli/index.mjs.map +1 -1
  52. package/dist/index.cjs +29 -14
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.mjs +29 -14
  55. package/dist/index.mjs.map +1 -1
  56. package/package.json +1 -1
  57. package/assets/init/.qfai/contracts/api/api-0001-sample.yaml +0 -15
  58. package/assets/init/.qfai/contracts/db/db-0001-sample.sql +0 -7
  59. package/assets/init/.qfai/contracts/ui/assets/thema-001-facebook-like/assets.yaml +0 -6
  60. package/assets/init/.qfai/contracts/ui/assets/thema-001-facebook-like/palette.png +0 -0
  61. package/assets/init/.qfai/contracts/ui/assets/ui-0001-sample/assets.yaml +0 -6
  62. package/assets/init/.qfai/contracts/ui/assets/ui-0001-sample/snapshots/login__desktop__light__default.png +0 -0
  63. package/assets/init/.qfai/contracts/ui/thema-001-facebook-like.yml +0 -13
  64. package/assets/init/.qfai/contracts/ui/ui-0001-sample.yaml +0 -17
  65. package/assets/init/.qfai/out/README.md +0 -17
  66. package/assets/init/.qfai/promptpack/commands/implement.md +0 -8
  67. package/assets/init/.qfai/promptpack/commands/plan.md +0 -11
  68. package/assets/init/.qfai/promptpack/commands/release.md +0 -6
  69. package/assets/init/.qfai/promptpack/commands/review.md +0 -6
  70. package/assets/init/.qfai/promptpack/constitution.md +0 -15
  71. package/assets/init/.qfai/promptpack/roles/qa.md +0 -4
  72. package/assets/init/.qfai/promptpack/roles/spec.md +0 -4
  73. package/assets/init/.qfai/promptpack/roles/test.md +0 -4
  74. package/assets/init/.qfai/promptpack/steering/naming.md +0 -7
  75. package/assets/init/.qfai/promptpack/steering/traceability.md +0 -25
  76. package/assets/init/.qfai/prompts/README.md +0 -68
  77. package/assets/init/.qfai/prompts/analyze/README.md +0 -21
  78. package/assets/init/.qfai/prompts/analyze/scenario_test_consistency.md +0 -8
  79. package/assets/init/.qfai/prompts/analyze/scenario_to_test.md +0 -56
  80. package/assets/init/.qfai/prompts/analyze/spec_contract_consistency.md +0 -8
  81. package/assets/init/.qfai/prompts/analyze/spec_scenario_consistency.md +0 -8
  82. package/assets/init/.qfai/prompts/analyze/spec_to_contract.md +0 -54
  83. package/assets/init/.qfai/prompts/analyze/spec_to_scenario.md +0 -56
  84. package/assets/init/.qfai/prompts/makeBusinessFlow.md +0 -34
  85. package/assets/init/.qfai/prompts/makeOverview.md +0 -27
  86. package/assets/init/.qfai/prompts/qfai-generate-test-globs.md +0 -29
  87. package/assets/init/.qfai/prompts/qfai-maintain-contracts.md +0 -35
  88. package/assets/init/.qfai/prompts/qfai-maintain-traceability.md +0 -36
  89. package/assets/init/.qfai/prompts/require-to-spec.md +0 -40
  90. package/assets/init/.qfai/prompts.local/README.md +0 -31
  91. package/assets/init/.qfai/specs/spec-0001/delta.md +0 -25
  92. package/assets/init/.qfai/specs/spec-0001/scenario.feature +0 -11
  93. package/assets/init/.qfai/specs/spec-0001/spec.md +0 -40
  94. package/assets/init/root/tests/qfai-traceability.sample.test.ts +0 -2
@@ -0,0 +1,209 @@
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-pr
10
+ title: QFAI PR (Prepare PR Description)
11
+ description: "Generate a PR description that matches the project template and includes evidence."
12
+ argument-hint: "<title> [--auto]"
13
+ allowed-tools: [Read, Glob, Write, Task]
14
+ roles: [Planner, QAEngineer, DevOpsCIEngineer, CodeReviewer]
15
+ mode: doc-focused
16
+
17
+ ---
18
+
19
+ # /qfai-pr — Prepare PR Description
20
+
21
+ ## Purpose
22
+
23
+ Generate a PR description that helps reviewers approve quickly:
24
+
25
+ - What changed / why
26
+ - Impact and migration notes
27
+ - How to verify (commands + evidence)
28
+ - Risk areas to pay attention to
29
+
30
+ ## Success Criteria
31
+
32
+ - PR body matches the repository’s PR template (if any).
33
+ - Includes verification evidence from /qfai-verify.
34
+
35
+ ## Non‑Negotiable Principles (QFAI Articles)
36
+
37
+ These principles are inspired by “constitution / articles” patterns used by other agent frameworks, but tailored to QFAI.
38
+
39
+ 1. **SDD First (Specification is the source of truth)**
40
+ 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.
41
+
42
+ 2. **Traceability is mandatory**
43
+ Every meaningful change must be traceable: **Require → Spec → Scenario → Tests → Code → Verification evidence**.
44
+
45
+ 3. **Evidence over confidence**
46
+ Prefer observable proof (logs, commands, file diffs, test results). If you cannot verify, say so and record it.
47
+
48
+ 4. **Minimize scope, but never hide gaps**
49
+ Keep changes minimal, but do not “paper over” missing decisions. If something blocks correctness, stop and ask.
50
+
51
+ 5. **Quality gates are the decision mechanism**
52
+ Use tests/lint/typecheck/build/pack verification (whatever the repo defines) as the primary guardrail. Fix until PASS.
53
+
54
+ 6. **Make it runnable**
55
+ Outputs must be executable in terminal/CI. Provide copy‑paste commands.
56
+
57
+ 7. **User time is expensive**
58
+ Ask only the questions that are truly blocking. Everything else: make reasonable assumptions and label them clearly.
59
+
60
+ ## Absolute Rule — Output Language
61
+
62
+ **All outputs MUST be written in the user’s working language for this session.**
63
+
64
+ - If the user writes in Japanese, output Japanese.
65
+ - If the user writes in English, output English.
66
+ - If the user mixes languages, prefer the dominant language unless explicitly instructed otherwise.
67
+ This rule overrides all other stylistic preferences.
68
+
69
+ ## Multi‑Role Orchestration (Subagents)
70
+
71
+ This workflow assumes the environment _may_ support subagents (e.g., Claude Code “Task” tool) or may not.
72
+
73
+ ### If subagents are supported
74
+
75
+ Delegate to multiple roles and then merge the results. Use a “real‑world workflow” order:
76
+
77
+ - Facilitator → Interviewer → Requirements Analyst → Planner → Architect → (Contract Designer) → Test Engineer → QA Engineer → Code Reviewer → DevOps/CI Engineer
78
+
79
+ **Pseudo‑invocation pattern** (adjust to your tool):
80
+
81
+ ```text
82
+ Task(
83
+ subagent_type="planner",
84
+ description="Create an execution plan and DoD",
85
+ prompt="Context: ...\nGoal: ...\nConstraints: ...\nReturn: phases + risks + DoD"
86
+ )
87
+ ```
88
+
89
+ ### If subagents are NOT supported
90
+
91
+ Simulate roles by running the same sequence yourself:
92
+
93
+ - Write a short “role output” section per role, then consolidate into the final deliverable(s).
94
+
95
+ ## Step 0 — Load Context (always)
96
+
97
+ 1. Read relevant **project steering** (if present):
98
+ - `.qfai/assistant/steering/structure.md`
99
+ - `.qfai/assistant/steering/tech.md`
100
+ - `.qfai/assistant/steering/product.md`
101
+ - any additional files under `.qfai/assistant/steering/`
102
+
103
+ 2. Read **project constitution / instructions** (if present):
104
+ - `.qfai/assistant/instructions/constitution.md`
105
+ - `.qfai/assistant/instructions/workflow.md` (or equivalent)
106
+
107
+ 3. Read existing artifacts for the current work item (if present):
108
+ - `.qfai/require/`
109
+ - `.qfai/specs/spec-*/`
110
+ - `.qfai/contracts/`
111
+
112
+ 4. Inspect repo conventions:
113
+ - package manager (pnpm/npm/yarn), test runner, lint/typecheck scripts, CI definitions
114
+ - existing test patterns (unit/integration/e2e)
115
+
116
+ ## Step 0 — Project Analysis (mandatory)
117
+
118
+ Before producing any deliverable, **thoroughly analyze the current project** so your outputs fit the repo’s:
119
+
120
+ - background and goals
121
+ - directory structure and conventions
122
+ - chosen technologies and versions (runtime, package manager, test runner)
123
+ - architecture boundaries (packages, CLI, core modules)
124
+ - existing patterns for tests, docs, and CI
125
+
126
+ ### Minimum analysis checklist
127
+
128
+ - [ ] Read key repo docs: README / CHANGELOG / RELEASE (if present)
129
+ - [ ] Inspect `.qfai/` layout and existing SDD/ATDD/TDD artifacts (if present)
130
+ - [ ] Inspect `packages/qfai` structure (CLI entrypoints, core modules, validators, assets/init)
131
+ - [ ] Identify standard gate commands (format/lint/type/test/verify-pack) and where they are defined
132
+ - [ ] Search for existing examples/patterns of similar changes in tests (if available)
133
+ - [ ] Note constraints: Node versions, CI matrix, packaging rules, verify-pack expectations
134
+
135
+ If analysis cannot be performed (missing access), clearly state what could not be verified and proceed with minimal-risk assumptions.
136
+
137
+ ## Step 0.5 — Steering Bootstrap / Refresh (mandatory when incomplete)
138
+
139
+ QFAI expects `assistant/steering/` to contain **project‑specific facts** so all subsequent design/test/implementation fits this repository.
140
+
141
+ ### What to do
142
+
143
+ 1. Open these files:
144
+
145
+ - `.qfai/assistant/steering/product.md`
146
+ - `.qfai/assistant/steering/tech.md`
147
+ - `.qfai/assistant/steering/structure.md`
148
+
149
+ 2. If they are missing, mostly empty, or still have placeholders (e.g., `- ` only), **populate them by analyzing the current repository**:
150
+
151
+ - derive “what/why/users/success/non-goals” from README/docs/issues (product.md)
152
+ - derive runtime/tooling versions + constraints from package.json, CI config, lockfiles (tech.md)
153
+ - derive repo layout + key directories + gate commands from the file tree and scripts (structure.md)
154
+
155
+ 3. Do **not** invent facts. If something cannot be verified, write it as:
156
+
157
+ - `TBD` + what evidence is missing, or
158
+ - an Open Question (if it blocks correctness)
159
+
160
+ ### Steering refresh checklist
161
+
162
+ - [ ] product.md: what we build / users / success / non-goals / release posture
163
+ - [ ] tech.md: Node / package manager / TS / test / lint / CI constraints
164
+ - [ ] structure.md: repo layout, key packages, entrypoints, standard gate commands, how to run locally
165
+
166
+ ## Step 1 — Locate PR template
167
+
168
+ Search for:
169
+
170
+ - `PULL_REQUEST_TEMPLATE.md`
171
+ - `.github/PULL_REQUEST_TEMPLATE.md`
172
+ - repo-specific templates
173
+
174
+ If none exists, use the standard structure in Step 3.
175
+
176
+ ## Step 2 — Collect evidence
177
+
178
+ Read the latest verification evidence (from /qfai-verify output or logs).
179
+
180
+ ## Step 3 — Write PR body
181
+
182
+ Use this structure (adapt to template if present):
183
+
184
+ ### Summary
185
+
186
+ ### Motivation / Context
187
+
188
+ ### Changes
189
+
190
+ ### Impact / Migration
191
+
192
+ ### Verification
193
+
194
+ (copy‑paste commands + results)
195
+
196
+ ### Risks / Notes
197
+
198
+ ### Reviewer Focus
199
+
200
+ (what to review carefully)
201
+
202
+ ## Step 4 — Final review
203
+
204
+ - QA: acceptance coverage and risk notes
205
+ - Code Reviewer: clarity, missing information, misleading claims
206
+
207
+ ## Output
208
+
209
+ - Ready-to-paste PR title + body
@@ -0,0 +1,264 @@
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-require
10
+ title: QFAI Require (Create Requirements Artifact)
11
+ description: "Generate a concrete requirements artifact (EARS + NFR) as a project deliverable."
12
+ argument-hint: "<work-item-name> [--auto]"
13
+ allowed-tools: [Read, Glob, Write, TodoWrite, Task]
14
+ roles: [RequirementsAnalyst, Interviewer, QAEngineer, CodeReviewer, Planner]
15
+ mode: approval-gated
16
+
17
+ ---
18
+
19
+ # /qfai-require — Create Requirements Artifact
20
+
21
+ ## Purpose
22
+
23
+ Turn the Requirements Seed (from /qfai-discuss or user input) into a **versioned, reviewable requirements artifact** under `.qfai/require/`.
24
+
25
+ ## Success Criteria (Definition of Done)
26
+
27
+ - `.qfai/require/require.md` exists and is readable by a newcomer.
28
+ - Requirements are **testable** (EARS style) and include **NFR** (security/performance/etc).
29
+ - Blocking Open Questions are explicitly listed with requested answers.
30
+
31
+ ## Non‑Negotiable Principles (QFAI Articles)
32
+
33
+ These principles are inspired by “constitution / articles” patterns used by other agent frameworks, but tailored to QFAI.
34
+
35
+ 1. **SDD First (Specification is the source of truth)**
36
+ 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.
37
+
38
+ 2. **Traceability is mandatory**
39
+ Every meaningful change must be traceable: **Require → Spec → Scenario → Tests → Code → Verification evidence**.
40
+
41
+ 3. **Evidence over confidence**
42
+ Prefer observable proof (logs, commands, file diffs, test results). If you cannot verify, say so and record it.
43
+
44
+ 4. **Minimize scope, but never hide gaps**
45
+ Keep changes minimal, but do not “paper over” missing decisions. If something blocks correctness, stop and ask.
46
+
47
+ 5. **Quality gates are the decision mechanism**
48
+ Use tests/lint/typecheck/build/pack verification (whatever the repo defines) as the primary guardrail. Fix until PASS.
49
+
50
+ 6. **Make it runnable**
51
+ Outputs must be executable in terminal/CI. Provide copy‑paste commands.
52
+
53
+ 7. **User time is expensive**
54
+ Ask only the questions that are truly blocking. Everything else: make reasonable assumptions and label them clearly.
55
+
56
+ ## Absolute Rule — Output Language
57
+
58
+ **All outputs MUST be written in the user’s working language for this session.**
59
+
60
+ - If the user writes in Japanese, output Japanese.
61
+ - If the user writes in English, output English.
62
+ - If the user mixes languages, prefer the dominant language unless explicitly instructed otherwise.
63
+ This rule overrides all other stylistic preferences.
64
+
65
+ ## Multi‑Role Orchestration (Subagents)
66
+
67
+ This workflow assumes the environment _may_ support subagents (e.g., Claude Code “Task” tool) or may not.
68
+
69
+ ### If subagents are supported
70
+
71
+ Delegate to multiple roles and then merge the results. Use a “real‑world workflow” order:
72
+
73
+ - Facilitator → Interviewer → Requirements Analyst → Planner → Architect → (Contract Designer) → Test Engineer → QA Engineer → Code Reviewer → DevOps/CI Engineer
74
+
75
+ **Pseudo‑invocation pattern** (adjust to your tool):
76
+
77
+ ```text
78
+ Task(
79
+ subagent_type="planner",
80
+ description="Create an execution plan and DoD",
81
+ prompt="Context: ...\nGoal: ...\nConstraints: ...\nReturn: phases + risks + DoD"
82
+ )
83
+ ```
84
+
85
+ ### If subagents are NOT supported
86
+
87
+ Simulate roles by running the same sequence yourself:
88
+
89
+ - Write a short “role output” section per role, then consolidate into the final deliverable(s).
90
+
91
+ ## Step 0 — Load Context (always)
92
+
93
+ 1. Read relevant **project steering** (if present):
94
+ - `.qfai/assistant/steering/structure.md`
95
+ - `.qfai/assistant/steering/tech.md`
96
+ - `.qfai/assistant/steering/product.md`
97
+ - any additional files under `.qfai/assistant/steering/`
98
+
99
+ 2. Read **project constitution / instructions** (if present):
100
+ - `.qfai/assistant/instructions/constitution.md`
101
+ - `.qfai/assistant/instructions/workflow.md` (or equivalent)
102
+
103
+ 3. Read existing artifacts for the current work item (if present):
104
+ - `.qfai/require/`
105
+ - `.qfai/specs/spec-*/`
106
+ - `.qfai/contracts/`
107
+
108
+ 4. Inspect repo conventions:
109
+ - package manager (pnpm/npm/yarn), test runner, lint/typecheck scripts, CI definitions
110
+ - existing test patterns (unit/integration/e2e)
111
+
112
+ ## Step 0 — Project Analysis (mandatory)
113
+
114
+ Before producing any deliverable, **thoroughly analyze the current project** so your outputs fit the repo’s:
115
+
116
+ - background and goals
117
+ - directory structure and conventions
118
+ - chosen technologies and versions (runtime, package manager, test runner)
119
+ - architecture boundaries (packages, CLI, core modules)
120
+ - existing patterns for tests, docs, and CI
121
+
122
+ ### Minimum analysis checklist
123
+
124
+ - [ ] Read key repo docs: README / CHANGELOG / RELEASE (if present)
125
+ - [ ] Inspect `.qfai/` layout and existing SDD/ATDD/TDD artifacts (if present)
126
+ - [ ] Inspect `packages/qfai` structure (CLI entrypoints, core modules, validators, assets/init)
127
+ - [ ] Identify standard gate commands (format/lint/type/test/verify-pack) and where they are defined
128
+ - [ ] Search for existing examples/patterns of similar changes in tests (if available)
129
+ - [ ] Note constraints: Node versions, CI matrix, packaging rules, verify-pack expectations
130
+
131
+ If analysis cannot be performed (missing access), clearly state what could not be verified and proceed with minimal-risk assumptions.
132
+
133
+ ## Step 0.5 — Steering Bootstrap / Refresh (mandatory when incomplete)
134
+
135
+ QFAI expects `assistant/steering/` to contain **project‑specific facts** so all subsequent design/test/implementation fits this repository.
136
+
137
+ ### What to do
138
+
139
+ 1. Open these files:
140
+
141
+ - `.qfai/assistant/steering/product.md`
142
+ - `.qfai/assistant/steering/tech.md`
143
+ - `.qfai/assistant/steering/structure.md`
144
+
145
+ 2. If they are missing, mostly empty, or still have placeholders (e.g., `- ` only), **populate them by analyzing the current repository**:
146
+
147
+ - derive “what/why/users/success/non-goals” from README/docs/issues (product.md)
148
+ - derive runtime/tooling versions + constraints from package.json, CI config, lockfiles (tech.md)
149
+ - derive repo layout + key directories + gate commands from the file tree and scripts (structure.md)
150
+
151
+ 3. Do **not** invent facts. If something cannot be verified, write it as:
152
+
153
+ - `TBD` + what evidence is missing, or
154
+ - an Open Question (if it blocks correctness)
155
+
156
+ ### Steering refresh checklist
157
+
158
+ - [ ] product.md: what we build / users / success / non-goals / release posture
159
+ - [ ] tech.md: Node / package manager / TS / test / lint / CI constraints
160
+ - [ ] structure.md: repo layout, key packages, entrypoints, standard gate commands, how to run locally
161
+
162
+ ## Step 1 — Ensure repository location
163
+
164
+ Create (or update) these files:
165
+
166
+ - `.qfai/require/README.md` — what this folder is, how to use it
167
+ - `.qfai/require/require.md` — the requirements artifact (single-file SSOT)
168
+
169
+ ## Step 2 — Requirements format: EARS (Requirements Analyst)
170
+
171
+ Use EARS patterns (inspired by SDD frameworks):
172
+
173
+ - **Ubiquitous**: “The system shall …”
174
+ - **Event‑driven**: “When <event>, the system shall …”
175
+ - **State‑driven**: “While <state>, the system shall …”
176
+ - **Unwanted behavior**: “If <undesired>, the system shall …”
177
+ - **Optional feature**: “Where <feature>, the system shall …”
178
+
179
+ ### Requirement ID scheme
180
+
181
+ Use stable IDs:
182
+
183
+ - `REQ-FUNC-###` for functional requirements
184
+ - `REQ-NFR-SEC-###`, `REQ-NFR-PERF-###`, `REQ-NFR-REL-###` etc for non-functional
185
+
186
+ IDs must be unique and never reused.
187
+
188
+ ## Step 3 — Write `require.md` with this template
189
+
190
+ Use this exact structure:
191
+
192
+ # Requirements
193
+
194
+ ## 1. Overview
195
+
196
+ - Problem / opportunity
197
+ - Target users
198
+ - Success definition (business + technical)
199
+
200
+ ## 2. Scope
201
+
202
+ ### In scope
203
+
204
+ ### Out of scope
205
+
206
+ ## 3. Constraints & Assumptions
207
+
208
+ - Constraints
209
+ - Assumptions (explicit)
210
+
211
+ ## 4. Glossary (optional but recommended)
212
+
213
+ ## 5. Functional Requirements (EARS)
214
+
215
+ ### REQ-FUNC-001: <title>
216
+
217
+ - Statement (EARS)
218
+ - Rationale
219
+ - Acceptance criteria (testable)
220
+ - Notes / edge cases
221
+
222
+ (repeat)
223
+
224
+ ## 6. Non‑Functional Requirements
225
+
226
+ ### Security
227
+
228
+ ### Performance
229
+
230
+ ### Reliability / Availability
231
+
232
+ ### Observability
233
+
234
+ ### Compliance / Privacy (if relevant)
235
+
236
+ ## 7. Acceptance Criteria (summary)
237
+
238
+ A bullet list of what must be true to accept the change.
239
+
240
+ ## 8. Open Questions
241
+
242
+ ### Blocking
243
+
244
+ ### Non‑blocking
245
+
246
+ ## Step 4 — Review cycle (QA + Code Reviewer)
247
+
248
+ - QA Engineer checks testability and missing failure cases.
249
+ - Code Reviewer checks ambiguity, contradictions, and “non‑testable language”.
250
+
251
+ ## Step 5 — Approval gate
252
+
253
+ If interactive mode:
254
+
255
+ - Ask the user for approval: “Approve requirements? (yes/no)”
256
+ - If no: update and repeat.
257
+ If `--auto`:
258
+ - Proceed, but highlight assumptions and warn about rework risk.
259
+
260
+ ## Output
261
+
262
+ - Updated `.qfai/require/README.md`
263
+ - Updated `.qfai/require/require.md`
264
+ - A short “next command” suggestion (typically /qfai-spec)
@@ -0,0 +1,220 @@
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-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."
12
+ argument-hint: "<spec-id> [--auto]"
13
+ allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
+ roles: [TestEngineer, DevOpsCIEngineer, QAEngineer, CodeReviewer, Planner]
15
+ mode: execution-focused
16
+
17
+ ---
18
+
19
+ # /qfai-scenario-test — Implement Executable Scenario Tests (ATDD)
20
+
21
+ ## Purpose
22
+
23
+ Turn `.qfai/specs/spec-XXXX/scenario.feature` into **runnable scenario tests** in this repository (terminal + CI).
24
+
25
+ ## Success Criteria (Definition of Done)
26
+
27
+ - Scenario tests exist and are runnable via documented commands.
28
+ - Tests are stable (no flakiness) and diagnostic (failures explain why).
29
+ - Quality checks (lint/typecheck/tests) pass in the repo’s standard way.
30
+
31
+ ## Non‑Negotiable Principles (QFAI Articles)
32
+
33
+ These principles are inspired by “constitution / articles” patterns used by other agent frameworks, but tailored to QFAI.
34
+
35
+ 1. **SDD First (Specification is the source of truth)**
36
+ 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.
37
+
38
+ 2. **Traceability is mandatory**
39
+ Every meaningful change must be traceable: **Require → Spec → Scenario → Tests → Code → Verification evidence**.
40
+
41
+ 3. **Evidence over confidence**
42
+ Prefer observable proof (logs, commands, file diffs, test results). If you cannot verify, say so and record it.
43
+
44
+ 4. **Minimize scope, but never hide gaps**
45
+ Keep changes minimal, but do not “paper over” missing decisions. If something blocks correctness, stop and ask.
46
+
47
+ 5. **Quality gates are the decision mechanism**
48
+ Use tests/lint/typecheck/build/pack verification (whatever the repo defines) as the primary guardrail. Fix until PASS.
49
+
50
+ 6. **Make it runnable**
51
+ Outputs must be executable in terminal/CI. Provide copy‑paste commands.
52
+
53
+ 7. **User time is expensive**
54
+ Ask only the questions that are truly blocking. Everything else: make reasonable assumptions and label them clearly.
55
+
56
+ ## Absolute Rule — Output Language
57
+
58
+ **All outputs MUST be written in the user’s working language for this session.**
59
+
60
+ - If the user writes in Japanese, output Japanese.
61
+ - If the user writes in English, output English.
62
+ - If the user mixes languages, prefer the dominant language unless explicitly instructed otherwise.
63
+ This rule overrides all other stylistic preferences.
64
+
65
+ ## Multi‑Role Orchestration (Subagents)
66
+
67
+ This workflow assumes the environment _may_ support subagents (e.g., Claude Code “Task” tool) or may not.
68
+
69
+ ### If subagents are supported
70
+
71
+ Delegate to multiple roles and then merge the results. Use a “real‑world workflow” order:
72
+
73
+ - Facilitator → Interviewer → Requirements Analyst → Planner → Architect → (Contract Designer) → Test Engineer → QA Engineer → Code Reviewer → DevOps/CI Engineer
74
+
75
+ **Pseudo‑invocation pattern** (adjust to your tool):
76
+
77
+ ```text
78
+ Task(
79
+ subagent_type="planner",
80
+ description="Create an execution plan and DoD",
81
+ prompt="Context: ...\nGoal: ...\nConstraints: ...\nReturn: phases + risks + DoD"
82
+ )
83
+ ```
84
+
85
+ ### If subagents are NOT supported
86
+
87
+ Simulate roles by running the same sequence yourself:
88
+
89
+ - Write a short “role output” section per role, then consolidate into the final deliverable(s).
90
+
91
+ ## Step 0 — Load Context (always)
92
+
93
+ 1. Read relevant **project steering** (if present):
94
+ - `.qfai/assistant/steering/structure.md`
95
+ - `.qfai/assistant/steering/tech.md`
96
+ - `.qfai/assistant/steering/product.md`
97
+ - any additional files under `.qfai/assistant/steering/`
98
+
99
+ 2. Read **project constitution / instructions** (if present):
100
+ - `.qfai/assistant/instructions/constitution.md`
101
+ - `.qfai/assistant/instructions/workflow.md` (or equivalent)
102
+
103
+ 3. Read existing artifacts for the current work item (if present):
104
+ - `.qfai/require/`
105
+ - `.qfai/specs/spec-*/`
106
+ - `.qfai/contracts/`
107
+
108
+ 4. Inspect repo conventions:
109
+ - package manager (pnpm/npm/yarn), test runner, lint/typecheck scripts, CI definitions
110
+ - existing test patterns (unit/integration/e2e)
111
+
112
+ ## Step 0 — Project Analysis (mandatory)
113
+
114
+ Before producing any deliverable, **thoroughly analyze the current project** so your outputs fit the repo’s:
115
+
116
+ - background and goals
117
+ - directory structure and conventions
118
+ - chosen technologies and versions (runtime, package manager, test runner)
119
+ - architecture boundaries (packages, CLI, core modules)
120
+ - existing patterns for tests, docs, and CI
121
+
122
+ ### Minimum analysis checklist
123
+
124
+ - [ ] Read key repo docs: README / CHANGELOG / RELEASE (if present)
125
+ - [ ] Inspect `.qfai/` layout and existing SDD/ATDD/TDD artifacts (if present)
126
+ - [ ] Inspect `packages/qfai` structure (CLI entrypoints, core modules, validators, assets/init)
127
+ - [ ] Identify standard gate commands (format/lint/type/test/verify-pack) and where they are defined
128
+ - [ ] Search for existing examples/patterns of similar changes in tests (if available)
129
+ - [ ] Note constraints: Node versions, CI matrix, packaging rules, verify-pack expectations
130
+
131
+ If analysis cannot be performed (missing access), clearly state what could not be verified and proceed with minimal-risk assumptions.
132
+
133
+ ## Step 0.5 — Steering Bootstrap / Refresh (mandatory when incomplete)
134
+
135
+ QFAI expects `assistant/steering/` to contain **project‑specific facts** so all subsequent design/test/implementation fits this repository.
136
+
137
+ ### What to do
138
+
139
+ 1. Open these files:
140
+
141
+ - `.qfai/assistant/steering/product.md`
142
+ - `.qfai/assistant/steering/tech.md`
143
+ - `.qfai/assistant/steering/structure.md`
144
+
145
+ 2. If they are missing, mostly empty, or still have placeholders (e.g., `- ` only), **populate them by analyzing the current repository**:
146
+
147
+ - derive “what/why/users/success/non-goals” from README/docs/issues (product.md)
148
+ - derive runtime/tooling versions + constraints from package.json, CI config, lockfiles (tech.md)
149
+ - derive repo layout + key directories + gate commands from the file tree and scripts (structure.md)
150
+
151
+ 3. Do **not** invent facts. If something cannot be verified, write it as:
152
+
153
+ - `TBD` + what evidence is missing, or
154
+ - an Open Question (if it blocks correctness)
155
+
156
+ ### Steering refresh checklist
157
+
158
+ - [ ] product.md: what we build / users / success / non-goals / release posture
159
+ - [ ] tech.md: Node / package manager / TS / test / lint / CI constraints
160
+ - [ ] structure.md: repo layout, key packages, entrypoints, standard gate commands, how to run locally
161
+
162
+ ## Step 1 — Locate the spec pack
163
+
164
+ Read:
165
+
166
+ - `.qfai/specs/spec-XXXX/spec.md`
167
+ - `.qfai/specs/spec-XXXX/scenario.feature`
168
+ - any referenced contracts under `.qfai/contracts/**`
169
+
170
+ ## Step 2 — Choose (or detect) scenario test harness
171
+
172
+ Prefer existing project tooling. Determine:
173
+
174
+ - Where tests live
175
+ - Test runner (e.g., Playwright/Cypress/Cucumber/Jest/Vitest/etc)
176
+ - CI execution command
177
+
178
+ If nothing exists:
179
+
180
+ - Propose the minimal harness choice consistent with the stack.
181
+ - In interactive mode, ask approval; in `--auto`, pick one and document assumptions.
182
+
183
+ ## Step 3 — Implement scenario tests (Test Engineer)
184
+
185
+ Rules:
186
+
187
+ - Scenarios must map to executable steps.
188
+ - Keep step definitions reusable but not overly generic.
189
+ - Ensure each scenario asserts observable behavior.
190
+
191
+ Deliverables:
192
+
193
+ - Step definitions / test code
194
+ - Any required fixtures/mocks (minimal)
195
+ - A “how to run” command
196
+
197
+ ## Step 4 — Integrate with CI / scripts (DevOps/CI Engineer)
198
+
199
+ - Add/adjust package scripts only if needed.
200
+ - Ensure a single command can run the scenario suite.
201
+ - Keep changes minimal and well documented.
202
+
203
+ ## Step 5 — QA review + code review
204
+
205
+ - QA Engineer: scenario coverage, failure cases, observability
206
+ - Code Reviewer: maintainability, flakiness risks, unclear assertions
207
+
208
+ ## Step 6 — Record verification evidence
209
+
210
+ Provide:
211
+
212
+ - Exact commands run
213
+ - Summary of results
214
+ - Where logs/artifacts can be found (if applicable)
215
+
216
+ ## Output
217
+
218
+ - Scenario test implementation files
219
+ - “Runbook” snippet (copy‑paste command)
220
+ - Short verification evidence summary