refactor(fleet-launcher): introduce CliConvention trait#159
Merged
Conversation
Replace the per-variant match in build_command_line() with a CliConvention trait implemented on CliKind. The trait owns binary(), home_env(), and command_line(prompt, extra_args) so new CLIs add one impl arm instead of touching a central match. - build_command_line() collapses from ~30 lines to a single delegating call: spec.cli.command_line(prompt, extras). - CliKind keeps its existing inherent binary() / home_env() methods for source compatibility; they delegate to the trait. - Behavior preserved: Claude still injects --dangerously-skip-permissions, Gemini still pipes the prompt via printf '%s' | gemini, Codex and Claw still use a bare positional prompt, and home env vars (CODEX_HOME, CLAUDE_CONFIG_DIR, GEMINI_CLI_HOME, CLAW_CONFIG_HOME) are unchanged. - All 12 existing tests pass.
71cc1b5 to
cb195ce
Compare
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CliConventiontrait, implemented onCliKind(one match arm per variant) to replace the inlined 4-way match inbuild_command_line()build_command_line()shrinks from ~32 lines to a single delegating callCliKind::binary()andCliKind::home_env()kept as inherent methods that delegate to the trait, so existing callers (bin/spawn.rs,heartbeat.rs) compile unchangedTrait
Chose enum-impl over struct-per-CLI:
CliKindisCopy, already wired into the public API andheartbeat.rs, and all four CLIs are compile-time known — aBox<dyn CliConvention>registry would add an allocation per command build for zero call-site benefit. The trait still provides a swap-in seam if dynamic registration is needed later.Behavior
Identical for all 4 CLIs. Verified by the existing tests (
build_command_line_per_cli_conventions,cli_home_envs_match_each_cli,cli_parse_accepts_aliases,write_launch_script_emits_exports_cd_and_exec):codex hello --flag 'with space'--dangerously-skip-permissionsbefore the prompt —claude --dangerously-skip-permissions 'review this'printf '%s' hi | geminiclaw 'ship it'CODEX_HOME,CLAUDE_CONFIG_DIR,GEMINI_CLI_HOME,CLAW_CONFIG_HOMEStack
Targets
feat/fleet-launcher(#158) which introduces the crate. GitHub will auto-retarget this PR tomainonce #158 merges.Test plan
cargo check -p fleet-launcher— cleancargo test -p fleet-launcher— 12/12 passfleet-launcher(greped —fleet_launcher::is only referenced inside this crate's ownbin/andheartbeat.rs)