From 0050a0ed5076c0c2d6e895bedc2aa340f36d07a9 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Sun, 19 Apr 2026 11:28:39 +0000 Subject: [PATCH 1/2] fix: detect dollar prefix as shell mode trigger in InputModeRouter The spec requires both ! and dollar sign to activate shell mode, but detect_mode() only recognised ! as the shell mode trigger. This caused dollar-prefixed inputs like dollar-sign-echo-hello to be routed to NORMAL mode instead of SHELL mode. - Add dollar sign to detect_mode() shell prefix check alongside ! - Add BDD tests for dollar prefix shell mode detection - Add step definitions for detect_mode() direct testing Closes #10412 --- features/steps/tui_input_modes_steps.py | 10 ++++++++++ features/tui_input_modes.feature | 20 ++++++++++++++++++++ src/cleveragents/tui/input/modes.py | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/features/steps/tui_input_modes_steps.py b/features/steps/tui_input_modes_steps.py index 38f8ae327..3477e5cc8 100644 --- a/features/steps/tui_input_modes_steps.py +++ b/features/steps/tui_input_modes_steps.py @@ -143,3 +143,13 @@ def step_run_fallback_tui_app(context: Context) -> None: def step_fallback_tui_fails(context: Context, message: str) -> None: assert context.tui_fallback_error is not None assert message in str(context.tui_fallback_error) + + +@when('I detect mode for "{text}"') +def step_detect_mode(context: Context, text: str) -> None: + context.detected_mode = InputModeRouter.detect_mode(text) + + +@then('the detected mode should be "{mode}"') +def step_detected_mode_equals(context: Context, mode: str) -> None: + assert context.detected_mode.value == mode diff --git a/features/tui_input_modes.feature b/features/tui_input_modes.feature index 954e7cc12..52c60ece9 100644 --- a/features/tui_input_modes.feature +++ b/features/tui_input_modes.feature @@ -37,3 +37,23 @@ Feature: TUI input modes Then TUI textual availability should be boolean When I run fallback TUI app Then fallback TUI app should fail with "Textual dependency missing." + + Scenario: Dollar prefix activates shell mode + When I route TUI input "$echo hello" + Then the TUI mode should be "shell" + And the TUI shell stdout should contain "hello" + + Scenario: Dollar prefix detect_mode returns shell + When I detect mode for "$echo hello" + Then the detected mode should be "shell" + + + Scenario: Dollar prefix with leading whitespace activates shell mode + When I detect mode for " $echo hello" + Then the detected mode should be "shell" + + + Scenario: Dollar prefix blocks dangerous command by default + When I route TUI input "$rm -rf /" + Then the TUI mode should be "shell" + And the TUI shell stderr should contain "blocked dangerous shell command" diff --git a/src/cleveragents/tui/input/modes.py b/src/cleveragents/tui/input/modes.py index 76231444c..7b6728c08 100644 --- a/src/cleveragents/tui/input/modes.py +++ b/src/cleveragents/tui/input/modes.py @@ -51,7 +51,7 @@ class InputModeRouter: stripped = text.lstrip() if stripped.startswith("/"): return InputMode.COMMAND - if stripped.startswith("!"): + if stripped.startswith(("!", "$")): return InputMode.SHELL return InputMode.NORMAL -- 2.52.0 From c539143ef29e3c672b96efd71813842b0e7742c4 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Thu, 23 Apr 2026 21:54:04 +0000 Subject: [PATCH 2/2] ci: retrigger CI pipeline -- 2.52.0