feat(multi-llm): Phase 1 - Foundation adaptor architecture
Implement base adaptor pattern for multi-LLM support (Issue #179) **Architecture:** - Created adaptors/ package with base SkillAdaptor class - Implemented factory pattern with get_adaptor() registry - Refactored Claude-specific code into ClaudeAdaptor **Changes:** - New: src/skill_seekers/cli/adaptors/base.py (SkillAdaptor + SkillMetadata) - New: src/skill_seekers/cli/adaptors/__init__.py (registry + factory) - New: src/skill_seekers/cli/adaptors/claude.py (refactored upload + enhance logic) - Modified: package_skill.py (added --target flag, uses adaptor.package()) - Modified: upload_skill.py (added --target flag, uses adaptor.upload()) - Modified: enhance_skill.py (added --target flag, uses adaptor.enhance()) **Tests:** - New: tests/test_adaptors/test_base.py (10 tests passing) - All existing tests still pass (backward compatible) **Backward Compatibility:** - Default --target=claude maintains existing behavior - All CLI tools work exactly as before without --target flag - No breaking changes **Next:** Phase 2 - Implement Gemini, OpenAI, Markdown adaptors
This commit is contained in:
124
src/skill_seekers/cli/adaptors/__init__.py
Normal file
124
src/skill_seekers/cli/adaptors/__init__.py
Normal file
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Multi-LLM Adaptor Registry
|
||||
|
||||
Provides factory function to get platform-specific adaptors for skill generation.
|
||||
Supports Claude AI, Google Gemini, OpenAI ChatGPT, and generic Markdown export.
|
||||
"""
|
||||
|
||||
from typing import Dict, Type
|
||||
|
||||
from .base import SkillAdaptor, SkillMetadata
|
||||
|
||||
# Import adaptors (some may not be implemented yet)
|
||||
try:
|
||||
from .claude import ClaudeAdaptor
|
||||
except ImportError:
|
||||
ClaudeAdaptor = None
|
||||
|
||||
try:
|
||||
from .gemini import GeminiAdaptor
|
||||
except ImportError:
|
||||
GeminiAdaptor = None
|
||||
|
||||
try:
|
||||
from .openai import OpenAIAdaptor
|
||||
except ImportError:
|
||||
OpenAIAdaptor = None
|
||||
|
||||
try:
|
||||
from .markdown import MarkdownAdaptor
|
||||
except ImportError:
|
||||
MarkdownAdaptor = None
|
||||
|
||||
|
||||
# Registry of available adaptors
|
||||
ADAPTORS: Dict[str, Type[SkillAdaptor]] = {}
|
||||
|
||||
# Register adaptors that are implemented
|
||||
if ClaudeAdaptor:
|
||||
ADAPTORS['claude'] = ClaudeAdaptor
|
||||
if GeminiAdaptor:
|
||||
ADAPTORS['gemini'] = GeminiAdaptor
|
||||
if OpenAIAdaptor:
|
||||
ADAPTORS['openai'] = OpenAIAdaptor
|
||||
if MarkdownAdaptor:
|
||||
ADAPTORS['markdown'] = MarkdownAdaptor
|
||||
|
||||
|
||||
def get_adaptor(platform: str, config: dict = None) -> SkillAdaptor:
|
||||
"""
|
||||
Factory function to get platform-specific adaptor instance.
|
||||
|
||||
Args:
|
||||
platform: Platform identifier ('claude', 'gemini', 'openai', 'markdown')
|
||||
config: Optional platform-specific configuration
|
||||
|
||||
Returns:
|
||||
SkillAdaptor instance for the specified platform
|
||||
|
||||
Raises:
|
||||
ValueError: If platform is not supported or not yet implemented
|
||||
|
||||
Examples:
|
||||
>>> adaptor = get_adaptor('claude')
|
||||
>>> adaptor = get_adaptor('gemini', {'api_version': 'v1beta'})
|
||||
"""
|
||||
if platform not in ADAPTORS:
|
||||
available = ', '.join(ADAPTORS.keys())
|
||||
if not ADAPTORS:
|
||||
raise ValueError(
|
||||
f"No adaptors are currently implemented. "
|
||||
f"Platform '{platform}' is not available."
|
||||
)
|
||||
raise ValueError(
|
||||
f"Platform '{platform}' is not supported or not yet implemented. "
|
||||
f"Available platforms: {available}"
|
||||
)
|
||||
|
||||
adaptor_class = ADAPTORS[platform]
|
||||
return adaptor_class(config)
|
||||
|
||||
|
||||
def list_platforms() -> list[str]:
|
||||
"""
|
||||
List all supported platforms.
|
||||
|
||||
Returns:
|
||||
List of platform identifiers
|
||||
|
||||
Examples:
|
||||
>>> list_platforms()
|
||||
['claude', 'gemini', 'openai', 'markdown']
|
||||
"""
|
||||
return list(ADAPTORS.keys())
|
||||
|
||||
|
||||
def is_platform_available(platform: str) -> bool:
|
||||
"""
|
||||
Check if a platform adaptor is available.
|
||||
|
||||
Args:
|
||||
platform: Platform identifier to check
|
||||
|
||||
Returns:
|
||||
True if platform is available
|
||||
|
||||
Examples:
|
||||
>>> is_platform_available('claude')
|
||||
True
|
||||
>>> is_platform_available('unknown')
|
||||
False
|
||||
"""
|
||||
return platform in ADAPTORS
|
||||
|
||||
|
||||
# Export public interface
|
||||
__all__ = [
|
||||
'SkillAdaptor',
|
||||
'SkillMetadata',
|
||||
'get_adaptor',
|
||||
'list_platforms',
|
||||
'is_platform_available',
|
||||
'ADAPTORS',
|
||||
]
|
||||
Reference in New Issue
Block a user