- 新增 GitHub Issue 模板(Bug 报告、功能请求)和 Pull Request 模板 - 新增 Code of Conduct(贡献者行为准则)和 Security Policy(安全政策) - 新增 CI 工作流(GitHub Actions),包含 ruff 代码检查和导入验证 - 新增开发依赖文件 requirements-dev.txt 📦 build(ci): 配置 GitHub Actions 持续集成 - 在 push 到 main 分支和 pull request 时自动触发 CI - 添加 lint 任务执行 ruff 代码风格检查 - 添加 import-check 任务验证核心服务模块导入 ♻️ refactor(structure): 重构项目目录结构 - 将根目录的 6 个服务模块迁移至 services/ 包 - 更新所有相关文件的导入语句(main.py、ui/、services/) - 根目录仅保留 main.py 作为唯一 Python 入口文件 🔧 chore(config): 调整配置和资源文件路径 - 将 config.json 移至 config/ 目录,更新相关引用 - 将个人头像图片移至 assets/faces/ 目录,更新 .gitignore - 更新 Dockerfile 和 docker-compose.yml 中的配置路径 📝 docs(readme): 完善 README 文档 - 添加项目状态徽章(Python 版本、License、CI) - 更新项目结构图反映实际目录布局 - 修正使用指南中的 Tab 名称和操作路径 - 替换 your-username 占位符为格式提示 🗑️ chore(cleanup): 清理冗余文件 - 删除旧版备份文件、测试脚本、临时记录和运行日志 - 删除散落的个人图片文件(已归档至 assets/faces/)
187 lines
7.6 KiB
Markdown
187 lines
7.6 KiB
Markdown
## 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
|
||

|
||
[](LICENSE)
|
||
[](https://github.com/<your-github-username>/autobot/actions/workflows/ci.yml)
|
||
```
|
||
> 将 `<your-github-username>` 替换为实际 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 正常加载,无启动错误
|