ralphflow 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/{chunk-DOC64TD6.js → chunk-CA4XP6KI.js} +1 -1
  2. package/dist/ralphflow.js +132 -18
  3. package/dist/{server-EX5MWYW4.js → server-64NQCIKJ.js} +88 -21
  4. package/package.json +1 -1
  5. package/src/dashboard/ui/app.js +4 -1
  6. package/src/dashboard/ui/archives.js +27 -2
  7. package/src/dashboard/ui/index.html +1 -1
  8. package/src/dashboard/ui/loop-detail.js +1 -1
  9. package/src/dashboard/ui/sidebar.js +1 -1
  10. package/src/dashboard/ui/state.js +3 -0
  11. package/src/dashboard/ui/styles.css +56 -0
  12. package/src/dashboard/ui/utils.js +30 -0
  13. package/src/templates/code-review/loops/00-collect-loop/changesets.md +3 -0
  14. package/src/templates/code-review/loops/00-collect-loop/prompt.md +179 -0
  15. package/src/templates/code-review/loops/00-collect-loop/tracker.md +16 -0
  16. package/src/templates/code-review/loops/01-spec-review-loop/prompt.md +238 -0
  17. package/src/templates/code-review/loops/01-spec-review-loop/tracker.md +16 -0
  18. package/src/templates/code-review/loops/02-quality-review-loop/issues.md +3 -0
  19. package/src/templates/code-review/loops/02-quality-review-loop/prompt.md +306 -0
  20. package/src/templates/code-review/loops/02-quality-review-loop/tracker.md +16 -0
  21. package/src/templates/code-review/loops/03-fix-loop/prompt.md +265 -0
  22. package/src/templates/code-review/loops/03-fix-loop/tracker.md +16 -0
  23. package/src/templates/code-review/ralphflow.yaml +98 -0
  24. package/src/templates/design-review/loops/00-explore-loop/ideas.md +3 -0
  25. package/src/templates/design-review/loops/00-explore-loop/prompt.md +207 -0
  26. package/src/templates/design-review/loops/00-explore-loop/tracker.md +16 -0
  27. package/src/templates/design-review/loops/01-design-loop/designs.md +3 -0
  28. package/src/templates/design-review/loops/01-design-loop/prompt.md +201 -0
  29. package/src/templates/design-review/loops/01-design-loop/tracker.md +16 -0
  30. package/src/templates/design-review/loops/02-review-loop/prompt.md +255 -0
  31. package/src/templates/design-review/loops/02-review-loop/tracker.md +16 -0
  32. package/src/templates/design-review/loops/03-plan-loop/plans.md +3 -0
  33. package/src/templates/design-review/loops/03-plan-loop/prompt.md +247 -0
  34. package/src/templates/design-review/loops/03-plan-loop/tracker.md +16 -0
  35. package/src/templates/design-review/ralphflow.yaml +84 -0
  36. package/src/templates/systematic-debugging/loops/00-investigate-loop/bugs.md +3 -0
  37. package/src/templates/systematic-debugging/loops/00-investigate-loop/prompt.md +237 -0
  38. package/src/templates/systematic-debugging/loops/00-investigate-loop/tracker.md +16 -0
  39. package/src/templates/systematic-debugging/loops/01-hypothesize-loop/hypotheses.md +3 -0
  40. package/src/templates/systematic-debugging/loops/01-hypothesize-loop/prompt.md +312 -0
  41. package/src/templates/systematic-debugging/loops/01-hypothesize-loop/tracker.md +18 -0
  42. package/src/templates/systematic-debugging/loops/02-fix-loop/fixes.md +3 -0
  43. package/src/templates/systematic-debugging/loops/02-fix-loop/prompt.md +342 -0
  44. package/src/templates/systematic-debugging/loops/02-fix-loop/tracker.md +18 -0
  45. package/src/templates/systematic-debugging/ralphflow.yaml +81 -0
  46. package/src/templates/tdd-implementation/loops/00-spec-loop/prompt.md +208 -0
  47. package/src/templates/tdd-implementation/loops/00-spec-loop/specs.md +3 -0
  48. package/src/templates/tdd-implementation/loops/00-spec-loop/tracker.md +16 -0
  49. package/src/templates/tdd-implementation/loops/01-tdd-loop/prompt.md +323 -0
  50. package/src/templates/tdd-implementation/loops/01-tdd-loop/test-cases.md +3 -0
  51. package/src/templates/tdd-implementation/loops/01-tdd-loop/tracker.md +18 -0
  52. package/src/templates/tdd-implementation/loops/02-verify-loop/prompt.md +226 -0
  53. package/src/templates/tdd-implementation/loops/02-verify-loop/tracker.md +16 -0
  54. package/src/templates/tdd-implementation/loops/02-verify-loop/verifications.md +3 -0
  55. package/src/templates/tdd-implementation/ralphflow.yaml +73 -0
@@ -0,0 +1,255 @@
1
+ # Review Loop — Review Design Specs for Quality and Completeness
2
+
3
+ **App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
4
+
5
+ **You are agent `{{AGENT_NAME}}`.** Multiple agents may work in parallel.
6
+ Coordinate via `tracker.md` — the single source of truth.
7
+ *(If you see the literal text `{{AGENT_NAME}}` above — i.e., it was not substituted — treat your name as `agent-1`.)*
8
+
9
+ Read `.ralph-flow/{{APP_NAME}}/02-review-loop/tracker.md` FIRST to determine where you are.
10
+
11
+ > **Only flag issues that would cause real problems during implementation.** Do not nitpick style, naming preferences, or theoretical concerns. Focus on: missing information, internal contradictions, ambiguous requirements, and unrequested complexity. A design that ships with minor imperfections beats a perfect design that never ships.
12
+
13
+ > Only write to: `.ralph-flow/{{APP_NAME}}/02-review-loop/tracker.md`, `.ralph-flow/{{APP_NAME}}/01-design-loop/designs.md` (for revisions). Read `designs.md` for input.
14
+
15
+ **Pipeline:** `designs.md → YOU → reviewed designs → 03-plan-loop → implementation plans`
16
+
17
+ ---
18
+
19
+ ## Visual Communication Protocol
20
+
21
+ When communicating scope, structure, relationships, or status, render **ASCII diagrams** using Unicode box-drawing characters. These help the user see the full picture at the terminal without scrolling through prose.
22
+
23
+ **Character set:** `┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼ ═ ● ○ ▼ ▶`
24
+
25
+ **Diagram types to use:**
26
+
27
+ - **Scope/Architecture Map** — components and their relationships in a bordered grid
28
+ - **Decomposition Tree** — hierarchical breakdown with `├──` and `└──` branches
29
+ - **Data Flow** — arrows (`──→`) showing how information moves between components
30
+ - **Comparison Table** — bordered table for trade-offs and design options
31
+ - **Status Summary** — bordered box with completion indicators (`✓` done, `◌` pending)
32
+
33
+ **Rules:** Keep diagrams under 20 lines and under 70 characters wide. Populate with real data from current context. Render inside fenced code blocks. Use diagrams to supplement, not replace, prose.
34
+
35
+ ---
36
+
37
+ ## Tracker Lock Protocol
38
+
39
+ Before ANY write to `tracker.md`, you MUST acquire the lock:
40
+
41
+ **Lock file:** `.ralph-flow/{{APP_NAME}}/02-review-loop/.tracker-lock`
42
+
43
+ ### Acquire Lock
44
+ 1. Check if `.tracker-lock` exists
45
+ - Exists AND file is < 60 seconds old → sleep 2s, retry (up to 5 retries)
46
+ - Exists AND file is >= 60 seconds old → stale lock, delete it (agent crashed mid-write)
47
+ - Does not exist → continue
48
+ 2. Write lock: `echo "{{AGENT_NAME}} $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/{{APP_NAME}}/02-review-loop/.tracker-lock`
49
+ 3. Sleep 500ms (`sleep 0.5`)
50
+ 4. Re-read `.tracker-lock` — verify YOUR agent name (`{{AGENT_NAME}}`) is in it
51
+ - Your name → you own the lock, proceed to write `tracker.md`
52
+ - Other name → you lost the race, retry from step 1
53
+ 5. Write your changes to `tracker.md`
54
+ 6. Delete `.tracker-lock` immediately: `rm .ralph-flow/{{APP_NAME}}/02-review-loop/.tracker-lock`
55
+ 7. Never leave a lock held — if your write fails, delete the lock in your error handler
56
+
57
+ ### When to Lock
58
+ - Claiming a design (pending → in_progress)
59
+ - Completing a design (in_progress → completed)
60
+ - Updating stage transitions (spec-review → user-review)
61
+ - Heartbeat updates (bundled with other writes, not standalone)
62
+
63
+ ### When NOT to Lock
64
+ - Reading `tracker.md` — read-only access needs no lock
65
+ - Reading `designs.md` — always read-only
66
+
67
+ ---
68
+
69
+ ## Design Selection Algorithm
70
+
71
+ 1. **Parse tracker** — read `completed_designs`, `## Dependencies`, Designs Queue metadata `{agent, status}`, Agent Status table
72
+ 2. **Update blocked→pending** — for each design with `status: blocked`, check if ALL its dependencies (from `## Dependencies`) are in `completed_designs`. If yes, acquire lock and update to `status: pending`
73
+ 3. **Resume own work** — if any design has `{agent: {{AGENT_NAME}}, status: in_progress}`, resume it (skip to the current stage)
74
+ 4. **Find claimable** — filter designs where `status: pending` AND `agent: -`
75
+ 5. **Claim** — acquire lock, set `{agent: {{AGENT_NAME}}, status: in_progress}`, update your Agent Status row, update `last_heartbeat`, release lock, log the claim
76
+ 6. **Nothing available:**
77
+ - All designs completed → emit `<promise>ALL DESIGNS REVIEWED</promise>`
78
+ - All remaining designs are blocked or claimed by others → log "{{AGENT_NAME}}: waiting — all designs blocked or claimed", exit: `kill -INT $PPID`
79
+
80
+ ### New Design Discovery
81
+
82
+ If you find a design in the Designs Queue without `{agent, status}` metadata (e.g., added by the design loop while agents were running):
83
+ 1. Read the design's `**Depends on:**` field in `designs.md`
84
+ 2. Add the dependency to `## Dependencies` section if not already there (skip if `Depends on: None`)
85
+ 3. Set status to `pending` (all deps in `completed_designs`) or `blocked` (deps incomplete)
86
+ 4. Set agent to `-`
87
+
88
+ ---
89
+
90
+ ## Anti-Hijacking Rules
91
+
92
+ 1. **Never touch another agent's `in_progress` design** — do not modify, complete, or reassign it
93
+ 2. **Respect ordering** — do not skip lower-numbered designs to grab higher-numbered ones unless lower are blocked/claimed
94
+ 3. **Note overlap** — if your design references components from another agent's active design, log a NOTE in the tracker
95
+
96
+ ---
97
+
98
+ ## Heartbeat Protocol
99
+
100
+ Every tracker write includes updating your `last_heartbeat` to current ISO 8601 timestamp in the Agent Status table. If another agent's heartbeat is **30+ minutes stale**, log a WARNING in the tracker log but do NOT auto-reclaim their design — user must manually reset.
101
+
102
+ ---
103
+
104
+ ## Crash Recovery (Self)
105
+
106
+ On fresh start, if your agent name has an `in_progress` design but you have no memory of it:
107
+ - Design already has `**Status:** reviewed` in `designs.md` → mark complete, move to next
108
+ - Design has `**Status:** drafted` → restart from SPEC-REVIEW stage
109
+
110
+ ---
111
+
112
+ ## State Machine (2 stages per design)
113
+
114
+ ```
115
+ SPEC-REVIEW → Review design for completeness, consistency, issues → stage: user-review
116
+ USER-REVIEW → Present reviewed spec to user, get approval or revise → next design
117
+ ```
118
+
119
+ When ALL done: `<promise>ALL DESIGNS REVIEWED</promise>`
120
+
121
+ After completing ANY stage, exit: `kill -INT $PPID`
122
+
123
+ ---
124
+
125
+ ## STAGE 1: SPEC-REVIEW
126
+
127
+ 1. Read tracker → **run design selection algorithm** (see above)
128
+ 2. Read the DESIGN entry from `01-design-loop/designs.md` — read it completely
129
+ 3. Read `CLAUDE.md` for project context and conventions
130
+ 4. If sibling designs are completed, read them to check for cross-design consistency
131
+ 5. Acquire lock → update tracker: your Agent Status row `active_design: DESIGN-{N}`, `stage: spec-review`, `last_heartbeat`, log entry → release lock
132
+ 6. **Run the review checklist** — systematically check each category:
133
+
134
+ **Completeness:**
135
+ - Does every success criterion (from the IDEA source) map to a component?
136
+ - Are all interfaces specified with enough detail to implement?
137
+ - Is the error handling strategy concrete (not just "handle errors gracefully")?
138
+ - Is the testing strategy actionable (specific scenarios, not just "write tests")?
139
+ - Does the file structure plan cover all components?
140
+
141
+ **Consistency:**
142
+ - Do components reference each other correctly? (no dangling references)
143
+ - Does the data flow match the component inputs/outputs?
144
+ - Are naming conventions consistent across the design?
145
+ - Does the design align with patterns described in `CLAUDE.md`?
146
+
147
+ **Clarity:**
148
+ - Could an implementer start coding from this spec without asking questions?
149
+ - Are there any TODOs, TBDs, or placeholder text?
150
+ - Are there ambiguous requirements ("should be fast", "handle edge cases")?
151
+
152
+ **YAGNI Check:**
153
+ - Does the design include features not in the original IDEA's in-scope list?
154
+ - Are there abstractions that only serve a hypothetical future need?
155
+ - Is the component count justified — could simpler structure achieve the same result?
156
+
157
+ 7. **Compile review findings** — categorize each issue:
158
+ - **BLOCKER** — must fix before implementation (missing info, contradictions)
159
+ - **WARNING** — should fix, could cause problems (ambiguity, weak testing)
160
+ - **NOTE** — minor observation, implementer can decide (style, naming)
161
+ 8. **Render a Review Summary** — ASCII bordered diagram:
162
+ ```
163
+ ┌─────────────────────────────────────┐
164
+ │ DESIGN-{N} Review Summary │
165
+ ├──────────┬──────────────────────────┤
166
+ │ BLOCKERS │ {count} issues │
167
+ │ WARNINGS │ {count} issues │
168
+ │ NOTES │ {count} observations │
169
+ ├──────────┴──────────────────────────┤
170
+ │ Verdict: {PASS / REVISE / ESCALATE} │
171
+ └─────────────────────────────────────┘
172
+ ```
173
+ 9. **If BLOCKERS exist and iteration < 3:** Fix them directly in `designs.md` — update the DESIGN entry with corrections. Log each fix. Re-run the review checklist on the revised spec. Repeat up to **3 review iterations**.
174
+ 10. **If BLOCKERS persist after 3 iterations:** Log "ESCALATE — unresolvable issues after 3 review iterations" and proceed to USER-REVIEW with the issues flagged.
175
+ 11. Acquire lock → update tracker: `stage: user-review`, `last_heartbeat`, log entry with review summary → release lock
176
+ 12. Exit: `kill -INT $PPID`
177
+
178
+ ## STAGE 2: USER-REVIEW
179
+
180
+ 1. **Present the reviewed design to the user** with a structured summary:
181
+ - **Render the Review Diagram** from SPEC-REVIEW
182
+ - For each BLOCKER/WARNING found: one-line description and how it was resolved (or flagged)
183
+ - Overall assessment: ready for implementation, or needs user input
184
+ 2. **Ask the user** via `AskUserQuestion` (multiple choice):
185
+ - "Approve — design is ready for planning"
186
+ - "Revise — I have changes (describe what to change)"
187
+ - "Reject — go back to design loop (fundamental issues)"
188
+ 3. **If approved:**
189
+ - Update `**Status:** reviewed` in the DESIGN entry in `designs.md`
190
+ - Mark complete (see step 6 below)
191
+ 4. **If revise:**
192
+ - Apply user's requested changes to the DESIGN entry in `designs.md`
193
+ - Re-run SPEC-REVIEW checklist on the revised sections only
194
+ - Present again — ask for approval. Max 3 revision rounds, then log and proceed.
195
+ 5. **If rejected:**
196
+ - Log rejection reason in tracker
197
+ - Do NOT mark as complete — leave in queue for the design loop to rework
198
+ - Mark design status as `rejected` in tracker queue
199
+ - Move to next design
200
+ 6. **Mark done & unblock dependents:**
201
+ - Acquire lock
202
+ - Add design to `completed_designs` list
203
+ - Check off design in Designs Queue: `[x]`, set `{completed}`
204
+ - **Unblock dependents:** for each design in `## Dependencies` that lists the just-completed design, check if ALL its dependencies are now in `completed_designs`. If yes, update from `blocked` → `pending`
205
+ - Update your Agent Status row: clear `active_design`
206
+ - Update `last_heartbeat`
207
+ - Log entry
208
+ - Release lock
209
+ 7. **Run design selection algorithm again:**
210
+ - Claimable design found → claim it, exit: `kill -INT $PPID`
211
+ - All designs completed → `<promise>ALL DESIGNS REVIEWED</promise>`
212
+ - All blocked/claimed → log "waiting", exit: `kill -INT $PPID`
213
+
214
+ ---
215
+
216
+ ## First-Run Handling
217
+
218
+ If Designs Queue in tracker is empty: read `designs.md`, scan `## DESIGN-{N}:` headers + `**Depends on:**` tags, populate queue with `{agent: -, status: pending|blocked}` metadata (compute from Dependencies), then start.
219
+
220
+ ## Decision Reporting Protocol
221
+
222
+ When you make a substantive decision a human reviewer would want to know about, report it to the dashboard:
223
+
224
+ **When to report:**
225
+ - Review severity classifications (why something is BLOCKER vs. WARNING vs. NOTE)
226
+ - Self-corrections to the design (what you changed and why during spec-review)
227
+ - YAGNI removals (features you flagged as unnecessary and why)
228
+ - Escalation decisions (why issues could not be resolved after 3 iterations)
229
+ - User feedback integration (how you incorporated revision requests)
230
+
231
+ **How to report:**
232
+ ```bash
233
+ curl -s --connect-timeout 2 --max-time 5 -X POST "http://127.0.0.1:4242/api/decision?app=$RALPHFLOW_APP&loop=$RALPHFLOW_LOOP" -H 'Content-Type: application/json' -d '{"item":"DESIGN-{N}","agent":"{{AGENT_NAME}}","decision":"{one-line summary}","reasoning":"{why this choice}"}'
234
+ ```
235
+
236
+ **Do NOT report** routine operations: claiming a design, updating heartbeat, stage transitions, waiting for blocked designs. Only report substantive choices that affect the review outcome.
237
+
238
+ **Best-effort only:** If the dashboard is unreachable (curl fails), continue working normally. Decision reporting must never block or delay your work.
239
+
240
+ ---
241
+
242
+ ## Rules
243
+
244
+ - One design at a time per agent. One stage per iteration.
245
+ - Read tracker first, update tracker last. Always use lock protocol for writes.
246
+ - **Only flag issues that would cause real problems during implementation.** Skip cosmetic and theoretical concerns.
247
+ - Max 3 review iterations per SPEC-REVIEW. If blockers remain, escalate to user.
248
+ - Max 3 revision rounds per USER-REVIEW. If user keeps requesting changes, log and proceed.
249
+ - Designs must have `**Status:** reviewed` before they flow to the plan loop.
250
+ - **Multi-agent: never touch another agent's in_progress design. Coordinate via tracker.md.**
251
+ - When fixing issues in designs.md, preserve the original structure — do not reorganize or reformat sections that are already clear.
252
+
253
+ ---
254
+
255
+ Read `.ralph-flow/{{APP_NAME}}/02-review-loop/tracker.md` now and begin.
@@ -0,0 +1,16 @@
1
+ # Review Loop — Tracker
2
+
3
+ - completed_designs: []
4
+
5
+ ## Agent Status
6
+
7
+ | agent | active_design | stage | last_heartbeat |
8
+ |-------|---------------|-------|----------------|
9
+
10
+ ---
11
+
12
+ ## Dependencies
13
+
14
+ ## Designs Queue
15
+
16
+ ## Log
@@ -0,0 +1,3 @@
1
+ # Plans
2
+
3
+ <!-- Populated by the Plan Loop -->
@@ -0,0 +1,247 @@
1
+ # Plan Loop — Write Implementation Plans from Reviewed Designs
2
+
3
+ **App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
4
+
5
+ Read `.ralph-flow/{{APP_NAME}}/03-plan-loop/tracker.md` FIRST to determine where you are.
6
+
7
+ > **Bite-sized task granularity — 2-5 minute tasks maximize agent autonomy.** Each task must be small enough that an implementer can hold the full context in their head. If a task requires reading more than 3 files to understand, it is too big. If a task takes longer than 5 minutes, split it.
8
+
9
+ > **READ-ONLY FOR SOURCE CODE.** Only write to: `.ralph-flow/{{APP_NAME}}/03-plan-loop/tracker.md`, `.ralph-flow/{{APP_NAME}}/03-plan-loop/plans.md`. Read `designs.md` for input.
10
+
11
+ **Pipeline:** `designs.md → YOU → plans.md → implementation`
12
+
13
+ ---
14
+
15
+ ## Visual Communication Protocol
16
+
17
+ When communicating scope, structure, relationships, or status, render **ASCII diagrams** using Unicode box-drawing characters. These help the user see the full picture at the terminal without scrolling through prose.
18
+
19
+ **Character set:** `┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼ ═ ● ○ ▼ ▶`
20
+
21
+ **Diagram types to use:**
22
+
23
+ - **Scope/Architecture Map** — components and their relationships in a bordered grid
24
+ - **Decomposition Tree** — hierarchical breakdown with `├──` and `└──` branches
25
+ - **Data Flow** — arrows (`──→`) showing how information moves between components
26
+ - **Comparison Table** — bordered table for trade-offs and design options
27
+ - **Status Summary** — bordered box with completion indicators (`✓` done, `◌` pending)
28
+
29
+ **Rules:** Keep diagrams under 20 lines and under 70 characters wide. Populate with real data from current context. Render inside fenced code blocks. Use diagrams to supplement, not replace, prose.
30
+
31
+ ---
32
+
33
+ ## State Machine (3 stages per plan)
34
+
35
+ **FIRST — Check completion.** Read the tracker. If the Plans Queue has entries
36
+ AND every entry is `[x]` (no pending plans):
37
+ 1. **Re-scan `designs.md`** — read all `## DESIGN-{N}:` headers with `**Status:** reviewed`
38
+ and compare against the Plans Queue in the tracker.
39
+ 2. **New reviewed designs found** (in `designs.md` but not in the queue) → add them as
40
+ `- [ ] PLAN-{N}: {title}` to the Plans Queue (PLAN number matches DESIGN number),
41
+ then proceed to process the lowest-numbered ready plan.
42
+ 3. **No new reviewed designs** → write `<promise>ALL PLANS WRITTEN</promise>`.
43
+
44
+ Pick the lowest-numbered `ready` plan. NEVER process a `blocked` plan.
45
+
46
+ ---
47
+
48
+ ```
49
+ STRUCTURE → Map file structure from design, identify all files → stage: plan
50
+ PLAN → Write detailed tasks with exact steps, TDD ordering → stage: review
51
+ REVIEW → Self-review plan completeness and ordering, mark done → kill
52
+ ```
53
+
54
+ ## First-Run / New Plan Detection
55
+
56
+ If Plans Queue in tracker is empty OR all entries are `[x]`: read `designs.md`,
57
+ scan `## DESIGN-{N}:` headers with `**Status:** reviewed`. For any reviewed design
58
+ NOT already in the queue, add as `- [ ] PLAN-{N}: {title}` and build/update the
59
+ Dependency Graph from `**Depends on:**` tags. If new plans were added, proceed.
60
+ If the queue is still empty after scanning, write `<promise>ALL PLANS WRITTEN</promise>`.
61
+
62
+ ---
63
+
64
+ ## STAGE 1: STRUCTURE
65
+
66
+ 1. Read tracker → pick lowest-numbered `ready` plan
67
+ 2. Read the corresponding DESIGN from `01-design-loop/designs.md` — read it completely, including architecture, components, interfaces, file structure plan
68
+ 3. Read `CLAUDE.md` for project context, conventions, file patterns, commands
69
+ 4. **Explore the codebase** — read **20+ key files** to understand:
70
+ - Existing file organization patterns
71
+ - Naming conventions for files, functions, variables
72
+ - Test file locations and patterns
73
+ - Configuration and build setup
74
+ 5. **Map every file** from the design's file structure plan:
75
+ - Files to CREATE (new files that do not exist)
76
+ - Files to MODIFY (existing files that need changes)
77
+ - Files to DELETE (if the design removes functionality)
78
+ - Test files for each component
79
+ 6. **Render a File Structure Map** — ASCII tree diagram showing:
80
+ ```
81
+ project/
82
+ ├── src/
83
+ │ ├── [NEW] component-a.ts
84
+ │ ├── [MOD] existing-file.ts
85
+ │ └── [NEW] component-b.ts
86
+ └── tests/
87
+ ├── [NEW] component-a.test.ts
88
+ └── [NEW] component-b.test.ts
89
+ ```
90
+ 7. **Identify dependencies between files** — which files must be created before others (e.g., interfaces before implementations, utilities before consumers)
91
+ 8. Update tracker: `active_plan: PLAN-{N}`, `stage: plan`, log entry
92
+
93
+ ## STAGE 2: PLAN
94
+
95
+ > **TDD ordering: write the test first, then the implementation, then verify.** Every task that creates or modifies behavior should have a preceding test task. This ensures the implementer always knows what "done" looks like before they start coding.
96
+
97
+ 1. Break the design into **bite-sized tasks** (2-5 minutes each):
98
+ - Each task targets exactly ONE file or ONE small group of tightly coupled files
99
+ - Each task has a single, clear outcome the implementer can verify in seconds
100
+ - Tasks are ordered for TDD: test task → implementation task → verification task
101
+ 2. For each task, write:
102
+ - **Exact file paths** — which files to create or modify
103
+ - **What to do** — specific instructions (not "implement the component" but "create the function `processInput` that takes `InputData` and returns `Result`, handling the three cases described in the design")
104
+ - **Code snippets** — key signatures, interfaces, type definitions that must match the design's interfaces section
105
+ - **Test command** — the exact command to run to verify this task (`npm test -- component-a`, `npx tsc --noEmit`, etc.)
106
+ - **Commit message** — a pre-written commit message for this task
107
+ - **Depends on** — which prior tasks must be complete
108
+ 3. **Render a Task Dependency Graph** — ASCII diagram showing task ordering:
109
+ ```
110
+ STEP-1 (test: interfaces) ──→ STEP-2 (impl: interfaces)
111
+
112
+ STEP-3 (test: component-a) ──→ STEP-4 (impl: component-a)
113
+
114
+ STEP-5 (test: component-b) ──→ STEP-6 (impl: component-b)
115
+
116
+ STEP-7 (integration test)
117
+ ```
118
+ 4. Group tasks into phases:
119
+ - **Phase 1: Foundation** — types, interfaces, utilities
120
+ - **Phase 2: Core** — main components and their tests
121
+ - **Phase 3: Integration** — wiring components together, integration tests
122
+ - **Phase 4: Polish** — error handling, edge cases, documentation
123
+ 5. Update tracker: `stage: review`, log entry
124
+
125
+ ## STAGE 3: REVIEW
126
+
127
+ > **Every design requirement must have a task. Every task must trace back to a design requirement.** If the mapping is not 1:1, the plan is incomplete or bloated.
128
+
129
+ 1. **Completeness check** — walk through the DESIGN entry section by section:
130
+ - Does every component have creation and test tasks?
131
+ - Does every interface have a definition task?
132
+ - Does the error handling strategy have corresponding tasks?
133
+ - Does every success criterion have at least one verification task?
134
+ - Are all files from the file structure plan accounted for?
135
+ 2. **Ordering check:**
136
+ - Can each task be executed with only its dependencies complete? (no implicit dependencies)
137
+ - Is TDD ordering maintained? (tests before implementations)
138
+ - Are foundation tasks (types, interfaces) before consumers?
139
+ 3. **Granularity check:**
140
+ - Is any task longer than 5 minutes of work? → split it
141
+ - Is any task trivial (< 1 minute)? → merge with an adjacent task
142
+ - Does any task require reading more than 3 files to understand? → add context or split
143
+ 4. **Render a Coverage Matrix** — ASCII table mapping design sections to tasks:
144
+ ```
145
+ ┌─────────────────────┬──────────────────────┐
146
+ │ Design Section │ Tasks │
147
+ ├─────────────────────┼──────────────────────┤
148
+ │ Component A │ STEP-1, STEP-2 │
149
+ │ Component B │ STEP-3, STEP-4 │
150
+ │ Data Flow │ STEP-5 │
151
+ │ Error Handling │ STEP-6 │
152
+ │ Integration │ STEP-7 │
153
+ └─────────────────────┴──────────────────────┘
154
+ ```
155
+ 5. **Fix any gaps** found during review — add missing tasks, adjust ordering, split oversized tasks
156
+ 6. Write the final PLAN entry to `03-plan-loop/plans.md` using the format below
157
+ 7. Mark done in tracker: check off queue, completed mapping, `active_plan: none`, `stage: structure`, update Dependency Graph, log
158
+ 8. Exit: `kill -INT $PPID`
159
+
160
+ **PLAN entry format:**
161
+ ```markdown
162
+ ## PLAN-{N}: {Title}
163
+
164
+ **Source:** DESIGN-{N}
165
+ **Depends on:** {PLAN-{M} or "None"}
166
+ **Status:** complete
167
+ **Total Steps:** {count}
168
+ **Estimated Time:** {minutes} minutes
169
+
170
+ ### Phase 1: Foundation
171
+
172
+ #### STEP-{N}.1: {Title}
173
+ - **Files:** `{path/to/file}`
174
+ - **Action:** {CREATE | MODIFY | DELETE}
175
+ - **Do:** {Specific instructions — what to create/change, key signatures, behavior}
176
+ - **Test:** `{exact test command}`
177
+ - **Commit:** `{pre-written commit message}`
178
+ - **Depends on:** {STEP-{N}.X or "None"}
179
+
180
+ ### Phase 2: Core
181
+
182
+ #### STEP-{N}.2: {Title}
183
+ ...
184
+
185
+ ### Phase 3: Integration
186
+
187
+ #### STEP-{N}.X: {Title}
188
+ ...
189
+
190
+ ### Phase 4: Polish
191
+
192
+ #### STEP-{N}.X: {Title}
193
+ ...
194
+
195
+ ### Coverage Matrix
196
+ | Design Section | Steps |
197
+ |----------------|-------|
198
+ | {Section} | STEP-{N}.X, STEP-{N}.Y |
199
+
200
+ ### Verification Checklist
201
+ - [ ] All success criteria from IDEA have corresponding steps
202
+ - [ ] TDD ordering maintained (tests before implementations)
203
+ - [ ] No step exceeds 5 minutes of estimated work
204
+ - [ ] All file paths from design's file structure plan are covered
205
+ - [ ] Every step has a test command or verification method
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Decision Reporting Protocol
211
+
212
+ When you make a substantive decision a human reviewer would want to know about, report it to the dashboard:
213
+
214
+ **When to report:**
215
+ - Task decomposition choices (why you split work at certain boundaries)
216
+ - Ordering decisions (why task A comes before task B when either order could work)
217
+ - Granularity trade-offs (why a task was kept larger or split further than the 2-5 minute guideline)
218
+ - Design interpretation (how you translated an ambiguous design section into concrete tasks)
219
+ - Scope additions (tasks you added that are not explicitly in the design but are necessary)
220
+
221
+ **How to report:**
222
+ ```bash
223
+ curl -s --connect-timeout 2 --max-time 5 -X POST "http://127.0.0.1:4242/api/decision?app=$RALPHFLOW_APP&loop=$RALPHFLOW_LOOP" -H 'Content-Type: application/json' -d '{"item":"PLAN-{N}","agent":"plan-loop","decision":"{one-line summary}","reasoning":"{why this choice}"}'
224
+ ```
225
+
226
+ **Do NOT report** routine operations: picking the next plan, updating tracker, stage transitions. Only report substantive choices that affect the implementation plan.
227
+
228
+ **Best-effort only:** If the dashboard is unreachable (curl fails), continue working normally. Decision reporting must never block or delay your work.
229
+
230
+ ---
231
+
232
+ ## Rules
233
+
234
+ - One plan at a time. All 3 stages run in one iteration, one `kill` at the end.
235
+ - Read tracker first, update tracker last.
236
+ - Append to `plans.md` — never overwrite. PLAN numbers match DESIGN numbers.
237
+ - **Bite-sized tasks: 2-5 minutes each.** If it takes longer, split it.
238
+ - **TDD ordering: test first, implement second, verify third.** Always.
239
+ - Every design requirement must have a task. Every task must trace back to a design requirement.
240
+ - Include exact file paths, code snippets, and test commands. No ambiguity.
241
+ - Plans must be self-contained — an implementer should be able to execute the plan without reading the design.
242
+ - Pre-write commit messages for each task. This forces clarity about what each task delivers.
243
+ - Group tasks into phases (Foundation → Core → Integration → Polish) for natural ordering.
244
+
245
+ ---
246
+
247
+ Read `.ralph-flow/{{APP_NAME}}/03-plan-loop/tracker.md` now and begin.
@@ -0,0 +1,16 @@
1
+ # Plan Loop — Tracker
2
+
3
+ - active_plan: none
4
+ - stage: structure
5
+ - completed_plans: []
6
+ - pending_plans: []
7
+
8
+ ---
9
+
10
+ ## Plans Queue
11
+
12
+ ## Dependency Graph
13
+
14
+ ## Completed Mapping
15
+
16
+ ## Log
@@ -0,0 +1,84 @@
1
+ name: design-review
2
+ description: "Explore → Design → Review → Plan pipeline for design-first development"
3
+ version: 1
4
+ dir: .ralph-flow
5
+
6
+ entities:
7
+ IDEA:
8
+ prefix: IDEA
9
+ data_file: 00-explore-loop/ideas.md
10
+ DESIGN:
11
+ prefix: DESIGN
12
+ data_file: 01-design-loop/designs.md
13
+ PLAN:
14
+ prefix: PLAN
15
+ data_file: 03-plan-loop/plans.md
16
+
17
+ loops:
18
+ explore-loop:
19
+ order: 0
20
+ name: "Explore Loop"
21
+ prompt: 00-explore-loop/prompt.md
22
+ tracker: 00-explore-loop/tracker.md
23
+ data_files:
24
+ - 00-explore-loop/ideas.md
25
+ entities: [IDEA]
26
+ stages: [context, clarify, scope]
27
+ completion: "ALL IDEAS SCOPED"
28
+ feeds: [design-loop]
29
+ multi_agent: false
30
+ model: claude-sonnet-4-6
31
+ cadence: 0
32
+
33
+ design-loop:
34
+ order: 1
35
+ name: "Design Loop"
36
+ prompt: 01-design-loop/prompt.md
37
+ tracker: 01-design-loop/tracker.md
38
+ data_files:
39
+ - 01-design-loop/designs.md
40
+ entities: [DESIGN, IDEA]
41
+ stages: [alternatives, design, document]
42
+ completion: "ALL DESIGNS WRITTEN"
43
+ fed_by: [explore-loop]
44
+ feeds: [review-loop]
45
+ multi_agent: false
46
+ model: claude-sonnet-4-6
47
+ cadence: 0
48
+
49
+ review-loop:
50
+ order: 2
51
+ name: "Review Loop"
52
+ prompt: 02-review-loop/prompt.md
53
+ tracker: 02-review-loop/tracker.md
54
+ entities: [DESIGN]
55
+ stages: [spec-review, user-review]
56
+ completion: "ALL DESIGNS REVIEWED"
57
+ fed_by: [design-loop]
58
+ feeds: [plan-loop]
59
+ model: claude-sonnet-4-6
60
+ multi_agent:
61
+ enabled: true
62
+ max_agents: 2
63
+ strategy: tracker-lock
64
+ agent_placeholder: "{{AGENT_NAME}}"
65
+ lock:
66
+ file: 02-review-loop/.tracker-lock
67
+ type: echo
68
+ stale_seconds: 60
69
+ cadence: 0
70
+
71
+ plan-loop:
72
+ order: 3
73
+ name: "Plan Loop"
74
+ prompt: 03-plan-loop/prompt.md
75
+ tracker: 03-plan-loop/tracker.md
76
+ data_files:
77
+ - 03-plan-loop/plans.md
78
+ entities: [PLAN, DESIGN]
79
+ stages: [structure, plan, review]
80
+ completion: "ALL PLANS WRITTEN"
81
+ fed_by: [review-loop]
82
+ multi_agent: false
83
+ model: claude-sonnet-4-6
84
+ cadence: 0
@@ -0,0 +1,3 @@
1
+ # Bugs
2
+
3
+ <!-- Populated by the investigate loop -->