From 6c75421bad54287d5b70dcaada40942d3c20a050 Mon Sep 17 00:00:00 2001 From: app_modernization Date: Thu, 23 Apr 2026 19:22:02 +0800 Subject: [PATCH 1/4] feat(watch-pr): auto-fix CI failures and review comments Co-Authored-By: Claude Opus 4 --- framework/commands/claude/pilot-watch-pr.md | 214 +++++++++++++++++-- framework/commands/copilot/pilot-watch-pr.md | 167 +++++++++++++-- 2 files changed, 355 insertions(+), 26 deletions(-) diff --git a/framework/commands/claude/pilot-watch-pr.md b/framework/commands/claude/pilot-watch-pr.md index d35298a..46b867a 100644 --- a/framework/commands/claude/pilot-watch-pr.md +++ b/framework/commands/claude/pilot-watch-pr.md @@ -1,10 +1,21 @@ -You are a lightweight PR monitoring daemon. **Automatically start monitoring on launch** using Claude Code's native scheduling. No need to ask the user. +You are a PR monitoring daemon with auto-fix capabilities. **Automatically start monitoring on launch** using Claude Code's native scheduling. No need to ask the user. ## Context - **Repos**: Read `~/.claude/pilot.yaml` → use the full `repos` list. Monitor PRs across ALL configured repos. - **Scope**: Only my own PRs (`--author @me`). +## Configuration + +Read `~/.claude/pilot.yaml` for auto-fix settings: +```yaml +watch_pr: + auto_fix_ci: true # default: true — auto-fix CI failures + auto_fix_comments: false # default: false — auto-fix review comments +``` + +If `watch_pr` section is missing, use defaults above. + ## Workspace Read `~/.claude/pilot.yaml` and extract: @@ -32,13 +43,14 @@ Use the correct CLI based on `$PLATFORM`. GraphQL review thread checks only work ``` CronCreate( cron="*/10 * * * *", - prompt="Run PR monitoring check cycle: fetch my open PRs from all repos in ~/.claude/pilot.yaml, detect new unresolved comments or ready-to-merge status, and report changes. See /pilot-watch-pr for full instructions.", + prompt="Run PR monitoring check cycle: fetch my open PRs from all repos in ~/.claude/pilot.yaml, detect CI failures, unresolved comments, or ready-to-merge status, auto-fix where enabled, and report changes. See /pilot-watch-pr for full instructions.", recurring=true ) ``` 3. **Report to user**: ``` PR Monitor started. Checking every 10 minutes (auto-expires after 7 days). +Auto-fix CI: | Auto-fix comments: Cron job ID: — cancel anytime with CronDelete. ``` @@ -76,18 +88,20 @@ query($owner:String!,$repo:String!,$number:Int!) { }' -f owner="$OWNER" -f repo="$REPO_NAME" -F number=$PR_NUMBER ``` -### Step 2: Detect only TWO conditions +### Step 2: Detect THREE conditions | Condition | How to detect | |-----------|---------------| +| **CI failure** | `statusCheckRollup` contains any check with `conclusion` of `FAILURE`, `ERROR`, `TIMED_OUT`, or `STARTUP_FAILURE` | | **New unresolved comments** | PR has unresolved review threads (`isResolved: false`) | | **Ready to merge** | `reviewDecision === "APPROVED"` AND all status checks pass AND not a draft | ### Step 3: Compare with last check — only act on NEW changes -Track state from the previous cycle. Only report when something **changed**: +Track state from the previous cycle. Only report/act when something **changed**: -- **New unresolved comments appeared** (count increased) → report +- **CI just failed** (was passing or pending before) → report + auto-fix if enabled +- **New unresolved comments appeared** (count increased) → report + auto-fix if enabled - **PR just became ready to merge** (wasn't ready before) → report If nothing changed: @@ -102,16 +116,33 @@ When a condition is detected and it's **NEW** (changed since last cycle): #### Terminal output (one line per PR): ``` PR Monitor —