core/tools: rename run_command to run_argv (argv param)

This commit is contained in:
2026-08-04 21:38:20 +08:00
parent 23f7b4e299
commit d698fbf06f
8 changed files with 49 additions and 49 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ from .process import ask_into_pty as ask_into_pty
from .process import close_pty as close_pty
from .process import open_pty as open_pty
from .process import read_pty as read_pty
from .process import run_command as run_command
from .process import run_argv as run_argv
from .process import run_command_batch as run_command_batch
from .process import write_pty as write_pty
from .process import write_pty_keys as write_pty_keys
+8 -8
View File
@@ -59,8 +59,8 @@ def _basename(argv0: str) -> str:
return name.lower()
def _as_argv(args: Mapping[str, object]) -> list[str] | None:
command = args.get("command")
def _as_argv(args: Mapping[str, object], *, key: str = "command") -> list[str] | None:
command = args.get(key)
if not isinstance(command, list) or not command:
return None
out: list[str] = []
@@ -110,7 +110,7 @@ def _shell_or_dash_c_reason(argv: Sequence[str], *, via: str) -> str | None:
"""Confirm interactive shells and ``*-c`` one-liners so the user can inspect argv.
Multi-line reason (shown inside the CLI confirm box). ``via`` is a short
label such as ``run_command`` or ``open_pty``.
label such as ``run_argv`` or ``open_pty``.
For ``-c`` scripts, argv shows ``$(command)`` instead of inlining the body;
the full script is printed below untruncated, with every line indented.
@@ -181,11 +181,11 @@ def _delete_path_reason(args: Mapping[str, object]) -> str | None:
return f"delete path {path!r}{extra}"
def _run_command_reason(args: Mapping[str, object]) -> str | None:
argv = _as_argv(args)
def _run_argv_reason(args: Mapping[str, object]) -> str | None:
argv = _as_argv(args, key="argv")
if argv is None:
return None
return _shell_or_dash_c_reason(argv, via="run_command")
return _shell_or_dash_c_reason(argv, via="run_argv")
def _batch_step_argv(item: object) -> list[str] | None:
@@ -262,8 +262,8 @@ def classify_danger(name: str, args: Mapping[str, object]) -> str | None: # noq
return _copy_path_reason(args)
if name == "write_file":
return _write_file_reason(args)
if name == "run_command":
return _run_command_reason(args)
if name == "run_argv":
return _run_argv_reason(args)
if name == "run_command_batch":
return _run_command_batch_reason(args)
if name == "open_pty":
+2 -2
View File
@@ -4,13 +4,13 @@ from .open_pty import open_pty as open_pty
from .pty_terminal import decode_write_data as decode_write_data
from .pty_terminal import sanitize_pty_output_for_tool as sanitize_pty_output_for_tool
from .read_pty import read_pty as read_pty
from .run_command import run_command as run_command
from .run_argv import run_argv as run_argv
from .run_command_batch import run_command_batch as run_command_batch
from .write_pty import write_pty as write_pty
from .write_pty_keys import write_pty_keys as write_pty_keys
PROCESS_TOOLS = [
run_command,
run_argv,
run_command_batch,
open_pty,
read_pty,
+1 -1
View File
@@ -83,7 +83,7 @@ async def execute_argv(
timeout_seconds: float = DEFAULT_TIMEOUT_SECONDS,
mix_stderr: bool = False,
) -> CommandStepResult:
"""Run one argv command; no shell. Used by run_command and run_command_batch."""
"""Run one argv command; no shell. Used by run_argv and run_command_batch."""
if not command:
msg = "command argv must not be empty"
raise WorkspaceError(msg)
@@ -11,21 +11,21 @@ from .command_exec import (
@tool(tags=ToolTag.LOCAL | ToolTag.INSTANCE_STATE | ToolTag.YOLO)
async def run_command(
command: list[str],
async def run_argv(
argv: list[str],
*,
cwd: str = ".",
timeout_seconds: float = DEFAULT_TIMEOUT_SECONDS,
stdin: str | None = None,
env: dict[str, str] | None = None,
) -> str:
"""Run ``command`` (argv, no shell) under the workspace; capture stdout/stderr."""
shape_error = argv_shape_error(command)
"""Run ``argv`` (argv, no shell) under the workspace; capture stdout/stderr."""
shape_error = argv_shape_error(argv)
if shape_error is not None:
return f"error: `run_command` {shape_error}"
return f"error: `run_argv` {shape_error}"
try:
result = await execute_argv(
command,
argv,
cwd=cwd,
env=env,
stdin=stdin,