协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
ci-repair【开发与工程】Fix CI failures by fetching GitHub Actions logs, dispatching dev to fix, verifying locally, and pushing.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Fix a CI failure on a pull request. Fetches the failure context from GitHub Actions, dispatches the dev role with bounded logs, verifies the fix locally, and pushes only if verification passes.
GitHub Actions only. The workflow is a bounded, resumable monitor → diagnose → repair → verify loop.
max_repair_cycles: 3, max_elapsed_minutes: 90, and a
five-minute CI polling interval. User-supplied lower budgets win..agenteam/ci-repair/pr-<pr_number>.json, keyed by
head_sha. Record the run ID, failed jobs, repair attempt, local verification,
pushed SHA, last heartbeat, and stop reason.Get the PR reference from the user:
$ateam:ci-repair #42$ateam:ci-repair feature/add-authResolve the input to a canonical tuple: pr_number, pr_url,
pr_branch, head_sha.
If PR number given:
gh pr view <number> --json number,url,headRefName,headRefOid
If branch given or current branch:
BRANCH=$(git rev-parse --abbrev-ref HEAD) # if no input
gh pr list --head <branch> --json number,url,headRefName,headRefOid --limit 1
If no PR found: "No PR found for branch <branch>. Push and create
a PR first, then retry." Stop.
Extract:
pr_number from numberpr_url from urlpr_branch from headRefNamehead_sha from headRefOidGet the latest CI run for the PR's current head commit:
gh run list --commit <head_sha> --limit 5 \
--json status,conclusion,databaseId,name,createdAt
Check the latest run for this exact commit:
failure → proceed to fetch context (step 4)success → "CI is passing on the current head commit. No
repair needed." Stop.in_progress or queued → Persist the run ID and heartbeat, then
monitor it within the elapsed budget. Poll no more frequently than the
configured interval. If this invocation cannot keep monitoring, arrange a
follow-up and stop with reason ci_wait_scheduled.<head_sha>.
Push or re-run CI, then retry." Stop.Get structural info (which jobs/steps failed):
gh run view <run-id> --json jobs
Get truncated logs for failed steps:
gh run view <run-id> --log-failed 2>/dev/null | tail -400
Context budget:
Format the failure summary:
## CI Failure Summary
**PR:** #<number> (<branch>)
**Run:** <run-url>
**Commit:** <head_sha>
**Status:** failure
### Failed Job: <job-name> (<runner>)
**Failed Step:** <step-name> (exit code <N>)
<step log output, last 100 lines>
If multiple jobs failed, include up to 3, each with their failed step logs.
Before dispatching dev, ensure a clean state on the correct branch.
Preflight:
bash <plugin-dir>/scripts/git-isolate.sh preflight
not-a-git-repo → stop. CI repair requires git.dirty-worktree → stop. Tell user: "Uncommitted changes
detected. Stash or commit before CI repair to avoid staging
unrelated files."detached-head → stop. Tell user: "Detached HEAD. Checkout
a branch before CI repair."Checkout the PR branch:
git fetch origin <pr_branch>
git checkout <pr_branch>
git pull origin <pr_branch>
If already on the PR branch and up to date, skip checkout.
Record repair baseline:
REPAIR_BASELINE=$(git rev-parse HEAD)
Used in step 8 to commit only the repair changes.
Dispatch the dev role as a subagent with:
Append systematic debugging guidance directly to the dev prompt: "Use a systematic debugging approach: reproduce the failure locally if possible, identify the root cause from the CI logs, then fix. Do not guess — trace the error."
Note: The hotl-skills adapter is NOT used for standalone CI
repair invocations — it requires a --run-id with pipeline state
that doesn't exist here. Debugging guidance is injected directly
into the prompt instead.
After dev completes the fix, run local verification:
python3 <runtime>/agenteam_rt.py final-verify-plan
This returns the project's verify commands (auto-detected or configured).
Only if local verify passed (or user confirmed unverified push):
Always re-read headRefOid immediately before committing and pushing. It must equal
the checkpoint's expected head SHA; otherwise stop with head_changed so a
concurrent contributor's update is never overwritten.
# Commit only files changed since repair baseline
git diff --name-only $REPAIR_BASELINE | xargs git add
git commit -m "[ateam:ci-repair] Fix CI failure in <failed-step>"
git push origin <pr_branch>
If no files changed since baseline: "Dev made no changes. The fix may require a different approach." Do NOT create an empty commit. Stop.
Success report:
CI repair pushed to <pr_branch>.
- Fixed: <brief description of what dev changed>
- Files changed: <list of files modified since baseline>
- Local verify: passed (or: unverified — user confirmed)
- PR: <pr_url>
- CI will re-run automatically.
After pushing, store the new head SHA and return to step 3. Continue the bounded
loop until CI succeeds or max_repair_cycles/max_elapsed_minutes is reached.
Each new failing SHA gets its own diagnostic and repair record; the same SHA is
never repaired twice after a successful local verification and push.
Failure report (local verify failed):
CI repair NOT pushed — local verification failed.
- Failure: <verify output excerpt>
- The fix may be incomplete. Review and retry with:
$ateam:ci-repair <pr_number>
gh CLI is not installed: show install instructions and stopgh is not authenticated: tell user to run gh auth loginResolve the AgenTeam runtime:
./runtime/agenteam_rt.py<plugin-install-path>/runtime/agenteam_rt.py