from importlib import import_module

__all__ = [
    'SkillRegistry',
    'SkillMeta',
    'SKILL_ID_FILENAME',
    'default_project_skill_roots',
    'default_user_skill_roots',
    'write_skill_id',
    'CaptureContract',
    'EvolutionSuggestion',
    'EvolutionType',
    'ExecutionAnalysis',
    'SkillCategory',
    'SkillJudgment',
    'SkillOrigin',
    'SkillLineage',
    'SkillRecord',
    'SkillTrustState',
    'SkillVisibility',
    'SkillStore',
    'ExecutionAnalyzer',
    'DecisionEngine',
    'AdmissionResult',
    'EvolutionCandidate',
    'EvolutionCandidateStore',
    'EvolutionActionRecord',
    'EvolutionCommitter',
    'EvolutionAdmission',
    'EvolutionValidator',
    'ValidationResult',
    'SkillBehaviorEvalResult',
    'SkillBehaviorEvaluator',
    'SkillEvalAdapter',
    'SubprocessSkillReplayRunner',
    'SkillEvolver',
    'EvolutionTrigger',
    'EvolutionContext',
    'SkillTool',
    'DiscoverSkillsTool',
    'SkillListingService',
    'SkillDiscoveryService',
    'consume_dynamic_skill_triggers',
    'SKILL_TOOL_NAME',
    'DISCOVER_SKILLS_TOOL_NAME',
]

_EXPORTS = {
    'SkillRegistry': ('.registry', 'SkillRegistry'),
    'SkillMeta': ('.registry', 'SkillMeta'),
    'SKILL_ID_FILENAME': ('.registry', 'SKILL_ID_FILENAME'),
    'default_project_skill_roots': ('.registry', 'default_project_skill_roots'),
    'default_user_skill_roots': ('.registry', 'default_user_skill_roots'),
    'write_skill_id': ('.registry', 'write_skill_id'),
    'CaptureContract': ('.types', 'CaptureContract'),
    'EvolutionSuggestion': ('.types', 'EvolutionSuggestion'),
    'EvolutionType': ('.types', 'EvolutionType'),
    'ExecutionAnalysis': ('.types', 'ExecutionAnalysis'),
    'SkillCategory': ('.types', 'SkillCategory'),
    'SkillJudgment': ('.types', 'SkillJudgment'),
    'SkillOrigin': ('.types', 'SkillOrigin'),
    'SkillLineage': ('.types', 'SkillLineage'),
    'SkillRecord': ('.types', 'SkillRecord'),
    'SkillTrustState': ('.types', 'SkillTrustState'),
    'SkillVisibility': ('.types', 'SkillVisibility'),
    'SkillStore': ('.store', 'SkillStore'),
    'ExecutionAnalyzer': ('.analyzer', 'ExecutionAnalyzer'),
    'DecisionEngine': ('.decision', 'DecisionEngine'),
    'AdmissionResult': ('.evolution', 'AdmissionResult'),
    'EvolutionCandidate': ('.evolution', 'EvolutionCandidate'),
    'EvolutionCandidateStore': ('.evolution', 'EvolutionCandidateStore'),
    'EvolutionActionRecord': ('.evolution', 'EvolutionActionRecord'),
    'EvolutionCommitter': ('.evolution', 'EvolutionCommitter'),
    'EvolutionAdmission': ('.evolution', 'EvolutionAdmission'),
    'EvolutionValidator': ('.evolution', 'EvolutionValidator'),
    'ValidationResult': ('.evolution', 'ValidationResult'),
    'SkillBehaviorEvalResult': ('.evolution', 'SkillBehaviorEvalResult'),
    'SkillBehaviorEvaluator': ('.evolution', 'SkillBehaviorEvaluator'),
    'SkillEvalAdapter': ('.evolution', 'SkillEvalAdapter'),
    'SubprocessSkillReplayRunner': ('.evolution', 'SubprocessSkillReplayRunner'),
    'SkillEvolver': ('.evolver', 'SkillEvolver'),
    'EvolutionTrigger': ('.evolver', 'EvolutionTrigger'),
    'EvolutionContext': ('.evolver', 'EvolutionContext'),
    'SkillTool': ('.protocol', 'SkillTool'),
    'DiscoverSkillsTool': ('.protocol', 'DiscoverSkillsTool'),
    'SkillListingService': ('.protocol', 'SkillListingService'),
    'SkillDiscoveryService': ('.protocol', 'SkillDiscoveryService'),
    'consume_dynamic_skill_triggers': ('.protocol', 'consume_dynamic_skill_triggers'),
    'SKILL_TOOL_NAME': ('.protocol', 'SKILL_TOOL_NAME'),
    'DISCOVER_SKILLS_TOOL_NAME': ('.protocol', 'DISCOVER_SKILLS_TOOL_NAME'),
}


def __getattr__(name: str):
    try:
        module_name, attr_name = _EXPORTS[name]
    except KeyError as exc:
        raise AttributeError(f'module {__name__!r} has no attribute {name!r}') from exc
    module = import_module(module_name, __name__)
    value = getattr(module, attr_name)
    globals()[name] = value
    return value
