Skip to content
This repository was archived by the owner on Mar 21, 2026. It is now read-only.

Commit f4b2b73

Browse files
Merge pull request #6 from PromptExecution/ralph/taskmaster-integration
TaskMaster Integration: Story-Based Task Management
2 parents 8b368fa + 3d093d5 commit f4b2b73

37 files changed

Lines changed: 3945 additions & 216 deletions

.github/workflows/python-ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Ralph Python CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- ralph/python-rewrite
8+
pull_request:
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
quality-checks:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Install uv with Python 3.11
22+
uses: astral-sh/setup-uv@v3
23+
with:
24+
python-version: "3.11"
25+
26+
- name: Synchronize dependencies
27+
run: uv sync --frozen --dev
28+
29+
- name: Run ruff
30+
run: uv run ruff check ralph
31+
32+
- name: Run mypy --strict
33+
run: uv run python -m mypy --strict ralph
34+
35+
- name: Run pytest with coverage
36+
run: uv run python -m pytest --cov=ralph --cov-report=term-missing --cov-report=xml
37+
38+
- name: Upload coverage report
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: coverage-xml
42+
path: coverage.xml
43+
if-no-files-found: error

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ prd.json
33
progress.txt
44
.last-branch
55

6+
# TaskMaster-AI task storage (managed by taskmaster-ai, not Ralph)
7+
.taskmaster/
8+
tasks.json
9+
610
# Archive is optional to commit
711
# archive/
812

@@ -12,6 +16,19 @@ progress.txt
1216
#Claude
1317
.claude/
1418

19+
# Python
20+
__pycache__/
21+
*.py[cod]
22+
*$py.class
23+
*.so
24+
.Python
25+
.venv
26+
.pytest_cache/
27+
.coverage
28+
htmlcov/
29+
*.egg-info/
30+
dist/
31+
build/
1532
# Python caches
1633
__pycache__/
1734
*.pyc

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ npm run dev
4545
- Memory persists via git history, `progress.txt`, and `prd.json`
4646
- Stories should be small enough to complete in one context window
4747
- Always update AGENTS.md with discovered patterns for future iterations
48-
- `mypy` and `ruff` are not yet available via `uv run` until Python tooling is configured (see US-007)
48+
- For uv-managed tooling, prefer `uv run python -m <tool>` (e.g., mypy, pytest) so commands use the project `.venv` and find dev dependencies

CLAUDE.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@
22

33
You are an autonomous coding agent working on a software project.
44

5+
## Understanding Stories vs Tasks
6+
7+
**IMPORTANT**: Each item in `tasks.json` should be written as a **user story** with rich context, not a bare task instruction. Stories provide narrative context that produces better results:
8+
9+
-**Good (Story)**: "As a developer using Ralph, I need the CLI to support OpenCode as a fourth executor option, so that I can leverage OpenCode's capabilities alongside amp/claude/codex. The implementation should follow the same pattern as existing executors, using the _TeeToStderr pattern for output capture and integrating with the config system."
10+
11+
-**Bad (Task)**: "Add OpenCode executor"
12+
13+
Stories answer: **Who** needs it, **what** they need, **why** they need it, and **how** it should work. This context helps you understand the full picture and make better implementation decisions.
14+
515
## Your Task
616

7-
1. Read the PRD at `prd.json` (in the same directory as this file)
17+
1. Read the story list at `tasks.json` (in the same directory as this file)
18+
- Each "task" entry should be written as a user story with context
819
2. Read the progress log at `progress.txt` (check Codebase Patterns section first)
9-
3. Check you're on the correct branch from PRD `branchName`. If not, check it out or create from main.
10-
4. Pick the **highest priority** user story where `passes: false`
11-
5. Implement that single user story
12-
6. Run quality checks (e.g., typecheck, lint, test - use whatever your project requires)
13-
7. Update CLAUDE.md files if you discover reusable patterns (see below)
14-
8. If checks pass, commit ALL changes with message: `feat: [Story ID] - [Story Title]`
15-
9. Update the PRD to set `passes: true` for the completed story
16-
10. Append your progress to `progress.txt`
20+
3. Check you're on the correct branch from tasks.json `metadata.branchName`. If not, check it out or create from main.
21+
4. Pick the **highest priority** story where `status: "pending"` and not blocked (empty `blockedBy` array)
22+
5. Set story status to `"in-progress"` before starting work
23+
6. Implement that single story, using the contextual information provided
24+
7. Run quality checks (e.g., typecheck, lint, test - use whatever your project requires)
25+
8. Update CLAUDE.md files if you discover reusable patterns (see below)
26+
9. If checks pass, commit ALL changes with message: `feat: [Story ID] - [Story Title]`
27+
10. Update the story status to `"done"` for the completed story
28+
11. Append your progress to `progress.txt`
1729

1830
## Progress Report Format
1931

@@ -89,12 +101,23 @@ If no browser tools are available, note in your progress report that manual brow
89101

90102
## Stop Condition
91103

92-
After completing a user story, check if ALL stories have `passes: true`.
104+
After completing a story, check if ALL stories have `status: "done"`.
93105

94-
If ALL stories are complete and passing, reply with:
106+
If ALL stories are complete, reply with:
95107
<promise>COMPLETE</promise>
96108

97-
If there are still stories with `passes: false`, end your response normally (another iteration will pick up the next story).
109+
If there are still stories with `status: "pending"` or `status: "in-progress"`, end your response normally (another iteration will pick up the next story).
110+
111+
## Writing New Stories
112+
113+
When creating new stories in tasks.json, always write them with full narrative context:
114+
- **As a** [role/persona]
115+
- **I need** [capability/feature]
116+
- **So that** [business value/outcome]
117+
- **Implementation approach**: [technical context, patterns to follow, constraints]
118+
- **Acceptance criteria**: [specific, testable conditions]
119+
120+
This story format provides the cognitive context needed for high-quality autonomous implementation.
98121

99122
## Important
100123

README.md

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22

33
![Ralph](ralph.webp)
44

5-
Ralph is an autonomous AI agent loop that runs AI coding tools ([Amp](https://ampcode.com) or [Claude Code](https://docs.anthropic.com/en/docs/claude-code)) repeatedly until all PRD items are complete. Each iteration is a fresh instance with clean context. Memory persists via git history, `progress.txt`, and `prd.json`.
5+
[![Ralph Python CI](https://github.com/promptexecution/b00t-wiggums/actions/workflows/python-ci.yml/badge.svg?branch=ralph/python-rewrite)](https://github.com/promptexecution/b00t-wiggums/actions/workflows/python-ci.yml)
6+
7+
Ralph is an autonomous AI agent loop that runs AI coding tools ([Amp](https://ampcode.com), [Claude Code](https://docs.anthropic.com/en/docs/claude-code), or [Codex](https://codex.anthropic.com)) repeatedly until all PRD items are complete. Each iteration is a fresh instance with clean context. Memory persists via git history, `progress.txt`, and `prd.json`.
8+
9+
**Python Rewrite**: Ralph has been rewritten in Python for improved maintainability, testability, and type safety. See [ralph/README.md](ralph/README.md) for Python-specific documentation.
610

711
Based on [Geoffrey Huntley's Ralph pattern](https://ghuntley.com/ralph/).
812

913
[Read my in-depth article on how I use Ralph](https://x.com/ryancarson/status/2008548371712135632)
1014

1115
## Prerequisites
1216

17+
- Python 3.11+ with [uv](https://github.com/astral-sh/uv) package manager installed
1318
- One of the following AI coding tools installed and authenticated:
1419
- [Amp CLI](https://ampcode.com)
1520
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (`npm install -g @anthropic-ai/claude-code`)
16-
- `jq` installed (`brew install jq` on macOS)
21+
- [Codex](https://codex.anthropic.com)
1722
- A git repository for your project
1823

1924
## Setup
@@ -109,15 +114,35 @@ This creates `prd.json` with user stories structured for autonomous execution.
109114

110115
### 3. Run Ralph
111116

117+
**Python Version (Recommended)**:
118+
119+
```bash
120+
# Using Amp (default)
121+
uv run ralph [max_iterations]
122+
123+
# Using Claude Code
124+
uv run ralph --tool claude [max_iterations]
125+
126+
# Using Codex
127+
uv run ralph --tool codex [max_iterations]
128+
129+
# Or use justfile commands
130+
just ralph # Run with amp (default)
131+
just ralph-claude # Run with claude
132+
just ralph-codex # Run with codex
133+
```
134+
135+
**Bash Version (Deprecated)**:
136+
112137
```bash
113-
# Using Amp
114-
./scripts/ralph/ralph.sh [max_iterations]
138+
# Using Amp (default)
139+
./ralph.sh [max_iterations]
115140

116141
# Using Claude Code
117-
./scripts/ralph/ralph.sh --agent claude [max_iterations]
142+
./ralph.sh --tool claude [max_iterations]
118143
```
119144

120-
Default is 10 iterations. Use `--agent amp`, `--agent claude`, or `--agent codex` to select your AI coding tool.
145+
Default is 10 iterations. Use `--tool amp`, `--tool claude`, or `--tool codex` to select your AI coding tool.
121146

122147
Ralph will:
123148
1. Create a feature branch (from PRD `branchName`)
@@ -151,12 +176,15 @@ or Codex so you can validate behavior locally before handing off to agents.
151176

152177
| File | Purpose |
153178
|------|---------|
154-
| `ralph.sh` | The bash loop that spawns fresh AI instances (supports `--agent amp`, `--agent claude`, or `--agent codex`) |
179+
| `ralph/` | Python implementation of Ralph (recommended) |
180+
| `ralph/README.md` | Detailed Python documentation |
181+
| `ralph.sh` | Bash wrapper (delegates to Python version) |
155182
| `prompt.md` | Prompt template for Amp |
156-
| `CLAUDE.md` | Prompt template for Claude Code |
183+
| `CLAUDE.md` | Prompt template for Claude Code and Codex |
157184
| `prd.json` | User stories with `passes` status (the task list) |
158185
| `prd.json.example` | Example PRD format for reference |
159186
| `progress.txt` | Append-only learnings for future iterations |
187+
| `justfile` | Just commands for Ralph (ralph, ralph-test, ralph-check, etc.) |
160188
| `skills/prd/` | Skill for generating PRDs (works with Amp and Claude Code) |
161189
| `skills/ralph/` | Skill for converting PRDs to JSON (works with Amp and Claude Code) |
162190
| `.claude-plugin/` | Plugin manifest for Claude Code marketplace discovery |
@@ -250,6 +278,52 @@ After copying `prompt.md` (for Amp) or `CLAUDE.md` (for Claude Code) to your pro
250278

251279
Ralph automatically archives previous runs when you start a new feature (different `branchName`). Archives are saved to `archive/YYYY-MM-DD-feature-name/`.
252280

281+
## Migration from Bash to Python
282+
283+
The Python version of Ralph maintains the same behavior as the bash version while adding benefits:
284+
285+
### What's the Same
286+
- Same command-line interface (just `--agent``--tool`)
287+
- Same file structure (`prd.json`, `progress.txt`)
288+
- Same workflow (iterations, completion signal, archival)
289+
- Same tool support (amp, claude, codex)
290+
291+
### What's Better
292+
- **Type Safety**: Full mypy strict mode type checking
293+
- **Testing**: 92% code coverage with unit and integration tests
294+
- **Error Handling**: Proper exception handling with returns Result types
295+
- **Maintainability**: Modular architecture with clear separation of concerns
296+
- **Development Tools**: justfile commands, ruff linting, comprehensive documentation
297+
298+
### Migration Steps
299+
300+
1. **Install uv** (if not already installed):
301+
```bash
302+
curl -LsSf https://astral.sh/uv/install.sh | sh
303+
```
304+
305+
2. **Test the Python version**:
306+
```bash
307+
uv run ralph --help
308+
```
309+
310+
3. **Update your workflow**:
311+
- Replace `./ralph.sh` with `uv run ralph` or `just ralph`
312+
- Update CI/CD scripts if needed
313+
- Note: `ralph.sh` still works (delegates to Python version)
314+
315+
4. **Customize configuration** (optional):
316+
- Set environment variables for codex (see [ralph/README.md](ralph/README.md))
317+
- Update `CLAUDE.md` or `prompt.md` for your project
318+
319+
### Breaking Changes
320+
321+
- CLI flag: `--agent``--tool`
322+
- Python 3.11+ required (was: bash)
323+
- `uv` package manager required (was: none)
324+
325+
See [ralph/README.md](ralph/README.md) for complete Python documentation.
326+
253327
## References
254328

255329
- [Geoffrey Huntley's Ralph article](https://ghuntley.com/ralph/)

justfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Ralph Python CLI justfile commands
2+
3+
# Run ralph with specified tool and iterations (default: amp, 10 iterations)
4+
ralph TOOL='amp' ITERATIONS='10':
5+
uv run ralph --tool {{TOOL}} {{ITERATIONS}}
6+
7+
# Run ralph tests
8+
ralph-test:
9+
uv run pytest tests/test_ralph*
10+
11+
# Type check and lint ralph module
12+
ralph-check:
13+
uv run mypy ralph/ && uv run ruff check ralph/
14+
15+
# Format ralph code with ruff
16+
ralph-format:
17+
uv run ruff format ralph/
18+
19+
# Run all quality checks (format, lint, type check, test)
20+
ralph-all: ralph-format ralph-check ralph-test
21+
@echo "✅ All quality checks passed!"
22+
23+
# Run ralph with amp tool
24+
ralph-amp ITERATIONS='10':
25+
uv run ralph --tool amp {{ITERATIONS}}
26+
27+
# Run ralph with claude tool
28+
ralph-claude ITERATIONS='10':
29+
uv run ralph --tool claude {{ITERATIONS}}
30+
31+
# Run ralph with codex tool
32+
ralph-codex ITERATIONS='10':
33+
uv run ralph --tool codex {{ITERATIONS}}

0 commit comments

Comments
 (0)