You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
After the cli.py and apm_package.py refactoring in PR #224, several newly extracted modules exceed code quality thresholds (400-line file limit, 30-statement function limit). This makes the codebase harder to navigate, test, and maintain. Key pain points:
5 god files exceed the 400-line limit: install.py (1449), dependency.py (1024), deps.py (879), compile.py (739), uninstall.py (559)
9 god functions exceed 30 statements, with _install_apm_dependencies() (~250 stmts), uninstall() (~540 stmts), and DependencyReference.parse() (~380 stmts) being the worst
~85-line integration loop duplicated in full for cached vs. fresh packages in install.py
30+ overly broad exception handlers (except Exception:) across all modules, some swallowing errors silently
String-typed dispatch (--only "apm"|"mcp") and boolean flag pairs where enums would be safer
Describe the solution you'd like
A phased refactoring (each phase is independently shippable) to bring all modules under quality thresholds:
Phase
Scope
Risk
1. Constants + exception handlers
Extract shared constants to constants.py. Narrow all except Exception: to specific types. Remove dead code.
Low
2. Decompose god functions
Break _install_apm_dependencies(), uninstall(), and DependencyReference.parse() into ≤30-statement helpers. Extract the duplicated integration loop into _integrate_package_artifacts().
Is your feature request related to a problem? Please describe.
After the cli.py and apm_package.py refactoring in PR #224, several newly extracted modules exceed code quality thresholds (400-line file limit, 30-statement function limit). This makes the codebase harder to navigate, test, and maintain. Key pain points:
install.py(1449),dependency.py(1024),deps.py(879),compile.py(739),uninstall.py(559)_install_apm_dependencies()(~250 stmts),uninstall()(~540 stmts), andDependencyReference.parse()(~380 stmts) being the worstinstall.pyexcept Exception:) across all modules, some swallowing errors silently--only "apm"|"mcp") and boolean flag pairs where enums would be saferDescribe the solution you'd like
A phased refactoring (each phase is independently shippable) to bring all modules under quality thresholds:
constants.py. Narrow allexcept Exception:to specific types. Remove dead code._install_apm_dependencies(),uninstall(), andDependencyReference.parse()into ≤30-statement helpers. Extract the duplicated integration loop into_integrate_package_artifacts().InstallMode,IntegrationTarget,VirtualPackageType,HostTypeenums. Replace string/boolean dispatch.install.py→ CLI entry + install engine + integrator orchestrator.deps.py→ list/tree/info submodules.compile.py→ CLI entry + compiler + watcher.InstallResult,PrimitiveCounts, etc. Strategy pattern for Rich/text rendering.Describe alternatives you've considered
cli.pyfrom 4500→80 lines, but the extracted modules inherited the same structural issues.Additional context
feat/172-refactor-cli-and-apm-package-modulesbranch (PR Refactor cli.py and apm_package.py into focused modules (#172) #224).install.py(1449),dependency.py(1024),deps.py(879),compile.py(739),uninstall.py(559),_helpers.py(405),validation.py(388),mcp.py(373),run.py(218),init.py(192),runtime.py(188),config.py(169),prune.py(143),update.py(136),list_cmd.py(102).uv run pytest tests/ -q --tb=short -x.