Refactor CLI into modular command/domain/build layers

Problem

cli/src/main.rs currently mixes command parsing, business logic, filesystem and process I/O, target resolution, staging, and build orchestration in one large file. This makes behavior harder to reason about, reduces testability, and increases merge conflict risk.

Proposal

Refactor the CLI internals into clear modules while keeping external CLI behavior stable.

Suggested structure:

  • src/main.rs: clap wiring + top-level error/exit mapping only
  • src/cmd/*: subcommand handlers (check, init, assembly, service, get, set, show, build, convert)
  • src/domain/*: target selection, config mutation/path resolution, validation helpers
  • src/build/*: staging pipeline + runtime-specific build adapters
  • src/io/*: filesystem/process wrappers where needed for test seams

Acceptance criteria

  • CLI behavior and flags remain backward compatible.
  • main.rs is reduced to dispatch/wiring concerns.
  • Core logic is moved into unit-testable modules.
  • New module boundaries are documented in docs/ or crate-level docs.
  • Existing tests pass and new tests cover moved pure logic.

Notes

This issue tracks architecture cleanup for maintainability and future feature work (parallel builds, richer error contracts, policy controls).