refactor(plugin_system): 引入 PluginMetadata 替代 manifest.json
将插件元数据定义从外部 `_manifest.json` 文件迁移到插件 `__init__.py` 文件中的 `__plugin_meta__` 变量。此举简化了插件加载流程,减少了文件I/O,并使元数据与插件代码更紧密地耦合。 主要变更: - 引入 `PluginMetadata` 数据类来标准化插件元数据。 - 插件基类 `PluginBase` 现在直接接收 `PluginMetadata` 对象,不再负责解析 JSON 文件。 - 插件管理器 `PluginManager` 调整加载逻辑,从插件模块的 `__plugin_meta__` 属性获取元数据。 - 删除了 `manifest_utils.py` 及其相关的验证和版本比较逻辑,简化了依赖关系。 - 更新了所有内置插件,以采用新的元数据定义方式,并删除了它们各自的 `_manifest.json` 文件。 BREAKING CHANGE: 插件加载机制已改变。所有插件必须在其 `__init__.py` 中定义一个 `__plugin_meta__` 变量,该变量是 `PluginMetadata` 类的实例,并移除旧的 `_manifest.json` 文件。
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
"""
|
||||
亲和力聊天处理器插件
|
||||
"""
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
from .plugin import AffinityChatterPlugin
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="Affinity Flow Chatter",
|
||||
description="Built-in chatter plugin for affinity flow with interest scoring and relationship building",
|
||||
usage="This plugin is automatically triggered by the system.",
|
||||
version="1.0.0",
|
||||
author="MoFox",
|
||||
keywords=["chatter", "affinity", "conversation"],
|
||||
categories=["Chat", "AI"],
|
||||
extra={
|
||||
"is_built_in": True
|
||||
}
|
||||
)
|
||||
|
||||
__all__ = ["AffinityChatterPlugin"]
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "affinity_chatter",
|
||||
"display_name": "Affinity Flow Chatter",
|
||||
"description": "Built-in chatter plugin for affinity flow with interest scoring and relationship building",
|
||||
"version": "1.0.0",
|
||||
"author": "MoFox",
|
||||
"plugin_class": "AffinityChatterPlugin",
|
||||
"enabled": true,
|
||||
"is_built_in": true,
|
||||
"components": [
|
||||
{
|
||||
"name": "affinity_chatter",
|
||||
"type": "chatter",
|
||||
"description": "Affinity flow chatter with intelligent interest scoring and relationship building",
|
||||
"enabled": true,
|
||||
"chat_type_allow": ["all"]
|
||||
}
|
||||
],
|
||||
"host_application": { "min_version": "0.8.0" },
|
||||
"keywords": ["chatter", "affinity", "conversation"],
|
||||
"categories": ["Chat", "AI"]
|
||||
}
|
||||
17
src/plugins/built_in/core_actions/__init__.py
Normal file
17
src/plugins/built_in/core_actions/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="Emoji插件 (Emoji Actions)",
|
||||
description="可以发送和管理Emoji",
|
||||
usage="该插件提供 `emoji` action。",
|
||||
version="1.0.0",
|
||||
author="SengokuCola",
|
||||
license="GPL-v3.0-or-later",
|
||||
repository_url="https://github.com/MaiM-with-u/maibot",
|
||||
keywords=["emoji", "action", "built-in"],
|
||||
categories=["Emoji"],
|
||||
extra={
|
||||
"is_built_in": True,
|
||||
"plugin_type": "action_provider",
|
||||
}
|
||||
)
|
||||
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "Emoji插件 (Emoji Actions)",
|
||||
"version": "1.0.0",
|
||||
"description": "可以发送和管理Emoji",
|
||||
"author": {
|
||||
"name": "SengokuCola",
|
||||
"url": "https://github.com/MaiM-with-u"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
|
||||
"host_application": {
|
||||
"min_version": "0.10.0"
|
||||
},
|
||||
"homepage_url": "https://github.com/MaiM-with-u/maibot",
|
||||
"repository_url": "https://github.com/MaiM-with-u/maibot",
|
||||
"keywords": ["emoji", "action", "built-in"],
|
||||
"categories": ["Emoji"],
|
||||
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales",
|
||||
|
||||
"plugin_info": {
|
||||
"is_built_in": true,
|
||||
"plugin_type": "action_provider",
|
||||
"components": [
|
||||
{
|
||||
"type": "action",
|
||||
"name": "emoji",
|
||||
"description": "作为一条全新的消息,发送一个符合当前情景的表情包来生动地表达情绪。"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,17 @@
|
||||
"""
|
||||
让框架能够发现并加载子目录中的组件。
|
||||
"""
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
from .actions.read_feed_action import ReadFeedAction as ReadFeedAction
|
||||
from .actions.send_feed_action import SendFeedAction as SendFeedAction
|
||||
from .commands.send_feed_command import SendFeedCommand as SendFeedCommand
|
||||
from .plugin import MaiZoneRefactoredPlugin as MaiZoneRefactoredPlugin
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="MaiZone(麦麦空间)- 重构版",
|
||||
description="(重构版)让你的麦麦发QQ空间说说、评论、点赞,支持AI配图、定时发送和自动监控功能",
|
||||
usage="该插件提供 `send_feed` 和 `read_feed` action,以及 `send_feed` command。",
|
||||
version="3.0.0",
|
||||
author="MoFox-Studio",
|
||||
license="GPL-v3.0",
|
||||
repository_url="https://github.com/MoFox-Studio",
|
||||
keywords=["QQ空间", "说说", "动态", "评论", "点赞", "自动化", "AI配图"],
|
||||
categories=["社交", "自动化", "QQ空间"],
|
||||
extra={
|
||||
"is_built_in": False,
|
||||
"plugin_type": "social",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "MaiZone(麦麦空间)- 重构版",
|
||||
"version": "3.0.0",
|
||||
"description": "(重构版)让你的麦麦发QQ空间说说、评论、点赞,支持AI配图、定时发送和自动监控功能",
|
||||
"author": {
|
||||
"name": "MoFox-Studio",
|
||||
"url": "https://github.com/MoFox-Studio"
|
||||
},
|
||||
"license": "GPL-v3.0",
|
||||
|
||||
"host_application": {
|
||||
"min_version": "0.10.0"
|
||||
},
|
||||
"keywords": ["QQ空间", "说说", "动态", "评论", "点赞", "自动化", "AI配图"],
|
||||
"categories": ["社交", "自动化", "QQ空间"],
|
||||
|
||||
"plugin_info": {
|
||||
"is_built_in": false,
|
||||
"plugin_type": "social",
|
||||
"components": [
|
||||
{
|
||||
"type": "action",
|
||||
"name": "send_feed",
|
||||
"description": "根据指定主题发送一条QQ空间说说"
|
||||
},
|
||||
{
|
||||
"type": "action",
|
||||
"name": "read_feed",
|
||||
"description": "读取指定好友最近的说说,并评论点赞"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"name": "send_feed",
|
||||
"description": "通过命令发送QQ空间说说"
|
||||
}
|
||||
],
|
||||
"features": [
|
||||
"智能生成说说内容",
|
||||
"AI自动配图(硅基流动)",
|
||||
"自动点赞评论好友说说",
|
||||
"定时发送说说",
|
||||
"权限管理系统",
|
||||
"历史记录避重"
|
||||
]
|
||||
}
|
||||
}
|
||||
16
src/plugins/built_in/napcat_adapter_plugin/__init__.py
Normal file
16
src/plugins/built_in/napcat_adapter_plugin/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="napcat_plugin",
|
||||
description="基于OneBot 11协议的NapCat QQ协议插件,提供完整的QQ机器人API接口,使用现有adapter连接",
|
||||
usage="该插件提供 `napcat_tool` tool。",
|
||||
version="1.0.0",
|
||||
author="Windpicker_owo",
|
||||
license="GPL-v3.0-or-later",
|
||||
repository_url="https://github.com/Windpicker-owo/InternetSearchPlugin",
|
||||
keywords=["qq", "bot", "napcat", "onebot", "api", "websocket"],
|
||||
categories=["protocol"],
|
||||
extra={
|
||||
"is_built_in": False,
|
||||
}
|
||||
)
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "napcat_plugin",
|
||||
"version": "1.0.0",
|
||||
"description": "基于OneBot 11协议的NapCat QQ协议插件,提供完整的QQ机器人API接口,使用现有adapter连接",
|
||||
"author": {
|
||||
"name": "Windpicker_owo",
|
||||
"url": "https://github.com/Windpicker-owo"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
|
||||
"host_application": {
|
||||
"min_version": "0.10.0",
|
||||
"max_version": "0.11.0"
|
||||
},
|
||||
"homepage_url": "https://github.com/Windpicker-owo/InternetSearchPlugin",
|
||||
"repository_url": "https://github.com/Windpicker-owo/InternetSearchPlugin",
|
||||
"keywords": ["qq", "bot", "napcat", "onebot", "api", "websocket"],
|
||||
"categories": ["protocol"],
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales",
|
||||
|
||||
"plugin_info": {
|
||||
"is_built_in": false,
|
||||
"components": [
|
||||
{
|
||||
"type": "tool",
|
||||
"name": "napcat_tool",
|
||||
"description": "NapCat QQ协议综合工具,提供消息发送、群管理、好友管理、文件操作等完整功能"
|
||||
}
|
||||
],
|
||||
"features": [
|
||||
"消息发送与接收",
|
||||
"群管理功能",
|
||||
"好友管理功能",
|
||||
"文件上传下载",
|
||||
"AI语音功能",
|
||||
"群签到与戳一戳",
|
||||
"现有adapter连接"
|
||||
]
|
||||
}
|
||||
}
|
||||
16
src/plugins/built_in/permission_management/__init__.py
Normal file
16
src/plugins/built_in/permission_management/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="权限管理插件(Permission Management)",
|
||||
description="通过系统API管理权限",
|
||||
usage="该插件提供 `permission_management` command。",
|
||||
version="1.0.0",
|
||||
author="MoFox-Studio",
|
||||
license="GPL-v3.0-or-later",
|
||||
repository_url="https://github.com/MoFox-Studio",
|
||||
keywords=["plugins", "permission", "management", "built-in"],
|
||||
extra={
|
||||
"is_built_in": True,
|
||||
"plugin_type": "permission",
|
||||
}
|
||||
)
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "权限管理插件(Permission Management)",
|
||||
"version": "1.0.0",
|
||||
"description": "通过系统API管理权限",
|
||||
"author": {
|
||||
"name": "MoFox-Studio",
|
||||
"url": "https://github.com/MoFox-Studio"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
"host_application": {
|
||||
"min_version": "0.10.0"
|
||||
},
|
||||
"keywords": [
|
||||
"plugins",
|
||||
"permission",
|
||||
"management",
|
||||
"built-in"
|
||||
],
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales",
|
||||
"plugin_info": {
|
||||
"is_built_in": true,
|
||||
"plugin_type": "permission",
|
||||
"components": [
|
||||
{
|
||||
"type": "command",
|
||||
"name": "permission_management",
|
||||
"description": "管理用户权限,包括添加、删除和修改权限等操作。"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
17
src/plugins/built_in/plugin_management/__init__.py
Normal file
17
src/plugins/built_in/plugin_management/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="插件和组件管理 (Plugin and Component Management)",
|
||||
description="通过系统API管理插件和组件的生命周期,包括加载、卸载、启用和禁用等操作。",
|
||||
usage="该插件提供 `plugin_management` command。",
|
||||
version="1.0.0",
|
||||
author="MaiBot团队",
|
||||
license="GPL-v3.0-or-later",
|
||||
repository_url="https://github.com/MaiM-with-u/maibot",
|
||||
keywords=["plugins", "components", "management", "built-in"],
|
||||
categories=["Core System", "Plugin Management"],
|
||||
extra={
|
||||
"is_built_in": True,
|
||||
"plugin_type": "plugin_management",
|
||||
}
|
||||
)
|
||||
@@ -1,39 +0,0 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "插件和组件管理 (Plugin and Component Management)",
|
||||
"version": "1.0.0",
|
||||
"description": "通过系统API管理插件和组件的生命周期,包括加载、卸载、启用和禁用等操作。",
|
||||
"author": {
|
||||
"name": "MaiBot团队",
|
||||
"url": "https://github.com/MaiM-with-u"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
"host_application": {
|
||||
"min_version": "0.9.1"
|
||||
},
|
||||
"homepage_url": "https://github.com/MaiM-with-u/maibot",
|
||||
"repository_url": "https://github.com/MaiM-with-u/maibot",
|
||||
"keywords": [
|
||||
"plugins",
|
||||
"components",
|
||||
"management",
|
||||
"built-in"
|
||||
],
|
||||
"categories": [
|
||||
"Core System",
|
||||
"Plugin Management"
|
||||
],
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales",
|
||||
"plugin_info": {
|
||||
"is_built_in": true,
|
||||
"plugin_type": "plugin_management",
|
||||
"components": [
|
||||
{
|
||||
"type": "command",
|
||||
"name": "plugin_management",
|
||||
"description": "管理插件和组件的生命周期,包括加载、卸载、启用和禁用等操作。"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="MoFox-Bot主动思考",
|
||||
description="主动思考插件",
|
||||
usage="该插件由系统自动触发。",
|
||||
version="1.0.0",
|
||||
author="MoFox-Studio",
|
||||
license="GPL-v3.0-or-later",
|
||||
repository_url="https://github.com/MoFox-Studio",
|
||||
keywords=["主动思考","自己发消息"],
|
||||
categories=["Chat", "Integration"],
|
||||
extra={
|
||||
"is_built_in": True,
|
||||
"plugin_type": "functional"
|
||||
}
|
||||
)
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "MoFox-Bot主动思考",
|
||||
"version": "1.0.0",
|
||||
"description": "主动思考插件",
|
||||
"author": {
|
||||
"name": "MoFox-Studio",
|
||||
"url": "https://github.com/MoFox-Studio"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
|
||||
"host_application": {
|
||||
"min_version": "0.10.0"
|
||||
},
|
||||
"keywords": ["主动思考","自己发消息"],
|
||||
"categories": ["Chat", "Integration"],
|
||||
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales",
|
||||
|
||||
"plugin_info": {
|
||||
"is_built_in": "true",
|
||||
"plugin_type": "functional"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="MoFox-Bot工具箱",
|
||||
description="一个集合多种实用功能的插件,旨在提升聊天体验和效率。",
|
||||
usage="该插件提供多种命令,详情请查阅文档。",
|
||||
version="1.0.0",
|
||||
author="MoFox-Studio",
|
||||
license="GPL-v3.0-or-later",
|
||||
repository_url="https://github.com/MoFox-Studio",
|
||||
keywords=["emoji", "reaction", "like", "表情", "回应", "点赞"],
|
||||
categories=["Chat", "Integration"],
|
||||
extra={
|
||||
"is_built_in": "true",
|
||||
"plugin_type": "functional"
|
||||
}
|
||||
)
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "MoFox-Bot工具箱",
|
||||
"version": "1.0.0",
|
||||
"description": "一个集合多种实用功能的插件,旨在提升聊天体验和效率。",
|
||||
"author": {
|
||||
"name": "MoFox-Studio",
|
||||
"url": "https://github.com/MoFox-Studio"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
|
||||
"host_application": {
|
||||
"min_version": "0.10.0"
|
||||
},
|
||||
"keywords": ["emoji", "reaction", "like", "表情", "回应", "点赞"],
|
||||
"categories": ["Chat", "Integration"],
|
||||
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales",
|
||||
|
||||
"plugin_info": {
|
||||
"is_built_in": "true",
|
||||
"plugin_type": "functional"
|
||||
}
|
||||
}
|
||||
17
src/plugins/built_in/tts_plugin/__init__.py
Normal file
17
src/plugins/built_in/tts_plugin/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="文本转语音插件 (Text-to-Speech)",
|
||||
description="将文本转换为语音进行播放的插件,支持多种语音模式和智能语音输出场景判断。",
|
||||
usage="该插件提供 `tts_action` action。",
|
||||
version="0.1.0",
|
||||
author="MaiBot团队",
|
||||
license="GPL-v3.0-or-later",
|
||||
repository_url="https://github.com/MaiM-with-u/maibot",
|
||||
keywords=["tts", "voice", "audio", "speech", "accessibility"],
|
||||
categories=["Audio Tools", "Accessibility", "Voice Assistant"],
|
||||
extra={
|
||||
"is_built_in": True,
|
||||
"plugin_type": "audio_processor",
|
||||
}
|
||||
)
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "文本转语音插件 (Text-to-Speech)",
|
||||
"version": "0.1.0",
|
||||
"description": "将文本转换为语音进行播放的插件,支持多种语音模式和智能语音输出场景判断。",
|
||||
"author": {
|
||||
"name": "MaiBot团队",
|
||||
"url": "https://github.com/MaiM-with-u"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
|
||||
"host_application": {
|
||||
"min_version": "0.8.0"
|
||||
},
|
||||
"homepage_url": "https://github.com/MaiM-with-u/maibot",
|
||||
"repository_url": "https://github.com/MaiM-with-u/maibot",
|
||||
"keywords": ["tts", "voice", "audio", "speech", "accessibility"],
|
||||
"categories": ["Audio Tools", "Accessibility", "Voice Assistant"],
|
||||
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales",
|
||||
|
||||
"plugin_info": {
|
||||
"is_built_in": true,
|
||||
"plugin_type": "audio_processor",
|
||||
"components": [
|
||||
{
|
||||
"type": "action",
|
||||
"name": "tts_action",
|
||||
"description": "将文本转换为语音进行播放",
|
||||
"activation_modes": ["llm_judge", "keyword"],
|
||||
"keywords": ["语音", "tts", "播报", "读出来", "语音播放", "听", "朗读"]
|
||||
}
|
||||
],
|
||||
"features": [
|
||||
"文本转语音播放",
|
||||
"智能场景判断",
|
||||
"关键词触发",
|
||||
"支持多种语音模式"
|
||||
]
|
||||
}
|
||||
}
|
||||
16
src/plugins/built_in/web_search_tool/__init__.py
Normal file
16
src/plugins/built_in/web_search_tool/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from src.plugin_system.base.plugin_metadata import PluginMetadata
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="Web Search Tool",
|
||||
description="A tool for searching the web.",
|
||||
usage="This plugin provides a `web_search` tool.",
|
||||
version="1.0.0",
|
||||
author="MoFox-Studio",
|
||||
license="GPL-v3.0-or-later",
|
||||
repository_url="https://github.com/MoFox-Studio",
|
||||
keywords=["web", "search", "tool"],
|
||||
categories=["Tools"],
|
||||
extra={
|
||||
"is_built_in": True,
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user