ralph-py-cli 0.3.2__tar.gz
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.
- ralph_py_cli-0.3.2/.gitignore +209 -0
- ralph_py_cli-0.3.2/CLAUDE.md +66 -0
- ralph_py_cli-0.3.2/LICENSE +21 -0
- ralph_py_cli-0.3.2/PKG-INFO +206 -0
- ralph_py_cli-0.3.2/README.md +177 -0
- ralph_py_cli-0.3.2/example_plans/numbers.md +1 -0
- ralph_py_cli-0.3.2/example_plans/numbers_change.md +1 -0
- ralph_py_cli-0.3.2/install.sh +3 -0
- ralph_py_cli-0.3.2/pyproject.toml +60 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/__init__.py +1 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/cli.py +395 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/__init__.py +22 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/agent_runner.py +221 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/agents/__init__.py +5 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/agents/base.py +78 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/agents/claude.py +142 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/agents/opencode.py +186 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/claude_runner.py +169 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/interactive.py +353 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/ralph_plan_helper.py +249 -0
- ralph_py_cli-0.3.2/src/ralph_py_cli/utils/token_usage.py +154 -0
- ralph_py_cli-0.3.2/tests/__init__.py +1 -0
- ralph_py_cli-0.3.2/tests/conftest.py +9 -0
- ralph_py_cli-0.3.2/tests/test_runner_integration.py +315 -0
- ralph_py_cli-0.3.2/tests/test_token_usage.py +255 -0
- ralph_py_cli-0.3.2/uv.lock +669 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
sandbox/
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
ralph-py-cli is a CLI tool for running Claude Code iteratively. It provides two main commands:
|
|
8
|
+
|
|
9
|
+
1. **`ralph run`** - Run Claude Code iteratively on a project
|
|
10
|
+
- Specify target folder and a plan (inline or from file)
|
|
11
|
+
- Set maximum number of iterations
|
|
12
|
+
- Execute Claude Code N times in sequence (a "Ralph loop")
|
|
13
|
+
- Interactive prompts between iterations to modify plan or continue
|
|
14
|
+
- Token usage tracking with tier-based rate limit percentages
|
|
15
|
+
|
|
16
|
+
2. **`ralph plan`** - Improve a plan for optimal iterative execution
|
|
17
|
+
- Restructures plans into small, atomic steps
|
|
18
|
+
- Orders steps by dependencies
|
|
19
|
+
- Makes each step independently completable
|
|
20
|
+
|
|
21
|
+
The core concept is automating repeated Claude Code runs against a codebase with a design document guiding each iteration.
|
|
22
|
+
|
|
23
|
+
## Development Setup
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Install UV and Claude Code CLI
|
|
27
|
+
./install.sh
|
|
28
|
+
|
|
29
|
+
# Run tests
|
|
30
|
+
uv run pytest tests/ -v
|
|
31
|
+
|
|
32
|
+
# Run the CLI
|
|
33
|
+
uv run ralph --help
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Tech Stack
|
|
37
|
+
|
|
38
|
+
- **Language:** Python
|
|
39
|
+
- **Package Manager:** UV (astral.sh/uv)
|
|
40
|
+
- **CLI Framework:** Typer
|
|
41
|
+
- **Output Formatting:** Rich
|
|
42
|
+
|
|
43
|
+
## Project Structure
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
ralph-py-cli/
|
|
47
|
+
├── src/ralph_py_cli/
|
|
48
|
+
│ ├── cli.py # Main CLI entry point (typer commands)
|
|
49
|
+
│ └── utils/
|
|
50
|
+
│ ├── claude_runner.py # Claude Code subprocess execution
|
|
51
|
+
│ ├── interactive.py # Interactive prompts between iterations
|
|
52
|
+
│ ├── ralph_plan_helper.py # Plan improvement logic
|
|
53
|
+
│ └── token_usage.py # Token tracking and tier percentages
|
|
54
|
+
├── tests/
|
|
55
|
+
│ ├── test_runner_integration.py # Claude runner tests
|
|
56
|
+
│ └── test_token_usage.py # Token usage tests
|
|
57
|
+
├── example_plans/ # Sample plan files
|
|
58
|
+
├── pyproject.toml # Project config and dependencies
|
|
59
|
+
└── install.sh # Setup script
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Key Concepts
|
|
63
|
+
|
|
64
|
+
- **Iteration markers**: Claude Code outputs `<Improved>...</Improved>` when making progress or `<Completed>...</Completed>` when fully done
|
|
65
|
+
- **Token tracking**: Tracks input/output tokens per iteration and shows usage against Pro, Max 5x, and Max 20x tier limits
|
|
66
|
+
- **Interactive mode**: Between iterations, users can modify the plan, change iteration count, or skip future prompts
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ryan Wiley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ralph-py-cli
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: A CLI application for running Claude Code iteratively on design documents
|
|
5
|
+
Project-URL: Homepage, https://github.com/rdubwiley09/ralph-py-cli
|
|
6
|
+
Project-URL: Repository, https://github.com/rdubwiley09/ralph-py-cli
|
|
7
|
+
Project-URL: Issues, https://github.com/rdubwiley09/ralph-py-cli/issues
|
|
8
|
+
Author: Ryan Wiley
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,automation,claude,cli,textual,tui
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: pandas>=2.3.3
|
|
25
|
+
Requires-Dist: playwright>=1.57.0
|
|
26
|
+
Requires-Dist: textual>=0.50.0
|
|
27
|
+
Requires-Dist: typer>=0.12.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# ralph-py-cli
|
|
31
|
+
|
|
32
|
+
## Note: this is a cli that allows one to run claude code in yolo mode for a given number of iterations. Use caution and other best practices when going degen mode.
|
|
33
|
+
|
|
34
|
+
A CLI tool for running Claude Code iteratively on a project until completion.
|
|
35
|
+
|
|
36
|
+
## What is a Ralph Loop?
|
|
37
|
+
|
|
38
|
+
A Ralph loop automates repeated Claude Code runs against a codebase. Instead of running Claude Code once and manually re-running it to continue work, Ralph handles the iteration automatically.
|
|
39
|
+
|
|
40
|
+
Each iteration:
|
|
41
|
+
1. Sends your plan/design document to Claude Code
|
|
42
|
+
2. Claude works on the task and reports progress
|
|
43
|
+
3. If the task isn't complete, Ralph starts another iteration
|
|
44
|
+
4. Continues until the task is done, an error occurs, or max iterations reached
|
|
45
|
+
|
|
46
|
+
This is useful for larger tasks that require multiple Claude Code sessions to complete.
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Install via pip
|
|
52
|
+
pip install ralph-py-cli
|
|
53
|
+
|
|
54
|
+
# Or install via uv
|
|
55
|
+
uv add ralph-py-cli
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Available Agents
|
|
59
|
+
|
|
60
|
+
Ralph supports multiple AI coding agents:
|
|
61
|
+
|
|
62
|
+
- **claude** (default) - Uses Claude Code CLI for code generation and iteration
|
|
63
|
+
- **opencode** - Uses OpenCode CLI as an alternative agent (requires OpenCode to be installed)
|
|
64
|
+
|
|
65
|
+
Both agents support the same Ralph loop workflow with iterative execution and interactive controls.
|
|
66
|
+
|
|
67
|
+
### Agent-Specific Notes
|
|
68
|
+
|
|
69
|
+
**OpenCode:**
|
|
70
|
+
- Default model: `opencode/glm-4.7-free` (if no model is specified)
|
|
71
|
+
- Requires OpenCode CLI to be installed and available in your PATH
|
|
72
|
+
- Use `--model` to specify a different OpenCode model
|
|
73
|
+
|
|
74
|
+
## CLI Usage
|
|
75
|
+
|
|
76
|
+
Ralph provides two commands: `run` and `plan`.
|
|
77
|
+
|
|
78
|
+
### Running the Loop
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Run with inline plan
|
|
82
|
+
ralph run ./my-project --plan "Build a REST API with user authentication" --iterations 5
|
|
83
|
+
|
|
84
|
+
# Run with plan from file
|
|
85
|
+
ralph run ./my-project --plan-file design.md --iterations 10
|
|
86
|
+
|
|
87
|
+
# With options
|
|
88
|
+
ralph run ./my-project \
|
|
89
|
+
--plan-file design.md \
|
|
90
|
+
--iterations 10 \
|
|
91
|
+
--timeout 600 \
|
|
92
|
+
--model claude-sonnet-4-20250514 \
|
|
93
|
+
--verbose
|
|
94
|
+
|
|
95
|
+
# Using OpenCode agent (alternative to Claude Code)
|
|
96
|
+
ralph run ./my-project \
|
|
97
|
+
--plan-file design.md \
|
|
98
|
+
--iterations 10 \
|
|
99
|
+
--agent opencode
|
|
100
|
+
|
|
101
|
+
# Using OpenCode with custom model
|
|
102
|
+
ralph run ./my-project \
|
|
103
|
+
--plan "Build a REST API" \
|
|
104
|
+
--iterations 5 \
|
|
105
|
+
--agent opencode \
|
|
106
|
+
--model opencode/glm-4.7-free
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Options:**
|
|
110
|
+
- `--plan, -p` - Plan text describing what to build
|
|
111
|
+
- `--plan-file, -f` - Read plan from a file
|
|
112
|
+
- `--iterations, -n` - Maximum iterations to run (required)
|
|
113
|
+
- `--timeout, -t` - Timeout per iteration in seconds (default: 300)
|
|
114
|
+
- `--agent, -a` - Agent to use: `claude` or `opencode` (default: claude)
|
|
115
|
+
- `--model, -m` - Model override for the agent
|
|
116
|
+
- `--verbose, -v` - Show detailed output
|
|
117
|
+
- `--interactive/--no-interactive` - Enable/disable prompts between iterations (default: enabled)
|
|
118
|
+
|
|
119
|
+
**Exit codes:**
|
|
120
|
+
- `0` - Task completed successfully
|
|
121
|
+
- `1` - Error occurred (timeout, process error, etc.)
|
|
122
|
+
- `2` - Max iterations reached without completion
|
|
123
|
+
|
|
124
|
+
### Improving a Plan
|
|
125
|
+
|
|
126
|
+
The `plan` command restructures your plan into small, atomic steps optimized for iterative execution:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Improve a plan from text
|
|
130
|
+
ralph plan --plan "Build a web app with login, dashboard, and settings pages"
|
|
131
|
+
|
|
132
|
+
# Improve a plan from file
|
|
133
|
+
ralph plan --plan-file rough-ideas.md
|
|
134
|
+
|
|
135
|
+
# Save improved plan to file
|
|
136
|
+
ralph plan --plan-file rough-ideas.md --output optimized-plan.md
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Options:**
|
|
140
|
+
- `--plan, -p` - Plan text to improve
|
|
141
|
+
- `--plan-file, -f` - Read plan from a file
|
|
142
|
+
- `--output, -o` - Write improved plan to file
|
|
143
|
+
- `--timeout, -t` - Timeout in seconds (default: 120)
|
|
144
|
+
- `--agent, -a` - Agent to use: `claude` or `opencode` (default: claude)
|
|
145
|
+
- `--model, -m` - Model override for the agent
|
|
146
|
+
- `--verbose, -v` - Show detailed output
|
|
147
|
+
|
|
148
|
+
## Example Workflow
|
|
149
|
+
|
|
150
|
+
1. Write a rough plan for what you want to build
|
|
151
|
+
2. Use `ralph plan` to optimize it for iterative execution
|
|
152
|
+
3. Use `ralph run` to execute the plan iteratively
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Start with a rough idea
|
|
156
|
+
echo "Build a CLI todo app with add, list, and delete commands" > plan.txt
|
|
157
|
+
|
|
158
|
+
# Optimize for iterative execution
|
|
159
|
+
ralph plan --plan-file plan.txt --output optimized-plan.txt
|
|
160
|
+
|
|
161
|
+
# Run the loop
|
|
162
|
+
ralph run ./todo-project --plan-file optimized-plan.txt --iterations 5
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Interactive Loop Menu
|
|
166
|
+
|
|
167
|
+
When running in an interactive terminal, Ralph pauses between iterations to let you control the loop. This gives you the opportunity to review progress and make adjustments.
|
|
168
|
+
|
|
169
|
+
### Main Menu
|
|
170
|
+
|
|
171
|
+
After each iteration, you'll see:
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
What would you like to do next?
|
|
175
|
+
[1] Continue to next iteration
|
|
176
|
+
[2] Edit loop settings
|
|
177
|
+
[3] Skip future prompts (auto-continue)
|
|
178
|
+
[4] Cancel
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- **Continue** - Proceed to the next iteration with current settings
|
|
182
|
+
- **Edit** - Open the edit menu to change plan or iterations
|
|
183
|
+
- **Skip** - Disable prompts and auto-continue for remaining iterations
|
|
184
|
+
- **Cancel** - Stop the loop immediately
|
|
185
|
+
|
|
186
|
+
### Edit Menu
|
|
187
|
+
|
|
188
|
+
When you select "Edit loop settings", you can make multiple changes before continuing:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
=== Edit Loop Settings ===
|
|
192
|
+
Current plan: <first 100 chars of plan>...
|
|
193
|
+
Remaining iterations: X
|
|
194
|
+
|
|
195
|
+
[1] Change plan (enter text)
|
|
196
|
+
[2] Change plan (load from file)
|
|
197
|
+
[3] Change iteration count
|
|
198
|
+
[4] Confirm and continue
|
|
199
|
+
[5] Cancel (discard changes)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
- **Change plan (text)** - Enter new plan text directly
|
|
203
|
+
- **Change plan (file)** - Load plan from a file path
|
|
204
|
+
- **Change iteration count** - Set remaining iterations
|
|
205
|
+
- **Confirm** - Apply changes and continue to next iteration
|
|
206
|
+
- **Cancel** - Discard all changes and return to main menu
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# ralph-py-cli
|
|
2
|
+
|
|
3
|
+
## Note: this is a cli that allows one to run claude code in yolo mode for a given number of iterations. Use caution and other best practices when going degen mode.
|
|
4
|
+
|
|
5
|
+
A CLI tool for running Claude Code iteratively on a project until completion.
|
|
6
|
+
|
|
7
|
+
## What is a Ralph Loop?
|
|
8
|
+
|
|
9
|
+
A Ralph loop automates repeated Claude Code runs against a codebase. Instead of running Claude Code once and manually re-running it to continue work, Ralph handles the iteration automatically.
|
|
10
|
+
|
|
11
|
+
Each iteration:
|
|
12
|
+
1. Sends your plan/design document to Claude Code
|
|
13
|
+
2. Claude works on the task and reports progress
|
|
14
|
+
3. If the task isn't complete, Ralph starts another iteration
|
|
15
|
+
4. Continues until the task is done, an error occurs, or max iterations reached
|
|
16
|
+
|
|
17
|
+
This is useful for larger tasks that require multiple Claude Code sessions to complete.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install via pip
|
|
23
|
+
pip install ralph-py-cli
|
|
24
|
+
|
|
25
|
+
# Or install via uv
|
|
26
|
+
uv add ralph-py-cli
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Available Agents
|
|
30
|
+
|
|
31
|
+
Ralph supports multiple AI coding agents:
|
|
32
|
+
|
|
33
|
+
- **claude** (default) - Uses Claude Code CLI for code generation and iteration
|
|
34
|
+
- **opencode** - Uses OpenCode CLI as an alternative agent (requires OpenCode to be installed)
|
|
35
|
+
|
|
36
|
+
Both agents support the same Ralph loop workflow with iterative execution and interactive controls.
|
|
37
|
+
|
|
38
|
+
### Agent-Specific Notes
|
|
39
|
+
|
|
40
|
+
**OpenCode:**
|
|
41
|
+
- Default model: `opencode/glm-4.7-free` (if no model is specified)
|
|
42
|
+
- Requires OpenCode CLI to be installed and available in your PATH
|
|
43
|
+
- Use `--model` to specify a different OpenCode model
|
|
44
|
+
|
|
45
|
+
## CLI Usage
|
|
46
|
+
|
|
47
|
+
Ralph provides two commands: `run` and `plan`.
|
|
48
|
+
|
|
49
|
+
### Running the Loop
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Run with inline plan
|
|
53
|
+
ralph run ./my-project --plan "Build a REST API with user authentication" --iterations 5
|
|
54
|
+
|
|
55
|
+
# Run with plan from file
|
|
56
|
+
ralph run ./my-project --plan-file design.md --iterations 10
|
|
57
|
+
|
|
58
|
+
# With options
|
|
59
|
+
ralph run ./my-project \
|
|
60
|
+
--plan-file design.md \
|
|
61
|
+
--iterations 10 \
|
|
62
|
+
--timeout 600 \
|
|
63
|
+
--model claude-sonnet-4-20250514 \
|
|
64
|
+
--verbose
|
|
65
|
+
|
|
66
|
+
# Using OpenCode agent (alternative to Claude Code)
|
|
67
|
+
ralph run ./my-project \
|
|
68
|
+
--plan-file design.md \
|
|
69
|
+
--iterations 10 \
|
|
70
|
+
--agent opencode
|
|
71
|
+
|
|
72
|
+
# Using OpenCode with custom model
|
|
73
|
+
ralph run ./my-project \
|
|
74
|
+
--plan "Build a REST API" \
|
|
75
|
+
--iterations 5 \
|
|
76
|
+
--agent opencode \
|
|
77
|
+
--model opencode/glm-4.7-free
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Options:**
|
|
81
|
+
- `--plan, -p` - Plan text describing what to build
|
|
82
|
+
- `--plan-file, -f` - Read plan from a file
|
|
83
|
+
- `--iterations, -n` - Maximum iterations to run (required)
|
|
84
|
+
- `--timeout, -t` - Timeout per iteration in seconds (default: 300)
|
|
85
|
+
- `--agent, -a` - Agent to use: `claude` or `opencode` (default: claude)
|
|
86
|
+
- `--model, -m` - Model override for the agent
|
|
87
|
+
- `--verbose, -v` - Show detailed output
|
|
88
|
+
- `--interactive/--no-interactive` - Enable/disable prompts between iterations (default: enabled)
|
|
89
|
+
|
|
90
|
+
**Exit codes:**
|
|
91
|
+
- `0` - Task completed successfully
|
|
92
|
+
- `1` - Error occurred (timeout, process error, etc.)
|
|
93
|
+
- `2` - Max iterations reached without completion
|
|
94
|
+
|
|
95
|
+
### Improving a Plan
|
|
96
|
+
|
|
97
|
+
The `plan` command restructures your plan into small, atomic steps optimized for iterative execution:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Improve a plan from text
|
|
101
|
+
ralph plan --plan "Build a web app with login, dashboard, and settings pages"
|
|
102
|
+
|
|
103
|
+
# Improve a plan from file
|
|
104
|
+
ralph plan --plan-file rough-ideas.md
|
|
105
|
+
|
|
106
|
+
# Save improved plan to file
|
|
107
|
+
ralph plan --plan-file rough-ideas.md --output optimized-plan.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Options:**
|
|
111
|
+
- `--plan, -p` - Plan text to improve
|
|
112
|
+
- `--plan-file, -f` - Read plan from a file
|
|
113
|
+
- `--output, -o` - Write improved plan to file
|
|
114
|
+
- `--timeout, -t` - Timeout in seconds (default: 120)
|
|
115
|
+
- `--agent, -a` - Agent to use: `claude` or `opencode` (default: claude)
|
|
116
|
+
- `--model, -m` - Model override for the agent
|
|
117
|
+
- `--verbose, -v` - Show detailed output
|
|
118
|
+
|
|
119
|
+
## Example Workflow
|
|
120
|
+
|
|
121
|
+
1. Write a rough plan for what you want to build
|
|
122
|
+
2. Use `ralph plan` to optimize it for iterative execution
|
|
123
|
+
3. Use `ralph run` to execute the plan iteratively
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Start with a rough idea
|
|
127
|
+
echo "Build a CLI todo app with add, list, and delete commands" > plan.txt
|
|
128
|
+
|
|
129
|
+
# Optimize for iterative execution
|
|
130
|
+
ralph plan --plan-file plan.txt --output optimized-plan.txt
|
|
131
|
+
|
|
132
|
+
# Run the loop
|
|
133
|
+
ralph run ./todo-project --plan-file optimized-plan.txt --iterations 5
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Interactive Loop Menu
|
|
137
|
+
|
|
138
|
+
When running in an interactive terminal, Ralph pauses between iterations to let you control the loop. This gives you the opportunity to review progress and make adjustments.
|
|
139
|
+
|
|
140
|
+
### Main Menu
|
|
141
|
+
|
|
142
|
+
After each iteration, you'll see:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
What would you like to do next?
|
|
146
|
+
[1] Continue to next iteration
|
|
147
|
+
[2] Edit loop settings
|
|
148
|
+
[3] Skip future prompts (auto-continue)
|
|
149
|
+
[4] Cancel
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
- **Continue** - Proceed to the next iteration with current settings
|
|
153
|
+
- **Edit** - Open the edit menu to change plan or iterations
|
|
154
|
+
- **Skip** - Disable prompts and auto-continue for remaining iterations
|
|
155
|
+
- **Cancel** - Stop the loop immediately
|
|
156
|
+
|
|
157
|
+
### Edit Menu
|
|
158
|
+
|
|
159
|
+
When you select "Edit loop settings", you can make multiple changes before continuing:
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
=== Edit Loop Settings ===
|
|
163
|
+
Current plan: <first 100 chars of plan>...
|
|
164
|
+
Remaining iterations: X
|
|
165
|
+
|
|
166
|
+
[1] Change plan (enter text)
|
|
167
|
+
[2] Change plan (load from file)
|
|
168
|
+
[3] Change iteration count
|
|
169
|
+
[4] Confirm and continue
|
|
170
|
+
[5] Cancel (discard changes)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
- **Change plan (text)** - Enter new plan text directly
|
|
174
|
+
- **Change plan (file)** - Load plan from a file path
|
|
175
|
+
- **Change iteration count** - Set remaining iterations
|
|
176
|
+
- **Confirm** - Apply changes and continue to next iteration
|
|
177
|
+
- **Cancel** - Discard all changes and return to main menu
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
If a file named numbers.txt doesn't exist create it. Then put one number between 1 and 5 in it. You are only allowed to put one number in at a time for each iteration. You will be complete when there are five numbers in this file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
If a file named numbers.txt doesn't exist create it. Then put one number between 5 and 10 in it. You are only allowed to put one number in at a time for each iteration. You will be complete when there are five numbers in this file
|