From a8fb4a6d842869cb79fc10b62b26e0abe92be7ae Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 6 Apr 2026 23:53:49 +0800 Subject: [PATCH] refactor(agent): rename run_plugin_command to run_slash_command to avoid confusion with execute_command (shell) --- app/agent/tools/factory.py | 4 ++-- app/agent/tools/impl/list_all_commands.py | 2 +- .../tools/impl/query_plugin_capabilities.py | 2 +- ...un_plugin_command.py => run_slash_command.py} | 16 ++++++++-------- skills/command-execute/SKILL.md | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) rename app/agent/tools/impl/{run_plugin_command.py => run_slash_command.py} (90%) diff --git a/app/agent/tools/factory.py b/app/agent/tools/factory.py index e4455c8a..1b641cbf 100644 --- a/app/agent/tools/factory.py +++ b/app/agent/tools/factory.py @@ -50,7 +50,7 @@ from app.agent.tools.impl.read_file import ReadFileTool from app.agent.tools.impl.browse_webpage import BrowseWebpageTool from app.agent.tools.impl.query_installed_plugins import QueryInstalledPluginsTool from app.agent.tools.impl.query_plugin_capabilities import QueryPluginCapabilitiesTool -from app.agent.tools.impl.run_plugin_command import RunPluginCommandTool +from app.agent.tools.impl.run_slash_command import RunSlashCommandTool from app.agent.tools.impl.list_all_commands import ListAllCommandsTool from app.core.plugin import PluginManager from app.log import logger @@ -126,7 +126,7 @@ class MoviePilotToolFactory: BrowseWebpageTool, QueryInstalledPluginsTool, QueryPluginCapabilitiesTool, - RunPluginCommandTool, + RunSlashCommandTool, ListAllCommandsTool, ] # 创建内置工具 diff --git a/app/agent/tools/impl/list_all_commands.py b/app/agent/tools/impl/list_all_commands.py index c861a74f..4f345840 100644 --- a/app/agent/tools/impl/list_all_commands.py +++ b/app/agent/tools/impl/list_all_commands.py @@ -25,7 +25,7 @@ class ListAllCommandsTool(MoviePilotTool): "List all available commands in the system, including system preset commands " "(e.g. /cookiecloud, /sites, /subscribes, /downloading, /transfer, /restart, etc.) " "and plugin-registered commands. " - "Use this tool to discover what commands are available before executing them with run_plugin_command. " + "Use this tool to discover what commands are available before executing them with run_slash_command. " "This is especially useful when the user describes an action in natural language and you need to " "find the matching command to fulfill their request." ) diff --git a/app/agent/tools/impl/query_plugin_capabilities.py b/app/agent/tools/impl/query_plugin_capabilities.py index 264c285d..821de940 100644 --- a/app/agent/tools/impl/query_plugin_capabilities.py +++ b/app/agent/tools/impl/query_plugin_capabilities.py @@ -29,7 +29,7 @@ class QueryPluginCapabilitiesTool(MoviePilotTool): name: str = "query_plugin_capabilities" description: str = ( "Query the capabilities of installed plugins, including supported commands and scheduled services. " - "Commands are slash-commands (e.g. /xxx) that can be executed via the run_plugin_command tool. " + "Commands are slash-commands (e.g. /xxx) that can be executed via the run_slash_command tool. " "Scheduled services are periodic tasks that can be triggered via the run_scheduler tool. " "Optionally specify a plugin_id to query a specific plugin, or omit to query all running plugins." ) diff --git a/app/agent/tools/impl/run_plugin_command.py b/app/agent/tools/impl/run_slash_command.py similarity index 90% rename from app/agent/tools/impl/run_plugin_command.py rename to app/agent/tools/impl/run_slash_command.py index 8d3f21e0..e480c7e0 100644 --- a/app/agent/tools/impl/run_plugin_command.py +++ b/app/agent/tools/impl/run_slash_command.py @@ -1,4 +1,4 @@ -"""运行插件/系统命令工具""" +"""运行斜杠命令工具(系统命令 + 插件命令)""" import json from typing import Optional, Type @@ -12,8 +12,8 @@ from app.log import logger from app.schemas.types import EventType, MessageChannel -class RunPluginCommandInput(BaseModel): - """运行插件/系统命令工具的输入参数模型""" +class RunSlashCommandInput(BaseModel): + """运行斜杠命令工具的输入参数模型""" explanation: str = Field( ..., @@ -28,11 +28,11 @@ class RunPluginCommandInput(BaseModel): ) -class RunPluginCommandTool(MoviePilotTool): - name: str = "run_plugin_command" +class RunSlashCommandTool(MoviePilotTool): + name: str = "run_slash_command" description: str = ( - "Execute a system or plugin command by sending a CommandExcute event. " - "This tool supports ALL registered commands, including: " + "Execute a slash command (system or plugin) by sending a CommandExcute event. " + "This tool supports ALL registered slash commands, including: " "1) System preset commands (e.g. /cookiecloud, /sites, /subscribes, /downloading, /transfer, /restart, etc.) " "2) Plugin commands registered by installed plugins. " "Use the query_plugin_capabilities tool to discover plugin commands, " @@ -40,7 +40,7 @@ class RunPluginCommandTool(MoviePilotTool): "The command will be executed asynchronously. " "Note: This tool triggers the command execution but the actual processing happens in the background." ) - args_schema: Type[BaseModel] = RunPluginCommandInput + args_schema: Type[BaseModel] = RunSlashCommandInput require_admin: bool = True def get_tool_message(self, **kwargs) -> Optional[str]: diff --git a/skills/command-execute/SKILL.md b/skills/command-execute/SKILL.md index 7e93fae5..46456e98 100644 --- a/skills/command-execute/SKILL.md +++ b/skills/command-execute/SKILL.md @@ -7,7 +7,7 @@ description: >- (e.g. "sync sites", "show subscriptions", "refresh subscriptions", "check downloads", etc.). This skill helps you identify the user's intent, find the matching command, extract necessary parameters, and execute the corresponding command. -allowed-tools: list_all_commands query_plugin_capabilities run_plugin_command +allowed-tools: list_all_commands query_plugin_capabilities run_slash_command --- # Command Execute @@ -31,7 +31,7 @@ Use this skill to identify user intent and invoke the corresponding system or pl - `list_all_commands` — List all available commands (system + plugin), returns command name, description, and category - `query_plugin_capabilities` — Query detailed plugin capabilities (commands, actions, scheduled services) -- `run_plugin_command` — Execute a specified command (works for both system and plugin commands) +- `run_slash_command` — Execute a specified command (works for both system and plugin commands) ## Workflow @@ -59,7 +59,7 @@ Some commands support additional arguments (space-separated after the command), - `/redo ` — Manually re-organize a specific record - `/subscribe_delete ` — Delete a specific subscription -Use `run_plugin_command` to execute the command in the format `/command_name arg1 arg2`. +Use `run_slash_command` to execute the command in the format `/command_name arg1 arg2`. ### Step 4: Report Result @@ -68,6 +68,6 @@ Command execution is asynchronous. After triggering, inform the user that the co ## Important Notes - Command execution requires admin privileges; the tool will automatically check permissions -- Both system and plugin commands are executed via the `run_plugin_command` tool — no need to distinguish between them +- Both system and plugin commands are executed via the `run_slash_command` tool — no need to distinguish between them - If you are unsure which command matches the user's intent, use `list_all_commands` first to look up before deciding - Never guess non-existent commands; always select from the available command list