用途:自动诊断并修复当前分支的 CI 失败。它从 GitHub Actions 获取失败日志,归类失败类型,应用针对性修复,然后提交并推送结果。
主要能力:支持 lint(ruff check)、format(ruff format)、type(mypy)、test(pytest)四类失败的识别与修复;多类失败时按 format -> lint -> type -> test 顺序处理;每类修复后本地验证,每类最多重试一次。
使用方式:命令为 /fix-ci 自动诊断修复,/fix-ci --dry-run 仅预览不修改、不提交、不推送。流程包括:用 git branch --show-current 确定分支,用 gh run list --branch <current-branch> --limit 1 --json databaseId,conclusion 获取最新运行,失败时用 gh run view <run-id> --log-failed 取日志;随后分类并执行 ruff format synapse/ tests/、ruff check --fix synapse/ tests/ 等修复;本地验证使用 ruff check synapse/ tests/、ruff format synapse/ tests/ --check、uv run mypy synapse/,涉及测试时运行 pytest;通过后 git add -u、git commit -m "fix: resolve CI failures (<categories>)"、git push。
适用场景:使用 GitHub Actions 且配置了 Ruff、Mypy、Pytest 的 Python 项目,需要快速处理当前 PR 分支 CI 失败时。
限制:需要 gh CLI 已认证,否则提示先运行 gh auth login;本地验证重试后仍失败则报告剩余问题并停止,不提交部分修复;始终使用 git push,禁止 force-push;仅暂存已修改文件,不暂存未跟踪文件。项目配置为 Python 3.10、行宽 88、规则 E,F,I,UP,B,SIM,忽略 E501、B008,排除 synapse/proto/a2a_pb2*.py;Mypy 严格模式,测试放宽,proto 文件排除;Pytest asyncio_mode 为 auto。