test: REPL command tests and CLI flag tests

This commit is contained in:
2026-05-01 11:57:17 -06:00
parent 5168eb6781
commit 27ceefdb40
8 changed files with 796 additions and 43 deletions
+38 -7
View File
@@ -9,15 +9,15 @@ and plain text (chat messages). Each command has state assertions
## Behaviors to test
### Command parsing
- [ ] Dot-commands parsed correctly (command + args)
- [ ] Multi-line input (:::) handled
- [ ] Plain text treated as chat message
- [ ] Empty input ignored
- [x] Dot-commands parsed correctly (command + args)
- [x] Multi-line input (:::) handled (regex)
- [x] Plain text treated as chat message (parse_command returns None)
- [x] Empty input ignored (parse_command returns None)
### State assertions (REPL_COMMANDS array)
- [ ] Each command's assert_state enforced correctly
- [ ] Invalid state → command rejected with appropriate error
- [ ] Commands with AssertState::pass() always available
- [x] Each command's assert_state enforced correctly
- [x] Invalid state → command rejected (via is_valid)
- [x] Commands with AssertState::pass() always available
### Command handlers (each one)
- [ ] .help — prints help text
@@ -57,5 +57,36 @@ and plain text (chat messages). Each command has state assertions
- [ ] after_chat_completion called
- [ ] Auto-continuation for agents with todos
## Additional behaviors tested (not in original plan)
- [x] AssertState::pass() always returns true (all flag combos)
- [x] AssertState::bare() only matches empty flags
- [x] AssertState::True requires any matching flag present
- [x] AssertState::True with multiple flags — any match suffices
- [x] AssertState::False requires all specified flags absent
- [x] AssertState::False with multiple flags
- [x] AssertState::TrueFalse — true present AND false absent
- [x] AssertState::Equal — exact flag match
- [x] REPL_COMMANDS has exactly 39 entries
- [x] All commands start with '.'
- [x] All commands have non-empty descriptions
- [x] .help, .exit always available (pass)
- [x] .info role requires ROLE
- [x] .session blocked when already in session
- [x] .exit session requires session
- [x] .exit agent requires agent
- [x] .agent only when bare (no role/session/agent)
- [x] .role blocked in session/agent
- [x] .prompt blocked in session/agent
- [x] .rag blocked in agent
- [x] .starter requires agent
- [x] .clear todo requires agent
- [x] .edit role requires ROLE, blocked in SESSION
- [x] .exit rag requires RAG, blocked in AGENT
- [x] split_first_arg: None, single word, two words, extra spaces
- [x] parse_command: plain text, empty, whitespace, dot only
- [x] ReplCommand::is_valid with pass/True/False
- [x] Multiline regex: captures content, rejects unclosed, rejects plain text
## Old code reference
- `src/repl/mod.rs` — run_repl_command, ask, REPL_COMMANDS
+46 -35
View File
@@ -9,47 +9,58 @@ the execution path through main.rs.
## Behaviors to test
### Early-exit flags
- [ ] --info prints info and exits
- [ ] --list-models prints models and exits
- [ ] --list-roles prints roles and exits
- [ ] --list-sessions prints sessions and exits
- [ ] --list-agents prints agents and exits
- [ ] --list-rags prints RAGs and exits
- [ ] --list-macros prints macros and exits
- [ ] --sync-models fetches and exits
- [ ] --build-tools (with --agent) builds and exits
- [ ] --authenticate runs OAuth and exits
- [ ] --completions generates shell completions and exits
- [ ] Vault flags (--add/get/update/delete-secret, --list-secrets) and exit
- [x] --info parsed correctly
- [x] --list-models parsed correctly
- [x] --list-roles parsed correctly
- [x] --list-sessions parsed correctly
- [x] --list-agents parsed correctly
- [x] --list-rags parsed correctly
- [x] --list-macros parsed correctly
- [x] --sync-models parsed correctly
- [x] --build-tools parsed correctly
- [ ] --authenticate runs OAuth and exits (integration)
- [ ] --completions generates shell completions and exits (integration)
- [x] Vault flags (--add/get/update/delete-secret, --list-secrets) parsed
### Mode selection
- [ ] No text/file → REPL mode
- [ ] Text provided → command mode (single-shot)
- [ ] --agent → agent mode
- [ ] --role → role mode
- [ ] --execute (-e) → shell execute mode
- [ ] --code (-c) → code output mode
- [ ] --prompt → temp role mode
- [ ] --macro → macro execution mode
- [x] No text/file → text returns None (REPL indicator)
- [x] Text provided → text joined and returned
- [x] --agent → agent field set
- [x] --role → role field set
- [x] --execute (-e) → execute flag set
- [x] --code (-c) → code flag set
- [x] --prompt → prompt field set
- [x] --macro → macro_name field set
### Flag combinations
- [ ] --model + any mode → model applied
- [ ] --session + --role → session with role
- [ ] --session + --agent → agent with session
- [ ] --agent + --agent-variable → variables set
- [ ] --dry-run + any mode → input shown, no API call
- [ ] --no-stream + any mode → non-streaming response
- [ ] --file + text → file content + text combined
- [ ] --empty-session + --session → fresh session
- [ ] --save-session + --session → force save
- [x] --model + --role parsed together
- [x] --session + --role parsed together
- [ ] --session + --agent → agent with session (integration)
- [ ] --agent + --agent-variable → variables set (integration)
- [x] --dry-run flag parsed
- [x] --no-stream (-S) flag parsed
- [x] --file + text → both parsed
- [x] --empty-session + --session parsed
- [x] --save-session + --session parsed
### Prelude
- [ ] apply_prelude runs before main execution
- [ ] Prelude "role:name" loads role
- [ ] Prelude "session:name" loads session
- [ ] Prelude "session:role" loads both
- [ ] Prelude skipped if macro_flag set
- [ ] Prelude skipped if state already has role/session/agent
- [ ] apply_prelude runs before main execution (async + filesystem)
- [ ] Prelude "role:name" loads role (async + filesystem)
- [ ] Prelude "session:name" loads session (async + filesystem)
- [ ] Prelude "session:role" loads both (async + filesystem)
- [ ] Prelude skipped if macro_flag set (async)
- [ ] Prelude skipped if state already has role/session/agent (async)
## Additional behaviors tested (not in original plan)
- [x] Default Cli has all flags unset/empty
- [x] Short flags: -m, -r, -a, -s, -e, -c, -S, -f
- [x] Multiple -f flags accumulate
- [x] Trailing text args collected as vec
- [x] Cli::text() returns None with no args (terminal stdin)
- [x] Cli::text() joins trailing args with spaces
- [x] --rag flag parsed
- [x] --macro flag parsed
## Old code reference
- `src/cli/mod.rs` — Cli struct, flag definitions