不再进行action_info转换了,保持一致性
This commit is contained in:
@@ -35,7 +35,7 @@ class ComponentRegistry:
|
||||
|
||||
# Action特定注册表
|
||||
self._action_registry: Dict[str, BaseAction] = {} # action名 -> action类
|
||||
self._default_actions: Dict[str, str] = {} # 启用的action名 -> 描述
|
||||
# self._action_descriptions: Dict[str, str] = {} # 启用的action名 -> 描述
|
||||
|
||||
# Command特定注册表
|
||||
self._command_registry: Dict[str, BaseCommand] = {} # command名 -> command类
|
||||
@@ -99,13 +99,16 @@ class ComponentRegistry:
|
||||
return True
|
||||
|
||||
def _register_action_component(self, action_info: ActionInfo, action_class: BaseAction):
|
||||
# -------------------------------- NEED REFACTORING --------------------------------
|
||||
# -------------------------------- LOGIC ERROR -------------------------------------
|
||||
"""注册Action组件到Action特定注册表"""
|
||||
action_name = action_info.name
|
||||
self._action_registry[action_name] = action_class
|
||||
|
||||
# 如果启用,添加到默认动作集
|
||||
if action_info.enabled:
|
||||
self._default_actions[action_name] = action_info.description
|
||||
# ---- HERE ----
|
||||
# if action_info.enabled:
|
||||
# self._action_descriptions[action_name] = action_info.description
|
||||
|
||||
def _register_command_component(self, command_info: CommandInfo, command_class: BaseCommand):
|
||||
"""注册Command组件到Command特定注册表"""
|
||||
@@ -231,10 +234,6 @@ class ComponentRegistry:
|
||||
"""获取Action注册表(用于兼容现有系统)"""
|
||||
return self._action_registry.copy()
|
||||
|
||||
def get_default_actions(self) -> Dict[str, str]:
|
||||
"""获取默认启用的Action列表(用于兼容现有系统)"""
|
||||
return self._default_actions.copy()
|
||||
|
||||
def get_action_info(self, action_name: str) -> Optional[ActionInfo]:
|
||||
"""获取Action信息"""
|
||||
info = self.get_component_info(action_name, ComponentType.ACTION)
|
||||
@@ -343,6 +342,8 @@ class ComponentRegistry:
|
||||
# === 状态管理方法 ===
|
||||
|
||||
def enable_component(self, component_name: str, component_type: ComponentType = None) -> bool:
|
||||
# -------------------------------- NEED REFACTORING --------------------------------
|
||||
# -------------------------------- LOGIC ERROR -------------------------------------
|
||||
"""启用组件,支持命名空间解析"""
|
||||
# 首先尝试找到正确的命名空间化名称
|
||||
component_info = self.get_component_info(component_name, component_type)
|
||||
@@ -364,13 +365,16 @@ class ComponentRegistry:
|
||||
if namespaced_name in self._components:
|
||||
self._components[namespaced_name].enabled = True
|
||||
# 如果是Action,更新默认动作集
|
||||
if isinstance(component_info, ActionInfo):
|
||||
self._default_actions[component_name] = component_info.description
|
||||
# ---- HERE ----
|
||||
# if isinstance(component_info, ActionInfo):
|
||||
# self._action_descriptions[component_name] = component_info.description
|
||||
logger.debug(f"已启用组件: {component_name} -> {namespaced_name}")
|
||||
return True
|
||||
return False
|
||||
|
||||
def disable_component(self, component_name: str, component_type: ComponentType = None) -> bool:
|
||||
# -------------------------------- NEED REFACTORING --------------------------------
|
||||
# -------------------------------- LOGIC ERROR -------------------------------------
|
||||
"""禁用组件,支持命名空间解析"""
|
||||
# 首先尝试找到正确的命名空间化名称
|
||||
component_info = self.get_component_info(component_name, component_type)
|
||||
@@ -392,8 +396,9 @@ class ComponentRegistry:
|
||||
if namespaced_name in self._components:
|
||||
self._components[namespaced_name].enabled = False
|
||||
# 如果是Action,从默认动作集中移除
|
||||
if component_name in self._default_actions:
|
||||
del self._default_actions[component_name]
|
||||
# ---- HERE ----
|
||||
# if component_name in self._action_descriptions:
|
||||
# del self._action_descriptions[component_name]
|
||||
logger.debug(f"已禁用组件: {component_name} -> {namespaced_name}")
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -37,16 +37,14 @@ class DependencyManager:
|
||||
missing_optional = []
|
||||
|
||||
for dep in dependencies:
|
||||
if not self._is_package_available(dep.package_name):
|
||||
if dep.optional:
|
||||
missing_optional.append(dep)
|
||||
logger.warning(f"可选依赖包缺失: {dep.package_name} - {dep.description}")
|
||||
else:
|
||||
missing_required.append(dep)
|
||||
logger.error(f"必需依赖包缺失: {dep.package_name} - {dep.description}")
|
||||
else:
|
||||
if self._is_package_available(dep.package_name):
|
||||
logger.debug(f"依赖包已存在: {dep.package_name}")
|
||||
|
||||
elif dep.optional:
|
||||
missing_optional.append(dep)
|
||||
logger.warning(f"可选依赖包缺失: {dep.package_name} - {dep.description}")
|
||||
else:
|
||||
missing_required.append(dep)
|
||||
logger.error(f"必需依赖包缺失: {dep.package_name} - {dep.description}")
|
||||
return missing_required, missing_optional
|
||||
|
||||
def _is_package_available(self, package_name: str) -> bool:
|
||||
|
||||
@@ -24,12 +24,14 @@ class PluginManager:
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.plugin_directories: List[str] = []
|
||||
self.loaded_plugins: Dict[str, "BasePlugin"] = {}
|
||||
self.failed_plugins: Dict[str, str] = {}
|
||||
self.plugin_paths: Dict[str, str] = {} # 记录插件名到目录路径的映射
|
||||
self.plugin_directories: List[str] = [] # 插件根目录列表
|
||||
self.plugin_classes: Dict[str, Type[BasePlugin]] = {} # 全局插件类注册表,插件名 -> 插件类
|
||||
self.plugin_paths: Dict[str, str] = {} # 记录插件名到目录路径的映射,插件名 -> 目录路径
|
||||
|
||||
self.loaded_plugins: Dict[str, BasePlugin] = {} # 已加载的插件类实例注册表,插件名 -> 插件类实例
|
||||
self.failed_plugins: Dict[str, str] = {} # 记录加载失败的插件类及其错误信息,插件名 -> 错误信息
|
||||
|
||||
self.events_subscriptions: Dict[EventType, List[Callable]] = {}
|
||||
self.plugin_classes: Dict[str, Type[BasePlugin]] = {} # 全局插件类注册表
|
||||
|
||||
# 确保插件目录存在
|
||||
self._ensure_plugin_directories()
|
||||
|
||||
Reference in New Issue
Block a user