2.1 KiB
2.1 KiB
Why
The rusty-claude-cli/src/main.rs file has grown to over 6200 lines, violating the Single Responsibility Principle and becoming a "God File". This high coupling makes the code difficult to read, maintain, and test. It also slows down compilation because all logic resides in a single file. Refactoring is necessary now to improve maintainability, reduce developer cognitive load, and enable easier addition of future features.
What Changes
- Split
main.rsinto smaller, focused modules based on Domain-Driven Design (DDD) boundaries. - Create
climodule for command-line argument parsing, prompt actions, and spelling suggestions. - Create
configmodule for model resolution and configuration management. - Create
executionmodule for the core tool execution engine (CliToolExecutor) and API client runtime interactions (AnthropicRuntimeClient). - Create
permissionsmodule for security, policy enforcement, and permission prompting (CliPermissionPrompter). - Create
diagnosticsmodule for diagnostic checks and error states. - Create
uimodule for terminal rendering, hooks, and progress tracking. - Shrink
main.rsso it only contains the entry point (main()function), global initialization, and top-level routing.
Capabilities
New Capabilities
main-module-refactoring: Refactoring of themain.rsfile into modular components (cli,config,execution,permissions,diagnostics,ui) without altering the external CLI behavior.
Modified Capabilities
- (None - This is a pure refactoring change; no external requirements or behaviors are changing.)
Impact
rusty-claude-cli/src/main.rswill be heavily reduced in size.- Numerous new files and folders will be created under
rusty-claude-cli/src/(e.g.,src/cli/,src/execution/, etc.). - Internal module imports (
usestatements) across the entirerusty-claude-clicrate will be updated to reflect the new structure. - Incremental compilation speed should improve.
- Unit tests currently residing in
main.rsormain_tests.rsmight need to be relocated to their respective new modules.