-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
tech-debtTechnical debt items to addressTechnical debt items to address
Description
Problem
The init.ts action handler (src/cli/commands/init.ts:112-631) is 520+ lines with 10+ responsibilities:
- Version detection
- Scope determination (user/local)
- Interactive prompts (TTY handling)
- Plugin discovery and installation
- Registry updates
- Hook installation (memory, ambient, etc.)
- Working memory bootstrap
- Error handling and user feedback
Scope
This file is monolithic and violates single-responsibility principle. Extracting just 2-3 small blocks is insufficient. A proper refactor requires:
-
Phase functions - Decompose into ~5-7 phase handlers:
detectVersion()- Package version loadingdetermineScope()- User/local scope selectionselectPlugins()- Interactive plugin selectioninstallPlugins()- Plugin installation orchestrationsetupHooks()- Memory and ambient hook installationbootstrapMemory()- Working memory initializationconcludeInstallation()- Summary and next steps
-
Helper utilities - Extract reusable patterns:
- Registry update logic
- File system operations
- Error recovery and logging
-
Type safety - Define phase-to-phase contracts with Result types
Risk Assessment
- Risk Level: HIGH
- Why: The file is working and well-tested. Any refactor touches core installation logic
- Mitigation: Comprehensive test coverage already exists; refactor can be validated via existing test suite
Testing Strategy
- Keep all existing tests passing (no behavior changes)
- Add unit tests for new phase functions
- Integration test full installation flow end-to-end
Acceptance Criteria
- Handler decomposed into phase functions
- Phase functions are <100 lines each
- All existing tests pass
- New tests cover phase boundaries
- Line count reduced from 520 to ~300-350 in main handler
Priority
Low - works well currently. Defer to post-v1.0.0 dedicated refactoring effort.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
tech-debtTechnical debt items to addressTechnical debt items to address