用途:在 git push 或创建 PR 后等待 CI/CD 流水线结束,并依据结果采取行动,避免把上下文消耗在轮询逻辑上。确定性工作由脚本处理,代理只需启动脚本并对返回结果作出反应。
主要能力:提供 detect-ci.sh 检测项目使用的 CI 系统,返回 JSON(含 ci、deploy、config_file、workflow_count、repo、branch、sha、tools 等字段);提供 wait-ci.sh 以阻塞方式等待流水线完成或超时,输出含 status、conclusion、elapsed_seconds、details、url 的 JSON。支持 GitHub Actions(gh run watch 原生阻塞等待)、GitLab CI(glab ci status 轮询)、Vercel(vercel inspect 轮询)。
使用方式:先运行 bash <skill-path>/scripts/detect-ci.sh /path/to/project 检测;若 ci 为 unknown 则告知用户未找到 CI 配置并询问;若所需 CLI 工具缺失则提示安装。随后以 run_in_background: true 运行 wait-ci.sh,例如 bash <skill-path>/scripts/wait-ci.sh github-actions --repo owner/repo --branch feature-x --sha abc1234 --timeout 600。可选参数:--repo、--branch、--sha、--timeout(默认 600 秒)、--poll(默认 15 秒,仅 GitLab/Vercel)。
结果处理:success 报告成功并继续后续步骤;failure 读取 details 中的失败任务与日志摘录,修复后重新推送;cancelled 提示用户可能需重新触发;timeout 提供运行 URL 供手动检查;missing_tool 提示安装对应 CLI;no_run_found 提示推送可能未触发 CI。
适用场景:推送后验证、CI 失败后的迭代修复循环、合并 PR 前的门禁检查;也可并行监控 CI 与部署(如 GitHub Actions 与 Vercel 各起一个后台任务)。
限制:需要相应 CLI 工具(gh、glab、vercel)已安装;GitLab 与 Vercel 采用 15 秒轮询;超时默认 10 分钟;details 仅含失败任务名与失败步骤最后 30 行日志摘录。