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("要执行的命令")