Add bash mode for executing shell commands

- Add ! prefix in TUI editor to execute shell commands directly
- Output streams in real-time and is added to LLM context
- Supports multiline commands, cancellation (Escape), truncation
- Preview mode shows last 20 lines, Ctrl+O expands full output
- Commands persist in session history as bashExecution messages
- Add bash command to RPC mode via {type:'bash',command:'...'}
- Add RPC tests for bash command execution and context inclusion
- Update docs: rpc.md, session.md, README.md, CHANGELOG.md

Closes #112

Co-authored-by: Markus Ylisiurunen <markus.ylisiurunen@gmail.com>
This commit is contained in:
Mario Zechner 2025-12-08 22:40:32 +01:00
parent 1608da8770
commit bd0d0676d4
13 changed files with 917 additions and 126 deletions

View file

@ -762,6 +762,27 @@ You can submit multiple messages while the agent is processing without waiting f
Change queue mode with `/queue` command. Setting is saved in `~/.pi/agent/settings.json`.
### Bash Mode (`!`)
Execute shell commands directly and add output to the LLM context by prefixing with `!`:
```
!ls -la
!git status
!cat package.json | jq '.dependencies'
```
**Features:**
- **Streaming output**: Command output streams in real-time as it executes
- **Multiline commands**: Write complex commands across multiple lines
- **Cancellation**: Press **Escape** to cancel a running command
- **Truncation**: Large outputs are truncated (2000 lines / 50KB) with full output saved to a temp file
- **Preview mode**: Shows last 20 lines by default; press **Ctrl+O** to expand
- **History**: Commands are added to editor history (navigate with Up/Down arrows)
- **Visual feedback**: Editor border turns green in bash mode; cancelled commands show yellow warning
Output is automatically added to the conversation context, allowing the LLM to see command results without manual copy-paste.
### Keyboard Shortcuts
**Navigation:**