Skip to content

feat: add provider override CLI flags#314

Merged
umputun merged 10 commits intoumputun:masterfrom
korjavin:claude-command-external-review-tool-flags
Apr 30, 2026
Merged

feat: add provider override CLI flags#314
umputun merged 10 commits intoumputun:masterfrom
korjavin:claude-command-external-review-tool-flags

Conversation

@korjavin
Copy link
Copy Markdown
Contributor

This PR adds per-run CLI flags that override configured provider settings for Claude-compatible task/review execution and external review tooling.

Why do we do these changes?

  1. Prevent Profile Bloat: Avoids creating a mess with multiple configuration files or separate RALPHEX_CONFIG_DIR profiles for simple variations in provider setup. One-off tests or temporary switches can now be handled directly via flags instead of maintaining redundant configuration state.
  2. Improved Developer Experience: By allowing --claude-command and --claude-args to override config settings before dependency checks, developers can easily point ralphex to experimental wrapper scripts even if the default Claude installation is missing or broken.
  3. Config-to-CLI Consistency: Adding these flags brings the provider configuration into the same override pattern already used for other settings like --task-model or --session-timeout.

What changed?

  • New CLI Flags: Added --claude-command, --claude-args, --external-review-tool, and --custom-review-script.
  • Explicit Override Tracking: Implemented ArgsSet logic in the executor to allow explicit empty overrides (e.g., --claude-args=) to clear default Claude flags.
  • Pre-Dependency Application: Adjusted the boot sequence in main.go to apply CLI overrides immediately after config loading but before verifying the Claude dependency.
  • Alias Support: Added hidden underscore aliases (e.g., --claude_command) to match configuration file field names.
  • Documentation:
    • Updated README.md with a new "Options" table and usage examples.
    • Enhanced docs/custom-providers.md with details on per-run provider switching.
    • Updated llms.txt for AI-assisted context.
  • Tests: Added comprehensive unit tests in main_test.go covering flag parsing, conflict resolution, and the dependency injection regression.

Example Usage

# Use a custom wrapper and clear default args for a single run
ralphex --claude-command=/path/to/wrapper.sh --claude-args= docs/plans/feature.md

# Use a custom review script without editing config
ralphex --external-review-tool=custom --custom-review-script=./my-review.sh docs/plans/feature.md

@korjavin korjavin requested a review from umputun as a code owner April 30, 2026 11:30
Copy link
Copy Markdown
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of things before this can merge. The core feature is reasonable: the empty-args fix is solving a real documented gap in pkg/config/values.go:435 (mergeFrom skips empty values, so claude_args = in config falls back to the embedded default), and the boot reorder is needed for --claude-command to actually work against checkClaudeDep.

underscore aliases have no precedent

--claude_command, --claude_args, --external_review_tool, --custom_review_script are the only underscore-aliased flags in the CLI. About 35 long flags in cmd/ralphex/main.go, none of the others ship aliases despite the same hyphen-vs-underscore mismatch with their config keys (--task-model / task_model, --review-patience / review_patience, etc.). The aliases cost 4 alias fields + 4 *Set bools + validateAliasConflict + cliStringOverride + a test matrix nothing else needs. I'd prefer dropping them. If consistent typo tolerance is something you want across the whole CLI, that's a separate scope.

--external-review-tool=custom silently flips CodexEnabled=true

cmd/ralphex/main.go:1322-1327. This is real back-compat work for users with codex_enabled = false legacy config, which is fine, but it lives in the wrong layer. A CLI flag silently mutating an unrelated config field is surprising. Cleaner: have Runner.externalReviewTool() defer to an explicit ExternalReviewTool regardless of CodexEnabled, then drop the implicit flip from applyCLIOverrides. At minimum the flag description should mention the side-effect.

Removes hidden --claude_command, --claude_args, --external_review_tool,
and --custom_review_script aliases. They were the only underscore-spelled
CLI flags in ralphex and didn't justify the alias fields, *Set bools,
conflict validation, and test matrix needed to support them. The hyphen
flags and the underscored config keys are unchanged.
… override

A CLI flag mutating an unrelated config field is surprising. Push the
explicitness signal down instead: processor.Config gains an
ExternalReviewToolSet flag, Runner.externalReviewTool() honors an
explicit choice over the legacy codex_enabled=false back-compat path,
and applyCLIOverrides only writes the field the user actually set.

Legacy behavior unchanged: a config with only codex_enabled=false (no
explicit external_review_tool from CLI) still resolves to "none".
@korjavin
Copy link
Copy Markdown
Contributor Author

FIxed

Copy link
Copy Markdown
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both points addressed cleanly:

  • aliases dropped in 8996ab0, only the canonical hyphen forms remain
  • codex_enabled flip moved out of applyCLIOverrides into Runner.externalReviewTool() in 7c3e82a, which now defers to an explicit ExternalReviewToolSet over the legacy codex_enabled=false back-compat. Regression test locks the behavior.

tests pass, lint clean. Lgtm, thx

@umputun umputun merged commit 03ae199 into umputun:master Apr 30, 2026
2 checks passed
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.

2 participants