Elffuss BraidHub

kikocis/continue public

chore: prettier
Changeset7fbb7af6157cec313e6c77bee9731af6921729e1aeb0f01cb8aa37d74edc1993
AuthorDallin Romney <dallinromney@gmail.com> · 2025-09-02 19:20 -07:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-09-02 19:20 -07:00
Parentsadd1a24afaff

Browse the files at this changeset

4 files changed

modified extensions/cli/spec/bash-mode.md +12 −1
@@ -1,23 +1,27 @@
11 Bash Mode (CLI TUI)
22
33 Overview
4+
45 - Bash mode lets users run shell commands directly from the chat input by starting their input with an exclamation mark (!).
56 - It is intended for quick terminal command execution without leaving the TUI.
67
78 Activation
9+
810 - Bash mode is activated when the current input (trimmed) starts with !
9- - Example: "!git status" or " !ls -la" both activate Bash mode.
11+ - Example: "!git status" or " !ls -la" both activate Bash mode.
1012 - Visual indicator:
1113 - Input border color changes to yellow.
1214 - The input prompt indicator changes to a yellow "$".
1315 - The input placeholder includes "! for bash mode".
1416
1517 Deactivation / Exiting Bash Mode
18+
1619 - Pressing Enter to submit the input exits bash mode immediately after submission, regardless of the command result.
1720 - Pressing Esc when the input (trimmed) is exactly ! clears the input and exits bash mode.
1821 - Editing the input so it no longer starts with ! also exits bash mode and restores normal input behavior.
1922
2023 Interaction with other input helpers
24+
2125 - When in bash mode (input starts with !):
2226 - "@" file search suggestions are disabled.
2327 - "/" slash command UI is disabled.
@@ -25,12 +29,14 @@
2529 - "@" file search suggestions are disabled.
2630
2731 Submission behavior
32+
2833 - On submit (Enter) with a bash-mode input:
2934 - The leading ! is removed and the remainder is treated as the shell command to run.
3035 - 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.
3136 - The bash command is executed asynchronously; when it completes, the tool call status is updated to done (or error) and the output is populated.
3237
3338 Execution semantics
39+
3440 - The command is executed from the current working directory of the CLI process.
3541 - The command runs in the user’s shell as a login shell:
3642 - Unix/macOS: SHELL (or /bin/bash) invoked with -l -c "<command>".
@@ -40,6 +46,7 @@
4046 - Environment variables are inherited from the parent process. Aliases/functions availability depends on the user’s shell configuration and is not guaranteed.
4147
4248 Output handling
49+
4350 - Stdout is streamed into memory; Stderr is captured and appended as a trailing "Stderr: ..." section on success.
4451 - If the process exits non-zero and Stderr contains content, the tool call is marked as error and the error text is shown.
4552 - Output is truncated to the first 5000 lines if exceeded.
@@ -47,18 +54,22 @@
4754 "[Command timed out after 30 seconds of no output]".
4855
4956 Keyboard behaviors (summary)
57+
5058 - Enter: submit input. If in bash mode, exits bash mode after submission and shows the pending Bash tool call immediately.
5159 - Shift+Enter: new line.
5260 - Backslash (\) at end-of-line: inserts a new line (line continuation) as usual.
5361 - Esc: if only ! (trimmed) is present, clears input and exits bash mode; otherwise cancels streaming or closes suggestions depending on context.
5462
5563 Scope / Modes
64+
5665 - Bash mode applies to interactive (TUI/standard) CLI usage. It is not part of headless (-p/--print) processing.
5766
5867 Error handling
68+
5969 - Command execution errors are captured and surfaced in the tool call as status error with human-readable error text (including Stderr when available).
6070
6171 Examples
72+
6273 - "!git status" → shows a Bash tool call immediately, then populates with the git status output.
6374 - "!echo hello" → shows a Bash tool call immediately, then output "hello".
6475 - "!some-unknown-cmd" → shows a Bash tool call immediately, then sets status to error with an error message.
modified extensions/cli/src/ui/UserInput.tsx +7 −3
@@ -618,7 +618,8 @@
618618 const renderInputText = () => {
619619 const placeholderText = isRemoteMode
620620 ? "Ask anything, / for slash commands, ! for bash mode"
621- : placeholder || "Ask anything, @ for context, / for slash commands, ! for bash mode";
621+ : placeholder ||
622+ "Ask anything, @ for context, / for slash commands, ! for bash mode";
622623 if (inputText.length === 0) {
623624 return (
624625 <>
@@ -717,8 +718,11 @@
717718 paddingX={1}
718719 borderColor={showBashMode ? "yellow" : isRemoteMode ? "cyan" : "gray"}
719720 >
720- <Text color={showBashMode ? "yellow" : isRemoteMode ? "cyan" : "blue"} bold>
721- {showBashMode ? "$" : isRemoteMode ? "◉" : "●"}
721+ <Text
722+ color={showBashMode ? "yellow" : isRemoteMode ? "cyan" : "blue"}
723+ bold
724+ >
725+ {showBashMode ? "$" : isRemoteMode ? "◉" : "●"}
722726 </Text>
723727 {renderInputText()}
724728 </Box>
modified extensions/cli/src/ui/hooks/useChat.bashMode.test.ts +4 −2
@@ -20,7 +20,9 @@
2020
2121 it("should detect bash mode when message starts with !", async () => {
2222 const mockRun = vi.mocked(runTerminalCommandTool.run);
23- mockRun.mockResolvedValue("total 5\ndrwxr-xr-x 2 user user 4096 Jan 1 12:00 .\ndrwxr-xr-x 3 user user 4096 Jan 1 12:00 ..");
23+ mockRun.mockResolvedValue(
24+ "total 5\ndrwxr-xr-x 2 user user 4096 Jan 1 12:00 .\ndrwxr-xr-x 3 user user 4096 Jan 1 12:00 ..",
25+ );
2426
2527 const ctx = createMinimalTestContext();
2628 const chat = useChat({
@@ -105,4 +107,4 @@
105107
106108 expect(mockRun).toHaveBeenCalledWith({ command: "echo hello" });
107109 });
108-});
No newline at the end of the file
110+});
modified extensions/cli/src/ui/hooks/useChat.ts +7 −3
@@ -349,7 +349,7 @@
349349
350350 // Extract the command after the !
351351 const bashCommand = message.trimStart().slice(1).trim();
352-
352+
353353 if (!bashCommand) {
354354 return message; // No command provided, treat as regular message
355355 }
@@ -373,8 +373,12 @@
373373 // Execute the bash command asynchronously - don't block UI
374374 (async () => {
375375 try {
376- const { runTerminalCommandTool } = await import("../../tools/runTerminalCommand.js");
377- const result = await runTerminalCommandTool.run({ command: bashCommand });
376+ const { runTerminalCommandTool } = await import(
377+ "../../tools/runTerminalCommand.js"
378+ );
379+ const result = await runTerminalCommandTool.run({
380+ command: bashCommand,
381+ });
378382 services.chatHistory.addToolResult(toolCallId, result, "done");
379383 } catch (error: any) {
380384 const errorMessage = `Bash command failed: ${error?.message || String(error)}`;