feat(interactive-bash): block tmux output capture commands

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)
This commit is contained in:
YeonGyu-Kim
2025-12-15 23:01:02 +09:00
parent cea64e40b8
commit 9b2048b3e8
2 changed files with 24 additions and 2 deletions

View File

@@ -1,5 +1,22 @@
export const DEFAULT_TIMEOUT_MS = 60_000 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. 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`

View File

@@ -1,5 +1,5 @@
import { tool } from "@opencode-ai/plugin/tool" 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" import { getCachedTmuxPath } from "./utils"
/** /**
@@ -62,6 +62,11 @@ export const interactive_bash = tool({
return "Error: Empty tmux command" 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], { const proc = Bun.spawn([tmuxPath, ...parts], {
stdout: "pipe", stdout: "pipe",
stderr: "pipe", stderr: "pipe",