#72: Add global command prefix

This commit is contained in:
Dustin Washington 2025-12-03 22:02:08 -05:00
parent 86f3a992bd
commit be9b026ce2
4 changed files with 16 additions and 0 deletions

View file

@ -965,6 +965,11 @@ def get_parser(default_config_files, git_root):
" specified, a default command for your OS may be used."
),
)
group.add_argument(
"--command-prefix",
default=None,
help="Specify a command prefix for all commands (useful for sandboxing)",
)
group.add_argument(
"--detect-urls",
action=argparse.BooleanOptionalAction,

View file

@ -3837,6 +3837,10 @@ class Coder:
if not command or command.startswith("#"):
continue
if command and getattr(self.args, "command_prefix", None):
command_prefix = getattr(self.args, "command_prefix", None)
command = f"{command_prefix} {command}"
self.io.tool_output()
self.io.tool_output(f"Running {command}")
# Add the command to input history

View file

@ -32,6 +32,9 @@ class Tool(BaseTool):
# Ask for confirmation before executing.
# allow_never=True enables the 'Always' option.
# confirm_ask handles remembering the 'Always' choice based on the subject.
if command_string and getattr(coder.args, "command_prefix", None):
command_prefix = getattr(coder.args, "command_prefix", None)
command_string = f"{command_prefix} {command_string}"
confirmed = (
True

View file

@ -31,6 +31,10 @@ class Tool(BaseTool):
Execute an interactive shell command using run_cmd (which uses pexpect/PTY).
"""
try:
if command_string and getattr(coder.args, "command_prefix", None):
command_prefix = getattr(coder.args, "command_prefix", None)
command_string = f"{command_prefix} {command_string}"
confirmed = (
True
if coder.skip_cli_confirmations