Setup Render Refactor Implementation Plan
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Split setup terminal rendering into smaller ownership modules without changing setup or uninstall behavior.
Architecture: Keep CLI rendering at the edge. SetupService still returns typed facts, and cli/render/ still owns terminal output. The split is by reason to change: brand/banner constants, terminal layout primitives, interactive setup screens, and setup/uninstall result rendering.
Tech Stack: Python 3.12, argparse CLI, Rich only inside cli/render/, pytest, ruff.
Baseline#
- Branch:
codex/macro-refactor-from-f2eb2c7 - Source of truth:
f2eb2c7a1ac56c913d4a44ab24d5c3a2b553007c uv run pytest: 401 passed on 2026-07-06uv run ruff check .: passed on 2026-07-06
Boundary Target#
Current pressure file:
src/codealmanac/cli/render/setup.pyis 612 lines and mixes setup result rendering, uninstall rendering, raw interactive choice screens, ANSI card layout, banner art, wrapping, and Rich panels.
Target files:
- Create
src/codealmanac/cli/render/brand.pyfor setup brand constants and banner/badge rendering. - Create
src/codealmanac/cli/render/terminal.pyfor ANSI-aware terminal primitives. - Create
src/codealmanac/cli/render/setup_screens.pyfor interactive setup choice screen rendering. - Keep
src/codealmanac/cli/render/setup.pyfor setup/uninstall result rendering and public render functions.
Task 1: Guard The Intended Split#
Files:
- Modify:
tests/test_architecture.py
Steps:
- Add an architecture assertion that the setup renderer split files exist.
- Keep the existing rule that Rich imports stay under
cli/render/. - Add a line cap for
cli/render/setup.pyafter extraction. - Run:
uv run pytest tests/test_architecture.py -q - Expected before implementation: fail because the new modules do not exist or
setup.pyis still too large.
Task 2: Extract Brand Rendering#
Files:
- Create:
src/codealmanac/cli/render/brand.py - Modify:
src/codealmanac/cli/render/setup.py
Steps:
- Move setup banner art, color constants, brand color mapping, and badge/banner functions into
brand.py. - Import those names from
setup.py. - Run:
uv run pytest tests/test_cli.py::test_cli_setup_and_uninstall_codex_instructions -q - Expected after implementation: pass.
Task 3: Extract Terminal Primitives#
Files:
- Create:
src/codealmanac/cli/render/terminal.py - Modify:
src/codealmanac/cli/render/setup.py
Steps:
- Move ANSI-aware helpers into
terminal.py: visible length, terminal width, line writing, wrapping, card rows, box rows, and shell command rendering where shared. - Keep names plain and product-neutral.
- Run:
uv run pytest tests/test_cli.py::test_cli_setup_and_uninstall_codex_instructions -q - Expected after implementation: pass.
Task 4: Extract Interactive Setup Screens#
Files:
- Create:
src/codealmanac/cli/render/setup_screens.py - Modify:
src/codealmanac/cli/render/setup.py - Possibly modify:
src/codealmanac/cli/dispatch/setup_tui.py
Steps:
- Move
SetupChoiceOption,SetupChoiceScreen, and all card-based choice screen rendering intosetup_screens.py. - Preserve the import path used by dispatchers. If callers import the classes from
setup.py, re-export them during the refactor only if that is needed for stable internal imports. - Run:
uv run pytest tests/test_cli.py::test_cli_setup_interactive_choices_can_disable_update_and_commits -q - Expected after implementation: pass.
Task 5: Verify The Whole Batch#
Files:
- All changed files.
Steps:
- Run:
uv run pytest tests/test_cli.py tests/test_setup_service.py tests/test_architecture.py -q - Run:
uv run ruff check src/codealmanac/cli/render tests/test_cli.py tests/test_setup_service.py tests/test_architecture.py - Run:
uv run pytest - Run:
uv run ruff check . - Run:
git diff --check - Commit:
git add docs/refactor-audit-2026-07-06 docs/plans/2026-07-06-setup-render-refactor.md src/codealmanac/cli/render tests/test_architecture.pygit commit -m "refactor: split setup terminal rendering"