refactor(backend): phase 4 - extract provider service layer

Architecture improvements:
- Extract ProviderService with switch/backfill/write methods
- Reduce command layer from 160 to 13 lines via delegation
- Separate business logic (services) from state management (commands)
- Introduce precise error handling with structured validation

Refactoring details:
- Split Codex/Claude switching into symmetric private methods
- Add multi-layer validation for Codex auth field (existence + type)
- Extract import_config_from_path for command and test reuse
- Expose export_config_to_file and ProviderService in public API

Test coverage:
- Add 10+ integration tests for Claude/Codex switching flows
- Cover import/export success and failure scenarios (JSON parse, missing file)
- Verify state consistency on error paths (current remains unchanged)
- Test snapshot backfill for both old and new providers after switching
This commit is contained in:
Jason
2025-10-28 10:47:48 +08:00
parent 8e980e6974
commit c2e8855a0f
8 changed files with 596 additions and 175 deletions

View File

@@ -0,0 +1,3 @@
pub mod provider;
pub use provider::ProviderService;