# TASK METADATA - **Target Files:** `infra/setup/cli.ts`, `infra/setup/prompts/*.ts`, `infra/setup/commands/*.ts` - **Core Objective:** Phase 4.1 (CLI Setup Modularization): Decompose the 772-line `infra/setup/cli.ts` monolith into isolated prompt flows and Cliffy command modules under `infra/setup/prompts/` and `infra/setup/commands/`. - **Dependencies:** `tasks/complete/2026-0825.01.jul.story.arch.monolith-decomposition-roadmap-1845.ph4.md` - **Additional Important Notes:** Must reduce `infra/setup/cli.ts` to a clean ~60-line router, pass `deno check infra/setup.ts`, and preserve all CLI subcommands (`auth`, `test`, `build`, `compile_proto`, `dump_compose`, `spire`, `secrets`, `wizard`). --- ### 2. Architectural Considerations & Risks - **Risks:** - Breaking CLI argument parsing or flag inheritance in Cliffy commands if command action handlers are miswired. - **Alternatives:** - Leaving 772 lines in `cli.ts`; rejected because it violates the Single Responsibility Principle and combines UI prompts, network testers, and command routing into one file. ### 3. Proposed Implementation 1. **Extract Interactive Prompts (`infra/setup/prompts/`):** - `infra/setup/prompts/auth.ts`: `promptAuthConfig`, `promptSpireConfig`, `promptConfirmation`. - `infra/setup/prompts/wizard.ts`: `runSetupWizard`, `handleReviewConfigs`. 2. **Extract CLI Subcommands (`infra/setup/commands/`):** - `infra/setup/commands/auth.ts`: `auth` command action & setup file generator. - `infra/setup/commands/test.ts`: `test` connection action (`handleTestConnection`). - `infra/setup/commands/build.ts`: `build` and `compile_proto` command actions. - `infra/setup/commands/compose.ts`: `dump_compose` and `spire` command actions. - `infra/setup/commands/secrets.ts`: `secrets` command action. 3. **Refactor `infra/setup/cli.ts`:** - Keep `cli.ts` purely as the lightweight Cliffy Command router (~60-80 lines) registering the command modules and executing `runCli(args)`. 4. **Quality Gates & Validation:** - Run `deno check infra/setup.ts`. - Run `deno fmt infra/` and `deno test --allow-all`.