| 1 | shell Mode (CLI TUI) |
| 2 | |
| 3 | Overview |
| 4 | |
| 5 | - shell mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!). |
| 6 | - It is intended for quick terminal command execution without leaving the TUI. |
| 7 | |
| 8 | Activation |
| 9 | |
| 10 | - shell mode is activated when the current input (trimmed) starts with ! |
| 11 | - Example: "!git status" or " !ls -la" both activate shell mode. |
| 12 | - Visual indicator: |
| 13 | - Input border color changes to yellow. |
| 14 | - The input prompt indicator changes to a yellow "$". |
| 15 | - The input placeholder includes "! for shell mode". |
| 16 | |
| 17 | Deactivation / Exiting shell Mode |
| 18 | |
| 19 | - Pressing Enter to submit the input exits shell mode immediately after submission, regardless of the command result. |
| 20 | - Pressing Esc when the input (trimmed) is exactly ! clears the input and exits shell mode. |
| 21 | - Editing the input so it no longer starts with ! also exits shell mode and restores normal input behavior. |
| 22 | |
| 23 | Interaction with other input helpers |
| 24 | |
| 25 | - When in shell mode (input starts with !): |
| 26 | - "@" file search suggestions are disabled. |
| 27 | - "/" slash command UI is disabled. |
| 28 | - When in slash command mode (input starts with /): |
| 29 | - "@" file search suggestions are disabled. |
| 30 | |
| 31 | Submission behavior |
| 32 | |
| 33 | - On submit (Enter) with a shell-mode input: |
| 34 | - The leading ! is removed and the remainder is treated as the shell command to run. |
| 35 | - The TUI immediately appends an assistant message representing a shell tool call, with status set to calling, so users can see that the command is in progress. |
| 36 | - The shell command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated. |
| 37 | |
| 38 | Execution semantics |
| 39 | |
| 40 | - The command is executed in the same way as terminal tool commands, minus permissions |
| 41 | |
| 42 | Output handling |
| 43 | |
| 44 | - Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success. |
| 45 | - If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown. |
| 46 | - Output is truncated to the first 5000 lines if exceeded. |
| 47 | - Timeout behavior: If no output is received for 30 seconds (configurable in tests), the process is terminated and the result includes a note like: |
| 48 | "[Command timed out after 30 seconds of no output]". |
| 49 | |
| 50 | Keyboard behaviors (summary) |
| 51 | |
| 52 | - Enter: submit input. If in shell mode, exits shell mode after submission and shows the pending shell tool call immediately. |
| 53 | - Shift+Enter: new line. |
| 54 | - Backslash (\) at end-of-line: inserts a new line (line continuation) as usual. |
| 55 | - Esc: if only ! (trimmed) is present, clears input and exits shell mode; otherwise cancels streaming or closes suggestions depending on context. |
| 56 | |
| 57 | Scope / Modes |
| 58 | |
| 59 | - shell mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing. |
| 60 | |
| 61 | Error handling |
| 62 | |
| 63 | - Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available). |
| 64 | |
| 65 | Examples |
| 66 | |
| 67 | - "!git status" → shows a shell tool call immediately, then populates with the git status output. |
| 68 | - "!echo hello" → shows a shell tool call immediately, then output "hello". |
| 69 | - "!some-unknown-cmd" → shows a shell tool call immediately, then sets status to error with an error message. |
| 70 | Shell Mode (CLI TUI) |
| 71 | |
| 72 | Overview |
| 73 | |
| 74 | - Shell mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!). |
| 75 | - It is intended for quick terminal command execution without leaving the TUI. |
| 76 | |
| 77 | Activation |
| 78 | |
| 79 | - Shell mode is activated when the current input (trimmed) starts with ! |
| 80 | - Example: "!git status" or " !ls -la" both activate Shell mode. |
| 81 | - Visual indicator: |
| 82 | - Input border color changes to yellow. |
| 83 | - The input prompt indicator changes to a yellow "$". |
| 84 | - The input placeholder includes "! for shell mode". |
| 85 | |
| 86 | Deactivation / Exiting Shell Mode |
| 87 | |
| 88 | - Pressing Enter to submit the input exits shell mode immediately after submission, regardless of the command result. |
| 89 | - Pressing Esc when the input (trimmed) is exactly ! clears the input and exits shell mode. |
| 90 | - Editing the input so it no longer starts with ! also exits shell mode and restores normal input behavior. |
| 91 | |
| 92 | Interaction with other input helpers |
| 93 | |
| 94 | - When in shell mode (input starts with !): |
| 95 | - "@" file search suggestions are disabled. |
| 96 | - "/" slash command UI is disabled. |
| 97 | - When in slash command mode (input starts with /): |
| 98 | - "@" file search suggestions are disabled. |
| 99 | |
| 100 | Submission behavior |
| 101 | |
| 102 | - On submit (Enter) with a shell-mode input: |
| 103 | - The leading ! is removed and the remainder is treated as the shell command to run. |
| 104 | - The TUI immediately appends an assistant message representing a Shell tool call, with status set to calling, so users can see that the command is in progress. |
| 105 | - The shell command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated. |
| 106 | |
| 107 | Execution semantics |
| 108 | |
| 109 | - The command is executed in the same way as terminal tool commands, minus permissions, and inserted into the chat history the same. |
| 110 | |
| 111 | Output handling |
| 112 | |
| 113 | - Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success. |
| 114 | - If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown. |
| 115 | - Output is truncated to the first 5000 lines if exceeded. |
| 116 | - Timeout behavior: If no output is received for 30 seconds (configurable in tests), the process is terminated and the result includes a note like: |
| 117 | "[Command timed out after 30 seconds of no output]". |
| 118 | |
| 119 | Keyboard behaviors (summary) |
| 120 | |
| 121 | - Enter: submit input. If in shell mode, exits shell mode after submission and shows the pending Shell tool call immediately. |
| 122 | - Shift+Enter: new line. |
| 123 | - Backslash (\) at end-of-line: inserts a new line (line continuation) as usual. |
| 124 | - Esc: if only ! (trimmed) is present, clears input and exits shell mode; otherwise cancels streaming or closes suggestions depending on context. |
| 125 | |
| 126 | Scope / Modes |
| 127 | |
| 128 | - Shell mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing. |
| 129 | |
| 130 | Error handling |
| 131 | |
| 132 | - Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available). |
| 133 | |
| 134 | Examples |
| 135 | |
| 136 | - "!git status" → shows a Shell tool call immediately, then populates with the git status output. |
| 137 | - "!echo hello" → shows a Shell tool call immediately, then output "hello". |
| 138 | - "!some-unknown-cmd" → shows a Shell tool call immediately, then sets status to error with an error message. |