diff --git a/docs/plugins/manifest-guide.md b/docs/plugins/manifest-guide.md index 5c5d7e3fb..d3dd746af 100644 --- a/docs/plugins/manifest-guide.md +++ b/docs/plugins/manifest-guide.md @@ -147,7 +147,7 @@ python scripts/manifest_tool.py validate src/plugins/my_plugin ## 📋 字段说明 ### 基本信息 -- `manifest_version`: manifest格式版本,当前为3 +- `manifest_version`: manifest格式版本,当前为1 - `name`: 插件显示名称(必需) - `version`: 插件版本号(必需) - `description`: 插件功能描述(必需) @@ -165,10 +165,12 @@ python scripts/manifest_tool.py validate src/plugins/my_plugin - `categories`: 分类数组(可选,建议填写) ### 兼容性 -- `host_application`: 主机应用兼容性(可选) +- `host_application`: 主机应用兼容性(可选,建议填写) - `min_version`: 最低兼容版本 - `max_version`: 最高兼容版本 +⚠️ 在不填写的情况下,插件将默认支持所有版本。**(由于我们在不同版本对插件系统进行了大量的重构,这种情况几乎不可能。)** + ### 国际化 - `default_locale`: 默认语言(可选) - `locales_path`: 语言文件目录(可选) @@ -185,24 +187,13 @@ python scripts/manifest_tool.py validate src/plugins/my_plugin 2. **编码格式**:manifest文件必须使用UTF-8编码 3. **JSON格式**:文件必须是有效的JSON格式 4. **必需字段**:`manifest_version`、`name`、`version`、`description`、`author.name`是必需的 -5. **版本兼容**:当前只支持manifest_version = 3 +5. **版本兼容**:当前只支持`manifest_version = 1` ## 🔍 常见问题 -### Q: 为什么要强制要求manifest文件? -A: Manifest文件提供了插件的标准化元数据,使得插件管理、依赖检查、版本兼容性验证等功能成为可能。 - ### Q: 可以不填写可选字段吗? A: 可以。所有标记为"可选"的字段都可以不填写,但建议至少填写`license`和`keywords`。 -### Q: 如何快速为所有插件创建manifest? -A: 可以编写脚本批量处理: -```bash -# 扫描并为每个缺少manifest的插件创建最小化manifest -python scripts/manifest_tool.py scan src/plugins -# 然后手动为每个插件运行create-minimal命令 -``` - ### Q: manifest验证失败怎么办? A: 根据验证器的错误提示修复相应问题。错误会导致插件加载失败,警告不会。 @@ -210,5 +201,5 @@ A: 根据验证器的错误提示修复相应问题。错误会导致插件加 查看内置插件的manifest文件作为参考: - `src/plugins/built_in/core_actions/_manifest.json` -- `src/plugins/built_in/doubao_pic_plugin/_manifest.json` - `src/plugins/built_in/tts_plugin/_manifest.json` +- `src/plugins/hello_world_plugin/_manifest.json` diff --git a/src/plugin_system/utils/manifest_utils.py b/src/plugin_system/utils/manifest_utils.py index 6a8aa804b..d070b733c 100644 --- a/src/plugin_system/utils/manifest_utils.py +++ b/src/plugin_system/utils/manifest_utils.py @@ -163,12 +163,11 @@ class VersionComparator: version_normalized, max_normalized ) - if is_compatible: - logger.info(f"版本兼容性检查:{compat_msg}") - return True, compat_msg - else: + if not is_compatible: return False, f"版本 {version_normalized} 高于最大支持版本 {max_normalized},且无兼容性映射" + logger.info(f"版本兼容性检查:{compat_msg}") + return True, compat_msg return True, "" @staticmethod @@ -358,14 +357,10 @@ class ManifestValidator: if self.validation_errors: report.append("❌ 验证错误:") - for error in self.validation_errors: - report.append(f" - {error}") - + report.extend(f" - {error}" for error in self.validation_errors) if self.validation_warnings: report.append("⚠️ 验证警告:") - for warning in self.validation_warnings: - report.append(f" - {warning}") - + report.extend(f" - {warning}" for warning in self.validation_warnings) if not self.validation_errors and not self.validation_warnings: report.append("✅ Manifest文件验证通过")