ReMe/reme_cli/component/application_context.py
jinli.yl 5fc57e7f4e feat(core): refactor application architecture with new component base classes
- Add BaseClient, BaseFileStore, BaseFileWatcher, BaseJob, BaseService, and BaseStep classes
- Move component initialization logic from ApplicationContext to Application class
- Add logo printing and logging initialization in Application startup
- Create client module with base client implementation
- Add file store base class with embedding resolution and validation
- Implement file watcher base class with watchfiles integration
- Add job base class for sequential step execution orchestration
- Create service base class for job exposure mechanisms
- Refactor BaseStep with LLM workflow execution capabilities
- Add case converter utility for naming convention transformations
- Update import structure and module organization
- Add proper type hints and docstrings across all components
- Implement component registry integration for dynamic loading
- Add error handling for missing backend configurations
2026-04-14 16:43:36 +08:00

33 lines
1.3 KiB
Python

"""Application context for initializing and managing all configured components."""
from ..enumeration import ComponentEnum
from ..schema import ApplicationConfig
class ApplicationContext:
"""Application context that initializes and manages all configured components.
This class is responsible for parsing the application configuration,
resolving backend implementations for each component via the registry,
and instantiating services, components, and jobs.
"""
def __init__(self, **kwargs):
"""Initialize the application context from configuration kwargs.
Args:
**kwargs: Keyword arguments that form the ApplicationConfig,
including app_name, service, components, and jobs.
Raises:
ValueError: If a required backend is missing for the service, any component, or any job,
or if a service, component, or job references an unregistered backend type.
"""
self.app_config: ApplicationConfig = ApplicationConfig(**kwargs)
from .base_component import BaseComponent
from .job.base_job import BaseJob
self.service = None
self.components: dict[ComponentEnum, dict[str, BaseComponent]] = {}
self.jobs: dict[str, BaseJob] = {}