Skip to content

Conversation

@jellydn
Copy link

@jellydn jellydn commented Jan 13, 2026

What

This PR adds support for using OpenCode CLI as an alternative to Amp CLI in Ralph, an autonomous AI agent loop for software development.

Why

Users should be able to choose their preferred AI coding CLI. OpenCode provides a free model (opencode/big-pickle) that removes the need for paid API credits, making Ralph more accessible.

Latest Changes (v3)

  • Session Sharing: Added --share flag support for OpenCode to enable collaborative debugging
  • OpenCode Permissions: Configure OPENCODE_PERMISSION=allow-all and disable auto-compact to prevent context window issues
  • Build Agent Mode: Enable --agent build flag for OpenCode executions

Core Changes

  • CLI Selection: New cli_tool argument (amp or opencode)
  • Model Selection: New model argument for both CLIs
    • amp: supports smart or rush modes
    • opencode: supports any model ID (default: opencode/big-pickle)
  • Prompt Files: Split into CLI-specific files
    • prompt-amp.md: Original prompt for Amp
    • prompt-opencode.md: OpenCode-specific with MCP browser testing

Usage

# Amp (default)
./ralph.sh 10 amp

# Amp with smart mode
./ralph.sh 10 amp smart

# OpenCode with default model (free)
./ralph.sh 10 opencode

# OpenCode with custom model
./ralph.sh 10 opencode glm-4.7-free

# OpenCode with session sharing for collaboration
./ralph.sh 10 opencode glm-4.7-free true

Curl Testing Commands

# Test OpenCode CLI is installed and working
curl -sL https://opencode.ai/install.sh | bash
opencode --version

# Test OpenCode with big-pickle model (free)
echo "Hello, test a simple task" | opencode run -m opencode/big-pickle --agent build

# Test with session sharing enabled
echo "Hello" | opencode run -m opencode/big-pickle --agent build --share -

# Test with custom model
echo "Hello" | opencode run -m glm-4.7-free --agent build

# Test the ralph.sh script with OpenCode
./ralph.sh 3 opencode           # 3 iterations, OpenCode
./ralph.sh 3 opencode big-pickle true  # With session sharing

Demo

Related

Closes #12

- Add CLI selection via argument (amp/opencode)
- Add model selection support for both CLIs
- Create CLI-specific prompt files (prompt-amp.md, prompt-opencode.md)
- Update browser testing for opencode with ChromeDevTools MCP

fix(ralph): correct amp flag from --model to --mode

feat(ralph): add build agent flag to opencode command

Enable build agent mode for opencode executions to leverage specialized
build-focused capabilities during Ralph iterations
@jellydn jellydn force-pushed the feature/ralph-opencode branch from 1161322 to 2d50612 Compare January 13, 2026 07:00
Set OPENCODE_PERMISSION to allow-all and disable auto-compaction for
opencode runs to prevent context window issues during Ralph iterations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode support

1 participant