ralph-operations
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRalph Operations
Ralph 运维操作
Manage, monitor, and diagnose Ralph orchestration loops.
管理、监控并诊断Ralph编排循环。
Loop Management
循环管理
Quick Reference
快速参考
| Task | Command |
|---|---|
| List active loops | |
| List all (including merged) | |
| View loop changes | |
| View loop logs | |
| Follow logs live | |
| Stop running loop | |
| Merge completed loop | |
| Retry failed merge | |
| Abandon loop | |
| Clean stale processes | |
Loop ID format: Partial matching works - matches
a3f2loop-20250124-143052-a3f2| 任务 | 命令 |
|---|---|
| 列出活跃循环 | |
| 列出所有循环(含已合并) | |
| 查看循环变更 | |
| 查看循环日志 | |
| 实时跟踪日志 | |
| 停止运行中的循环 | |
| 合并已完成的循环 | |
| 重试失败的合并 | |
| 废弃循环 | |
| 清理僵死进程 | |
循环ID格式: 支持部分匹配 - 可匹配
a3f2loop-20250124-143052-a3f2Loop Status
循环状态
| Status | Color | Meaning |
|---|---|---|
| running | green | Loop is actively executing |
| queued | blue | Completed, waiting for merge |
| merging | yellow | Merge in progress |
| needs-review | red | Merge failed, requires intervention |
| merged | dim | Successfully merged (with |
| discarded | dim | Abandoned (with |
| 状态 | 颜色 | 含义 |
|---|---|---|
| running | 绿色 | 循环正在执行 |
| queued | 蓝色 | 已完成,等待合并 |
| merging | 黄色 | 合并中 |
| needs-review | 红色 | 合并失败,需要人工干预 |
| merged | 灰色 | 合并成功(需加 |
| discarded | 灰色 | 已废弃(需加 |
Starting & Stopping
启动与停止
Loops start automatically via :
ralph run- Primary loop: Runs in main workspace, holds
.ralph/loop.lock - Worktree loop: Created when primary is running, isolated in
.worktrees/<loop-id>/
bash
ralph loops # Any loops running?
cat .ralph/loop.lock 2>/dev/null # Primary loop details
ralph loops stop <id> # Graceful stop
ralph loops stop <id> --force # Immediate stop
ralph loops discard <id> # Abandon + clean worktree循环通过自动启动:
ralph run- 主循环:在主工作区运行,持有文件
.ralph/loop.lock - 工作树循环:主循环运行时创建,隔离在目录中
.worktrees/<loop-id>/
bash
ralph loops # 查看是否有运行中的循环?
cat .ralph/loop.lock 2>/dev/null # 查看主循环详情
ralph loops stop <id> # 优雅停止
ralph loops stop <id> --force # 强制立即停止
ralph loops discard <id> # 废弃并清理工作树Inspecting Loops
检查循环
bash
ralph loops diff <id> # What changed
ralph loops logs <id> -f # Live event log
ralph loops history <id> # State changes
ralph loops attach <id> # Shell into worktreeWorktree context files ():
.worktrees/<loop-id>/| File | Contents |
|---|---|
| Event stream: hats, iterations, tool calls |
| Current session summary |
| Handoff context for next iteration |
| Working notes |
| Runtime task state |
Primary loop uses the same files at in repo root.
.ralph/agent/bash
ralph loops diff <id> # 查看变更内容
ralph loops logs <id> -f # 实时事件日志
ralph loops history <id> # 查看状态变更历史
ralph loops attach <id> # 进入工作树的Shell环境工作树上下文文件(位于):
.worktrees/<loop-id>/| 文件 | 内容 |
|---|---|
| 事件流:Hat、迭代、工具调用 |
| 当前会话摘要 |
| 供下一次迭代使用的交接上下文 |
| 工作笔记 |
| 运行时任务状态 |
主循环在仓库根目录的目录中使用相同的文件。
.ralph/agent/Merge Queue
合并队列
Flow: or or
Queued → Merging → Merged→ NeedsReview → Merging (retry)→ Discardedbash
ralph loops merge <id> # Queue for merge
ralph loops process # Process pending merges now
ralph loops retry <id> # Retry failed mergeReading state:
bash
jq -r '.prompt' .ralph/loop.lock 2>/dev/null
tail -20 .ralph/merge-queue.jsonl | jq .流程: 或 或
已排队 → 合并中 → 已合并→ 需要审核 → 合并中(重试)→ 已废弃bash
ralph loops merge <id> # 加入合并队列
ralph loops process # 立即处理待合并任务
ralph loops retry <id> # 重试失败的合并读取状态:
bash
jq -r '.prompt' .ralph/loop.lock 2>/dev/null
tail -20 .ralph/merge-queue.jsonl | jq .Diagnostics
诊断功能
Enabling
启用诊断
bash
RALPH_DIAGNOSTICS=1 ralph run -p "your prompt"Zero overhead when disabled. Output:
.ralph/diagnostics/<YYYY-MM-DDTHH-MM-SS>/bash
RALPH_DIAGNOSTICS=1 ralph run -p "your prompt"禁用时无额外性能开销。输出目录:
.ralph/diagnostics/<YYYY-MM-DDTHH-MM-SS>/Session Discovery
会话查找
bash
LATEST=$(ls -t .ralph/diagnostics/ | head -1)
SESSION=".ralph/diagnostics/$LATEST"bash
LATEST=$(ls -t .ralph/diagnostics/ | head -1)
SESSION=".ralph/diagnostics/$LATEST"File Reference
文件参考
| File | Contains | Key Fields |
|---|---|---|
| Agent text, tool calls, results | |
| Hat selection, events, backpressure | |
| Timing, latency, token counts | |
| Parse errors, validation failures | |
| All tracing logs with metadata | |
| 文件 | 包含内容 | 关键字段 |
|---|---|---|
| Agent文本、工具调用、结果 | |
| Hat选择、事件、背压 | |
| 计时、延迟、Token计数 | |
| 解析错误、验证失败 | |
| 所有带元数据的跟踪日志 | |
Diagnostic Workflow
诊断工作流
1. Errors first:
bash
wc -l "$SESSION/errors.jsonl"
jq '.' "$SESSION/errors.jsonl"
jq -s 'group_by(.error_type) | map({type: .[0].error_type, count: length})' "$SESSION/errors.jsonl"2. Orchestration flow:
bash
jq '{iter: .iteration, hat: .hat, event: .event.type}' "$SESSION/orchestration.jsonl"
jq 'select(.event.type == "hat_selected") | {iter: .iteration, hat: .event.hat, reason: .event.reason}' "$SESSION/orchestration.jsonl"
jq 'select(.event.type == "backpressure_triggered") | {iter: .iteration, reason: .event.reason}' "$SESSION/orchestration.jsonl"3. Agent activity:
bash
jq 'select(.type == "tool_call") | {iter: .iteration, tool: .name}' "$SESSION/agent-output.jsonl"
jq -s '[.[] | select(.type == "tool_call")] | group_by(.iteration) | map({iter: .[0].iteration, tools: [.[].name]})' "$SESSION/agent-output.jsonl"4. Performance:
bash
jq 'select(.metric.type == "iteration_duration") | {iter: .iteration, ms: .metric.duration_ms}' "$SESSION/performance.jsonl"
jq -s '[.[] | select(.metric.type == "token_count")] | {total_in: (map(.metric.input) | add), total_out: (map(.metric.output) | add)}' "$SESSION/performance.jsonl"5. Trace logs:
bash
jq 'select(.level == "ERROR" or .level == "WARN")' "$SESSION/trace.jsonl"1. 优先检查错误:
bash
wc -l "$SESSION/errors.jsonl"
jq '.' "$SESSION/errors.jsonl"
jq -s 'group_by(.error_type) | map({type: .[0].error_type, count: length})' "$SESSION/errors.jsonl"2. 编排流程:
bash
jq '{iter: .iteration, hat: .hat, event: .event.type}' "$SESSION/orchestration.jsonl"
jq 'select(.event.type == "hat_selected") | {iter: .iteration, hat: .event.hat, reason: .event.reason}' "$SESSION/orchestration.jsonl"
jq 'select(.event.type == "backpressure_triggered") | {iter: .iteration, reason: .event.reason}' "$SESSION/orchestration.jsonl"3. Agent活动:
bash
jq 'select(.type == "tool_call") | {iter: .iteration, tool: .name}' "$SESSION/agent-output.jsonl"
jq -s '[.[] | select(.type == "tool_call")] | group_by(.iteration) | map({iter: .[0].iteration, tools: [.[].name]})' "$SESSION/agent-output.jsonl"4. 性能分析:
bash
jq 'select(.metric.type == "iteration_duration") | {iter: .iteration, ms: .metric.duration_ms}' "$SESSION/performance.jsonl"
jq -s '[.[] | select(.metric.type == "token_count")] | {total_in: (map(.metric.input) | add), total_out: (map(.metric.output) | add)}' "$SESSION/performance.jsonl"5. 跟踪日志:
bash
jq 'select(.level == "ERROR" or .level == "WARN")' "$SESSION/trace.jsonl"Quick Health Check
快速健康检查
bash
SESSION=".ralph/diagnostics/$(ls -t .ralph/diagnostics/ | head -1)"
echo "=== Session: $SESSION ==="
echo -e "\n--- Errors ---"
wc -l < "$SESSION/errors.jsonl" 2>/dev/null || echo "0"
echo -e "\n--- Iterations ---"
jq -s 'map(select(.event.type == "iteration_started")) | length' "$SESSION/orchestration.jsonl"
echo -e "\n--- Hats Used ---"
jq -s '[.[] | select(.event.type == "hat_selected") | .event.hat] | unique' "$SESSION/orchestration.jsonl"
echo -e "\n--- Backpressure Count ---"
jq -s 'map(select(.event.type == "backpressure_triggered")) | length' "$SESSION/orchestration.jsonl"
echo -e "\n--- Termination ---"
jq 'select(.event.type == "loop_terminated")' "$SESSION/orchestration.jsonl"bash
SESSION=".ralph/diagnostics/$(ls -t .ralph/diagnostics/ | head -1)"
echo "=== 会话: $SESSION ==="
echo -e "\n--- 错误统计 ---"
wc -l < "$SESSION/errors.jsonl" 2>/dev/null || echo "0"
echo -e "\n--- 迭代次数 ---"
jq -s 'map(select(.event.type == "iteration_started")) | length' "$SESSION/orchestration.jsonl"
echo -e "\n--- 使用的Hat ---"
jq -s '[.[] | select(.event.type == "hat_selected") | .event.hat] | unique' "$SESSION/orchestration.jsonl"
echo -e "\n--- 背压触发次数 ---"
jq -s 'map(select(.event.type == "backpressure_triggered")) | length' "$SESSION/orchestration.jsonl"
echo -e "\n--- 终止原因 ---"
jq 'select(.event.type == "loop_terminated")' "$SESSION/orchestration.jsonl"Troubleshooting
故障排查
Stale Processes
僵死进程
ralph loopsralph loops pruneralph loopsralph loops pruneOrphan Worktrees
孤立工作树
.worktrees/ralph loopsralph loops prunegit worktree remove .worktrees/<id> --force.worktrees/ralph loopsralph loops prunegit worktree remove .worktrees/<id> --forceMerge Conflicts
合并冲突
Loop stuck in :
needs-review- — see conflicting changes
ralph loops diff <id> - — resolve manually, commit, retry
ralph loops attach <id> - — abandon if not worth fixing
ralph loops discard <id>
循环卡在状态:
needs-review- — 查看冲突变更
ralph loops diff <id> - — 手动解决冲突,提交后重试
ralph loops attach <id> - — 若不值得修复则废弃
ralph loops discard <id>
Lock Stuck
锁卡住
"Loop already running" but nothing is → (safe if process is dead)
rm .ralph/loop.lock提示“Loop already running”但实际无运行中的循环 → 删除(确认进程已终止时操作安全)
.ralph/loop.lockAgent Stuck in Loop
Agent陷入循环
bash
jq -s '[.[] | select(.type == "tool_call")] | group_by(.name) | map({tool: .[0].name, count: length}) | sort_by(-.count)' "$SESSION/agent-output.jsonl"Red flag: Many iterations with few events = agent not making progress.
bash
jq -s '[.[] | select(.type == "tool_call")] | group_by(.name) | map({tool: .[0].name, count: length}) | sort_by(-.count)' "$SESSION/agent-output.jsonl"危险信号:多次迭代但事件极少 → Agent未取得进展。
Merge Stuck in "merging"
合并卡在“merging”状态
Process died mid-merge. Unblock:
bash
echo '{"ts":"'$(date -u +%Y-%m-%dT%H:%M:%S.000000Z)'","loop_id":"<loop-id>","event":{"type":"needs_review","reason":"Merge process died"}}' >> .ralph/merge-queue.jsonl
ralph loops discard <loop-id>合并过程中途崩溃。解决方法:
bash
echo '{"ts":"'$(date -u +%Y-%m-%dT%H:%M:%S.000000Z)'","loop_id":"<loop-id>","event":{"type":"needs_review","reason":"Merge process died"}}' >> .ralph/merge-queue.jsonl
ralph loops discard <loop-id>Worktree Corruption
工作树损坏
bash
git worktree repair
ralph loops prunebash
git worktree repair
ralph loops pruneCleanup
清理
bash
ralph clean --diagnostics # Delete all sessions
ralph clean --diagnostics --dry-run # Preview deletionsbash
ralph clean --diagnostics # 删除所有诊断会话
ralph clean --diagnostics --dry-run # 预览要删除的内容