|
| 1 | +# Feature 1: CLI Entry & Startup Modes |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +`gen` supports several startup modes controlled by flags. The TUI is only launched in interactive mode; other modes produce plain stdout output. |
| 6 | + |
| 7 | +| Flag | Behavior | |
| 8 | +|------|----------| |
| 9 | +| `gen` | Launch interactive TUI | |
| 10 | +| `gen -p "prompt"` | Non-interactive: print response to stdout, no TUI | |
| 11 | +| `gen --plan "task"` | Start in plan mode (read-only) | |
| 12 | +| `gen -c` | Resume the most recent session | |
| 13 | +| `gen -r` | Pick a session from a list | |
| 14 | +| `gen -c --fork` | Fork the most recent session | |
| 15 | +| `gen -r <id> --fork` | Fork a specific session | |
| 16 | +| `gen --plugin-dir PATH` | Load plugins from a directory | |
| 17 | +| `gen version` | Print version string | |
| 18 | +| `gen help` | Print help | |
| 19 | + |
| 20 | +## UI Interactions |
| 21 | + |
| 22 | +- **Interactive mode**: full TUI with input box, streaming output, and status bar. |
| 23 | +- **Print mode (`-p`)**: no TUI; response is written to stdout line by line. |
| 24 | +- **Plan mode**: status bar shows `[PLAN MODE]`; write tools are blocked. |
| 25 | +- **Session resume (`-r`)**: a scrollable session picker is shown before the TUI starts. |
| 26 | + |
| 27 | +## Automated Tests |
| 28 | + |
| 29 | +```bash |
| 30 | +go test ./tests/integration/session/... -v |
| 31 | + |
| 32 | +# Smoke test: non-interactive mode |
| 33 | +echo "say hello" | gen -p 2>&1 | grep -i hello |
| 34 | + |
| 35 | +# No provider needed |
| 36 | +gen version |
| 37 | +gen help |
| 38 | +``` |
| 39 | + |
| 40 | +Test cases to add: |
| 41 | + |
| 42 | +```go |
| 43 | +func TestNonInteractivePrintMode(t *testing.T) { |
| 44 | + // -p must write response to stdout without launching a TUI |
| 45 | +} |
| 46 | + |
| 47 | +func TestPlanModeFlag_ToolsAreRestricted(t *testing.T) { |
| 48 | + // --plan flag: write tools must be blocked |
| 49 | +} |
| 50 | + |
| 51 | +func TestSessionContinue_LoadsHistory(t *testing.T) { |
| 52 | + // -c must restore previous session messages |
| 53 | +} |
| 54 | + |
| 55 | +func TestSessionFork_IsIndependent(t *testing.T) { |
| 56 | + // --fork must create a new session that does not affect the original |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +## Interactive Tests (tmux) |
| 61 | + |
| 62 | +```bash |
| 63 | +tmux new-session -d -s t_cli -x 200 -y 50 |
| 64 | + |
| 65 | +# Test 1: Basic TUI startup |
| 66 | +tmux send-keys -t t_cli 'gen' Enter |
| 67 | +sleep 2 |
| 68 | +tmux capture-pane -t t_cli -p |
| 69 | +# Expected: TUI appears with input box and status bar |
| 70 | + |
| 71 | +# Test 2: Non-interactive print mode |
| 72 | +tmux send-keys -t t_cli 'q' Enter |
| 73 | +tmux send-keys -t t_cli 'gen -p "what is 1+1"' Enter |
| 74 | +sleep 5 |
| 75 | +tmux capture-pane -t t_cli -p |
| 76 | +# Expected: "2" on stdout; no TUI launched |
| 77 | + |
| 78 | +# Test 3: Plan mode startup |
| 79 | +tmux send-keys -t t_cli 'gen --plan "analyze this project"' Enter |
| 80 | +sleep 2 |
| 81 | +tmux capture-pane -t t_cli -p |
| 82 | +# Expected: [PLAN MODE] visible in status bar |
| 83 | +tmux send-keys -t t_cli 'q' Enter |
| 84 | + |
| 85 | +# Test 4: Session resume picker |
| 86 | +tmux send-keys -t t_cli 'gen -r' Enter |
| 87 | +sleep 2 |
| 88 | +tmux capture-pane -t t_cli -p |
| 89 | +# Expected: session list sorted by recency; navigate with arrow keys |
| 90 | + |
| 91 | +tmux kill-session -t t_cli |
| 92 | +``` |
0 commit comments