## Tasks ### 1. 迁移服务文件至 services/ 包(project-restructure) - [x] **1.1** 将 `config_manager.py` 移入 `services/` ```powershell Move-Item config_manager.py services\config_manager.py ``` - [x] **1.2** 将 `mcp_client.py` 移入 `services/` ```powershell Move-Item mcp_client.py services\mcp_client.py ``` - [x] **1.3** 将 `llm_service.py` 移入 `services/` ```powershell Move-Item llm_service.py services\llm_service.py ``` - [x] **1.4** 将 `sd_service.py` 移入 `services/` ```powershell Move-Item sd_service.py services\sd_service.py ``` - [x] **1.5** 将 `analytics_service.py` 移入 `services/` ```powershell Move-Item analytics_service.py services\analytics_service.py ``` - [x] **1.6** 将 `publish_queue.py` 移入 `services/` ```powershell Move-Item publish_queue.py services\publish_queue.py ``` --- ### 2. 更新外部文件的绝对导入(main.py、ui/) - [x] **2.1** 更新 `main.py` 中的导入 - `from config_manager import ConfigManager, OUTPUT_DIR` → `from services.config_manager import ConfigManager, OUTPUT_DIR` - `from llm_service import LLMService` → `from services.llm_service import LLMService` - [x] **2.2** 更新 `ui/app.py` 中的导入 - `from config_manager import ConfigManager` → `from services.config_manager import ConfigManager` - `from sd_service import SDService, DEFAULT_NEGATIVE, FACE_IMAGE_PATH, ...` → `from services.sd_service import SDService, DEFAULT_NEGATIVE, FACE_IMAGE_PATH, ...` - `from analytics_service import AnalyticsService` → `from services.analytics_service import AnalyticsService` - `from publish_queue import STATUS_LABELS` → `from services.publish_queue import STATUS_LABELS` - [x] **2.3** 更新 `ui/tab_create.py` 中的导入(检查并替换所有根目录服务模块引用) --- ### 3. 更新 services/ 内部使用相对导入 - [x] **3.1** 更新 `services/scheduler.py` - `from config_manager import ConfigManager, OUTPUT_DIR` → `from .config_manager import ConfigManager, OUTPUT_DIR` - `from llm_service import LLMService` → `from .llm_service import LLMService` - `from sd_service import SDService` → `from .sd_service import SDService` - `from mcp_client import get_mcp_client` → `from .mcp_client import get_mcp_client` - `from analytics_service import AnalyticsService` → `from .analytics_service import AnalyticsService` - [x] **3.2** 更新 `services/content.py` - `from config_manager import ConfigManager, OUTPUT_DIR` → `from .config_manager import ConfigManager, OUTPUT_DIR` - `from llm_service import LLMService` → `from .llm_service import LLMService` - `from sd_service import SDService, get_sd_preset` → `from .sd_service import SDService, get_sd_preset` - `from mcp_client import get_mcp_client` → `from .mcp_client import get_mcp_client` - [x] **3.3** 更新 `services/hotspot.py` - `from llm_service import LLMService` → `from .llm_service import LLMService` - `from mcp_client import get_mcp_client` → `from .mcp_client import get_mcp_client` - [x] **3.4** 更新 `services/engagement.py` - `from mcp_client import get_mcp_client` → `from .mcp_client import get_mcp_client` - `from llm_service import LLMService` → `from .llm_service import LLMService` - [x] **3.5** 更新 `services/profile.py` - `from mcp_client import get_mcp_client` → `from .mcp_client import get_mcp_client` - [x] **3.6** 更新 `services/persona.py` - `from config_manager import ConfigManager` → `from .config_manager import ConfigManager` - [x] **3.7** 检查 `services/queue_ops.py`、`services/rate_limiter.py`、`services/autostart.py`、`services/connection.py` 有无根目录模块引用,按需更新 --- ### 4. 回归验证——导入与语法检查 - [x] **4.1** 对所有修改文件执行 Python 语法验证 ```powershell python -c " import ast, pathlib files = ['main.py','ui/app.py','ui/tab_create.py', 'services/scheduler.py','services/content.py', 'services/hotspot.py','services/engagement.py', 'services/profile.py','services/persona.py'] for f in files: ast.parse(pathlib.Path(f).read_text(encoding='utf-8')) print(f'OK: {f}') " ``` - [x] **4.2** 执行核心服务导入验证 ```powershell python -c "from services.config_manager import ConfigManager; print('config_manager OK')" python -c "from services.llm_service import LLMService; print('llm_service OK')" python -c "from services.sd_service import SDService; print('sd_service OK')" python -c "from services.mcp_client import get_mcp_client; print('mcp_client OK')" python -c "from services.analytics_service import AnalyticsService; print('analytics_service OK')" python -c "from services.publish_queue import STATUS_LABELS; print('publish_queue OK')" ``` - [x] **4.3** 执行 UI 层导入验证 ```powershell python -c "import ui.app; print('ui.app OK')" ``` - [x] **4.4** 确认根目录无游离 `.py` 业务文件 ```powershell Get-ChildItem -Path . -MaxDepth 1 -Filter "*.py" | Select-Object Name # 预期仅显示 main.py(以及测试脚本如 _test_config_save.py) ``` --- ### 5. 添加社区健康文件(oss-community-health) - [x] **5.1** 创建 `.github/ISSUE_TEMPLATE/bug_report.md`(Bug 报告模板) 包含:问题描述、复现步骤、预期行为、实际行为、环境信息(Python 版本、OS) - [x] **5.2** 创建 `.github/ISSUE_TEMPLATE/feature_request.md`(功能请求模板) 包含:背景/需求、期望解决方案、替代方案 - [x] **5.3** 创建 `.github/pull_request_template.md`(PR 模板) 包含:变更类型(Bug Fix / Feature / Docs / Refactor)、变更描述、测试说明、相关 Issue - [x] **5.4** 创建 `CODE_OF_CONDUCT.md`(Contributor Covenant v2.1 中文版) - [x] **5.5** 创建 `SECURITY.md`(安全漏洞报告政策) 包含:支持版本、私下报告方式(GitHub Security Advisory)、响应时间承诺 --- ### 6. 添加 CI 工作流(oss-ci-workflow) - [x] **6.1** 创建 `requirements-dev.txt`,包含 `ruff>=0.4.0` - [x] **6.2** 创建 `.github/workflows/ci.yml` - trigger: `push` to `main`、`pull_request` to `main` - job `lint`: - `pip install ruff` - `ruff check . --select E,F,W --ignore E501`(宽松规则,忽略行长) - job `import-check`: - `pip install -r requirements.txt` - `python -c "from services.config_manager import ConfigManager"` - `python -c "from services.llm_service import LLMService"` - `python -c "from services.sd_service import SDService"` --- ### 7. 完善 README(oss-readme-polish) - [x] **7.1** 在 README 标题下方添加徽章(Python、MIT License、CI Status) ```markdown ![Python](https://img.shields.io/badge/python-3.10+-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![CI](https://github.com//autobot/actions/workflows/ci.yml/badge.svg)](https://github.com//autobot/actions/workflows/ci.yml) ``` > 将 `` 替换为实际 GitHub 用户名 - [x] **7.2** 修正 README 中的「项目结构」章节,反映迁移后 `services/` 的完整内容 - [x] **7.3** 全局搜索替换 `your-username` 占位符 ```powershell Select-String -Path README.md -Pattern "your-username" # 确认所有出现位置后,手动或批量替换 ``` - [x] **7.4** 检查「首次使用流程」中的 Tab 名称与实际 Gradio UI 一致 --- ### 8. 最终验证 - [x] **8.1** 执行 `git status` 确认所有变更文件符合预期 - [x] **8.2** 执行 `git diff --stat` 确认无意外文件被修改 - [x] **8.3** 启动应用:`python main.py` 确认 Gradio UI 正常加载,无启动错误