# v0.0.2-continuous-shell Task Breakdown

## Overview
Transform CLI from single-command mode to interactive continuous shell.

---

## Phase 1 — Foundation: Interactive Shell Loop
**Status**: ✅ COMPLETE | **Priority**: HIGH

### Tasks
- [x] Create `lib/src/ui/` directory structure
- [x] Implement `lib/src/ui/shell.dart` REPL loop
  - [x] Prompt display (`mycli> `)
  - [x] Input reading
  - [x] Command routing
  - [x] Error handling (no exit on error)
- [x] Implement built-in shell commands
  - [x] `help` - list available commands
  - [x] `exit` / `quit` - exit shell
  - [x] `clear` - clear screen
- [x] Create `lib/src/core/command_registry.dart`
  - [x] Map<String, Command> structure
  - [x] Register existing commands
- [x] Modify `bin/mobile_build_cli.dart`
  - [x] Add `--shell` flag
  - [x] Add `--interactive-mode` flag (arrow|numeric)
  - [x] Default to shell mode when no args
  - [x] Single-command mode when args provided
- [ ] Write unit tests for shell

---

## Phase 2 — Arrow-Key Interactive Menus
**Status**: ✅ COMPLETE | **Priority**: HIGH

### Tasks
- [x] Create `lib/src/utils/terminal_helper.dart`
  - [x] Raw mode enable/disable
  - [x] Platform detection
  - [x] Escape sequence constants
- [x] Create `lib/src/ui/menu.dart` with two modes
  - [x] `Menu.select()` method with mode parameter
  - [x] **Arrow Mode** implementation:
    - [x] Highlight current option with `>`
    - [x] Arrow key navigation (up/down)
    - [x] Enter to select
    - [x] Raw terminal mode handling
  - [x] **Numeric Mode** implementation:
    - [x] Numbered list display: `1) option_a`
    - [x] Read number input
    - [x] Validate selection
- [x] Create `InteractiveMode` enum (arrow, numeric)
- [ ] Test menu on:
  - [ ] Windows PowerShell (both modes)
  - [ ] Windows CMD (numeric mode)
  - [ ] Git Bash / WSL (arrow mode)

---

## Phase 3 — Multi-Step Command Workflows
**Status**: ✅ COMPLETE | **Priority**: MEDIUM

### Tasks
- [x] Create `lib/src/flows/` directory
- [x] Implement `lib/src/flows/flow_context.dart`
  - [x] Store selected values
  - [x] Step navigation (back/skip/cancel)
- [x] Implement `lib/src/flows/build_flow.dart`
  - [x] Step 1: Select target (apk/aab/ipa)
  - [x] Step 2: Select flavor (dev/staging/prod)
  - [x] Step 3: Optional dart-defines
  - [x] Step 4: Show summary + confirm
- [x] Integrate build flow with shell (`wizard` command)
- [x] Add flow support - can run build after wizard

---

## Phase 4 — Shared Runtime Context
**Status**: ✅ COMPLETE | **Priority**: MEDIUM

### Tasks
- [x] Create `lib/src/core/app_context.dart`
  - [x] Load `.buildenv` once
  - [x] Load `pubspec.yaml` info
  - [x] Cache project paths
- [x] Modify shell to load context at startup
- [x] Pass context to shell (`appContext` field)
- [x] Add `context` command to view loaded config
- [ ] _(Optional)_ Update commands to use context directly

---

## Phase 5 — UX Polish
**Status**: ✅ COMPLETE | **Priority**: LOW

### Tasks
- [x] Create `lib/src/ui/styles.dart`
  - [x] Colors class with ANSI codes + semantic methods
  - [x] Symbols class with Unicode characters
- [x] Create `lib/src/ui/spinner.dart`
  - [x] Animated spinner characters (3 styles)
  - [x] Status message display
  - [x] Success/failure/warning/info indicators
  - [x] `withSpinner()` helper function
- [x] Menu already has colors (Phase 2)
- [x] Shell banner exists (Phase 1)
- [ ] _(Deferred)_ Command history file

---

## Phase 6 — Packaging & Distribution
**Status**: ✅ COMPLETE | **Priority**: LOW

### Tasks
- [x] Create `scripts/compile.ps1` (Windows)
- [x] Create `scripts/compile.sh` (Linux/macOS)
- [x] Update `README.md`
  - [x] Interactive shell documentation
  - [x] New features section
- [ ] _(Deferred)_ Update `CHANGELOG.md`

---

## Dependencies Between Phases

```
Phase 1 (Shell) ──────┬──► Phase 2 (Menus) ──► Phase 3 (Flows)
                      │
                      └──► Phase 4 (Context)
                                │
                                ▼
                          Phase 5 (Polish) ──► Phase 6 (Package)
```

- **Phase 1** must complete before anything else
- **Phase 2** requires Phase 1 (shell to host menus)
- **Phase 3** requires Phase 2 (menus for selection)
- **Phase 4** can run in parallel with Phase 2-3
- **Phase 5** requires Phase 1-4 complete
- **Phase 6** is final step after all others

---

## Success Criteria

| Criteria | Metric |
|----------|--------|
| Shell starts | `mycli` with no args opens shell |
| Commands work | All existing commands function in shell |
| Arrow mode works | `--interactive-mode arrow` enables arrow navigation |
| Numeric mode works | `--interactive-mode numeric` enables number selection |
| Build wizard | Multi-step flow completes successfully |
| No regressions | Single-command mode still works |
| Tests pass | All new tests green |
