refactor(arch): cli = parse + route only; domain logic relocated to owning subsystems#129
Merged
Merged
Conversation
cli.cppm (6192 lines) -> thin dispatcher (481 lines). All command implementations move into dedicated modules, byte-identical bodies: mcpp.cli.common project/workspace discovery + fs utils mcpp.cli.install_ui xlings NDJSON -> ui download-progress adapters mcpp.toolchain.post_install patchelf/specs/cfg payload fixups mcpp.cli.build BuildContext + prepare_build (build core) mcpp.cli.cmd_build build/run/test/clean/dyndep + fast-path cache mcpp.cli.cmd_new new + package templates mcpp.cli.cmd_registry search + index management mcpp.cli.cmd_cache cache list/info/prune/clean mcpp.cli.cmd_toolchain toolchain install/list/default/remove mcpp.cli.cmd_publish publish/pack/emit-xpkg mcpp.cli.cmd_self self */doctor/why/env/explain Zero behavior change (same statement order, messages, exit codes). Architecture + plan: .agents/docs/2026-06-10-cli-modularization.md
…se + route)
Phase 2 of the cli modularization: every implementation now lives in
its owning subsystem; cli/cmd_* modules contain only argument handling,
CLI-shape validation and routing (no ParsedArgs below the cli layer).
mcpp.project manifest/workspace discovery (pm.commands' private
copy folded in)
mcpp.fetcher.progress xlings NDJSON -> ui adapters (InstallProgressHandler)
mcpp.build.prepare BuildContext + prepare_build
mcpp.build.execute build cache/fast-path, run_build_plan, run/test/clean
mcpp.toolchain.manager toolchain list/install/set-default/remove
mcpp.pm.index_ops search + index list/add/remove/update/pin/unpin
mcpp.bmi_cache.ops cache walk/list/info/prune/clean + fs size helpers
mcpp.scaffold.ops package templates + builtin project creation
mcpp.publish.ops publish pipeline + emit xpkg
mcpp.pack.ops pack orchestration
mcpp.doctor doctor/why/env/explain + self init/config
mcpp.cli.{common,install_ui,build} are gone; the whole cli layer is now
cli.cppm (481) + seven adapters (450 lines total). Bodies moved verbatim
(zero behavior change). Doc: .agents/docs/2026-06-10-cli-modularization.md
…onsibility names mcpp.bmi_cache.ops -> mcpp.bmi_cache.maintenance mcpp.scaffold.ops -> mcpp.scaffold.create mcpp.publish.ops -> mcpp.publish.pipeline mcpp.pack.ops -> mcpp.pack.pipeline mcpp.pm.index_ops -> mcpp.pm.index_management mcpp.toolchain.manager -> mcpp.toolchain.lifecycle Pure rename (module/file/import sites); namespaces, exported symbols and behavior unchanged.
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.
Motivation
src/cli.cppmhad grown to 6192 lines, mixing command dispatch, the entire build-orchestration pipeline (prepare_build, ~2240 lines), toolchain payload post-install fixups, install-progress UI plumbing, and 25 command implementations in one module — the slowest incremental rebuild unit in the repo and a permanent merge-conflict hotspot.This PR restructures the whole CLI surface in two layers:
cli.cppmis now a 481-line module containing only the usage screen and thecmdline::App+run()dispatch.src/cli/cmd_*.cppm(7 modules, ~450 lines total) contain only argument handling, CLI-shape validation, and routing. No domain logic;mcpplibs.cmdlinenever crosses below the cli layer.All implementations were relocated into their owning subsystems:
mcpp.projectpm.commandskept to avoid importing the old cli)mcpp.fetcher.progressmcpp.build.prepareBuildContext,BuildOverrides,prepare_build(workspace → toolchain → dependency resolution → features → modgraph → fingerprint → plan → lockfile)mcpp.build.executerun_build_plan, run/test/clean pipelinesmcpp.toolchain.post_installmcpp.toolchain.lifecyclemcpp.pm.index_managementmcpp.bmi_cache.maintenancemcpp.scaffold.createmcpp.publish.pipelinemcpp.pack.pipelinemcpp.doctorLayering rules:
cmd_*adapters never import each other; domain ops take plain typed parameters (neverParsedArgs); export surface is explicit per symbol; module names state their responsibility (no grab-bagops/manager/utilsnames). Full architecture + relocation map:.agents/docs/2026-06-10-cli-modularization.md.Zero behavior change
Bodies were moved byte-identical via scripted line-range extraction (same statement order, messages, exit codes). The only edits: namespaces,
exportkeywords, explicit qualification at cross-namespace call sites, andCliInstallProgress→InstallProgressHandler(renamed for its new fetcher-domain home). No platform-conditional code touched; source discovery is glob-based so no manifest change on any platform.Verification (after each phase)
imgui.*scanner warnings from the template raw-string literal pre-date this PR — identical on main)mcpp test: 18/18 unit tests passtests/e2e/run_all.sh: 67 pass / 1 skip — the 6llvm_*failures fail identically with the pre-refactor binary on the same host (local LLVM payload exec issue, environment-specific, not a regression)--helpscreen,version, unknown-command exit 127 unchangedFollow-ups (documented in the plan doc)
prepare_buildinternally now that it lives inmcpp.build.preparemcpp.build.prepare's inherited import listpm.commands(add/remove/update) behind typed ops to complete the parse/route pattern