Implement `agents repl` command providing an interactive read-eval-print loop that dispatches to existing CLI commands without the `agents` prefix. Features: - Command dispatch via existing Typer app - readline history with --no-history opt-out (default: ~/.cleveragents/history) - Tab-completion for all CLI commands and built-in commands - !! last-command repetition - Prompt context from CLEVERAGENTS_PROJECT / CLEVERAGENTS_PLAN env vars - Ctrl+C (continue) and Ctrl+D (exit) signal handling - Multi-line input with \ continuation - :help and :exit/:quit built-in commands Test coverage: - 15 Behave scenarios (features/repl.feature) - 10 Robot Framework smoke tests (robot/repl_smoke.robot) - ASV benchmark suite (benchmarks/repl_bench.py) - All nox sessions pass: lint, typecheck, unit_tests, integration_tests - Coverage: 97.2% (threshold: 97%)
2.9 KiB
Interactive REPL
The agents repl command starts an interactive read-eval-print loop that
lets you run any CleverAgents CLI command without the leading agents
prefix.
Quick start
agents repl
Once inside the REPL you can type commands directly:
agents> plan list
agents> session create --actor openai/gpt-4
agents> config get log_level
Built-in commands
| Command | Description |
|---|---|
:help |
Show available commands |
:exit |
Exit the REPL (same as Ctrl+D) |
:quit |
Alias for :exit |
!! |
Repeat the last command |
Command-line options
| Flag | Default | Description |
|---|---|---|
--no-history |
False |
Disable history loading/saving |
--history-path |
~/.cleveragents/history |
Custom history file location |
Features
Tab-completion
Press Tab to complete top-level command names. All CLI commands and built-in REPL commands are available as completion candidates.
Command repetition
Type !! and press Enter to repeat the previous command. The repeated
command is printed before execution so you can see what ran.
Multi-line input
End a line with \ to continue on the next line. The REPL shows a ...
continuation prompt. All lines are joined with a space before dispatch.
agents> plan create \
... --name "My Plan" \
... --project demo
Prompt context
The prompt reflects the active project and plan when the environment
variables CLEVERAGENTS_PROJECT and CLEVERAGENTS_PLAN are set:
agents (myproject/active-plan)> plan status
Signal handling
| Signal | Behaviour |
|---|---|
| Ctrl+C | Cancels the current input; stays in REPL |
| Ctrl+D | Exits the REPL cleanly |
History
By default the REPL persists command history to
~/.cleveragents/history. The file is created automatically on first
use. History survives across sessions and is limited to 10 000 entries.
Privacy considerations
The history file is stored in the user's home directory with default filesystem permissions. It may contain sensitive information such as project names, plan names, and configuration values passed on the command line. If this is a concern:
- Use
--no-historyto disable persistence entirely. - Periodically delete or truncate
~/.cleveragents/history. - Ensure the directory permissions on
~/.cleveragents/are restricted (e.g.chmod 700).
Running the REPL smoke tests
nox -e unit_tests -- features/repl.feature
nox -e integration_tests # includes robot/repl_smoke.robot