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,291 @@
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-spec
10
+ title: QFAI Spec (SDD Deliverables: specs + contracts + scenario skeleton)
11
+ description: "Create SDD artifacts: spec pack, delta, scenario.feature skeleton, and required contracts."
12
+ argument-hint: "<spec-id-or-name> [--auto]"
13
+ allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
+ roles: [Architect, ContractDesigner, TestEngineer, QAEngineer, CodeReviewer, Planner]
15
+ mode: approval-gated
16
+
17
+ ---
18
+
19
+ # /qfai-spec — Create Specification Pack (SDD)
20
+
21
+ ## Purpose
22
+
23
+ Create/update a **spec pack** that becomes the source of truth for implementation and testing.
24
+
25
+ ## Success Criteria (Definition of Done)
26
+
27
+ - A new directory exists: `.qfai/specs/spec-XXXX/` (or an existing one is updated).
28
+ - At minimum, these files exist and are coherent:
29
+ - `spec.md` (SDD spec)
30
+ - `delta.md` (change log / impact / migration)
31
+ - `scenario.feature` (ATDD skeleton aligned with spec)
32
+ - Contracts are added/updated under `.qfai/contracts/` _only when needed_.
33
+
34
+ ## Non‑Negotiable Principles (QFAI Articles)
35
+
36
+ These principles are inspired by “constitution / articles” patterns used by other agent frameworks, but tailored to QFAI.
37
+
38
+ 1. **SDD First (Specification is the source of truth)**
39
+ 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.
40
+
41
+ 2. **Traceability is mandatory**
42
+ Every meaningful change must be traceable: **Require → Spec → Scenario → Tests → Code → Verification evidence**.
43
+
44
+ 3. **Evidence over confidence**
45
+ Prefer observable proof (logs, commands, file diffs, test results). If you cannot verify, say so and record it.
46
+
47
+ 4. **Minimize scope, but never hide gaps**
48
+ Keep changes minimal, but do not “paper over” missing decisions. If something blocks correctness, stop and ask.
49
+
50
+ 5. **Quality gates are the decision mechanism**
51
+ Use tests/lint/typecheck/build/pack verification (whatever the repo defines) as the primary guardrail. Fix until PASS.
52
+
53
+ 6. **Make it runnable**
54
+ Outputs must be executable in terminal/CI. Provide copy‑paste commands.
55
+
56
+ 7. **User time is expensive**
57
+ Ask only the questions that are truly blocking. Everything else: make reasonable assumptions and label them clearly.
58
+
59
+ ## Absolute Rule — Output Language
60
+
61
+ **All outputs MUST be written in the user’s working language for this session.**
62
+
63
+ - If the user writes in Japanese, output Japanese.
64
+ - If the user writes in English, output English.
65
+ - If the user mixes languages, prefer the dominant language unless explicitly instructed otherwise.
66
+ This rule overrides all other stylistic preferences.
67
+
68
+ ## Multi‑Role Orchestration (Subagents)
69
+
70
+ This workflow assumes the environment _may_ support subagents (e.g., Claude Code “Task” tool) or may not.
71
+
72
+ ### If subagents are supported
73
+
74
+ Delegate to multiple roles and then merge the results. Use a “real‑world workflow” order:
75
+
76
+ - Facilitator → Interviewer → Requirements Analyst → Planner → Architect → (Contract Designer) → Test Engineer → QA Engineer → Code Reviewer → DevOps/CI Engineer
77
+
78
+ **Pseudo‑invocation pattern** (adjust to your tool):
79
+
80
+ ```text
81
+ Task(
82
+ subagent_type="planner",
83
+ description="Create an execution plan and DoD",
84
+ prompt="Context: ...\nGoal: ...\nConstraints: ...\nReturn: phases + risks + DoD"
85
+ )
86
+ ```
87
+
88
+ ### If subagents are NOT supported
89
+
90
+ Simulate roles by running the same sequence yourself:
91
+
92
+ - Write a short “role output” section per role, then consolidate into the final deliverable(s).
93
+
94
+ ## Step 0 — Load Context (always)
95
+
96
+ 1. Read relevant **project steering** (if present):
97
+ - `.qfai/assistant/steering/structure.md`
98
+ - `.qfai/assistant/steering/tech.md`
99
+ - `.qfai/assistant/steering/product.md`
100
+ - any additional files under `.qfai/assistant/steering/`
101
+
102
+ 2. Read **project constitution / instructions** (if present):
103
+ - `.qfai/assistant/instructions/constitution.md`
104
+ - `.qfai/assistant/instructions/workflow.md` (or equivalent)
105
+
106
+ 3. Read existing artifacts for the current work item (if present):
107
+ - `.qfai/require/`
108
+ - `.qfai/specs/spec-*/`
109
+ - `.qfai/contracts/`
110
+
111
+ 4. Inspect repo conventions:
112
+ - package manager (pnpm/npm/yarn), test runner, lint/typecheck scripts, CI definitions
113
+ - existing test patterns (unit/integration/e2e)
114
+
115
+ ## Step 0 — Project Analysis (mandatory)
116
+
117
+ Before producing any deliverable, **thoroughly analyze the current project** so your outputs fit the repo’s:
118
+
119
+ - background and goals
120
+ - directory structure and conventions
121
+ - chosen technologies and versions (runtime, package manager, test runner)
122
+ - architecture boundaries (packages, CLI, core modules)
123
+ - existing patterns for tests, docs, and CI
124
+
125
+ ### Minimum analysis checklist
126
+
127
+ - [ ] Read key repo docs: README / CHANGELOG / RELEASE (if present)
128
+ - [ ] Inspect `.qfai/` layout and existing SDD/ATDD/TDD artifacts (if present)
129
+ - [ ] Inspect `packages/qfai` structure (CLI entrypoints, core modules, validators, assets/init)
130
+ - [ ] Identify standard gate commands (format/lint/type/test/verify-pack) and where they are defined
131
+ - [ ] Search for existing examples/patterns of similar changes in tests (if available)
132
+ - [ ] Note constraints: Node versions, CI matrix, packaging rules, verify-pack expectations
133
+
134
+ If analysis cannot be performed (missing access), clearly state what could not be verified and proceed with minimal-risk assumptions.
135
+
136
+ ## Step 0.5 — Steering Bootstrap / Refresh (mandatory when incomplete)
137
+
138
+ QFAI expects `assistant/steering/` to contain **project‑specific facts** so all subsequent design/test/implementation fits this repository.
139
+
140
+ ### What to do
141
+
142
+ 1. Open these files:
143
+
144
+ - `.qfai/assistant/steering/product.md`
145
+ - `.qfai/assistant/steering/tech.md`
146
+ - `.qfai/assistant/steering/structure.md`
147
+
148
+ 2. If they are missing, mostly empty, or still have placeholders (e.g., `- ` only), **populate them by analyzing the current repository**:
149
+
150
+ - derive “what/why/users/success/non-goals” from README/docs/issues (product.md)
151
+ - derive runtime/tooling versions + constraints from package.json, CI config, lockfiles (tech.md)
152
+ - derive repo layout + key directories + gate commands from the file tree and scripts (structure.md)
153
+
154
+ 3. Do **not** invent facts. If something cannot be verified, write it as:
155
+
156
+ - `TBD` + what evidence is missing, or
157
+ - an Open Question (if it blocks correctness)
158
+
159
+ ### Steering refresh checklist
160
+
161
+ - [ ] product.md: what we build / users / success / non-goals / release posture
162
+ - [ ] tech.md: Node / package manager / TS / test / lint / CI constraints
163
+ - [ ] structure.md: repo layout, key packages, entrypoints, standard gate commands, how to run locally
164
+
165
+ ## Step 1 — Determine spec pack identity
166
+
167
+ If the user does not provide an ID:
168
+
169
+ - Propose the next available `spec-XXXX` and proceed (or ask if interactive).
170
+
171
+ ## Step 2 — Create/Update spec pack files
172
+
173
+ ### 2.1 `spec.md` template (Architect)
174
+
175
+ Use this structure:
176
+
177
+ # Spec: <title>
178
+
179
+ ## 1. Goal
180
+
181
+ ## 2. Non‑Goals
182
+
183
+ ## 3. Background / Context
184
+
185
+ ## 4. Requirements Mapping
186
+
187
+ Reference the requirement IDs from `.qfai/require/require.md`.
188
+
189
+ ## 5. Proposed Behavior
190
+
191
+ - User flows
192
+ - Inputs/outputs
193
+ - Error handling
194
+ - Observability
195
+
196
+ ## 6. Interfaces & Contracts
197
+
198
+ List which contracts are used:
199
+
200
+ - UI contracts: (file paths / IDs)
201
+ - API contracts:
202
+ - DB contracts:
203
+
204
+ If a contract is missing, mark it as “to be created” and create it in Step 3.
205
+
206
+ ## 7. Acceptance Criteria
207
+
208
+ Tie each acceptance criterion to scenarios and/or tests.
209
+
210
+ ## 8. Risks & Mitigations
211
+
212
+ ## 9. Open Questions
213
+
214
+ (only what truly blocks correctness)
215
+
216
+ ### 2.2 `delta.md` template (Planner + QA)
217
+
218
+ Use this structure:
219
+
220
+ # Delta
221
+
222
+ ## Summary
223
+
224
+ ## User-visible changes
225
+
226
+ ## Backward compatibility / migration notes
227
+
228
+ ## Affected areas
229
+
230
+ ## Verification plan (commands + expected results)
231
+
232
+ ## Rollback / recovery notes
233
+
234
+ ## Known limitations
235
+
236
+ ### 2.3 `scenario.feature` skeleton (Test Engineer)
237
+
238
+ Create a minimal but correct Gherkin skeleton aligned with acceptance criteria:
239
+
240
+ - Feature + Background
241
+ - 1–3 core scenarios
242
+ - Edge / failure scenarios as needed
243
+
244
+ ## Step 3 — Contracts (Contract Designer)
245
+
246
+ Only create contracts when the spec requires a stable interface definition.
247
+
248
+ - Place under:
249
+ - `.qfai/contracts/ui/`
250
+ - `.qfai/contracts/api/`
251
+ - `.qfai/contracts/db/`
252
+ - Keep them minimal and aligned with what tests will validate.
253
+
254
+ If your repo defines contract schema or naming rules, follow them. Otherwise:
255
+
256
+ - **UI / API contracts:** write **YAML** and include “Purpose / Fields / Constraints / Examples” as YAML comments.
257
+ - **DB contracts:** write **SQL (`.sql`)** and include a small header comment block, then representative DDL/schema notes.
258
+
259
+ DB contract default conventions (unless your repo defines others):
260
+
261
+ - Filename: `db-0001-<slug>.sql`
262
+ - Header (must):
263
+ ```sql
264
+ -- QFAI-CONTRACT-ID: DB-0001
265
+ -- Purpose: <what this schema contract guarantees>
266
+ -- Constraints: <keys, nullability, ranges, invariants>
267
+ -- Examples: <optional example rows or queries>
268
+ ```
269
+ - Body: DDL or schema notes that tests/scenarios can validate (minimal, spec-driven).
270
+
271
+ ## Step 4 — QA + Review
272
+
273
+ - QA Engineer checks acceptance criteria ↔ scenario consistency.
274
+ - Code Reviewer checks naming, contradictions, missing impact notes.
275
+ - Planner ensures next steps are explicit and minimal.
276
+
277
+ ## Step 5 — Approval gate
278
+
279
+ If interactive:
280
+
281
+ - Ask approval before proceeding to test implementation.
282
+ If `--auto`:
283
+ - Proceed with explicit assumptions flagged.
284
+
285
+ ## Output
286
+
287
+ - `.qfai/specs/spec-XXXX/spec.md`
288
+ - `.qfai/specs/spec-XXXX/delta.md`
289
+ - `.qfai/specs/spec-XXXX/scenario.feature`
290
+ - (If needed) updated `.qfai/contracts/**`
291
+ - Next recommended command: /qfai-scenario-test and/or /qfai-unit-test
@@ -0,0 +1,193 @@
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-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."
12
+ argument-hint: "<spec-id> [--auto]"
13
+ allowed-tools: [Read, Glob, Write, TodoWrite, Task, Bash]
14
+ roles: [TestEngineer, BackendEngineer, FrontendEngineer, QAEngineer, CodeReviewer]
15
+ mode: test-first
16
+
17
+ ---
18
+
19
+ # /qfai-unit-test — Implement Unit Tests (TDD)
20
+
21
+ ## Purpose
22
+
23
+ Implement **unit tests** that enforce the spec and provide fast feedback.
24
+
25
+ ## Success Criteria (Definition of Done)
26
+
27
+ - Unit tests exist, are deterministic, and runnable in CI.
28
+ - Tests cover core logic and key edge cases derived from spec/scenario.
29
+ - Tests fail meaningfully (actionable errors).
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 — Read relevant artifacts
163
+
164
+ - `.qfai/specs/spec-XXXX/spec.md`
165
+ - `.qfai/specs/spec-XXXX/scenario.feature`
166
+ - referenced contracts (if used by logic)
167
+
168
+ ## Step 2 — Identify units and boundaries (Test Engineer + Architect mindset)
169
+
170
+ - What are the smallest meaningful units?
171
+ - What should be mocked vs real?
172
+ - Where are seams (interfaces) needed to test cleanly?
173
+
174
+ ## Step 3 — Write tests first (RED)
175
+
176
+ - Add tests that should fail on current code.
177
+ - Keep them minimal and focused.
178
+
179
+ ## Step 4 — Review test quality
180
+
181
+ - QA Engineer: edge cases, unwanted behavior, observability
182
+ - Code Reviewer: brittleness, over-mocking, unclear naming
183
+
184
+ ## Step 5 — Provide run commands + evidence
185
+
186
+ - Document the exact command(s) to run unit tests.
187
+ - Provide summary of pass/fail.
188
+
189
+ ## Output
190
+
191
+ - Unit test files
192
+ - Run command snippet
193
+ - Evidence summary
@@ -0,0 +1,222 @@
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-verify
10
+ title: QFAI Verify (Quality Gates + Evidence)
11
+ description: "Run and document quality gates (repo + qfai validate/report), fix until PASS."
12
+ argument-hint: "[--auto]"
13
+ allowed-tools: [Read, Glob, Bash, Write, TodoWrite, Task]
14
+ roles: [DevOpsCIEngineer, QAEngineer, CodeReviewer, Planner]
15
+ mode: evidence-focused
16
+
17
+ ---
18
+
19
+ # /qfai-verify — Quality Gates and Evidence
20
+
21
+ ## Purpose
22
+
23
+ Run quality gates and produce **evidence** that the change is correct and safe.
24
+
25
+ ## Success Criteria (Definition of Done)
26
+
27
+ - Repo quality gates PASS (format/lint/type/test/build/etc).
28
+ - QFAI checks PASS (at minimum: `qfai validate`, and optionally `qfai report`).
29
+ - A concise evidence summary exists (copy‑paste for PR).
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 — Discover project gate commands (DevOps/CI Engineer)
163
+
164
+ Prefer existing scripts:
165
+
166
+ - package.json scripts
167
+ - Makefile / task runner
168
+ - CI config
169
+
170
+ If unknown, propose defaults and mark assumptions.
171
+
172
+ ## Step 2 — Run QFAI gates
173
+
174
+ Run (adjust as needed):
175
+
176
+ - `qfai validate --fail-on error`
177
+ - `qfai report` (if used in this repo)
178
+
179
+ Capture:
180
+
181
+ - exit codes
182
+ - key errors/warnings
183
+ - file paths affected
184
+
185
+ ## Step 3 — Run repo gates
186
+
187
+ Run the repo’s standard pipeline in a stable order:
188
+
189
+ 1. format
190
+ 2. lint
191
+ 3. typecheck
192
+ 4. unit tests
193
+ 5. scenario/e2e tests
194
+ 6. build/package (if relevant)
195
+
196
+ ## Step 4 — Fix loop (Code Reviewer + QA)
197
+
198
+ If anything fails:
199
+
200
+ - Identify whether it’s spec mismatch, test issue, or implementation defect.
201
+ - Fix the root cause (do not silence tests without reason).
202
+
203
+ ## Step 5 — Produce Evidence Summary (Planner)
204
+
205
+ Output this format:
206
+
207
+ ### Verification Evidence
208
+
209
+ - QFAI:
210
+ - command:
211
+ - result:
212
+ - Repo gates:
213
+ - command:
214
+ - result:
215
+ - Notes:
216
+ - assumptions:
217
+ - risks:
218
+
219
+ ## Output
220
+
221
+ - Evidence summary
222
+ - Next action suggestion: /qfai-pr (optional) or proceed to PR creation