test: REPL command tests and CLI flag tests

This commit is contained in:
2026-05-01 11:57:17 -06:00
parent f3b410d146
commit b6ad7a575d
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