powerglide is designed to be both a standalone CLI tool and a high-performance substrate for other agents (like Claude Code, oh-my-opencode, etc.) to build upon. This guide details the Ralph Loop protocol, PTY management, and how to integrate with powerglide programmatically.
Every session follows an explicit 11-state transition model. Agents MUST NOT skip states or exit implicitly.
| State | Purpose | Transition Signal |
|---|---|---|
idle |
Waiting for initialization | Start session |
load_tasks |
Fetching from task-queue.json |
Queue not empty |
pick_task |
Selecting highest priority task | Task assigned |
thinking |
LLM cognition / completion | LLM response received |
tool_call |
Parsing tool use blocks | Tools ready |
executing |
Subprocess in isolated PTY | Tool finished |
observing |
Result aggregation / analysis | Next action decided |
verify |
Running automated checks | Success/Failure |
commit |
State persistence | Task status updated |
done |
Clean termination | <POWERGLIDE_DONE> |
failed |
Unrecoverable error | <POWERGLIDE_ERROR> |
- Success: The session MUST output
<POWERGLIDE_DONE>to stdout upon completion of all tasks. - Failure: The session MUST output
<POWERGLIDE_ERROR>followed by a diagnostic message.
Velocity is a floating-point multiplier (f64) on a 1000ms base delay.
- Formula:
delay_ms = 1000 / velocity - Default:
1.0(1000ms) - Speeding up:
2.0(500ms),4.0(250ms) - Slowing down:
0.5(2000ms),0.25(4000ms)
CLI flags: --velocity accepts floating-point values.
Agents can self-throttle via CLI flag or config:
powerglide run --velocity 0.5 "task" or set velocity in ~/.config/powerglide/config.json
powerglide runs all tools in a pseudoterminal (PTY). This ensures:
- Interactive behavior: Tools like
gitornpmbehave as if they are in a real terminal. - ANSI colors: preserved in logs.
- Exit Code capture: Reliability via
waitpidwithWNOHANGpolling and/proc/<pid>/statusfallback.
When building tools for powerglide, assume a standard POSIX environment.
powerglide implements the Model Context Protocol (JSON-RPC 2.0) over stdin/stdout in both directions.
powerglide mcpThe server exposes all registered tools. Protocol handshake:
- Send
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"my-client","version":"1.0"}}} - Server responds with
protocolVersion,capabilities.tools, andserverInfo - Send
{"jsonrpc":"2.0","id":2,"method":"tools/list"}to enumerate tools - Send
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"bash","arguments":{"command":"ls"}}}to execute
Add mcp_servers to ~/.config/powerglide/config.json:
{
"mcp_servers": [
{
"name": "filesystem",
"command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
}
]
}External tools register as mcp_filesystem_<tool_name> and are callable through the standard tool dispatch path — indistinguishable from built-in tools to the Ralph Loop.
# Launch powerglide in background
powerglide run --agent hephaestus --velocity 2.0 "refactor src/main.zig" > session.log 2>&1 &
PID=$!
# Monitor progress
tail -f session.log | grep --line-buffered "Ralph Loop State"Workers write a timestamp to ~/.powerglide/workers/<id>/heartbeat every 30 seconds. If the timestamp is older than 60 seconds, the worker is considered "stale" and should be SIGKILLed.
Named after the Lamborghini Powerglide transmission — built for maximum throughput. 🦀⚡