From 9b2048b3e8df427d85094c031a722f8990f6d107 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 15 Dec 2025 23:01:02 +0900 Subject: [PATCH] feat(interactive-bash): block tmux output capture commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Block capture-pane, save-buffer, show-buffer, pipe-pane and their aliases in interactive_bash tool. Guide users to use bash tool instead for terminal output capture operations. - Add BLOCKED_TMUX_SUBCOMMANDS list in constants.ts - Add input validation in tools.ts to reject blocked commands - Update tool description with blocked commands documentation 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) --- src/tools/interactive-bash/constants.ts | 19 ++++++++++++++++++- src/tools/interactive-bash/tools.ts | 7 ++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/tools/interactive-bash/constants.ts b/src/tools/interactive-bash/constants.ts index 4b83fc7..2dad94c 100644 --- a/src/tools/interactive-bash/constants.ts +++ b/src/tools/interactive-bash/constants.ts @@ -1,5 +1,22 @@ export const DEFAULT_TIMEOUT_MS = 60_000 +export const BLOCKED_TMUX_SUBCOMMANDS = [ + "capture-pane", + "capturep", + "save-buffer", + "saveb", + "show-buffer", + "showb", + "pipe-pane", + "pipep", +] + export const INTERACTIVE_BASH_DESCRIPTION = `Execute tmux commands for interactive terminal session management. -Use session names following the pattern "omo-{name}" for automatic tracking.` +Use session names following the pattern "omo-{name}" for automatic tracking. + +BLOCKED COMMANDS (use bash tool instead): +- capture-pane / capturep: Use bash to read output files or pipe output +- save-buffer / saveb: Use bash to save content to files +- show-buffer / showb: Use bash to read buffer content +- pipe-pane / pipep: Use bash for piping output` diff --git a/src/tools/interactive-bash/tools.ts b/src/tools/interactive-bash/tools.ts index 32ccadd..d9be453 100644 --- a/src/tools/interactive-bash/tools.ts +++ b/src/tools/interactive-bash/tools.ts @@ -1,5 +1,5 @@ import { tool } from "@opencode-ai/plugin/tool" -import { DEFAULT_TIMEOUT_MS, INTERACTIVE_BASH_DESCRIPTION } from "./constants" +import { BLOCKED_TMUX_SUBCOMMANDS, DEFAULT_TIMEOUT_MS, INTERACTIVE_BASH_DESCRIPTION } from "./constants" import { getCachedTmuxPath } from "./utils" /** @@ -62,6 +62,11 @@ export const interactive_bash = tool({ return "Error: Empty tmux command" } + const subcommand = parts[0].toLowerCase() + if (BLOCKED_TMUX_SUBCOMMANDS.includes(subcommand)) { + return `Error: '${parts[0]}' is blocked. Use bash tool instead for capturing/printing terminal output.` + } + const proc = Bun.spawn([tmuxPath, ...parts], { stdout: "pipe", stderr: "pipe",