fix: 去掉 cmd_executor 的 run 前缀 + 验证工具错误传递机制
This commit is contained in:
1 parent
78fea7ccdd
commit
b90ca35149
1 file changed
+11
-8
+11
-8
@@ -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("要执行的命令")
|
||||
|
||||
Reference in new issue
Block a user