@haposoft/cafekit 0.9.1 → 0.9.3
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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/claude/hooks/state.cjs +22 -5
- package/src/claude/skills/brainstorm/SKILL.md +23 -6
- package/src/claude/skills/brainstorm/references/question-framework.md +232 -0
- package/src/claude/skills/specs/SKILL.md +11 -0
- package/src/claude/skills/specs/references/ask-user-question-gates.md +61 -0
- package/src/claude/skills/specs/rules/phase-decision-matrix.md +55 -0
- package/src/claude/skills/specs/rules/task-scoring-rubric.md +52 -0
- package/src/claude/skills/specs/rules/tasks-generation.md +13 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Claude Code-first spec-driven workflow and runtime bundle for AI coding assistants.
|
|
4
4
|
|
|
5
|
-
[](https://github.com/haposoft/cafekit)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://claude.ai/code)
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haposoft/cafekit",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Claude Code-first spec-driven workflow for AI coding assistants. Bundles CafeKit hapo: skills, runtime hooks, agents, and installer scaffolding.",
|
|
5
5
|
"author": "Haposoft <nghialt@haposoft.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,8 @@ try {
|
|
|
26
26
|
|
|
27
27
|
const EXPIRY_DAYS = 7;
|
|
28
28
|
const MAX_ARCHIVES = 5;
|
|
29
|
+
const MAX_AGENT_SECTIONS = 3;
|
|
30
|
+
const MAX_MODIFIED_FILES_DISPLAY = 5;
|
|
29
31
|
const TRACKED_POST_TOOL_EVENTS = new Set(['Task', 'TaskCreate', 'TaskUpdate', 'TodoWrite']);
|
|
30
32
|
|
|
31
33
|
function stateDir(cwd) {
|
|
@@ -126,7 +128,7 @@ try {
|
|
|
126
128
|
}).trim();
|
|
127
129
|
|
|
128
130
|
if (diff) {
|
|
129
|
-
data.modifiedFiles = diff.split('\n').slice(0,
|
|
131
|
+
data.modifiedFiles = diff.split('\n').slice(0, MAX_MODIFIED_FILES_DISPLAY);
|
|
130
132
|
}
|
|
131
133
|
} catch {
|
|
132
134
|
// fail-open
|
|
@@ -157,27 +159,40 @@ try {
|
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
function buildAgentSection(data) {
|
|
160
|
-
const agentType = data.agent_type || '
|
|
162
|
+
const agentType = data.agent_type || '';
|
|
163
|
+
if (!agentType || agentType === 'unknown') return '';
|
|
161
164
|
const time = new Date().toISOString().slice(11, 19);
|
|
162
165
|
return `\n## Agent Result: ${agentType} (${time})\n- Completed at ${time}\n`;
|
|
163
166
|
}
|
|
164
167
|
|
|
168
|
+
function takeRecentAgentSections(sections) {
|
|
169
|
+
if (!Array.isArray(sections) || sections.length <= MAX_AGENT_SECTIONS) return sections || [];
|
|
170
|
+
return sections.slice(-MAX_AGENT_SECTIONS);
|
|
171
|
+
}
|
|
172
|
+
|
|
165
173
|
function mergeAgentSections(existing, content) {
|
|
166
174
|
if (!existing) return content;
|
|
167
175
|
|
|
168
176
|
const agentSections = existing.match(/## Agent Result:.+?(?=\n## |$)/gs);
|
|
169
177
|
if (!agentSections) return content;
|
|
170
178
|
|
|
179
|
+
const kept = takeRecentAgentSections(agentSections);
|
|
171
180
|
const marker = '\n## Key Files Modified';
|
|
172
181
|
if (content.includes(marker)) {
|
|
173
|
-
return content.replace(marker, `\n${
|
|
182
|
+
return content.replace(marker, `\n${kept.join('\n')}${marker}`);
|
|
174
183
|
}
|
|
175
184
|
|
|
176
|
-
return `${content.trimEnd()}\n\n${
|
|
185
|
+
return `${content.trimEnd()}\n\n${kept.join('\n')}\n`;
|
|
177
186
|
}
|
|
178
187
|
|
|
179
188
|
function appendAgentSection(existing, agentSection) {
|
|
180
189
|
if (!existing) return agentSection.trimStart();
|
|
190
|
+
if (!agentSection) {
|
|
191
|
+
const sections = existing.match(/## Agent Result:.+?(?=\n## |$)/gs) || [];
|
|
192
|
+
if (sections.length <= MAX_AGENT_SECTIONS) return existing;
|
|
193
|
+
const kept = takeRecentAgentSections(sections);
|
|
194
|
+
return existing.replace(/(## Agent Result:.+?(?=\n## |$))+/gs, kept.join('\n'));
|
|
195
|
+
}
|
|
181
196
|
|
|
182
197
|
const marker = '\n## Key Files Modified';
|
|
183
198
|
if (existing.includes(marker)) {
|
|
@@ -226,8 +241,10 @@ try {
|
|
|
226
241
|
}
|
|
227
242
|
|
|
228
243
|
if (event === 'SubagentStop') {
|
|
229
|
-
const file = path.join(dir, 'latest.md');
|
|
230
244
|
const agentSection = buildAgentSection(data);
|
|
245
|
+
if (!agentSection) process.exit(0);
|
|
246
|
+
|
|
247
|
+
const file = path.join(dir, 'latest.md');
|
|
231
248
|
const existing = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
|
|
232
249
|
const updated = existing
|
|
233
250
|
? appendAgentSection(existing, agentSection)
|
|
@@ -69,17 +69,30 @@ Leverage these specific tools or sub-agents to execute the workflow effectively:
|
|
|
69
69
|
- `brainstormer`: Call only for medium/high-complexity architecture trade-offs.
|
|
70
70
|
- **Ecosystem Swarm (`SendMessage`):** Call `researcher` (validation), `docs-keeper` (architecture boundaries), or `project-manager` (scope warnings) for deeply complex specs.
|
|
71
71
|
|
|
72
|
+
## Discovery Question Framework
|
|
73
|
+
|
|
74
|
+
Load and follow `references/question-framework.md` before the first user-facing discovery question.
|
|
75
|
+
|
|
76
|
+
Use it to:
|
|
77
|
+
- Generate questions from scout evidence, user intent, exact requirement gaps, matching domain matrices, and risk surfaces.
|
|
78
|
+
- Avoid asking the user to answer technical facts that should be verified from code, docs, or current provider/browser documentation.
|
|
79
|
+
- Prioritize only questions that can materially change architecture, MVP scope, UX, cost/privacy/security, acceptance criteria, or delivery format.
|
|
80
|
+
- Record every user-confirmed decision in a decision register in the final report.
|
|
81
|
+
|
|
82
|
+
If the framework conflicts with the general "one question at a time" rule, prefer the framework's question budget and batching limits: one high-impact question by default, up to 3 independent questions in one `AskUserQuestion` call only when batching reduces friction without mixing unrelated decisions.
|
|
83
|
+
|
|
72
84
|
## Authoritative Workflow
|
|
73
85
|
|
|
74
86
|
```mermaid
|
|
75
87
|
flowchart TD
|
|
76
88
|
A["Run /hapo:inspect or narrow scout"] --> B["Summarize codebase findings"]
|
|
77
|
-
B --> C["
|
|
78
|
-
C -->
|
|
79
|
-
D
|
|
89
|
+
B --> C["Load question framework"]
|
|
90
|
+
C --> DQ["Ask highest-impact grounded question"]
|
|
91
|
+
DQ --> D{"Exact requirements captured?"}
|
|
92
|
+
D -->|No| DQ
|
|
80
93
|
D -->|Yes| E{"Multiple independent subsystems?"}
|
|
81
94
|
E -->|Yes| F["Decompose into sub-projects"]
|
|
82
|
-
F -->
|
|
95
|
+
F --> DQ
|
|
83
96
|
E -->|No| G{"Medium/high complexity?"}
|
|
84
97
|
G -->|Yes| H["Call brainstormer/researcher/docs-keeper as needed"]
|
|
85
98
|
G -->|No| I["Propose 2-3 approaches"]
|
|
@@ -107,10 +120,14 @@ flowchart TD
|
|
|
107
120
|
|
|
108
121
|
### 2. Discovery Phase
|
|
109
122
|
|
|
110
|
-
-
|
|
123
|
+
- Load `references/question-framework.md`.
|
|
124
|
+
- Ask exactly **one high-impact question at a time** by default. Do not stack unrelated questions.
|
|
125
|
+
- You may batch up to 3 independent questions only when each question maps to a different required decision surface and none requires explanation before the user can answer.
|
|
111
126
|
- Prefer multiple-choice options grounded in scout findings.
|
|
112
127
|
- Push vague intent into concrete examples, sample inputs/outputs, or acceptance criteria.
|
|
113
128
|
- Challenge the first proposed solution when the underlying goal suggests a simpler path.
|
|
129
|
+
- Do not ask users to decide technical facts. Research browser/runtime/provider/package facts first; then ask only the product or trade-off decision.
|
|
130
|
+
- Track decisions as you go so the final report can distinguish `User Decision`, `Assumption`, and `Open Question`.
|
|
114
131
|
|
|
115
132
|
### 3. Scope Guard
|
|
116
133
|
|
|
@@ -154,7 +171,7 @@ Before passing the completed design to the user for final review, you must inter
|
|
|
154
171
|
### 8. Final Handoff & Documentation
|
|
155
172
|
Upon the user's explicit final approval of the sanitized design document:
|
|
156
173
|
1. Generate the final **Design Doc / Summary Report**.
|
|
157
|
-
2. Include: problem statement, exact requirements, evaluated approaches, recommended solution, risks, validation criteria, and next steps.
|
|
174
|
+
2. Include: problem statement, exact requirements, evaluated approaches, recommended solution, risks, validation criteria, decision register, open questions, and next steps.
|
|
158
175
|
3. Invoke `/hapo:specs` with the report context to hand off into CafeKit's structured specification phase.
|
|
159
176
|
4. Optionally update an existing project notes, docs, or report file if the approved design context should be persisted for future work.
|
|
160
177
|
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Brainstorm Question Framework
|
|
2
|
+
|
|
3
|
+
Use this reference to decide **what to ask**, **what not to ask**, and **how to record decisions** during `hapo:brainstorm`.
|
|
4
|
+
|
|
5
|
+
The goal is not to ask many questions. The goal is to ask the smallest set of questions that can materially change the design.
|
|
6
|
+
|
|
7
|
+
## Source Hierarchy
|
|
8
|
+
|
|
9
|
+
Generate questions from this hierarchy, in order:
|
|
10
|
+
|
|
11
|
+
1. **Scout evidence** — repo type, framework, existing modules, docs, specs, plans, runtime config, and constraints.
|
|
12
|
+
2. **User intent** — nouns, verbs, success language, target users, examples, and implied deliverables in the prompt.
|
|
13
|
+
3. **Exact requirement gaps** — expected output, acceptance criteria, scope boundary, non-negotiable constraints, touchpoints.
|
|
14
|
+
4. **Domain matrix** — only domains that actually apply to the request.
|
|
15
|
+
5. **Risk matrix** — security, privacy, cost, runtime limits, provider failure, migration, compliance, maintainability.
|
|
16
|
+
|
|
17
|
+
Never ask a question that the repository, docs, or trusted technical research can answer directly.
|
|
18
|
+
|
|
19
|
+
## Ask / Do Not Ask
|
|
20
|
+
|
|
21
|
+
Ask the user when the answer changes:
|
|
22
|
+
|
|
23
|
+
- product scope or MVP boundaries
|
|
24
|
+
- target user workflow or UX surface
|
|
25
|
+
- expected output artifact or delivery format
|
|
26
|
+
- acceptance criteria
|
|
27
|
+
- business priority, timeline, or rollout
|
|
28
|
+
- cost, privacy, API-key ownership, external provider choice
|
|
29
|
+
- irreversible workspace action such as renaming/moving/deleting
|
|
30
|
+
- whether to accept a trade-off after you explain it
|
|
31
|
+
|
|
32
|
+
Do **not** ask the user when the answer is a technical fact you should verify:
|
|
33
|
+
|
|
34
|
+
- browser or runtime limits
|
|
35
|
+
- package/API compatibility
|
|
36
|
+
- dependency maintenance state
|
|
37
|
+
- security best practice
|
|
38
|
+
- exact syntax for framework config
|
|
39
|
+
- existing code location, schema, endpoint, or convention
|
|
40
|
+
|
|
41
|
+
If a topic mixes user preference and technical fact, verify the technical facts first, then ask the preference question with those facts included.
|
|
42
|
+
|
|
43
|
+
## Prioritization
|
|
44
|
+
|
|
45
|
+
Before asking, score each candidate question:
|
|
46
|
+
|
|
47
|
+
| Signal | Score |
|
|
48
|
+
|---|---:|
|
|
49
|
+
| Could change architecture, data model, or platform | +3 |
|
|
50
|
+
| Could change MVP scope or exclude a feature | +3 |
|
|
51
|
+
| Could affect cost, privacy, security, or compliance | +3 |
|
|
52
|
+
| Defines observable acceptance criteria | +2 |
|
|
53
|
+
| Defines UX flow or primary user surface | +2 |
|
|
54
|
+
| Can be answered from repo/docs/research | -4 |
|
|
55
|
+
| Merely names an implementation detail with a safe default | -2 |
|
|
56
|
+
|
|
57
|
+
Ask only the highest-impact question. If several are tied and independent, ask at most 3 in one `AskUserQuestion` batch; otherwise ask one at a time.
|
|
58
|
+
|
|
59
|
+
## Required Decision Surfaces
|
|
60
|
+
|
|
61
|
+
Every brainstorm must eventually resolve these surfaces:
|
|
62
|
+
|
|
63
|
+
| Surface | Question Intent |
|
|
64
|
+
|---|---|
|
|
65
|
+
| Outcome | What does the user expect to exist or happen after the work? |
|
|
66
|
+
| Done | How will the user verify it works? |
|
|
67
|
+
| Scope | What is explicitly not included now? |
|
|
68
|
+
| Constraints | What cannot change: stack, platform, naming, runtime, compatibility, deadline? |
|
|
69
|
+
| Touchpoints | Which existing files/modules/contracts will this affect? |
|
|
70
|
+
|
|
71
|
+
If any surface is missing, ask a grounded question before proposing architecture.
|
|
72
|
+
|
|
73
|
+
## Domain Matrix
|
|
74
|
+
|
|
75
|
+
Use only the domains that match the request.
|
|
76
|
+
|
|
77
|
+
### Product / UX
|
|
78
|
+
|
|
79
|
+
Ask when the prompt includes UI, workflow, dashboard, extension, app, or user-facing behavior.
|
|
80
|
+
|
|
81
|
+
- Primary user: who uses this first?
|
|
82
|
+
- Primary flow: what is the shortest successful path?
|
|
83
|
+
- Surface: page, overlay, sidebar, modal, command, background task?
|
|
84
|
+
- State: loading, empty, error, partial result, retry?
|
|
85
|
+
- Accessibility or localization expectations?
|
|
86
|
+
|
|
87
|
+
### Browser Extension
|
|
88
|
+
|
|
89
|
+
Ask when the work involves Chrome, Edge, Firefox, YouTube, DOM injection, content scripts, popup, options page, or browser APIs.
|
|
90
|
+
|
|
91
|
+
- Target browser/runtime and manifest version?
|
|
92
|
+
- UI surface: content overlay, sidebar, popup, options page, or all?
|
|
93
|
+
- Permissions posture: minimal host permissions or broader convenience?
|
|
94
|
+
- Storage: browser storage, IndexedDB, sync storage, or no persistence?
|
|
95
|
+
- Publishing target: dev-only, Chrome Web Store, enterprise install?
|
|
96
|
+
|
|
97
|
+
Verify instead of asking:
|
|
98
|
+
|
|
99
|
+
- Manifest V3 service worker lifetime.
|
|
100
|
+
- Browser-reserved shortcut conflicts.
|
|
101
|
+
- Content script isolated-world vs main-world behavior.
|
|
102
|
+
- Current Chrome API compatibility.
|
|
103
|
+
|
|
104
|
+
### AI / LLM
|
|
105
|
+
|
|
106
|
+
Ask when the work involves translation, summarization, agents, prompt output, generation, or provider choice.
|
|
107
|
+
|
|
108
|
+
- Provider ownership: user API key, app-owned key, proxy, or local model?
|
|
109
|
+
- Provider shape: fixed provider, multi-provider, or custom base URL?
|
|
110
|
+
- Output contract: prose, JSON, markdown, SRT, code, patch?
|
|
111
|
+
- Failure behavior: retry, fallback, partial result, ask user, or stop?
|
|
112
|
+
- Cache policy: never, per session, persistent, or shared?
|
|
113
|
+
- Privacy boundary: what content may leave the browser/server?
|
|
114
|
+
|
|
115
|
+
Verify instead of asking:
|
|
116
|
+
|
|
117
|
+
- Whether a provider is Anthropic-compatible vs OpenAI-compatible.
|
|
118
|
+
- Whether a provider supports tool use / JSON schema / streaming.
|
|
119
|
+
- Current API endpoint paths and auth header format.
|
|
120
|
+
|
|
121
|
+
### Data / Transcript / Documents
|
|
122
|
+
|
|
123
|
+
Ask when the work transforms documents, captions, data, logs, OCR, audio, video, or legacy code into another artifact.
|
|
124
|
+
|
|
125
|
+
- Source priority and fallback order?
|
|
126
|
+
- Output format and fidelity level?
|
|
127
|
+
- Confidence / evidence tracking requirement?
|
|
128
|
+
- Missing/unknown handling?
|
|
129
|
+
- Export/import requirements?
|
|
130
|
+
|
|
131
|
+
### Backend / API / Database
|
|
132
|
+
|
|
133
|
+
Ask when the work includes server endpoints, persistence, auth, jobs, integrations, or migrations.
|
|
134
|
+
|
|
135
|
+
- API contract: endpoint, method, request/response shape?
|
|
136
|
+
- Persistence: new table, existing table, no DB?
|
|
137
|
+
- Auth/permission model?
|
|
138
|
+
- Idempotency, retries, and background job behavior?
|
|
139
|
+
- Migration and rollback constraints?
|
|
140
|
+
|
|
141
|
+
### Docs / Legacy Reconstruction
|
|
142
|
+
|
|
143
|
+
Ask when the work is documentation, legacy analysis, or requirement reconstruction.
|
|
144
|
+
|
|
145
|
+
- Scope path/module to reconstruct?
|
|
146
|
+
- Output docs required: overview, requirements, architecture, evidence map, unknowns?
|
|
147
|
+
- Evidence level: observed-only or inferred allowed with confidence?
|
|
148
|
+
- Review gate: who approves the reconstructed docs?
|
|
149
|
+
- Change request follows reconstruction or is separate?
|
|
150
|
+
|
|
151
|
+
### Release / Packaging
|
|
152
|
+
|
|
153
|
+
Ask when the work includes publish, store listing, npm release, versioning, or deployment.
|
|
154
|
+
|
|
155
|
+
- Target release channel?
|
|
156
|
+
- Version bump type?
|
|
157
|
+
- Required checks before publish?
|
|
158
|
+
- Store/listing metadata ownership?
|
|
159
|
+
- Rollback or deprecation plan?
|
|
160
|
+
|
|
161
|
+
## Question Format
|
|
162
|
+
|
|
163
|
+
Use `AskUserQuestion` when available.
|
|
164
|
+
|
|
165
|
+
- Use 2-4 concrete options.
|
|
166
|
+
- Put the recommended option first and label it `(Recommended)`.
|
|
167
|
+
- Include a one-sentence impact description per option.
|
|
168
|
+
- Do not add an explicit "Other" option; the tool supplies it.
|
|
169
|
+
- Avoid abstract labels like "Option A" unless paired with concrete meaning.
|
|
170
|
+
|
|
171
|
+
Good:
|
|
172
|
+
|
|
173
|
+
> "Where should transcript fallback live?"
|
|
174
|
+
> - "Defer STT for MVP (Recommended)" — Ships faster; no fragile audio extraction now.
|
|
175
|
+
> - "Browser-only STT" — No backend, but fragile and heavy.
|
|
176
|
+
> - "Companion backend" — More robust, but requires hosting and ops.
|
|
177
|
+
|
|
178
|
+
Bad:
|
|
179
|
+
|
|
180
|
+
> "What architecture do you want?"
|
|
181
|
+
|
|
182
|
+
## Explain Before Asking
|
|
183
|
+
|
|
184
|
+
When the user cannot reasonably know the answer, first explain the trade-off briefly, then ask.
|
|
185
|
+
|
|
186
|
+
Use this pattern:
|
|
187
|
+
|
|
188
|
+
1. State why the decision matters.
|
|
189
|
+
2. Give 2-3 viable options with consequences.
|
|
190
|
+
3. Recommend one.
|
|
191
|
+
4. Ask the user to confirm or override.
|
|
192
|
+
|
|
193
|
+
Do not force a choice before explaining hidden technical risk.
|
|
194
|
+
|
|
195
|
+
## Decision Register
|
|
196
|
+
|
|
197
|
+
Every final brainstorm report must include a decision register.
|
|
198
|
+
|
|
199
|
+
```markdown
|
|
200
|
+
## Decision Register
|
|
201
|
+
|
|
202
|
+
| ID | Question | Options Presented | User Decision | Rationale | Impact |
|
|
203
|
+
|---|---|---|---|---|---|
|
|
204
|
+
| D-001 | Where does transcript fallback live? | Defer STT / Browser-only / Backend | Defer STT | Ships MVP safely | Phase 7 becomes graceful fallback |
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Rules:
|
|
208
|
+
|
|
209
|
+
- Record only decisions actually made by the user or explicitly accepted in chat.
|
|
210
|
+
- Do not write "user selected" unless `AskUserQuestion` or direct user text confirms it.
|
|
211
|
+
- If you infer a default, label it as `Assumption`, not `User Decision`.
|
|
212
|
+
- Carry unresolved decisions into `Open Questions`.
|
|
213
|
+
|
|
214
|
+
## Maximum Question Budget
|
|
215
|
+
|
|
216
|
+
Default budget:
|
|
217
|
+
|
|
218
|
+
- Small change: 1-2 questions.
|
|
219
|
+
- Medium feature: 3-6 questions.
|
|
220
|
+
- Large/greenfield/architecture-heavy: 6-10 questions across multiple rounds.
|
|
221
|
+
|
|
222
|
+
Stop asking when the next question would only refine an implementation detail with a safe default. Propose the design and list remaining assumptions instead.
|
|
223
|
+
|
|
224
|
+
## Final Self-Check
|
|
225
|
+
|
|
226
|
+
Before presenting design:
|
|
227
|
+
|
|
228
|
+
- Did each asked question map to one of the required decision surfaces or domain risks?
|
|
229
|
+
- Did any question ask the user to answer a technical fact that should have been researched?
|
|
230
|
+
- Are all user decisions captured in the decision register?
|
|
231
|
+
- Are assumptions clearly separated from user decisions?
|
|
232
|
+
- Are open questions truly blocking, or can they be deferred?
|
|
@@ -184,6 +184,7 @@ flowchart TD
|
|
|
184
184
|
## Detailed Workflow
|
|
185
185
|
|
|
186
186
|
### Step 1: Analyze Description
|
|
187
|
+
- Load `references/ask-user-question-gates.md` before asking user questions. Ask only at documented gates; do not ask questions that repo evidence or official/current docs can answer.
|
|
187
188
|
- Assess clarity and complexity of the description
|
|
188
189
|
- Route to `hapo:brainstorm` before creating files when:
|
|
189
190
|
- the expected output or acceptance criteria are not concrete
|
|
@@ -209,6 +210,7 @@ Load: `references/cross-spec-dependency.md`
|
|
|
209
210
|
|
|
210
211
|
### Step 3: Complexity Assessment & Scope Inquiry
|
|
211
212
|
Load: `references/scope-inquiry.md`
|
|
213
|
+
- Also load `references/ask-user-question-gates.md` when scope, evidence, contract, or architecture decisions require user input.
|
|
212
214
|
- Evaluate the request across **5 dimensions**: Semantic Intent, Implementation Hypothesis, Gap Sizing, Risk/Uncertainty (Cynefin), and Blast Radius
|
|
213
215
|
- If Risk = **Chaotic** → exit spec workflow, redirect to `hapo:hotfix`
|
|
214
216
|
- If Risk = **Complex** → include spike/prototype tasks in the spec
|
|
@@ -252,6 +254,8 @@ Load: `references/scope-inquiry.md`
|
|
|
252
254
|
- Read `spec.json` — stop if requirements haven't completed
|
|
253
255
|
- Pick discovery mode: `minimal` / `light` / `full` based on complexity. **Default: `light`** unless certain it is simple UI (minimal) or complex integration (full).
|
|
254
256
|
- Load `rules/design-principles.md`
|
|
257
|
+
- Load `rules/phase-decision-matrix.md` to define implementation slices, task clusters, foundation boundaries, spike needs, integration gates, and verification gates before task generation.
|
|
258
|
+
- Load `references/ask-user-question-gates.md` if a design decision would change scope, contract, provider/platform, or implementation safety.
|
|
255
259
|
- Load `rules/design-discovery-[mode].md`:
|
|
256
260
|
- **minimal**: UI-only or simple CRUD
|
|
257
261
|
- **light**: extending existing system
|
|
@@ -267,6 +271,9 @@ Load: `references/scope-inquiry.md`
|
|
|
267
271
|
- Read `spec.json` — stop if `requirements.md` or `design.md` missing
|
|
268
272
|
- Respect `scope_lock` — only use valid requirement IDs within `in_scope`
|
|
269
273
|
- Load `rules/tasks-generation.md` for core principles
|
|
274
|
+
- Load `rules/phase-decision-matrix.md` before generating task files. Treat "phase" as an implementation slice/task cluster, not a `phase-XX.md` artifact.
|
|
275
|
+
- Load `rules/task-scoring-rubric.md` for every candidate task to decide priority, split/merge, spike needs, dependencies, parallel eligibility, and evidence depth.
|
|
276
|
+
- Load `references/ask-user-question-gates.md`; if scoring reveals unapproved scope expansion or an unresolved user-owned choice, pause before writing task files.
|
|
270
277
|
- Load `rules/tasks-parallel-analysis.md` for parallel markers (default: enabled)
|
|
271
278
|
- Each task file follows template `templates/task.md`
|
|
272
279
|
- `Related Files` and test plans must inherit paths, contracts, and test targets from the codebase scout. If exact files/tests cannot be named for an enhancement, run targeted inspect before generating tasks.
|
|
@@ -345,6 +352,7 @@ Load: `references/task-hydration.md`
|
|
|
345
352
|
|
|
346
353
|
### Step 9: Validation Review (Optional)
|
|
347
354
|
Load: `references/review.md` + `rules/design-review.md`
|
|
355
|
+
- Load `references/ask-user-question-gates.md` before applying validation or red-team changes. User approval is required when findings modify approved scope, requirements, canonical contracts, design decisions, or task behavior.
|
|
348
356
|
- System auto-evaluates spec complexity and decides review depth:
|
|
349
357
|
- **< 3 task files, no security concerns** → Validate only (lightweight interview)
|
|
350
358
|
- **>= 5 task files OR security/migration keywords** → Red Team first, then Validate
|
|
@@ -551,10 +559,13 @@ Before finalizing any specification, assert all the following:
|
|
|
551
559
|
- `design-discovery-full.md` — Full research workflow
|
|
552
560
|
- `design-discovery-light.md` — Lightweight research workflow
|
|
553
561
|
- `design-review.md` — Design review GO/NO-GO process
|
|
562
|
+
- `phase-decision-matrix.md` — Implementation slice/task-cluster boundary rules
|
|
554
563
|
- `tasks-generation.md` — Task generation rules (includes spike task rules)
|
|
555
564
|
- `tasks-parallel-analysis.md` — Parallel task analysis
|
|
565
|
+
- `task-scoring-rubric.md` — Task priority, split/merge, spike, dependency, and evidence-depth scoring
|
|
556
566
|
|
|
557
567
|
### References (`references/`)
|
|
568
|
+
- `ask-user-question-gates.md` — AskUserQuestion gate matrix for user-owned decisions
|
|
558
569
|
- `cross-spec-dependency.md` — Cross-spec dependency detection
|
|
559
570
|
- `scope-inquiry.md` — 5-Dimension Complexity Assessment (Semantic, Hypothesis, Gap, Risk/Cynefin, Blast Radius)
|
|
560
571
|
- `research-strategy.md` — Research strategy (7 tools)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# AskUserQuestion Gate Matrix
|
|
2
|
+
|
|
3
|
+
Use this matrix to decide when `hapo:specs` must pause for user input. Ask only when the answer changes scope, architecture, requirements, task shape, validation disposition, or implementation safety.
|
|
4
|
+
|
|
5
|
+
## Source Priority
|
|
6
|
+
|
|
7
|
+
Resolve uncertainty in this order:
|
|
8
|
+
|
|
9
|
+
1. Existing `spec.json`, `requirements.md`, `research.md`, `design.md`, and task files.
|
|
10
|
+
2. Codebase evidence from targeted scout/inspect.
|
|
11
|
+
3. Official/current external docs when platform/provider behavior matters.
|
|
12
|
+
4. Reasonable default from CafeKit rules.
|
|
13
|
+
5. `AskUserQuestion` only when the remaining decision is user-owned.
|
|
14
|
+
|
|
15
|
+
Do not ask about facts that codebase or official docs can answer.
|
|
16
|
+
|
|
17
|
+
## Gate Matrix
|
|
18
|
+
|
|
19
|
+
| Gate | Trigger | Ask? | Question shape | Record in |
|
|
20
|
+
|---|---|---:|---|---|
|
|
21
|
+
| Operation | `/hapo:specs` called without args | Yes | Choose create/status/resume/validate/archive | none |
|
|
22
|
+
| Active spec | In-progress or branch-matched spec exists | Yes | Continue existing vs create new | `spec.json` if changed |
|
|
23
|
+
| Pre-spec clarity | Description lacks concrete output, actor, or acceptance signal | Yes | 1-2 clarifying questions | `spec.json.scope_lock` |
|
|
24
|
+
| Brainstorm routing | 2+ plausible architectures and no approved direction | Yes | Route to brainstorm vs continue minimal spec | final response / `research.md` |
|
|
25
|
+
| Scope inquiry | Non-trivial task after 5D assessment | Yes | Expand / Hold / Reduce | `spec.json.scope_lock` |
|
|
26
|
+
| Evidence gap | Required evidence is unavailable after targeted research | Yes | Continue with explicit risk / run more scout / narrow scope | `research.md` |
|
|
27
|
+
| Architecture tie | Two approaches are materially similar after evidence | Yes | Pick approach with recommended option first | `design.md` |
|
|
28
|
+
| Contract change | Auth, persistence, provider, API, CLI, schema, permissions, or runtime contract changes | Yes if user intent not explicit | Confirm contract and rollback expectations | `design.md` canonical contracts |
|
|
29
|
+
| Scope expansion | A task candidate adds work not in `scope_lock` | Yes | Approve expansion / defer / reject | `spec.json.scope_lock` + affected docs |
|
|
30
|
+
| High-risk spike | Risk = Complex and spike may change deliverables | Yes if cost/scope impact > 4h | Spike now / reduce / defer | `research.md` + task file |
|
|
31
|
+
| Task conflict | Parallel candidate shares files/contracts with another task | No by default | Resolve sequentially unless business deadline requires parallelization | task dependencies |
|
|
32
|
+
| Validation findings | Red-team/validate findings modify approved scope/design/tasks | Yes | Apply accepted / review each / reject all | `reports/red-team-report.md` or validation log |
|
|
33
|
+
| Final contradiction | Whole-spec sweep finds unresolved contradiction | Yes | Choose authoritative source/decision | affected docs + `spec.json` |
|
|
34
|
+
|
|
35
|
+
## Question Format
|
|
36
|
+
|
|
37
|
+
Every `AskUserQuestion` must:
|
|
38
|
+
|
|
39
|
+
- Ask 1-3 questions max per pause.
|
|
40
|
+
- Provide 2-3 concrete options.
|
|
41
|
+
- Put recommended option first and suffix label with `(Recommended)`.
|
|
42
|
+
- Explain the tradeoff in one sentence per option.
|
|
43
|
+
- Include an implicit free-form "Other" option when the tool supports it.
|
|
44
|
+
|
|
45
|
+
## Do Not Ask
|
|
46
|
+
|
|
47
|
+
Do not ask when:
|
|
48
|
+
|
|
49
|
+
- The answer is discoverable via repo files, tests, docs, or official/current docs.
|
|
50
|
+
- The choice is pure implementation detail with no scope/user impact.
|
|
51
|
+
- The task can safely use an existing codebase convention.
|
|
52
|
+
- The question exists only to avoid making a normal engineering judgment.
|
|
53
|
+
|
|
54
|
+
## Recording Rules
|
|
55
|
+
|
|
56
|
+
After a user answer:
|
|
57
|
+
|
|
58
|
+
- Update the artifact that drives implementation, not only a report.
|
|
59
|
+
- Keep exact selected option and custom free text when provided.
|
|
60
|
+
- Add unresolved questions at the end of the affected document.
|
|
61
|
+
- Do not mark `ready_for_implementation = true` while a blocking question remains unresolved.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Phase Decision Matrix
|
|
2
|
+
|
|
3
|
+
CafeKit does not create `phase-XX.md` files. In `hapo:specs`, "phase" means an implementation slice or task cluster that becomes one or more `tasks/task-R*.md` files.
|
|
4
|
+
|
|
5
|
+
Use this matrix after `requirements.md` and `design.md` exist, before generating task files.
|
|
6
|
+
|
|
7
|
+
## Slice Types
|
|
8
|
+
|
|
9
|
+
| Slice | Use when | Output pattern | Must prove |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| R0 Foundation | Shared setup, contracts, schema, config, base runtime, permissions, package wiring | `task-R0-01-<slug>.md` | Later tasks depend on it or explicitly consume it |
|
|
12
|
+
| Risk Spike | Risk = Complex, API/platform behavior uncertain, or feasibility not proven by evidence | `task-R{N}-00-spike-<slug>.md` | Go/no-go, findings, time-box <= 4h |
|
|
13
|
+
| Vertical Slice | User-visible behavior crosses multiple layers but can be delivered end-to-end | `task-R{N}-01-<feature-slice>.md` | Runtime entrypoint reaches the behavior |
|
|
14
|
+
| Layer Slice | Work naturally splits by layer and dependencies are clear | `task-R{N}-01-api.md`, `task-R{N}-02-ui.md` | Contract handoff between layers |
|
|
15
|
+
| Cross-Cutting Slice | One concern affects many requirements, e.g. language handling, privacy, error policy | One primary task plus secondary requirement refs in related tasks | No duplicated implementation across tasks |
|
|
16
|
+
| Integration Gate | Prior outputs must be wired into a route, app, command, worker, extension manifest, or runtime surface | Final task in dependency chain | No orphaned services/components/files |
|
|
17
|
+
| Verification Gate | Security/performance/migration/critical path needs dedicated proof | Dedicated task only when proof cannot live inside related task | Exact command/artifact/negative-path evidence |
|
|
18
|
+
| Release/Packaging | Store/package/release behavior is explicitly in scope | Last task | Build artifact and release-specific checks |
|
|
19
|
+
|
|
20
|
+
## Selection Rules
|
|
21
|
+
|
|
22
|
+
1. Start with requirement IDs and design contracts.
|
|
23
|
+
2. Extract shared infrastructure into R0 only when 2+ later tasks consume it or a contract must exist first.
|
|
24
|
+
3. Prefer vertical slices for user-facing workflows because they prove reachability early.
|
|
25
|
+
4. Use layer slices when one layer blocks another or file ownership would conflict.
|
|
26
|
+
5. Add a spike before implementation when evidence says the outcome is uncertain.
|
|
27
|
+
6. Add an integration gate for every feature with runtime-facing outputs.
|
|
28
|
+
7. Add a verification gate only when the required proof is too broad for a single implementation task.
|
|
29
|
+
8. Do not create a slice just because the plan "feels large"; every slice needs a deliverable boundary.
|
|
30
|
+
|
|
31
|
+
## Split / Merge Signals
|
|
32
|
+
|
|
33
|
+
Split into separate task files when:
|
|
34
|
+
|
|
35
|
+
- Acceptance criteria span multiple architectural layers.
|
|
36
|
+
- Effort exceeds 4 hours.
|
|
37
|
+
- A task would modify unrelated files or contracts.
|
|
38
|
+
- One part can be verified independently before the next part starts.
|
|
39
|
+
- Different agents could own the work without touching the same files.
|
|
40
|
+
|
|
41
|
+
Merge when:
|
|
42
|
+
|
|
43
|
+
- Work touches the same files and cannot be verified separately.
|
|
44
|
+
- A task would only wrap another task with no independent deliverable.
|
|
45
|
+
- Splitting would create orphaned support code before integration.
|
|
46
|
+
|
|
47
|
+
## Output Requirements
|
|
48
|
+
|
|
49
|
+
Before writing task files, capture the chosen slices in working notes and ensure:
|
|
50
|
+
|
|
51
|
+
- Every slice maps to at least one requirement ID or R0 foundation rationale.
|
|
52
|
+
- Every runtime-facing slice names its entrypoint or later integration task.
|
|
53
|
+
- Every dependency is explicit.
|
|
54
|
+
- Every parallel-capable slice has no shared file ownership with sibling tasks.
|
|
55
|
+
- Scope additions route through `references/ask-user-question-gates.md`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Task Scoring Rubric
|
|
2
|
+
|
|
3
|
+
Use this rubric after applying the Phase Decision Matrix and before writing each task file. The score determines priority, split/merge, spike needs, dependency shape, and evidence depth.
|
|
4
|
+
|
|
5
|
+
## Score Each Candidate Task
|
|
6
|
+
|
|
7
|
+
Score each dimension 0-3.
|
|
8
|
+
|
|
9
|
+
| Dimension | 0 | 1 | 2 | 3 |
|
|
10
|
+
|---|---|---|---|---|
|
|
11
|
+
| Dependency criticality | Standalone | Depends on one task | Blocks one feature slice | Blocks many tasks or core runtime |
|
|
12
|
+
| Implementation risk | Routine | Known pattern, minor edge cases | Complex logic or integration | Unproven behavior, migration, security, provider/platform uncertainty |
|
|
13
|
+
| Blast radius | Isolated file | Feature-local files | Shared component/API/config | Auth, data layer, routing, permissions, package export, or critical path |
|
|
14
|
+
| User value | Internal cleanup | Enables later work | User-visible improvement | Core acceptance criterion or launch blocker |
|
|
15
|
+
| Evidence confidence | Proven by code/tests/docs | Mostly proven | Partial evidence | Low/no evidence |
|
|
16
|
+
| Testability burden | Simple unit/smoke | Component/integration | Multi-step workflow | E2E/security/performance/rollback proof required |
|
|
17
|
+
| File conflict risk | No overlap | Minor shared utility | Shared module with consumers | Same files as another task or cross-agent conflict likely |
|
|
18
|
+
| Scope creep risk | Fully in scope | Small interpretation | Adds adjacent behavior | Adds unapproved feature/contract |
|
|
19
|
+
|
|
20
|
+
## Interpret Score
|
|
21
|
+
|
|
22
|
+
| Total | Priority | Action |
|
|
23
|
+
|---:|---|---|
|
|
24
|
+
| 0-6 | P3 | Keep compact. Merge if no independent proof exists. |
|
|
25
|
+
| 7-12 | P2 | Normal task. Include explicit dependencies and evidence. |
|
|
26
|
+
| 13-18 | P1 | High attention. Consider split, stronger evidence, and validation note. |
|
|
27
|
+
| 19+ | P1 critical | Split or add spike. Do not mark parallel unless file ownership is isolated. |
|
|
28
|
+
|
|
29
|
+
## Mandatory Overrides
|
|
30
|
+
|
|
31
|
+
- If Scope creep risk = 3, stop and use `AskUserQuestion` before generating the task.
|
|
32
|
+
- If Evidence confidence = 3 and Implementation risk >= 2, create a spike task first.
|
|
33
|
+
- If Blast radius = 3, include rollback/negative-path proof in `Evidence`.
|
|
34
|
+
- If File conflict risk >= 2, remove `(P)` unless ownership is explicitly separated.
|
|
35
|
+
- If User value = 3 and Dependency criticality >= 2, schedule early unless blocked by foundation work.
|
|
36
|
+
|
|
37
|
+
## Task Metadata Decisions
|
|
38
|
+
|
|
39
|
+
- `priority`: from total score plus overrides.
|
|
40
|
+
- `dependencies`: list every required predecessor task file.
|
|
41
|
+
- `(P)` marker: allowed only when dependency and file conflict scores are <= 1 and design boundaries do not overlap.
|
|
42
|
+
- `Evidence`: choose proof type from `tasks-generation.md` Test Type Selection table; increase proof depth for high scores.
|
|
43
|
+
- `Risk Assessment`: include all dimensions scored 2-3 as risks or constraints.
|
|
44
|
+
|
|
45
|
+
## Compact Output
|
|
46
|
+
|
|
47
|
+
Do not write the raw score table into every task file. Use the rubric to shape task content. Surface only decisions that affect implementation:
|
|
48
|
+
|
|
49
|
+
- why task is P1/P2/P3
|
|
50
|
+
- why it is split/merged
|
|
51
|
+
- why it is or is not parallel
|
|
52
|
+
- why a spike or extra proof is required
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Core Principles
|
|
4
4
|
|
|
5
|
+
### 0. Pre-Generation Decision Gates
|
|
6
|
+
|
|
7
|
+
Before writing any `tasks/task-R*.md` file:
|
|
8
|
+
|
|
9
|
+
1. Load `phase-decision-matrix.md` and identify implementation slices/task clusters: R0 foundation, risk spikes, vertical slices, layer slices, cross-cutting slices, integration gates, verification gates, and release/packaging slices when in scope.
|
|
10
|
+
2. Load `task-scoring-rubric.md` and score each candidate task. Use the result to choose priority, split/merge, spike needs, dependencies, parallel eligibility, and evidence depth.
|
|
11
|
+
3. Load `../references/ask-user-question-gates.md` if scoring or slicing detects unapproved scope expansion, unresolved architecture tie, missing evidence, contract ambiguity, or final contradiction.
|
|
12
|
+
4. Do not ask about facts that targeted scout, repo files, tests, or official/current docs can answer.
|
|
13
|
+
|
|
14
|
+
The raw score table does not need to appear in each task file. The task file must reflect the decisions: why the task exists, what it depends on, why it is split/merged, whether it can be parallel, and what proof is required.
|
|
15
|
+
|
|
5
16
|
### 1. Natural Language Descriptions
|
|
6
17
|
Focus on capabilities and outcomes, not code structure.
|
|
7
18
|
|
|
@@ -71,6 +82,7 @@ When splitting a requirement into multiple tasks:
|
|
|
71
82
|
2. **Split by concern** — e.g., R3-01 for consent onboarding UI, R3-02 for consent version re-check logic
|
|
72
83
|
3. **Split by dependency chain** — if acceptance criteria A must finish before B can start, they belong in separate task files with explicit `Dependencies:`
|
|
73
84
|
4. **Never split by arbitrary size** — don't create 3 task files just because "3 feels right"
|
|
85
|
+
5. **Use the Phase Decision Matrix** — only split when the implementation slice has an independent deliverable boundary or proof path.
|
|
74
86
|
|
|
75
87
|
#### Cross-cutting requirements
|
|
76
88
|
Some requirements (e.g., "language handling", "error handling") naturally touch code in many other requirements' tasks. For these:
|
|
@@ -86,6 +98,7 @@ Grouping tasks vertically by requirement carries the risk of "siloed" or fragmen
|
|
|
86
98
|
2. **Shared Interfaces (Horizontal Contracts)**: Sub-tasks that touch shared cross-requirement architecture (like registering a new page in a global `router.ts` or adding a column to a shared table) MUST explicitly reference the shared contract defined in `design.md`.
|
|
87
99
|
3. **Integration Enforcers**: If R1 and R2 interact (e.g., R2 UI displays data fetched by R1 backend), the later task MUST have a sub-task explicitly dedicated to "Wiring/Integrating with [Previous Feature] output".
|
|
88
100
|
4. **Final Runtime Integration**: For any feature that has a user-facing screen, public route, CLI command, background worker, browser extension surface, or API flow, create a final integration task (or a final integration section in the last dependent task) that proves the whole scoped feature works from its runtime entrypoint. This task MUST fail if prior-task outputs exist but are not imported, mounted, registered, or invoked.
|
|
101
|
+
5. **Scored Sequencing**: Use `task-scoring-rubric.md` to schedule high-value/high-dependency tasks early, but only after required foundation/spike work. High file-conflict or high blast-radius tasks must not be marked `(P)` without isolated ownership.
|
|
89
102
|
|
|
90
103
|
### 3d. Spike Tasks for Complex/Uncertain Areas (MANDATORY)
|
|
91
104
|
|