orchestr8 2.4.0 → 2.6.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 (55) hide show
  1. package/.blueprint/agents/AGENT_BA_CASS.md +50 -25
  2. package/.blueprint/agents/AGENT_DEVELOPER_CODEY.md +60 -69
  3. package/.blueprint/agents/AGENT_SPECIFICATION_ALEX.md +45 -0
  4. package/.blueprint/agents/AGENT_TESTER_NIGEL.md +72 -105
  5. package/.blueprint/features/feature_adaptive-retry/FEATURE_SPEC.md +239 -0
  6. package/.blueprint/features/feature_adaptive-retry/IMPLEMENTATION_PLAN.md +48 -0
  7. package/.blueprint/features/feature_adaptive-retry/story-prompt-modification.md +85 -0
  8. package/.blueprint/features/feature_adaptive-retry/story-retry-config.md +89 -0
  9. package/.blueprint/features/feature_adaptive-retry/story-should-retry.md +98 -0
  10. package/.blueprint/features/feature_adaptive-retry/story-strategy-recommendation.md +85 -0
  11. package/.blueprint/features/feature_agent-guardrails/FEATURE_SPEC.md +328 -0
  12. package/.blueprint/features/feature_agent-guardrails/IMPLEMENTATION_PLAN.md +90 -0
  13. package/.blueprint/features/feature_agent-guardrails/story-citation-requirements.md +50 -0
  14. package/.blueprint/features/feature_agent-guardrails/story-confidentiality.md +50 -0
  15. package/.blueprint/features/feature_agent-guardrails/story-escalation-protocol.md +55 -0
  16. package/.blueprint/features/feature_agent-guardrails/story-source-restrictions.md +50 -0
  17. package/.blueprint/features/feature_feedback-loop/FEATURE_SPEC.md +347 -0
  18. package/.blueprint/features/feature_feedback-loop/IMPLEMENTATION_PLAN.md +71 -0
  19. package/.blueprint/features/feature_feedback-loop/story-feedback-collection.md +63 -0
  20. package/.blueprint/features/feature_feedback-loop/story-feedback-config.md +61 -0
  21. package/.blueprint/features/feature_feedback-loop/story-feedback-insights.md +63 -0
  22. package/.blueprint/features/feature_feedback-loop/story-quality-gates.md +57 -0
  23. package/.blueprint/features/feature_pipeline-history/FEATURE_SPEC.md +239 -0
  24. package/.blueprint/features/feature_pipeline-history/IMPLEMENTATION_PLAN.md +71 -0
  25. package/.blueprint/features/feature_pipeline-history/story-clear-history.md +73 -0
  26. package/.blueprint/features/feature_pipeline-history/story-display-history.md +75 -0
  27. package/.blueprint/features/feature_pipeline-history/story-record-execution.md +76 -0
  28. package/.blueprint/features/feature_pipeline-history/story-show-statistics.md +85 -0
  29. package/.blueprint/features/feature_pipeline-insights/FEATURE_SPEC.md +288 -0
  30. package/.blueprint/features/feature_pipeline-insights/IMPLEMENTATION_PLAN.md +65 -0
  31. package/.blueprint/features/feature_pipeline-insights/story-anomaly-detection.md +71 -0
  32. package/.blueprint/features/feature_pipeline-insights/story-bottleneck-analysis.md +75 -0
  33. package/.blueprint/features/feature_pipeline-insights/story-failure-patterns.md +75 -0
  34. package/.blueprint/features/feature_pipeline-insights/story-json-output.md +75 -0
  35. package/.blueprint/features/feature_pipeline-insights/story-trend-analysis.md +78 -0
  36. package/.blueprint/features/feature_validate-command/FEATURE_SPEC.md +209 -0
  37. package/.blueprint/features/feature_validate-command/IMPLEMENTATION_PLAN.md +59 -0
  38. package/.blueprint/features/feature_validate-command/story-failure-output.md +61 -0
  39. package/.blueprint/features/feature_validate-command/story-node-version-check.md +52 -0
  40. package/.blueprint/features/feature_validate-command/story-run-validation.md +59 -0
  41. package/.blueprint/features/feature_validate-command/story-success-output.md +50 -0
  42. package/.blueprint/system_specification/SYSTEM_SPEC.md +248 -0
  43. package/README.md +174 -40
  44. package/SKILL.md +399 -74
  45. package/bin/cli.js +128 -20
  46. package/package.json +1 -1
  47. package/src/feedback.js +171 -0
  48. package/src/history.js +306 -0
  49. package/src/index.js +57 -2
  50. package/src/init.js +2 -6
  51. package/src/insights.js +504 -0
  52. package/src/retry.js +274 -0
  53. package/src/update.js +10 -2
  54. package/src/validate.js +172 -0
  55. package/src/skills.js +0 -93
package/SKILL.md CHANGED
@@ -14,9 +14,13 @@ description: Run the Alex → Cass → Nigel → Codey pipeline using Task tool
14
14
  | `{FEAT_SPEC}` | `{FEAT_DIR}/FEATURE_SPEC.md` |
15
15
  | `{STORIES}` | `{FEAT_DIR}/story-*.md` |
16
16
  | `{TEST_DIR}` | `./test/artifacts/feature_{slug}` |
17
+ | `{TEST_SPEC}` | `{TEST_DIR}/test-spec.md` |
17
18
  | `{TEST_FILE}` | `./test/feature_{slug}.test.js` |
18
19
  | `{PLAN}` | `{FEAT_DIR}/IMPLEMENTATION_PLAN.md` |
19
20
  | `{QUEUE}` | `.claude/implement-queue.json` |
21
+ | `{HISTORY}` | `.claude/pipeline-history.json` |
22
+ | `{RETRY_CONFIG}` | `.claude/retry-config.json` |
23
+ | `{FEEDBACK_CONFIG}` | `.claude/feedback-config.json` |
20
24
 
21
25
  ## Invocation
22
26
 
@@ -25,6 +29,9 @@ description: Run the Alex → Cass → Nigel → Codey pipeline using Task tool
25
29
  /implement-feature "user-auth" # New feature
26
30
  /implement-feature "user-auth" --pause-after=alex|cass|nigel|codey-plan
27
31
  /implement-feature "user-auth" --no-commit
32
+ /implement-feature "user-auth" --no-feedback # Skip feedback collection
33
+ /implement-feature "user-auth" --no-validate # Skip pre-flight validation
34
+ /implement-feature "user-auth" --no-history # Skip history recording
28
35
  ```
29
36
 
30
37
  ## Pipeline Overview
@@ -34,16 +41,62 @@ description: Run the Alex → Cass → Nigel → Codey pipeline using Task tool
34
41
 
35
42
 
36
43
  ┌─────────────────────────────────────────┐
44
+ │ 0. Pre-flight validation (validate.js) │
37
45
  │ 1. Parse args, get slug │
38
46
  │ 2. Check system spec exists (gate) │
39
- │ 3. Initialize queue
40
- │ 4. Route based on flags/state
47
+ │ 3. Show insights preview (insights.js)
48
+ │ 4. Initialize queue + history entry
49
+ │ 5. Route based on flags/state │
41
50
  └─────────────────────────────────────────┘
42
51
 
43
52
 
44
- SPAWN ALEX → SPAWN CASS → SPAWN NIGEL → SPAWN CODEY AUTO-COMMIT
53
+ ALEX → [feedback] CASS → [feedback] NIGEL → [feedback]CODEY
54
+ │ │
55
+ └──────────── Record timing in history.js ──────────────────┘
56
+ │ │
57
+ └──────────── On failure: retry.js strategy ────────────────┘
58
+
59
+
60
+ AUTO-COMMIT → Record completion in history
45
61
  ```
46
62
 
63
+ ## Output Constraints (CRITICAL)
64
+
65
+ **All agents MUST follow these rules to avoid token limit errors:**
66
+
67
+ 1. **Write files incrementally** - Write each file separately, never combine multiple files in one response
68
+ 2. **Keep summaries brief** - Final completion summaries should be 5-10 bullet points max
69
+ 3. **Reference, don't repeat** - Use file paths instead of quoting content from other artifacts
70
+ 4. **One concern per file** - Don't merge unrelated content into single large files
71
+ 5. **Chunk large files** - If a file would exceed ~200 lines, split into logical parts
72
+
73
+ ---
74
+
75
+ ## Step 0: Pre-flight Validation (NEW)
76
+
77
+ **Module:** `src/validate.js`
78
+
79
+ Unless `--no-validate` flag is set:
80
+
81
+ ```bash
82
+ # Run validation checks
83
+ node bin/cli.js validate
84
+ ```
85
+
86
+ **Checks performed:**
87
+ - Required directories exist (`.blueprint/`, `.business_context/`)
88
+ - System spec exists
89
+ - All 4 agent spec files present
90
+ - Business context has content
91
+ - Skills installed
92
+ - Node.js version >= 18
93
+
94
+ **On validation failure:**
95
+ - Show which checks failed with fix suggestions
96
+ - Ask user: "Fix issues and retry?" or "Continue anyway?" or "Abort"
97
+
98
+ **On validation success:** Continue to Step 1
99
+
47
100
  ---
48
101
 
49
102
  ## Steps 1-5: Setup
@@ -57,6 +110,23 @@ If not provided: Ask user, convert to slug format (lowercase, hyphens), confirm.
57
110
  ### Step 3: System Spec Gate
58
111
  Check `{SYS_SPEC}` exists. If not: run Alex to create it, then **stop for review**.
59
112
 
113
+ ### Step 3.5: Insights Preview (NEW)
114
+
115
+ **Module:** `src/insights.js`
116
+
117
+ Unless `--no-history` flag is set, show pipeline insights:
118
+
119
+ ```bash
120
+ node bin/cli.js insights --json 2>/dev/null
121
+ ```
122
+
123
+ **Display to user:**
124
+ - Recent success rate (e.g., "Last 10 runs: 85% success")
125
+ - Estimated duration (e.g., "Estimated: ~12 min based on history")
126
+ - Any warnings (e.g., "Note: Nigel stage has 30% failure rate recently")
127
+
128
+ If no history exists, skip this step silently.
129
+
60
130
  ### Step 4: Route
61
131
  - Slug exists at `{FEAT_DIR}` → ask: continue from last state or restart
62
132
  - No slug → new feature pipeline
@@ -64,10 +134,26 @@ Check `{SYS_SPEC}` exists. If not: run Alex to create it, then **stop for review
64
134
  ### Step 5: Initialize
65
135
  Create/read `{QUEUE}`. Ensure dirs exist: `mkdir -p {FEAT_DIR} {TEST_DIR}`
66
136
 
137
+ **History Integration (NEW):**
138
+
139
+ Unless `--no-history` flag is set, start a history entry:
140
+
141
+ ```javascript
142
+ // Conceptual - orchestrator tracks this in memory
143
+ historyEntry = {
144
+ slug: "{slug}",
145
+ startedAt: new Date().toISOString(),
146
+ stages: {},
147
+ feedback: {}
148
+ }
149
+ ```
150
+
67
151
  ---
68
152
 
69
153
  ## Step 6: Spawn Alex Agent
70
154
 
155
+ **History:** Record `stages.alex.startedAt` before spawning.
156
+
71
157
  Use the Task tool with `subagent_type="general-purpose"`:
72
158
 
73
159
  **Prompt:**
@@ -87,26 +173,56 @@ Create a feature specification for "{slug}".
87
173
  ## Output (write this file)
88
174
  Write the feature spec to: {FEAT_DIR}/FEATURE_SPEC.md
89
175
 
176
+ ## Output Rules
177
+ - Write file incrementally (section by section if large)
178
+ - Only include sections relevant to this feature (skip empty/N/A sections)
179
+ - Reference system spec by path, don't repeat its content
180
+ - Keep Change Log to 1-2 entries max
181
+
90
182
  ## Completion
91
- When done, summarize:
92
- - Feature intent
93
- - Key behaviours
94
- - Scope boundaries
95
- - Story themes you recommend
96
- - Any system spec tensions found
183
+ Brief summary (5 bullets max): intent, key behaviours, scope, story themes, tensions
97
184
  ```
98
185
 
99
186
  **On completion:**
100
187
  1. Verify `{FEAT_SPEC}` exists
101
- 2. Update queue: move feature to `cassQueue`
102
- 3. If `--pause-after=alex`: Show output path, ask user to continue
188
+ 2. **Record history:** `stages.alex = { completedAt, durationMs, status: "success" }`
189
+ 3. Update queue: move feature to `cassQueue`
190
+ 4. If `--pause-after=alex`: Show output path, ask user to continue
103
191
 
104
- **On failure:** Ask user (retry / skip / abort)
192
+ **On failure:** See [Error Handling with Retry](#error-handling-with-smart-retry)
193
+
194
+ ---
195
+
196
+ ## Step 6.5: Cass Feedback on Alex (NEW)
197
+
198
+ **Module:** `src/feedback.js`
199
+
200
+ Unless `--no-feedback` flag is set, collect feedback before Cass writes stories:
201
+
202
+ **Prompt addition to Cass:**
203
+ ```
204
+ FIRST, before writing stories, evaluate Alex's feature spec:
205
+ - Rating (1-5): How clear and complete is the spec?
206
+ - Issues: List any problems (e.g., "missing-error-handling", "unclear-scope")
207
+ - Recommendation: "proceed" | "pause" | "revise"
208
+
209
+ Output your feedback as:
210
+ FEEDBACK: { "rating": N, "issues": [...], "recommendation": "..." }
211
+ ```
212
+
213
+ **Quality Gate Check:**
214
+ - If rating < minRatingThreshold (default 3.0) OR recommendation = "pause"
215
+ - Ask user: "Cass rated Alex's spec {N}/5. Issues: {issues}. Continue anyway?"
216
+ - Options: Continue / Review spec / Abort
217
+
218
+ **Store feedback:** `feedback.cass = { about: "alex", rating, issues, recommendation }`
105
219
 
106
220
  ---
107
221
 
108
222
  ## Step 7: Spawn Cass Agent
109
223
 
224
+ **History:** Record `stages.cass.startedAt` before spawning.
225
+
110
226
  Use the Task tool with `subagent_type="general-purpose"`:
111
227
 
112
228
  **Prompt:**
@@ -128,29 +244,56 @@ Create one markdown file per user story in {FEAT_DIR}/:
128
244
 
129
245
  Each story must include:
130
246
  - User story in standard format
131
- - Context/scope
132
- - Acceptance criteria (Given/When/Then)
133
- - Session persistence shape (if relevant)
134
- - Out of scope items
247
+ - Acceptance criteria (Given/When/Then) - max 5-7 per story
248
+ - Out of scope items (brief list)
249
+
250
+ ## Output Rules
251
+ - Write ONE story file at a time, then move to next
252
+ - Keep each story focused - split large stories into multiple files
253
+ - Reference feature spec by path for shared context
254
+ - Skip boilerplate sections (session shape only if non-obvious)
135
255
 
136
256
  ## Completion
137
- When done, summarize:
138
- - Number of stories created
139
- - Story filenames
140
- - Key behaviours covered
257
+ Brief summary: story count, filenames, behaviours covered (5 bullets max)
141
258
  ```
142
259
 
143
260
  **On completion:**
144
261
  1. Verify at least one `story-*.md` exists in `{FEAT_DIR}`
145
- 2. Update queue: move feature to `nigelQueue`
146
- 3. If `--pause-after=cass`: Show story paths, ask user to continue
262
+ 2. **Record history:** `stages.cass = { completedAt, durationMs, status: "success" }`
263
+ 3. Update queue: move feature to `nigelQueue`
264
+ 4. If `--pause-after=cass`: Show story paths, ask user to continue
265
+
266
+ **On failure:** See [Error Handling with Retry](#error-handling-with-smart-retry)
147
267
 
148
- **On failure:** Ask user (retry / skip / abort)
268
+ ---
269
+
270
+ ## Step 7.5: Nigel Feedback on Cass (NEW)
271
+
272
+ **Module:** `src/feedback.js`
273
+
274
+ Unless `--no-feedback` flag is set:
275
+
276
+ **Prompt addition to Nigel:**
277
+ ```
278
+ FIRST, before writing tests, evaluate Cass's user stories:
279
+ - Rating (1-5): How testable are the stories?
280
+ - Issues: List any problems (e.g., "ambiguous-ac", "missing-edge-cases")
281
+ - Recommendation: "proceed" | "pause" | "revise"
282
+
283
+ Output your feedback as:
284
+ FEEDBACK: { "rating": N, "issues": [...], "recommendation": "..." }
285
+ ```
286
+
287
+ **Quality Gate Check:** Same as Step 6.5
288
+
289
+ **Store feedback:** `feedback.nigel = { about: "cass", rating, issues, recommendation }`
149
290
 
150
291
  ---
151
292
 
152
293
  ## Step 8: Spawn Nigel Agent
153
294
 
295
+ **History:** Record `stages.nigel.startedAt` before spawning.
296
+
154
297
  Use the Task tool with `subagent_type="general-purpose"`:
155
298
 
156
299
  **Prompt:**
@@ -165,36 +308,66 @@ Create tests for feature "{slug}".
165
308
  ## Inputs (read these files)
166
309
  - Stories: {FEAT_DIR}/story-*.md
167
310
  - Feature Spec: {FEAT_DIR}/FEATURE_SPEC.md
168
- - System Spec: .blueprint/system_specification/SYSTEM_SPEC.md
169
311
 
170
- ## Outputs (write these files)
171
- 1. Test artifacts in {TEST_DIR}/:
172
- - understanding.md
173
- - test-plan.md
174
- - test-behaviour-matrix.md
175
- - implementation-guide.md
312
+ ## Outputs (write these files IN ORDER, one at a time)
176
313
 
177
- 2. Executable tests:
178
- - {TEST_FILE}
314
+ Step 1: Write {TEST_DIR}/test-spec.md containing:
315
+ - Brief understanding (5-10 lines)
316
+ - AC → Test ID mapping table (compact)
317
+ - Key assumptions (bullet list)
318
+
319
+ Step 2: Write {TEST_FILE} containing:
320
+ - Executable tests (Jest/Node test runner)
321
+ - Group by user story
322
+ - One describe block per story, one test per AC
323
+
324
+ ## Output Rules
325
+ - Write test-spec.md FIRST, then write test file
326
+ - Keep test-spec.md under 100 lines (table format, no prose)
327
+ - Tests should be self-documenting - minimal comments
328
+ - Reference story files by path in test descriptions
179
329
 
180
330
  ## Completion
181
- When done, summarize:
182
- - Test count
183
- - Coverage of acceptance criteria
184
- - Key assumptions made
331
+ Brief summary: test count, AC coverage %, assumptions (5 bullets max)
185
332
  ```
186
333
 
187
334
  **On completion:**
188
- 1. Verify `{TEST_FILE}` exists
189
- 2. Update queue: move feature to `codeyQueue`
190
- 3. If `--pause-after=nigel`: Show test paths, ask user to continue
335
+ 1. Verify `{TEST_SPEC}` and `{TEST_FILE}` exist
336
+ 2. **Record history:** `stages.nigel = { completedAt, durationMs, status: "success" }`
337
+ 3. Update queue: move feature to `codeyQueue`
338
+ 4. If `--pause-after=nigel`: Show test paths, ask user to continue
191
339
 
192
- **On failure:** Ask user (retry / skip / abort)
340
+ **On failure:** See [Error Handling with Retry](#error-handling-with-smart-retry)
341
+
342
+ ---
343
+
344
+ ## Step 8.5: Codey Feedback on Nigel (NEW)
345
+
346
+ **Module:** `src/feedback.js`
347
+
348
+ Unless `--no-feedback` flag is set:
349
+
350
+ **Prompt addition to Codey (Plan phase):**
351
+ ```
352
+ FIRST, before creating the plan, evaluate Nigel's tests:
353
+ - Rating (1-5): How implementable are the tests?
354
+ - Issues: List any problems (e.g., "over-mocked", "missing-setup")
355
+ - Recommendation: "proceed" | "pause" | "revise"
356
+
357
+ Output your feedback as:
358
+ FEEDBACK: { "rating": N, "issues": [...], "recommendation": "..." }
359
+ ```
360
+
361
+ **Quality Gate Check:** Same as Step 6.5
362
+
363
+ **Store feedback:** `feedback.codey = { about: "nigel", rating, issues, recommendation }`
193
364
 
194
365
  ---
195
366
 
196
367
  ## Step 9: Spawn Codey Agent (Plan)
197
368
 
369
+ **History:** Record `stages.codeyPlan.startedAt` before spawning.
370
+
198
371
  Use the Task tool with `subagent_type="general-purpose"`:
199
372
 
200
373
  **Prompt:**
@@ -209,33 +382,32 @@ Create an implementation plan for feature "{slug}". Do NOT implement yet.
209
382
  ## Inputs (read these files)
210
383
  - Feature Spec: {FEAT_DIR}/FEATURE_SPEC.md
211
384
  - Stories: {FEAT_DIR}/story-*.md
212
- - Test Artifacts: {TEST_DIR}/
385
+ - Test Spec: {TEST_DIR}/test-spec.md
213
386
  - Tests: {TEST_FILE}
214
387
 
215
388
  ## Output (write this file)
216
389
  Write implementation plan to: {FEAT_DIR}/IMPLEMENTATION_PLAN.md
217
390
 
218
- Plan structure:
219
- ## Summary
220
- ## Understanding (behaviors, test count)
221
- ## Files to Create/Modify
222
- ## Implementation Steps
223
- ## Data Model (if applicable)
224
- ## Validation Rules
225
- ## Risks/Questions
226
- ## Definition of Done
391
+ Plan structure (keep concise - aim for <80 lines total):
392
+ ## Summary (2-3 sentences)
393
+ ## Files to Create/Modify (table: path | action | purpose)
394
+ ## Implementation Steps (numbered, max 10 steps)
395
+ ## Risks/Questions (bullet list, only if non-obvious)
227
396
  ```
228
397
 
229
398
  **On completion:**
230
399
  1. Verify `{PLAN}` exists
231
- 2. If `--pause-after=codey-plan`: Show plan path, ask user to continue
400
+ 2. **Record history:** `stages.codeyPlan = { completedAt, durationMs, status: "success" }`
401
+ 3. If `--pause-after=codey-plan`: Show plan path, ask user to continue
232
402
 
233
- **On failure:** Ask user (retry / skip / abort)
403
+ **On failure:** See [Error Handling with Retry](#error-handling-with-smart-retry)
234
404
 
235
405
  ---
236
406
 
237
407
  ## Step 10: Spawn Codey Agent (Implement)
238
408
 
409
+ **History:** Record `stages.codeyImplement.startedAt` before spawning.
410
+
239
411
  Use the Task tool with `subagent_type="general-purpose"`:
240
412
 
241
413
  **Prompt:**
@@ -249,35 +421,38 @@ Implement feature "{slug}" according to the plan.
249
421
 
250
422
  ## Inputs (read these files)
251
423
  - Implementation Plan: {FEAT_DIR}/IMPLEMENTATION_PLAN.md
252
- - Feature Spec: {FEAT_DIR}/FEATURE_SPEC.md
253
- - Stories: {FEAT_DIR}/story-*.md
254
- - Test Artifacts: {TEST_DIR}/
255
424
  - Tests: {TEST_FILE}
256
425
 
257
- ## Process
258
- 1. Run tests to establish baseline: npm test
259
- 2. Implement code to make tests pass
260
- 3. Run npm test to verify all tests pass
261
- 4. Run npm run lint (if available) to verify code quality
426
+ ## Process (INCREMENTAL - one file at a time)
427
+ 1. Run tests: node --test {TEST_FILE}
428
+ 2. For each failing test group:
429
+ a. Identify the minimal code needed
430
+ b. Write/edit ONE file
431
+ c. Run tests again
432
+ d. Repeat until group passes
433
+ 3. Move to next test group
434
+
435
+ ## Output Rules
436
+ - Write ONE source file at a time
437
+ - Run tests after each file write
438
+ - Keep functions small (<30 lines)
439
+ - No explanatory comments in code - code should be self-documenting
262
440
 
263
441
  ## Important
264
442
  - Do NOT commit changes
265
443
  - Do NOT modify test assertions unless they contain bugs
266
- - Focus on making tests pass
267
444
 
268
445
  ## Completion
269
- When done, summarize:
270
- - Files created/modified
271
- - Test status (pass/fail count)
272
- - Any issues encountered
446
+ Brief summary: files changed (list), test status (X/Y passing), blockers if any
273
447
  ```
274
448
 
275
449
  **On completion:**
276
450
  1. Run `npm test` to verify
277
- 2. Update queue: move feature to `completed`
278
- 3. Proceed to auto-commit (unless `--no-commit`)
451
+ 2. **Record history:** `stages.codeyImplement = { completedAt, durationMs, status: "success" }`
452
+ 3. Update queue: move feature to `completed`
453
+ 4. Proceed to auto-commit (unless `--no-commit`)
279
454
 
280
- **On failure:** Ask user (retry / skip / abort)
455
+ **On failure:** See [Error Handling with Retry](#error-handling-with-smart-retry)
281
456
 
282
457
  ---
283
458
 
@@ -306,29 +481,128 @@ Co-Authored-By: Claude <noreply@anthropic.com>
306
481
 
307
482
  ---
308
483
 
309
- ## Step 12: Report Status
484
+ ## Step 12: Report Status & Finalize History (ENHANCED)
485
+
486
+ **Module:** `src/history.js`
310
487
 
488
+ Unless `--no-history` flag is set, finalize the history entry:
489
+
490
+ ```javascript
491
+ historyEntry.status = "success";
492
+ historyEntry.completedAt = new Date().toISOString();
493
+ historyEntry.totalDurationMs = completedAt - startedAt;
494
+ historyEntry.commitHash = "{hash}";
495
+ // Save to .claude/pipeline-history.json
496
+ ```
497
+
498
+ **Display summary:**
311
499
  ```
312
500
  ## Completed
313
501
  - feature_{slug}
314
502
  - Stories: N
315
503
  - Tests: N (all passing)
504
+ - Duration: X min (avg: Y min)
316
505
  - Commit: {hash}
317
506
 
507
+ ## Feedback Summary
508
+ - Alex spec: rated 4/5 by Cass
509
+ - Cass stories: rated 5/5 by Nigel
510
+ - Nigel tests: rated 4/5 by Codey
511
+
318
512
  ## Next Action
319
513
  Pipeline complete. Run `npm test` to verify or `/implement-feature` for next feature.
320
514
  ```
321
515
 
322
516
  ---
323
517
 
324
- ## Error Handling
518
+ ## Error Handling with Smart Retry (ENHANCED)
519
+
520
+ **Modules:** `src/retry.js`, `src/feedback.js`, `src/insights.js`
325
521
 
326
522
  After each agent spawn, if the Task tool returns an error or output validation fails:
327
523
 
328
- **Ask the user:**
329
- 1. **Retry** - Re-run the agent with same inputs
330
- 2. **Skip** - Move to next stage anyway (with warning about missing artifacts)
331
- 3. **Abort** - Stop pipeline, update queue with failure for recovery
524
+ ### 1. Analyze Failure Context
525
+
526
+ **Check feedback chain for clues:**
527
+ ```
528
+ If Cass flagged "unclear-scope" on Alex's spec
529
+ → Likely root cause identified
530
+ → Recommend: "add-context" strategy
531
+ ```
532
+
533
+ **Check history for patterns:**
534
+ ```bash
535
+ node bin/cli.js insights --failures --json
536
+ ```
537
+ - If this stage has >20% failure rate, suggest alternative strategy
538
+ - If this specific issue pattern correlates with failures, mention it
539
+
540
+ ### 2. Get Retry Strategy Recommendation
541
+
542
+ **Module:** `src/retry.js`
543
+
544
+ ```
545
+ Strategy recommendation based on:
546
+ - Stage: {stage}
547
+ - Attempt: {attemptNumber}
548
+ - Failure rate: {rate}%
549
+ - Feedback issues: {issues}
550
+
551
+ Recommended: {strategy}
552
+ ```
553
+
554
+ **Available strategies:**
555
+ | Strategy | Effect |
556
+ |----------|--------|
557
+ | `retry` | Simple retry with same prompt |
558
+ | `simplify-prompt` | Reduce scope: "Focus only on core happy path" |
559
+ | `add-context` | Include more output from previous stages |
560
+ | `reduce-stories` | Ask for fewer, more focused stories |
561
+ | `simplify-tests` | Ask for fewer, essential tests only |
562
+ | `incremental` | Implement one test at a time |
563
+
564
+ ### 3. Ask User with Recommendation
565
+
566
+ ```
567
+ ## Stage Failed: {stage}
568
+
569
+ Feedback context: Cass flagged "unclear-scope" on Alex's spec
570
+ History: This stage fails 25% of the time
571
+ Recommended strategy: add-context
572
+
573
+ Options:
574
+ 1. Retry with "add-context" strategy (recommended)
575
+ 2. Retry with simple retry
576
+ 3. Skip this stage (warning: missing artifacts)
577
+ 4. Abort pipeline
578
+ ```
579
+
580
+ ### 4. Apply Strategy and Retry
581
+
582
+ If user selects a retry strategy, modify the agent prompt:
583
+
584
+ **Example: add-context strategy**
585
+ ```
586
+ [Original prompt]
587
+
588
+ ## Additional Context (added due to retry)
589
+ Previous stage feedback indicated: "unclear-scope"
590
+ Here is additional context from earlier stages:
591
+ - System spec key points: [summary]
592
+ - Feature spec key decisions: [summary]
593
+ ```
594
+
595
+ ### 5. Record Failure in History
596
+
597
+ ```javascript
598
+ historyEntry.stages[stage] = {
599
+ status: "failed",
600
+ failedAt: "...",
601
+ attempts: N,
602
+ lastStrategy: "add-context",
603
+ feedbackContext: ["unclear-scope"]
604
+ };
605
+ ```
332
606
 
333
607
  **On abort:** Update queue `failed` array with:
334
608
  ```json
@@ -336,6 +610,8 @@ After each agent spawn, if the Task tool returns an error or output validation f
336
610
  "slug": "{slug}",
337
611
  "stage": "{stage}",
338
612
  "reason": "{error message}",
613
+ "feedbackContext": ["issues from feedback chain"],
614
+ "attemptCount": N,
339
615
  "timestamp": "{ISO timestamp}"
340
616
  }
341
617
  ```
@@ -379,3 +655,52 @@ Run `/implement-feature` again - reads queue and resumes from `current.stage`.
379
655
  | Cass | `.blueprint/agents/AGENT_BA_CASS.md` |
380
656
  | Nigel | `.blueprint/agents/AGENT_TESTER_NIGEL.md` |
381
657
  | Codey | `.blueprint/agents/AGENT_DEVELOPER_CODEY.md` |
658
+
659
+ ---
660
+
661
+ ## Module Integration Summary (NEW)
662
+
663
+ The pipeline integrates these orchestr8 modules:
664
+
665
+ | Module | File | Integration Points |
666
+ |--------|------|-------------------|
667
+ | **validate** | `src/validate.js` | Step 0: Pre-flight checks |
668
+ | **history** | `src/history.js` | Steps 5-12: Record timing, finalize entry |
669
+ | **insights** | `src/insights.js` | Step 3.5: Preview, On failure: Analysis |
670
+ | **feedback** | `src/feedback.js` | Steps 6.5, 7.5, 8.5: Quality gates |
671
+ | **retry** | `src/retry.js` | On failure: Strategy recommendation |
672
+
673
+ ### CLI Commands Available
674
+
675
+ ```bash
676
+ # Pre-flight validation
677
+ npx orchestr8 validate
678
+
679
+ # History management
680
+ npx orchestr8 history
681
+ npx orchestr8 history --stats
682
+ npx orchestr8 history --all
683
+
684
+ # Pipeline insights
685
+ npx orchestr8 insights
686
+ npx orchestr8 insights --feedback
687
+ npx orchestr8 insights --bottlenecks
688
+ npx orchestr8 insights --failures
689
+
690
+ # Retry configuration
691
+ npx orchestr8 retry-config
692
+ npx orchestr8 retry-config set maxRetries 5
693
+
694
+ # Feedback configuration
695
+ npx orchestr8 feedback-config
696
+ npx orchestr8 feedback-config set minRatingThreshold 3.5
697
+ ```
698
+
699
+ ### Data Files Created
700
+
701
+ | File | Purpose |
702
+ |------|---------|
703
+ | `.claude/pipeline-history.json` | Execution history with timing and feedback |
704
+ | `.claude/retry-config.json` | Retry strategies and thresholds |
705
+ | `.claude/feedback-config.json` | Feedback quality gate thresholds |
706
+ | `.claude/implement-queue.json` | Pipeline queue state (existing) |