Skip to content

Commit dec6b59

Browse files
authored
Merge pull request #39 from computerlovetech/claude/research-ralphs-directory-YsZ7w
2 parents f30de9d + 882f340 commit dec6b59

File tree

23 files changed

+111
-1588
lines changed

23 files changed

+111
-1588
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ ralph_logs/
1111
node_modules/
1212
.playwright-cli/
1313
mess/
14-
.ralphify/
14+
.agents/
1515
.DS_Store
1616
.coverage

AGENTS.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ uv run mkdocs serve # Preview docs at http://127.0.0.1:8000
2121
All source code is in `src/ralphify/`. The main file is `cli.py` — it contains the CLI commands and delegates to the engine for the core loop.
2222

2323
Key modules:
24-
- `cli.py` — CLI commands (`run`, `new`, `init`); delegates to `_console_emitter.py` for terminal event rendering
24+
- `cli.py` — CLI commands (`run`, `scaffold`); delegates to `_console_emitter.py` for terminal event rendering
2525
- `engine.py` — Core run loop orchestration with structured event emission
2626
- `manager.py` — Multi-run orchestration (concurrent runs via threads)
2727
- `_frontmatter.py` — YAML frontmatter parsing (uses PyYAML) and the `RALPH_MARKER` constant
@@ -33,15 +33,12 @@ Key modules:
3333
- `_console_emitter.py` — Rich terminal rendering of events
3434
- `_output.py``ProcessResult` base class, combine stdout+stderr, format durations
3535
- `_brand.py` — Brand color constants shared across CLI and console rendering
36-
- `_source.py` — GitHub source parsing and git-based ralph fetching for `ralph add`
37-
- `_skills.py` — Skill installation, agent detection, and command building for `ralph new`
38-
- `skills/new-ralph/SKILL.md` — AI-guided ralph creation skill (bundled, installed into agent skill dir)
3936

4037
Tests are in `tests/` with one file per module. Docs are in `docs/` using MkDocs with Material theme.
4138

4239
## Core concepts
4340

44-
A **ralph** is a directory containing a `RALPH.md` file. That's it. No project-level config, no `.ralphify/` directory, no `ralph init`.
41+
A **ralph** is a directory containing a `RALPH.md` file. That's it. No project-level config, no special directories.
4542

4643
**RALPH.md** has YAML frontmatter + a prompt body:
4744
- `agent` (required) — the agent command to run
@@ -60,14 +57,12 @@ A **ralph** is a directory containing a `RALPH.md` file. That's it. No project-l
6057
- `docs/` (MkDocs) — user-facing docs: CLI reference, quick reference, writing prompts guide, cookbook. Only include what's relevant for users.
6158
- `docs/contributing/` — contributor/agent docs: codebase map, architecture. Only include what's relevant for contributors and coding agents.
6259
- `README.md` — keep short and high-level. Update only when the change affects the quickstart, install, or core concepts.
63-
- `src/ralphify/skills/new-ralph/SKILL.md` — the skill that powers `ralph new`. Update when new frontmatter fields or features are added.
6460
- `CHANGELOG.md` — add an entry for every release.
6561

6662
## Boundaries
6763

6864
### Always Do
6965
- Run `uv run pytest` and `uv run ruff check .` before committing
70-
- Save all skills in `skills/` directory (not `.claude/skills/` which is gitignored)
7166

7267
## Traps
7368

CLAUDE.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ uv run mkdocs serve # Preview docs at http://127.0.0.1:8000
2121
All source code is in `src/ralphify/`. The main file is `cli.py` — it contains the CLI commands and delegates to the engine for the core loop.
2222

2323
Key modules:
24-
- `cli.py` — CLI commands (`run`, `new`, `init`); delegates to `_console_emitter.py` for terminal event rendering
24+
- `cli.py` — CLI commands (`run`, `scaffold`); delegates to `_console_emitter.py` for terminal event rendering
2525
- `engine.py` — Core run loop orchestration with structured event emission
2626
- `manager.py` — Multi-run orchestration (concurrent runs via threads)
2727
- `_frontmatter.py` — YAML frontmatter parsing (uses PyYAML) and the `RALPH_MARKER` constant
@@ -33,15 +33,12 @@ Key modules:
3333
- `_console_emitter.py` — Rich terminal rendering of events
3434
- `_output.py``ProcessResult` base class, combine stdout+stderr, format durations
3535
- `_brand.py` — Brand color constants shared across CLI and console rendering
36-
- `_source.py` — GitHub source parsing and git-based ralph fetching for `ralph add`
37-
- `_skills.py` — Skill installation, agent detection, and command building for `ralph new`
38-
- `skills/new-ralph/SKILL.md` — AI-guided ralph creation skill (bundled, installed into agent skill dir)
3936

4037
Tests are in `tests/` with one file per module. Docs are in `docs/` using MkDocs with Material theme.
4138

4239
## Core concepts
4340

44-
A **ralph** is a directory containing a `RALPH.md` file. That's it. No project-level config, no `.ralphify/` directory, no `ralph init`.
41+
A **ralph** is a directory containing a `RALPH.md` file. That's it. No project-level config, no special directories.
4542

4643
**RALPH.md** has YAML frontmatter + a prompt body:
4744
- `agent` (required) — the agent command to run
@@ -60,14 +57,12 @@ A **ralph** is a directory containing a `RALPH.md` file. That's it. No project-l
6057
- `docs/` (MkDocs) — user-facing docs: CLI reference, quick reference, writing prompts guide, cookbook. Only include what's relevant for users.
6158
- `docs/contributing/` — contributor/agent docs: codebase map, architecture. Only include what's relevant for contributors and coding agents.
6259
- `README.md` — keep short and high-level. Update only when the change affects the quickstart, install, or core concepts.
63-
- `src/ralphify/skills/new-ralph/SKILL.md` — the skill that powers `ralph new`. Update when new frontmatter fields or features are added.
6460
- `CHANGELOG.md` — add an entry for every release.
6561

6662
## Boundaries
6763

6864
### Always Do
6965
- Run `uv run pytest` and `uv run ruff check .` before committing
70-
- Save all skills in `skills/` directory (not `.claude/skills/` which is gitignored)
7166

7267
## Traps
7368

README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Any of these gives you the `ralph` command.
3939
A ralph is a directory with a `RALPH.md` file. Scaffold one:
4040

4141
```bash
42-
ralph init my-ralph
42+
ralph scaffold my-ralph
4343
```
4444

4545
Then edit `my-ralph/RALPH.md`:
@@ -140,22 +140,16 @@ my-ralph/
140140

141141
**No project-level configuration.** No `ralph.toml`. No config files. A ralph is fully self-contained.
142142

143-
## AI-guided setup
144-
145-
```bash
146-
ralph new my-task
147-
```
148-
149-
Launches an interactive agent conversation to scaffold a new ralph with the right commands and prompt for your project.
150-
151143
## Install ralphs from GitHub
152144

145+
Use [agr](https://github.com/computerlovetech/agr) to install shared ralphs:
146+
153147
```bash
154-
ralph add owner/repo # Install all ralphs from a repo
155-
ralph add owner/repo/my-ralph # Install a specific ralph by name
148+
agr add owner/repo/my-ralph # Install a ralph from GitHub
149+
ralph run my-ralph # Run it by name
156150
```
157151

158-
Installs ralphs to `.ralphify/ralphs/` so you can run them by name with `ralph run`.
152+
Ralphs installed by agr go to `.agents/ralphs/` and are automatically discovered by `ralph run`.
159153

160154
## Documentation
161155

docs/agents.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ This page shows how to configure the [`agent` frontmatter field](quick-reference
1515

1616
## Agent comparison
1717

18-
| Agent | Stdin support | Streaming | `ralph new` support | Wrapper needed |
19-
|---|---|---|---|---|
20-
| [Claude Code](#claude-code) | Native (`-p`) | Yes — real-time activity tracking | Yes | No |
21-
| [Aider](#aider) | Via bash wrapper | No | No | Yes (`bash -c`) |
22-
| [Codex CLI](#codex-cli) | Native (`exec`) | No | Yes | No |
23-
| [Custom](#custom-wrapper-script) | You implement it | No | No | Yes (script) |
18+
| Agent | Stdin support | Streaming | Wrapper needed |
19+
|---|---|---|---|
20+
| [Claude Code](#claude-code) | Native (`-p`) | Yes — real-time activity tracking | No |
21+
| [Aider](#aider) | Via bash wrapper | No | Yes (`bash -c`) |
22+
| [Codex CLI](#codex-cli) | Native (`exec`) | No | No |
23+
| [Custom](#custom-wrapper-script) | You implement it | No | Yes (script) |
2424

2525
If you're not sure which to pick: **start with Claude Code.** It has the deepest integration, the best autonomous coding capabilities, and is the default.
2626

docs/blog/posts/the-ralph-standard.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ ralph run ./ralphs/bug-hunter
150150

151151
Declare `args: [focus]` and you get `--focus` on the CLI. The value fills `{{ args.focus }}` in the prompt. One ralph, many use cases.
152152

153-
Because ralphs are just directories in a git repo, anyone can share them. If a repo contains a directory with a `RALPH.md`, you can install it with `ralph add`:
153+
Because ralphs are just directories in a git repo, anyone can share them. If a repo contains a directory with a `RALPH.md`, you can install it with [agr](https://github.com/computerlovetech/agr):
154154

155155
```bash
156156
# install a specific ralph from any GitHub repo
157-
ralph add owner/repo/ralph-name
157+
agr add owner/repo/ralph-name
158158

159159
# install all ralphs in a repo
160-
ralph add owner/repo
160+
agr add owner/repo
161161
```
162162

163163
The [ralphify examples](https://github.com/computerlovetech/ralphify/tree/main/examples) are a good place to start — and the [cookbook](https://ralphify.co/docs/cookbook/) has more.

docs/cli.md

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
title: "CLI Reference: Run AI Coding Agents in Autonomous Loops"
3-
description: "Complete CLI reference for the ralph command — run autonomous AI coding loops, scaffold new agent prompts, install shared ralphs from GitHub, and configure RALPH.md frontmatter options."
4-
keywords: run AI agent in loop CLI, autonomous coding agent command line, ralph run command, ralph init, ralph add GitHub, RALPH.md frontmatter format, AI coding loop options, agent timeout iterations, user arguments CLI, ralphify CLI reference
3+
description: "Complete CLI reference for the ralph command — run autonomous AI coding loops, scaffold new agent prompts, and configure RALPH.md frontmatter options."
4+
keywords: run AI agent in loop CLI, autonomous coding agent command line, ralph run command, ralph scaffold, RALPH.md frontmatter format, AI coding loop options, agent timeout iterations, user arguments CLI, ralphify CLI reference
55
---
66

77
# CLI Reference
88

99
!!! tldr "TL;DR"
10-
**`ralph run <path> -n 5`** runs the loop. **`ralph init <name>`** scaffolds a ralph from a template. **`ralph new`** creates one with AI guidance. **`ralph add owner/repo`** installs from GitHub. Pass user args as `--name value` flags. Everything is configured in a single [`RALPH.md`](#ralphmd-format) file with YAML frontmatter.
10+
**`ralph run <path> -n 5`** runs the loop. **`ralph scaffold <name>`** creates a ralph from a template. Pass user args as `--name value` flags. Everything is configured in a single [`RALPH.md`](#ralphmd-format) file with YAML frontmatter.
1111

1212
## `ralph`
1313

@@ -52,7 +52,7 @@ ralph run my-ralph --dir ./src # Pass user args to the ralph
5252

5353
| Argument / Option | Short | Default | Description |
5454
|---|---|---|---|
55-
| `PATH` | | (required) | Path to a ralph directory containing `RALPH.md`, a direct path to a `RALPH.md` file, or the name of an installed ralph (from `ralph add`) |
55+
| `PATH` | | (required) | Path to a ralph directory containing `RALPH.md`, a direct path to a `RALPH.md` file, or the name of an installed ralph in `.agents/ralphs/` |
5656
| `-n` | | unlimited | Max number of iterations |
5757
| `--stop-on-error` | `-s` | off | Stop loop if agent exits non-zero or times out |
5858
| `--delay` | `-d` | `0` | Seconds to wait between iterations |
@@ -116,13 +116,13 @@ The loop also stops automatically when:
116116

117117
---
118118

119-
## `ralph init`
119+
## `ralph scaffold`
120120

121-
Scaffold a new ralph with a ready-to-customize template. No AI agent required. For a guided setup, see [`ralph new`](#ralph-new) instead.
121+
Scaffold a new ralph with a ready-to-customize template.
122122

123123
```bash
124-
ralph init my-task # Creates my-task/RALPH.md with a generic template
125-
ralph init # Creates RALPH.md in the current directory
124+
ralph scaffold my-task # Creates my-task/RALPH.md with a generic template
125+
ralph scaffold # Creates RALPH.md in the current directory
126126
```
127127

128128
| Argument | Default | Description |
@@ -135,52 +135,6 @@ Errors if `RALPH.md` already exists at the target location.
135135

136136
---
137137

138-
## `ralph new`
139-
140-
Create a new ralph with AI-guided setup. Launches an interactive session where the agent guides you through creating a complete ralph via conversation.
141-
142-
```bash
143-
ralph new # Agent helps you choose a name and build everything
144-
ralph new my-task # Start with a name already chosen
145-
```
146-
147-
| Argument | Default | Description |
148-
|---|---|---|
149-
| `[NAME]` | none | Name for the new ralph. If omitted, the agent will help you choose |
150-
151-
The command detects your [agent](agents.md) and installs a skill to guide the creation process.
152-
153-
---
154-
155-
## `ralph add`
156-
157-
Add a ralph from a GitHub repository. Installs it to `.ralphify/ralphs/<name>/` so you can run it by name.
158-
159-
```bash
160-
ralph add owner/repo # Install all ralphs in the repo
161-
ralph add owner/repo/ralph-name # Specific ralph by name
162-
ralph add https://github.com/owner/repo # Full GitHub URL
163-
ralph add https://github.com/owner/repo/tree/main/my-ralph # URL copied from GitHub browser
164-
```
165-
166-
| Argument | Default | Description |
167-
|---|---|---|
168-
| `SOURCE` | required | GitHub source — shorthand (`owner/repo`), subpath (`owner/repo/path`), or full GitHub URL |
169-
170-
**How it resolves:**
171-
172-
- `owner/repo` — if the repo root contains `RALPH.md`, installs it as a single ralph named after the repo. Otherwise, finds and installs all ralphs in the repo.
173-
- `owner/repo/ralph-name` — searches the repo for a directory named `ralph-name` containing `RALPH.md`. If multiple matches are found, prints the paths and asks you to use the full subpath to disambiguate.
174-
- `https://github.com/owner/repo/tree/branch/path` — extracts the path from the URL. This is the format you get when you copy a URL from the GitHub web UI while browsing a directory. The branch name is used only to locate the path — `ralph add` always clones the default branch.
175-
176-
After adding, run the ralph by name:
177-
178-
```bash
179-
ralph run ralph-name
180-
```
181-
182-
---
183-
184138
## RALPH.md format
185139

186140
The `RALPH.md` file is the single configuration and prompt file for a ralph. It uses YAML frontmatter for settings and the body for the prompt text. See [Writing Prompts](writing-prompts.md) for detailed guidance on crafting effective prompts.

docs/contributing/codebase-map.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,18 @@ The core loop is simple. The complexity lives in **prompt assembly** — running
1919
```
2020
src/ralphify/ # All source code
2121
├── __init__.py # Version detection + app entry point
22-
├── cli.py # CLI commands (run, new, init) — delegates to engine for the loop
22+
├── cli.py # CLI commands (run, scaffold) — delegates to engine for the loop
2323
├── engine.py # Core run loop orchestration with structured event emission
2424
├── manager.py # Multi-run orchestration (concurrent runs via threads)
2525
├── _resolver.py # Template placeholder resolution ({{ commands.* }}, {{ args.* }}, {{ ralph.* }})
2626
├── _agent.py # Run agent subprocesses (streaming + blocking modes, log writing)
2727
├── _run_types.py # RunConfig, RunState, RunStatus, Command — shared data types
2828
├── _runner.py # Execute shell commands with timeout and capture output
2929
├── _frontmatter.py # Parse YAML frontmatter from RALPH.md, marker constants
30-
├── _source.py # GitHub source parsing and git-based ralph fetching for `ralph add`
31-
├── _skills.py # Skill installation and agent detection for `ralph new`
3230
├── _console_emitter.py # Rich console renderer for run-loop events (ConsoleEmitter)
3331
├── _events.py # Event types, emitter protocol, and BoundEmitter convenience wrapper
3432
├── _output.py # ProcessResult base class, combine stdout+stderr, format durations
35-
├── _brand.py # Brand color constants shared across CLI and console rendering
36-
└── skills/ # Bundled skill definitions (installed into agent skill dirs)
37-
└── new-ralph/ # AI-guided ralph creation skill for `ralph new`
33+
└── _brand.py # Brand color constants shared across CLI and console rendering
3834
3935
tests/ # Pytest tests — one test file per module
4036
docs/ # MkDocs site (Material theme) — user-facing documentation
@@ -118,8 +114,6 @@ The CLI uses a `ConsoleEmitter` (defined in `_console_emitter.py`) that renders
118114
3. **`cli.py`** — All CLI commands. Validates frontmatter fields via extracted helpers (`_validate_agent`, `_validate_commands`, `_validate_credit`, `_validate_run_options`, `_validate_declared_args`), builds a `RunConfig`, and delegates to `engine.run_loop()` for the actual loop. Terminal event rendering lives in `_console_emitter.py`.
119115
4. **`_frontmatter.py`** — YAML frontmatter parsing. Extracts `agent`, `commands`, `args` from the RALPH.md file.
120116
5. **`_resolver.py`** — Template placeholder logic. Small file but critical.
121-
6. **`_skills.py`** + **`skills/`** — The skill system behind `ralph new`. `_skills.py` handles agent detection, reads bundled skill definitions from `skills/`, installs them into the agent's skill directory, and builds the command to launch the agent.
122-
123117
## Traps and gotchas
124118

125119
### If you change frontmatter fields...

docs/getting-started.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ keywords: set up autonomous AI coding agent, install ralphify, AI coding loop tu
77
# Getting Started
88

99
!!! tldr "TL;DR"
10-
`uv tool install ralphify``ralph init my-ralph` → edit the RALPH.md → `ralph run my-ralph -n 1 --log-dir ralph_logs` to test → add a `commands` entry for your test suite → `ralph run my-ralph` to loop. The agent sees fresh test output each iteration and fixes what it breaks.
10+
`uv tool install ralphify``ralph scaffold my-ralph` → edit the RALPH.md → `ralph run my-ralph -n 1 --log-dir ralph_logs` to test → add a `commands` entry for your test suite → `ralph run my-ralph` to loop. The agent sees fresh test output each iteration and fixes what it breaks.
1111

1212
This tutorial walks through setting up ralphify, creating a ralph with commands, and running a productive autonomous loop. By the end, you'll have a self-healing coding loop that validates its own work.
1313

@@ -41,10 +41,10 @@ ralphify 0.3.0
4141

4242
## Step 2: Create a ralph
4343

44-
The fastest way to scaffold a ralph is `ralph init`:
44+
The fastest way to scaffold a ralph is `ralph scaffold`:
4545

4646
```bash
47-
ralph init my-ralph
47+
ralph scaffold my-ralph
4848
```
4949

5050
```text
@@ -54,16 +54,16 @@ Edit the file, then run: ralph run my-ralph
5454

5555
This creates `my-ralph/RALPH.md` with a ready-to-customize template including an example command, arg, and prompt. Edit the task section, [test it](#step-3-do-a-test-run), then follow [Step 4](#step-4-add-a-test-command) to add a test command — test feedback is what makes the loop self-healing.
5656

57-
Alternatively, use `ralph new` for AI-guided setup, or create the file manually as shown below.
57+
Or create the file manually as shown below.
5858

5959
!!! tip "Installing an existing ralph?"
60-
If someone has shared a ralph on GitHub, skip the manual setup and install it directly:
60+
Use [agr](https://github.com/computerlovetech/agr) to install shared ralphs from GitHub:
6161

6262
```bash
63-
ralph add owner/repo
63+
agr add owner/repo
6464
```
6565

66-
This installs to `.ralphify/ralphs/` so you can run it by name with `ralph run <name>`. See the [CLI reference](cli.md#ralph-add) for all source formats.
66+
This installs to `.agents/ralphs/` so you can run it by name with `ralph run <name>`.
6767

6868
### Manual setup
6969

docs/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ Done: 3 iterations — 2 succeeded, 1 failed
127127

128128
Edit `RALPH.md` while the loop is running — changes take effect on the next iteration.
129129

130-
## Or grab one from GitHub
130+
## Or install one with agr
131131

132-
Install a pre-built ralph from any GitHub repo and run it immediately:
132+
Install a pre-built ralph from any GitHub repo using [agr](https://github.com/computerlovetech/agr) and run it immediately:
133133

134134
```bash
135-
ralph add owner/repo/my-ralph # Install a ralph from GitHub
135+
agr add owner/repo/my-ralph # Install a ralph from GitHub
136136
ralph run my-ralph # Run it
137137
```
138138

139-
`ralph add` fetches the ralph and installs it locally. You can install a single ralph by name, or all ralphs in a repo at once with `ralph add owner/repo`. See the [CLI reference](cli.md#ralph-add) for details.
139+
agr installs ralphs to `.agents/ralphs/` so you can run them by name.
140140

141141
---
142142

0 commit comments

Comments
 (0)