@herbcaudill/ralph 0.1.0 → 0.3.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 (176) hide show
  1. package/README.md +1 -1
  2. package/bin/ralph.js +1 -1
  3. package/dist/cli.d.ts +2 -19
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +30 -65
  6. package/dist/cli.js.map +1 -1
  7. package/dist/components/App.d.ts +10 -0
  8. package/dist/components/App.d.ts.map +1 -0
  9. package/dist/components/App.js +16 -0
  10. package/dist/components/App.js.map +1 -0
  11. package/dist/components/EventDisplay.d.ts +7 -0
  12. package/dist/components/EventDisplay.d.ts.map +1 -0
  13. package/dist/components/EventDisplay.js +64 -0
  14. package/dist/components/EventDisplay.js.map +1 -0
  15. package/dist/components/EventDisplay.replay.test.d.ts +2 -0
  16. package/dist/components/EventDisplay.replay.test.d.ts.map +1 -0
  17. package/dist/components/EventDisplay.replay.test.js +403 -0
  18. package/dist/components/EventDisplay.replay.test.js.map +1 -0
  19. package/dist/components/EventDisplay.test.d.ts +2 -0
  20. package/dist/components/EventDisplay.test.d.ts.map +1 -0
  21. package/dist/components/EventDisplay.test.js +223 -0
  22. package/dist/components/EventDisplay.test.js.map +1 -0
  23. package/dist/components/Header.d.ts +8 -0
  24. package/dist/components/Header.d.ts.map +1 -0
  25. package/dist/components/Header.js +15 -0
  26. package/dist/components/Header.js.map +1 -0
  27. package/dist/components/Header.test.d.ts +2 -0
  28. package/dist/components/Header.test.d.ts.map +1 -0
  29. package/dist/components/Header.test.js +27 -0
  30. package/dist/components/Header.test.js.map +1 -0
  31. package/dist/components/InitRalph.d.ts +3 -0
  32. package/dist/components/InitRalph.d.ts.map +1 -0
  33. package/dist/components/InitRalph.js +100 -0
  34. package/dist/components/InitRalph.js.map +1 -0
  35. package/dist/components/IterationRunner.d.ts +7 -0
  36. package/dist/components/IterationRunner.d.ts.map +1 -0
  37. package/dist/components/IterationRunner.js +285 -0
  38. package/dist/components/IterationRunner.js.map +1 -0
  39. package/dist/components/IterationRunner.test.d.ts +2 -0
  40. package/dist/components/IterationRunner.test.d.ts.map +1 -0
  41. package/dist/components/IterationRunner.test.js +109 -0
  42. package/dist/components/IterationRunner.test.js.map +1 -0
  43. package/dist/components/ReplayLog.d.ts +7 -0
  44. package/dist/components/ReplayLog.d.ts.map +1 -0
  45. package/dist/components/ReplayLog.js +51 -0
  46. package/dist/components/ReplayLog.js.map +1 -0
  47. package/dist/components/StreamingText.d.ts +7 -0
  48. package/dist/components/StreamingText.d.ts.map +1 -0
  49. package/dist/components/StreamingText.js +36 -0
  50. package/dist/components/StreamingText.js.map +1 -0
  51. package/dist/components/StreamingText.test.d.ts +2 -0
  52. package/dist/components/StreamingText.test.d.ts.map +1 -0
  53. package/dist/components/StreamingText.test.js +86 -0
  54. package/dist/components/StreamingText.test.js.map +1 -0
  55. package/dist/components/ToolUse.d.ts +8 -0
  56. package/dist/components/ToolUse.d.ts.map +1 -0
  57. package/dist/components/ToolUse.js +10 -0
  58. package/dist/components/ToolUse.js.map +1 -0
  59. package/dist/components/ToolUse.test.d.ts +2 -0
  60. package/dist/components/ToolUse.test.d.ts.map +1 -0
  61. package/dist/components/ToolUse.test.js +43 -0
  62. package/dist/components/ToolUse.test.js.map +1 -0
  63. package/dist/components/eventToBlocks.d.ts +12 -0
  64. package/dist/components/eventToBlocks.d.ts.map +1 -0
  65. package/dist/components/eventToBlocks.js +142 -0
  66. package/dist/components/eventToBlocks.js.map +1 -0
  67. package/dist/components/eventToBlocks.test.d.ts +2 -0
  68. package/dist/components/eventToBlocks.test.d.ts.map +1 -0
  69. package/dist/components/eventToBlocks.test.js +412 -0
  70. package/dist/components/eventToBlocks.test.js.map +1 -0
  71. package/dist/index.d.ts +1 -0
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +3 -21
  74. package/dist/index.js.map +1 -1
  75. package/dist/lib/cleanupAllWorktrees.d.ts +5 -0
  76. package/dist/lib/cleanupAllWorktrees.d.ts.map +1 -0
  77. package/dist/lib/cleanupAllWorktrees.js +25 -0
  78. package/dist/lib/cleanupAllWorktrees.js.map +1 -0
  79. package/dist/lib/cleanupWorktree.d.ts +6 -0
  80. package/dist/lib/cleanupWorktree.d.ts.map +1 -0
  81. package/dist/lib/cleanupWorktree.js +33 -0
  82. package/dist/lib/cleanupWorktree.js.map +1 -0
  83. package/dist/lib/copyRalphFilesFromWorktree.d.ts +5 -0
  84. package/dist/lib/copyRalphFilesFromWorktree.d.ts.map +1 -0
  85. package/dist/lib/copyRalphFilesFromWorktree.js +19 -0
  86. package/dist/lib/copyRalphFilesFromWorktree.js.map +1 -0
  87. package/dist/lib/copyRalphFilesToWorktree.d.ts +5 -0
  88. package/dist/lib/copyRalphFilesToWorktree.d.ts.map +1 -0
  89. package/dist/lib/copyRalphFilesToWorktree.js +21 -0
  90. package/dist/lib/copyRalphFilesToWorktree.js.map +1 -0
  91. package/dist/lib/createWorktree.d.ts +6 -0
  92. package/dist/lib/createWorktree.d.ts.map +1 -0
  93. package/dist/lib/createWorktree.js +34 -0
  94. package/dist/lib/createWorktree.js.map +1 -0
  95. package/dist/lib/getClaudeVersion.d.ts +2 -0
  96. package/dist/lib/getClaudeVersion.d.ts.map +1 -0
  97. package/dist/lib/getClaudeVersion.js +17 -0
  98. package/dist/lib/getClaudeVersion.js.map +1 -0
  99. package/dist/lib/getClaudeVersion.test.d.ts +2 -0
  100. package/dist/lib/getClaudeVersion.test.d.ts.map +1 -0
  101. package/dist/lib/getClaudeVersion.test.js +39 -0
  102. package/dist/lib/getClaudeVersion.test.js.map +1 -0
  103. package/dist/lib/getGitRoot.d.ts +5 -0
  104. package/dist/lib/getGitRoot.d.ts.map +1 -0
  105. package/dist/lib/getGitRoot.js +18 -0
  106. package/dist/lib/getGitRoot.js.map +1 -0
  107. package/dist/lib/installDependencies.d.ts +5 -0
  108. package/dist/lib/installDependencies.d.ts.map +1 -0
  109. package/dist/lib/installDependencies.js +23 -0
  110. package/dist/lib/installDependencies.js.map +1 -0
  111. package/dist/lib/installDependencies.test.d.ts +2 -0
  112. package/dist/lib/installDependencies.test.d.ts.map +1 -0
  113. package/dist/lib/installDependencies.test.js +37 -0
  114. package/dist/lib/installDependencies.test.js.map +1 -0
  115. package/dist/lib/mergeWorktreeToMain.d.ts +6 -0
  116. package/dist/lib/mergeWorktreeToMain.d.ts.map +1 -0
  117. package/dist/lib/mergeWorktreeToMain.js +44 -0
  118. package/dist/lib/mergeWorktreeToMain.js.map +1 -0
  119. package/dist/lib/popStash.d.ts +5 -0
  120. package/dist/lib/popStash.d.ts.map +1 -0
  121. package/dist/lib/popStash.js +17 -0
  122. package/dist/lib/popStash.js.map +1 -0
  123. package/dist/lib/rel.test.d.ts +2 -0
  124. package/dist/lib/rel.test.d.ts.map +1 -0
  125. package/dist/lib/rel.test.js +36 -0
  126. package/dist/lib/rel.test.js.map +1 -0
  127. package/dist/lib/replayLog.d.ts.map +1 -1
  128. package/dist/lib/replayLog.js +20 -6
  129. package/dist/lib/replayLog.js.map +1 -1
  130. package/dist/lib/runIteration.d.ts.map +1 -1
  131. package/dist/lib/runIteration.js +19 -9
  132. package/dist/lib/runIteration.js.map +1 -1
  133. package/dist/lib/shortenTempPaths.test.d.ts +2 -0
  134. package/dist/lib/shortenTempPaths.test.d.ts.map +1 -0
  135. package/dist/lib/shortenTempPaths.test.js +46 -0
  136. package/dist/lib/shortenTempPaths.test.js.map +1 -0
  137. package/dist/lib/signalHandler.d.ts +3 -0
  138. package/dist/lib/signalHandler.d.ts.map +1 -0
  139. package/dist/lib/signalHandler.js +19 -0
  140. package/dist/lib/signalHandler.js.map +1 -0
  141. package/dist/lib/stashChanges.d.ts +6 -0
  142. package/dist/lib/stashChanges.d.ts.map +1 -0
  143. package/dist/lib/stashChanges.js +27 -0
  144. package/dist/lib/stashChanges.js.map +1 -0
  145. package/dist/lib/types.d.ts +8 -0
  146. package/dist/lib/types.d.ts.map +1 -0
  147. package/dist/lib/types.js +5 -0
  148. package/dist/lib/types.js.map +1 -0
  149. package/dist/lib/worktree.d.ts +43 -0
  150. package/dist/lib/worktree.d.ts.map +1 -0
  151. package/dist/lib/worktree.js +210 -0
  152. package/dist/lib/worktree.js.map +1 -0
  153. package/dist/ui/EventProcessor.d.ts +11 -0
  154. package/dist/ui/EventProcessor.d.ts.map +1 -0
  155. package/dist/ui/EventProcessor.js +95 -0
  156. package/dist/ui/EventProcessor.js.map +1 -0
  157. package/dist/ui/IterationApp.d.ts +10 -0
  158. package/dist/ui/IterationApp.d.ts.map +1 -0
  159. package/dist/ui/IterationApp.js +21 -0
  160. package/dist/ui/IterationApp.js.map +1 -0
  161. package/dist/ui/IterationUI.d.ts +13 -0
  162. package/dist/ui/IterationUI.d.ts.map +1 -0
  163. package/dist/ui/IterationUI.js +19 -0
  164. package/dist/ui/IterationUI.js.map +1 -0
  165. package/dist/ui/TextDisplay.d.ts +7 -0
  166. package/dist/ui/TextDisplay.d.ts.map +1 -0
  167. package/dist/ui/TextDisplay.js +41 -0
  168. package/dist/ui/TextDisplay.js.map +1 -0
  169. package/dist/ui/ToolUseDisplay.d.ts +10 -0
  170. package/dist/ui/ToolUseDisplay.d.ts.map +1 -0
  171. package/dist/ui/ToolUseDisplay.js +10 -0
  172. package/dist/ui/ToolUseDisplay.js.map +1 -0
  173. package/package.json +23 -4
  174. package/templates/progress.md +1 -1
  175. package/templates/prompt.md +11 -1
  176. package/templates/todo.md +0 -1
@@ -0,0 +1,412 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { eventToBlocks } from "./eventToBlocks.js";
3
+ describe("eventToBlocks", () => {
4
+ it("returns empty array for non-assistant events", () => {
5
+ const event = { type: "message_start" };
6
+ const result = eventToBlocks(event);
7
+ expect(result).toEqual([]);
8
+ });
9
+ it("returns empty array for assistant event without message", () => {
10
+ const event = { type: "assistant" };
11
+ const result = eventToBlocks(event);
12
+ expect(result).toEqual([]);
13
+ });
14
+ it("returns empty array for assistant event without content", () => {
15
+ const event = { type: "assistant", message: {} };
16
+ const result = eventToBlocks(event);
17
+ expect(result).toEqual([]);
18
+ });
19
+ it("extracts text blocks", () => {
20
+ const event = {
21
+ type: "assistant",
22
+ message: {
23
+ id: "msg_123",
24
+ content: [{ type: "text", text: "Hello world" }],
25
+ },
26
+ };
27
+ const result = eventToBlocks(event);
28
+ expect(result).toEqual([{ type: "text", content: "Hello world", id: "msg_123-0" }]);
29
+ });
30
+ it("merges consecutive text blocks", () => {
31
+ const event = {
32
+ type: "assistant",
33
+ message: {
34
+ id: "msg_123",
35
+ content: [
36
+ { type: "text", text: "First" },
37
+ { type: "text", text: "Second" },
38
+ ],
39
+ },
40
+ };
41
+ const result = eventToBlocks(event);
42
+ expect(result).toEqual([{ type: "text", content: "FirstSecond", id: "msg_123-0" }]);
43
+ });
44
+ it("keeps text blocks separate when interrupted by tool calls", () => {
45
+ const event = {
46
+ type: "assistant",
47
+ message: {
48
+ id: "msg_123",
49
+ content: [
50
+ { type: "text", text: "Before tool" },
51
+ {
52
+ type: "tool_use",
53
+ name: "Read",
54
+ input: { file_path: `${process.cwd()}/file.ts` },
55
+ },
56
+ { type: "text", text: "After tool" },
57
+ ],
58
+ },
59
+ };
60
+ const result = eventToBlocks(event);
61
+ expect(result).toEqual([
62
+ { type: "text", content: "Before tool", id: "msg_123-0" },
63
+ { type: "tool", name: "Read", arg: "file.ts", id: "msg_123-1" },
64
+ { type: "text", content: "After tool", id: "msg_123-2" },
65
+ ]);
66
+ });
67
+ it("extracts Read tool use with relative path", () => {
68
+ const event = {
69
+ type: "assistant",
70
+ message: {
71
+ id: "msg_123",
72
+ content: [
73
+ {
74
+ type: "tool_use",
75
+ name: "Read",
76
+ input: { file_path: `${process.cwd()}/src/index.ts` },
77
+ },
78
+ ],
79
+ },
80
+ };
81
+ const result = eventToBlocks(event);
82
+ expect(result).toEqual([{ type: "tool", name: "Read", arg: "src/index.ts", id: "msg_123-0" }]);
83
+ });
84
+ it("extracts Edit tool use", () => {
85
+ const event = {
86
+ type: "assistant",
87
+ message: {
88
+ id: "msg_123",
89
+ content: [
90
+ {
91
+ type: "tool_use",
92
+ name: "Edit",
93
+ input: { file_path: `${process.cwd()}/src/app.ts` },
94
+ },
95
+ ],
96
+ },
97
+ };
98
+ const result = eventToBlocks(event);
99
+ expect(result).toEqual([{ type: "tool", name: "Edit", arg: "src/app.ts", id: "msg_123-0" }]);
100
+ });
101
+ it("extracts Write tool use", () => {
102
+ const event = {
103
+ type: "assistant",
104
+ message: {
105
+ id: "msg_123",
106
+ content: [
107
+ {
108
+ type: "tool_use",
109
+ name: "Write",
110
+ input: { file_path: `${process.cwd()}/src/new.ts` },
111
+ },
112
+ ],
113
+ },
114
+ };
115
+ const result = eventToBlocks(event);
116
+ expect(result).toEqual([{ type: "tool", name: "Write", arg: "src/new.ts", id: "msg_123-0" }]);
117
+ });
118
+ it("extracts Bash tool use with shortened temp paths", () => {
119
+ const event = {
120
+ type: "assistant",
121
+ message: {
122
+ id: "msg_123",
123
+ content: [
124
+ {
125
+ type: "tool_use",
126
+ name: "Bash",
127
+ input: { command: "cat /tmp/temp-file.txt" },
128
+ },
129
+ ],
130
+ },
131
+ };
132
+ const result = eventToBlocks(event);
133
+ expect(result).toEqual([{ type: "tool", name: "$", arg: "cat temp-file.txt", id: "msg_123-0" }]);
134
+ });
135
+ it("extracts Grep tool use with pattern only", () => {
136
+ const event = {
137
+ type: "assistant",
138
+ message: {
139
+ id: "msg_123",
140
+ content: [
141
+ {
142
+ type: "tool_use",
143
+ name: "Grep",
144
+ input: { pattern: "search-term" },
145
+ },
146
+ ],
147
+ },
148
+ };
149
+ const result = eventToBlocks(event);
150
+ expect(result).toEqual([{ type: "tool", name: "Grep", arg: "search-term", id: "msg_123-0" }]);
151
+ });
152
+ it("extracts Grep tool use with pattern and path", () => {
153
+ const event = {
154
+ type: "assistant",
155
+ message: {
156
+ id: "msg_123",
157
+ content: [
158
+ {
159
+ type: "tool_use",
160
+ name: "Grep",
161
+ input: { pattern: "TODO", path: `${process.cwd()}/src` },
162
+ },
163
+ ],
164
+ },
165
+ };
166
+ const result = eventToBlocks(event);
167
+ expect(result).toEqual([{ type: "tool", name: "Grep", arg: "TODO in src", id: "msg_123-0" }]);
168
+ });
169
+ it("extracts Glob tool use with pattern only", () => {
170
+ const event = {
171
+ type: "assistant",
172
+ message: {
173
+ id: "msg_123",
174
+ content: [
175
+ {
176
+ type: "tool_use",
177
+ name: "Glob",
178
+ input: { pattern: "**/*.ts" },
179
+ },
180
+ ],
181
+ },
182
+ };
183
+ const result = eventToBlocks(event);
184
+ expect(result).toEqual([{ type: "tool", name: "Glob", arg: "**/*.ts", id: "msg_123-0" }]);
185
+ });
186
+ it("extracts Glob tool use with pattern and path", () => {
187
+ const event = {
188
+ type: "assistant",
189
+ message: {
190
+ id: "msg_123",
191
+ content: [
192
+ {
193
+ type: "tool_use",
194
+ name: "Glob",
195
+ input: { pattern: "*.json", path: `${process.cwd()}/config` },
196
+ },
197
+ ],
198
+ },
199
+ };
200
+ const result = eventToBlocks(event);
201
+ expect(result).toEqual([
202
+ { type: "tool", name: "Glob", arg: "*.json in config", id: "msg_123-0" },
203
+ ]);
204
+ });
205
+ it("extracts TodoWrite with todos", () => {
206
+ const event = {
207
+ type: "assistant",
208
+ message: {
209
+ id: "msg_123",
210
+ content: [
211
+ {
212
+ type: "tool_use",
213
+ name: "TodoWrite",
214
+ input: {
215
+ todos: [
216
+ { content: "Task 1", status: "pending" },
217
+ { content: "Task 2", status: "in_progress" },
218
+ { content: "Task 3", status: "completed" },
219
+ ],
220
+ },
221
+ },
222
+ ],
223
+ },
224
+ };
225
+ const result = eventToBlocks(event);
226
+ expect(result).toEqual([
227
+ {
228
+ type: "tool",
229
+ name: "TodoWrite",
230
+ arg: "\n [ ] Task 1\n [~] Task 2\n [x] Task 3",
231
+ id: "msg_123-0",
232
+ },
233
+ ]);
234
+ });
235
+ it("extracts TodoWrite without todos", () => {
236
+ const event = {
237
+ type: "assistant",
238
+ message: {
239
+ id: "msg_123",
240
+ content: [
241
+ {
242
+ type: "tool_use",
243
+ name: "TodoWrite",
244
+ input: { todos: [] },
245
+ },
246
+ ],
247
+ },
248
+ };
249
+ const result = eventToBlocks(event);
250
+ expect(result).toEqual([{ type: "tool", name: "TodoWrite", id: "msg_123-0" }]);
251
+ });
252
+ it("extracts WebFetch tool use", () => {
253
+ const event = {
254
+ type: "assistant",
255
+ message: {
256
+ id: "msg_123",
257
+ content: [
258
+ {
259
+ type: "tool_use",
260
+ name: "WebFetch",
261
+ input: { url: "https://example.com" },
262
+ },
263
+ ],
264
+ },
265
+ };
266
+ const result = eventToBlocks(event);
267
+ expect(result).toEqual([
268
+ {
269
+ type: "tool",
270
+ name: "WebFetch",
271
+ arg: "https://example.com",
272
+ id: "msg_123-0",
273
+ },
274
+ ]);
275
+ });
276
+ it("extracts WebSearch tool use", () => {
277
+ const event = {
278
+ type: "assistant",
279
+ message: {
280
+ id: "msg_123",
281
+ content: [
282
+ {
283
+ type: "tool_use",
284
+ name: "WebSearch",
285
+ input: { query: "test query" },
286
+ },
287
+ ],
288
+ },
289
+ };
290
+ const result = eventToBlocks(event);
291
+ expect(result).toEqual([
292
+ {
293
+ type: "tool",
294
+ name: "WebSearch",
295
+ arg: "test query",
296
+ id: "msg_123-0",
297
+ },
298
+ ]);
299
+ });
300
+ it("extracts Task tool use", () => {
301
+ const event = {
302
+ type: "assistant",
303
+ message: {
304
+ id: "msg_123",
305
+ content: [
306
+ {
307
+ type: "tool_use",
308
+ name: "Task",
309
+ input: { description: "Run tests" },
310
+ },
311
+ ],
312
+ },
313
+ };
314
+ const result = eventToBlocks(event);
315
+ expect(result).toEqual([{ type: "tool", name: "Task", arg: "Run tests", id: "msg_123-0" }]);
316
+ });
317
+ it("extracts Skill tool use", () => {
318
+ const event = {
319
+ type: "assistant",
320
+ message: {
321
+ id: "msg_123",
322
+ content: [
323
+ {
324
+ type: "tool_use",
325
+ name: "Skill",
326
+ input: { skill: "commit" },
327
+ },
328
+ ],
329
+ },
330
+ };
331
+ const result = eventToBlocks(event);
332
+ expect(result).toEqual([{ type: "tool", name: "Skill", arg: "commit", id: "msg_123-0" }]);
333
+ });
334
+ it("ignores unknown tool types", () => {
335
+ const event = {
336
+ type: "assistant",
337
+ message: {
338
+ id: "msg_123",
339
+ content: [
340
+ {
341
+ type: "tool_use",
342
+ name: "UnknownTool",
343
+ input: { foo: "bar" },
344
+ },
345
+ ],
346
+ },
347
+ };
348
+ const result = eventToBlocks(event);
349
+ expect(result).toEqual([]);
350
+ });
351
+ it("handles mixed content types", () => {
352
+ const event = {
353
+ type: "assistant",
354
+ message: {
355
+ id: "msg_123",
356
+ content: [
357
+ { type: "text", text: "Let me read a file" },
358
+ {
359
+ type: "tool_use",
360
+ name: "Read",
361
+ input: { file_path: `${process.cwd()}/src/index.ts` },
362
+ },
363
+ { type: "text", text: "Done reading" },
364
+ ],
365
+ },
366
+ };
367
+ const result = eventToBlocks(event);
368
+ expect(result).toEqual([
369
+ { type: "text", content: "Let me read a file", id: "msg_123-0" },
370
+ { type: "tool", name: "Read", arg: "src/index.ts", id: "msg_123-1" },
371
+ { type: "text", content: "Done reading", id: "msg_123-2" },
372
+ ]);
373
+ });
374
+ it("generates unique IDs for each block", () => {
375
+ const event = {
376
+ type: "assistant",
377
+ message: {
378
+ id: "msg_123",
379
+ content: [
380
+ { type: "text", text: "First" },
381
+ {
382
+ type: "tool_use",
383
+ name: "Read",
384
+ input: { file_path: `${process.cwd()}/file1.ts` },
385
+ },
386
+ { type: "text", text: "Second" },
387
+ {
388
+ type: "tool_use",
389
+ name: "Read",
390
+ input: { file_path: `${process.cwd()}/file2.ts` },
391
+ },
392
+ { type: "text", text: "Third" },
393
+ ],
394
+ },
395
+ };
396
+ const result = eventToBlocks(event);
397
+ const ids = result.map(block => block.id);
398
+ expect(ids).toEqual(["msg_123-0", "msg_123-1", "msg_123-2", "msg_123-3", "msg_123-4"]);
399
+ expect(new Set(ids).size).toBe(5); // All unique
400
+ });
401
+ it('uses "unknown" ID when message has no ID', () => {
402
+ const event = {
403
+ type: "assistant",
404
+ message: {
405
+ content: [{ type: "text", text: "Hello" }],
406
+ },
407
+ };
408
+ const result = eventToBlocks(event);
409
+ expect(result[0].id).toBe("unknown-0");
410
+ });
411
+ });
412
+ //# sourceMappingURL=eventToBlocks.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventToBlocks.test.js","sourceRoot":"","sources":["../../src/components/eventToBlocks.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,CAAA;QACvC,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;QACnC,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;QAChD,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA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EAAE,OAAO,EAAE,CAAC;aAC3C;SACF,CAAA;QACD,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ import "./lib/signalHandler.js";
1
2
  export declare const run: () => void;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG,YAuBf,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,wBAAwB,CAAA;AAE/B,eAAO,MAAM,GAAG,YAEf,CAAA"}
package/dist/index.js CHANGED
@@ -1,25 +1,7 @@
1
- import { replayLog } from "./lib/replayLog.js";
2
- import { runIteration } from "./lib/runIteration.js";
3
- import { parseArgs, showHelp, initRalph } from "./cli.js";
1
+ import { program } from "./cli.js";
2
+ import "./lib/signalHandler.js"; // Register global SIGINT/SIGTERM handlers
4
3
  export const run = () => {
5
- const args = process.argv.slice(2);
6
- const parsed = parseArgs(args);
7
- if (parsed.mode === "help") {
8
- showHelp();
9
- return;
10
- }
11
- if (parsed.mode === "init") {
12
- initRalph();
13
- return;
14
- }
15
- if (parsed.mode === "replay") {
16
- replayLog(parsed.replayFile);
17
- return;
18
- }
19
- if (parsed.mode === "run") {
20
- runIteration(1, parsed.iterations);
21
- return;
22
- }
4
+ program.parse(process.argv);
23
5
  };
24
6
  // Run if called directly
25
7
  if (import.meta.url === `file://${process.argv[1]}`) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAC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,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAC,CAAA;AAED,yBAAyB;AACzB,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,GAAG,EAAE,CAAA;AACP,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Clean up all ralph worktrees (useful for recovery)
3
+ */
4
+ export declare function cleanupAllWorktrees(repoRoot: string): void;
5
+ //# sourceMappingURL=cleanupAllWorktrees.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanupAllWorktrees.d.ts","sourceRoot":"","sources":["../../src/lib/cleanupAllWorktrees.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAe1D"}
@@ -0,0 +1,25 @@
1
+ import { execSync } from "child_process";
2
+ import { existsSync, rmSync } from "fs";
3
+ import { tmpdir } from "os";
4
+ import { join } from "path";
5
+ import { execOptions } from "./types.js";
6
+ /**
7
+ * Clean up all ralph worktrees (useful for recovery)
8
+ */
9
+ export function cleanupAllWorktrees(repoRoot) {
10
+ try {
11
+ const worktreesDir = join(tmpdir(), "ralph-worktrees");
12
+ if (existsSync(worktreesDir)) {
13
+ rmSync(worktreesDir, { recursive: true, force: true });
14
+ }
15
+ // Prune any stale worktree references
16
+ execSync("git worktree prune", {
17
+ ...execOptions,
18
+ cwd: repoRoot,
19
+ });
20
+ }
21
+ catch (error) {
22
+ console.error(`Warning: Failed to cleanup all worktrees: ${error}`);
23
+ }
24
+ }
25
+ //# sourceMappingURL=cleanupAllWorktrees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanupAllWorktrees.js","sourceRoot":"","sources":["../../src/lib/cleanupAllWorktrees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAA;QACtD,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACxD,CAAC;QAED,sCAAsC;QACtC,QAAQ,CAAC,oBAAoB,EAAE;YAC7B,GAAG,WAAW;YACd,GAAG,EAAE,QAAQ;SACd,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6CAA6C,KAAK,EAAE,CAAC,CAAA;IACrE,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { WorktreeInfo } from "./types.js";
2
+ /**
3
+ * Remove a worktree and its branch
4
+ */
5
+ export declare function cleanupWorktree(repoRoot: string, worktree: WorktreeInfo): void;
6
+ //# sourceMappingURL=cleanupWorktree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanupWorktree.d.ts","sourceRoot":"","sources":["../../src/lib/cleanupWorktree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAe,MAAM,YAAY,CAAA;AAEtD;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI,CAyB9E"}
@@ -0,0 +1,33 @@
1
+ import { execSync } from "child_process";
2
+ import { existsSync, rmSync } from "fs";
3
+ import { execOptions } from "./types.js";
4
+ /**
5
+ * Remove a worktree and its branch
6
+ */
7
+ export function cleanupWorktree(repoRoot, worktree) {
8
+ try {
9
+ // Remove the worktree
10
+ execSync(`git worktree remove "${worktree.path}" --force`, {
11
+ ...execOptions,
12
+ cwd: repoRoot,
13
+ });
14
+ // Delete the branch
15
+ execSync(`git branch -D ${worktree.branch}`, {
16
+ ...execOptions,
17
+ cwd: repoRoot,
18
+ });
19
+ }
20
+ catch (error) {
21
+ // Try to clean up the directory even if git commands fail
22
+ try {
23
+ if (existsSync(worktree.path)) {
24
+ rmSync(worktree.path, { recursive: true, force: true });
25
+ }
26
+ }
27
+ catch {
28
+ // Ignore cleanup errors
29
+ }
30
+ console.error(`Warning: Failed to fully cleanup worktree: ${error}`);
31
+ }
32
+ }
33
+ //# sourceMappingURL=cleanupWorktree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanupWorktree.js","sourceRoot":"","sources":["../../src/lib/cleanupWorktree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AACvC,OAAO,EAAgB,WAAW,EAAE,MAAM,YAAY,CAAA;AAEtD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,QAAsB;IACtE,IAAI,CAAC;QACH,sBAAsB;QACtB,QAAQ,CAAC,wBAAwB,QAAQ,CAAC,IAAI,WAAW,EAAE;YACzD,GAAG,WAAW;YACd,GAAG,EAAE,QAAQ;SACd,CAAC,CAAA;QAEF,oBAAoB;QACpB,QAAQ,CAAC,iBAAiB,QAAQ,CAAC,MAAM,EAAE,EAAE;YAC3C,GAAG,WAAW;YACd,GAAG,EAAE,QAAQ;SACd,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,0DAA0D;QAC1D,IAAI,CAAC;YACH,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC9B,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;YACzD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,8CAA8C,KAAK,EAAE,CAAC,CAAA;IACtE,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Copy updated .ralph files from worktree back to main repo
3
+ */
4
+ export declare function copyRalphFilesFromWorktree(repoRoot: string, worktreePath: string): void;
5
+ //# sourceMappingURL=copyRalphFilesFromWorktree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyRalphFilesFromWorktree.d.ts","sourceRoot":"","sources":["../../src/lib/copyRalphFilesFromWorktree.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAavF"}
@@ -0,0 +1,19 @@
1
+ import { copyFileSync, existsSync } from "fs";
2
+ import { join } from "path";
3
+ /**
4
+ * Copy updated .ralph files from worktree back to main repo
5
+ */
6
+ export function copyRalphFilesFromWorktree(repoRoot, worktreePath) {
7
+ const ralphDir = join(repoRoot, ".ralph");
8
+ const worktreeRalphDir = join(worktreePath, ".ralph");
9
+ // Copy back todo.md and progress.md (prompt.md doesn't change)
10
+ const files = ["todo.md", "progress.md"];
11
+ for (const file of files) {
12
+ const src = join(worktreeRalphDir, file);
13
+ const dest = join(ralphDir, file);
14
+ if (existsSync(src)) {
15
+ copyFileSync(src, dest);
16
+ }
17
+ }
18
+ }
19
+ //# sourceMappingURL=copyRalphFilesFromWorktree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyRalphFilesFromWorktree.js","sourceRoot":"","sources":["../../src/lib/copyRalphFilesFromWorktree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,QAAgB,EAAE,YAAoB;IAC/E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACzC,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;IAErD,+DAA+D;IAC/D,MAAM,KAAK,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IACxC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAA;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QACjC,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACpB,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Copy .ralph files from main repo to worktree
3
+ */
4
+ export declare function copyRalphFilesToWorktree(repoRoot: string, worktreePath: string): void;
5
+ //# sourceMappingURL=copyRalphFilesToWorktree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyRalphFilesToWorktree.d.ts","sourceRoot":"","sources":["../../src/lib/copyRalphFilesToWorktree.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAgBrF"}
@@ -0,0 +1,21 @@
1
+ import { copyFileSync, mkdirSync, existsSync } from "fs";
2
+ import { join } from "path";
3
+ /**
4
+ * Copy .ralph files from main repo to worktree
5
+ */
6
+ export function copyRalphFilesToWorktree(repoRoot, worktreePath) {
7
+ const ralphDir = join(repoRoot, ".ralph");
8
+ const worktreeRalphDir = join(worktreePath, ".ralph");
9
+ // Create .ralph directory in worktree
10
+ mkdirSync(worktreeRalphDir, { recursive: true });
11
+ // Copy required files
12
+ const files = ["prompt.md", "todo.md", "progress.md"];
13
+ for (const file of files) {
14
+ const src = join(ralphDir, file);
15
+ const dest = join(worktreeRalphDir, file);
16
+ if (existsSync(src)) {
17
+ copyFileSync(src, dest);
18
+ }
19
+ }
20
+ }
21
+ //# sourceMappingURL=copyRalphFilesToWorktree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyRalphFilesToWorktree.js","sourceRoot":"","sources":["../../src/lib/copyRalphFilesToWorktree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAAgB,EAAE,YAAoB;IAC7E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACzC,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;IAErD,sCAAsC;IACtC,SAAS,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAEhD,sBAAsB;IACtB,MAAM,KAAK,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAA;IACrD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAA;QACzC,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACpB,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { WorktreeInfo } from "./types.js";
2
+ /**
3
+ * Create a new git worktree for an iteration
4
+ */
5
+ export declare function createWorktree(repoRoot: string): WorktreeInfo;
6
+ //# sourceMappingURL=createWorktree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createWorktree.d.ts","sourceRoot":"","sources":["../../src/lib/createWorktree.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAe,MAAM,YAAY,CAAA;AAEtD;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAyB7D"}