cralph 1.0.0-beta.5 → 1.0.0-beta.6

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 CHANGED
@@ -98,9 +98,14 @@ Claude maintains this structure:
98
98
  - [ ] Pending task
99
99
  - [x] Completed task
100
100
 
101
+ ---
102
+
101
103
  # Notes
102
104
 
103
- Any relevant context
105
+ ## Task Title - Done
106
+ - What was implemented
107
+ - Files changed
108
+ - Learnings: patterns discovered, gotchas encountered
104
109
  ```
105
110
 
106
111
  ## First Run (No .ralph/ in cwd)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cralph",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.6",
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/prompt.ts CHANGED
@@ -10,12 +10,12 @@ FIRST: Read and internalize the rules provided below.
10
10
 
11
11
  ## Your Task Each Iteration
12
12
 
13
- 1. Read the TODO file and check the Patterns section first
13
+ 1. Read the TODO file
14
14
  2. Pick the FIRST uncompleted task (marked with [ ])
15
15
  3. Implement that SINGLE task
16
16
  4. Run quality checks (typecheck, lint, test - whatever the project requires)
17
17
  5. If checks pass, mark the task [x] complete
18
- 6. Append your progress with learnings (see format below)
18
+ 6. Append your progress to the Notes section (see format below)
19
19
  7. If ALL tasks are complete, output the completion signal
20
20
 
21
21
  ## Critical Rules
@@ -24,6 +24,17 @@ FIRST: Read and internalize the rules provided below.
24
24
  - **Quality first** - Do NOT mark a task complete if tests/typecheck fail
25
25
  - **Keep changes focused** - Minimal, targeted changes only
26
26
  - **Follow existing patterns** - Match the codebase style
27
+ - **Commit after completing** - Commit your changes with a meaningful message
28
+
29
+ ## Commit Format
30
+
31
+ After completing a task and quality checks pass, commit ALL changes with:
32
+
33
+ \`\`\`
34
+ feat: [Task Title]
35
+ \`\`\`
36
+
37
+ Use \`feat:\` for new features, \`fix:\` for bug fixes, \`refactor:\` for refactoring, \`docs:\` for documentation.
27
38
 
28
39
  ## Progress Format
29
40
 
@@ -38,18 +49,6 @@ After completing a task, APPEND to the Notes section:
38
49
  - Gotchas encountered
39
50
  \`\`\`
40
51
 
41
- ## Consolidate Patterns
42
-
43
- If you discover a REUSABLE pattern, add it to the **# Patterns** section at the TOP of the TODO file:
44
-
45
- \`\`\`
46
- # Patterns
47
- - Example: Use \`sql<number>\` template for aggregations
48
- - Example: Always update X when changing Y
49
- \`\`\`
50
-
51
- Only add patterns that are general and reusable, not task-specific details.
52
-
53
52
  ## Refs (Read-Only)
54
53
 
55
54
  If refs paths are provided, they are READ-ONLY reference material. Never modify files in refs.
package/src/runner.ts CHANGED
@@ -9,13 +9,7 @@ import { setCurrentProcess, throwIfCancelled } from "./state";
9
9
  const COMPLETION_SIGNAL = "<promise>COMPLETE</promise>";
10
10
  const AUTH_CACHE_TTL_MS = 6 * 60 * 60 * 1000; // 6 hours
11
11
 
12
- const INITIAL_TODO_CONTENT = `# Patterns
13
-
14
- _None yet - add reusable patterns discovered during work_
15
-
16
- ---
17
-
18
- # Tasks
12
+ const INITIAL_TODO_CONTENT = `# Tasks
19
13
 
20
14
  - [ ] Task 1
21
15
  - [ ] Task 2
@@ -186,6 +180,48 @@ async function log(state: RunnerState, message: string): Promise<void> {
186
180
  await Bun.write(state.logFile, existing + logLine);
187
181
  }
188
182
 
183
+ /**
184
+ * Try to commit progress after each iteration
185
+ * Fails gracefully - logs warning and continues if commit fails
186
+ */
187
+ async function tryCommitProgress(state: RunnerState, cwd: string): Promise<void> {
188
+ try {
189
+ // Stage all changes
190
+ const addProc = Bun.spawn(["git", "add", "-A"], {
191
+ cwd,
192
+ stdout: "pipe",
193
+ stderr: "pipe",
194
+ });
195
+ await addProc.exited;
196
+
197
+ // Commit with iteration number
198
+ const commitMessage = `chore(ralph): iteration ${state.iteration} progress`;
199
+ const commitProc = Bun.spawn(
200
+ ["git", "commit", "-m", commitMessage, "--no-verify"],
201
+ {
202
+ cwd,
203
+ stdout: "pipe",
204
+ stderr: "pipe",
205
+ }
206
+ );
207
+
208
+ const exitCode = await commitProc.exited;
209
+
210
+ if (exitCode === 0) {
211
+ consola.info(`Committed iteration ${state.iteration} progress`);
212
+ await log(state, `Committed: ${commitMessage}`);
213
+ } else {
214
+ // Exit code 1 usually means nothing to commit
215
+ await log(state, `No changes to commit for iteration ${state.iteration}`);
216
+ }
217
+ } catch (error) {
218
+ // Gracefully fail - just log and continue
219
+ const errorMsg = error instanceof Error ? error.message : String(error);
220
+ consola.warn(`Could not commit progress: ${errorMsg}`);
221
+ await log(state, `Commit failed: ${errorMsg}`);
222
+ }
223
+ }
224
+
189
225
  /**
190
226
  * Run a single Claude iteration
191
227
  */
@@ -268,6 +304,9 @@ export async function run(config: RalphConfig): Promise<void> {
268
304
 
269
305
  const result = await runIteration(prompt, state, cwd);
270
306
 
307
+ // Try to commit progress after each iteration (fails gracefully)
308
+ await tryCommitProgress(state, cwd);
309
+
271
310
  if (result.isComplete) {
272
311
  break;
273
312
  }