1k monitor pr ci

From OneKeyHQ/app-monorepo · View interactive version

1k monitor pr ci is an AI agent skill from the GitHub repository OneKeyHQ/app-monorepo. Monitor OneKey PR checks and review threads, fix failures, address comments, and continue until the PR is ready.

How to use this skill

Skill file

Monitor PR CI & Reviews

Monitor a pull request's CI checks and review comments. Auto-fix CI failures, address inline review comments, reply to reviewers, and resolve threads.

For a one-shot, low-context PR status summary, use:

yarn agent:check --profile ci --pr <PR_NUMBER>

For monitor automation, prefer the stable machine-readable contract:

yarn agent:check --profile ci --pr <PR_NUMBER> --json-file /tmp/agent-check.json

Read /tmp/agent-check.json instead of parsing terminal text. The report has

schemaVersion: 1, top-level status / exitCode / failureReasons, and

stable nested objects for remote.pr, remote.checks, and remote.review.

To reply to and resolve a specific review thread without starting the monitor:

yarn agent:review-thread --pr <PR_NUMBER> --list
yarn agent:review-thread --pr <PR_NUMBER> --thread <THREAD_ID> --reply-file <FILE>

Use the GraphQL thread id from --list or

remote.review.threads.unresolvedItems[].id; numeric indexes are only for

--dry-run validation.

Use this monitor workflow only when the user wants polling, automatic fixes, or

batch review-thread handling.

Usage

/1k-monitor-pr-ci https://github.com/OneKeyHQ/app-monorepo/pull/10717 3m
/1k-monitor-pr-ci 10717 5m
/1k-monitor-pr-ci https://github.com/OneKeyHQ/app-monorepo/pull/10717
/1k-monitor-pr-ci 10717
/1k-monitor-pr-ci

Input

$ARGUMENTS — Two parts, space-separated:

  1. PR identifier (required if no current branch PR): PR number, GitHub PR URL
  2. Polling interval (optional, default 6m): e.g. 30s, 1m, 2m, 3分钟, 5min, 6m

If $ARGUMENTS is empty, auto-detect PR from current branch and use default 6m interval.

Step 0: Initial Setup

  1. Parse arguments: Split $ARGUMENTS into PR identifier and polling interval.

```bash

gh pr list --head "$(git branch --show-current)" --json number --jq '.[0].number'

```

  1. Resolve owner/repo:

```bash

gh repo view --json owner,name --jq '"\(.owner.login)/\(.name)"'

```

  1. Confirm and start (no further questions needed):

```

Monitoring PR #10717 (OneKeyHQ/app-monorepo)

Polling interval: 3m

Starting...

```

Step 1: Poll Loop

Each iteration ([Check N/30]):

1a. Fetch agent-check JSON — EVERY iteration

Use agent:check as the single read path. It fetches CI checks, PR metadata,

inline comments, and GraphQL review-thread state, then writes a stable

schemaVersion: 1 JSON report.

AGENT_CHECK_JSON="$(mktemp -t agent-check.XXXXXX.json)"
yarn agent:check --profile ci --pr <PR_NUMBER> --json-file "$AGENT_CHECK_JSON" || true

Do not treat a non-zero agent:check exit code as a command failure by itself.

For monitor purposes, non-zero means the JSON contains actionable state such as

pending CI, failed CI, unresolved review threads, draft PR, blocked merge state,

or truncated review data.

Read these fields from the JSON report:

Fallback: If agent:check is unavailable or returns an unsupported

schemaVersion, use raw gh queries for the same four signals. GraphQL remains

required for thread IDs and resolution state. If GraphQL fails, fall back to the

REST API for inline comments:

gh api repos/{owner}/{repo}/pulls/{pr_number}/comments \
  --jq '.[] | {id: .id, body: .body, path: .path, line: .original_line, user: .user.login, in_reply_to_id: .in_reply_to_id, created_at: .created_at}'

Note: REST fallback can fetch comments and reply to them, but cannot resolve threads (GitHub only supports this via GraphQL). When using REST fallback, skip the resolve step (Step 3d) and log a warning that threads must be resolved manually.

Filter to only unresolved threads (isResolved: false). Skip threads where the last comment is from the current gh user (already replied).

1b. Display status summary

[Check 3/30]

CI Status:
| Check            | Status  | Duration |
|------------------|---------|----------|
| lint (24.x)      | pass    | 5m34s    |
| unittest (24.x)  | pending | -        |

Unresolved threads: 3
- src/views/Example.tsx:42 (@reviewer): "Consider using useCallback here"
- src/utils/format.ts:15 (@reviewer): "This should handle null case"
- src/components/Card.tsx:88 (@reviewer): "Typo in variable name"

1c. Decide next action

Before choosing an action, classify the agent:check JSON into three buckets:

If release-ready-merge-gate is failing, treat it as an expected merge blocker rather than a CI failure to auto-fix.

| CI Status | Unresolved Threads | Action |

|-----------|-------------------|--------|

| Normal failed checks | - | Auto-fix CI failure (Step 2) |

| Gate failure | Has threads | Address threads (Step 3), then report blocked by missing release-ready |

| Gate failure | No threads | Stop waiting and report blocked by missing release-ready |

| Any pending | Has threads | Address threads (Step 3), keep waiting for CI |

| Any pending | No threads | Wait, re-check |

| All pass | Has threads | Address threads (Step 3) |

| All pass | No threads | Done (Step 4) |

Step 2: Auto-fix CI Failures

For each failed check:

  1. Identify the actionable failed check from the latest poll result.
  1. Derive RUN_ID from the failed check link.
  1. Get failure log:

```bash

gh run view <RUN_ID> --log-failed 2>&1 | tail -100

```

  1. Analyze the failure and determine the cause.
  1. Fixable (lint error, type error, test failure from our changes):
  1. Potentially unrelated or pre-existing (repo-wide package/version consistency failure, failure in files untouched by the PR, or issue that appears to predate the PR):
  1. Not fixable (infra issue, flaky test, unrelated failure the user does not want fixed here):

Step 3: Address Review Threads

For each unresolved thread:

3a. Categorize the comment

Read the comment body and the relevant code context. Categorize:

Display a one-line log per thread of what will be done, then proceed to fix immediately. Do NOT wait for user confirmation — only pause for disagree/won't-fix cases.

3b. Fix the code

For each thread that needs a code fix:

  1. Read the file at the specified path and line
  2. Make the fix using the Edit tool
  3. Verify the fix doesn't break lint/types if quick to check

3c. Reply to the comment

Reply explaining what was done, using the REST API:

gh api --method POST \
  repos/{owner}/{repo}/pulls/{pr_number}/comments/{comment_database_id}/replies \
  -f body='Fixed: [concise explanation of the change]'

For questions (no code change needed):

gh api --method POST \
  repos/{owner}/{repo}/pulls/{pr_number}/comments/{comment_database_id}/replies \
  -f body='[answer to the question]'

Keep replies concise. Explain what was changed and why.

3d. Resolve the thread

After replying, resolve the thread via GraphQL:

gh api graphql -f query='
mutation($threadId: ID!) {
  resolveReviewThread(input: {threadId: $threadId}) {
    thread {
      isResolved
    }
  }
}' -f threadId="THREAD_NODE_ID"

Note: Resolve thread requires GraphQL — there is no REST API equivalent. If Step 1b fell back to REST, skip this step and log a warning: "Thread resolve skipped (GraphQL unavailable). Please resolve manually."

3e. Commit and push

After all threads are addressed in this iteration:

  1. Stage changed files: git add <specific files>
  2. Commit with a descriptive message:

```bash

git commit -m "fix: address PR review feedback

```

  1. Push: git push

3f. Request re-review

After pushing fixes, request re-review from the reviewers who left comments:

  1. Get reviewers who left the comments (collected from Step 1b thread data, author.login fields)
  2. Request re-review:

```bash

gh pr edit <PR_NUMBER> --add-reviewer <reviewer1>,<reviewer2>

```

Or via API if --add-reviewer doesn't trigger re-review:

```bash

gh api --method POST \

repos/{owner}/{repo}/pulls/{pr_number}/requested_reviewers \

-f 'reviewers[]=reviewer1' -f 'reviewers[]=reviewer2'

```

  1. Return to Step 1 (wait for CI to re-run)

Step 3g: Report release-ready gate blocker

If the only remaining failed check is release-ready-merge-gate, stop the polling loop and report:

CI is complete, but merge is blocked by the release-ready gate.

Blocking check:
- release-ready-merge-gate: expected failure until the PR gets the `release-ready` label

Action:
- Add the `release-ready` label to the PR, then run the monitor again if needed

Do not:

Step 4: Final Report

When all normal CI checks pass and no unresolved threads remain:

All normal CI checks passed. All review threads resolved.

CI:
| Check            | Status | Duration |
|------------------|--------|----------|
| lint (24.x)      | pass   | 5m34s    |
| unittest (24.x)  | pass   | 4m42s    |

Review threads: 5 resolved, 0 remaining
PR: <URL>
Status: Ready for re-review / Ready to merge

If release-ready-merge-gate is still failing, do not use this final report. Use the blocked-state report from Step 3g instead.

Polling Rules

Important Notes

Error Handling

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.