From b90ca35149048e64d58eb44e7f0550756366e956 Mon Sep 17 00:00:00 2001 From: shuiyu1123 Date: Sun, 5 Jul 2026 13:31:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=BB=E6=8E=89=20cmd=5Fexecutor=20?= =?UTF-8?q?=E7=9A=84=20run=20=E5=89=8D=E7=BC=80=20+=20=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=94=99=E8=AF=AF=E4=BC=A0=E9=80=92=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/cmd_executor.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/cmd_executor.py b/plugins/cmd_executor.py index 3813862..8f8eee2 100644 --- a/plugins/cmd_executor.py +++ b/plugins/cmd_executor.py @@ -19,13 +19,13 @@ class Liugin: self.usage = """Shell 命令执行器 操作: - run <命令> [--timeout 秒] - 执行 Shell 命令 (默认超时 30s) + <命令> [--timeout 秒] - 执行 Shell 命令 (默认超时 30s) 示例: - run ls -la - 列出当前目录 - run python3 --version - 查看 Python 版本 - run git status - 查看 Git 状态 - run make build --timeout 60 - 执行构建 (60秒超时) + ls -la - 列出当前目录 + python3 --version - 查看 Python 版本 + git status - 查看 Git 状态 + make build --timeout 60 - 执行构建 (60秒超时) 注意: - 跨平台兼容 (Linux/macOS/Windows) @@ -79,9 +79,12 @@ class Liugin: if not parts: return ToolResult.missing("操作。可用: run <命令>") - operation = parts[0].lower() - if operation != "run": - return ToolResult.fail(f"不支持的操作 '{operation}'。可用: run", ErrorCode.UNSUPPORTED_OP) + # 支持两种格式: "命令" 或 "run 命令" + command = parts[0] if len(parts) > 1 else "" + if not command and len(parts) > 1: + command = parts[1] + if not command: + return ToolResult.missing("请提供要执行的命令") if len(parts) < 2: return ToolResult.missing("要执行的命令")