buildanything 2.0.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +9 -1
  3. package/README.md +57 -61
  4. package/agents/a11y-architect.md +2 -0
  5. package/agents/briefing-officer.md +172 -0
  6. package/agents/business-model.md +14 -12
  7. package/agents/code-architect.md +6 -1
  8. package/agents/code-reviewer.md +3 -2
  9. package/agents/code-simplifier.md +12 -4
  10. package/agents/design-brand-guardian.md +19 -0
  11. package/agents/design-critic.md +16 -11
  12. package/agents/design-inclusive-visuals-specialist.md +2 -0
  13. package/agents/design-ui-designer.md +17 -0
  14. package/agents/design-ux-architect.md +15 -0
  15. package/agents/design-ux-researcher.md +102 -7
  16. package/agents/engineering-ai-engineer.md +2 -0
  17. package/agents/engineering-backend-architect.md +2 -0
  18. package/agents/engineering-data-engineer.md +2 -0
  19. package/agents/engineering-devops-automator.md +2 -0
  20. package/agents/engineering-frontend-developer.md +13 -0
  21. package/agents/engineering-mobile-app-builder.md +2 -0
  22. package/agents/engineering-rapid-prototyper.md +15 -2
  23. package/agents/engineering-security-engineer.md +2 -0
  24. package/agents/engineering-senior-developer.md +13 -0
  25. package/agents/engineering-sre.md +2 -0
  26. package/agents/engineering-technical-writer.md +2 -0
  27. package/agents/feature-intel.md +8 -7
  28. package/agents/ios-app-review-guardian.md +2 -0
  29. package/agents/ios-foundation-models-specialist.md +2 -0
  30. package/agents/ios-product-reality-auditor.md +292 -0
  31. package/agents/ios-storekit-specialist.md +2 -0
  32. package/agents/ios-swift-architect.md +1 -0
  33. package/agents/ios-swift-search.md +1 -0
  34. package/agents/ios-swift-ui-design.md +7 -4
  35. package/agents/marketing-app-store-optimizer.md +2 -0
  36. package/agents/planner.md +6 -1
  37. package/agents/pr-test-analyzer.md +3 -2
  38. package/agents/product-feedback-synthesizer.md +62 -0
  39. package/agents/product-owner.md +163 -0
  40. package/agents/product-reality-auditor.md +216 -0
  41. package/agents/product-spec-writer.md +176 -0
  42. package/agents/refactor-cleaner.md +9 -1
  43. package/agents/security-reviewer.md +2 -1
  44. package/agents/silent-failure-hunter.md +2 -1
  45. package/agents/swift-build-resolver.md +2 -0
  46. package/agents/swift-reviewer.md +2 -1
  47. package/agents/tech-feasibility.md +5 -3
  48. package/agents/testing-api-tester.md +2 -0
  49. package/agents/testing-evidence-collector.md +24 -0
  50. package/agents/testing-performance-benchmarker.md +2 -0
  51. package/agents/testing-reality-checker.md +2 -1
  52. package/agents/visual-research.md +7 -5
  53. package/bin/adapters/scribe-tool.ts +4 -2
  54. package/bin/adapters/write-lease-tool.ts +1 -1
  55. package/bin/buildanything-runtime.ts +20 -107
  56. package/bin/graph-index.js +24 -0
  57. package/bin/graph-index.ts +340 -0
  58. package/bin/mcp-servers/graph-mcp.js +26 -0
  59. package/bin/mcp-servers/graph-mcp.ts +481 -0
  60. package/bin/mcp-servers/orchestrator-mcp.js +26 -0
  61. package/bin/mcp-servers/orchestrator-mcp.ts +361 -0
  62. package/bin/setup.js +272 -111
  63. package/commands/build.md +424 -177
  64. package/commands/idea-sweep.md +2 -2
  65. package/commands/setup.md +15 -4
  66. package/commands/ux-review.md +3 -3
  67. package/commands/verify.md +3 -0
  68. package/docs/migration/phase-graph.yaml +573 -157
  69. package/hooks/design-md-lint +4 -0
  70. package/hooks/design-md-lint.ts +295 -0
  71. package/hooks/pre-tool-use.ts +37 -6
  72. package/hooks/record-mode-transitions.ts +63 -6
  73. package/hooks/subagent-start.ts +3 -2
  74. package/package.json +3 -1
  75. package/protocols/agent-prompt-authoring.md +165 -0
  76. package/protocols/architecture-schema.md +10 -3
  77. package/protocols/cleanup.md +4 -0
  78. package/protocols/decision-log.md +8 -4
  79. package/protocols/design-md-authoring.md +520 -0
  80. package/protocols/design-md-spec.md +362 -0
  81. package/protocols/fake-data-detector.md +1 -1
  82. package/protocols/ios-fake-data-detector.md +65 -0
  83. package/protocols/ios-phase-branches.md +128 -43
  84. package/protocols/launch-readiness.md +9 -5
  85. package/protocols/metric-loop.md +1 -1
  86. package/protocols/page-spec-schema.md +234 -0
  87. package/protocols/product-spec-schema.md +354 -0
  88. package/protocols/sprint-tasks-schema.md +53 -0
  89. package/protocols/state-schema.json +38 -3
  90. package/protocols/state-schema.md +32 -2
  91. package/protocols/verify.md +29 -1
  92. package/protocols/web-phase-branches.md +246 -76
  93. package/skills/ios/ios-bootstrap/SKILL.md +1 -1
  94. package/src/graph/ids.ts +86 -0
  95. package/src/graph/index.ts +32 -0
  96. package/src/graph/parser/architecture.ts +603 -0
  97. package/src/graph/parser/component-manifest.ts +268 -0
  98. package/src/graph/parser/decisions-jsonl.ts +407 -0
  99. package/src/graph/parser/design-md-pass2.ts +253 -0
  100. package/src/graph/parser/design-md.ts +477 -0
  101. package/src/graph/parser/page-spec.ts +496 -0
  102. package/src/graph/parser/product-spec.ts +930 -0
  103. package/src/graph/parser/screenshot.ts +342 -0
  104. package/src/graph/parser/sprint-tasks.ts +317 -0
  105. package/src/graph/storage/index.ts +1154 -0
  106. package/src/graph/types.ts +432 -0
  107. package/src/graph/util/dhash.ts +84 -0
  108. package/src/lrr/aggregator.ts +105 -10
  109. package/src/orchestrator/hooks/context-header.ts +34 -10
  110. package/src/orchestrator/hooks/token-accounting.ts +25 -14
  111. package/src/orchestrator/mcp/cycle-counter.ts +2 -1
  112. package/src/orchestrator/mcp/scribe.ts +27 -16
  113. package/src/orchestrator/mcp/write-lease.ts +30 -13
  114. package/src/orchestrator/phase4-shared-context.ts +20 -4
  115. package/protocols/visual-dna.md +0 -185
@@ -0,0 +1,234 @@
1
+ # Page Spec Schema
2
+
3
+ ## Purpose
4
+
5
+ Step 3.3's UX architect (`design-ux-architect`) produces page specs alongside `ux-architecture.md` — flows and layouts are created together because they inform each other. One file per screen is emitted to `docs/plans/page-specs/{screen-name}.md`. Each file is the spatial blueprint for a single screen — ASCII wireframe + structured metadata — so Phase 4 implementers know exactly what to build without interpreting prose. This protocol defines the required sections, wireframe format, platform conventions, and validation rules.
6
+
7
+ ## Inputs
8
+
9
+ The page spec writer reads these artifacts before producing any page spec:
10
+
11
+ - `docs/plans/product-spec.md` — feature states, data requirements, persona constraints, screen inventory (SOURCE OF TRUTH for what each screen does)
12
+ - `docs/plans/architecture.md` — frontend component hierarchy, routing, API contracts
13
+ - `DESIGN.md` `## Overview > ### Brand DNA` — 7-axis DNA card (Density axis drives layout decisions)
14
+ - `docs/plans/component-manifest.md` — library component picks per slot
15
+ - `docs/plans/design-references/` — competitor/inspiration screenshots for layout reference
16
+
17
+ NOTE: `visual-design-spec.md` does NOT exist yet when page specs are produced (it's created at Step 3.4, after Step 3.3). Page specs use the DNA Density axis for spatial decisions (Airy vs Dense) and the component manifest for component choices. Exact spacing values and typography ramp are applied by Phase 4 implementers when they build from the visual design spec.
18
+
19
+ ## Questions Answered
20
+
21
+ Page specs close three questions from the Phase 0-3 question map:
22
+
23
+ - **Q50** — Screen layouts (spatial arrangement of every element)
24
+ - **Q51** — Content hierarchy (what's primary, secondary, tertiary per screen)
25
+ - **Q53** — Key copy per screen (headings, CTAs, empty states, errors)
26
+
27
+ ## File Convention
28
+
29
+ - Path: `docs/plans/page-specs/{screen-name}.md` (kebab-case)
30
+ - Anchors: `page-specs/{screen-name}#wireframe`, `page-specs/{screen-name}#content-hierarchy`, `page-specs/{screen-name}#key-copy`, etc.
31
+ - One file per screen in the product-spec Screen Inventory. Multi-step flows (e.g., checkout) get one file per step.
32
+
33
+ ## Required Sections
34
+
35
+ Every page spec MUST contain these sections, in this order.
36
+
37
+ ### 1. Screen Overview
38
+
39
+ One line: what this screen is, which feature(s) it serves.
40
+
41
+ ### 2. ASCII Wireframe
42
+
43
+ Spatial layout using box-drawing characters. Desktop wireframe required for all platforms. Mobile wireframe required for web projects. Section labels inside brackets map to Content Hierarchy entries.
44
+
45
+ ### 3. Content Hierarchy
46
+
47
+ Ordered list (top → bottom, primary → tertiary) of every content section. Each entry: section name, data shown, component from manifest (or `custom`), data source (API endpoint or `local`/`computed`), visual weight (`primary`/`secondary`/`tertiary`).
48
+
49
+ ### 4. Key Copy
50
+
51
+ Headings, CTAs, labels, empty state messages, error messages for this screen. Not every string — the ones that set the tone and guide implementation.
52
+
53
+ ### 5. Responsive Behavior (web only)
54
+
55
+ What changes at each breakpoint: desktop (1024px+), tablet (768px), mobile (375px). What reflows, collapses, or hides.
56
+
57
+ ### 6. Platform Conventions
58
+
59
+ Which platform patterns this screen follows. iOS: navigation stack, tab bar, sheets. Web: sidebar state, breadcrumbs, header nav. Reference the relevant HIG pattern or web convention.
60
+
61
+ ### 7. Data Loading
62
+
63
+ What's fetched on mount, loading skeleton description, refresh strategy (pull-to-refresh, auto-refresh, manual).
64
+
65
+ ### 8. States
66
+
67
+ Reference to product-spec feature states, plus screen-specific visual states: skeleton loading, partial data, stale indicator, empty, error.
68
+
69
+ ## ASCII Wireframe Format
70
+
71
+ **Characters:** `┌ ┐ └ ┘ ─ │ ├ ┤ ┬ ┴ ┼`
72
+
73
+ **Rules:**
74
+ - Label every section inside brackets: `[Header]`, `[Sidebar]`, `[KPI Cards]`
75
+ - Show relative sizing — sidebar narrower than main content
76
+ - Desktop wireframe: ~60 chars wide
77
+ - Mobile wireframe: ~30 chars wide
78
+ - Include placeholder text for key copy: `[Place Order]`, `[Your cart is empty...]`
79
+ - Density axis from visual-dna.md drives spacing: Airy = generous gaps between sections, fewer items visible. Dense = compact rows, more items per viewport.
80
+
81
+ ## Platform-Specific Wireframe Conventions
82
+
83
+ **Web SaaS:** Sidebar + main content area. Header with nav. Sidebar collapses to hamburger on mobile.
84
+
85
+ **iOS:** Navigation bar at top (title, back button if applicable), content area, tab bar at bottom. Standard HIG layout patterns. See iOS-specific conventions section below for full requirements.
86
+
87
+ **Dashboard/Analytics:** Filter bar, card grid, chart placement. Dense layout with data tables.
88
+
89
+ **CLI:** No wireframe. Show command output format with example terminal session instead.
90
+
91
+ **Mobile (React Native/Expo):** Follow target platform conventions — iOS patterns if iOS, Material if Android, cross-platform neutral if both.
92
+
93
+ ### iOS-specific wireframe conventions
94
+
95
+ When `project_type=ios`, page-specs follow these conventions:
96
+
97
+ - **Single viewport:** iPhone 16 Pro (393×852 logical) as the primary; iPad layout deltas captured as a Notes section. No second mobile/desktop view.
98
+ - **Navigation annotation:** name the parent NavigationStack / TabView / sheet and the back/dismiss gesture per screen.
99
+ - **Component refs:** every interactive element references a DESIGN.md `components:` token name (e.g., `button-primary`, `list-row-grouped`, `card-elevated`) — these are SwiftUI view modifiers at Phase 4.
100
+ - **Dynamic Type:** declare which typography role tokens the screen uses; flag any layout that breaks at xxxLarge.
101
+ - **Safe-area handling:** name top/bottom safe-area treatments (large title vs nav bar; tab bar inset).
102
+ - **Data loading strategy:** async/await + `.task` modifier vs `ObservableObject` reference; loading/error/empty states sourced from product-spec.md per-feature sections.
103
+
104
+ ## Validation Checklist
105
+
106
+ 1. Every screen in product-spec.md Screen Inventory has a page spec file
107
+ 2. Every page spec has all 8 required sections (skip Responsive Behavior for non-web)
108
+ 3. Every content hierarchy entry references a component from `component-manifest.md` or marks it `custom`
109
+ 4. Every data source references an API endpoint from `architecture.md#backend/api` or marks it `local`/`computed`
110
+ 5. ASCII wireframe exists for desktop (and mobile for web projects)
111
+ 6. Section labels in wireframe match content hierarchy entry names
112
+ 7. Key copy includes at least: one heading, one primary CTA, one empty state message
113
+
114
+ ## Worked Example: Dashboard (Web SaaS)
115
+
116
+ ```markdown
117
+ # Page Spec: Dashboard
118
+
119
+ ## Screen Overview
120
+
121
+ Main dashboard — KPI summary, recent activity, and quick actions. Features: Dashboard, Notifications.
122
+
123
+ ## ASCII Wireframe
124
+
125
+ ### Desktop (1024px+)
126
+
127
+ ┌──────────────────────────────────────────────────────────┐
128
+ │ [Header] [Search] [Avatar ▼] │
129
+ ├────────────┬─────────────────────────────────────────────┤
130
+ │ [Sidebar] │ [Page Title: Dashboard] │
131
+ │ │ │
132
+ │ Dashboard │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
133
+ │ Orders │ │[KPI: ]│ │[KPI: ]│ │[KPI: ]│ │
134
+ │ Products │ │ Revenue │ │ Orders │ │ Users │ │
135
+ │ Customers │ │ $12,340 │ │ 142 │ │ 1,203 │ │
136
+ │ Settings │ └─────────┘ └─────────┘ └─────────┘ │
137
+ │ │ │
138
+ │ │ ┌──────────────────────────────────────┐ │
139
+ │ │ │[Revenue Chart] │ │
140
+ │ │ │ │ │
141
+ │ │ │ ▁▂▃▅▆▇█▇▆▅▃▂▁▂▃▅▆▇ │ │
142
+ │ │ │ │ │
143
+ │ │ └──────────────────────────────────────┘ │
144
+ │ │ │
145
+ │ │ ┌──────────────────────────────────────┐ │
146
+ │ │ │[Activity Feed] │ │
147
+ │ │ │ • New order #1042 — 2m ago │ │
148
+ │ │ │ • User signed up — 15m ago │ │
149
+ │ │ │ • Payment received — 1h ago │ │
150
+ │ │ └──────────────────────────────────────┘ │
151
+ ├────────────┴─────────────────────────────────────────────┤
152
+ │ [Footer] │
153
+ └──────────────────────────────────────────────────────────┘
154
+
155
+ ### Mobile (375px)
156
+
157
+ ┌────────────────────────────┐
158
+ │ [Header] [☰] [Avatar] │
159
+ ├────────────────────────────┤
160
+ │ [Page Title: Dashboard] │
161
+ │ │
162
+ │ ┌────────────────────────┐ │
163
+ │ │[KPI: Revenue] $12,340 │ │
164
+ │ └────────────────────────┘ │
165
+ │ ┌────────────────────────┐ │
166
+ │ │[KPI: Orders] 142 │ │
167
+ │ └────────────────────────┘ │
168
+ │ ┌────────────────────────┐ │
169
+ │ │[KPI: Users] 1,203 │ │
170
+ │ └────────────────────────┘ │
171
+ │ │
172
+ │ ┌────────────────────────┐ │
173
+ │ │[Revenue Chart] │ │
174
+ │ │ ▁▂▃▅▆▇█▇▆▅▃▂▁▂▃▅▆▇ │ │
175
+ │ └────────────────────────┘ │
176
+ │ │
177
+ │ ┌────────────────────────┐ │
178
+ │ │[Activity Feed] │ │
179
+ │ │ • New order — 2m ago │ │
180
+ │ │ • Signup — 15m ago │ │
181
+ │ │ • Payment — 1h ago │ │
182
+ │ └────────────────────────┘ │
183
+ └────────────────────────────┘
184
+
185
+ ## Content Hierarchy
186
+
187
+ | # | Section | Data Shown | Component | Data Source | Weight |
188
+ |---|---------|-----------|-----------|-------------|--------|
189
+ | 1 | KPI Cards | Revenue, order count, active users (current period + delta) | `StatCard` from manifest | `GET /api/dashboard/kpis` | primary |
190
+ | 2 | Revenue Chart | 30-day revenue trend line | `AreaChart` from manifest | `GET /api/dashboard/revenue?range=30d` | primary |
191
+ | 3 | Activity Feed | Last 10 events (orders, signups, payments) with relative timestamps | `FeedList` from manifest | `GET /api/dashboard/activity?limit=10` | secondary |
192
+ | 4 | Header | App logo, search, user avatar dropdown | `AppHeader` from manifest | `local` (user session) | tertiary |
193
+ | 5 | Sidebar | Navigation links with active state, unread badge on notifications | `SideNav` from manifest | `local` (route) + `GET /api/notifications/count` | tertiary |
194
+
195
+ ## Key Copy
196
+
197
+ - **Page heading:** "Dashboard"
198
+ - **KPI labels:** "Revenue" · "Orders" · "Active Users"
199
+ - **KPI delta format:** "+12% vs last period" / "−3% vs last period"
200
+ - **Activity feed heading:** "Recent Activity"
201
+ - **Empty activity state:** "No activity yet. Once your first order comes in, you'll see it here."
202
+ - **Error state:** "Couldn't load dashboard data. Check your connection and try again." CTA: [Retry]
203
+ - **Stale indicator:** "Last updated 5 minutes ago" (appears after 60s without refresh)
204
+
205
+ ## Responsive Behavior
206
+
207
+ | Breakpoint | Changes |
208
+ |-----------|---------|
209
+ | Desktop (1024px+) | Sidebar visible. KPI cards in 3-column row. Chart full width of main area. |
210
+ | Tablet (768px) | Sidebar collapses to icon-only rail. KPI cards in 3-column row (narrower). Chart full width. |
211
+ | Mobile (375px) | Sidebar hidden behind hamburger menu. KPI cards stack vertically (full width each). Chart full width. Activity feed below chart. |
212
+
213
+ ## Platform Conventions
214
+
215
+ - **Web SaaS pattern:** Persistent sidebar navigation with active-state highlight on current page. Header with global search and user menu. Breadcrumbs not needed (top-level screen).
216
+ - **Sidebar:** Collapsible — user preference persisted in local storage. Icon-only mode at tablet breakpoint.
217
+ - **Data refresh:** No pull-to-refresh (web). Auto-refresh every 60s via polling. Manual refresh button in header.
218
+
219
+ ## Data Loading
220
+
221
+ - **On mount:** Parallel fetch `GET /api/dashboard/kpis`, `GET /api/dashboard/revenue?range=30d`, `GET /api/dashboard/activity?limit=10`
222
+ - **Loading skeleton:** 3 shimmer rectangles for KPI cards (same dimensions as loaded cards). Chart area shows shimmer block. Activity feed shows 3 shimmer rows with avatar circle + text lines.
223
+ - **Refresh:** Auto-poll every 60s. Stale indicator appears if last successful fetch > 60s ago. No full-page reload — data swaps in place.
224
+
225
+ ## States
226
+
227
+ - **From product-spec:** `initial`, `loading`, `loaded`, `empty`, `error`, `stale`
228
+ - **Screen-specific visuals:**
229
+ - `skeleton-loading` — shimmer cards + shimmer chart + shimmer feed rows (see Data Loading)
230
+ - `partial-data` — KPIs loaded but chart still loading: show KPI cards, chart area shows shimmer
231
+ - `stale` — data older than 60s: subtle "Last updated X ago" badge below page title
232
+ - `empty` — new account, no data yet: KPI cards show "—", chart shows flat line, activity feed shows empty state copy
233
+ - `error` — fetch failed: inline error banner with retry button, no full-page error
234
+ ```
@@ -0,0 +1,354 @@
1
+ # product-spec.md Schema
2
+
3
+ ## Purpose
4
+
5
+ Step 1.6's product-spec-writer emits `docs/plans/product-spec.md` with stable section anchors so that Phase 2 architects, Phase 2 planner, Phase 3 UX architect, Phase 4 Product Owner, and Phase 4 Briefing Officers can receive content-addressed refs instead of pasted content. This document defines the required structure, anchor convention, format rules, validation checklist, and product-type variations.
6
+
7
+ ## Required Top-Level Sections
8
+
9
+ The product spec MUST contain these top-level headings, in this order:
10
+
11
+ - `# Product Spec`
12
+ - `## App Overview`
13
+ - `## Screen Inventory`
14
+ - `## Permissions & Roles`
15
+ - `## Cross-Feature Interactions`
16
+
17
+ Then, one `## Feature: {Name}` section per feature in the PRD scope.
18
+
19
+ ### App Overview
20
+
21
+ Two parts, both required.
22
+
23
+ **Part 1 — Grounding paragraph.** One paragraph: what this app is and core value proposition. Not a restatement of the PRD — a grounding paragraph that any engineer can read in 10 seconds to understand the product.
24
+
25
+ **Part 2 — Persona Table.** A table listing every persona the product serves. One row flagged `(primary)` next to its name. Required columns: `Persona`, `Role`, `Primary JTBD`, `Relationship to Other Personas`.
26
+
27
+ Format:
28
+
29
+ ```
30
+ | Persona | Role | Primary JTBD | Relationship to Other Personas |
31
+ |---------|------|--------------|--------------------------------|
32
+ | Buyer (primary) | End consumer placing orders | Find a trusted seller and complete a purchase fast | Buys from Seller; rates Seller post-transaction |
33
+ | Seller | Independent merchant fulfilling orders | Receive, fulfill, and get paid for orders without manual chasing | Sells to Buyer; notified by Buyer order events |
34
+ | Admin | Platform operator handling disputes | Resolve disputes between Buyer and Seller without losing trust on either side | Mediates Buyer ↔ Seller |
35
+ ```
36
+
37
+ Rules:
38
+ - ≥ 1 row required. A single-persona product still uses the table — name the one persona explicitly.
39
+ - Exactly one row carries `(primary)` after the name.
40
+ - Persona names defined here are the canonical identifiers used in every per-feature `Persona Constraints` block. Do not introduce a persona name in a feature that does not appear in this table.
41
+ - Pull persona enumeration directly from `ux-research.md` (Persona Enumeration section). If `ux-research.md` lists N personas, this table has N rows.
42
+
43
+ Anchors: `product-spec.md#app-overview` (top-level grounding paragraph + table), `product-spec.md#app-overview/personas` (the table specifically, for refs.json indexing).
44
+
45
+ ### Screen Inventory
46
+
47
+ Complete list of every screen in the app with a one-line description. Format:
48
+
49
+ ```
50
+ | Screen | Description | Features |
51
+ |--------|-------------|----------|
52
+ | Login | Email/password + social auth | Auth |
53
+ | Dashboard | KPI cards, activity feed, charts | Dashboard, Notifications |
54
+ | Checkout (3 screens) | Cart review → Shipping → Confirmation | Checkout |
55
+ | Settings | Profile, notifications, billing, security tabs | Settings |
56
+ | Admin Panel | User management, analytics | Admin |
57
+ ```
58
+
59
+ This is the master list. Per-feature sections reference screens from this inventory.
60
+
61
+ ### Permissions & Roles
62
+
63
+ Define every role in the system and what each can access. Format:
64
+
65
+ ```
66
+ | Role | Can Do | Cannot Do |
67
+ |------|--------|-----------|
68
+ | Anonymous | View public pages, sign up | Access dashboard, place orders |
69
+ | User | CRUD own resources, checkout | Manage other users, view admin |
70
+ | Admin | All user actions + manage users, view analytics | Delete system config |
71
+ ```
72
+
73
+ If the product has no roles beyond "authenticated user," say so explicitly: "Single role: authenticated user. No admin or public access."
74
+
75
+ ### Cross-Feature Interactions
76
+
77
+ A dependency map showing how features connect. Where an interaction crosses a persona boundary (one persona's action triggers another persona's experience), call this out explicitly with `(Persona) → (Persona)` notation. This is critical for marketplaces and other multi-sided products — without it, the seller-side and buyer-side experiences diverge silently.
78
+
79
+ Format:
80
+
81
+ ```
82
+ - Auth → Checkout: user must be authenticated to check out
83
+ - Order Placement (Buyer) → Order Notification (Seller): seller notified within 60s when buyer submits order
84
+ - Order Fulfillment (Seller) → Order Status (Buyer): buyer sees status update when seller marks shipped
85
+ - Dispute (Buyer or Seller) → Mediation (Admin): admin queue receives dispute when either party files
86
+ - Checkout → Inventory: stock check at cart review and at submit
87
+ - Dashboard → Settings: display preferences read from user settings
88
+ - Notifications → Auth, Checkout, Dashboard: triggered by events in each
89
+ ```
90
+
91
+ Every dependency must be bidirectional — if A depends on B, B's feature section must mention A under its own interactions. Persona-crossing interactions must appear in BOTH personas' feature sections.
92
+
93
+ ## Required Per-Feature Sections
94
+
95
+ Every `## Feature: {Name}` section MUST contain these subsections, in this order:
96
+
97
+ ### States
98
+ Flat list of all states this feature can be in. Minimum 3: a loaded state, an empty/initial state, and an error state. Include meta-states as relevant: loading, stale, offline, permission-denied, disabled. The first entry is the initial state.
99
+
100
+ Format: `States: initial (initial), loading, loaded, empty, error, stale`
101
+
102
+ ### Transitions
103
+ Table of valid state changes.
104
+
105
+ Format:
106
+ ```
107
+ | From → To | Trigger | Preconditions | Side Effects |
108
+ |-----------|---------|---------------|--------------|
109
+ | initial → loading | Page mount | User authenticated | Fetch GET /api/orders |
110
+ | loading → loaded | API 200 | Response has ≥1 item | Render list |
111
+ | loading → empty | API 200 | Response has 0 items | Show empty state |
112
+ | loading → error | API 4xx/5xx or timeout | — | Show error message |
113
+ ```
114
+
115
+ ### Data Requirements
116
+ Per-state data needs. What data is displayed, where it comes from, what shape it has.
117
+
118
+ Format:
119
+ ```
120
+ - loaded: list of orders [{id, status, total, created_at, items[]}] from GET /api/orders
121
+ - empty: no data needed, static copy
122
+ - error: error message string from API response or "Something went wrong. Please try again."
123
+ ```
124
+
125
+ ### Failure Modes
126
+ Per-transition failures. What can go wrong, what the user sees (exact copy), what they can do, what the system does.
127
+
128
+ Format:
129
+ ```
130
+ - Network failure during checkout submit →
131
+ User sees: "We couldn't process your order. Please check your connection and try again."
132
+ User can: Retry (button), go back to cart
133
+ System: Log error, do NOT create partial order
134
+ ```
135
+
136
+ ### Business Rules
137
+ Bullet list with concrete values. Every rule has a number or a `[DECISION NEEDED]` flag.
138
+
139
+ ### Happy Path
140
+ Numbered steps. Each step: what the user sees, what they can do, what happens.
141
+
142
+ ### Persona Constraints
143
+ Which personas this feature serves and what research findings shaped its design for each. Every constraint MUST attribute to a specific persona named in the App Overview persona table. Cite specific findings from `ux-research.md` and `feature-intel.md`.
144
+
145
+ Rules:
146
+ - One constraint block per persona that uses this feature.
147
+ - Persona names must match the App Overview table verbatim (including `(primary)` flag where applicable).
148
+ - If a feature serves multiple personas, list a constraint block per persona — even if some constraints overlap, attribute each to the persona it shapes the design for.
149
+ - If a feature serves only one persona, name it explicitly. Do not leave persona attribution implicit.
150
+
151
+ Format (multi-persona example — marketplace order placement):
152
+ ```
153
+ - Persona: Buyer (primary) — time-poor, scans, doesn't read [ux-research.md]
154
+ Constraint: keep checkout to 3 steps max — competitors average 5+ [feature-intel.md]
155
+ Constraint: show progress indicator at top of each step — persona abandons flows without visible progress [ux-research.md]
156
+ - Persona: Seller — needs visibility into pending orders to plan fulfillment [ux-research.md]
157
+ Constraint: notification within 60s of order placed — sellers report losing time-sensitive orders to slower competitors [ux-research.md]
158
+ Constraint: order detail must include buyer-supplied notes verbatim — fulfillment errors traced to truncated notes in v0 [ux-research.md]
159
+ ```
160
+
161
+ ### Empty/Loading/Error States
162
+ What the user sees in each non-happy state. Include specific copy and call-to-action for empty states.
163
+
164
+ ### Acceptance Criteria
165
+ Testable statements using checkbox format. Each starts with "Verify that..."
166
+
167
+ Format:
168
+ ```
169
+ - [ ] Verify that checkout completes in 3 steps or fewer
170
+ - [ ] Verify that discount code validates without page reload
171
+ - [ ] Verify that out-of-stock items show inline notification, not a generic error page
172
+ ```
173
+
174
+ ## Optional Per-Feature Sections
175
+
176
+ Include based on product type. Omit if not applicable — do not stub empty sections.
177
+
178
+ - **Notification Triggers** — channel (email/push/in-app), timing (immediate/delayed/batched), content summary, opt-out mechanism. Required for: SaaS with user accounts, marketplaces, mobile apps.
179
+ - **Technical Constraints & Integrations** — third-party services this feature depends on (payment processor, geocoding API, email provider, analytics), rate limits, SDK requirements, authentication method for each. Required for: features that call external APIs or use third-party SDKs.
180
+ - **Copy Direction** — tone examples for CTAs, errors, empty states, confirmations specific to this feature. Required for: consumer-facing products, marketplaces.
181
+ - **Offline Behavior** — what's cached, what degrades, what's blocked. Required for: mobile apps, PWAs.
182
+ - **Multi-User Scenarios** — concurrent access, conflict resolution, real-time sync. Required for: collaborative tools, marketplaces, multi-tenant SaaS.
183
+ - **Performance Expectations** — latency targets per interaction. Required for: search-heavy products, real-time dashboards, e-commerce checkout.
184
+ - **Inter-Screen Data Flow** — what state carries from this feature's screens to other screens (URL params, local storage, context providers, server session). What data this feature reads that another feature writes, and vice versa. Required for: multi-screen flows, features that share state.
185
+
186
+ ## Anchor Naming Convention
187
+
188
+ Anchors follow `product-spec.md#{feature}/{section}` format for refs.json indexing.
189
+
190
+ Rules:
191
+ - Feature names are kebab-case: `checkout`, `user-dashboard`, `admin-settings`
192
+ - Section names are kebab-case: `states`, `transitions`, `data-requirements`, `failure-modes`, `business-rules`, `happy-path`, `persona-constraints`, `empty-states`, `acceptance-criteria`
193
+ - Full anchor example: `product-spec.md#checkout/business-rules`
194
+ - Top-level sections use flat anchors: `product-spec.md#app-overview`, `product-spec.md#screen-inventory`, `product-spec.md#permissions`, `product-spec.md#cross-feature`
195
+ - Anchors must be stable across regeneration — same inputs produce same anchors
196
+
197
+ The Refs Indexer (Phase 2.2) parses these anchors into `refs.json` alongside architecture and PRD anchors.
198
+
199
+ ## Product-Type Variations
200
+
201
+ | Section | Web SaaS | Dashboard/Analytics | API/Dev Tool | iOS/Mobile | CLI | Marketplace |
202
+ |---------|----------|-------------------|-------------|-----------|-----|-------------|
203
+ | States | Required | Required | Omit (use request lifecycle) | Required + app lifecycle | Omit (use exit codes) | Required × 2 roles |
204
+ | Transitions | Required | Required (lighter) | Required (request/response) | Required + background states | Required (command flow) | Required × 2 roles |
205
+ | Data Requirements | Required | Required (heavy) | Required (request/response shapes) | Required + cache strategy | Required (stdin/stdout) | Required × 2 roles |
206
+ | Failure Modes | Required | Required | Required (error codes) | Required + offline failures | Required (exit codes) | Required × 2 roles |
207
+ | Happy Path | Required | Required | Required (request examples) | Required | Required (command examples) | Required × 2 roles |
208
+ | Business Rules | Required | Light | Required (rate limits, quotas) | Required | Light | Required (both sides) |
209
+ | Empty States | Required | Required | N/A | Required | N/A | Required × 2 roles |
210
+ | Notification Triggers | Optional | Optional | N/A | Required | N/A | Required |
211
+ | Offline Behavior | Optional | N/A | N/A | Required | N/A | Optional |
212
+ | Multi-User Scenarios | Optional | Optional | Optional | Optional | N/A | Required |
213
+ | Performance | Optional | Required | Required | Optional | Optional | Optional |
214
+
215
+ ## Validation Checklist
216
+
217
+ Step 1.7 runs these checks. Failure sends the spec back to the product-spec-writer with specific gaps.
218
+
219
+ **Mechanical checks (no LLM, ~0 tokens):**
220
+ 1. Every feature in `design-doc.md` scope has a `## Feature: {Name}` section
221
+ 2. Every feature section has all 9 required subsections (States through Acceptance Criteria, including Persona Constraints)
222
+ 3. Every States list has ≥ 3 entries
223
+ 4. Every Transitions table has ≥ 1 row
224
+ 5. No banned vague phrases: "appropriate," "as needed," "standard," "graceful," "configurable," "reasonable," "properly," "adequate"
225
+ 6. All `[DECISION NEEDED]` tags are well-formed: `[DECISION NEEDED: question | Suggest: value]` or `[DECISION NEEDED: question]`
226
+ 7. Permissions & Roles section exists and is non-empty
227
+ 8. Cross-Feature Interactions section exists and is non-empty
228
+ 9. Screen Inventory section exists and is non-empty
229
+ 10. Every acceptance criterion starts with "Verify that"
230
+ 11. App Overview persona table has ≥ 1 row, each persona has a role and JTBD, exactly one persona is flagged `(primary)`, and the `Relationship to Other Personas` column is filled for each row
231
+ 12. Every feature's Persona Constraints attributes each constraint to a named persona that appears in the App Overview persona table (no orphan persona names, no implicit attribution)
232
+ 13. For multi-persona products: every Cross-Feature Interactions entry that crosses a persona boundary uses the `(Persona) → (Persona)` annotation
233
+
234
+ **State machine checks (mechanical, ~0 tokens):**
235
+ 14. Every state in a States list appears in at least one Transitions row (no orphan states)
236
+ 15. Every Transitions row references states that exist in the States list
237
+ 16. No transition has empty preconditions (every transition requires something to be true, even if it's just "user clicks button")
238
+ 17. Error states have at least one outgoing transition (recovery path) OR are marked terminal
239
+ 18. The initial state is explicitly identified in the States list (first entry or marked with "(initial)")
240
+
241
+ ## Worked Example: Marketplace Order Placement (Buyer + Seller)
242
+
243
+ This example illustrates the multi-persona pattern. App Overview persona table for this hypothetical product would include at minimum `Buyer (primary)` and `Seller`. The feature below is order placement, which originates with the Buyer but has direct downstream effects on the Seller (notification, fulfillment queue) — so its `Persona Constraints` block has entries for both personas, and the top-level `Cross-Feature Interactions` map records the persona-crossing edge.
244
+
245
+ ```markdown
246
+ ## Feature: Checkout
247
+
248
+ ### States
249
+ States: empty-cart (initial), cart-review, entering-shipping, confirming, processing, completed, failed
250
+
251
+ ### Transitions
252
+ | From → To | Trigger | Preconditions | Side Effects |
253
+ |-----------|---------|---------------|--------------|
254
+ | empty-cart → cart-review | Add first item | User authenticated | Cart created in local storage |
255
+ | cart-review → entering-shipping | Click "Continue to Shipping" | Cart has ≥ 1 in-stock item | Validate inventory via GET /api/inventory/check |
256
+ | cart-review → empty-cart | Remove last item | — | Clear cart from local storage |
257
+ | entering-shipping → confirming | Submit shipping form | All required fields valid, address verified | Calculate tax via POST /api/tax/calculate |
258
+ | confirming → processing | Click "Place Order" | — | POST /api/orders, disable button, show spinner |
259
+ | processing → completed | API 201 | Order created | Show confirmation, send email, clear cart |
260
+ | processing → failed | API 4xx/5xx or 30s timeout | — | Show error message, re-enable "Place Order" |
261
+ | failed → processing | Click "Try Again" | Poll GET /api/orders/{id} confirms no order exists | Retry POST /api/orders |
262
+ | failed → cart-review | Click "Review Cart" | — | Navigate back, cart preserved |
263
+ | any → cart-review | Click browser back / breadcrumb | — | State preserved, no data loss |
264
+
265
+ ### Data Requirements
266
+ - cart-review: cart items [{id, name, price, quantity, image_url}] from local storage, inventory status from GET /api/inventory/check
267
+ - entering-shipping: saved addresses from GET /api/user/addresses (if any), country list static
268
+ - confirming: order summary {items, subtotal, shipping, tax, discount, total} computed client-side, tax from API
269
+ - processing: no new data, spinner only
270
+ - completed: order {id, estimated_delivery, email} from POST /api/orders response
271
+ - failed: error message from API response body
272
+ - empty-cart: no data, static copy
273
+
274
+ ### Failure Modes
275
+ - Inventory check fails (item out of stock after carting) →
276
+ User sees: "'{item name}' is no longer available. We've updated your cart."
277
+ User can: Continue with remaining items, or go back to browse
278
+ System: Remove item from cart, recalculate total
279
+
280
+ - Shipping address validation fails →
281
+ User sees: Inline field errors ("Enter a valid ZIP code")
282
+ User can: Correct fields and resubmit
283
+ System: No API call until client-side validation passes
284
+
285
+ - Payment processing fails →
286
+ User sees: "We couldn't process your payment. Please check your card details and try again."
287
+ User can: Retry, change payment method, go back to cart
288
+ System: Log failure reason, do NOT create partial order, do NOT charge card
289
+
290
+ - Network failure during order submit →
291
+ User sees: "Connection lost. Your cart is saved — try again when you're back online."
292
+ User can: Retry when connection restores
293
+ System: Cart persisted in local storage, no server-side state created
294
+
295
+ - 30s timeout during processing →
296
+ User sees: "This is taking longer than expected. Please wait or try again."
297
+ User can: Wait (spinner continues) or click "Try Again"
298
+ System: If order was created server-side, poll GET /api/orders/{id} to confirm before retrying
299
+
300
+ ### Business Rules
301
+ - Discount codes: one per order, validated in real-time via POST /api/discounts/validate, shows adjusted total immediately
302
+ - Tax: calculated by jurisdiction based on shipping address, displayed at confirmation step
303
+ - Inventory: checked at cart-review entry AND at order submit — stale cart items removed with notification
304
+ - Minimum order: [DECISION NEEDED: Is there a minimum order value? Suggest: no minimum]
305
+ - Shipping: [DECISION NEEDED: Free shipping threshold? Suggest: free over $50, flat $5.99 under]
306
+ - Order timeout: 30 seconds before showing timeout message
307
+ - Cart persistence: local storage, survives browser close, expires after 7 days
308
+ - Pricing display: [DECISION NEEDED: Include tax in displayed prices or show separately? Common options: tax-exclusive (US standard) or tax-inclusive (EU standard)]
309
+
310
+ ### Happy Path
311
+ 1. User is on cart-review screen. Sees: item list with names, prices, quantities, images. Subtotal displayed. Can: edit quantities (inline +/- buttons), remove items, apply discount code, click "Continue to Shipping."
312
+ 2. User clicks "Continue to Shipping." Sees: shipping form with saved addresses (if any) or empty form. Required fields: name, street, city, state, ZIP, country. Can: select saved address or enter new one.
313
+ 3. User submits shipping. Sees: order confirmation screen with full summary — items, subtotal, shipping cost, tax, discount (if applied), total. Can: edit any section (back navigation preserves all data), click "Place Order."
314
+ 4. User clicks "Place Order." Sees: button disabled, spinner. Waits up to 10 seconds.
315
+ 5. Order succeeds. Sees: confirmation page with order ID, estimated delivery date, "A confirmation email has been sent to {email}." Can: click "Continue Shopping" or view order in account.
316
+
317
+ ### Persona Constraints
318
+ - Persona: Buyer (primary) — time-poor, scans, doesn't read [ux-research.md]
319
+ Constraint: checkout must complete in 3 steps — competitors average 5+ steps; research shows each additional step loses ~10% of users [feature-intel.md]
320
+ Constraint: show progress indicator at top of each step — persona abandons flows without visible progress [ux-research.md]
321
+ Constraint: real-time discount validation — competitors require page reload, this is a key differentiator [feature-intel.md]
322
+ - Persona: Seller — needs immediate visibility into incoming orders to plan fulfillment [ux-research.md]
323
+ Constraint: order notification fires within 60s of buyer's `processing → completed` transition — sellers in interviews reported losing time-sensitive orders to faster-notifying competitors [ux-research.md]
324
+ Constraint: order payload to seller includes buyer-supplied notes verbatim (no truncation) — fulfillment errors traced to truncated notes in v0 research [ux-research.md]
325
+
326
+ ### Empty/Loading/Error States
327
+ - Empty cart: "Your cart is empty. Browse our products to find something you'll love." CTA: "Start Shopping" button linking to product catalog.
328
+ - Loading (inventory check): Skeleton cards matching item layout, no spinner.
329
+ - Loading (tax calculation): Subtotal visible, tax line shows "Calculating..." with shimmer.
330
+ - Loading (order processing): "Place Order" button disabled, inline spinner, "Processing your order..." text.
331
+ - Error (generic): "Something went wrong. Please try again." with "Retry" button. Never a full-page error — always inline within the checkout flow.
332
+
333
+ ### Performance Expectations
334
+ - Cart page load: < 1s TTI (Time to Interactive) on 4G connection
335
+ - Discount code validation: < 500ms API response, show inline spinner during request
336
+ - Tax calculation: < 1s API response, show shimmer placeholder during calculation
337
+ - Order submission: < 10s to confirmation, show spinner, timeout message at 30s
338
+
339
+ ### Notification Triggers
340
+ - Order placed → Email (immediate): order confirmation with item summary, order ID, estimated delivery, tracking link
341
+ - Payment failed → Email (immediate): retry prompt with direct link to payment page, cart preserved
342
+ - Cart abandoned (7 days) → Email (delayed, 24h after last activity): reminder with cart contents and direct link to resume
343
+
344
+ ### Acceptance Criteria
345
+ - [ ] Verify that checkout completes in 3 steps (cart review, shipping, confirmation)
346
+ - [ ] Verify that user can navigate back to any previous step without losing entered data
347
+ - [ ] Verify that discount code validates in real-time without page reload
348
+ - [ ] Verify that out-of-stock items detected during checkout show inline notification with item name
349
+ - [ ] Verify that payment failure shows specific error message with retry option, not a generic error page
350
+ - [ ] Verify that cart persists across browser close and is recoverable
351
+ - [ ] Verify that order confirmation displays order ID and sends confirmation email
352
+ - [ ] Verify that the "Place Order" button is disabled during processing to prevent double-submit
353
+ - [ ] Verify that 30s timeout during processing shows timeout message with retry option
354
+ ```
@@ -0,0 +1,53 @@
1
+ # Sprint Tasks Schema
2
+
3
+ Schema for `docs/plans/sprint-tasks.md` — the pipe-delimited markdown table produced by the planner agent (Step 2.3.2) and parsed by `src/graph/parser/sprint-tasks.ts`.
4
+
5
+ ## Columns (required, in order)
6
+
7
+ | # | Column | Format | Rules |
8
+ |---|--------|--------|-------|
9
+ | 1 | Task ID | `T-{N}` (e.g. `T-1`, `T-2`) | Must not be empty. No duplicates (case-insensitive). |
10
+ | 2 | Title | Free text | Human-readable task description. |
11
+ | 3 | Size | `S`, `M`, or `L` | Case-insensitive; parser normalizes to uppercase. |
12
+ | 4 | Dependencies | Comma-separated Task IDs | e.g. `T-1, T-3`. Use `—` for none. Phase 4 uses this to batch independent tasks in parallel. |
13
+ | 5 | Behavioral Test | Concrete testable interaction | UI: `Navigate to X, click Y, verify Z`. API: curl-based. Should reference a product-spec acceptance criterion. |
14
+ | 6 | Owns Files | Comma-separated file paths | Files this task creates or modifies. Use `—` for none. |
15
+ | 7 | Implementing Phase | Phase identifier | e.g. `phase-4-frontend`, `phase-4-backend`. |
16
+ | 8 | Feature | Exact feature name from `product-spec.md` | Must match a `## Feature: X` heading. Use `—` for infrastructure tasks. Parser generates graph ID via kebab-case: `Order Placement` → `feature__order-placement`. |
17
+ | 9 | Screens | Comma-separated screen names | From the product-spec Screen Inventory. Use `—` for backend-only tasks. Parser generates IDs via kebab-case: `Catalog` → `screen__catalog`. |
18
+
19
+ ## Validation Rules
20
+
21
+ The parser enforces these rules and rejects the table on any violation:
22
+
23
+ 1. Table must have **exactly 9 columns**.
24
+ 2. All 9 column headers must be present (matched case-insensitively).
25
+ 3. **Task ID** must not be empty.
26
+ 4. **Task ID** must not be duplicated (case-insensitive comparison).
27
+ 5. **Size** must be one of `S`, `M`, `L`.
28
+
29
+ The DAG validator (Step 2.3, dispatch #3) additionally checks:
30
+ - No circular dependencies.
31
+ - All Task IDs referenced in Dependencies exist.
32
+ - Every UI task has a Behavioral Test; every API task has a curl-based test.
33
+
34
+ ## Graph Edges Emitted Per Row
35
+
36
+ | Relation | Condition | Source | Target |
37
+ |----------|-----------|--------|--------|
38
+ | `task_implements_feature` | Feature is not `—` | `task__{task-id}` | `feature__{kebab-name}` |
39
+ | `task_touches_screen` | Per screen when Screens is not `—` | `task__{task-id}` | `screen__{kebab-name}` |
40
+ | `task_depends_on` | Per dependency in Dependencies | `task__{task-id}` | `task__{dep-id}` |
41
+
42
+ ## Example Row
43
+
44
+ ```
45
+ | T-3 | Implement product catalog grid | M | T-1, T-2 | Navigate to /catalog, verify 12 product cards render with images and prices | src/components/CatalogGrid.tsx, src/api/products.ts | phase-4-frontend | Product Browsing | Catalog, Product Detail |
46
+ ```
47
+
48
+ ## References
49
+
50
+ - **Parser:** `src/graph/parser/sprint-tasks.ts`
51
+ - **Planner prompt:** `commands/build.md` Step 2.3, dispatch #2 ("Sprint breakdown")
52
+ - **DAG validator:** `commands/build.md` Step 2.3, dispatch #3 ("Task DAG validator")
53
+ - **Graph index command:** `node ${CLAUDE_PLUGIN_ROOT}/bin/graph-index.js docs/plans/sprint-tasks.md`