95 lines
3.0 KiB
Python
95 lines
3.0 KiB
Python
import logging
|
|
from gitea.client import GiteaClient
|
|
from core.interfaces import (
|
|
IssuesClient,
|
|
PullRequestsClient,
|
|
FilesClient,
|
|
RefsClient,
|
|
ReposClient,
|
|
)
|
|
from core.coding_agent import CodingAgent
|
|
from core.agent import CavemanAgent
|
|
from core.coordinator_agent import CoordinatorAgent
|
|
from core.planning_agent import PlanningAgent
|
|
from core.notification_agent import NotificationReaderAgent
|
|
from gitea.workspace import WorkspaceManager
|
|
|
|
logger: logging.Logger = logging.getLogger("core-factory")
|
|
|
|
|
|
class GiteaClientFactory:
|
|
"""Factory for creating Gitea client components with dependency injection support."""
|
|
|
|
@staticmethod
|
|
def create_full_client() -> GiteaClient:
|
|
return GiteaClient()
|
|
|
|
@staticmethod
|
|
def create_issues_client(client: GiteaClient | None = None) -> IssuesClient:
|
|
if client is None:
|
|
client = GiteaClient()
|
|
return client
|
|
|
|
@staticmethod
|
|
def create_prs_client(client: GiteaClient | None = None) -> PullRequestsClient:
|
|
if client is None:
|
|
client = GiteaClient()
|
|
return client
|
|
|
|
@staticmethod
|
|
def create_files_client(client: GiteaClient | None = None) -> FilesClient:
|
|
if client is None:
|
|
client = GiteaClient()
|
|
return client
|
|
|
|
@staticmethod
|
|
def create_refs_client(client: GiteaClient | None = None) -> RefsClient:
|
|
if client is None:
|
|
client = GiteaClient()
|
|
return client
|
|
|
|
@staticmethod
|
|
def create_repos_client(client: GiteaClient | None = None) -> ReposClient:
|
|
if client is None:
|
|
client = GiteaClient()
|
|
return client
|
|
|
|
|
|
class AgentFactory:
|
|
"""Factory for creating AI agent instances."""
|
|
|
|
@staticmethod
|
|
def create_coding_agent(model_name: str) -> CodingAgent:
|
|
logger.info(f"Factory creating CodingAgent with model: {model_name}")
|
|
return CodingAgent(model_name)
|
|
|
|
@staticmethod
|
|
def create_caveman_agent(model_name: str) -> CavemanAgent:
|
|
logger.info(f"Factory creating CavemanAgent with model: {model_name}")
|
|
return CavemanAgent(model_name)
|
|
|
|
@staticmethod
|
|
def create_coordinator_agent(model_name: str) -> CoordinatorAgent:
|
|
logger.info(f"Factory creating CoordinatorAgent with model: {model_name}")
|
|
return CoordinatorAgent(model_name)
|
|
|
|
@staticmethod
|
|
def create_planning_agent(model_name: str) -> PlanningAgent:
|
|
logger.info(f"Factory creating PlanningAgent with model: {model_name}")
|
|
return PlanningAgent(model_name)
|
|
|
|
@staticmethod
|
|
def create_notification_reader_agent(model_name: str) -> NotificationReaderAgent:
|
|
logger.info(f"Factory creating NotificationReaderAgent with model: {model_name}")
|
|
return NotificationReaderAgent(model_name)
|
|
|
|
|
|
|
|
class WorkspaceFactory:
|
|
"""Factory for creating workspace manager instances."""
|
|
|
|
@staticmethod
|
|
def create_workspace() -> WorkspaceManager:
|
|
logger.info("Factory creating WorkspaceManager")
|
|
return WorkspaceManager()
|