[PR #118] [MERGED] feat(cli): add loop merge command and custom backend args #145

Closed
opened 2026-02-27 10:22:24 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mikeyobrien/ralph-orchestrator/pull/118
Author: @mikeyobrien
Created: 1/26/2026
Status: Merged
Merged: 1/26/2026
Merged by: @mikeyobrien

Base: mainHead: feat/loop-merge-custom-backend


📝 Commits (1)

  • 3a0991d feat(cli): add loop merge command and custom backend args

📊 Changes

3 files changed (+184 additions, -32 deletions)

View changed files

📝 crates/ralph-cli/src/loops.rs (+117 -29)
📝 crates/ralph-cli/src/main.rs (+18 -0)
📝 crates/ralph-cli/src/sop_runner.rs (+49 -3)

📄 Description

Summary

This PR adds two enhancements to the Ralph CLI:

  1. Manual loop merging - New ralph loops merge command to manually trigger merge of completed loops
  2. Custom backend arguments - Support for passing custom backend commands/args to ralph plan and ralph task

Closes #117

Changes

Loop Merge Command

  • Added ralph loops merge <loop-id> command with --force option
  • Consolidates orphan worktree recovery and retry-merge logic
  • Handles various loop states (queued, merging, completed, discarded)
  • Force option allows retrying stuck merges

Custom Backend Arguments (Resolves #117)

  • Added custom_args field to PlanArgs and CodeTaskArgs
  • CLI accepts custom backend args after -- separator
  • sop_runner supports ad-hoc custom backend configuration
  • Enables using any executable as a backend without config file
  • Added "custom" as a valid backend name

Usage Examples

Custom Backend with Kimi CLI (Issue #117)

# Use Kimi CLI for planning
ralph plan -i "Add user authentication" -b custom -- kimi --model moonshot-v1-8k

# Use Kimi CLI for task execution
ralph task my-task.md -b custom -- kimi --model moonshot-v1-8k

Loop Merge Command

# Manually merge a completed loop
ralph loops merge abc123

# Force retry a stuck merge
ralph loops merge abc123 --force

Other Custom Backends

# Any CLI backend that accepts prompts
ralph plan -i "Add tests" -b custom -- custom-llm --model gpt-4 --temperature 0.7

Technical Details

The implementation:

  • Accepts custom args via the -- separator (clap's last = true attribute)
  • First arg becomes the backend command, remaining args are passed through
  • Assumes PromptMode::Arg with prompt appended as last argument
  • Falls back to config file if backend is "custom" but no CLI args provided

Test Plan

  • Pre-commit hooks pass (fmt + clippy)
  • Manual testing of loop merge command
  • Manual testing with Kimi CLI (issue #117)
  • Manual testing with other custom backends

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mikeyobrien/ralph-orchestrator/pull/118 **Author:** [@mikeyobrien](https://github.com/mikeyobrien) **Created:** 1/26/2026 **Status:** ✅ Merged **Merged:** 1/26/2026 **Merged by:** [@mikeyobrien](https://github.com/mikeyobrien) **Base:** `main` ← **Head:** `feat/loop-merge-custom-backend` --- ### 📝 Commits (1) - [`3a0991d`](https://github.com/mikeyobrien/ralph-orchestrator/commit/3a0991d81817c263d2c18a2c8ccb09346a67c8e0) feat(cli): add loop merge command and custom backend args ### 📊 Changes **3 files changed** (+184 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `crates/ralph-cli/src/loops.rs` (+117 -29) 📝 `crates/ralph-cli/src/main.rs` (+18 -0) 📝 `crates/ralph-cli/src/sop_runner.rs` (+49 -3) </details> ### 📄 Description ## Summary This PR adds two enhancements to the Ralph CLI: 1. **Manual loop merging** - New `ralph loops merge` command to manually trigger merge of completed loops 2. **Custom backend arguments** - Support for passing custom backend commands/args to `ralph plan` and `ralph task` Closes #117 ## Changes ### Loop Merge Command - Added `ralph loops merge <loop-id>` command with `--force` option - Consolidates orphan worktree recovery and retry-merge logic - Handles various loop states (queued, merging, completed, discarded) - Force option allows retrying stuck merges ### Custom Backend Arguments (Resolves #117) - Added `custom_args` field to `PlanArgs` and `CodeTaskArgs` - CLI accepts custom backend args after `--` separator - `sop_runner` supports ad-hoc custom backend configuration - Enables using any executable as a backend without config file - Added "custom" as a valid backend name ## Usage Examples ### Custom Backend with Kimi CLI (Issue #117) ```bash # Use Kimi CLI for planning ralph plan -i "Add user authentication" -b custom -- kimi --model moonshot-v1-8k # Use Kimi CLI for task execution ralph task my-task.md -b custom -- kimi --model moonshot-v1-8k ``` ### Loop Merge Command ```bash # Manually merge a completed loop ralph loops merge abc123 # Force retry a stuck merge ralph loops merge abc123 --force ``` ### Other Custom Backends ```bash # Any CLI backend that accepts prompts ralph plan -i "Add tests" -b custom -- custom-llm --model gpt-4 --temperature 0.7 ``` ## Technical Details The implementation: - Accepts custom args via the `--` separator (clap's `last = true` attribute) - First arg becomes the backend command, remaining args are passed through - Assumes `PromptMode::Arg` with prompt appended as last argument - Falls back to config file if backend is "custom" but no CLI args provided ## Test Plan - [x] Pre-commit hooks pass (fmt + clippy) - [ ] Manual testing of loop merge command - [ ] Manual testing with Kimi CLI (issue #117) - [ ] Manual testing with other custom backends --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 10:22:24 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ralph-orchestrator#145
No description provided.