From a14e2bdd5023ecb5de5a5d36370a4854425f8543 Mon Sep 17 00:00:00 2001 From: meeks Date: Thu, 16 Jul 2026 12:49:12 +0200 Subject: [PATCH] Refactor vacuous interface hierarchy and remove core/interfaces.py --- core/agent.py | 3 +- core/interfaces.py | 182 --------------------------------------------- gitea/client.py | 10 +-- 3 files changed, 2 insertions(+), 193 deletions(-) delete mode 100644 core/interfaces.py diff --git a/core/agent.py b/core/agent.py index cc5eb95..2313023 100644 --- a/core/agent.py +++ b/core/agent.py @@ -2,7 +2,6 @@ import asyncio import logging import lmstudio as lms from typing import Any, Callable -from core.interfaces import Agent from .prompt import CAVEMAN_PROMPT logger: logging.Logger = logging.getLogger("agent-base") @@ -54,7 +53,7 @@ class _ActResponseCapture: return '\n'.join(self.responses) if self.responses else "No response captured." -class BaseAgent(Agent): +class BaseAgent: """Base AI agent implementing common LMStudio interaction patterns.""" def __init__(self, model_name: str) -> None: diff --git a/core/interfaces.py b/core/interfaces.py deleted file mode 100644 index d6b5586..0000000 --- a/core/interfaces.py +++ /dev/null @@ -1,182 +0,0 @@ -"""Interfaces for Gitea operations.""" - -from abc import ABC, abstractmethod -from typing import Any -from gitea.models import ( - IssueModel, - PullRequestModel, - CommentModel, - LabelModel, - UserModel, - RepositoryModel, - PullRequestFileModel, -) - - -class IssuesClient(ABC): - """Interface for Gitea issue operations.""" - - @abstractmethod - def list_repo_issues(self, owner: str, repo: str, state: str = "open") -> list[IssueModel]: ... - - @abstractmethod - def get_issue(self, owner: str, repo: str, issue_number: int) -> IssueModel: ... - - @abstractmethod - def close_issue(self, owner: str, repo: str, issue_number: int) -> IssueModel: ... - - @abstractmethod - def get_issue_comments(self, owner: str, repo: str, issue_number: int) -> list[CommentModel]: ... - - @abstractmethod - def list_assigned_issues(self, owner: str, repo: str) -> list[IssueModel]: ... - - @abstractmethod - def create_issue( - self, - owner: str, - repo: str, - title: str, - body: str, - labels: list[str] | None = None, - assignees: list[str] | None = None, - ) -> IssueModel: ... - - @abstractmethod - def add_comment(self, owner: str, repo: str, issue_number: int, body: str) -> CommentModel: ... - - @abstractmethod - def add_label(self, owner: str, repo: str, issue_number: int, label: str) -> LabelModel: ... - - -class PullRequestsClient(ABC): - """Interface for Gitea pull request operations.""" - - @abstractmethod - def list_repo_pull_requests(self, owner: str, repo: str, state: str = "open") -> list[PullRequestModel]: ... - - @abstractmethod - def get_pull_request(self, owner: str, repo: str, pull_number: int) -> PullRequestModel: ... - - @abstractmethod - def close_pull_request(self, owner: str, repo: str, pull_number: int) -> PullRequestModel: ... - - @abstractmethod - def get_pull_request_comments(self, owner: str, repo: str, pull_number: int) -> list[CommentModel]: ... - - @abstractmethod - def get_pr_reviews(self, owner: str, repo: str, pr_number: int) -> list[dict[str, Any]]: ... - - @abstractmethod - def get_pull_request_diff(self, owner: str, repo: str, pull_number: int) -> str: ... - - @abstractmethod - def get_pull_request_patch(self, owner: str, repo: str, pull_number: int) -> str: ... - - @abstractmethod - def get_pull_request_files(self, owner: str, repo: str, pull_number: int) -> list[PullRequestFileModel]: ... - - @abstractmethod - def list_assigned_pull_requests(self, owner: str, repo: str) -> list[PullRequestModel]: ... - - @abstractmethod - def create_pull_request( - self, owner: str, repo: str, head: str, base: str, title: str, description: str = "" - ) -> PullRequestModel: ... - - @abstractmethod - def update_pull_request( - self, - owner: str, - repo: str, - pull_number: int, - title: str | None = None, - body: str | None = None, - state: str | None = None, - ) -> PullRequestModel: ... - - @abstractmethod - def approve_pr(self, owner: str, repo: str, pr_number: int, comment: str) -> dict[str, Any]: ... - - @abstractmethod - def request_changes_pr(self, owner: str, repo: str, pr_number: int, comment: str) -> dict[str, Any]: ... - - @abstractmethod - def dismiss_review_pr( - self, owner: str, repo: str, pr_number: int, review_id: int, message: str - ) -> dict[str, Any]: ... - - @abstractmethod - def assign_issue(self, owner: str, repo: str, issue_number: int, username: str) -> IssueModel: ... - - -class FilesClient(ABC): - """Interface for Gitea file/content operations.""" - - @abstractmethod - def get_file_content(self, owner: str, repo: str, path: str, ref: str = "master") -> str | list[str]: ... - - @abstractmethod - def update_file( - self, owner: str, repo: str, path: str, message: str, content: str, branch: str - ) -> dict[str, Any]: ... - - -class RefsClient(ABC): - """Interface for Gitea git ref operations.""" - - @abstractmethod - def update_ref(self, owner: str, repo: str, ref: str, sha: str) -> dict[str, Any]: ... - - @abstractmethod - def create_ref(self, owner: str, repo: str, ref: str, sha: str) -> dict[str, Any]: ... - - -class ReposClient(ABC): - """Interface for Gitea repository operations.""" - - @abstractmethod - def list_all_user_repos(self) -> list[RepositoryModel]: ... - - -class Agent(ABC): - """Interface for AI agent operations.""" - - @abstractmethod - async def initialize(self) -> None: ... - - @abstractmethod - async def run(self, user_input: str) -> str: ... - - @abstractmethod - async def run_with_tools(self, user_input: str, tools: list[Any]) -> str: ... - - -class Workspace(ABC): - """Interface for workspace management.""" - - @abstractmethod - def get_repo_path(self, repo_full_name: str) -> Any: ... - - @abstractmethod - def sanitize_repo(self, repo_path: Any) -> None: ... - - @abstractmethod - def clone_repo(self, repo_full_name: str, clone_url: str) -> Any: ... - - -class MissionBuilder(ABC): - """Interface for mission string construction.""" - - @abstractmethod - def build_issue_mission(self, issue_info: dict[str, Any], branch_name: str) -> str: ... - - @abstractmethod - def build_pr_mission(self, pr_info: dict[str, Any]) -> str: ... - - -class BranchStrategy(ABC): - """Interface for branch creation strategy.""" - - @abstractmethod - async def create_or_reuse_branch(self, repo_path: Any, branch_name: str, base_branch: str | None = None) -> str: ... diff --git a/gitea/client.py b/gitea/client.py index 5fc2c65..8ea1dba 100644 --- a/gitea/client.py +++ b/gitea/client.py @@ -16,16 +16,8 @@ from .models import ( CommentModel, PullRequestFileModel, ) -from core.interfaces import ( - IssuesClient, - PullRequestsClient, - FilesClient, - RefsClient, - ReposClient, -) - -class GiteaClient(IssuesClient, PullRequestsClient, FilesClient, RefsClient, ReposClient): +class GiteaClient: """HTTP client for Gitea API v1.""" def __init__(self) -> None: