Ralph 2.0 Go CLI#2
Conversation
- Introduced `Agent` interface and implementations for `claude` and `opencode`. - Updated command handling to select and execute the configured agent. - Enhanced documentation to reflect new agent support and usage instructions.
- Introduced `--model` flag and `RALPH_MODEL` environment variable for specifying AI models. - Updated `GetAgent` function to accept model parameter. - Modified `ClaudeAgent` and `OpencodeAgent` to utilize the specified model during execution. - Enhanced documentation in GO.md to reflect new model selection capabilities. - Added test scripts to verify model precedence from flags, environment variables, and config files.
…y support for .ralphrc files
- Updated the executor package to improve command execution and output handling. - Refactored the logger package for better file management and logging configuration. - Enhanced the prompt package to streamline prompt retrieval from various sources. - Improved test coverage for executor, logger, and prompt functionalities. - Added utility functions for better code organization and readability.
…nd security workflows
…rlay documentation
…alph.toml and remove ralphrc support
…n environment variables
…nt support and configuration examples
There was a problem hiding this comment.
Pull request overview
This PR introduces the “Ralph 2.0” Go-based CLI along with specs-first documentation and an expanded automated test suite (unit + E2E) covering routing, config precedence, prompt front matter, logging, and agent integration.
Changes:
- Added a Go CLI implementation (cobra-based) with init/run command routing, config overlays, agent env overrides, front matter parsing, and logging.
- Added extensive unit + end-to-end tests plus a test agent to validate CLI behavior deterministically.
- Added/updated project specs, dev tooling, and CI workflows to support the new Go implementation and release process.
Reviewed changes
Copilot reviewed 122 out of 124 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/types_test.go | Defines shared E2E test types. |
| test/e2e/specs_flags_test.go | E2E coverage for specs flags. |
| test/e2e/scenarios_test.go | E2E scenarios for loop behavior. |
| test/e2e/run_command_test.go | E2E coverage for run routing. |
| test/e2e/prompt_test.go | E2E prompt source tests. |
| test/e2e/plan_flags_test.go | E2E plan naming tests. |
| test/e2e/model_flags_test.go | E2E model/agent-mode flags. |
| test/e2e/logging_flags_test.go | E2E logging behavior validation. |
| test/e2e/init_command_test.go | E2E init command behavior. |
| test/e2e/config_precedence_test.go | E2E precedence (flags/env/config). |
| test/e2e/config_local_test.go | E2E local overlay behavior. |
| test/e2e/config_by_prompt_test.go | E2E front matter overrides. |
| test/e2e/agents/ralph-test-agent/main_test.go | Unit tests for test agent. |
| test/e2e/agents/ralph-test-agent/main.go | Test-only agent binary. |
| test/e2e/agent_selection_test.go | E2E agent selection tests. |
| test/e2e/agent_env_overrides_test.go | E2E child env overrides. |
| specs/vision-goals.md | Defines project vision/goals. |
| specs/run-command.md | Documents run command routing. |
| specs/release-workflow.md | Documents release workflow. |
| specs/prompts.md | Documents prompt resolution. |
| specs/logging.md | Documents logging behavior. |
| specs/init-command.md | Documents init command design. |
| specs/development-testing.md | Documents dev/testing workflow. |
| specs/core-architecture.md | Documents core CLI architecture. |
| specs/config-local-overlay.md | Documents overlay merge rules. |
| specs/config-by-prompt.md | Documents prompt front matter overrides. |
| specs/agents/opencode.md | Opencode integration spec. |
| specs/agents/cursor.md | Cursor integration spec. |
| specs/agents/claude.md | Claude integration spec. |
| specs/agents.md | Agent interface/selection spec. |
| specs/agent-env-overrides.md | Documents --env child env support. |
| specs/README.md | Index for specs set. |
| skills-lock.json | Locks external skills metadata. |
| ralph.toml | Adds default config example. |
| package.json | Adds JS tooling dependency. |
| opencode.jsonc | OpenCode configuration updates. |
| logs/.gitignore | Ignores generated logs. |
| lefthook.yml | Adds local hook automation. |
| internal/prompt/frontmatter_test.go | Adds front matter parsing tests. |
| internal/prompt/frontmatter.go | Implements front matter parsing. |
| internal/logger/logger_test.go | Adds logger unit tests. |
| internal/logger/logger.go | Implements file logger behavior. |
| internal/executor/executor_test.go | Adds executor unit tests. |
| internal/executor/executor.go | Implements command execution helper. |
| internal/config/writer_test.go | Adds config writer tests. |
| internal/config/writer.go | Implements atomic config writing. |
| internal/config/config_local_test.go | Adds overlay config tests. |
| internal/cli/run_test.go | Adds run command tests. |
| internal/cli/run_internal_test.go | Adds internal run helpers tests. |
| internal/cli/init_test.go | Adds init command structure tests. |
| internal/cli/init_internal_test.go | Adds init internal behavior tests. |
| internal/cli/init.go | Implements init command skeleton. |
| internal/cli/cmd_config_test.go | Adds precedence tests for CLI. |
| internal/cli/cmd.go | Creates root command + subcommands. |
| internal/agent/runner.go | Adds child env builder + exec helper. |
| internal/agent/opencode.go | Implements opencode agent. |
| internal/agent/cursor.go | Implements cursor agent. |
| internal/agent/claude.go | Implements claude agent. |
| internal/agent/agent.go | Agent interface + factory. |
| go.sum | Adds Go dependency checksums. |
| go.mod | Defines module + dependencies. |
| examples/ralph.toml | Provides full config example. |
| cmd/ralph/main_test.go | Adds CLI entrypoint tests. |
| cmd/ralph/main.go | Adds CLI entrypoint. |
| Makefile | Adds build/test/quality targets. |
| LICENSE | Adds MIT license file. |
| CONTRIBUTING.md | Adds contributor workflow docs. |
| AGENTS.md | Adds agent contribution guidelines. |
| .opencode/skills | Links OpenCode skills directory. |
| .opencode/plans/.gitignore | Ignores OpenCode plans output. |
| .opencode/commands/spec-status.md | Adds OpenCode command doc. |
| .gremlins.yaml | Adds mutation testing config. |
| .golangci.yml | Adds golangci-lint config. |
| .go-arch-lint.yml | Adds architecture lint config. |
| .gitignore | Updates repo ignore rules. |
| .github/workflows/tests.yml | Removes legacy shell test workflow. |
| .github/workflows/security.yml | Adds Go security workflow. |
| .github/workflows/release.yml | Adds release workflow for binaries. |
| .github/workflows/quality.yml | Adds CI quality gates. |
| .github/workflows/dependabot-automerge.yml | Adds dependabot automerge. |
| .github/dependabot.yml | Adds npm/go updates to dependabot. |
| .devcontainer/setup.sh | Devcontainer bootstrap script. |
| .devcontainer/pull-git-lfs-artifacts-override.sh | Overrides LFS pull behavior. |
| .devcontainer/install-go-tools.sh | Installs Go tools in container. |
| .devcontainer/devcontainer.json | Updates devcontainer definition. |
| .devcontainer/devcontainer-lock.json | Locks devcontainer features. |
| .agents/skills/skill-creator/scripts/utils.py | Adds skill parsing utility. |
| .agents/skills/skill-creator/scripts/quick_validate.py | Adds skill quick validation script. |
| .agents/skills/skill-creator/scripts/package_skill.py | Adds skill packager script. |
| .agents/skills/skill-creator/assets/eval_review.html | Adds eval review static asset. |
| .agents/skills/skill-creator/agents/comparator.md | Adds comparator agent spec. |
| .agents/skills/code-search/SKILL.md | Adds code-search skill doc. |
| .agents/skills/agent-spec-creation/SKILL.md | Adds agent spec workflow skill. |
| .agents/skills/agent-implementation/SKILL.md | Adds agent implementation skill. |
| .agents/.skill-lock.json | Adds agents skill lock. |
Comments suppressed due to low confidence (5)
internal/logger/logger.go:1
getGitBranch(andgetGitCommit) return\"N/A\"on failure, butNewLoggerprints these lines whenever the value is non-empty—so logs will includeGit branch: N/Aeven when git metadata is unavailable. To match the intent of 'when available' (and the function comment), return an empty string on error (or update the caller to explicitly test for\"N/A\"and omit the line).
internal/cli/init.go:1- TTY detection checks
os.Stdoutonly, butralph initreads from stdin (interactive questionnaire). This can incorrectly allow non-interactive runs (e.g., stdin is piped) or block waiting for input. Consider checking both stdin and stdout (or usegolang.org/x/term.IsTerminal(int(fd))on stdin) so the command reliably fails fast when not interactive.
internal/cli/init.go:1 - The error from
getWorkingDir()is ignored. Ifos.Getwdfails,cwdwill be empty and the command may write to an unintended relative location. Handle the error and return a clear failure soinitdoesn’t proceed with an invalid output path.
internal/prompt/frontmatter.go:1 strings.TrimSpace(body)removes all leading/trailing whitespace, which can unintentionally change prompt content (e.g., intentional indentation, trailing newlines, or leading spaces). If the goal is only to drop the single newline after the closing---, prefer trimming only leading\\r\\nafter the delimiter, or return the body unchanged and let callers decide.
AGENTS.md:1- Correct typo: 'Writting' should be 'Writing'.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "features": { | ||
| "ghcr.io/devcontainers/features/common-utils:": { | ||
| "installZsh": false, | ||
| "installOhMyZsh": false, | ||
| "installOhMyZshConfig": false, | ||
| "username": "automatic" | ||
| }, | ||
| "ghcr.io/devcontainers/features/go:": { | ||
| "version": "1.25", | ||
| "golangciLintVersion": "latest" | ||
| }, |
There was a problem hiding this comment.
Devcontainer feature identifiers look malformed (e.g., common-utils: and go: have a trailing colon but no feature version). Devcontainer features generally require an explicit version suffix (e.g., common-utils:2, go:1). As written, feature resolution may fail.
| """ | ||
|
|
||
| import sys | ||
| import os |
There was a problem hiding this comment.
os is imported but not used in this script. Removing unused imports keeps the script cleaner and avoids linter failures if Python linting is introduced.
| import os |
Why
Ralph has outgrown the original shell-based implementation. This PR introduces a Go-based CLI architecture that is easier to maintain, test, and evolve, while preserving the core workflow and adding stronger configuration, multi-agent support, and quality gates.
What’s included
ralph.shwith a compiled Go CLI (cmd/ralph) and structured internal packages.opencodeclaudecursor--modeland agent mode support, with clear precedence across flags, env vars, config, and prompt front matter.runfor explicit executioninitfor interactive setup and config generationspecs/.Breaking changes / migration notes
ralph.shis removed in favor of the Go binary.ralph init(or update existing config files) to align with the new format and defaults.Validation
Outcome
This PR establishes the Ralph 2.0 foundation: a production-ready Go CLI with multi-agent support, deterministic configuration behavior, strong test coverage, and maintainable delivery pipelines.