@@ -252,7 +252,16 @@ class ComponentRegistry:
|
||||
|
||||
def get_registry_stats(self) -> Dict[str, Any]:
|
||||
"""获取注册中心统计信息"""
|
||||
action_components: int = 0
|
||||
command_components: int = 0
|
||||
for component in self._components.values():
|
||||
if component.component_type == ComponentType.ACTION:
|
||||
action_components += 1
|
||||
elif component.component_type == ComponentType.COMMAND:
|
||||
command_components += 1
|
||||
return {
|
||||
"action_components": action_components,
|
||||
"command_components": command_components,
|
||||
"total_components": len(self._components),
|
||||
"total_plugins": len(self._plugins),
|
||||
"components_by_type": {
|
||||
|
||||
@@ -38,14 +38,20 @@ class PluginManager:
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
logger.info(f"创建插件目录: {directory}")
|
||||
if directory not in self.plugin_directories:
|
||||
self.plugin_directories.append(directory)
|
||||
logger.debug(f"已添加插件目录: {directory}")
|
||||
else:
|
||||
logger.warning(f"插件不可重复加载: {directory}")
|
||||
|
||||
def add_plugin_directory(self, directory: str):
|
||||
"""添加插件目录"""
|
||||
if os.path.exists(directory):
|
||||
if directory not in self.plugin_directories:
|
||||
self.plugin_directories.append(directory)
|
||||
logger.debug(f"已添加插件目录: {directory}")
|
||||
else:
|
||||
logger.warning(f"插件不可重复加载: {directory}")
|
||||
else:
|
||||
logger.warning(f"插件目录不存在: {directory}")
|
||||
|
||||
@@ -130,7 +136,7 @@ class PluginManager:
|
||||
if plugin_info:
|
||||
# 插件基本信息
|
||||
version_info = f"v{plugin_info.version}" if plugin_info.version else ""
|
||||
author_info = f"by {plugin_info.author}" if plugin_info.author else ""
|
||||
author_info = f"by {plugin_info.author}" if plugin_info.author else "unknown"
|
||||
info_parts = [part for part in [version_info, author_info] if part]
|
||||
extra_info = f" ({', '.join(info_parts)})" if info_parts else ""
|
||||
|
||||
@@ -342,7 +348,9 @@ class PluginManager:
|
||||
# 全局插件管理器实例
|
||||
plugin_manager = PluginManager()
|
||||
|
||||
# 注释掉以解决插件目录重复加载的情况
|
||||
# 默认插件目录
|
||||
plugin_manager.add_plugin_directory("src/plugins/built_in")
|
||||
plugin_manager.add_plugin_directory("src/plugins/examples")
|
||||
plugin_manager.add_plugin_directory("plugins") # 用户插件目录
|
||||
# plugin_manager.add_plugin_directory("src/plugins/built_in")
|
||||
# plugin_manager.add_plugin_directory("src/plugins/examples")
|
||||
# 用户插件目录
|
||||
# plugin_manager.add_plugin_directory("plugins")
|
||||
|
||||
Reference in New Issue
Block a user