indusagi-coding-agent 0.1.29 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE.md +22 -0
- package/package.json +2 -2
- package/docs/COMPLETE-GUIDE.md +0 -300
- package/docs/COMPREHENSIVE-CLI-SUMMARY.md +0 -900
- package/docs/MODES-ARCHITECTURE.md +0 -565
- package/docs/PRINT-MODE-GUIDE.md +0 -456
- package/docs/README.md +0 -78
- package/docs/RPC-GUIDE.md +0 -705
- package/docs/UTILS-IMPLEMENTATION-SUMMARY.md +0 -647
- package/docs/UTILS-MODULE-OVERVIEW.md +0 -1480
- package/docs/UTILS-QA-CHECKLIST.md +0 -1061
- package/docs/UTILS-USAGE-GUIDE.md +0 -1419
- package/docs/compaction.md +0 -390
- package/docs/custom-provider.md +0 -538
- package/docs/development.md +0 -69
- package/docs/extensions.md +0 -1733
- package/docs/hooks.md +0 -378
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/json.md +0 -79
- package/docs/keybindings.md +0 -162
- package/docs/models.md +0 -193
- package/docs/packages.md +0 -163
- package/docs/prompt-templates.md +0 -67
- package/docs/providers.md +0 -147
- package/docs/rpc.md +0 -1048
- package/docs/sdk.md +0 -969
- package/docs/session.md +0 -412
- package/docs/settings.md +0 -219
- package/docs/shell-aliases.md +0 -13
- package/docs/skills.md +0 -226
- package/docs/subagents.md +0 -225
- package/docs/terminal-setup.md +0 -65
- package/docs/themes.md +0 -295
- package/docs/tree.md +0 -219
- package/docs/tui.md +0 -887
- package/docs/web-tools.md +0 -304
- package/docs/windows.md +0 -17
- package/examples/README.md +0 -25
- package/examples/extensions/README.md +0 -192
- package/examples/extensions/antigravity-image-gen.ts +0 -414
- package/examples/extensions/auto-commit-on-exit.ts +0 -49
- package/examples/extensions/bookmark.ts +0 -50
- package/examples/extensions/claude-rules.ts +0 -86
- package/examples/extensions/confirm-destructive.ts +0 -59
- package/examples/extensions/custom-compaction.ts +0 -115
- package/examples/extensions/custom-footer.ts +0 -65
- package/examples/extensions/custom-header.ts +0 -73
- package/examples/extensions/custom-provider-anthropic/index.ts +0 -605
- package/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
- package/examples/extensions/custom-provider-anthropic/package.json +0 -19
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +0 -350
- package/examples/extensions/custom-provider-gitlab-duo/package.json +0 -16
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -83
- package/examples/extensions/dirty-repo-guard.ts +0 -56
- package/examples/extensions/doom-overlay/README.md +0 -46
- package/examples/extensions/doom-overlay/doom/build/doom.js +0 -21
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +0 -152
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -72
- package/examples/extensions/doom-overlay/doom-component.ts +0 -133
- package/examples/extensions/doom-overlay/doom-engine.ts +0 -173
- package/examples/extensions/doom-overlay/doom-keys.ts +0 -105
- package/examples/extensions/doom-overlay/index.ts +0 -74
- package/examples/extensions/doom-overlay/wad-finder.ts +0 -51
- package/examples/extensions/event-bus.ts +0 -43
- package/examples/extensions/file-trigger.ts +0 -41
- package/examples/extensions/git-checkpoint.ts +0 -53
- package/examples/extensions/handoff.ts +0 -151
- package/examples/extensions/hello.ts +0 -25
- package/examples/extensions/inline-bash.ts +0 -94
- package/examples/extensions/input-transform.ts +0 -43
- package/examples/extensions/interactive-shell.ts +0 -196
- package/examples/extensions/mac-system-theme.ts +0 -47
- package/examples/extensions/message-renderer.ts +0 -60
- package/examples/extensions/modal-editor.ts +0 -86
- package/examples/extensions/model-status.ts +0 -31
- package/examples/extensions/notify.ts +0 -25
- package/examples/extensions/overlay-qa-tests.ts +0 -882
- package/examples/extensions/overlay-test.ts +0 -151
- package/examples/extensions/permission-gate.ts +0 -34
- package/examples/extensions/pirate.ts +0 -47
- package/examples/extensions/plan-mode/README.md +0 -65
- package/examples/extensions/plan-mode/index.ts +0 -341
- package/examples/extensions/plan-mode/utils.ts +0 -168
- package/examples/extensions/preset.ts +0 -399
- package/examples/extensions/protected-paths.ts +0 -30
- package/examples/extensions/qna.ts +0 -120
- package/examples/extensions/question.ts +0 -265
- package/examples/extensions/questionnaire.ts +0 -428
- package/examples/extensions/rainbow-editor.ts +0 -88
- package/examples/extensions/sandbox/index.ts +0 -318
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
- package/examples/extensions/send-user-message.ts +0 -97
- package/examples/extensions/session-name.ts +0 -27
- package/examples/extensions/shutdown-command.ts +0 -63
- package/examples/extensions/snake.ts +0 -344
- package/examples/extensions/space-invaders.ts +0 -561
- package/examples/extensions/ssh.ts +0 -220
- package/examples/extensions/status-line.ts +0 -40
- package/examples/extensions/subagent/README.md +0 -172
- package/examples/extensions/subagent/agents/planner.md +0 -37
- package/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/examples/extensions/subagent/agents/scout.md +0 -50
- package/examples/extensions/subagent/agents/worker.md +0 -24
- package/examples/extensions/subagent/agents.ts +0 -127
- package/examples/extensions/subagent/index.ts +0 -964
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
- package/examples/extensions/summarize.ts +0 -196
- package/examples/extensions/timed-confirm.ts +0 -70
- package/examples/extensions/todo.ts +0 -300
- package/examples/extensions/tool-override.ts +0 -144
- package/examples/extensions/tools.ts +0 -147
- package/examples/extensions/trigger-compact.ts +0 -40
- package/examples/extensions/truncated-tool.ts +0 -193
- package/examples/extensions/widget-placement.ts +0 -17
- package/examples/extensions/with-deps/index.ts +0 -36
- package/examples/extensions/with-deps/package-lock.json +0 -31
- package/examples/extensions/with-deps/package.json +0 -22
- package/examples/sdk/01-minimal.ts +0 -22
- package/examples/sdk/02-custom-model.ts +0 -50
- package/examples/sdk/03-custom-prompt.ts +0 -55
- package/examples/sdk/04-skills.ts +0 -46
- package/examples/sdk/05-tools.ts +0 -56
- package/examples/sdk/06-extensions.ts +0 -88
- package/examples/sdk/07-context-files.ts +0 -40
- package/examples/sdk/08-prompt-templates.ts +0 -47
- package/examples/sdk/09-api-keys-and-oauth.ts +0 -48
- package/examples/sdk/10-settings.ts +0 -38
- package/examples/sdk/11-sessions.ts +0 -48
- package/examples/sdk/12-full-control.ts +0 -82
- package/examples/sdk/13-codex-oauth.ts +0 -37
- package/examples/sdk/README.md +0 -144
|
@@ -1,565 +0,0 @@
|
|
|
1
|
-
# Modes Module - Complete Architecture Guide
|
|
2
|
-
|
|
3
|
-
This document provides comprehensive documentation for the modes module, covering all three execution modes and their implementation details.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
1. [Input System Documentation](#input-system-documentation)
|
|
7
|
-
2. [Theme System Documentation](#theme-system-documentation)
|
|
8
|
-
3. [Key Bindings Reference](#key-bindings-reference)
|
|
9
|
-
4. [Print Mode Details](#print-mode-details)
|
|
10
|
-
5. [RPC Mode Details](#rpc-mode-details)
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Input System Documentation
|
|
15
|
-
|
|
16
|
-
### Input States & State Machine
|
|
17
|
-
|
|
18
|
-
The interactive mode uses a state machine to manage user input across different contexts:
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
States:
|
|
22
|
-
--------
|
|
23
|
-
┌─────────────────────────────────────────────────┐
|
|
24
|
-
│ Input State Machine │
|
|
25
|
-
├─────────────────────────────────────────────────┤
|
|
26
|
-
│ │
|
|
27
|
-
│ NORMAL │
|
|
28
|
-
│ ├── Regular typing → input buffer │
|
|
29
|
-
│ ├── Enter → submit prompt │
|
|
30
|
-
│ ├── Tab → autocomplete │
|
|
31
|
-
│ ├── Escape → clear │
|
|
32
|
-
│ └── Ctrl+K → compaction mode │
|
|
33
|
-
│ │
|
|
34
|
-
│ SELECTING (Model/Session/Config selector) │
|
|
35
|
-
│ ├── Up/Down → navigate options │
|
|
36
|
-
│ ├── Enter → select option │
|
|
37
|
-
│ ├── Escape → cancel selection │
|
|
38
|
-
│ └── Type → filter options │
|
|
39
|
-
│ │
|
|
40
|
-
│ EDITING (Multi-line editor) │
|
|
41
|
-
│ ├── Alt+Enter → new line │
|
|
42
|
-
│ ├── Ctrl+D → exit edit mode │
|
|
43
|
-
│ ├── Up/Down → navigate history │
|
|
44
|
-
│ └── Ctrl+A/E → line start/end │
|
|
45
|
-
│ │
|
|
46
|
-
│ WAITING (Agent is processing) │
|
|
47
|
-
│ ├── Ctrl+C → cancel request │
|
|
48
|
-
│ ├── Display read-only output │
|
|
49
|
-
│ └── Prevent new input │
|
|
50
|
-
│ │
|
|
51
|
-
└─────────────────────────────────────────────────┘
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Input Handling Pipeline
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
User Input
|
|
58
|
-
↓
|
|
59
|
-
InputHandler.parseInput()
|
|
60
|
-
↓
|
|
61
|
-
Check Extension Shortcuts (highest priority)
|
|
62
|
-
↓
|
|
63
|
-
Check App-level Keybindings (e.g., Ctrl+C)
|
|
64
|
-
↓
|
|
65
|
-
Check Slash Commands (/exit, /save, /branch, etc.)
|
|
66
|
-
↓
|
|
67
|
-
Validate Input
|
|
68
|
-
↓
|
|
69
|
-
Route to Handler
|
|
70
|
-
├─ Agent prompt → submit to session
|
|
71
|
-
├─ Command → execute command
|
|
72
|
-
└─ Extension action → pass to extension
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Key Binding System
|
|
76
|
-
|
|
77
|
-
The CustomEditor component extends the base Editor with app-level keybindings management:
|
|
78
|
-
|
|
79
|
-
**Key Binding Levels (priority order):**
|
|
80
|
-
|
|
81
|
-
1. **Extension Shortcuts** (highest priority)
|
|
82
|
-
- Registered by extensions
|
|
83
|
-
- Custom keybindings for extension actions
|
|
84
|
-
- Example: Extension registers Ctrl+Shift+T for test runner
|
|
85
|
-
|
|
86
|
-
2. **App-Level Actions** (medium priority)
|
|
87
|
-
- interrupt (Ctrl+C, Escape) - cancel operation
|
|
88
|
-
- pasteImage (Ctrl+Shift+V) - paste image from clipboard
|
|
89
|
-
- submitPrompt (Enter) - submit prompt
|
|
90
|
-
- compaction (Ctrl+K) - enter compaction mode
|
|
91
|
-
- Example: Ctrl+D to exit
|
|
92
|
-
|
|
93
|
-
3. **Editor Keybindings** (lowest priority)
|
|
94
|
-
- Arrow keys, Ctrl+A/E, backspace, etc.
|
|
95
|
-
- Standard terminal editor shortcuts
|
|
96
|
-
|
|
97
|
-
**Slash Commands** (text-based):
|
|
98
|
-
|
|
99
|
-
Commands starting with "/" are parsed as slash commands:
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
/exit, /quit - Exit interactive mode
|
|
103
|
-
/save - Save session to disk
|
|
104
|
-
/branch [name] - Create new session branch
|
|
105
|
-
/switch [id] - Switch to different session
|
|
106
|
-
/compact - Run compaction algorithm
|
|
107
|
-
/clear - Clear screen
|
|
108
|
-
/help - Show help
|
|
109
|
-
/models - List available models
|
|
110
|
-
/settings - Show settings dialog
|
|
111
|
-
/theme [name] - Change theme
|
|
112
|
-
/sessions - Browse session tree
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Autocomplete System
|
|
116
|
-
|
|
117
|
-
Triggered with Ctrl+Space during text input:
|
|
118
|
-
|
|
119
|
-
**Autocomplete Sources:**
|
|
120
|
-
1. **Slash Commands** - `/exit`, `/save`, `/branch`, etc.
|
|
121
|
-
2. **Bash Commands** - Common shell commands when prefixed with `$`
|
|
122
|
-
3. **File Paths** - When typing file paths (starting with `.` or `/`)
|
|
123
|
-
4. **Session IDs** - When switching sessions
|
|
124
|
-
5. **Model Names** - When selecting models
|
|
125
|
-
6. **Recent Inputs** - Previously typed prompts
|
|
126
|
-
|
|
127
|
-
**Autocomplete Behavior:**
|
|
128
|
-
- Filters suggestions based on typed text
|
|
129
|
-
- Shows description for each suggestion
|
|
130
|
-
- Press Up/Down to navigate suggestions
|
|
131
|
-
- Press Enter to accept suggestion
|
|
132
|
-
- Press Escape to dismiss autocomplete
|
|
133
|
-
|
|
134
|
-
### Command History
|
|
135
|
-
|
|
136
|
-
The editor maintains a command history for easy recall:
|
|
137
|
-
|
|
138
|
-
- **Up Arrow** - Previous command
|
|
139
|
-
- **Down Arrow** - Next command
|
|
140
|
-
- **Ctrl+R** - Reverse search in history
|
|
141
|
-
- **Ctrl+S** - Forward search in history
|
|
142
|
-
|
|
143
|
-
History is persisted per session and includes:
|
|
144
|
-
- User prompts sent to agent
|
|
145
|
-
- Slash commands executed
|
|
146
|
-
- Settings changes
|
|
147
|
-
- Model/session selections
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## Theme System Documentation
|
|
152
|
-
|
|
153
|
-
### Theme Structure
|
|
154
|
-
|
|
155
|
-
Each theme is defined as a JSON file with the following structure:
|
|
156
|
-
|
|
157
|
-
```json
|
|
158
|
-
{
|
|
159
|
-
"name": "theme-name",
|
|
160
|
-
"extends": "default",
|
|
161
|
-
"colors": {
|
|
162
|
-
"agent": {
|
|
163
|
-
"fg": "blue",
|
|
164
|
-
"bg": null,
|
|
165
|
-
"bold": false,
|
|
166
|
-
"dim": false,
|
|
167
|
-
"italic": false
|
|
168
|
-
},
|
|
169
|
-
"user": {
|
|
170
|
-
"fg": "white",
|
|
171
|
-
"bold": true
|
|
172
|
-
},
|
|
173
|
-
"error": {
|
|
174
|
-
"fg": "red",
|
|
175
|
-
"bg": "black"
|
|
176
|
-
},
|
|
177
|
-
// ... more colors
|
|
178
|
-
},
|
|
179
|
-
"layout": {
|
|
180
|
-
"indent": 2,
|
|
181
|
-
"messageSpacing": 1,
|
|
182
|
-
"toolIndent": 4,
|
|
183
|
-
"maxWidth": 120
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Available Colors
|
|
189
|
-
|
|
190
|
-
**Message Colors:**
|
|
191
|
-
- `agent` - AI assistant messages
|
|
192
|
-
- `user` - User prompt messages
|
|
193
|
-
- `assistant` - Assistant thinking/state
|
|
194
|
-
- `error` - Error messages
|
|
195
|
-
- `warning` - Warning messages
|
|
196
|
-
- `info` - Information messages
|
|
197
|
-
- `success` - Success messages
|
|
198
|
-
|
|
199
|
-
**Component Colors:**
|
|
200
|
-
- `tool` - Tool names and headers
|
|
201
|
-
- `toolInput` - Tool input parameters
|
|
202
|
-
- `toolOutput` - Tool output display
|
|
203
|
-
- `code` - Code blocks and syntax
|
|
204
|
-
- `codeKeyword` - Code keywords
|
|
205
|
-
- `codeString` - Code string literals
|
|
206
|
-
- `bash` - Bash command output
|
|
207
|
-
- `bashError` - Bash error output
|
|
208
|
-
|
|
209
|
-
**UI Colors:**
|
|
210
|
-
- `selection` - Selected item in list
|
|
211
|
-
- `border` - Box borders and dividers
|
|
212
|
-
- `header` - Header text
|
|
213
|
-
- `footer` - Footer text
|
|
214
|
-
- `cursor` - Text cursor
|
|
215
|
-
- `scrollbar` - Scrollbar indicator
|
|
216
|
-
|
|
217
|
-
### Available Color Values
|
|
218
|
-
|
|
219
|
-
Standard ANSI colors:
|
|
220
|
-
- `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
|
|
221
|
-
- `brightBlack`, `brightRed`, `brightGreen`, `brightYellow`, `brightBlue`, `brightMagenta`, `brightCyan`, `brightWhite`
|
|
222
|
-
|
|
223
|
-
Special values:
|
|
224
|
-
- `null` - Inherit from terminal default
|
|
225
|
-
- `#RRGGBB` - Hex colors (if terminal supports 24-bit colors)
|
|
226
|
-
|
|
227
|
-
### Text Attributes
|
|
228
|
-
|
|
229
|
-
Each color can have these attributes:
|
|
230
|
-
- `bold: true|false` - Bold text
|
|
231
|
-
- `dim: true|false` - Dimmed/faint text
|
|
232
|
-
- `italic: true|false` - Italic text (if supported)
|
|
233
|
-
- `underline: true|false` - Underlined text (if supported)
|
|
234
|
-
- `inverse: true|false` - Inverted colors
|
|
235
|
-
- `strikethrough: true|false` - Strikethrough text (if supported)
|
|
236
|
-
|
|
237
|
-
### Creating a Custom Theme
|
|
238
|
-
|
|
239
|
-
**Step 1: Create theme file**
|
|
240
|
-
```
|
|
241
|
-
mkdir -p ~/.indusagi/themes
|
|
242
|
-
cat > ~/.indusagi/themes/mytheme.json << 'EOF'
|
|
243
|
-
{
|
|
244
|
-
"name": "mytheme",
|
|
245
|
-
"extends": "dark",
|
|
246
|
-
"colors": {
|
|
247
|
-
"agent": {
|
|
248
|
-
"fg": "cyan"
|
|
249
|
-
},
|
|
250
|
-
"user": {
|
|
251
|
-
"fg": "brightGreen",
|
|
252
|
-
"bold": true
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
EOF
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
**Step 2: Use the theme**
|
|
260
|
-
```bash
|
|
261
|
-
indusagi --theme=mytheme
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
**Step 3: Set as default** (optional)
|
|
265
|
-
```bash
|
|
266
|
-
indusagi config set theme mytheme
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### Theme Loading & Hot Reload
|
|
270
|
-
|
|
271
|
-
**Loading Process:**
|
|
272
|
-
1. Check user's `~/.indusagi/themes/` directory
|
|
273
|
-
2. Check built-in themes in package
|
|
274
|
-
3. Validate against JSON schema
|
|
275
|
-
4. Merge with parent theme (if `extends` is set)
|
|
276
|
-
5. Apply defaults for missing properties
|
|
277
|
-
6. Load custom fonts (if specified)
|
|
278
|
-
|
|
279
|
-
**Hot Reload:**
|
|
280
|
-
The theme system watches for file changes in `~/.indusagi/themes/`:
|
|
281
|
-
- If theme file is modified, changes apply immediately
|
|
282
|
-
- No need to restart the application
|
|
283
|
-
- Useful for iterating on custom themes
|
|
284
|
-
|
|
285
|
-
### Theme Validation
|
|
286
|
-
|
|
287
|
-
All themes are validated against `theme-schema.json` which enforces:
|
|
288
|
-
- Required fields (name)
|
|
289
|
-
- Valid color names
|
|
290
|
-
- Valid attribute types
|
|
291
|
-
- Proper nesting of properties
|
|
292
|
-
- Type correctness
|
|
293
|
-
|
|
294
|
-
---
|
|
295
|
-
|
|
296
|
-
## Key Bindings Reference
|
|
297
|
-
|
|
298
|
-
### Default Interactive Mode Keybindings
|
|
299
|
-
|
|
300
|
-
**Editor Navigation:**
|
|
301
|
-
| Keybinding | Action |
|
|
302
|
-
|------------|--------|
|
|
303
|
-
| Ctrl+A | Move to start of line |
|
|
304
|
-
| Ctrl+E | Move to end of line |
|
|
305
|
-
| Ctrl+B | Move cursor back (left) |
|
|
306
|
-
| Ctrl+F | Move cursor forward (right) |
|
|
307
|
-
| Alt+B | Move word backward |
|
|
308
|
-
| Alt+F | Move word forward |
|
|
309
|
-
|
|
310
|
-
**Editing:**
|
|
311
|
-
| Keybinding | Action |
|
|
312
|
-
|------------|--------|
|
|
313
|
-
| Backspace | Delete character before cursor |
|
|
314
|
-
| Delete | Delete character at cursor |
|
|
315
|
-
| Ctrl+D | Exit editor / delete char at cursor |
|
|
316
|
-
| Ctrl+H | Backspace (alternative) |
|
|
317
|
-
| Ctrl+K | Delete to end of line |
|
|
318
|
-
| Ctrl+U | Delete to start of line |
|
|
319
|
-
| Ctrl+W | Delete word before cursor |
|
|
320
|
-
| Alt+D | Delete word after cursor |
|
|
321
|
-
|
|
322
|
-
**Multi-line Editing:**
|
|
323
|
-
| Keybinding | Action |
|
|
324
|
-
|------------|--------|
|
|
325
|
-
| Enter | Submit prompt (if not in edit mode) |
|
|
326
|
-
| Alt+Enter | New line (while in edit mode) |
|
|
327
|
-
| Ctrl+M | Alternative: new line |
|
|
328
|
-
|
|
329
|
-
**History Navigation:**
|
|
330
|
-
| Keybinding | Action |
|
|
331
|
-
|------------|--------|
|
|
332
|
-
| Up Arrow | Previous command in history |
|
|
333
|
-
| Down Arrow | Next command in history |
|
|
334
|
-
| Ctrl+R | Reverse search in history |
|
|
335
|
-
| Ctrl+S | Forward search in history |
|
|
336
|
-
| Ctrl+P | Previous (alternative to Up) |
|
|
337
|
-
| Ctrl+N | Next (alternative to Down) |
|
|
338
|
-
|
|
339
|
-
**Special Actions:**
|
|
340
|
-
| Keybinding | Action |
|
|
341
|
-
|------------|--------|
|
|
342
|
-
| Ctrl+C | Cancel current operation / interrupt agent |
|
|
343
|
-
| Escape | Exit autocomplete / dismiss dialog |
|
|
344
|
-
| Ctrl+Space | Trigger autocomplete |
|
|
345
|
-
| Ctrl+Shift+V | Paste image from clipboard |
|
|
346
|
-
| Tab | Autocomplete (if showing suggestions) |
|
|
347
|
-
|
|
348
|
-
**Session/Mode Commands (Slash Commands):**
|
|
349
|
-
| Command | Action |
|
|
350
|
-
|---------|--------|
|
|
351
|
-
| /exit, /quit | Exit interactive mode |
|
|
352
|
-
| /save | Save session to disk |
|
|
353
|
-
| /branch [name] | Create new session branch |
|
|
354
|
-
| /switch [id] | Switch to different session |
|
|
355
|
-
| /compact | Run compaction on messages |
|
|
356
|
-
| /clear | Clear screen |
|
|
357
|
-
| /help | Show help |
|
|
358
|
-
| /models | List available models |
|
|
359
|
-
| /theme [name] | Change active theme |
|
|
360
|
-
| /sessions | Browse session tree |
|
|
361
|
-
|
|
362
|
-
### Customizing Keybindings
|
|
363
|
-
|
|
364
|
-
Keybindings can be customized via configuration:
|
|
365
|
-
|
|
366
|
-
```json
|
|
367
|
-
{
|
|
368
|
-
"keybindings": {
|
|
369
|
-
"interrupt": ["ctrl+c", "ctrl+x"],
|
|
370
|
-
"submitPrompt": ["enter"],
|
|
371
|
-
"pasteImage": ["ctrl+shift+v"],
|
|
372
|
-
"customAction": ["ctrl+alt+s"]
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
---
|
|
378
|
-
|
|
379
|
-
## Print Mode Details
|
|
380
|
-
|
|
381
|
-
### Output Format Specifications
|
|
382
|
-
|
|
383
|
-
**JSON Mode** - Machine-readable event stream:
|
|
384
|
-
```json
|
|
385
|
-
{"type": "message_start", "role": "user", "content": "Hello"}
|
|
386
|
-
{"type": "agent_start", "model": "gpt-4"}
|
|
387
|
-
{"type": "message_start", "role": "assistant", "content": "Hi there!"}
|
|
388
|
-
{"type": "message_end"}
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
**TEXT Mode** - Human-readable output:
|
|
392
|
-
```
|
|
393
|
-
User: Hello
|
|
394
|
-
Agent: Hi there!
|
|
395
|
-
|
|
396
|
-
Session: abc123
|
|
397
|
-
Model: gpt-4
|
|
398
|
-
Tokens: 1,523 (est. ~1,142 words)
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
**COMPACT Mode** - Minimal output:
|
|
402
|
-
```
|
|
403
|
-
Hi there!
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
### Exit Codes
|
|
407
|
-
|
|
408
|
-
| Code | Meaning | Use Case |
|
|
409
|
-
|------|---------|----------|
|
|
410
|
-
| 0 | Success | All operations completed successfully |
|
|
411
|
-
| 1 | General Error | Unexpected error during execution |
|
|
412
|
-
| 2 | Invalid Arguments | Invalid CLI arguments or options |
|
|
413
|
-
| 3 | Session Not Found | Specified session doesn't exist |
|
|
414
|
-
| 4 | Tool Execution Failed | Error executing a tool or bash command |
|
|
415
|
-
| 5 | Model Error | Model unavailable, quota exceeded, etc. |
|
|
416
|
-
| 6 | Timeout | Operation exceeded time limit |
|
|
417
|
-
| 127 | Unknown Error | Unhandled exception or unknown error |
|
|
418
|
-
|
|
419
|
-
---
|
|
420
|
-
|
|
421
|
-
## RPC Mode Details
|
|
422
|
-
|
|
423
|
-
### RPC Protocol Basics
|
|
424
|
-
|
|
425
|
-
JSON-RPC 2.0 over stdin/stdout or Unix socket:
|
|
426
|
-
|
|
427
|
-
```json
|
|
428
|
-
// Command with ID (expects response)
|
|
429
|
-
{
|
|
430
|
-
"jsonrpc": "2.0",
|
|
431
|
-
"id": "req-1",
|
|
432
|
-
"method": "prompt",
|
|
433
|
-
"params": {
|
|
434
|
-
"message": "What does this code do?"
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// Response
|
|
439
|
-
{
|
|
440
|
-
"jsonrpc": "2.0",
|
|
441
|
-
"id": "req-1",
|
|
442
|
-
"result": {
|
|
443
|
-
"success": true,
|
|
444
|
-
"message": "This code..."
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
// Notification (no response expected)
|
|
449
|
-
{
|
|
450
|
-
"jsonrpc": "2.0",
|
|
451
|
-
"method": "ping"
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// Event (sent from server to client)
|
|
455
|
-
{
|
|
456
|
-
"jsonrpc": "2.0",
|
|
457
|
-
"method": "event",
|
|
458
|
-
"params": {
|
|
459
|
-
"type": "agent_start",
|
|
460
|
-
"timestamp": 1677000000000
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
### RPC Command Categories
|
|
466
|
-
|
|
467
|
-
**Session Management:**
|
|
468
|
-
- `session.create` - Create new session
|
|
469
|
-
- `session.list` - List available sessions
|
|
470
|
-
- `session.load` - Load session by ID
|
|
471
|
-
- `session.save` - Save current session
|
|
472
|
-
- `session.export` - Export session to HTML/JSON
|
|
473
|
-
- `session.delete` - Delete session
|
|
474
|
-
|
|
475
|
-
**Prompting:**
|
|
476
|
-
- `prompt` - Send prompt to agent
|
|
477
|
-
- `followUp` - Send follow-up without waiting
|
|
478
|
-
- `steer` - Queue prompt during execution
|
|
479
|
-
|
|
480
|
-
**Model Control:**
|
|
481
|
-
- `setModel` - Change active model
|
|
482
|
-
- `getModels` - List available models
|
|
483
|
-
- `setThinking` - Set thinking level
|
|
484
|
-
|
|
485
|
-
**State Management:**
|
|
486
|
-
- `compact` - Run compaction
|
|
487
|
-
- `branch` - Create session branch
|
|
488
|
-
- `undo` - Undo last action
|
|
489
|
-
- `getState` - Get session state
|
|
490
|
-
|
|
491
|
-
**Bash Commands:**
|
|
492
|
-
- `bash.execute` - Run bash command
|
|
493
|
-
- `bash.kill` - Kill running bash process
|
|
494
|
-
|
|
495
|
-
### RPC Error Codes
|
|
496
|
-
|
|
497
|
-
| Code | Category | Meaning |
|
|
498
|
-
|------|----------|---------|
|
|
499
|
-
| -32700 | Parse Error | Invalid JSON received |
|
|
500
|
-
| -32600 | Invalid Request | Malformed request object |
|
|
501
|
-
| -32601 | Method Not Found | Unknown method called |
|
|
502
|
-
| -32602 | Invalid Params | Invalid method parameters |
|
|
503
|
-
| -32603 | Internal Error | Server error |
|
|
504
|
-
| -32000 | Server Error: Session not found |
|
|
505
|
-
| -32001 | Server Error: Invalid prompt |
|
|
506
|
-
| -32002 | Server Error: Tool execution failed |
|
|
507
|
-
| -32003 | Server Error: Model error |
|
|
508
|
-
| -32004 | Server Error: Timeout |
|
|
509
|
-
| -32005 | Server Error: Authentication required |
|
|
510
|
-
|
|
511
|
-
### RPC Authentication & Security
|
|
512
|
-
|
|
513
|
-
**Supported Methods:**
|
|
514
|
-
1. **Token-based** - Pass token in header or params
|
|
515
|
-
2. **File-based** - Read token from `~/.indusagi/rpc-token`
|
|
516
|
-
3. **Environment** - `INDUSAGI_RPC_TOKEN` env var
|
|
517
|
-
4. **No Auth** - For local/trusted connections only
|
|
518
|
-
|
|
519
|
-
**Security Considerations:**
|
|
520
|
-
- Always use HTTPS/Unix sockets for remote connections
|
|
521
|
-
- Never expose RPC over public networks without auth
|
|
522
|
-
- Token should have sufficient entropy (32+ bytes)
|
|
523
|
-
- Rotate tokens regularly for long-lived connections
|
|
524
|
-
- Log all RPC calls for audit trails
|
|
525
|
-
|
|
526
|
-
### RPC Connection Management
|
|
527
|
-
|
|
528
|
-
**Lifecycle:**
|
|
529
|
-
|
|
530
|
-
```
|
|
531
|
-
Client Server
|
|
532
|
-
│ │
|
|
533
|
-
├─ Connect ──────────────>│
|
|
534
|
-
│ │
|
|
535
|
-
├─ Subscribe events ──────>│
|
|
536
|
-
│ │
|
|
537
|
-
├─ Send commands ────────>│
|
|
538
|
-
│ <──── Responses
|
|
539
|
-
│ <──── Events
|
|
540
|
-
│ │
|
|
541
|
-
├─ Disconnect ──────────>│
|
|
542
|
-
│ │
|
|
543
|
-
```
|
|
544
|
-
|
|
545
|
-
**Connection Options:**
|
|
546
|
-
- `host` - Server hostname (default: localhost)
|
|
547
|
-
- `port` - Server port (default: 3000)
|
|
548
|
-
- `socket` - Unix socket path (prefer over TCP)
|
|
549
|
-
- `timeout` - Request timeout in ms (default: 30000)
|
|
550
|
-
- `retries` - Number of retries on failure (default: 3)
|
|
551
|
-
|
|
552
|
-
**Reconnection Strategy:**
|
|
553
|
-
- Exponential backoff: 100ms, 200ms, 400ms, 800ms...
|
|
554
|
-
- Max delay: 30 seconds
|
|
555
|
-
- Automatic reconnection on disconnect
|
|
556
|
-
- Requeue pending requests after reconnect
|
|
557
|
-
|
|
558
|
-
---
|
|
559
|
-
|
|
560
|
-
## Additional Resources
|
|
561
|
-
|
|
562
|
-
- See `src/modes/shared.ts` for utility functions
|
|
563
|
-
- See `src/modes/interactive-mode.ts` for event handling
|
|
564
|
-
- See `src/modes/print-mode.ts` for output formatting
|
|
565
|
-
- See `src/modes/rpc/` for RPC implementation
|