cralph 1.0.0-alpha.3 → 1.0.0-alpha.4

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 (3) hide show
  1. package/README.md +10 -1
  2. package/package.json +1 -1
  3. package/src/runner.ts +48 -18
package/README.md CHANGED
@@ -134,6 +134,14 @@ If not authenticated:
134
134
  ✔ Saved .ralph/paths.json
135
135
  ```
136
136
 
137
+ **TODO state check (on run):**
138
+ ```
139
+ ? Found existing TODO with progress. Reset to start fresh? (y/N)
140
+ ```
141
+ - If the `.ralph/TODO.md` file has been modified from previous runs, you'll be asked whether to reset it
142
+ - Default is **No** (continue with existing progress)
143
+ - Choose **Yes** to start fresh with a clean TODO
144
+
137
145
  **Cancellation:**
138
146
  - Press `Ctrl+C` at any time to exit
139
147
  - Running Claude processes are terminated cleanly
@@ -149,7 +157,8 @@ If not authenticated:
149
157
  bun test
150
158
  ```
151
159
 
152
- Tests validate config loading, prompt building, and CLI behavior without calling Claude.
160
+ - **Unit tests** validate config loading, prompt building, and CLI behavior
161
+ - **E2E tests** run the full loop with Claude (requires authentication)
153
162
 
154
163
  ## Requirements
155
164
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cralph",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "Claude in a loop. Point at refs, give it a rule, let it cook.",
5
5
  "author": "mguleryuz",
6
6
  "license": "MIT",
package/src/runner.ts CHANGED
@@ -6,6 +6,21 @@ import { createPrompt } from "./prompt";
6
6
 
7
7
  const COMPLETION_SIGNAL = "<promise>COMPLETE</promise>";
8
8
 
9
+ const INITIAL_TODO_CONTENT = `# Ralph Agent Status
10
+
11
+ ## Current Status
12
+
13
+ Idle - waiting for documents in refs/
14
+
15
+ ## Processed Files
16
+
17
+ _None yet_
18
+
19
+ ## Pending
20
+
21
+ _Check refs/ for new documents_
22
+ `;
23
+
9
24
  /**
10
25
  * Check if Claude CLI is authenticated by sending a minimal test prompt
11
26
  */
@@ -40,6 +55,18 @@ export async function checkClaudeAuth(): Promise<boolean> {
40
55
  }
41
56
 
42
57
 
58
+ /**
59
+ * Check if the TODO file is in a clean/initial state
60
+ */
61
+ async function isTodoClean(todoPath: string): Promise<boolean> {
62
+ const file = Bun.file(todoPath);
63
+ if (!(await file.exists())) {
64
+ return true; // Non-existent is considered clean
65
+ }
66
+ const content = await file.text();
67
+ return content.trim() === INITIAL_TODO_CONTENT.trim();
68
+ }
69
+
43
70
  /**
44
71
  * Initialize the runner state and log file
45
72
  */
@@ -61,26 +88,29 @@ Ralph Session: ${state.startTime.toISOString()}
61
88
 
62
89
  await Bun.write(state.logFile, logHeader);
63
90
 
64
- // Initialize TODO file if not exists
91
+ // Check TODO file state
65
92
  const todoFile = Bun.file(state.todoFile);
66
- if (!(await todoFile.exists())) {
67
- await Bun.write(
68
- state.todoFile,
69
- `# Ralph Agent Status
70
-
71
- ## Current Status
72
-
73
- Idle - waiting for documents in refs/
74
-
75
- ## Processed Files
76
-
77
- _None yet_
78
-
79
- ## Pending
80
-
81
- _Check refs/ for new documents_
82
- `
93
+ const todoExists = await todoFile.exists();
94
+
95
+ if (!todoExists) {
96
+ // Create fresh TODO file
97
+ await Bun.write(state.todoFile, INITIAL_TODO_CONTENT);
98
+ } else if (!(await isTodoClean(state.todoFile))) {
99
+ // TODO exists and has been modified - ask about reset
100
+ const response = await consola.prompt(
101
+ "Found existing TODO with progress. Reset to start fresh?",
102
+ {
103
+ type: "confirm",
104
+ initial: false,
105
+ }
83
106
  );
107
+
108
+ if (response === true) {
109
+ await Bun.write(state.todoFile, INITIAL_TODO_CONTENT);
110
+ consola.info("TODO reset to clean state");
111
+ } else {
112
+ consola.info("Continuing with existing TODO state");
113
+ }
84
114
  }
85
115
 
86
116
  return state;