sinapse-ai 1.15.0 → 1.17.0

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 (39) hide show
  1. package/.claude/hooks/doc-first-gate.cjs +156 -0
  2. package/.claude/hooks/enforce-story-gate.cjs +6 -2
  3. package/.claude/rules/hook-governance.md +1 -0
  4. package/.sinapse-ai/constitution.md +1 -1
  5. package/.sinapse-ai/core/atlas/atlas-data.js +278 -0
  6. package/.sinapse-ai/core/atlas/flows-pt.js +253 -0
  7. package/.sinapse-ai/core/atlas/flows.js +266 -0
  8. package/.sinapse-ai/core/atlas/index.js +62 -0
  9. package/.sinapse-ai/core/atlas/render-html.js +216 -0
  10. package/.sinapse-ai/core/atlas/render-markdown.js +313 -0
  11. package/.sinapse-ai/core/atlas/render-research-card.js +164 -0
  12. package/.sinapse-ai/core/orchestration/build-command.js +136 -0
  13. package/.sinapse-ai/core/orchestration/doc-first-resolver.js +322 -0
  14. package/.sinapse-ai/core/orchestration/route-command.js +97 -0
  15. package/.sinapse-ai/data/entity-registry.yaml +113 -16
  16. package/.sinapse-ai/development/agents/snps-orqx.md +9 -0
  17. package/.sinapse-ai/development/tasks/create-doc.md +1 -1
  18. package/.sinapse-ai/development/tasks/create-next-story.md +2 -3
  19. package/.sinapse-ai/development/tasks/spec-analyze.md +460 -0
  20. package/.sinapse-ai/development/tasks/spec-clarify.md +374 -0
  21. package/.sinapse-ai/development/tasks/spec-gather-requirements.md +11 -0
  22. package/.sinapse-ai/development/templates/approval-table.md +106 -0
  23. package/.sinapse-ai/development/workflows/spec-pipeline.yaml +122 -7
  24. package/.sinapse-ai/install-manifest.yaml +70 -18
  25. package/.sinapse-ai/product/templates/prd-tmpl.yaml +6 -2
  26. package/.sinapse-ai/product/templates/spec-tmpl.md +18 -0
  27. package/AGENTS.md +1 -1
  28. package/CHANGELOG.md +18 -3
  29. package/bin/sinapse.js +121 -0
  30. package/docs/framework/atlas/OPERATING-ATLAS.md +537 -0
  31. package/docs/framework/atlas/README.md +34 -0
  32. package/docs/framework/atlas/atlas-data.json +2810 -0
  33. package/docs/framework/atlas/atlas.html +392 -0
  34. package/package.json +1 -1
  35. package/packages/installer/src/wizard/ide-config-generator.js +6 -0
  36. package/scripts/install-chrome-brain.sh +2 -2
  37. package/scripts/validate-no-personal-leaks.js +24 -9
  38. package/squads/squad-copy/knowledge-base/consequence-headline-patterns.md +2 -2
  39. package/docs/guides/hooks-two-layers.md +0 -66
@@ -0,0 +1,374 @@
1
+ # Spec Pipeline: Clarify Specification
2
+
3
+ > **Phase:** 4b - Clarify
4
+ > **Owner Agent:** @project-lead
5
+ > **Pipeline:** spec-pipeline
6
+
7
+ ---
8
+
9
+ ## Purpose
10
+
11
+ Desambiguar a especificação ANTES do QA gate e do plano. Roda DEPOIS de `write` (spec escrita)
12
+ e ANTES de `critique`. Varre o `spec.md` por uma taxonomia de 9 categorias de cobertura, faz no
13
+ máximo 5 perguntas guiadas por (Impacto × Incerteza) — uma de cada vez — e integra cada resposta
14
+ atomicamente no `spec.md`. Sub-especificação descoberta tarde é o retrabalho mais caro do pipeline;
15
+ o clarify ataca isso cedo, perguntando apenas o que muda decisão downstream.
16
+
17
+ ---
18
+
19
+ ## autoClaude
20
+
21
+ ```yaml
22
+ autoClaude:
23
+ version: '3.0'
24
+ pipelinePhase: spec-clarify
25
+
26
+ elicit: true # Interactive - asks the user clarifying questions
27
+ deterministic: false # Output depends on user answers
28
+ composable: true
29
+
30
+ selfCritique:
31
+ required: false
32
+
33
+ inputs:
34
+ - name: storyId
35
+ type: string
36
+ required: true
37
+
38
+ - name: spec
39
+ type: file
40
+ path: docs/stories/{storyId}/spec/spec.md
41
+ required: true
42
+
43
+ - name: requirements
44
+ type: file
45
+ path: docs/stories/{storyId}/spec/requirements.json
46
+ required: false
47
+
48
+ outputs:
49
+ - name: spec.md
50
+ type: file
51
+ path: docs/stories/{storyId}/spec/spec.md
52
+ mutation: append # Adds/updates the `## Clarifications` section + target sections
53
+
54
+ verification:
55
+ type: gate
56
+ blocking: false # Skippable with explicit rework-risk warning
57
+ completion_field: clarificationComplete
58
+
59
+ contextRequirements:
60
+ projectContext: true
61
+ filesContext: true
62
+ implementationPlan: false
63
+ spec: true
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Coverage Taxonomy (9 categories)
69
+
70
+ Varra o `spec.md` e marque cada categoria como **Clear / Partial / Missing**. Perguntas só nascem
71
+ de categorias `Partial` ou `Missing` cujo esclarecimento muda uma decisão downstream.
72
+
73
+ ```yaml
74
+ taxonomy:
75
+ - id: tax-1
76
+ name: 'Functional Scope & Behavior'
77
+ looks_for: 'Core actions, in/out of scope, behavioral edges'
78
+
79
+ - id: tax-2
80
+ name: 'Domain & Data Model'
81
+ looks_for: 'Entities, attributes, relationships, identity, lifecycle/state'
82
+
83
+ - id: tax-3
84
+ name: 'Interaction & UX Flow'
85
+ looks_for: 'Steps, states, error/empty states, accessibility intent'
86
+
87
+ - id: tax-4
88
+ name: 'Non-Functional Quality Attributes'
89
+ looks_for: 'Performance, scale, latency, availability, security targets (quantified)'
90
+
91
+ - id: tax-5
92
+ name: 'Integration & External Dependencies'
93
+ looks_for: 'External services, APIs, contracts, failure modes of integrations'
94
+
95
+ - id: tax-6
96
+ name: 'Edge Cases & Failure Handling'
97
+ looks_for: 'Boundary conditions, invalid input, partial failure, recovery'
98
+
99
+ - id: tax-7
100
+ name: 'Constraints & Tradeoffs'
101
+ looks_for: 'Hard constraints, rejected alternatives, explicit tradeoffs'
102
+
103
+ - id: tax-8
104
+ name: 'Terminology & Consistency'
105
+ looks_for: 'Consistent naming, no synonym drift, defined glossary terms'
106
+
107
+ - id: tax-9
108
+ name: 'Completion Signals'
109
+ looks_for: 'Measurable done criteria, acceptance signals, Success Criteria present'
110
+
111
+ - id: tax-misc
112
+ name: 'Misc / Signals'
113
+ looks_for: 'TODO / ??? placeholders, unquantified adjectives (fast/scalable/secure), [NEEDS CLARIFICATION] markers'
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Question Selection (Impact × Uncertainty)
119
+
120
+ ```yaml
121
+ selection:
122
+ heuristic: 'Impact × Uncertainty'
123
+
124
+ rule: |
125
+ Only include questions whose answers materially impact architecture, data modeling,
126
+ task decomposition, test design, UX behavior, operational readiness, or compliance
127
+ validation. Discard cosmetic questions that do not change a downstream decision.
128
+
129
+ prioritize:
130
+ - High impact + high uncertainty (ask first)
131
+ - High impact + medium uncertainty
132
+ discard:
133
+ - Low impact (any uncertainty)
134
+ - Already Clear in the taxonomy scan
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Question Format
140
+
141
+ ```yaml
142
+ question_format:
143
+ max_questions: 5
144
+ one_at_a_time: true # Ask, wait for answer, integrate, then next
145
+
146
+ styles:
147
+ - type: multiple_choice
148
+ options: '2 to 5 mutually exclusive options'
149
+ include_recommendation: true # Mark the recommended option
150
+ - type: short_answer
151
+ constraint: 'answer in <= 5 words'
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Integration (atomic)
157
+
158
+ Cada resposta é integrada IMEDIATAMENTE antes da próxima pergunta — registro + aplicação na seção-alvo.
159
+
160
+ ```yaml
161
+ integration:
162
+ log_section:
163
+ create_if_missing: '## Clarifications'
164
+ subsection: '### Session {YYYY-MM-DD}'
165
+ entry_format: '- Q: {question} -> A: {answer}'
166
+
167
+ apply_change:
168
+ description: 'Apply the answer to the target section of the spec'
169
+ targets:
170
+ - Functional Requirements (FR-*)
171
+ - Key Entities / Data Model
172
+ - Success Criteria (SC-*)
173
+ - Edge Cases
174
+ - Constraints (CON-*)
175
+ rule: 'Never log an answer without applying it to the target section'
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Stop Criteria
181
+
182
+ ```yaml
183
+ stop_when:
184
+ any_of:
185
+ - 'All critical ambiguities resolved'
186
+ - 'User says proceed / done / skip'
187
+ - 'Reached 5 questions'
188
+ - 'No critical ambiguity detected in the taxonomy scan (zero questions is valid)'
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Gate
194
+
195
+ ```yaml
196
+ gate:
197
+ order: 'Run (and complete) clarify BEFORE the plan phase'
198
+ blocking: false
199
+
200
+ on_skip:
201
+ allowed: true
202
+ required_action: |
203
+ Warn explicitly: downstream rework risk increases when clarification is skipped.
204
+ message: |
205
+ ⚠️ Skipping clarification. Ambiguities in the spec may surface during plan/implement,
206
+ increasing rework cost. Proceeding at user request.
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Execution Flow
212
+
213
+ ### Step 1: Scan Coverage
214
+
215
+ ```yaml
216
+ scan:
217
+ action: scan_spec_against_taxonomy
218
+ for_each: category in taxonomy
219
+ process: |
220
+ 1. Read spec.md
221
+ 2. Mark category Clear / Partial / Missing
222
+ 3. Note specific gap location (section)
223
+ ```
224
+
225
+ ### Step 2: Select Questions
226
+
227
+ ```yaml
228
+ select:
229
+ action: rank_by_impact_uncertainty
230
+ process: |
231
+ 1. Build candidate questions from Partial/Missing categories
232
+ 2. Apply the materially-impacts filter (discard cosmetic)
233
+ 3. Rank by Impact x Uncertainty
234
+ 4. Cap the queue at 5
235
+ ```
236
+
237
+ ### Step 3: Ask & Integrate Loop
238
+
239
+ ```yaml
240
+ ask_loop:
241
+ for_each: question in selected (max 5)
242
+ process: |
243
+ 1. Ask ONE question (multiple-choice 2-5 opts w/ recommendation, OR short answer <=5 words)
244
+ 2. Wait for the answer
245
+ 3. Append `- Q: ... -> A: ...` under `## Clarifications` / `### Session {date}`
246
+ 4. Apply the answer to the target spec section
247
+ 5. Re-check stop criteria; break if met
248
+ ```
249
+
250
+ ### Step 4: Finalize
251
+
252
+ ```yaml
253
+ finalize:
254
+ action: confirm_clarification_complete
255
+ process: |
256
+ 1. Ensure every asked question was both logged AND applied
257
+ 2. Set clarificationComplete = true
258
+ 3. Hand off to critique
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Integration
264
+
265
+ ### Command Integration (@project-lead)
266
+
267
+ ```yaml
268
+ command:
269
+ name: '*clarify-spec'
270
+ syntax: '*clarify-spec {story-id}'
271
+ agent: pm
272
+
273
+ examples:
274
+ - '*clarify-spec STORY-42'
275
+ ```
276
+
277
+ ### Pipeline Integration
278
+
279
+ ```yaml
280
+ pipeline:
281
+ phase: clarify
282
+ previous_phase: spec
283
+ next_phase: critique
284
+
285
+ requires:
286
+ - spec.md
287
+
288
+ optional:
289
+ - requirements.json
290
+
291
+ gate: true # Order gate: complete before plan
292
+ blocking: false # Skippable with rework-risk warning
293
+
294
+ pass_to_next:
295
+ - spec.md
296
+ ```
297
+
298
+ ---
299
+
300
+ ## Error Handling
301
+
302
+ ```yaml
303
+ errors:
304
+ - id: missing-spec
305
+ condition: 'spec.md not found'
306
+ action: 'Halt - cannot clarify without a spec'
307
+ blocking: true
308
+
309
+ - id: no-ambiguity
310
+ condition: 'Taxonomy scan finds zero critical ambiguities'
311
+ action: 'Skip questions, set clarificationComplete=true, proceed to critique'
312
+ blocking: false
313
+
314
+ - id: user-defers
315
+ condition: 'User declines to answer / says proceed'
316
+ action: 'Warn of rework risk, set clarificationComplete=false, proceed'
317
+ blocking: false
318
+ ```
319
+
320
+ ---
321
+
322
+ ## Examples
323
+
324
+ ### Example: Clarify a vague NFR
325
+
326
+ **Input:** spec.md says "the endpoint should be fast" (tax-4 = Partial, unquantified adjective)
327
+
328
+ **Interaction:**
329
+
330
+ ```
331
+ Q: What is the acceptable p95 latency for the endpoint?
332
+ A) < 100ms B) < 300ms (recommended) C) < 1s D) No target needed
333
+ A: B
334
+ ```
335
+
336
+ **Spec mutation:**
337
+
338
+ ```markdown
339
+ ## Clarifications
340
+
341
+ ### Session 2026-06-24
342
+
343
+ - Q: What is the acceptable p95 latency for the endpoint? → A: < 300ms (p95)
344
+
345
+ <!-- and NFR section updated: -->
346
+ | Category | Requirement | Target |
347
+ | ----------- | ------------------------ | ------------- |
348
+ | Performance | Endpoint response (p95) | < 300ms |
349
+ ```
350
+
351
+ ---
352
+
353
+ ## Metadata
354
+
355
+ ```yaml
356
+ metadata:
357
+ story: '3.4b'
358
+ epic: 'Epic 3 - Spec Pipeline'
359
+ created: '2026-06-24'
360
+ author: '@project-lead (Axis)'
361
+ version: '1.0.0'
362
+ source: 'GitHub Spec Kit — templates/commands/clarify.md'
363
+ tags:
364
+ - spec-pipeline
365
+ - clarify
366
+ - ambiguity
367
+ - elicitation
368
+ - product-lead
369
+ ```
370
+
371
+ ## Handoff
372
+ next_agent: @quality-gate
373
+ next_command: *critique-spec {story-id}
374
+ condition: Clarification complete (no critical ambiguities open) OR user proceeds with rework-risk warning
@@ -302,6 +302,17 @@ structuring:
302
302
 
303
303
  ---
304
304
 
305
+ ### Phase 5: Present for Approval
306
+
307
+ After structuring `requirements.json`, present the gathered requirements back to the user as
308
+ scannable **approval tables** following `.sinapse-ai/development/templates/approval-table.md`
309
+ (Requirements schema) — one table for Functional (`| ID | Description | Priority | Source |`),
310
+ one for Non-Functional (`| ID | Category | Requirement | Metric/Target |`), and one for
311
+ Constraints when present. Lead with the verdict header (`── REQUIREMENTS REVIEW · {n} item(s) · status: DRAFT ──`).
312
+ Do NOT report only the count (e.g. "8 FR, 3 NFR") — the user must see and approve the actual rows.
313
+
314
+ ---
315
+
305
316
  ## Output Schema
306
317
 
307
318
  ```json
@@ -0,0 +1,106 @@
1
+ # Approval Table — Shared Terminal Presentation Convention
2
+
3
+ > **Reusable presentation protocol.** Any task that asks the user to review or approve a
4
+ > set of artifacts (requirements, epics, stories, tasks, risks, open questions) MUST render
5
+ > them through this convention BEFORE asking for a decision. This is the single source of
6
+ > truth for "scannable terminal table + verdict", so the experience is identical across
7
+ > PRD, epic, story, and spec flows. Do not duplicate ad-hoc formats per task — reference
8
+ > this file.
9
+
10
+ ## Why this exists
11
+
12
+ Lists decided during planning (FRs, NFRs, epics, stories) used to be reported as counts or
13
+ prose ("✅ 8 FR, 3 NFR"). That forces the user to open a file to actually review. This
14
+ convention renders the real items as a scannable table the user can approve row by row,
15
+ right in the terminal. Output language follows the project's language (PT-BR for the user
16
+ when applicable); the schemas below are language-agnostic.
17
+
18
+ ## The protocol (3 parts, always in this order)
19
+
20
+ 1. **Verdict header** — one scannable line stating what is being reviewed and the current
21
+ status. Format:
22
+ ```
23
+ ── {ARTIFACT} REVIEW · {n} item(s) · status: {DRAFT|READY|APPROVED|NEEDS REVISION} ──
24
+ ```
25
+ 2. **The table** — render the items using the matching schema below. Keep it scannable:
26
+ one row per item, truncate long cells to ~60 chars with `…`, never wrap a cell across
27
+ lines. Use the priority/severity emoji legend when the schema has one.
28
+ 3. **The decision prompt** — after the table, ask for the decision in the form the calling
29
+ task requires (the 1-9 elicitation menu, or a GO / NO-GO, or `[GO] [PAUSE] [REVISE] [ABORT]`).
30
+ Never ask for approval without showing the table first.
31
+
32
+ ## Standard schemas
33
+
34
+ Use the schema that matches the artifact. Add/trim columns only when the data genuinely
35
+ requires it — keep the core columns stable so the experience is consistent.
36
+
37
+ ### Requirements (gather / spec)
38
+ ```
39
+ | ID | Description | Priority | Source |
40
+ | ----- | ------------------------------------ | -------- | ----------------- |
41
+ | FR-1 | {functional requirement} | 🔴 P0 | requirements.json |
42
+
43
+ | ID | Category | Requirement | Metric / Target |
44
+ | ----- | ----------- | ------------------------ | ----------------- |
45
+ | NFR-1 | {category} | {non-functional req} | {measurable} |
46
+
47
+ | ID | Type | Constraint | Impact |
48
+ | ----- | -------- | ------------------------ | ----------------- |
49
+ | CON-1 | {type} | {constraint} | {impact} |
50
+ ```
51
+
52
+ ### Epic list (PRD epic-list approval)
53
+ ```
54
+ | # | Epic | Goal (1 line) | Stories |
55
+ | -- | ----------------------------- | ------------------------------------- | ------- |
56
+ | 1 | Foundation & Core Infra | {one-sentence goal} | ~{n} |
57
+ ```
58
+
59
+ ### Epic detail — stories within an epic
60
+ ```
61
+ | Story | As a … / I want … | ACs | Depends on |
62
+ | ----- | --------------------------------- | --- | ---------- |
63
+ | 1.1 | {user} wants {action} | {n} | — |
64
+ ```
65
+
66
+ ### Story summary (create / validate story)
67
+ ```
68
+ | Field | Value |
69
+ | ------------ | ------------------------------------------------ |
70
+ | Story | {epicNum}.{storyNum} — {title} |
71
+ | Status | {Draft \| Ready \| InProgress \| Done} |
72
+ | Acceptance | {n} criteria |
73
+ | Tasks | {n} (linked to AC: {list}) |
74
+ | Dependencies | {list or —} |
75
+
76
+ | AC# | Criterion | Tasks |
77
+ | --- | ------------------------------------------ | ---------- |
78
+ | 1 | {given/when/then} | T1, T3 |
79
+ ```
80
+
81
+ ### Risks & open questions (spec / plan)
82
+ ```
83
+ | Risk | Probability | Impact | Mitigation |
84
+ | --------------- | ------------- | ------------- | ----------------- |
85
+ | {risk} | 🟢/🟡/🔴 | 🟢/🟡/🔴 | {mitigation} |
86
+
87
+ | ID | Question | Blocking | Assigned To |
88
+ | ---- | ------------------------- | -------- | ----------- |
89
+ | OQ-1 | {open question} | Yes / No | @{agent} |
90
+ ```
91
+
92
+ ## Legends
93
+
94
+ - **Priority:** 🔴 P0 (must) · 🟠 P1 (should) · 🟡 P2 (could) · 🟢 P3 (won't-now)
95
+ - **Severity / level:** 🔴 High · 🟡 Medium · 🟢 Low
96
+ - **Status glyphs (optional inline):** ✓ done · ● in progress · ○ pending · ✗ blocked
97
+
98
+ ## Rules
99
+
100
+ - Always render the table for a list ≥ 2 items. For a single item, a compact field table is
101
+ still preferred over prose.
102
+ - The table is in addition to writing the artifact file — never replace the file, and never
103
+ replace the table with a count.
104
+ - Keep within terminal width: prefer fewer, tighter columns over a wide table that wraps.
105
+ - When iterating (NEEDS REVISION), re-render the full table with the changed rows marked
106
+ (prefix the changed cell with `» `), so the user sees what moved.