substrate-ai 0.1.21 → 0.1.22

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/dist/index.d.ts CHANGED
@@ -231,6 +231,68 @@ interface StoryStallEvent {
231
231
  /** Milliseconds since the last progress event */
232
232
  elapsed_ms: number;
233
233
  }
234
+ /**
235
+ * Emitted when the supervisor kills a stalled pipeline process tree.
236
+ */
237
+ interface SupervisorKillEvent {
238
+ type: 'supervisor:kill';
239
+ /** ISO-8601 timestamp generated at emit time */
240
+ ts: string;
241
+ /** Pipeline run ID that was killed */
242
+ run_id: string | null;
243
+ /** Reason for the kill — always 'stall' for threshold-triggered kills */
244
+ reason: 'stall';
245
+ /** Seconds the pipeline had been stalled */
246
+ staleness_seconds: number;
247
+ /** PIDs that were killed (orchestrator + child processes) */
248
+ pids: number[];
249
+ }
250
+ /**
251
+ * Emitted when the supervisor restarts a killed pipeline.
252
+ */
253
+ interface SupervisorRestartEvent {
254
+ type: 'supervisor:restart';
255
+ /** ISO-8601 timestamp generated at emit time */
256
+ ts: string;
257
+ /** Pipeline run ID being resumed */
258
+ run_id: string | null;
259
+ /** Restart attempt number (1-based) */
260
+ attempt: number;
261
+ }
262
+ /**
263
+ * Emitted when the supervisor exceeds the maximum restart limit and aborts.
264
+ */
265
+ interface SupervisorAbortEvent {
266
+ type: 'supervisor:abort';
267
+ /** ISO-8601 timestamp generated at emit time */
268
+ ts: string;
269
+ /** Pipeline run ID that was abandoned */
270
+ run_id: string | null;
271
+ /** Reason for aborting */
272
+ reason: 'max_restarts_exceeded';
273
+ /** Number of restart attempts that were made */
274
+ attempts: number;
275
+ }
276
+ /**
277
+ * Emitted when the supervisor detects a terminal pipeline state and exits.
278
+ */
279
+ interface SupervisorSummaryEvent {
280
+ type: 'supervisor:summary';
281
+ /** ISO-8601 timestamp generated at emit time */
282
+ ts: string;
283
+ /** Pipeline run ID */
284
+ run_id: string | null;
285
+ /** Total elapsed seconds from supervisor start to terminal state */
286
+ elapsed_seconds: number;
287
+ /** Story keys that completed successfully */
288
+ succeeded: string[];
289
+ /** Story keys that failed (non-COMPLETE, non-PENDING phases) */
290
+ failed: string[];
291
+ /** Story keys that were escalated */
292
+ escalated: string[];
293
+ /** Number of restart cycles performed by the supervisor */
294
+ restarts: number;
295
+ }
234
296
  /**
235
297
  * Discriminated union of all pipeline event types.
236
298
  *
@@ -243,7 +305,7 @@ interface StoryStallEvent {
243
305
  * }
244
306
  * ```
245
307
  */
246
- type PipelineEvent = PipelineStartEvent | PipelineCompleteEvent | StoryPhaseEvent | StoryDoneEvent | StoryEscalationEvent | StoryWarnEvent | StoryLogEvent | PipelineHeartbeatEvent | StoryStallEvent; //#endregion
308
+ type PipelineEvent = PipelineStartEvent | PipelineCompleteEvent | StoryPhaseEvent | StoryDoneEvent | StoryEscalationEvent | StoryWarnEvent | StoryLogEvent | PipelineHeartbeatEvent | StoryStallEvent | SupervisorKillEvent | SupervisorRestartEvent | SupervisorAbortEvent | SupervisorSummaryEvent; //#endregion
247
309
  //#region src/core/errors.d.ts
248
310
 
249
311
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,16 +8,92 @@ phases:
8
8
  entryGates: []
9
9
  exitGates: [product-brief-complete]
10
10
  artifacts: [product-brief]
11
+ steps:
12
+ - name: analysis-step-1-vision
13
+ template: analysis-step-1-vision
14
+ context:
15
+ - placeholder: concept
16
+ source: "param:concept"
17
+ - name: analysis-step-2-scope
18
+ template: analysis-step-2-scope
19
+ context:
20
+ - placeholder: concept
21
+ source: "param:concept"
22
+ - placeholder: vision_output
23
+ source: "step:analysis-step-1-vision"
11
24
  - name: planning
12
25
  description: PRD and requirements generation
13
26
  entryGates: [product-brief-complete]
14
27
  exitGates: [prd-complete]
15
28
  artifacts: [prd]
29
+ steps:
30
+ - name: planning-step-1-classification
31
+ template: planning-step-1-classification
32
+ context:
33
+ - placeholder: product_brief
34
+ source: "decision:analysis.product-brief"
35
+ - name: planning-step-2-frs
36
+ template: planning-step-2-frs
37
+ context:
38
+ - placeholder: product_brief
39
+ source: "decision:analysis.product-brief"
40
+ - placeholder: classification
41
+ source: "step:planning-step-1-classification"
42
+ - name: planning-step-3-nfrs
43
+ template: planning-step-3-nfrs
44
+ context:
45
+ - placeholder: product_brief
46
+ source: "decision:analysis.product-brief"
47
+ - placeholder: classification
48
+ source: "step:planning-step-1-classification"
49
+ - placeholder: functional_requirements
50
+ source: "step:planning-step-2-frs"
16
51
  - name: solutioning
17
52
  description: Architecture and epic/story breakdown
18
53
  entryGates: [prd-complete]
19
54
  exitGates: [architecture-complete, stories-complete, readiness-check]
20
55
  artifacts: [architecture, epics, stories]
56
+ steps:
57
+ - name: architecture-step-1-context
58
+ template: architecture-step-1-context
59
+ context:
60
+ - placeholder: requirements
61
+ source: "decision:planning.functional-requirements"
62
+ - placeholder: nfr
63
+ source: "decision:planning.non-functional-requirements"
64
+ outputCategory: architecture
65
+ - name: architecture-step-2-decisions
66
+ template: architecture-step-2-decisions
67
+ context:
68
+ - placeholder: requirements
69
+ source: "decision:planning.functional-requirements"
70
+ - placeholder: starter_decisions
71
+ source: "step:architecture-step-1-context"
72
+ outputCategory: architecture
73
+ - name: architecture-step-3-patterns
74
+ template: architecture-step-3-patterns
75
+ context:
76
+ - placeholder: architecture_decisions
77
+ source: "decision:solutioning.architecture"
78
+ outputCategory: architecture
79
+ - name: stories-step-1-epics
80
+ template: stories-step-1-epics
81
+ context:
82
+ - placeholder: requirements
83
+ source: "decision:planning.functional-requirements"
84
+ - placeholder: architecture_decisions
85
+ source: "decision:solutioning.architecture"
86
+ outputCategory: epic-design
87
+ - name: stories-step-2-stories
88
+ template: stories-step-2-stories
89
+ context:
90
+ - placeholder: epic_structure
91
+ source: "step:stories-step-1-epics"
92
+ - placeholder: requirements
93
+ source: "decision:planning.functional-requirements"
94
+ - placeholder: architecture_decisions
95
+ source: "decision:solutioning.architecture"
96
+ outputCategory: stories
21
97
  - name: implementation
22
98
  description: Code generation, testing, and review
23
99
  entryGates: [stories-complete]
@@ -33,6 +109,17 @@ prompts:
33
109
  dev-story: prompts/dev-story.md
34
110
  code-review: prompts/code-review.md
35
111
  fix-story: prompts/fix-story.md
112
+ # Multi-step phase decomposition prompts
113
+ analysis-step-1-vision: prompts/analysis-step-1-vision.md
114
+ analysis-step-2-scope: prompts/analysis-step-2-scope.md
115
+ planning-step-1-classification: prompts/planning-step-1-classification.md
116
+ planning-step-2-frs: prompts/planning-step-2-frs.md
117
+ planning-step-3-nfrs: prompts/planning-step-3-nfrs.md
118
+ architecture-step-1-context: prompts/architecture-step-1-context.md
119
+ architecture-step-2-decisions: prompts/architecture-step-2-decisions.md
120
+ architecture-step-3-patterns: prompts/architecture-step-3-patterns.md
121
+ stories-step-1-epics: prompts/stories-step-1-epics.md
122
+ stories-step-2-stories: prompts/stories-step-2-stories.md
36
123
 
37
124
  constraints:
38
125
  create-story: constraints/create-story.yaml
@@ -0,0 +1,51 @@
1
+ # BMAD Analysis Step 1: Vision & Problem Analysis
2
+
3
+ ## Context (pre-assembled by pipeline)
4
+
5
+ ### Project Concept
6
+ {{concept}}
7
+
8
+ ---
9
+
10
+ ## Mission
11
+
12
+ Analyze the project concept above and produce a focused **vision analysis**: a clear problem statement and identification of target users. Do NOT define features or metrics yet — those come in a subsequent step.
13
+
14
+ ## Instructions
15
+
16
+ 1. **Analyze the concept deeply:**
17
+ - What problem does this solve? Who experiences this problem most acutely?
18
+ - What existing solutions exist? Why do they fall short?
19
+ - What would make this succeed vs. fail?
20
+
21
+ 2. **Generate a research-grade problem statement:**
22
+ - A clear, specific articulation of the problem (minimum 2-3 sentences)
23
+ - Ground it in user pain, not technology
24
+ - Include the impact of the problem remaining unsolved
25
+
26
+ 3. **Identify target users:**
27
+ - Specific user segments (not generic labels)
28
+ - Include role, context, and why they care
29
+ - Minimum 2 distinct segments
30
+
31
+ 4. **Quality bar**: Every field should contain enough detail that a product manager could begin scoping from this analysis alone.
32
+
33
+ ## Output Contract
34
+
35
+ Emit ONLY this YAML block as your final output — no other text.
36
+
37
+ **CRITICAL**: All array items MUST be plain strings, NOT objects/maps.
38
+
39
+ ```yaml
40
+ result: success
41
+ problem_statement: "A clear articulation of the problem in 2-3 sentences."
42
+ target_users:
43
+ - "Software developers who work in terminal environments and want habit tracking"
44
+ - "DevOps engineers who need to maintain daily operational checklists"
45
+ ```
46
+
47
+ If you cannot produce valid output:
48
+
49
+ ```yaml
50
+ result: failed
51
+ ```
@@ -0,0 +1,59 @@
1
+ # BMAD Analysis Step 2: Scope & Features
2
+
3
+ ## Context (pre-assembled by pipeline)
4
+
5
+ ### Project Concept
6
+ {{concept}}
7
+
8
+ ### Vision Analysis (from Step 1)
9
+ {{vision_output}}
10
+
11
+ ---
12
+
13
+ ## Mission
14
+
15
+ Building on the vision analysis above, define the **scope**: core features, success metrics, and constraints. The problem statement and target users are already established — now determine WHAT to build and HOW to measure success.
16
+
17
+ ## Instructions
18
+
19
+ 1. **Define core features** that directly address the problem statement:
20
+ - Each feature should be a concrete capability, not a vague category
21
+ - Prioritize by user impact — list the most critical features first
22
+ - Ensure features serve the identified target users
23
+
24
+ 2. **Define measurable success metrics:**
25
+ - Tied to user value and business objectives
26
+ - Include both leading indicators (engagement, adoption) and lagging indicators (retention, revenue)
27
+ - Be specific enough to measure
28
+
29
+ 3. **Identify constraints:**
30
+ - Technical limitations, regulatory requirements, budget boundaries
31
+ - Timeline pressures, platform restrictions, or integration requirements
32
+ - Omit if genuinely none exist
33
+
34
+ 4. **Quality bar**: A product manager should be able to write a PRD from the combined vision + scope output.
35
+
36
+ ## Output Contract
37
+
38
+ Emit ONLY this YAML block as your final output — no other text.
39
+
40
+ **CRITICAL**: All array items MUST be plain strings, NOT objects/maps.
41
+
42
+ ```yaml
43
+ result: success
44
+ core_features:
45
+ - "CLI command to register, check-off, and view daily habits with streak tracking"
46
+ - "Local SQLite storage with export to JSON/CSV for portability"
47
+ success_metrics:
48
+ - "Daily active usage rate >60% among onboarded users within 30 days"
49
+ - "Streak completion rate >40% across all tracked habits"
50
+ constraints:
51
+ - "CLI-only interface limits audience to terminal-comfortable users"
52
+ - "Must work offline with local storage, no cloud dependency"
53
+ ```
54
+
55
+ If you cannot produce valid output:
56
+
57
+ ```yaml
58
+ result: failed
59
+ ```
@@ -0,0 +1,69 @@
1
+ # BMAD Architecture Step 1: Context Analysis
2
+
3
+ ## Context (pre-assembled by pipeline)
4
+
5
+ ### Requirements (from Planning Phase)
6
+ {{requirements}}
7
+
8
+ ### Non-Functional Requirements
9
+ {{nfr}}
10
+
11
+ ---
12
+
13
+ ## Mission
14
+
15
+ Analyze the requirements context and produce **initial architecture decisions** focused on the foundational technology choices: system architecture style, API design, data storage, and project structure. Think like a pragmatic senior architect — choose boring technology that ships.
16
+
17
+ ## Instructions
18
+
19
+ 1. **Make concrete decisions, not suggestions:**
20
+ - Each decision is a key-value pair capturing one architectural concern
21
+ - The `key` identifies WHAT is being decided
22
+ - The `value` states the CHOICE
23
+ - The `rationale` explains WHY this choice over alternatives
24
+
25
+ 2. **Focus on foundational decisions:**
26
+ - **System architecture**: Monolith, modular monolith, microservices, or serverless
27
+ - **API design**: REST, GraphQL, gRPC, or hybrid
28
+ - **Data storage**: Database engine, schema strategy, migration approach
29
+ - **Project structure**: Directory layout, module boundaries, dependency rules
30
+
31
+ 3. **Align with requirements:**
32
+ - Every `must` functional requirement should be architecturally supportable
33
+ - NFRs should directly inform decisions
34
+ - Tech stack choices from planning should be respected
35
+
36
+ 4. **Use the `category` field** to group related decisions:
37
+ - `infrastructure`: deployment, hosting, CI/CD
38
+ - `backend`: API, database, auth, services
39
+ - `frontend`: UI framework, state, routing
40
+ - `crosscutting`: logging, error handling, testing, security
41
+
42
+ ## Output Contract
43
+
44
+ Emit ONLY this YAML block as your final output — no other text.
45
+
46
+ **CRITICAL**: All string values MUST be quoted with double quotes.
47
+
48
+ ```yaml
49
+ result: success
50
+ architecture_decisions:
51
+ - category: "backend"
52
+ key: "system-architecture"
53
+ value: "Modular monolith with clear module boundaries"
54
+ rationale: "Right complexity level for the project scope"
55
+ - category: "backend"
56
+ key: "database"
57
+ value: "SQLite with better-sqlite3 driver"
58
+ rationale: "Zero-config local storage, perfect for CLI tools"
59
+ - category: "backend"
60
+ key: "api-style"
61
+ value: "CLI command interface with Commander.js"
62
+ rationale: "Direct command-line interaction, no HTTP needed"
63
+ ```
64
+
65
+ If you cannot produce valid output:
66
+
67
+ ```yaml
68
+ result: failed
69
+ ```
@@ -0,0 +1,62 @@
1
+ # BMAD Architecture Step 2: Detailed Decisions
2
+
3
+ ## Context (pre-assembled by pipeline)
4
+
5
+ ### Requirements (from Planning Phase)
6
+ {{requirements}}
7
+
8
+ ### Foundational Decisions (from Step 1)
9
+ {{starter_decisions}}
10
+
11
+ ---
12
+
13
+ ## Mission
14
+
15
+ Building on the foundational architecture decisions, produce **detailed architecture decisions** covering authentication, error handling, testing strategy, and remaining architectural concerns. Do NOT repeat decisions from Step 1 — extend and complement them.
16
+
17
+ ## Instructions
18
+
19
+ 1. **Extend the architecture with detailed decisions:**
20
+ - **Authentication/authorization**: Strategy and implementation approach
21
+ - **Error handling**: Strategy for errors, logging, monitoring
22
+ - **Testing strategy**: Unit/integration/E2E split, framework choices
23
+ - **Security**: Input validation, data protection, dependency management
24
+
25
+ 2. **Build on foundational decisions:**
26
+ - Reference the system architecture and data storage choices from Step 1
27
+ - Ensure new decisions are compatible with existing ones
28
+ - Don't contradict or repeat previous decisions
29
+
30
+ 3. **Be concrete:**
31
+ - "JWT with RS256 and 15-minute expiry" not "Use tokens"
32
+ - "Vitest with 80% coverage threshold" not "Write tests"
33
+ - Include rationale for each decision
34
+
35
+ ## Output Contract
36
+
37
+ Emit ONLY this YAML block as your final output — no other text.
38
+
39
+ **CRITICAL**: All string values MUST be quoted with double quotes.
40
+
41
+ ```yaml
42
+ result: success
43
+ architecture_decisions:
44
+ - category: "crosscutting"
45
+ key: "testing-strategy"
46
+ value: "Vitest for unit and integration, no E2E needed for CLI"
47
+ rationale: "Fast execution, native ESM support, compatible with TypeScript"
48
+ - category: "crosscutting"
49
+ key: "error-handling"
50
+ value: "Structured error types with error codes, stderr for errors"
51
+ rationale: "Machine-parseable errors enable automation and debugging"
52
+ - category: "crosscutting"
53
+ key: "logging"
54
+ value: "Structured JSON logging to stderr, configurable verbosity"
55
+ rationale: "Separates data output from diagnostic output"
56
+ ```
57
+
58
+ If you cannot produce valid output:
59
+
60
+ ```yaml
61
+ result: failed
62
+ ```
@@ -0,0 +1,58 @@
1
+ # BMAD Architecture Step 3: Implementation Patterns
2
+
3
+ ## Context (pre-assembled by pipeline)
4
+
5
+ ### Architecture Decisions (from Steps 1 & 2)
6
+ {{architecture_decisions}}
7
+
8
+ ---
9
+
10
+ ## Mission
11
+
12
+ Based on the accumulated architecture decisions, define **implementation patterns** — the concrete coding patterns, conventions, and structural rules that developers will follow. This bridges architecture decisions and actual code.
13
+
14
+ ## Instructions
15
+
16
+ 1. **Define implementation patterns:**
17
+ - Module structure and dependency injection approach
18
+ - Data access patterns (repository pattern, direct queries, ORM)
19
+ - Configuration management approach
20
+ - CLI command registration and routing patterns
21
+
22
+ 2. **Codify conventions:**
23
+ - Naming conventions for files, functions, types
24
+ - Import organization rules
25
+ - Error propagation patterns within the codebase
26
+
27
+ 3. **Output as architecture decisions** with category "patterns":
28
+ - Each pattern is a decision with a clear key, value, and rationale
29
+ - These are prescriptive — developers follow them, not choose between options
30
+
31
+ ## Output Contract
32
+
33
+ Emit ONLY this YAML block as your final output — no other text.
34
+
35
+ **CRITICAL**: All string values MUST be quoted with double quotes.
36
+
37
+ ```yaml
38
+ result: success
39
+ architecture_decisions:
40
+ - category: "patterns"
41
+ key: "dependency-injection"
42
+ value: "Constructor injection with interface-based dependencies"
43
+ rationale: "Enables testing with mocks, keeps modules loosely coupled"
44
+ - category: "patterns"
45
+ key: "data-access"
46
+ value: "Repository pattern wrapping better-sqlite3 prepared statements"
47
+ rationale: "Centralizes SQL, enables query optimization and caching"
48
+ - category: "patterns"
49
+ key: "cli-commands"
50
+ value: "One file per command in src/commands/, registered via index barrel"
51
+ rationale: "Easy to find, add, and test individual commands"
52
+ ```
53
+
54
+ If you cannot produce valid output:
55
+
56
+ ```yaml
57
+ result: failed
58
+ ```
@@ -0,0 +1,50 @@
1
+ # BMAD Planning Step 1: Project Classification
2
+
3
+ ## Context (pre-assembled by pipeline)
4
+
5
+ ### Product Brief (from Analysis Phase)
6
+ {{product_brief}}
7
+
8
+ ---
9
+
10
+ ## Mission
11
+
12
+ Classify the project and establish a clear **vision statement** with key goals. This classification guides the depth and structure of subsequent planning steps (requirements, tech stack, domain model).
13
+
14
+ ## Instructions
15
+
16
+ 1. **Classify the project type:**
17
+ - What kind of software is this? (CLI tool, web app, API service, mobile app, library, platform, etc.)
18
+ - Be specific — "TypeScript CLI tool" not just "application"
19
+
20
+ 2. **Write a vision statement:**
21
+ - One paragraph capturing the aspirational end-state
22
+ - What does the world look like when this product succeeds?
23
+ - Should inspire and constrain — broad enough to motivate, specific enough to guide decisions
24
+
25
+ 3. **Define key goals (3-5):**
26
+ - Concrete, prioritized goals that the project must achieve
27
+ - Each goal should be achievable and verifiable
28
+ - Order by priority — most critical first
29
+
30
+ ## Output Contract
31
+
32
+ Emit ONLY this YAML block as your final output — no other text.
33
+
34
+ **CRITICAL**: All string values MUST be quoted with double quotes. All array items MUST be plain strings.
35
+
36
+ ```yaml
37
+ result: success
38
+ project_type: "TypeScript CLI tool for personal productivity"
39
+ vision: "A lightweight, terminal-native habit tracker that makes consistency visible and rewarding for developers who live in their terminals."
40
+ key_goals:
41
+ - "Provide instant habit tracking without leaving the terminal"
42
+ - "Make streak data visible to motivate daily consistency"
43
+ - "Zero-config setup with local-first data storage"
44
+ ```
45
+
46
+ If you cannot produce valid output:
47
+
48
+ ```yaml
49
+ result: failed
50
+ ```
@@ -0,0 +1,60 @@
1
+ # BMAD Planning Step 2: Functional Requirements & User Stories
2
+
3
+ ## Context (pre-assembled by pipeline)
4
+
5
+ ### Product Brief (from Analysis Phase)
6
+ {{product_brief}}
7
+
8
+ ### Project Classification (from Step 1)
9
+ {{classification}}
10
+
11
+ ---
12
+
13
+ ## Mission
14
+
15
+ Derive **functional requirements** and **user stories** from the product brief and project classification. These define WHAT the system must do from the user's perspective.
16
+
17
+ ## Instructions
18
+
19
+ 1. **Derive functional requirements:**
20
+ - Each FR must be specific, testable, and traceable to a core feature or user need
21
+ - Use MoSCoW prioritization: `must` (MVP-critical), `should` (high-value), `could` (nice-to-have)
22
+ - Minimum 3 FRs, but don't pad — every FR should earn its place
23
+ - Frame as capabilities: "Users can filter by date range" not "Add a date picker component"
24
+
25
+ 2. **Write user stories:**
26
+ - Each story captures a user journey or interaction pattern
27
+ - Title should be scannable; description should explain the "why"
28
+ - Stories bridge the gap between requirements and implementation
29
+
30
+ 3. **Align with classification:**
31
+ - FRs should support the key goals from the classification step
32
+ - Prioritization should reflect the project type and vision
33
+
34
+ ## Output Contract
35
+
36
+ Emit ONLY this YAML block as your final output — no other text.
37
+
38
+ **CRITICAL**: All string values MUST be quoted with double quotes.
39
+
40
+ ```yaml
41
+ result: success
42
+ functional_requirements:
43
+ - description: "Users can register new habits with a name and frequency"
44
+ priority: must
45
+ - description: "Users can view current streaks for all tracked habits"
46
+ priority: must
47
+ - description: "Users can export habit data to JSON or CSV format"
48
+ priority: should
49
+ user_stories:
50
+ - title: "Habit Registration"
51
+ description: "As a developer, I want to register daily habits so I can track my consistency"
52
+ - title: "Streak Dashboard"
53
+ description: "As a user, I want to see my current streaks so I stay motivated"
54
+ ```
55
+
56
+ If you cannot produce valid output:
57
+
58
+ ```yaml
59
+ result: failed
60
+ ```
@@ -0,0 +1,75 @@
1
+ # BMAD Planning Step 3: NFRs, Tech Stack, Domain Model & Scope
2
+
3
+ ## Context (pre-assembled by pipeline)
4
+
5
+ ### Product Brief (from Analysis Phase)
6
+ {{product_brief}}
7
+
8
+ ### Project Classification (from Step 1)
9
+ {{classification}}
10
+
11
+ ### Functional Requirements (from Step 2)
12
+ {{functional_requirements}}
13
+
14
+ ---
15
+
16
+ ## Mission
17
+
18
+ Complete the PRD by defining **non-functional requirements**, **tech stack**, **domain model**, and **out-of-scope items**. These constrain HOW the system is built and what it explicitly does NOT do.
19
+
20
+ ## Instructions
21
+
22
+ 1. **Define non-functional requirements:**
23
+ - Each NFR must have a category (performance, security, scalability, accessibility, reliability)
24
+ - Be concrete: "API responses under 200ms at p95" not "System should be fast"
25
+ - Minimum 2 NFRs covering different categories
26
+ - NFRs should align with the project type and constraints
27
+
28
+ 2. **Specify the tech stack:**
29
+ - Key-value pairs mapping technology concerns to specific choices
30
+ - Use real, current technologies — do not fabricate frameworks
31
+ - Cover at minimum: language, framework, database, testing
32
+ - Choices should align with the product brief constraints
33
+
34
+ 3. **Build the domain model:**
35
+ - Key entities and their relationships
36
+ - Each entity as a key with its attributes/relationships as the value
37
+ - This informs database design and API structure downstream
38
+
39
+ 4. **Define out-of-scope items** to prevent scope creep — what this product explicitly does NOT do.
40
+
41
+ ## Output Contract
42
+
43
+ Emit ONLY this YAML block as your final output — no other text.
44
+
45
+ **CRITICAL**: All string values MUST be quoted with double quotes.
46
+
47
+ ```yaml
48
+ result: success
49
+ non_functional_requirements:
50
+ - description: "CLI commands complete within 200ms for local operations"
51
+ category: "performance"
52
+ - description: "All user data encrypted at rest using AES-256"
53
+ category: "security"
54
+ tech_stack:
55
+ language: "TypeScript"
56
+ framework: "Node.js CLI with Commander"
57
+ database: "SQLite via better-sqlite3"
58
+ testing: "Vitest"
59
+ domain_model:
60
+ Habit:
61
+ attributes: ["name", "frequency", "created_at"]
62
+ relationships: ["has_many: Completions"]
63
+ Completion:
64
+ attributes: ["habit_id", "completed_at"]
65
+ relationships: ["belongs_to: Habit"]
66
+ out_of_scope:
67
+ - "Web or mobile interface"
68
+ - "Cloud sync or multi-device support"
69
+ ```
70
+
71
+ If you cannot produce valid output:
72
+
73
+ ```yaml
74
+ result: failed
75
+ ```