Skip to content

feat: bang (!) commands — shell exec via spawned task with timeout - #404

Open
alecuba16 wants to merge 1 commit into
Kuberwastaken:mainfrom
alecuba16:pr388-bang
Open

feat: bang (!) commands — shell exec via spawned task with timeout#404
alecuba16 wants to merge 1 commit into
Kuberwastaken:mainfrom
alecuba16:pr388-bang

Conversation

@alecuba16

Copy link
Copy Markdown

Split from #388 (bang + yolo + poke). This PR contains only the bang commands feature.

What it does: Execute shell commands directly from the prompt with ! prefix. Disabled by default (opt-in via bangCommands.enabled in settings).

Security improvements over the original #388 implementation:

  • Spawned task, not synchronous: Command runs in tokio::task::spawn_blocking wrapped in tokio::time::timeout(60s). The TUI event loop never blocks.
  • Timeout: 60-second hard limit. If the command doesn't finish, the user sees "Command timed out after 60 seconds."
  • Output cap: 100KB max output. Beyond that, output is truncated with a notice.
  • Cross-platform: Uses sh -c on Unix, cmd /C on Windows. No hardcoded bash.
  • Plan mode blocked: Bang commands are disabled in plan mode.
  • No duplicate interception: The ! is intercepted only at the prompt submission path in run_interactive (run.rs), not in multiple places.

Config:

{
  "config": {
    "bangCommands": {
      "enabled": true,
      "showInTranscript": true
    }
  }
}

bangCommands.enabled is global-only in the Settings merge (project settings cannot enable it when global is disabled).

5 files, +175 lines, 0 deletions. No CRLF/LF churn.

Execute shell commands directly from the prompt with ! prefix.
Disabled by default (opt-in via bangCommands.enabled in settings).

- Spawned subprocess with 60s timeout (not synchronous on event loop)
- Output capped at 100KB to prevent OOM
- Cross-platform: sh on Unix, cmd on Windows (no hardcoded bash)
- Blocked in plan mode
- Result displayed as a notification when showInTranscript is true

Addresses PR Kuberwastaken#388 review point 3: bang exec moved from synchronous
bash -c .output() to spawned task with timeout and output cap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant