ralphflow 0.2.0 → 0.4.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.
- package/README.md +67 -27
- package/dist/chunk-GVOJO5IN.js +274 -0
- package/dist/ralphflow.js +372 -322
- package/dist/server-O6J52DZT.js +323 -0
- package/package.json +7 -2
- package/src/dashboard/ui/index.html +838 -0
- package/src/templates/code-implementation/loops/00-story-loop/prompt.md +19 -11
- package/src/templates/code-implementation/loops/01-tasks-loop/prompt.md +7 -5
- package/src/templates/code-implementation/loops/02-delivery-loop/prompt.md +4 -2
- package/src/templates/research/loops/00-discovery-loop/prompt.md +7 -5
- package/src/templates/research/loops/01-research-loop/prompt.md +7 -5
- package/src/templates/research/loops/02-story-loop/prompt.md +4 -2
- package/src/templates/research/loops/03-document-loop/prompt.md +4 -2
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
# Story Loop — Break Stories into Structured Tasks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
5
|
+
Read `.ralph-flow/{{APP_NAME}}/00-story-loop/tracker.md` FIRST to determine where you are.
|
|
4
6
|
|
|
5
7
|
> **Describe the destination, not the route.** Focus on what the user will experience, not how you'll build it. Surface anything that could go wrong — broken flows, overlooked edge cases, data at risk.
|
|
6
8
|
|
|
7
|
-
> **READ-ONLY FOR SOURCE CODE.** Only write to:
|
|
9
|
+
> **READ-ONLY FOR SOURCE CODE.** Only write to: `.ralph-flow/{{APP_NAME}}/01-tasks-loop/tasks.md`, `.ralph-flow/{{APP_NAME}}/01-tasks-loop/tracker.md`, `.ralph-flow/{{APP_NAME}}/00-story-loop/tracker.md`, `.ralph-flow/{{APP_NAME}}/00-story-loop/stories.md`.
|
|
8
10
|
|
|
9
11
|
**Pipeline:** `stories.md → YOU → tasks.md → 01-tasks-loop → code`
|
|
10
12
|
|
|
11
13
|
---
|
|
12
14
|
|
|
15
|
+
## State Machine (3 stages per story)
|
|
16
|
+
|
|
17
|
+
**FIRST — Check completion.** Read the tracker. If the Stories Queue has entries
|
|
18
|
+
AND every entry is `[x]`, write `<promise>ALL STORIES PROCESSED</promise>` to
|
|
19
|
+
the bottom of the tracker and `kill -INT $PPID`. Do NOT collect new stories.
|
|
20
|
+
|
|
21
|
+
Pick the lowest-numbered `ready` story. NEVER process a `blocked` story.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
13
25
|
## No Stories? Collect Them
|
|
14
26
|
|
|
15
|
-
If `stories.md` has no
|
|
27
|
+
If `stories.md` has no stories at all (first run, empty queue with no entries):
|
|
16
28
|
1. Tell the user: *"No stories queued. Tell me what you want to build — describe features, problems, or goals in your own words."*
|
|
17
29
|
2. Use `AskUserQuestion` to prompt: "What do you want to build or fix next?" (open-ended)
|
|
18
30
|
3. As the user narrates, capture each distinct idea as a `## STORY-{N}: {Title}` in `stories.md` with description and `**Depends on:** None` (or dependencies if mentioned)
|
|
@@ -21,10 +33,6 @@ If `stories.md` has no unprocessed stories and the tracker queue is empty/all do
|
|
|
21
33
|
|
|
22
34
|
---
|
|
23
35
|
|
|
24
|
-
## State Machine (3 stages per story)
|
|
25
|
-
|
|
26
|
-
Pick the lowest-numbered `ready` story. NEVER process a `blocked` story. If none are `ready`: `<promise>ALL STORIES PROCESSED</promise>`.
|
|
27
|
-
|
|
28
36
|
```
|
|
29
37
|
ANALYZE → Read story, explore codebase, map scope → stage: clarify
|
|
30
38
|
CLARIFY → Ask user up to 20 questions (5 at a time) → stage: decompose
|
|
@@ -63,11 +71,11 @@ If Stories Queue in tracker is empty: read `stories.md`, scan `## STORY-{N}:` he
|
|
|
63
71
|
5. **Sanity-check:** Do NOT embed specific file paths in tasks — describe *what* changes, not *where*. The tasks loop will explore the codebase itself.
|
|
64
72
|
6. Append to `01-tasks-loop/tasks.md` (format below)
|
|
65
73
|
7. **Update `01-tasks-loop/tracker.md` (with lock protocol):**
|
|
66
|
-
1. Acquire `.ralph-flow/01-tasks-loop/.tracker-lock`:
|
|
74
|
+
1. Acquire `.ralph-flow/{{APP_NAME}}/01-tasks-loop/.tracker-lock`:
|
|
67
75
|
- Exists + < 60s old → sleep 2s, retry up to 5 times
|
|
68
76
|
- Exists + ≥ 60s old → stale, delete it
|
|
69
77
|
- Not exists → continue
|
|
70
|
-
- Write lock: `echo "story-loop $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/01-tasks-loop/.tracker-lock`
|
|
78
|
+
- Write lock: `echo "story-loop $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/{{APP_NAME}}/01-tasks-loop/.tracker-lock`
|
|
71
79
|
- Sleep 500ms, re-read lock, verify `story-loop` is in it
|
|
72
80
|
2. Add new Task Groups to `## Task Groups`
|
|
73
81
|
3. Add new tasks to `## Tasks Queue` with multi-agent metadata:
|
|
@@ -78,7 +86,7 @@ If Stories Queue in tracker is empty: read `stories.md`, scan `## STORY-{N}:` he
|
|
|
78
86
|
4. Add dependency entries to `## Dependencies` section (for tasks with dependencies only):
|
|
79
87
|
- Example: `- TASK-15: [TASK-12]`
|
|
80
88
|
- Tasks with `Depends on: None` are NOT added to Dependencies
|
|
81
|
-
5. Release lock: `rm .ralph-flow/01-tasks-loop/.tracker-lock`
|
|
89
|
+
5. Release lock: `rm .ralph-flow/{{APP_NAME}}/01-tasks-loop/.tracker-lock`
|
|
82
90
|
8. Mark done in tracker: check off queue, completed mapping, `active_story: none`, `stage: analyze`, update Dependency Graph, log
|
|
83
91
|
9. Exit: `kill -INT $PPID`
|
|
84
92
|
|
|
@@ -132,4 +140,4 @@ If Stories Queue in tracker is empty: read `stories.md`, scan `## STORY-{N}:` he
|
|
|
132
140
|
|
|
133
141
|
---
|
|
134
142
|
|
|
135
|
-
Read `.ralph-flow/00-story-loop/tracker.md` now and begin.
|
|
143
|
+
Read `.ralph-flow/{{APP_NAME}}/00-story-loop/tracker.md` now and begin.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# Tasks Loop — Implement Tasks
|
|
2
2
|
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
3
5
|
**You are agent `{{AGENT_NAME}}`.** Multiple agents may work in parallel.
|
|
4
6
|
Coordinate via `tracker.md` — the single source of truth.
|
|
5
7
|
*(If you see the literal text `{{AGENT_NAME}}` above — i.e., it was not substituted — treat your name as `agent-1`.)*
|
|
6
8
|
|
|
7
|
-
Read `.ralph-flow/01-tasks-loop/tracker.md` FIRST to determine where you are.
|
|
9
|
+
Read `.ralph-flow/{{APP_NAME}}/01-tasks-loop/tracker.md` FIRST to determine where you are.
|
|
8
10
|
|
|
9
11
|
> **PROJECT CONTEXT.** Read `CLAUDE.md` for architecture, stack, conventions, commands, and URLs.
|
|
10
12
|
|
|
@@ -16,20 +18,20 @@ Read `.ralph-flow/01-tasks-loop/tracker.md` FIRST to determine where you are.
|
|
|
16
18
|
|
|
17
19
|
Before ANY write to `tracker.md`, you MUST acquire the lock:
|
|
18
20
|
|
|
19
|
-
**Lock file:** `.ralph-flow/01-tasks-loop/.tracker-lock`
|
|
21
|
+
**Lock file:** `.ralph-flow/{{APP_NAME}}/01-tasks-loop/.tracker-lock`
|
|
20
22
|
|
|
21
23
|
### Acquire Lock
|
|
22
24
|
1. Check if `.tracker-lock` exists
|
|
23
25
|
- Exists AND file is < 60 seconds old → sleep 2s, retry (up to 5 retries)
|
|
24
26
|
- Exists AND file is ≥ 60 seconds old → stale lock, delete it (agent crashed mid-write)
|
|
25
27
|
- Does not exist → continue
|
|
26
|
-
2. Write lock: `echo "{{AGENT_NAME}} $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/01-tasks-loop/.tracker-lock`
|
|
28
|
+
2. Write lock: `echo "{{AGENT_NAME}} $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/{{APP_NAME}}/01-tasks-loop/.tracker-lock`
|
|
27
29
|
3. Sleep 500ms (`sleep 0.5`)
|
|
28
30
|
4. Re-read `.tracker-lock` — verify YOUR agent name (`{{AGENT_NAME}}`) is in it
|
|
29
31
|
- Your name → you own the lock, proceed to write `tracker.md`
|
|
30
32
|
- Other name → you lost the race, retry from step 1
|
|
31
33
|
5. Write your changes to `tracker.md`
|
|
32
|
-
6. Delete `.tracker-lock` immediately: `rm .ralph-flow/01-tasks-loop/.tracker-lock`
|
|
34
|
+
6. Delete `.tracker-lock` immediately: `rm .ralph-flow/{{APP_NAME}}/01-tasks-loop/.tracker-lock`
|
|
33
35
|
7. Never leave a lock held — if your write fails, delete the lock in your error handler
|
|
34
36
|
|
|
35
37
|
### When to Lock
|
|
@@ -159,4 +161,4 @@ If Tasks Queue in tracker is empty: read `tasks.md`, scan `## TASK-{N}:` headers
|
|
|
159
161
|
|
|
160
162
|
---
|
|
161
163
|
|
|
162
|
-
Read `.ralph-flow/01-tasks-loop/tracker.md` now and begin.
|
|
164
|
+
Read `.ralph-flow/{{APP_NAME}}/01-tasks-loop/tracker.md` now and begin.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Delivery Loop — Present Completed Stories for Feedback
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
5
|
+
Read `.ralph-flow/{{APP_NAME}}/02-delivery-loop/tracker.md` FIRST to determine where you are.
|
|
4
6
|
|
|
5
7
|
> **You are a service delivery agent. The user is your client.** Your job is to present completed work, gather structured feedback, and resolve it. Small bugs are fixed on the spot. Everything else becomes a new story.
|
|
6
8
|
|
|
@@ -102,4 +104,4 @@ After resolving all feedback:
|
|
|
102
104
|
|
|
103
105
|
---
|
|
104
106
|
|
|
105
|
-
Read `.ralph-flow/02-delivery-loop/tracker.md` now and begin.
|
|
107
|
+
Read `.ralph-flow/{{APP_NAME}}/02-delivery-loop/tracker.md` now and begin.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Discovery Loop — Identify Research Topics
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
5
|
+
Read `.ralph-flow/{{APP_NAME}}/00-discovery-loop/tracker.md` FIRST to determine where you are.
|
|
4
6
|
|
|
5
7
|
> **Map the territory before exploring it.** Your job is to take a broad research brief and decompose it into specific, researchable topics. Each topic should be independently investigable and contribute to the overall research goal.
|
|
6
8
|
|
|
@@ -66,17 +68,17 @@ If Topics Queue in tracker is empty and Research Brief exists: proceed to SCOPE.
|
|
|
66
68
|
- Tagged with priority (high/medium/low) and estimated depth
|
|
67
69
|
3. Append to `00-discovery-loop/topics.md` (format below)
|
|
68
70
|
4. **Seed `01-research-loop/tracker.md`:**
|
|
69
|
-
1. Acquire `.ralph-flow/01-research-loop/.tracker-lock`:
|
|
71
|
+
1. Acquire `.ralph-flow/{{APP_NAME}}/01-research-loop/.tracker-lock`:
|
|
70
72
|
- Exists + < 60s old → sleep 2s, retry up to 5 retries
|
|
71
73
|
- Exists + ≥ 60s old → stale, delete it
|
|
72
74
|
- Not exists → continue
|
|
73
|
-
- Write lock: `echo "discovery-loop $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/01-research-loop/.tracker-lock`
|
|
75
|
+
- Write lock: `echo "discovery-loop $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/{{APP_NAME}}/01-research-loop/.tracker-lock`
|
|
74
76
|
- Sleep 500ms, re-read lock, verify `discovery-loop` is in it
|
|
75
77
|
2. Add topics to `## Topics Queue` with metadata:
|
|
76
78
|
- `{agent: -, status: pending}` for topics with no dependencies
|
|
77
79
|
- `{agent: -, status: blocked}` for topics that depend on other topics
|
|
78
80
|
3. Add dependency entries to `## Dependencies` section
|
|
79
|
-
4. Release lock: `rm .ralph-flow/01-research-loop/.tracker-lock`
|
|
81
|
+
4. Release lock: `rm .ralph-flow/{{APP_NAME}}/01-research-loop/.tracker-lock`
|
|
80
82
|
5. Update own tracker: mark complete, `stage: scope`, log entry
|
|
81
83
|
6. Exit: `kill -INT $PPID`
|
|
82
84
|
|
|
@@ -116,4 +118,4 @@ If all topics have been discovered and queue is empty: `<promise>ALL TOPICS DISC
|
|
|
116
118
|
|
|
117
119
|
---
|
|
118
120
|
|
|
119
|
-
Read `.ralph-flow/00-discovery-loop/tracker.md` now and begin.
|
|
121
|
+
Read `.ralph-flow/{{APP_NAME}}/00-discovery-loop/tracker.md` now and begin.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# Research Loop — Investigate Topics
|
|
2
2
|
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
3
5
|
**You are agent `{{AGENT_NAME}}`.** Multiple agents may work in parallel.
|
|
4
6
|
Coordinate via `tracker.md` — the single source of truth.
|
|
5
7
|
*(If you see the literal text `{{AGENT_NAME}}` above — i.e., it was not substituted — treat your name as `agent-1`.)*
|
|
6
8
|
|
|
7
|
-
Read `.ralph-flow/01-research-loop/tracker.md` FIRST to determine where you are.
|
|
9
|
+
Read `.ralph-flow/{{APP_NAME}}/01-research-loop/tracker.md` FIRST to determine where you are.
|
|
8
10
|
|
|
9
11
|
> **Go deep, stay focused.** Each topic is a specific research question. Your job is to investigate thoroughly and produce structured findings. Use web search, file reading, and any available tools to gather evidence.
|
|
10
12
|
|
|
@@ -16,20 +18,20 @@ Read `.ralph-flow/01-research-loop/tracker.md` FIRST to determine where you are.
|
|
|
16
18
|
|
|
17
19
|
Before ANY write to `tracker.md`, you MUST acquire the lock:
|
|
18
20
|
|
|
19
|
-
**Lock file:** `.ralph-flow/01-research-loop/.tracker-lock`
|
|
21
|
+
**Lock file:** `.ralph-flow/{{APP_NAME}}/01-research-loop/.tracker-lock`
|
|
20
22
|
|
|
21
23
|
### Acquire Lock
|
|
22
24
|
1. Check if `.tracker-lock` exists
|
|
23
25
|
- Exists AND file is < 60 seconds old → sleep 2s, retry (up to 5 retries)
|
|
24
26
|
- Exists AND file is ≥ 60 seconds old → stale lock, delete it (agent crashed mid-write)
|
|
25
27
|
- Does not exist → continue
|
|
26
|
-
2. Write lock: `echo "{{AGENT_NAME}} $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/01-research-loop/.tracker-lock`
|
|
28
|
+
2. Write lock: `echo "{{AGENT_NAME}} $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/{{APP_NAME}}/01-research-loop/.tracker-lock`
|
|
27
29
|
3. Sleep 500ms (`sleep 0.5`)
|
|
28
30
|
4. Re-read `.tracker-lock` — verify YOUR agent name (`{{AGENT_NAME}}`) is in it
|
|
29
31
|
- Your name → you own the lock, proceed to write `tracker.md`
|
|
30
32
|
- Other name → you lost the race, retry from step 1
|
|
31
33
|
5. Write your changes to `tracker.md`
|
|
32
|
-
6. Delete `.tracker-lock` immediately: `rm .ralph-flow/01-research-loop/.tracker-lock`
|
|
34
|
+
6. Delete `.tracker-lock` immediately: `rm .ralph-flow/{{APP_NAME}}/01-research-loop/.tracker-lock`
|
|
33
35
|
7. Never leave a lock held — if your write fails, delete the lock in your error handler
|
|
34
36
|
|
|
35
37
|
### When to Lock
|
|
@@ -179,4 +181,4 @@ If Topics Queue in tracker is empty: read `topics.md`, scan `## TOPIC-{N}:` head
|
|
|
179
181
|
|
|
180
182
|
---
|
|
181
183
|
|
|
182
|
-
Read `.ralph-flow/01-research-loop/tracker.md` now and begin.
|
|
184
|
+
Read `.ralph-flow/{{APP_NAME}}/01-research-loop/tracker.md` now and begin.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Story Loop — Condense Findings into Narratives
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
5
|
+
Read `.ralph-flow/{{APP_NAME}}/02-story-loop/tracker.md` FIRST to determine where you are.
|
|
4
6
|
|
|
5
7
|
> **Turn research into readable stories.** Your job is to take raw findings and synthesize them into coherent, well-structured narrative stories. Each story should stand on its own while contributing to the overall research picture.
|
|
6
8
|
|
|
@@ -106,4 +108,4 @@ If all stories written: `<promise>ALL STORIES WRITTEN</promise>`
|
|
|
106
108
|
|
|
107
109
|
---
|
|
108
110
|
|
|
109
|
-
Read `.ralph-flow/02-story-loop/tracker.md` now and begin.
|
|
111
|
+
Read `.ralph-flow/{{APP_NAME}}/02-story-loop/tracker.md` now and begin.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Document Loop — Compile Stories into Final Output
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
5
|
+
Read `.ralph-flow/{{APP_NAME}}/03-document-loop/tracker.md` FIRST to determine where you are.
|
|
4
6
|
|
|
5
7
|
> **This is an on-demand loop.** Unlike discovery, research, and story loops, this loop runs once to produce the final document. It reads all completed stories and compiles them into the requested output format.
|
|
6
8
|
|
|
@@ -119,4 +121,4 @@ Read `.ralph-flow/03-document-loop/tracker.md` FIRST to determine where you are.
|
|
|
119
121
|
|
|
120
122
|
---
|
|
121
123
|
|
|
122
|
-
Read `.ralph-flow/03-document-loop/tracker.md` now and begin.
|
|
124
|
+
Read `.ralph-flow/{{APP_NAME}}/03-document-loop/tracker.md` now and begin.
|