cralph 1.0.0-beta.3 → 1.0.0-beta.5

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
@@ -1,7 +1,7 @@
1
1
  # cralph
2
2
 
3
3
  <p align="center">
4
- <img src="assets/ralph.png" alt="Ralph cooking" width="500">
4
+ <img src="https://raw.githubusercontent.com/mguleryuz/cralph/main/assets/ralph.png" alt="Ralph cooking" width="500">
5
5
  </p>
6
6
 
7
7
  Claude in a loop. Give it a rule, let it cook.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cralph",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.5",
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",
@@ -26,8 +26,7 @@
26
26
  "src",
27
27
  "index.ts",
28
28
  "README.md",
29
- "LICENSE",
30
- "assets"
29
+ "LICENSE"
31
30
  ],
32
31
  "scripts": {
33
32
  "start": "bun run src/cli.ts",
package/src/prompt.ts CHANGED
@@ -2,26 +2,67 @@ import type { RalphConfig } from "./types";
2
2
 
3
3
  /**
4
4
  * The main ralph prompt template.
5
- * Generic prompt for any Ralph use case.
5
+ * Based on ralph-ref best practices for autonomous agent loops.
6
6
  */
7
- const BASE_PROMPT = `You are an autonomous agent running in a loop.
7
+ const BASE_PROMPT = `You are an autonomous coding agent running in a loop.
8
8
 
9
9
  FIRST: Read and internalize the rules provided below.
10
10
 
11
- Your job is to follow the rules and complete the task. Write output to the output directory.
11
+ ## Your Task Each Iteration
12
12
 
13
- If refs paths are provided, they are READ-ONLY reference material. Never delete, move, or modify files in refs.
13
+ 1. Read the TODO file and check the Patterns section first
14
+ 2. Pick the FIRST uncompleted task (marked with [ ])
15
+ 3. Implement that SINGLE task
16
+ 4. Run quality checks (typecheck, lint, test - whatever the project requires)
17
+ 5. If checks pass, mark the task [x] complete
18
+ 6. Append your progress with learnings (see format below)
19
+ 7. If ALL tasks are complete, output the completion signal
14
20
 
15
- **IMPORTANT: At the end of EVERY iteration, update the TODO file with your progress.**
16
- Keep the TODO structure with these sections:
17
- - **# Tasks** - Checklist with [ ] for pending and [x] for done
18
- - **# Notes** - Any relevant notes or context
21
+ ## Critical Rules
19
22
 
20
- STOPPING CONDITION: When done, update the TODO file, then output exactly:
23
+ - **ONE task per iteration** - Do not try to complete multiple tasks
24
+ - **Quality first** - Do NOT mark a task complete if tests/typecheck fail
25
+ - **Keep changes focused** - Minimal, targeted changes only
26
+ - **Follow existing patterns** - Match the codebase style
27
+
28
+ ## Progress Format
29
+
30
+ After completing a task, APPEND to the Notes section:
31
+
32
+ \`\`\`
33
+ ## [Task Title] - Done
34
+ - What was implemented
35
+ - Files changed
36
+ - **Learnings:**
37
+ - Patterns discovered
38
+ - Gotchas encountered
39
+ \`\`\`
40
+
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
+ ## Refs (Read-Only)
54
+
55
+ If refs paths are provided, they are READ-ONLY reference material. Never modify files in refs.
56
+
57
+ ## Stop Condition
58
+
59
+ After completing a task, check if ALL tasks are marked [x] complete.
60
+
61
+ If ALL tasks are done, output exactly:
21
62
 
22
63
  <promise>COMPLETE</promise>
23
64
 
24
- This signals the automation to stop. Only output this tag when truly done.`;
65
+ If there are still pending tasks, end your response normally (the loop will continue).`;
25
66
 
26
67
  /**
27
68
  * Build the complete prompt with config and rules injected
@@ -37,18 +78,18 @@ export function buildPrompt(config: RalphConfig, rulesContent: string, todoFile:
37
78
 
38
79
  ## Configuration
39
80
 
40
- **TODO file (update after each iteration):**
81
+ **TODO file (read first, update after each task):**
41
82
  ${todoFile}
42
83
 
43
- **Refs paths (optional, read-only reference material):**
84
+ **Refs (read-only reference material):**
44
85
  ${refsList}
45
86
 
46
- **Output directory:**
87
+ **Output directory (write your work here):**
47
88
  ${config.output}
48
89
 
49
90
  ---
50
91
 
51
- ## Rules
92
+ ## Rules (Your Instructions)
52
93
 
53
94
  ${rulesContent}
54
95
  `;
package/src/runner.ts CHANGED
@@ -9,14 +9,22 @@ 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 = `# Tasks
12
+ const INITIAL_TODO_CONTENT = `# Patterns
13
+
14
+ _None yet - add reusable patterns discovered during work_
15
+
16
+ ---
17
+
18
+ # Tasks
13
19
 
14
20
  - [ ] Task 1
15
21
  - [ ] Task 2
16
22
 
23
+ ---
24
+
17
25
  # Notes
18
26
 
19
- _None yet_
27
+ _Append progress and learnings here after each iteration_
20
28
  `;
21
29
 
22
30
  /**
package/assets/ralph.png DELETED
Binary file