--- name: review-fixer description: Reads unresolved review comments on a pull request — from the `pr-reviewer` agent, repo members, or allowlisted review bots — applies code fixes for the actionable ones, runs the repo's checks, and pushes. Thin skill wrapper around the `review-fixer` sub-agent; ends with a machine-readable `result` block. In a workflow, use `review-fixer-workflow`. tools: Bash, PowerShell, Read, Glob, Grep, Agent --- # Review Fixer Wraps the `task-agent:review-fixer` sub-agent so it can be invoked as a skill. It fixes review comments no matter who left them, as long as the author is trusted (repo members, the account running the workflow, or an allowlisted review bot); comments from anyone else are reported and ignored. It replaces the former `copilot-review-fixer`. **Arguments** (key=value form): - `pr_url=` — full GitHub PR URL (e.g. `https://github.com/owner/repo/pull/42`). Required. - `repo=` — repository in `owner/repo` format. Required. - `branch=` — branch name the PR is on. Required. - `reviewers=` — extra review-bot logins to trust, on top of `copilot-pull-request-reviewer` and `coderabbitai`. Optional. - `poll=` — how many times to re-check, 60 seconds apart, when no trusted comment exists yet. Optional, default `3`; `0` checks once. ## What to do ### Step 1 — Parse arguments Parse `pr_url`, `repo`, `branch`, `reviewers` and `poll` from the invocation arguments. Derive: - `OWNER` and `REPO_NAME` from `repo` (split on `/`) - `PR_NUMBER` from the last path segment of `pr_url` If any required argument is missing or cannot be parsed, stop and report the error clearly. If `poll` is not a non-negative integer, stop and report it. Validate the target before touching any clone: ```bash case "$PR_URL" in "https://github.com/$OWNER/$REPO_NAME/pull/"*) ;; *) echo "pr_url does not belong to $repo"; exit 1;; esac gh pr view "$PR_NUMBER" --repo "$repo" --json headRefName,headRepository,headRepositoryOwner,state ``` Stop unless the PR is open, `headRefName` equals `branch`, and the head repository is `repo` itself (the fixer pushes to `origin/BRANCH`, which a fork PR does not have). ### Step 2 — Prepare the local clone Reuse the `task-agent` workdir convention so the clone is shared with a preceding `task-agent` run: ```bash WORKDIR="${TASK_AGENT_WORKDIR:-$(python3 -c 'import os,tempfile;print(os.path.join(tempfile.gettempdir(),"task-agent"))')}" LOCAL_PATH="$WORKDIR/$REPO_NAME" if [ ! -d "$LOCAL_PATH/.git" ]; then mkdir -p "$WORKDIR" git clone "https://github.com/$OWNER/$REPO_NAME.git" "$LOCAL_PATH" fi ``` Verify the reused clone is this repository before using it (clones of different owners can share a name). A GitHub `origin` for a different `owner/repo` is an error; non-GitHub origins (local mirrors) are accepted: ```bash ORIGIN=$(git -C "$LOCAL_PATH" remote get-url origin) case "$ORIGIN" in *github.com[:/]*) SLUG=$(printf '%s' "$ORIGIN" | sed -E 's#.*github.com[:/]##; s#\.git$##') [ "$(printf '%s' "$SLUG" | tr A-Z a-z)" = "$(printf '%s' "$repo" | tr A-Z a-z)" ] || { echo "$LOCAL_PATH is a clone of $SLUG, not $repo"; exit 1; } ;; esac ``` Never discard local work. Refuse a dirty or diverged clone instead of resetting it: ```bash git -C "$LOCAL_PATH" fetch origin [ -z "$(git -C "$LOCAL_PATH" status --porcelain)" ] || { echo "$LOCAL_PATH has uncommitted changes; refusing to reset"; exit 1; } git -C "$LOCAL_PATH" checkout "$BRANCH" git -C "$LOCAL_PATH" merge --ff-only "origin/$BRANCH" || { echo "local $BRANCH has diverged from origin; refusing to reset"; exit 1; } ``` Detect the default branch: ```bash DEFAULT_BRANCH=$(git -C "$LOCAL_PATH" symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||') DEFAULT_BRANCH="${DEFAULT_BRANCH:-main}" ``` ### Step 3 — Spawn the sub-agent Spawn the `review-fixer` sub-agent via the `Agent` tool (`subagent_type: task-agent:review-fixer`), passing all resolved values in the prompt so the agent can substitute them for `OWNER`, `REPO_NAME`, `PR_NUMBER`, `BRANCH`, `LOCAL_PATH`, `DEFAULT_BRANCH`, `REVIEWERS` and `POLL_RETRIES`. ### Step 4 — Relay the report Print the agent's report verbatim, including the "Ignored" list: it is how the user finds out that a comment from an untrusted author was deliberately not acted on. ### Step 5 — Result block End your reply with one fenced `json` block, labelled `result:` on the line before it, after the relayed report: ```` result: ```json {"fixed": 2, "resolved": 2, "skipped": 0, "ignored": 1, "pushed": true, "commit": ""} ``` ```` The counts are the `N` of the report's `Fixed`, `Resolved threads`, `Skipped` and `Ignored` lists. `pushed` is `true` only when a commit was pushed; `commit` is its SHA, or `""` when none. If the agent failed (a failing check, a rejected push), stop with that error and emit no block.