Problem
src/main.rs is over 7k lines and currently owns many unrelated responsibilities: CLI definitions, command dispatch, broker runtime setup, Relaycast connection setup, delivery retry state, helper functions, and tests. That makes the binary entrypoint hard to scan and hard to test in isolation.
Scope
After the broker crate is isolated, make main.rs a thin entrypoint and move responsibilities into focused modules.
Suggested shape:
src/main.rs
src/cli/mod.rs
src/cli/args.rs
src/cli/commands/init.rs
src/cli/commands/pty.rs
src/cli/commands/headless.rs
src/cli/commands/mcp_args.rs
src/cli/commands/swarm.rs
src/cli/commands/dump_pty.rs
src/cli/commands/wrap.rs
src/broker/runtime.rs
src/broker/delivery.rs
src/broker/state.rs
Acceptance criteria
main.rs mostly parses/dispatches through relay_broker::cli::run() or equivalent.
- Clap command structs are moved out of
main.rs into cli modules.
run_init, run_headless_worker, run_dump_pty, and MCP argument handling live near their command modules or a broker runtime module.
- Existing CLI behavior and flags remain compatible.
- Relevant Rust tests pass.
Notes
This should be a mechanical extraction where possible. Avoid broad behavior changes so the diff stays reviewable.
Problem
src/main.rsis over 7k lines and currently owns many unrelated responsibilities: CLI definitions, command dispatch, broker runtime setup, Relaycast connection setup, delivery retry state, helper functions, and tests. That makes the binary entrypoint hard to scan and hard to test in isolation.Scope
After the broker crate is isolated, make
main.rsa thin entrypoint and move responsibilities into focused modules.Suggested shape:
Acceptance criteria
main.rsmostly parses/dispatches throughrelay_broker::cli::run()or equivalent.main.rsintoclimodules.run_init,run_headless_worker,run_dump_pty, and MCP argument handling live near their command modules or a broker runtime module.Notes
This should be a mechanical extraction where possible. Avoid broad behavior changes so the diff stays reviewable.