Elffuss BraidHub

kikocis/continue public

88f9397dc3b6 · 3.7 KiBRenderedRawPermalink
1Bash Mode (CLI TUI)
2
3Overview
4
5- Bash 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
8Activation
9
10- Bash mode is activated when the current input (trimmed) starts with !
11 - Example: "!git status" or " !ls -la" both activate Bash 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 bash mode".
16
17Deactivation / Exiting Bash Mode
18
19- Pressing Enter to submit the input exits bash mode immediately after submission, regardless of the command result.
20- Pressing Esc when the input (trimmed) is exactly ! clears the input and exits bash mode.
21- Editing the input so it no longer starts with ! also exits bash mode and restores normal input behavior.
22
23Interaction with other input helpers
24
25- When in bash 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
31Submission behavior
32
33- On submit (Enter) with a bash-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 Bash tool call, with status set to calling, so users can see that the command is in progress.
36 - The bash command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated.
37
38Execution semantics
39
40- The command is executed from the current working directory of the CLI process.
41- The command runs in the user’s shell as a login shell:
42 - Unix/macOS: SHELL (or /bin/bash) invoked with -l -c "<command>".
43 - Windows: powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "<command>".
44- The child process stdin is detached (not connected to the TTY). This prevents the TUI from being suspended by job control. Consequences:
45 - Interactive commands that require stdin will not work.
46- Environment variables are inherited from the parent process. Aliases/functions availability depends on the user’s shell configuration and is not guaranteed.
47
48Output handling
49
50- Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success.
51- If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown.
52- Output is truncated to the first 5000 lines if exceeded.
53- Timeout behavior: If no output is received for 30 seconds (configurable in tests), the process is terminated and the result includes a note like:
54 "[Command timed out after 30 seconds of no output]".
55
56Keyboard behaviors (summary)
57
58- Enter: submit input. If in bash mode, exits bash mode after submission and shows the pending Bash tool call immediately.
59- Shift+Enter: new line.
60- Backslash (\) at end-of-line: inserts a new line (line continuation) as usual.
61- Esc: if only ! (trimmed) is present, clears input and exits bash mode; otherwise cancels streaming or closes suggestions depending on context.
62
63Scope / Modes
64
65- Bash mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing.
66
67Error handling
68
69- Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available).
70
71Examples
72
73- "!git status" → shows a Bash tool call immediately, then populates with the git status output.
74- "!echo hello" → shows a Bash tool call immediately, then output "hello".
75- "!some-unknown-cmd" → shows a Bash tool call immediately, then sets status to error with an error message.