This commit is contained in:
Anthony Shaw
2026-02-11 14:23:25 -08:00
parent 84486c2e46
commit ff69b804ac
5 changed files with 710 additions and 70 deletions

View File

@@ -43,7 +43,7 @@ A [Ralph loop](https://ghuntley.com/ralph/) is an autonomous development workflo
## Simple Version
The minimal Ralph loop — the SDK equivalent of `while :; do cat PROMPT.md | claude ; done`:
The minimal Ralph loop — the SDK equivalent of `while :; do cat PROMPT.md | copilot ; done`:
```python
import asyncio
@@ -117,14 +117,17 @@ async def ralph_loop(mode: str = "build", max_iterations: int = 50):
# Pin the agent to the project directory
working_directory=str(Path.cwd()),
# Auto-approve tool calls for unattended operation
on_permission_request=lambda _req, _ctx: {"kind": "approved", "rules": []},
on_permission_request=lambda _req, _ctx: {
"kind": "approved", "rules": []
},
))
# Log tool usage for visibility
session.on(lambda event:
print(f"{event.data.tool_name}")
if event.type.value == "tool.execution_start" else None
)
def log_tool_event(event):
if event.type.value == "tool.execution_start":
print(f"{event.data.tool_name}")
session.on(log_tool_event)
try:
await session.send_and_wait(
@@ -193,9 +196,9 @@ creating ad-hoc copies.
4. When tests pass, update IMPLEMENTATION_PLAN.md, then `git add -A`
then `git commit` with a descriptive message.
99999. When authoring documentation, capture the why.
999999. Implement completely. No placeholders or stubs.
9999999. Keep IMPLEMENTATION_PLAN.md current — future iterations depend on it.
5. When authoring documentation, capture the why.
6. Implement completely. No placeholders or stubs.
7. Keep IMPLEMENTATION_PLAN.md current — future iterations depend on it.
```
### Example `AGENTS.md`
@@ -230,12 +233,14 @@ python -m pytest
## When to Use a Ralph Loop
**Good for:**
- Implementing features from specs with test-driven validation
- Large refactors broken into many small tasks
- Unattended, long-running development with clear requirements
- Any work where backpressure (tests/builds) can verify correctness
**Not good for:**
- Tasks requiring human judgment mid-loop
- One-shot operations that don't benefit from iteration
- Vague requirements without testable acceptance criteria