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:
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": "管理插件和组件的生命周期,包括加载、卸载、启用和禁用等操作。"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user