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.
- package/dist/{chunk-DOC64TD6.js → chunk-CA4XP6KI.js} +1 -1
- package/dist/ralphflow.js +132 -18
- package/dist/{server-EX5MWYW4.js → server-64NQCIKJ.js} +88 -21
- package/package.json +1 -1
- package/src/dashboard/ui/app.js +4 -1
- package/src/dashboard/ui/archives.js +27 -2
- package/src/dashboard/ui/index.html +1 -1
- package/src/dashboard/ui/loop-detail.js +1 -1
- package/src/dashboard/ui/sidebar.js +1 -1
- package/src/dashboard/ui/state.js +3 -0
- package/src/dashboard/ui/styles.css +56 -0
- package/src/dashboard/ui/utils.js +30 -0
- package/src/templates/code-review/loops/00-collect-loop/changesets.md +3 -0
- package/src/templates/code-review/loops/00-collect-loop/prompt.md +179 -0
- package/src/templates/code-review/loops/00-collect-loop/tracker.md +16 -0
- package/src/templates/code-review/loops/01-spec-review-loop/prompt.md +238 -0
- package/src/templates/code-review/loops/01-spec-review-loop/tracker.md +16 -0
- package/src/templates/code-review/loops/02-quality-review-loop/issues.md +3 -0
- package/src/templates/code-review/loops/02-quality-review-loop/prompt.md +306 -0
- package/src/templates/code-review/loops/02-quality-review-loop/tracker.md +16 -0
- package/src/templates/code-review/loops/03-fix-loop/prompt.md +265 -0
- package/src/templates/code-review/loops/03-fix-loop/tracker.md +16 -0
- package/src/templates/code-review/ralphflow.yaml +98 -0
- package/src/templates/design-review/loops/00-explore-loop/ideas.md +3 -0
- package/src/templates/design-review/loops/00-explore-loop/prompt.md +207 -0
- package/src/templates/design-review/loops/00-explore-loop/tracker.md +16 -0
- package/src/templates/design-review/loops/01-design-loop/designs.md +3 -0
- package/src/templates/design-review/loops/01-design-loop/prompt.md +201 -0
- package/src/templates/design-review/loops/01-design-loop/tracker.md +16 -0
- package/src/templates/design-review/loops/02-review-loop/prompt.md +255 -0
- package/src/templates/design-review/loops/02-review-loop/tracker.md +16 -0
- package/src/templates/design-review/loops/03-plan-loop/plans.md +3 -0
- package/src/templates/design-review/loops/03-plan-loop/prompt.md +247 -0
- package/src/templates/design-review/loops/03-plan-loop/tracker.md +16 -0
- package/src/templates/design-review/ralphflow.yaml +84 -0
- package/src/templates/systematic-debugging/loops/00-investigate-loop/bugs.md +3 -0
- package/src/templates/systematic-debugging/loops/00-investigate-loop/prompt.md +237 -0
- package/src/templates/systematic-debugging/loops/00-investigate-loop/tracker.md +16 -0
- package/src/templates/systematic-debugging/loops/01-hypothesize-loop/hypotheses.md +3 -0
- package/src/templates/systematic-debugging/loops/01-hypothesize-loop/prompt.md +312 -0
- package/src/templates/systematic-debugging/loops/01-hypothesize-loop/tracker.md +18 -0
- package/src/templates/systematic-debugging/loops/02-fix-loop/fixes.md +3 -0
- package/src/templates/systematic-debugging/loops/02-fix-loop/prompt.md +342 -0
- package/src/templates/systematic-debugging/loops/02-fix-loop/tracker.md +18 -0
- package/src/templates/systematic-debugging/ralphflow.yaml +81 -0
- package/src/templates/tdd-implementation/loops/00-spec-loop/prompt.md +208 -0
- package/src/templates/tdd-implementation/loops/00-spec-loop/specs.md +3 -0
- package/src/templates/tdd-implementation/loops/00-spec-loop/tracker.md +16 -0
- package/src/templates/tdd-implementation/loops/01-tdd-loop/prompt.md +323 -0
- package/src/templates/tdd-implementation/loops/01-tdd-loop/test-cases.md +3 -0
- package/src/templates/tdd-implementation/loops/01-tdd-loop/tracker.md +18 -0
- package/src/templates/tdd-implementation/loops/02-verify-loop/prompt.md +226 -0
- package/src/templates/tdd-implementation/loops/02-verify-loop/tracker.md +16 -0
- package/src/templates/tdd-implementation/loops/02-verify-loop/verifications.md +3 -0
- package/src/templates/tdd-implementation/ralphflow.yaml +73 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
name: code-review
|
|
2
|
+
description: "Collect → Spec Review → Quality Review → Fix pipeline for multi-stage code review"
|
|
3
|
+
version: 1
|
|
4
|
+
dir: .ralph-flow
|
|
5
|
+
|
|
6
|
+
entities:
|
|
7
|
+
CHANGESET:
|
|
8
|
+
prefix: CS
|
|
9
|
+
data_file: 00-collect-loop/changesets.md
|
|
10
|
+
ISSUE:
|
|
11
|
+
prefix: ISSUE
|
|
12
|
+
data_file: 02-quality-review-loop/issues.md
|
|
13
|
+
|
|
14
|
+
loops:
|
|
15
|
+
collect-loop:
|
|
16
|
+
order: 0
|
|
17
|
+
name: "Collect Loop"
|
|
18
|
+
prompt: 00-collect-loop/prompt.md
|
|
19
|
+
tracker: 00-collect-loop/tracker.md
|
|
20
|
+
data_files:
|
|
21
|
+
- 00-collect-loop/changesets.md
|
|
22
|
+
entities: [CHANGESET]
|
|
23
|
+
stages: [discover, catalog]
|
|
24
|
+
completion: "ALL CHANGESETS COLLECTED"
|
|
25
|
+
feeds: [spec-review-loop]
|
|
26
|
+
multi_agent: false
|
|
27
|
+
model: claude-sonnet-4-6
|
|
28
|
+
cadence: 0
|
|
29
|
+
|
|
30
|
+
spec-review-loop:
|
|
31
|
+
order: 1
|
|
32
|
+
name: "Spec Review Loop"
|
|
33
|
+
prompt: 01-spec-review-loop/prompt.md
|
|
34
|
+
tracker: 01-spec-review-loop/tracker.md
|
|
35
|
+
entities: [CHANGESET]
|
|
36
|
+
stages: [review, verdict]
|
|
37
|
+
completion: "ALL SPEC REVIEWS COMPLETE"
|
|
38
|
+
fed_by: [collect-loop]
|
|
39
|
+
feeds: [quality-review-loop]
|
|
40
|
+
model: claude-sonnet-4-6
|
|
41
|
+
multi_agent:
|
|
42
|
+
enabled: true
|
|
43
|
+
max_agents: 3
|
|
44
|
+
strategy: tracker-lock
|
|
45
|
+
agent_placeholder: "{{AGENT_NAME}}"
|
|
46
|
+
lock:
|
|
47
|
+
file: 01-spec-review-loop/.tracker-lock
|
|
48
|
+
type: echo
|
|
49
|
+
stale_seconds: 60
|
|
50
|
+
cadence: 0
|
|
51
|
+
|
|
52
|
+
quality-review-loop:
|
|
53
|
+
order: 2
|
|
54
|
+
name: "Quality Review Loop"
|
|
55
|
+
prompt: 02-quality-review-loop/prompt.md
|
|
56
|
+
tracker: 02-quality-review-loop/tracker.md
|
|
57
|
+
data_files:
|
|
58
|
+
- 02-quality-review-loop/issues.md
|
|
59
|
+
entities: [ISSUE, CHANGESET]
|
|
60
|
+
stages: [review, categorize]
|
|
61
|
+
completion: "ALL QUALITY REVIEWS COMPLETE"
|
|
62
|
+
fed_by: [spec-review-loop]
|
|
63
|
+
feeds: [fix-loop]
|
|
64
|
+
model: claude-sonnet-4-6
|
|
65
|
+
multi_agent:
|
|
66
|
+
enabled: true
|
|
67
|
+
max_agents: 3
|
|
68
|
+
strategy: tracker-lock
|
|
69
|
+
agent_placeholder: "{{AGENT_NAME}}"
|
|
70
|
+
lock:
|
|
71
|
+
file: 02-quality-review-loop/.tracker-lock
|
|
72
|
+
type: echo
|
|
73
|
+
stale_seconds: 60
|
|
74
|
+
cadence: 0
|
|
75
|
+
|
|
76
|
+
fix-loop:
|
|
77
|
+
order: 3
|
|
78
|
+
name: "Fix Loop"
|
|
79
|
+
prompt: 03-fix-loop/prompt.md
|
|
80
|
+
tracker: 03-fix-loop/tracker.md
|
|
81
|
+
entities: [ISSUE, CHANGESET]
|
|
82
|
+
stages: [fix, re-review]
|
|
83
|
+
completion: "ALL ISSUES RESOLVED"
|
|
84
|
+
fed_by: [quality-review-loop]
|
|
85
|
+
model: claude-sonnet-4-6
|
|
86
|
+
multi_agent:
|
|
87
|
+
enabled: true
|
|
88
|
+
max_agents: 3
|
|
89
|
+
strategy: tracker-lock
|
|
90
|
+
agent_placeholder: "{{AGENT_NAME}}"
|
|
91
|
+
lock:
|
|
92
|
+
file: 03-fix-loop/.tracker-lock
|
|
93
|
+
type: echo
|
|
94
|
+
stale_seconds: 60
|
|
95
|
+
worktree:
|
|
96
|
+
strategy: shared
|
|
97
|
+
auto_merge: true
|
|
98
|
+
cadence: 0
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Explore Loop — Discover and Scope Ideas Before Design
|
|
2
|
+
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
5
|
+
Read `.ralph-flow/{{APP_NAME}}/00-explore-loop/tracker.md` FIRST to determine where you are.
|
|
6
|
+
|
|
7
|
+
> **Design-first thinking starts with understanding.** Before any design or code, explore what exists, clarify what the user wants, and define sharp boundaries. Ambiguity killed here saves days of rework later.
|
|
8
|
+
|
|
9
|
+
> **READ-ONLY FOR SOURCE CODE.** Only write to: `.ralph-flow/{{APP_NAME}}/00-explore-loop/tracker.md`, `.ralph-flow/{{APP_NAME}}/00-explore-loop/ideas.md`.
|
|
10
|
+
|
|
11
|
+
**Pipeline:** `ideas.md → YOU → designs.md → 01-design-loop → design specs`
|
|
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 idea)
|
|
34
|
+
|
|
35
|
+
**FIRST — Check completion.** Read the tracker. If the Ideas Queue has entries
|
|
36
|
+
AND every entry is `[x]` (no pending ideas):
|
|
37
|
+
1. **Re-scan `ideas.md`** — read all `## IDEA-{N}:` headers and compare
|
|
38
|
+
against the Ideas Queue in the tracker.
|
|
39
|
+
2. **New ideas found** (in `ideas.md` but not in the queue) → add them as
|
|
40
|
+
`- [ ] IDEA-{N}: {title}` to the Ideas Queue, update the Dependency Graph
|
|
41
|
+
from their `**Depends on:**` tags, then proceed to process the lowest-numbered
|
|
42
|
+
ready idea via the normal state machine.
|
|
43
|
+
3. **No new ideas** → go to **"No Ideas? Collect Them"** to ask the user.
|
|
44
|
+
|
|
45
|
+
Only write `<promise>ALL IDEAS SCOPED</promise>` when the user explicitly
|
|
46
|
+
confirms they have no more ideas to add AND `ideas.md` has no ideas
|
|
47
|
+
missing from the tracker queue.
|
|
48
|
+
|
|
49
|
+
Pick the lowest-numbered `ready` idea. NEVER process a `blocked` idea.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## No Ideas? Collect Them
|
|
54
|
+
|
|
55
|
+
**Triggers when:**
|
|
56
|
+
- `ideas.md` has no ideas at all (first run, empty queue with no entries), OR
|
|
57
|
+
- All ideas in the queue are completed (`[x]`), no `pending` ideas remain, AND
|
|
58
|
+
`ideas.md` has been re-scanned and contains no ideas missing from the queue
|
|
59
|
+
|
|
60
|
+
**Flow:**
|
|
61
|
+
1. Tell the user: *"No pending ideas. Tell me what you want to build — describe features, problems, or goals in your own words."*
|
|
62
|
+
2. Use `AskUserQuestion` to prompt: "What do you want to build or change?" (open-ended)
|
|
63
|
+
3. As the user narrates, capture each distinct concept as a `## IDEA-{N}: {Title}` in `ideas.md` (continue numbering from existing ideas) with a brief description and `**Depends on:** None` (or dependencies if mentioned)
|
|
64
|
+
4. **Confirm ideas & dependencies** — present all captured ideas back. Use `AskUserQuestion` (up to 3 questions) to validate: correct ideas? right dependency order? any to split/merge?
|
|
65
|
+
5. Apply corrections, finalize `ideas.md`, add new entries to tracker queue, proceed to normal flow
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
CONTEXT → Explore project state, read docs, understand what exists → stage: clarify
|
|
71
|
+
CLARIFY → Ask questions one at a time, nail down intent and constraints → stage: scope
|
|
72
|
+
SCOPE → Define boundaries, write structured IDEA entry, mark done → kill
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## First-Run / New Idea Detection
|
|
76
|
+
|
|
77
|
+
If Ideas Queue in tracker is empty OR all entries are `[x]`: read `ideas.md`,
|
|
78
|
+
scan `## IDEA-{N}:` headers + `**Depends on:**` tags. For any idea NOT already
|
|
79
|
+
in the queue, add as `- [ ] IDEA-{N}: {title}` and build/update the Dependency Graph.
|
|
80
|
+
If new ideas were added, proceed to process them. If the queue is still empty
|
|
81
|
+
after scanning, go to **"No Ideas? Collect Them"**.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## STAGE 1: CONTEXT
|
|
86
|
+
|
|
87
|
+
1. Read tracker → pick lowest-numbered `ready` idea
|
|
88
|
+
2. Read the idea from `ideas.md` (if it exists — on first run it may be empty)
|
|
89
|
+
3. **Explore the project state:**
|
|
90
|
+
- Read `CLAUDE.md` for project context, architecture, conventions, stack
|
|
91
|
+
- Read **15+ key files** across the project: configs, entry points, core modules, recent changes
|
|
92
|
+
- Check recent git commits (`git log --oneline -20`) to understand momentum and active areas
|
|
93
|
+
- Identify existing patterns, conventions, and architectural decisions
|
|
94
|
+
4. **Render a Project State Map** — output an ASCII architecture diagram showing:
|
|
95
|
+
- Current project structure (major components and modules)
|
|
96
|
+
- Active areas of development (`●` = stable, `○` = recently changed)
|
|
97
|
+
- Where this idea might touch the codebase
|
|
98
|
+
5. Update tracker: `active_idea: IDEA-{N}`, `stage: clarify`, log entry
|
|
99
|
+
|
|
100
|
+
## STAGE 2: CLARIFY
|
|
101
|
+
|
|
102
|
+
> **One question at a time, multiple choice preferred.** Reduce cognitive load on the user. Do not dump a wall of questions — guide the conversation.
|
|
103
|
+
|
|
104
|
+
1. Formulate questions about purpose, constraints, success criteria, and scope
|
|
105
|
+
2. **Present understanding first** — render an ASCII scope diagram showing your current understanding of the idea. Give the user a visual anchor before asking questions.
|
|
106
|
+
3. **Ask up to 20 questions, 5 at a time** via `AskUserQuestion`:
|
|
107
|
+
- **Round 1 — Purpose & Intent:**
|
|
108
|
+
- What problem does this solve? Who benefits?
|
|
109
|
+
- What does success look like? (measurable criteria)
|
|
110
|
+
- Are there existing solutions or workarounds?
|
|
111
|
+
- **Round 2 — Constraints & Boundaries:**
|
|
112
|
+
- What must NOT change? (protected areas, APIs, contracts)
|
|
113
|
+
- Performance, security, or compatibility requirements?
|
|
114
|
+
- Timeline or effort constraints?
|
|
115
|
+
- **Round 3 — Scope & Priority:**
|
|
116
|
+
- What is the smallest useful version? (MVP thinking)
|
|
117
|
+
- What can be deferred to a follow-up?
|
|
118
|
+
- Dependencies on other work?
|
|
119
|
+
- **Round 4+ — Clarification:** Based on prior answers, dig deeper
|
|
120
|
+
- **Stop early** if the idea is clear enough
|
|
121
|
+
- For multi-option decisions: numbered list with one-line descriptions
|
|
122
|
+
- For trade-offs: include a comparison table
|
|
123
|
+
4. **Flag scope concerns:** If the idea seems too large for a single design cycle, suggest splitting it. Present a decomposition tree showing how it could break down.
|
|
124
|
+
5. Save Q&A summary in tracker log
|
|
125
|
+
6. Update tracker: `stage: scope`, log entry with key decisions
|
|
126
|
+
|
|
127
|
+
## STAGE 3: SCOPE
|
|
128
|
+
|
|
129
|
+
1. Synthesize all context and clarification into a structured IDEA entry
|
|
130
|
+
2. **Render a Scope Boundary Diagram** — ASCII diagram showing:
|
|
131
|
+
- In-scope items (`✓`) vs. out-of-scope items (`✗`)
|
|
132
|
+
- Dependencies on existing systems or components
|
|
133
|
+
- Data flow for the proposed change
|
|
134
|
+
3. Write the IDEA entry to `ideas.md` (or update if skeleton exists) using the format below
|
|
135
|
+
4. **Present the scoped idea to the user** — show the IDEA summary and ask for confirmation via `AskUserQuestion`: "Does this capture what you want? Anything to add, remove, or change?"
|
|
136
|
+
5. Apply any corrections from the user
|
|
137
|
+
6. Mark done in tracker: check off queue, completed mapping, `active_idea: none`, `stage: context`, update Dependency Graph, log
|
|
138
|
+
7. Exit: `kill -INT $PPID`
|
|
139
|
+
|
|
140
|
+
**IDEA entry format:**
|
|
141
|
+
```markdown
|
|
142
|
+
## IDEA-{N}: {Title}
|
|
143
|
+
|
|
144
|
+
**Depends on:** {IDEA-{M} or "None"}
|
|
145
|
+
**Status:** scoped
|
|
146
|
+
|
|
147
|
+
### Description
|
|
148
|
+
{2-4 sentences describing what this idea is about — the problem, the user need, the opportunity.}
|
|
149
|
+
|
|
150
|
+
### Constraints
|
|
151
|
+
{Bullet list of hard constraints: must not break X, must work with Y, performance budget, etc.}
|
|
152
|
+
|
|
153
|
+
### Success Criteria
|
|
154
|
+
- [ ] {Specific, measurable condition — at least 3}
|
|
155
|
+
- [ ] {Observable outcome the user can verify}
|
|
156
|
+
- [ ] {Edge case or failure mode that must be handled}
|
|
157
|
+
|
|
158
|
+
### In Scope
|
|
159
|
+
- {Concrete deliverable or behavior change}
|
|
160
|
+
- {Another concrete deliverable}
|
|
161
|
+
|
|
162
|
+
### Out of Scope
|
|
163
|
+
- {Explicitly deferred item — with brief reason}
|
|
164
|
+
- {Another deferred item}
|
|
165
|
+
|
|
166
|
+
### Open Questions
|
|
167
|
+
- {Any remaining ambiguity that the design loop should resolve}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Decision Reporting Protocol
|
|
173
|
+
|
|
174
|
+
When you make a substantive decision a human reviewer would want to know about, report it to the dashboard:
|
|
175
|
+
|
|
176
|
+
**When to report:**
|
|
177
|
+
- Scope boundary decisions (what is in vs. out of scope for an idea)
|
|
178
|
+
- Splitting or merging ideas (decomposition choices)
|
|
179
|
+
- Interpretation of ambiguous user intent (how you resolved unclear descriptions)
|
|
180
|
+
- Constraint identification (constraints you surfaced that the user did not mention)
|
|
181
|
+
- Priority or ordering decisions (why one idea comes before another)
|
|
182
|
+
|
|
183
|
+
**How to report:**
|
|
184
|
+
```bash
|
|
185
|
+
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":"IDEA-{N}","agent":"explore-loop","decision":"{one-line summary}","reasoning":"{why this choice}"}'
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Do NOT report** routine operations: picking the next idea, updating tracker, stage transitions. Only report substantive choices that affect the scoped idea.
|
|
189
|
+
|
|
190
|
+
**Best-effort only:** If the dashboard is unreachable (curl fails), continue working normally. Decision reporting must never block or delay your work.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Rules
|
|
195
|
+
|
|
196
|
+
- One idea at a time. All 3 stages run in one iteration, one `kill` at the end.
|
|
197
|
+
- Read tracker first, update tracker last.
|
|
198
|
+
- Append to `ideas.md` — never overwrite. Numbers globally unique and sequential.
|
|
199
|
+
- Ideas must be self-contained — the design loop should not need to re-ask the user basic intent questions.
|
|
200
|
+
- Flag ideas that are too large — suggest splitting before scoping.
|
|
201
|
+
- **One question at a time, multiple choice preferred.** Reduce cognitive load.
|
|
202
|
+
- Always present your understanding visually before asking questions.
|
|
203
|
+
- Capture explicit out-of-scope items — these prevent scope creep downstream.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
Read `.ralph-flow/{{APP_NAME}}/00-explore-loop/tracker.md` now and begin.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Design Loop — Produce Design Specs from Scoped Ideas
|
|
2
|
+
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
5
|
+
Read `.ralph-flow/{{APP_NAME}}/01-design-loop/tracker.md` FIRST to determine where you are.
|
|
6
|
+
|
|
7
|
+
> **Design for isolation and clarity — smaller units with one clear purpose, well-defined interfaces.** Every component should be replaceable without rippling through the system. Prefer boring, proven patterns over clever abstractions.
|
|
8
|
+
|
|
9
|
+
> **READ-ONLY FOR SOURCE CODE.** Only write to: `.ralph-flow/{{APP_NAME}}/01-design-loop/tracker.md`, `.ralph-flow/{{APP_NAME}}/01-design-loop/designs.md`. Read `ideas.md` for input.
|
|
10
|
+
|
|
11
|
+
**Pipeline:** `ideas.md → YOU → designs.md → 02-review-loop → reviewed specs`
|
|
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 design)
|
|
34
|
+
|
|
35
|
+
**FIRST — Check completion.** Read the tracker. If the Designs Queue has entries
|
|
36
|
+
AND every entry is `[x]` (no pending designs):
|
|
37
|
+
1. **Re-scan `ideas.md`** — read all `## IDEA-{N}:` headers with `**Status:** scoped`
|
|
38
|
+
and compare against the Designs Queue in the tracker.
|
|
39
|
+
2. **New scoped ideas found** (in `ideas.md` but not in the queue) → add them as
|
|
40
|
+
`- [ ] DESIGN-{N}: {title}` to the Designs Queue (DESIGN number matches IDEA number),
|
|
41
|
+
then proceed to process the lowest-numbered ready design.
|
|
42
|
+
3. **No new scoped ideas** → write `<promise>ALL DESIGNS WRITTEN</promise>`.
|
|
43
|
+
|
|
44
|
+
Pick the lowest-numbered `ready` design. NEVER process a `blocked` design.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
ALTERNATIVES → Propose 2-3 approaches with trade-offs, recommend one → stage: design
|
|
50
|
+
DESIGN → Present design incrementally, get user approval → stage: document
|
|
51
|
+
DOCUMENT → Write full design spec as DESIGN entry, mark done → kill
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## First-Run / New Design Detection
|
|
55
|
+
|
|
56
|
+
If Designs Queue in tracker is empty OR all entries are `[x]`: read `ideas.md`,
|
|
57
|
+
scan `## IDEA-{N}:` headers with `**Status:** scoped`. For any scoped idea NOT
|
|
58
|
+
already in the queue, add as `- [ ] DESIGN-{N}: {title}` and build/update the
|
|
59
|
+
Dependency Graph from `**Depends on:**` tags. If new designs were added, proceed.
|
|
60
|
+
If the queue is still empty after scanning, write `<promise>ALL DESIGNS WRITTEN</promise>`.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## STAGE 1: ALTERNATIVES
|
|
65
|
+
|
|
66
|
+
1. Read tracker → pick lowest-numbered `ready` design
|
|
67
|
+
2. Read the corresponding IDEA from `00-explore-loop/ideas.md` — understand description, constraints, success criteria, in-scope/out-scope
|
|
68
|
+
3. **Explore the codebase** — read `CLAUDE.md` and **20+ key files** across affected areas to understand current architecture, patterns, and constraints
|
|
69
|
+
4. **Propose 2-3 alternative approaches** — for each approach:
|
|
70
|
+
- Name and one-line summary
|
|
71
|
+
- How it works (2-3 sentences)
|
|
72
|
+
- Key trade-offs: complexity, performance, maintainability, risk
|
|
73
|
+
- What it does well and where it falls short
|
|
74
|
+
5. **Render an Alternatives Comparison Table** — ASCII bordered table:
|
|
75
|
+
```
|
|
76
|
+
┌──────────────┬────────────┬─────────┬──────────────┐
|
|
77
|
+
│ Approach │ Complexity │ Risk │ Maintenance │
|
|
78
|
+
├──────────────┼────────────┼─────────┼──────────────┤
|
|
79
|
+
│ A: {name} │ Low │ Low │ Easy │
|
|
80
|
+
│ B: {name} │ Medium │ Medium │ Moderate │
|
|
81
|
+
│ C: {name} │ High │ Low │ Hard │
|
|
82
|
+
└──────────────┴────────────┴─────────┴──────────────┘
|
|
83
|
+
```
|
|
84
|
+
6. **Recommend one approach** with clear reasoning — why it best fits the constraints and success criteria from the IDEA
|
|
85
|
+
7. **Ask the user** via `AskUserQuestion`: present the comparison and recommendation, ask which approach to proceed with (or if they want a different direction)
|
|
86
|
+
8. Record the chosen approach in tracker log
|
|
87
|
+
9. Update tracker: `active_design: DESIGN-{N}`, `stage: design`, log entry
|
|
88
|
+
|
|
89
|
+
## STAGE 2: DESIGN
|
|
90
|
+
|
|
91
|
+
> **Present design incrementally. Get approval on each section before moving to the next.** Do not dump a complete design — walk the user through it piece by piece.
|
|
92
|
+
|
|
93
|
+
1. Using the chosen approach from ALTERNATIVES, build the design section by section:
|
|
94
|
+
2. **Architecture Overview** — render an ASCII architecture diagram showing major components, their responsibilities, and how they connect. Ask user: "Does this architecture make sense?"
|
|
95
|
+
3. **Component Breakdown** — for each component:
|
|
96
|
+
- Name, responsibility (one sentence), inputs/outputs
|
|
97
|
+
- Key design decisions within this component
|
|
98
|
+
- Ask user after every 2-3 components: "Any concerns so far?"
|
|
99
|
+
4. **Data Flow** — render an ASCII data flow diagram showing how information moves through the system. Cover happy path and key error paths.
|
|
100
|
+
5. **Error Handling Strategy** — how errors propagate, where they are caught, what the user sees. Present as a bordered list.
|
|
101
|
+
6. **Testing Approach** — what to test, how to test it, what coverage looks like. Unit vs. integration vs. e2e breakdown.
|
|
102
|
+
7. **After each section**, ask the user via `AskUserQuestion` (multiple choice preferred):
|
|
103
|
+
- "Approve and continue to next section"
|
|
104
|
+
- "Revise this section (tell me what to change)"
|
|
105
|
+
- "Go back to alternatives (this approach is not working)"
|
|
106
|
+
8. If the user wants to go back to alternatives, reset to ALTERNATIVES stage
|
|
107
|
+
9. Update tracker: `stage: document`, log entry with design decisions
|
|
108
|
+
|
|
109
|
+
## STAGE 3: DOCUMENT
|
|
110
|
+
|
|
111
|
+
1. Compile all approved sections into a formal DESIGN entry
|
|
112
|
+
2. Write the DESIGN entry to `01-design-loop/designs.md` using the format below
|
|
113
|
+
3. **Render a Design Summary** — ASCII status diagram showing:
|
|
114
|
+
- All components with their status (`✓` designed)
|
|
115
|
+
- Data flow overview in compact form
|
|
116
|
+
- Success criteria mapping (which criteria each component addresses)
|
|
117
|
+
4. Mark done in tracker: check off queue, completed mapping, `active_design: none`, `stage: alternatives`, update Dependency Graph, log
|
|
118
|
+
5. Exit: `kill -INT $PPID`
|
|
119
|
+
|
|
120
|
+
**DESIGN entry format:**
|
|
121
|
+
```markdown
|
|
122
|
+
## DESIGN-{N}: {Title}
|
|
123
|
+
|
|
124
|
+
**Source:** IDEA-{N}
|
|
125
|
+
**Depends on:** {DESIGN-{M} or "None"}
|
|
126
|
+
**Approach:** {Name of chosen approach from alternatives}
|
|
127
|
+
**Status:** drafted
|
|
128
|
+
|
|
129
|
+
### Architecture Overview
|
|
130
|
+
{2-3 paragraphs describing the high-level architecture. Reference the components below.}
|
|
131
|
+
|
|
132
|
+
### Components
|
|
133
|
+
|
|
134
|
+
#### {Component Name}
|
|
135
|
+
- **Responsibility:** {One sentence}
|
|
136
|
+
- **Inputs:** {What it receives}
|
|
137
|
+
- **Outputs:** {What it produces}
|
|
138
|
+
- **Key Decisions:** {Design choices made for this component}
|
|
139
|
+
|
|
140
|
+
### Data Flow
|
|
141
|
+
{Description of how data moves through the system. Reference components by name.}
|
|
142
|
+
|
|
143
|
+
### Interfaces
|
|
144
|
+
{Public APIs, function signatures, event contracts, or file formats that other components depend on. Be specific — these are the contracts.}
|
|
145
|
+
|
|
146
|
+
### Error Handling
|
|
147
|
+
{How errors propagate, where they are caught, recovery strategies, what the user sees.}
|
|
148
|
+
|
|
149
|
+
### Testing Strategy
|
|
150
|
+
- **Unit:** {What to unit test, key scenarios}
|
|
151
|
+
- **Integration:** {What to integration test, component boundaries}
|
|
152
|
+
- **E2E:** {End-to-end scenarios to verify}
|
|
153
|
+
|
|
154
|
+
### File Structure Plan
|
|
155
|
+
{Which files to create, modify, or delete. Group by component.}
|
|
156
|
+
|
|
157
|
+
### Success Criteria Mapping
|
|
158
|
+
{Map each success criterion from the IDEA to the component(s) that address it.}
|
|
159
|
+
- [ ] {Criterion} → {Component(s)}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Decision Reporting Protocol
|
|
165
|
+
|
|
166
|
+
When you make a substantive decision a human reviewer would want to know about, report it to the dashboard:
|
|
167
|
+
|
|
168
|
+
**When to report:**
|
|
169
|
+
- Approach selection (why one alternative was chosen over others)
|
|
170
|
+
- Architecture decisions (component boundaries, data flow choices)
|
|
171
|
+
- Trade-off resolutions (performance vs. simplicity, flexibility vs. complexity)
|
|
172
|
+
- Scope adjustments during design (things that turned out harder or simpler than expected)
|
|
173
|
+
- User feedback integration (how you incorporated user revisions into the design)
|
|
174
|
+
|
|
175
|
+
**How to report:**
|
|
176
|
+
```bash
|
|
177
|
+
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":"design-loop","decision":"{one-line summary}","reasoning":"{why this choice}"}'
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Do NOT report** routine operations: picking the next design, updating tracker, stage transitions. Only report substantive choices that affect the design spec.
|
|
181
|
+
|
|
182
|
+
**Best-effort only:** If the dashboard is unreachable (curl fails), continue working normally. Decision reporting must never block or delay your work.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Rules
|
|
187
|
+
|
|
188
|
+
- One design at a time. All 3 stages run in one iteration, one `kill` at the end.
|
|
189
|
+
- Read tracker first, update tracker last.
|
|
190
|
+
- Append to `designs.md` — never overwrite. DESIGN numbers match IDEA numbers.
|
|
191
|
+
- **Design for isolation and clarity** — smaller units with one clear purpose, well-defined interfaces.
|
|
192
|
+
- Present design incrementally — get approval on each section before proceeding.
|
|
193
|
+
- Always propose alternatives before committing to an approach. Never jump to "the obvious solution."
|
|
194
|
+
- If the user rejects the approach during DESIGN, go back to ALTERNATIVES gracefully.
|
|
195
|
+
- Designs must be self-contained — the review loop should not need to read `ideas.md` to understand the spec.
|
|
196
|
+
- Include concrete interfaces — these are the contracts that implementation will follow.
|
|
197
|
+
- Map every success criterion to a component. If a criterion has no owner, the design is incomplete.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
Read `.ralph-flow/{{APP_NAME}}/01-design-loop/tracker.md` now and begin.
|