Commit a3e8cbf
committed
Add interactive shell with multi-round conversation support
This commit adds a complete interactive shell/REPL mode to the AI orchestrator,
providing a Claude Code/Codex-like experience for multi-round conversations
with AI agents.
## New Features
### Interactive Shell (`orchestrator/shell.py`)
- REPL-style interface for continuous interaction
- Multi-round conversations with full context preservation
- Conversation history management (last 10 messages for context)
- Session save/load functionality
- Agent switching on-the-fly
- Workflow switching during session
- Full readline support (arrow keys, command history, tab completion)
### Shell Commands
- `/help` - Show all available commands
- `/exit`, `/quit` - Exit the shell
- `/clear` - Clear the screen
- `/history` - Show conversation history
- `/agents` - List available agents
- `/workflows` - List available workflows
- `/switch <agent>` - Switch to a specific agent
- `/workflow <name>` - Change the workflow
- `/save [filename]` - Save current session
- `/load <filename>` - Load a previous session
- `/context` - Show current context
- `/reset` - Reset conversation and context
- `/info` - Show system information
### CLI Integration
- New `shell` command: `./ai-orchestrator shell`
- New `interactive` command (alias for shell)
- Workflow selection on startup: `--workflow <name>`
- Custom config support: `--config <path>`
### Session Management
- Sessions saved to `~/.ai-orchestrator/sessions/`
- JSON format with full conversation history
- Auto-save prompt on exit if messages exist
- Load previous sessions to continue work
### User Experience
- Beautiful rich-formatted output
- Context-aware prompts showing current agent and workflow
- Graceful error handling
- Keyboard interrupt handling (Ctrl+C shows message, doesn't exit)
- Auto-completion for commands and agent names
- Persistent command history across sessions
## Testing
Added comprehensive test suite for interactive shell:
- 16 new tests in `tests/test_shell.py`
- Tests for ConversationHistory class
- Tests for InteractiveShell class
- Integration tests for shell startup/exit
- All 53 tests passing (37 original + 16 new)
## Documentation
Created detailed documentation:
- `docs/interactive-shell.md` - Complete guide (344 lines)
- Features overview
- Shell commands reference
- Usage patterns
- Keyboard shortcuts
- Session management
- Examples and best practices
- Troubleshooting
Updated existing documentation:
- `README.md` - Added interactive shell features and examples
- Interactive shell section
- Usage examples
- Project structure updated
## Comparison
### Before (One-Shot Mode)
```bash
./ai-orchestrator run "Create API"
# Single execution, no context preservation
```
### After (Interactive Mode)
```bash
./ai-orchestrator shell
> Create API
> Add authentication
> Write tests
> /save api-project
```
## Benefits
1. **Natural Workflow**: Like chatting with Claude Code or Codex
2. **Context Preservation**: Each message builds on previous conversation
3. **Session Continuity**: Save and resume work across days
4. **Agent Flexibility**: Switch agents mid-conversation
5. **Better UX**: Readline support, history, tab completion
6. **Iterative Development**: Refine code through multiple rounds
## Files Modified/Added
Modified:
- `orchestrator/__init__.py` - Export InteractiveShell
- `ai-orchestrator` - Add shell and interactive commands
- `README.md` - Document interactive features
- `tests/test_integration.py` - Fix test assertion
Added:
- `orchestrator/shell.py` - Interactive shell implementation (500+ lines)
- `tests/test_shell.py` - Comprehensive shell tests (260+ lines)
- `docs/interactive-shell.md` - Complete documentation (800+ lines)
## Usage Example
```bash
$ ./ai-orchestrator shell
Welcome to the AI Orchestrator interactive shell!
Available agents: claude
orchestrator (default) > Create a REST API
✓ Task completed successfully!
orchestrator (default) > Add JWT authentication
✓ Task completed successfully!
orchestrator (default) > /switch claude
Switched to agent: claude
claude (default) > Review and optimize the code
✓ Task completed successfully!
claude (default) > /save rest-api-project
Session saved!
claude (default) > /exit
Thank you for using AI Orchestrator!
```
This transforms the tool from a single-shot command executor into a true
interactive development environment for AI-assisted coding.1 parent 78c2555 commit a3e8cbf
6 files changed
Lines changed: 1450 additions & 25 deletions
File tree
- docs
- orchestrator
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
115 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
116 | 159 | | |
117 | 160 | | |
118 | 161 | | |
119 | | - | |
| 162 | + | |
120 | 163 | | |
121 | 164 | | |
122 | | - | |
| 165 | + | |
123 | 166 | | |
124 | 167 | | |
125 | | - | |
| 168 | + | |
126 | 169 | | |
127 | 170 | | |
128 | | - | |
| 171 | + | |
129 | 172 | | |
130 | 173 | | |
131 | 174 | | |
132 | 175 | | |
133 | 176 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | 177 | | |
138 | | - | |
| 178 | + | |
139 | 179 | | |
140 | 180 | | |
141 | | - | |
| 181 | + | |
142 | 182 | | |
143 | | - | |
144 | | - | |
| 183 | + | |
| 184 | + | |
145 | 185 | | |
146 | 186 | | |
147 | 187 | | |
148 | 188 | | |
149 | 189 | | |
150 | 190 | | |
151 | 191 | | |
152 | | - | |
| 192 | + | |
153 | 193 | | |
154 | 194 | | |
155 | 195 | | |
| |||
161 | 201 | | |
162 | 202 | | |
163 | 203 | | |
164 | | - | |
| 204 | + | |
165 | 205 | | |
166 | 206 | | |
167 | 207 | | |
168 | 208 | | |
169 | 209 | | |
170 | 210 | | |
171 | | - | |
| 211 | + | |
172 | 212 | | |
173 | 213 | | |
174 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
175 | 221 | | |
176 | 222 | | |
177 | 223 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 224 | + | |
182 | 225 | | |
183 | 226 | | |
184 | 227 | | |
| |||
189 | 232 | | |
190 | 233 | | |
191 | 234 | | |
192 | | - | |
| 235 | + | |
| 236 | + | |
193 | 237 | | |
194 | 238 | | |
195 | 239 | | |
| 240 | + | |
196 | 241 | | |
197 | 242 | | |
198 | 243 | | |
199 | 244 | | |
200 | 245 | | |
201 | | - | |
202 | | - | |
| 246 | + | |
203 | 247 | | |
204 | 248 | | |
205 | 249 | | |
206 | 250 | | |
207 | | - | |
| 251 | + | |
| 252 | + | |
208 | 253 | | |
209 | 254 | | |
| 255 | + | |
210 | 256 | | |
211 | 257 | | |
212 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
308 | 358 | | |
309 | 359 | | |
0 commit comments