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

Commit 9465153

Browse files
Merge pull request #7 from PromptExecution/fix/agent-required
fix: unify entrypoint, remove ralph_cli drift
2 parents f4b2b73 + 84b0d28 commit 9465153

23 files changed

Lines changed: 2158 additions & 1297 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ __pycache__/
4242

4343
# UV/temporary artifacts
4444
=3.0.0b1
45+
.uv-cache/

OPERATIONS.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Ralph Operations
2+
3+
This repo implements the Ralph loop runner. Ralph runs an agent repeatedly until it emits the completion signal:
4+
5+
`<promise>COMPLETE</promise>`
6+
7+
Ralph is intentionally context-scoped: each iteration is a fresh agent invocation. Long-term memory MUST live in repo state (git history, `progress.txt`, and TaskMaster tasks).
8+
9+
## Prereqs
10+
11+
- `uv` installed
12+
- One agent CLI installed/authenticated:
13+
- `amp`
14+
- `claude`
15+
- `codex`
16+
- A git repo (Ralph resolves the project root by walking up to `.git`)
17+
18+
## Tasks (TaskMaster)
19+
20+
Ralph uses TaskMaster tasks stored at:
21+
22+
`.taskmaster/tasks/tasks.json`
23+
24+
If `tasks.json` is missing/empty/invalid, `./ralph.sh` exits early and prints a copy/paste prompt to generate tasks (nothing runs until tasks exist).
25+
26+
Schema reference:
27+
28+
`schemas/taskmaster-schema.json`
29+
30+
### Generating Tasks (Recommended)
31+
32+
Run your designated agent and instruct it to use the `prd` skill to produce TaskMaster-format tasks at:
33+
34+
`.taskmaster/tasks/tasks.json`
35+
36+
Requirements for generated tasks:
37+
38+
- MUST be TaskMaster format with `tasks[]` and `metadata`
39+
- MUST include 3-7 small tasks with verifiable acceptance criteria
40+
- MUST use IETF 2119 language (MUST/SHOULD/MAY) in acceptance criteria
41+
- MUST set `metadata.project` and `metadata.branchName`
42+
43+
## Running Ralph (CLI)
44+
45+
Preferred (uses the packaged entrypoint):
46+
47+
```bash
48+
uv run ralph --agent codex 3
49+
uv run ralph --agent amp 10
50+
uv run ralph --agent claude 5
51+
```
52+
53+
Wrapper (runs preflight + delegates to `uv run ralph ...`):
54+
55+
```bash
56+
./ralph.sh --agent codex 3
57+
```
58+
59+
Script entrypoint (equivalent behavior):
60+
61+
```bash
62+
uv run --script ralphython.py --agent codex 3
63+
```
64+
65+
Notes:
66+
- `--agent` is required (unless using `--mcp`)
67+
- default iterations is 10
68+
69+
## Running Ralph (MCP Server)
70+
71+
stdio:
72+
73+
```bash
74+
uv run ralph --mcp --transport stdio
75+
```
76+
77+
http:
78+
79+
```bash
80+
uv run ralph --mcp --transport http --host 127.0.0.1 --port 8000
81+
```
82+
83+
MCP tools/resources (current):
84+
- Tools: `run_ralph_iteration`, `get_ralph_status`, `get_task_status`
85+
- Resources: `ralph://tasks`, `ralph://progress`
86+
87+
## Configuration
88+
89+
TaskMaster model (written to `.taskmaster/config.json` by `ralph.sh`):
90+
91+
- `RALPH_TASKMASTER_MODEL` (default: `gpt-5-codex`)
92+
93+
Codex:
94+
- `CODEX_MODEL`
95+
- `CODEX_REASONING_EFFORT`
96+
- `CODEX_SANDBOX`
97+
- `CODEX_EXTRA_ARGS`
98+
99+
## Sandboxed Environments
100+
101+
`ralph.sh` sets a repo-local uv cache by default:
102+
103+
- `UV_CACHE_DIR=$GIT_ROOT/.uv-cache`
104+
105+
If your environment needs a different location, set `UV_CACHE_DIR` explicitly.
106+

README-MCP.md

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,4 @@
1-
# Ralph MCP Integration 🚀
1+
# Ralph MCP
22

3-
Ralph now supports **FastMCP 3.0** with both server and client capabilities!
4-
5-
## Features
6-
7-
### MCP Server Mode
8-
Ralph exposes its autonomous agent capabilities as an MCP server with:
9-
10-
**Tools:**
11-
- `run_ralph_iteration(agent, max_iterations, prd_path)` - Run Ralph for N iterations
12-
- `get_ralph_status()` - Get current execution status from progress.txt
13-
- `get_prd_status(prd_path)` - Get PRD completion metrics
14-
15-
**Resources:**
16-
- `ralph://prd` - Current PRD JSON content
17-
- `ralph://progress` - Current progress.txt log
18-
19-
### Usage
20-
21-
**As CLI (default):**
22-
```bash
23-
./ralph.sh --agent codex 3
24-
# or
25-
uv run --script ralphython.py --agent codex 3
26-
```
27-
28-
**As MCP Server (HTTP):**
29-
```bash
30-
uv run --script ralphython.py --mcp --transport http --port 8000
31-
```
32-
33-
**As MCP Server (stdio):**
34-
```bash
35-
uv run --script ralphython.py --mcp --transport stdio
36-
```
37-
38-
### Client Example
39-
```python
40-
import asyncio
41-
from fastmcp import Client
42-
43-
async def check_ralph():
44-
async with Client("http://localhost:8000/mcp") as client:
45-
# Get PRD status
46-
status = await client.call_tool("get_prd_status", {})
47-
print(f"Completed: {status['completed_stories']}/{status['total_stories']}")
48-
49-
# Run Ralph for 1 iteration
50-
result = await client.call_tool("run_ralph_iteration", {
51-
"agent": "codex",
52-
"max_iterations": 1
53-
})
54-
print(f"Exit code: {result['exit_code']}")
55-
56-
asyncio.run(check_ralph())
57-
```
58-
59-
### MCP Client Config
60-
Add to your MCP client settings (e.g., Claude Desktop):
61-
62-
```json
63-
{
64-
"mcpServers": {
65-
"ralph": {
66-
"command": "uv",
67-
"args": ["run", "--script", "/path/to/ralphython.py", "--mcp"]
68-
}
69-
}
70-
}
71-
```
72-
73-
## Implementation Details
74-
75-
- FastMCP 3.0.0b1 (beta)
76-
- PEP 723 inline script dependencies
77-
- Supports both CLI and MCP modes via `--mcp` flag
78-
- Model: gpt-5.2-codex (configurable via `CODEX_MODEL` env var)
3+
MCP usage is documented in `OPERATIONS.md`.
794

0 commit comments

Comments
 (0)