"""
Genesis System Skills Library

A comprehensive collection of AI-powered skills for the Genesis orchestration system.
Each skill is designed to be modular, self-contained, and ready for integration.

Available Skills:
-----------------

1. WebIntelligence (web_intelligence.py)
   - Web scraping using Firecrawl patterns
   - Branding extraction, screenshots, site maps
   - Knowledge base storage

2. LongDocumentAnalyzer (long_document_analyzer.py)
   - Process documents up to 1M+ tokens
   - Chunking with memory mechanism
   - Qwen-Long inspired patterns

3. CodeAnalyzer (code_analyzer.py)
   - LSP integration patterns
   - 10x token reduction for code navigation
   - Hybrid grep + precise lookup

4. ModelSelector (model_selector.py)
   - Automatic optimal model selection
   - Multi-Model-Orchestration patterns
   - Returns recommendation with reasoning

5. ResearchAgent (research_agent.py)
   - Autonomous research capability
   - Web search, analysis, synthesis
   - Persistent memory for findings

Usage:
------

Each skill can be used as a standalone script:

    python -m genesis.skills.web_intelligence https://example.com
    python -m genesis.skills.long_document_analyzer document.pdf --query "summarize"
    python -m genesis.skills.code_analyzer /path/to/project
    python -m genesis.skills.model_selector --task "analyze this code"
    python -m genesis.skills.research_agent "quantum computing advances"

Or imported programmatically:

    from genesis.skills.web_intelligence import WebIntelligence
    from genesis.skills.long_document_analyzer import LongDocumentAnalyzer
    from genesis.skills.code_analyzer import CodeAnalyzer
    from genesis.skills.model_selector import ModelSelector
    from genesis.skills.research_agent import ResearchAgent

Integration with Genesis Orchestrator:
--------------------------------------

All skills follow a consistent pattern for orchestrator integration:

    1. Each skill has a main() function as the entry point
    2. Results are returned as dataclass objects with to_dict() methods
    3. Knowledge base storage is automatic
    4. Error handling is built-in
    5. Logging is standardized

For orchestrator integration, use the skill registry:

    from genesis.skills import SKILL_REGISTRY

    skill = SKILL_REGISTRY['research']
    result = skill.execute(query="your query")
"""

__version__ = "1.0.0"
__author__ = "Genesis System"

# Skill imports with lazy loading
_skill_modules = {
    'web_intelligence': 'web_intelligence',
    'long_document_analyzer': 'long_document_analyzer',
    'code_analyzer': 'code_analyzer',
    'model_selector': 'model_selector',
    'research_agent': 'research_agent'
}

# Skill registry for orchestrator integration
SKILL_REGISTRY = {
    'web': {
        'module': 'web_intelligence',
        'class': 'WebIntelligence',
        'description': 'Web scraping and intelligence gathering',
        'entry_point': 'analyze_website'
    },
    'document': {
        'module': 'long_document_analyzer',
        'class': 'LongDocumentAnalyzer',
        'description': 'Long document analysis with memory',
        'entry_point': 'analyze'
    },
    'code': {
        'module': 'code_analyzer',
        'class': 'CodeAnalyzer',
        'description': 'Code analysis with LSP patterns',
        'entry_point': 'analyze_project'
    },
    'model': {
        'module': 'model_selector',
        'class': 'ModelSelector',
        'description': 'Optimal model selection',
        'entry_point': 'select_model'
    },
    'research': {
        'module': 'research_agent',
        'class': 'ResearchAgent',
        'description': 'Autonomous research agent',
        'entry_point': 'research'
    }
}


def get_skill(skill_name: str):
    """
    Get a skill instance by name.

    Args:
        skill_name: Name of the skill ('web', 'document', 'code', 'model', 'research')

    Returns:
        Skill instance ready for use

    Example:
        skill = get_skill('research')
        result = skill.research("quantum computing")
    """
    if skill_name not in SKILL_REGISTRY:
        raise ValueError(f"Unknown skill: {skill_name}. Available: {list(SKILL_REGISTRY.keys())}")

    skill_info = SKILL_REGISTRY[skill_name]
    module_name = skill_info['module']
    class_name = skill_info['class']

    # Dynamic import
    import importlib
    module = importlib.import_module(f'.{module_name}', package=__name__)
    skill_class = getattr(module, class_name)

    return skill_class()


def list_skills():
    """List all available skills with descriptions."""
    return {
        name: info['description']
        for name, info in SKILL_REGISTRY.items()
    }


# Convenience exports
__all__ = [
    'get_skill',
    'list_skills',
    'SKILL_REGISTRY',
    '__version__'
]
