refactor(agent): rename run_plugin_command to run_slash_command to avoid confusion with execute_command (shell)

This commit is contained in:
jxxghp
2026-04-06 23:53:49 +08:00
parent 7806267e92
commit a8fb4a6d84
5 changed files with 16 additions and 16 deletions
+2 -2
View File
@@ -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.browse_webpage import BrowseWebpageTool
from app.agent.tools.impl.query_installed_plugins import QueryInstalledPluginsTool 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.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.agent.tools.impl.list_all_commands import ListAllCommandsTool
from app.core.plugin import PluginManager from app.core.plugin import PluginManager
from app.log import logger from app.log import logger
@@ -126,7 +126,7 @@ class MoviePilotToolFactory:
BrowseWebpageTool, BrowseWebpageTool,
QueryInstalledPluginsTool, QueryInstalledPluginsTool,
QueryPluginCapabilitiesTool, QueryPluginCapabilitiesTool,
RunPluginCommandTool, RunSlashCommandTool,
ListAllCommandsTool, ListAllCommandsTool,
] ]
# 创建内置工具 # 创建内置工具
+1 -1
View File
@@ -25,7 +25,7 @@ class ListAllCommandsTool(MoviePilotTool):
"List all available commands in the system, including system preset commands " "List all available commands in the system, including system preset commands "
"(e.g. /cookiecloud, /sites, /subscribes, /downloading, /transfer, /restart, etc.) " "(e.g. /cookiecloud, /sites, /subscribes, /downloading, /transfer, /restart, etc.) "
"and plugin-registered commands. " "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 " "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." "find the matching command to fulfill their request."
) )
@@ -29,7 +29,7 @@ class QueryPluginCapabilitiesTool(MoviePilotTool):
name: str = "query_plugin_capabilities" name: str = "query_plugin_capabilities"
description: str = ( description: str = (
"Query the capabilities of installed plugins, including supported commands and scheduled services. " "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. " "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." "Optionally specify a plugin_id to query a specific plugin, or omit to query all running plugins."
) )
@@ -1,4 +1,4 @@
"""运行插件/系统命令工具""" """运行斜杠命令工具(系统命令 + 插件命令)"""
import json import json
from typing import Optional, Type from typing import Optional, Type
@@ -12,8 +12,8 @@ from app.log import logger
from app.schemas.types import EventType, MessageChannel from app.schemas.types import EventType, MessageChannel
class RunPluginCommandInput(BaseModel): class RunSlashCommandInput(BaseModel):
"""运行插件/系统命令工具的输入参数模型""" """运行斜杠命令工具的输入参数模型"""
explanation: str = Field( explanation: str = Field(
..., ...,
@@ -28,11 +28,11 @@ class RunPluginCommandInput(BaseModel):
) )
class RunPluginCommandTool(MoviePilotTool): class RunSlashCommandTool(MoviePilotTool):
name: str = "run_plugin_command" name: str = "run_slash_command"
description: str = ( description: str = (
"Execute a system or plugin command by sending a CommandExcute event. " "Execute a slash command (system or plugin) by sending a CommandExcute event. "
"This tool supports ALL registered commands, including: " "This tool supports ALL registered slash commands, including: "
"1) System preset commands (e.g. /cookiecloud, /sites, /subscribes, /downloading, /transfer, /restart, etc.) " "1) System preset commands (e.g. /cookiecloud, /sites, /subscribes, /downloading, /transfer, /restart, etc.) "
"2) Plugin commands registered by installed plugins. " "2) Plugin commands registered by installed plugins. "
"Use the query_plugin_capabilities tool to discover plugin commands, " "Use the query_plugin_capabilities tool to discover plugin commands, "
@@ -40,7 +40,7 @@ class RunPluginCommandTool(MoviePilotTool):
"The command will be executed asynchronously. " "The command will be executed asynchronously. "
"Note: This tool triggers the command execution but the actual processing happens in the background." "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 require_admin: bool = True
def get_tool_message(self, **kwargs) -> Optional[str]: def get_tool_message(self, **kwargs) -> Optional[str]:
+4 -4
View File
@@ -7,7 +7,7 @@ description: >-
(e.g. "sync sites", "show subscriptions", "refresh subscriptions", "check downloads", etc.). (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, This skill helps you identify the user's intent, find the matching command, extract necessary parameters,
and execute the corresponding command. 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 # 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 - `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) - `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 ## Workflow
@@ -59,7 +59,7 @@ Some commands support additional arguments (space-separated after the command),
- `/redo <history_id>` — Manually re-organize a specific record - `/redo <history_id>` — Manually re-organize a specific record
- `/subscribe_delete <name>` — Delete a specific subscription - `/subscribe_delete <name>` — 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 ### Step 4: Report Result
@@ -68,6 +68,6 @@ Command execution is asynchronous. After triggering, inform the user that the co
## Important Notes ## Important Notes
- Command execution requires admin privileges; the tool will automatically check permissions - 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 - 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 - Never guess non-existent commands; always select from the available command list