Problem
src/cli/commands/init.ts:296-2000 — the initCommand action handler is a ~1,704-line monolithic function. This PR (PR #316) added ~28 executable lines to it (attribution wizard call site), pushing the function further into unmaintainability.
A function this large is difficult to test in isolation, hard to review, and resistant to incremental refactoring. Line count alone isn't the issue; architecture is: the Advanced prompt list, phase sequencing, and settings pass all live inline with zero separation of concerns.
Current Status
Expected Behavior
The function should be decomposed into separately testable units with clear responsibilities:
- Advanced prompt list construction (what prompts, in what order, with what defaults)
- Phase sequencing (flow through Recommended vs Advanced modes)
- Settings pass (applying wizard answers to settings.json)
Each unit should have unit tests that can run without invoking the full init command.
Suggested Sequencing
Phase 1: Extract the Advanced prompt list definition
- Move prompt construction and phase sequencing into a separate module
- Example:
src/cli/commands/init-wizard.ts — pure definition, no I/O
Phase 2: Decompose the settings application logic
applyAttributionAnswer / applyCageAnswer patterns become a registry
- Each setting has a dedicated
apply_* function, tested independently
Phase 3: Reduce init.ts to a thin orchestrator
- Call the wizard, get the answers, apply them, done
- Line count target: <500 lines for the action handler
Acceptance Criteria
Related
Problem
src/cli/commands/init.ts:296-2000— theinitCommandaction handler is a ~1,704-line monolithic function. This PR (PR #316) added ~28 executable lines to it (attribution wizard call site), pushing the function further into unmaintainability.A function this large is difficult to test in isolation, hard to review, and resistant to incremental refactoring. Line count alone isn't the issue; architecture is: the Advanced prompt list, phase sequencing, and settings pass all live inline with zero separation of concerns.
Current Status
src/cli/commands/prompt-io.ts)attributionSeedFrom,applyAttributionAnswer)Expected Behavior
The function should be decomposed into separately testable units with clear responsibilities:
Each unit should have unit tests that can run without invoking the full init command.
Suggested Sequencing
Phase 1: Extract the Advanced prompt list definition
src/cli/commands/init-wizard.ts— pure definition, no I/OPhase 2: Decompose the settings application logic
applyAttributionAnswer/applyCageAnswerpatterns become a registryapply_*function, tested independentlyPhase 3: Reduce init.ts to a thin orchestrator
Acceptance Criteria
Related