zhoujie 2ba87c8f6e
Some checks failed
CI / Lint (ruff) (push) Has been cancelled
CI / Import Check (push) Has been cancelled
📝 docs(project): 添加开源社区标准文档与 CI 工作流
- 新增 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/)
2026-02-27 22:12:39 +08:00

7.6 KiB
Raw Permalink Blame History

Tasks

1. 迁移服务文件至 services/ 包project-restructure

  • 1.1config_manager.py 移入 services/

    Move-Item config_manager.py services\config_manager.py
    
  • 1.2mcp_client.py 移入 services/

    Move-Item mcp_client.py services\mcp_client.py
    
  • 1.3llm_service.py 移入 services/

    Move-Item llm_service.py services\llm_service.py
    
  • 1.4sd_service.py 移入 services/

    Move-Item sd_service.py services\sd_service.py
    
  • 1.5analytics_service.py 移入 services/

    Move-Item analytics_service.py services\analytics_service.py
    
  • 1.6publish_queue.py 移入 services/

    Move-Item publish_queue.py services\publish_queue.py
    

2. 更新外部文件的绝对导入main.py、ui/

  • 2.1 更新 main.py 中的导入

    • from config_manager import ConfigManager, OUTPUT_DIRfrom services.config_manager import ConfigManager, OUTPUT_DIR
    • from llm_service import LLMServicefrom services.llm_service import LLMService
  • 2.2 更新 ui/app.py 中的导入

    • from config_manager import ConfigManagerfrom 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 AnalyticsServicefrom services.analytics_service import AnalyticsService
    • from publish_queue import STATUS_LABELSfrom services.publish_queue import STATUS_LABELS
  • 2.3 更新 ui/tab_create.py 中的导入(检查并替换所有根目录服务模块引用)


3. 更新 services/ 内部使用相对导入

  • 3.1 更新 services/scheduler.py

    • from config_manager import ConfigManager, OUTPUT_DIRfrom .config_manager import ConfigManager, OUTPUT_DIR
    • from llm_service import LLMServicefrom .llm_service import LLMService
    • from sd_service import SDServicefrom .sd_service import SDService
    • from mcp_client import get_mcp_clientfrom .mcp_client import get_mcp_client
    • from analytics_service import AnalyticsServicefrom .analytics_service import AnalyticsService
  • 3.2 更新 services/content.py

    • from config_manager import ConfigManager, OUTPUT_DIRfrom .config_manager import ConfigManager, OUTPUT_DIR
    • from llm_service import LLMServicefrom .llm_service import LLMService
    • from sd_service import SDService, get_sd_presetfrom .sd_service import SDService, get_sd_preset
    • from mcp_client import get_mcp_clientfrom .mcp_client import get_mcp_client
  • 3.3 更新 services/hotspot.py

    • from llm_service import LLMServicefrom .llm_service import LLMService
    • from mcp_client import get_mcp_clientfrom .mcp_client import get_mcp_client
  • 3.4 更新 services/engagement.py

    • from mcp_client import get_mcp_clientfrom .mcp_client import get_mcp_client
    • from llm_service import LLMServicefrom .llm_service import LLMService
  • 3.5 更新 services/profile.py

    • from mcp_client import get_mcp_clientfrom .mcp_client import get_mcp_client
  • 3.6 更新 services/persona.py

    • from config_manager import ConfigManagerfrom .config_manager import ConfigManager
  • 3.7 检查 services/queue_ops.pyservices/rate_limiter.pyservices/autostart.pyservices/connection.py 有无根目录模块引用,按需更新


4. 回归验证——导入与语法检查

  • 4.1 对所有修改文件执行 Python 语法验证

    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}')
    "
    
  • 4.2 执行核心服务导入验证

    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')"
    
  • 4.3 执行 UI 层导入验证

    python -c "import ui.app; print('ui.app OK')"
    
  • 4.4 确认根目录无游离 .py 业务文件

    Get-ChildItem -Path . -MaxDepth 1 -Filter "*.py" | Select-Object Name
    # 预期仅显示 main.py以及测试脚本如 _test_config_save.py
    

5. 添加社区健康文件oss-community-health

  • 5.1 创建 .github/ISSUE_TEMPLATE/bug_report.mdBug 报告模板) 包含问题描述、复现步骤、预期行为、实际行为、环境信息Python 版本、OS

  • 5.2 创建 .github/ISSUE_TEMPLATE/feature_request.md(功能请求模板) 包含:背景/需求、期望解决方案、替代方案

  • 5.3 创建 .github/pull_request_template.mdPR 模板) 包含变更类型Bug Fix / Feature / Docs / Refactor、变更描述、测试说明、相关 Issue

  • 5.4 创建 CODE_OF_CONDUCT.mdContributor Covenant v2.1 中文版)

  • 5.5 创建 SECURITY.md(安全漏洞报告政策) 包含支持版本、私下报告方式GitHub Security Advisory、响应时间承诺


6. 添加 CI 工作流oss-ci-workflow

  • 6.1 创建 requirements-dev.txt,包含 ruff>=0.4.0

  • 6.2 创建 .github/workflows/ci.yml

    • trigger: push to mainpull_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. 完善 READMEoss-readme-polish

  • 7.1 在 README 标题下方添加徽章Python、MIT License、CI Status

    ![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/<your-github-username>/autobot/actions/workflows/ci.yml/badge.svg)](https://github.com/<your-github-username>/autobot/actions/workflows/ci.yml)
    

    <your-github-username> 替换为实际 GitHub 用户名

  • 7.2 修正 README 中的「项目结构」章节,反映迁移后 services/ 的完整内容

  • 7.3 全局搜索替换 your-username 占位符

    Select-String -Path README.md -Pattern "your-username"
    # 确认所有出现位置后,手动或批量替换
    
  • 7.4 检查「首次使用流程」中的 Tab 名称与实际 Gradio UI 一致


8. 最终验证

  • 8.1 执行 git status 确认所有变更文件符合预期
  • 8.2 执行 git diff --stat 确认无意外文件被修改
  • 8.3 启动应用:python main.py 确认 Gradio UI 正常加载,无启动错误