@hivehub/rulebook 3.1.0 → 3.2.1
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/.claude/commands/ralph-config.md +112 -0
- package/.claude/commands/ralph-history.md +110 -0
- package/.claude/commands/ralph-init.md +72 -0
- package/.claude/commands/ralph-pause-resume.md +105 -0
- package/.claude/commands/ralph-run.md +101 -0
- package/.claude/commands/ralph-status.md +76 -0
- package/.claude/commands/rulebook-memory-save.md +48 -0
- package/.claude/commands/rulebook-memory-search.md +47 -0
- package/.claude/commands/rulebook-task-apply.md +67 -0
- package/.claude/commands/rulebook-task-archive.md +70 -0
- package/.claude/commands/rulebook-task-create.md +93 -0
- package/.claude/commands/rulebook-task-list.md +42 -0
- package/.claude/commands/rulebook-task-show.md +52 -0
- package/.claude/commands/rulebook-task-validate.md +53 -0
- package/.claude-plugin/marketplace.json +29 -0
- package/.claude-plugin/plugin.json +8 -0
- package/README.md +1 -0
- package/dist/agents/ralph-parser.d.ts.map +1 -1
- package/dist/agents/ralph-parser.js +5 -28
- package/dist/agents/ralph-parser.js.map +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +15 -9
- package/dist/cli/commands.js.map +1 -1
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/generator.js +29 -29
- package/dist/core/generator.js.map +1 -1
- package/dist/core/iteration-tracker.d.ts.map +1 -1
- package/dist/core/iteration-tracker.js.map +1 -1
- package/dist/core/prd-generator.d.ts.map +1 -1
- package/dist/core/prd-generator.js.map +1 -1
- package/dist/core/ralph-manager.d.ts.map +1 -1
- package/dist/core/ralph-manager.js +1 -3
- package/dist/core/ralph-manager.js.map +1 -1
- package/dist/core/workflow-generator.js +297 -297
- package/dist/mcp/rulebook-server.d.ts +1 -1
- package/dist/mcp/rulebook-server.d.ts.map +1 -1
- package/dist/mcp/rulebook-server.js +47 -25
- package/dist/mcp/rulebook-server.js.map +1 -1
- package/dist/memory/hnsw-index.d.ts.map +1 -1
- package/dist/memory/hnsw-index.js.map +1 -1
- package/dist/memory/memory-cache.d.ts.map +1 -1
- package/dist/memory/memory-cache.js.map +1 -1
- package/dist/memory/memory-hooks.d.ts.map +1 -1
- package/dist/memory/memory-hooks.js +1 -3
- package/dist/memory/memory-hooks.js.map +1 -1
- package/dist/memory/memory-manager.d.ts.map +1 -1
- package/dist/memory/memory-manager.js +2 -7
- package/dist/memory/memory-manager.js.map +1 -1
- package/dist/memory/memory-search.d.ts.map +1 -1
- package/dist/memory/memory-search.js +3 -8
- package/dist/memory/memory-search.js.map +1 -1
- package/dist/memory/memory-store.d.ts.map +1 -1
- package/dist/memory/memory-store.js +68 -71
- package/dist/memory/memory-store.js.map +1 -1
- package/dist/memory/memory-vectorizer.d.ts.map +1 -1
- package/dist/memory/memory-vectorizer.js +108 -13
- package/dist/memory/memory-vectorizer.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: /ralph-config
|
|
3
|
+
id: ralph-config
|
|
4
|
+
category: Ralph
|
|
5
|
+
description: Configure Ralph autonomous loop settings and parameters.
|
|
6
|
+
---
|
|
7
|
+
<!-- RALPH:START -->
|
|
8
|
+
**Overview**
|
|
9
|
+
Manage Ralph's configuration including max iterations, AI tool selection, and other loop parameters. Configuration is stored in `.rulebook/ralph/config.json`.
|
|
10
|
+
|
|
11
|
+
**Guardrails**
|
|
12
|
+
- Configuration applies to future iterations only
|
|
13
|
+
- Changing config mid-loop may not affect current iteration
|
|
14
|
+
- Save configuration changes before resuming loop
|
|
15
|
+
- Common settings: max_iterations, ai_tool, branch_name
|
|
16
|
+
|
|
17
|
+
**Configuration Options**
|
|
18
|
+
|
|
19
|
+
### Max Iterations
|
|
20
|
+
Maximum number of iterations Ralph will run before stopping.
|
|
21
|
+
```bash
|
|
22
|
+
rulebook ralph config set max_iterations 20
|
|
23
|
+
```
|
|
24
|
+
- Recommended: 5-20 for most projects
|
|
25
|
+
- Higher values allow more complex tasks to complete
|
|
26
|
+
- Lower values quick validation runs
|
|
27
|
+
|
|
28
|
+
### AI Tool
|
|
29
|
+
Which AI tool to use for solving tasks (claude, cursor, gemini).
|
|
30
|
+
```bash
|
|
31
|
+
rulebook ralph config set ai_tool claude
|
|
32
|
+
```
|
|
33
|
+
- `claude` (recommended): Best for complex reasoning
|
|
34
|
+
- `cursor`: Fast iteration if you have Cursor CLI
|
|
35
|
+
- `gemini`: Alternative option for diversity
|
|
36
|
+
- Note: Tool must be installed and available on CLI
|
|
37
|
+
|
|
38
|
+
### Branch Name
|
|
39
|
+
Git branch Ralph works on for this loop.
|
|
40
|
+
```bash
|
|
41
|
+
rulebook ralph config set branch_name ralph/my-feature
|
|
42
|
+
```
|
|
43
|
+
- Automatically set during init
|
|
44
|
+
- Change if working on different feature
|
|
45
|
+
- Ralph commits to this branch
|
|
46
|
+
|
|
47
|
+
### Project Name
|
|
48
|
+
Project name for documentation and tracking.
|
|
49
|
+
```bash
|
|
50
|
+
rulebook ralph config set project_name my-project
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Steps**
|
|
54
|
+
|
|
55
|
+
1. **View Current Configuration**:
|
|
56
|
+
```bash
|
|
57
|
+
rulebook ralph config show
|
|
58
|
+
```
|
|
59
|
+
Displays all current settings
|
|
60
|
+
|
|
61
|
+
2. **Update a Setting**:
|
|
62
|
+
```bash
|
|
63
|
+
rulebook ralph config set <key> <value>
|
|
64
|
+
```
|
|
65
|
+
Example:
|
|
66
|
+
```bash
|
|
67
|
+
rulebook ralph config set max_iterations 15
|
|
68
|
+
rulebook ralph config set ai_tool cursor
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. **Reset to Defaults**:
|
|
72
|
+
```bash
|
|
73
|
+
rulebook ralph config reset
|
|
74
|
+
```
|
|
75
|
+
Resets to default values from init
|
|
76
|
+
|
|
77
|
+
4. **Verify Changes**:
|
|
78
|
+
```bash
|
|
79
|
+
rulebook ralph status
|
|
80
|
+
```
|
|
81
|
+
Shows updated config in status output
|
|
82
|
+
|
|
83
|
+
**Configuration File**
|
|
84
|
+
Location: `.rulebook/ralph/config.json`
|
|
85
|
+
|
|
86
|
+
Example structure:
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"enabled": true,
|
|
90
|
+
"max_iterations": 10,
|
|
91
|
+
"current_iteration": 0,
|
|
92
|
+
"ai_tool": "claude",
|
|
93
|
+
"project_name": "my-project",
|
|
94
|
+
"branch_name": "ralph/my-project",
|
|
95
|
+
"paused": false
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Workflow**
|
|
100
|
+
1. Initialize Ralph: `rulebook ralph init` (sets initial config)
|
|
101
|
+
2. Review config: `rulebook ralph config show`
|
|
102
|
+
3. Adjust as needed: `rulebook ralph config set <key> <value>`
|
|
103
|
+
4. Start loop: `rulebook ralph run`
|
|
104
|
+
5. Monitor with: `rulebook ralph status`
|
|
105
|
+
|
|
106
|
+
**Troubleshooting**
|
|
107
|
+
- **Config file missing**: Run `rulebook ralph init` again
|
|
108
|
+
- **Settings not updating**: Ensure you're using correct key name
|
|
109
|
+
- **Changes not taking effect**: Pause loop, update config, then resume
|
|
110
|
+
- **Invalid ai_tool**: Check tool is installed (e.g., `claude --version`)
|
|
111
|
+
|
|
112
|
+
<!-- RALPH:END -->
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: /ralph-history
|
|
3
|
+
id: ralph-history
|
|
4
|
+
category: Ralph
|
|
5
|
+
description: View past Ralph iterations, quality check results, and learnings.
|
|
6
|
+
---
|
|
7
|
+
<!-- RALPH:START -->
|
|
8
|
+
**Overview**
|
|
9
|
+
Review detailed records of all Ralph iterations, including:
|
|
10
|
+
- Task completion status
|
|
11
|
+
- Quality gate results (type-check, lint, tests, coverage)
|
|
12
|
+
- Execution time and performance metrics
|
|
13
|
+
- Errors encountered and learnings discovered
|
|
14
|
+
- Git commits associated with each iteration
|
|
15
|
+
|
|
16
|
+
**Guardrails**
|
|
17
|
+
- History is automatically recorded by Ralph during execution
|
|
18
|
+
- Read-only view - use to analyze and debug past iterations
|
|
19
|
+
- Useful for identifying patterns in failures or learning opportunities
|
|
20
|
+
- Each iteration is stored separately for audit trail
|
|
21
|
+
|
|
22
|
+
**Steps**
|
|
23
|
+
1. **View All Iterations**:
|
|
24
|
+
```bash
|
|
25
|
+
rulebook ralph history
|
|
26
|
+
```
|
|
27
|
+
Shows summary of all iterations with status and task info
|
|
28
|
+
|
|
29
|
+
2. **View Latest Iterations**:
|
|
30
|
+
```bash
|
|
31
|
+
rulebook ralph history --limit 5
|
|
32
|
+
```
|
|
33
|
+
Shows most recent N iterations (useful for large iteration counts)
|
|
34
|
+
|
|
35
|
+
3. **View Specific Iteration**:
|
|
36
|
+
```bash
|
|
37
|
+
rulebook ralph history --iteration 3
|
|
38
|
+
```
|
|
39
|
+
Shows detailed information for iteration 3
|
|
40
|
+
|
|
41
|
+
4. **Export History**:
|
|
42
|
+
```bash
|
|
43
|
+
rulebook ralph history --export history.json
|
|
44
|
+
```
|
|
45
|
+
Exports full iteration history for analysis
|
|
46
|
+
|
|
47
|
+
**Iteration Record Fields**
|
|
48
|
+
Each iteration record contains:
|
|
49
|
+
- **Metadata**:
|
|
50
|
+
- Iteration number
|
|
51
|
+
- Timestamp
|
|
52
|
+
- Task ID and title
|
|
53
|
+
- AI tool used
|
|
54
|
+
- Execution time (ms)
|
|
55
|
+
- Status: success / partial / failed
|
|
56
|
+
|
|
57
|
+
- **Quality Checks**:
|
|
58
|
+
- type-check: TypeScript compilation result
|
|
59
|
+
- lint: ESLint check result
|
|
60
|
+
- tests: Test suite result
|
|
61
|
+
- coverage_met: Coverage threshold result
|
|
62
|
+
|
|
63
|
+
- **Output**:
|
|
64
|
+
- output_summary: Summary of what was done
|
|
65
|
+
- learnings: Insights discovered during iteration
|
|
66
|
+
- errors: Any errors encountered
|
|
67
|
+
|
|
68
|
+
- **Git**:
|
|
69
|
+
- git_commit: Commit hash if changes were committed
|
|
70
|
+
- branch: Branch used for this iteration
|
|
71
|
+
|
|
72
|
+
**Analyzing History**
|
|
73
|
+
1. **Success Rate**:
|
|
74
|
+
```bash
|
|
75
|
+
# Successful iterations / total iterations
|
|
76
|
+
# Shows loop health and AI tool effectiveness
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
2. **Quality Gate Patterns**:
|
|
80
|
+
- Check which gates fail most often
|
|
81
|
+
- Identify systematic issues (e.g., always failing lint)
|
|
82
|
+
- Plan improvements based on failure patterns
|
|
83
|
+
|
|
84
|
+
3. **Learnings Extraction**:
|
|
85
|
+
- Ralph records lessons learned from each iteration
|
|
86
|
+
- Use these to improve task definitions or AI prompts
|
|
87
|
+
- Share with team for knowledge base
|
|
88
|
+
|
|
89
|
+
4. **Performance Metrics**:
|
|
90
|
+
- Track execution time per iteration
|
|
91
|
+
- Identify slow tasks or AI tools
|
|
92
|
+
- Optimize based on trends
|
|
93
|
+
|
|
94
|
+
**Location**
|
|
95
|
+
- Iteration records stored in: `.rulebook/ralph/history/`
|
|
96
|
+
- Each file named: `iteration-<N>.json`
|
|
97
|
+
- Full history also available in: `.rulebook/ralph/history-all.json`
|
|
98
|
+
|
|
99
|
+
**Using History for Debugging**
|
|
100
|
+
1. **Failed iteration**: Check error field for root cause
|
|
101
|
+
2. **Partial success**: Review which quality gates failed
|
|
102
|
+
3. **Slow iteration**: Check execution_time_ms
|
|
103
|
+
4. **Pattern analysis**: Compare multiple iterations for trends
|
|
104
|
+
|
|
105
|
+
**Next Steps**
|
|
106
|
+
- After reviewing history, fix issues and retry: `rulebook ralph run`
|
|
107
|
+
- Save learnings to persistent memory: `rulebook memory save "learning from iteration" ...`
|
|
108
|
+
- Update PRD based on discoveries from history analysis
|
|
109
|
+
|
|
110
|
+
<!-- RALPH:END -->
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: /ralph-init
|
|
3
|
+
id: ralph-init
|
|
4
|
+
category: Ralph
|
|
5
|
+
description: Initialize Ralph autonomous loop for AI-driven task completion in a project.
|
|
6
|
+
---
|
|
7
|
+
<!-- RALPH:START -->
|
|
8
|
+
**Overview**
|
|
9
|
+
Ralph is an autonomous AI loop that iteratively solves tasks from a PRD (Product Requirements Document). It runs your AI tool (Claude, Cursor, Gemini) in a continuous loop, tracks iterations, and learns from execution results.
|
|
10
|
+
|
|
11
|
+
**Guardrails**
|
|
12
|
+
- Always initialize Ralph before running iterations
|
|
13
|
+
- Use `rulebook ralph status` to check initialization and loop state
|
|
14
|
+
- Set appropriate max iterations (5-20 recommended for most projects)
|
|
15
|
+
- Keep the AI tool consistent across iterations for learning continuity
|
|
16
|
+
|
|
17
|
+
**Prerequisites**
|
|
18
|
+
- Project must be initialized with `rulebook init`
|
|
19
|
+
- Git repository must be set up with a remote origin
|
|
20
|
+
- Current branch will be used as the base for Ralph work
|
|
21
|
+
|
|
22
|
+
**Steps**
|
|
23
|
+
1. **Initialize Ralph**:
|
|
24
|
+
```bash
|
|
25
|
+
rulebook ralph init
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. **Interactive Setup**:
|
|
29
|
+
- Select max iterations (number of attempts to complete tasks)
|
|
30
|
+
- Choose AI tool: `claude` (recommended), `cursor`, or `gemini`
|
|
31
|
+
- Creates `.rulebook/ralph/` directory with configuration and PRD
|
|
32
|
+
|
|
33
|
+
3. **Verify Initialization**:
|
|
34
|
+
```bash
|
|
35
|
+
rulebook ralph status
|
|
36
|
+
```
|
|
37
|
+
Should show:
|
|
38
|
+
- `enabled: true`
|
|
39
|
+
- `current_iteration: 0`
|
|
40
|
+
- `max_iterations: <your choice>`
|
|
41
|
+
- `ai_tool: <your choice>`
|
|
42
|
+
|
|
43
|
+
4. **Review Generated PRD**:
|
|
44
|
+
- View `.rulebook/ralph/prd.json` for generated user stories
|
|
45
|
+
- Each story has: `id`, `title`, `description`, `acceptanceCriteria`, `priority`, `passes`, `notes`
|
|
46
|
+
- `passes: false` indicates pending stories
|
|
47
|
+
|
|
48
|
+
5. **Optional: Customize PRD**:
|
|
49
|
+
- Edit user stories directly in `prd.json`
|
|
50
|
+
- Adjust priorities, add acceptance criteria, refine descriptions
|
|
51
|
+
- Ralph will track which stories are completed (`passes: true`)
|
|
52
|
+
|
|
53
|
+
**Output**
|
|
54
|
+
Ralph creates:
|
|
55
|
+
- `.rulebook/ralph/prd.json` - The product requirements document
|
|
56
|
+
- `.rulebook/ralph/config.json` - Loop configuration (max_iterations, ai_tool)
|
|
57
|
+
- `.rulebook/ralph/history/` - Directory for iteration records
|
|
58
|
+
|
|
59
|
+
**Next Steps**
|
|
60
|
+
After initialization, use:
|
|
61
|
+
- `rulebook ralph run` - Start the autonomous loop
|
|
62
|
+
- `rulebook ralph pause` - Pause ongoing iterations
|
|
63
|
+
- `rulebook ralph resume` - Resume paused loop
|
|
64
|
+
- `rulebook ralph status` - Check current state
|
|
65
|
+
- `rulebook ralph history` - View past iterations
|
|
66
|
+
|
|
67
|
+
**Troubleshooting**
|
|
68
|
+
- **Init hangs**: Check git remote is properly configured (`git remote -v`)
|
|
69
|
+
- **PRD not generated**: Ensure project has valid task/context for Ralph to work with
|
|
70
|
+
- **Configuration lost**: Check `.rulebook/ralph/config.json` exists
|
|
71
|
+
|
|
72
|
+
<!-- RALPH:END -->
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: /ralph-pause-resume
|
|
3
|
+
id: ralph-pause-resume
|
|
4
|
+
category: Ralph
|
|
5
|
+
description: Pause and resume Ralph autonomous loop for manual intervention or debugging.
|
|
6
|
+
---
|
|
7
|
+
<!-- RALPH:START -->
|
|
8
|
+
**Overview**
|
|
9
|
+
Control Ralph's iteration loop by pausing and resuming execution:
|
|
10
|
+
- **Pause**: Stop after current iteration completes, allows manual inspection or fixes
|
|
11
|
+
- **Resume**: Continue from where paused, picking up with next incomplete story
|
|
12
|
+
|
|
13
|
+
**Guardrails**
|
|
14
|
+
- Pause completes current iteration before stopping (safe operation)
|
|
15
|
+
- Loop can only be resumed from paused state
|
|
16
|
+
- Use pause when: debugging failures, making manual fixes, investigating quality issues
|
|
17
|
+
- Keep pause duration short - long pauses may lose AI context
|
|
18
|
+
|
|
19
|
+
**Steps**
|
|
20
|
+
|
|
21
|
+
### Pausing the Loop
|
|
22
|
+
|
|
23
|
+
1. **Pause Ralph**:
|
|
24
|
+
```bash
|
|
25
|
+
rulebook ralph pause
|
|
26
|
+
```
|
|
27
|
+
- Completes current iteration
|
|
28
|
+
- Stops before next iteration starts
|
|
29
|
+
- Preserves all progress and iteration records
|
|
30
|
+
|
|
31
|
+
2. **Verify Paused State**:
|
|
32
|
+
```bash
|
|
33
|
+
rulebook ralph status
|
|
34
|
+
```
|
|
35
|
+
Should show: `Paused: true`
|
|
36
|
+
|
|
37
|
+
3. **Investigate Issues** (while paused):
|
|
38
|
+
- Review latest iteration: `rulebook ralph history --iteration <N>`
|
|
39
|
+
- Check quality gate failures: `rulebook ralph show <story-id>`
|
|
40
|
+
- Review error logs and learnings
|
|
41
|
+
- Make manual fixes to code if needed
|
|
42
|
+
|
|
43
|
+
### Resuming the Loop
|
|
44
|
+
|
|
45
|
+
1. **Resume Ralph**:
|
|
46
|
+
```bash
|
|
47
|
+
rulebook ralph resume
|
|
48
|
+
```
|
|
49
|
+
- Continues from where paused
|
|
50
|
+
- Picks up with next incomplete story
|
|
51
|
+
- Maintains iteration count and progress
|
|
52
|
+
|
|
53
|
+
2. **Verify Running State**:
|
|
54
|
+
```bash
|
|
55
|
+
rulebook ralph status
|
|
56
|
+
```
|
|
57
|
+
Should show: `Paused: false`
|
|
58
|
+
|
|
59
|
+
3. **Monitor Resumed Iterations**:
|
|
60
|
+
```bash
|
|
61
|
+
rulebook ralph history --limit 3
|
|
62
|
+
```
|
|
63
|
+
Check latest iterations to ensure resumption succeeded
|
|
64
|
+
|
|
65
|
+
**Common Workflows**
|
|
66
|
+
|
|
67
|
+
### Debugging Quality Gate Failures
|
|
68
|
+
1. Loop running, tests fail in iteration 5
|
|
69
|
+
2. `rulebook ralph pause` - stops after iteration 5
|
|
70
|
+
3. Analyze: `rulebook ralph history --iteration 5`
|
|
71
|
+
4. Identify test failure root cause
|
|
72
|
+
5. Make manual code fixes
|
|
73
|
+
6. `rulebook ralph resume` - continues from iteration 6
|
|
74
|
+
|
|
75
|
+
### Making Manual Adjustments
|
|
76
|
+
1. Pause loop: `rulebook ralph pause`
|
|
77
|
+
2. Manually edit code based on iteration learnings
|
|
78
|
+
3. Update PRD: `vi .rulebook/ralph/prd.json`
|
|
79
|
+
4. Resume: `rulebook ralph resume` - continues with updated PRD
|
|
80
|
+
|
|
81
|
+
### Inspecting AI Tool Output
|
|
82
|
+
1. Pause: `rulebook ralph pause`
|
|
83
|
+
2. Check `rulebook ralph history --iteration <N>` for AI output
|
|
84
|
+
3. Review learnings and errors from iteration
|
|
85
|
+
4. Resume: `rulebook ralph resume`
|
|
86
|
+
|
|
87
|
+
**Pause vs Stopping**
|
|
88
|
+
- **Pause** (`ralph pause`): Loop continues later with resume
|
|
89
|
+
- **Stop** (Ctrl+C during run): Stops immediately, may interrupt current iteration
|
|
90
|
+
- Use pause for graceful, resumable stops
|
|
91
|
+
- Use Ctrl+C only for emergency stops
|
|
92
|
+
|
|
93
|
+
**State Preservation**
|
|
94
|
+
When paused:
|
|
95
|
+
- Current iteration status saved
|
|
96
|
+
- User story states preserved
|
|
97
|
+
- Learnings and errors recorded
|
|
98
|
+
- Loop progress not lost
|
|
99
|
+
|
|
100
|
+
**Edge Cases**
|
|
101
|
+
- **Can't pause if not running**: Check with `ralph status`
|
|
102
|
+
- **Can't resume if not paused**: Call `ralph run` instead
|
|
103
|
+
- **Resuming after long pause**: Ralph retains context up to max iterations allowed
|
|
104
|
+
|
|
105
|
+
<!-- RALPH:END -->
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: /ralph-run
|
|
3
|
+
id: ralph-run
|
|
4
|
+
category: Ralph
|
|
5
|
+
description: Start Ralph autonomous loop to iteratively complete tasks from the PRD.
|
|
6
|
+
---
|
|
7
|
+
<!-- RALPH:START -->
|
|
8
|
+
**Overview**
|
|
9
|
+
Ralph runs your configured AI tool in a continuous loop, solving user stories from the PRD one at a time. Each iteration:
|
|
10
|
+
1. Picks the next incomplete user story
|
|
11
|
+
2. Invokes your AI tool (Claude, Cursor, or Gemini) to solve it
|
|
12
|
+
3. Parses the output for quality checks and completion status
|
|
13
|
+
4. Records the iteration results
|
|
14
|
+
5. Marks the story as complete if all quality gates pass
|
|
15
|
+
6. Moves to the next story or stops if max iterations reached
|
|
16
|
+
|
|
17
|
+
**Guardrails**
|
|
18
|
+
- Ralph must be initialized first with `rulebook ralph init`
|
|
19
|
+
- Quality gates MUST pass: type-check, lint, tests, coverage
|
|
20
|
+
- Failed iterations are recorded but don't auto-mark stories complete
|
|
21
|
+
- Monitor logs and iteration history for quality issues
|
|
22
|
+
|
|
23
|
+
**Prerequisites**
|
|
24
|
+
- Ralph initialized with `rulebook ralph init`
|
|
25
|
+
- All quality gate tools installed: TypeScript, ESLint, test framework, coverage reporter
|
|
26
|
+
- `.rulebook/ralph/prd.json` exists with user stories
|
|
27
|
+
|
|
28
|
+
**Steps**
|
|
29
|
+
1. **Start the Loop**:
|
|
30
|
+
```bash
|
|
31
|
+
rulebook ralph run
|
|
32
|
+
```
|
|
33
|
+
Ralph will:
|
|
34
|
+
- Load configuration and PRD
|
|
35
|
+
- Find first incomplete story (`passes: false`)
|
|
36
|
+
- Invoke your AI tool
|
|
37
|
+
- Parse output for task completion and quality checks
|
|
38
|
+
|
|
39
|
+
2. **Monitor Execution**:
|
|
40
|
+
- Watch the console for iteration progress
|
|
41
|
+
- Each iteration shows: story ID, title, execution time, quality gate results
|
|
42
|
+
- Ralph will pause on quality gate failures for review
|
|
43
|
+
|
|
44
|
+
3. **Review Iteration Results**:
|
|
45
|
+
```bash
|
|
46
|
+
rulebook ralph history
|
|
47
|
+
```
|
|
48
|
+
Shows:
|
|
49
|
+
- Iteration number
|
|
50
|
+
- Task ID and title
|
|
51
|
+
- Success/partial/failed status
|
|
52
|
+
- Quality check results (type-check, lint, tests, coverage)
|
|
53
|
+
- Execution time
|
|
54
|
+
- Errors and learnings
|
|
55
|
+
|
|
56
|
+
4. **Check Status**:
|
|
57
|
+
```bash
|
|
58
|
+
rulebook ralph status
|
|
59
|
+
```
|
|
60
|
+
Shows:
|
|
61
|
+
- Current iteration count
|
|
62
|
+
- Pending user stories count
|
|
63
|
+
- Completion percentage
|
|
64
|
+
- Paused state (if paused)
|
|
65
|
+
|
|
66
|
+
**Iteration Lifecycle**
|
|
67
|
+
1. **Iteration Start**: Ralph picks next incomplete story
|
|
68
|
+
2. **AI Tool Execution**: Runs your configured tool (Claude/Cursor/Gemini)
|
|
69
|
+
3. **Output Parsing**: Extracts quality checks, errors, completion indicators
|
|
70
|
+
4. **Quality Gates**:
|
|
71
|
+
- type-check ✓ - TypeScript compilation succeeds
|
|
72
|
+
- lint ✓ - ESLint passes without errors
|
|
73
|
+
- tests ✓ - All test suites pass
|
|
74
|
+
- coverage ✓ - Coverage meets thresholds
|
|
75
|
+
5. **Story Completion**: If all gates pass, marks `passes: true`
|
|
76
|
+
6. **Next Iteration**: Moves to next story or completes loop
|
|
77
|
+
|
|
78
|
+
**Quality Gate Failures**
|
|
79
|
+
If gates fail:
|
|
80
|
+
- Status recorded as `partial` or `failed`
|
|
81
|
+
- Story remains `passes: false` for retry
|
|
82
|
+
- Error details saved in iteration history
|
|
83
|
+
- Manual review and fixes may be needed before retry
|
|
84
|
+
|
|
85
|
+
**Pausing and Resuming**
|
|
86
|
+
- `rulebook ralph pause` - Pause after current iteration
|
|
87
|
+
- `rulebook ralph resume` - Continue from where paused
|
|
88
|
+
- Useful for investigating failures or making manual adjustments
|
|
89
|
+
|
|
90
|
+
**Iteration Records**
|
|
91
|
+
Each iteration is recorded in:
|
|
92
|
+
- `.rulebook/ralph/history/iteration-<N>.json` with full details
|
|
93
|
+
- Includes: task details, quality checks, errors, learnings, git commit
|
|
94
|
+
|
|
95
|
+
**Troubleshooting**
|
|
96
|
+
- **Loop stops early**: Check quality gate failures in latest iteration
|
|
97
|
+
- **AI tool not found**: Ensure `rulebook ralph config set ai-tool <tool>` is set correctly
|
|
98
|
+
- **Infinite loops**: Use `rulebook ralph pause` and check loop configuration
|
|
99
|
+
- **Context loss**: Ralph tracks context loss and reports it in iteration metadata
|
|
100
|
+
|
|
101
|
+
<!-- RALPH:END -->
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: /ralph-status
|
|
3
|
+
id: ralph-status
|
|
4
|
+
category: Ralph
|
|
5
|
+
description: Check the status of Ralph autonomous loop and view task completion statistics.
|
|
6
|
+
---
|
|
7
|
+
<!-- RALPH:START -->
|
|
8
|
+
**Overview**
|
|
9
|
+
View the current state of Ralph's autonomous loop, including:
|
|
10
|
+
- Loop enabled/disabled status
|
|
11
|
+
- Current iteration count and max iterations
|
|
12
|
+
- Paused/running state
|
|
13
|
+
- User story completion statistics
|
|
14
|
+
- Overall project progress
|
|
15
|
+
|
|
16
|
+
**Guardrails**
|
|
17
|
+
- Status shows real-time state from `.rulebook/ralph/config.json` and `prd.json`
|
|
18
|
+
- Use status regularly to monitor loop health
|
|
19
|
+
- Paused state prevents iterations from continuing (must resume to continue)
|
|
20
|
+
|
|
21
|
+
**Steps**
|
|
22
|
+
1. **Check Ralph Status**:
|
|
23
|
+
```bash
|
|
24
|
+
rulebook ralph status
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. **Interpret Output**:
|
|
28
|
+
```
|
|
29
|
+
Ralph Status:
|
|
30
|
+
├─ Enabled: true
|
|
31
|
+
├─ Current Iteration: 3
|
|
32
|
+
├─ Max Iterations: 10
|
|
33
|
+
├─ AI Tool: claude
|
|
34
|
+
├─ Paused: false
|
|
35
|
+
├─ Task Statistics:
|
|
36
|
+
│ ├─ Total Stories: 5
|
|
37
|
+
│ ├─ Completed: 2
|
|
38
|
+
│ ├─ Pending: 3
|
|
39
|
+
│ └─ Completion: 40%
|
|
40
|
+
└─ Branch: ralph/my-project
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
3. **Status Fields**:
|
|
44
|
+
- **Enabled**: Whether Ralph loop is active
|
|
45
|
+
- **Current Iteration**: Which iteration loop is on (0 = not started)
|
|
46
|
+
- **Max Iterations**: Total iterations allowed before stopping
|
|
47
|
+
- **AI Tool**: Which AI tool is being used (claude, cursor, gemini)
|
|
48
|
+
- **Paused**: Whether loop is paused (must resume to continue)
|
|
49
|
+
- **Task Statistics**: User story completion breakdown
|
|
50
|
+
- **Branch**: Git branch Ralph is working on
|
|
51
|
+
|
|
52
|
+
4. **Check Completion**:
|
|
53
|
+
```bash
|
|
54
|
+
# View detailed task statistics
|
|
55
|
+
rulebook ralph status --detailed
|
|
56
|
+
```
|
|
57
|
+
Shows individual user story status and completion breakdown
|
|
58
|
+
|
|
59
|
+
**Common Patterns**
|
|
60
|
+
- **Just initialized**: `Current Iteration: 0`, `Pending: <all stories>`
|
|
61
|
+
- **In progress**: `Current Iteration: N` increasing, `Pending` decreasing
|
|
62
|
+
- **Complete**: `Current Iteration` matches total completed stories, `Pending: 0`
|
|
63
|
+
- **Paused**: `Paused: true`, resume with `rulebook ralph resume`
|
|
64
|
+
|
|
65
|
+
**Next Steps**
|
|
66
|
+
- If loop not started: `rulebook ralph run`
|
|
67
|
+
- If paused: `rulebook ralph resume`
|
|
68
|
+
- To view iterations: `rulebook ralph history`
|
|
69
|
+
- To view story details: `rulebook ralph show <story-id>` (if available)
|
|
70
|
+
|
|
71
|
+
**Troubleshooting**
|
|
72
|
+
- **Status shows disabled**: Run `rulebook ralph init` to enable
|
|
73
|
+
- **Iteration count stuck**: Check if loop is paused or if max iterations reached
|
|
74
|
+
- **Statistics don't match**: Check `.rulebook/ralph/prd.json` for consistency
|
|
75
|
+
|
|
76
|
+
<!-- RALPH:END -->
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: /rulebook-memory-save
|
|
3
|
+
id: rulebook-memory-save
|
|
4
|
+
category: Rulebook
|
|
5
|
+
description: Save a new persistent memory for context across AI sessions.
|
|
6
|
+
---
|
|
7
|
+
<!-- RULEBOOK:START -->
|
|
8
|
+
**Guardrails**
|
|
9
|
+
- Use the MCP memory tools when available (preferred over CLI commands).
|
|
10
|
+
- Choose the correct memory type for accurate classification and search.
|
|
11
|
+
- Keep titles concise and content descriptive.
|
|
12
|
+
- Use tags for better discoverability.
|
|
13
|
+
|
|
14
|
+
**Steps**
|
|
15
|
+
1. **Save a memory** using the MCP tool or CLI:
|
|
16
|
+
```
|
|
17
|
+
# Via MCP (preferred)
|
|
18
|
+
rulebook_memory_save({
|
|
19
|
+
type: "feature",
|
|
20
|
+
title: "Short descriptive title",
|
|
21
|
+
content: "Detailed description of what happened, why, and context",
|
|
22
|
+
tags: ["relevant", "tags"]
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
# Via CLI
|
|
26
|
+
rulebook memory save "content text" --type feature --title "Title" --tags tag1,tag2
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. **Choose the right type**:
|
|
30
|
+
- `bugfix` - Fixed a bug or resolved an error
|
|
31
|
+
- `feature` - Added new functionality
|
|
32
|
+
- `refactor` - Restructured code without changing behavior
|
|
33
|
+
- `decision` - Made an architecture or design choice (protected from eviction)
|
|
34
|
+
- `discovery` - Found something important about the codebase
|
|
35
|
+
- `change` - General code modification
|
|
36
|
+
- `observation` - Noted something worth remembering
|
|
37
|
+
|
|
38
|
+
3. **Verify** the memory was saved:
|
|
39
|
+
```
|
|
40
|
+
rulebook_memory_search({ query: "your title keywords" })
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Best Practices**
|
|
44
|
+
- Save decisions early - they are protected from cache eviction
|
|
45
|
+
- Include "why" in content, not just "what"
|
|
46
|
+
- Use consistent tags across related memories
|
|
47
|
+
- Content within `<private>...</private>` tags will be automatically redacted
|
|
48
|
+
<!-- RULEBOOK:END -->
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: /rulebook-memory-search
|
|
3
|
+
id: rulebook-memory-search
|
|
4
|
+
category: Rulebook
|
|
5
|
+
description: Search persistent memories using hybrid BM25+vector search for context across sessions.
|
|
6
|
+
---
|
|
7
|
+
<!-- RULEBOOK:START -->
|
|
8
|
+
**Guardrails**
|
|
9
|
+
- Use the MCP memory tools when available (preferred over CLI commands).
|
|
10
|
+
- The memory system uses 3-layer search: Layer 1 (compact search), Layer 2 (timeline), Layer 3 (full details).
|
|
11
|
+
- Always start with a broad search, then narrow down with timeline and full details.
|
|
12
|
+
|
|
13
|
+
**Steps**
|
|
14
|
+
1. **Search memories** using the MCP tool or CLI:
|
|
15
|
+
```
|
|
16
|
+
# Via MCP (preferred)
|
|
17
|
+
rulebook_memory_search({ query: "search terms", mode: "hybrid", limit: 20 })
|
|
18
|
+
|
|
19
|
+
# Via CLI
|
|
20
|
+
rulebook memory search "search terms" --mode hybrid --limit 20
|
|
21
|
+
```
|
|
22
|
+
Modes: `hybrid` (default, best results), `bm25` (keyword only), `vector` (semantic only).
|
|
23
|
+
|
|
24
|
+
2. **Get timeline context** around a relevant result:
|
|
25
|
+
```
|
|
26
|
+
rulebook_memory_timeline({ memoryId: "<id>", window: 5 })
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
3. **Get full details** for specific memories:
|
|
30
|
+
```
|
|
31
|
+
rulebook_memory_get({ ids: ["<id1>", "<id2>"] })
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Memory Types**
|
|
35
|
+
- `bugfix` - Bug fixes and error resolutions
|
|
36
|
+
- `feature` - New features and capabilities
|
|
37
|
+
- `refactor` - Code restructuring
|
|
38
|
+
- `decision` - Architecture/design decisions (protected from eviction)
|
|
39
|
+
- `discovery` - Findings about codebase or tools
|
|
40
|
+
- `change` - General code changes
|
|
41
|
+
- `observation` - General observations
|
|
42
|
+
|
|
43
|
+
**Reference**
|
|
44
|
+
- Use `rulebook memory stats` to check database health
|
|
45
|
+
- Decisions are never evicted during cleanup
|
|
46
|
+
- Privacy: content within `<private>...</private>` tags is automatically redacted
|
|
47
|
+
<!-- RULEBOOK:END -->
|