All checks were successful
Build and Deploy Log Center / build-and-deploy (push) Successful in 1m31s
72 lines
2.4 KiB
Python
72 lines
2.4 KiB
Python
"""
|
|
配置管理
|
|
"""
|
|
import os
|
|
from typing import Optional
|
|
from pydantic_settings import BaseSettings
|
|
from pydantic import Field
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Repair Agent 配置"""
|
|
|
|
# Log Center
|
|
log_center_url: str = Field(
|
|
default="https://qiyuan-log-center-api.airlabs.art",
|
|
description="Log Center API 地址"
|
|
)
|
|
|
|
# Claude CLI
|
|
claude_cli_path: str = Field(default="claude", description="Claude CLI 路径")
|
|
claude_timeout: int = Field(default=1000, description="Claude CLI 超时时间(秒)")
|
|
|
|
# Git
|
|
git_user_name: str = Field(default="repair-agent", description="Git 用户名")
|
|
git_user_email: str = Field(default="agent@airlabs.art", description="Git 邮箱")
|
|
gitea_token: Optional[str] = Field(default=None, description="Gitea Token")
|
|
|
|
# 安全配置
|
|
max_retry_count: int = Field(default=3, description="最大重试次数")
|
|
max_modified_lines: int = Field(default=500, description="最大修改行数")
|
|
max_modified_files: int = Field(default=20, description="最大修改文件数")
|
|
critical_files: str = Field(
|
|
default="payment,auth,security",
|
|
description="核心文件关键词,逗号分隔"
|
|
)
|
|
|
|
# 项目路径映射
|
|
path_rtc_backend: str = Field(
|
|
default="/Users/maidong/Desktop/zyc/qy_gitlab/rtc_backend",
|
|
description="rtc_backend 本地路径"
|
|
)
|
|
path_rtc_web: str = Field(
|
|
default="/Users/maidong/Desktop/zyc/qy_gitlab/rtc_web",
|
|
description="rtc_web 本地路径"
|
|
)
|
|
path_airhub_app: str = Field(
|
|
default="/Users/maidong/Desktop/zyc/qiyuan_gitea/rtc_prd/airhub_app",
|
|
description="airhub_app 本地路径"
|
|
)
|
|
|
|
class Config:
|
|
env_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".env")
|
|
env_file_encoding = "utf-8"
|
|
extra = "ignore"
|
|
|
|
def get_project_path(self, project_id: str) -> Optional[str]:
|
|
"""获取项目本地路径"""
|
|
path_map = {
|
|
"rtc_backend": self.path_rtc_backend,
|
|
"rtc_web": self.path_rtc_web,
|
|
"airhub_app": self.path_airhub_app,
|
|
}
|
|
return path_map.get(project_id)
|
|
|
|
def get_critical_files(self) -> list[str]:
|
|
"""获取核心文件关键词列表"""
|
|
return [f.strip() for f in self.critical_files.split(",") if f.strip()]
|
|
|
|
|
|
# 单例
|
|
settings = Settings()
|