Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: add conflict resolution for bot PRs to nightly cleaner (#1307)
worktrunk-botac0ade9b6342
diff --git a/.github/workflows/claude-nightly-cleaner.yaml b/.github/workflows/claude-nightly-cleaner.yamlindex 9904f2478..26b103aaa 100644--- a/.github/workflows/claude-nightly-cleaner.yaml+++ b/.github/workflows/claude-nightly-cleaner.yaml@@ -1,9 +1,9 @@name: claude-nightly-cleaner# Runner versions pinned; see ci.yaml header comment for rationale.-# Nightly code quality sweep — reviews all commits merged to main in the past-# 24 hours for bugs, inconsistencies, and improvement opportunities. Also closes-# open issues that have been resolved by recent (or earlier unlinked) merges.+# Nightly code quality sweep — resolves merge conflicts on bot PRs, reviews all+# commits merged to main in the past 24 hours for bugs, inconsistencies, and+# improvement opportunities, and closes open issues resolved by recent merges.on:schedule:# Run at 6:17 AM UTC daily (off-peak minute)@@ -51,7 +51,34 @@ jobs:actions: readprompt: |- You are running as a nightly code quality sweep. Your job is to review all commits merged to main in the past 24 hours, find mistakes and improvement opportunities, and create issues or PRs.+ You are running as a nightly code quality sweep. Your job has two phases: first resolve conflicts on bot PRs, then review recent commits.++ ## Step 0: Resolve conflicts on bot PRs++ Check for open PRs authored by `worktrunk-bot` that have merge conflicts:++ ```+ gh pr list --author worktrunk-bot --json number,title,mergeable,headRefName \+ --jq '.[] | select(.mergeable == "CONFLICTING")'+ ```++ If there are conflicted PRs, resolve each one using a subagent (use the Task tool). For each conflicted PR, dispatch a subagent with these instructions:++ 1. Check out the PR branch: `gh pr checkout <number>`+ 2. Merge the default branch: `git merge origin/main`+ 3. If there are conflicts, resolve them by reading the conflicting files, understanding both sides, and making the correct resolution. Use `git diff` and read the files to understand the conflict context. After resolving, `git add` the resolved files and `git commit --no-edit`.+ 4. Push the result: `git push`+ 5. Comment on the PR with a brief summary of what was resolved (e.g., `gh pr comment <number> --body "..."`).+ 6. If the conflicts are too complex to resolve confidently, abort with `git merge --abort` and comment on the PR explaining that manual resolution is needed.+ 7. After pushing, wait for CI with `gh pr checks <number> --watch`. If CI fails, investigate and fix.++ Run subagents in parallel for independent PRs. Each subagent must work in an isolated directory to avoid checkout conflicts (e.g., `git worktree add /tmp/pr-<number> <branch>` or `git clone . /tmp/pr-<number>`). After all subagents complete, clean up temp directories and switch back to main before proceeding:++ ```+ git checkout main+ ```++ If no PRs have conflicts, skip this step.## Step 1: Find recent commits