Skip to content

Commit db8f15e

Browse files
authored
Merge branch 'master' into claude/eager-goldberg-fhHjL
2 parents 6291745 + 784d1e7 commit db8f15e

16 files changed

Lines changed: 1095 additions & 221 deletions

File tree

.github/workflows/lint.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
---
12
name: Lint
23

3-
on: # yamllint disable-line rule:truthy
4+
# yamllint disable rule:truthy
5+
"on":
46
push:
57
branches:
68
- main
9+
- master
710
- "claude/**"
811
pull_request:
912
branches:
1013
- main
14+
- master
1115

1216
permissions: {}
1317

@@ -23,12 +27,32 @@ jobs:
2327

2428
steps:
2529
- name: Checkout code
26-
uses: actions/checkout@v6
30+
# actions/checkout v4.2.2
31+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2732
with:
2833
fetch-depth: 0
2934
persist-credentials: false
3035

3136
- name: Super-linter
32-
uses: super-linter/super-linter@v8.6.0
37+
# super-linter v8.6.0
38+
uses: super-linter/super-linter@9e863354e3ff62e0727d37183162c4a88873df41
3339
env:
3440
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
DEFAULT_BRANCH: master
42+
VALIDATE_ALL_CODEBASE: false
43+
VALIDATE_BASH: true
44+
VALIDATE_BASH_EXEC: true
45+
VALIDATE_CHECKOV: true
46+
VALIDATE_GITHUB_ACTIONS: true
47+
VALIDATE_GITHUB_ACTIONS_ZIZMOR: true
48+
VALIDATE_GITLEAKS: true
49+
VALIDATE_GIT_MERGE_CONFLICT_MARKERS: true
50+
VALIDATE_JSON: true
51+
VALIDATE_JSON_PRETTIER: true
52+
VALIDATE_MARKDOWN: true
53+
VALIDATE_MARKDOWN_PRETTIER: true
54+
VALIDATE_RENOVATE: true
55+
VALIDATE_SHELL_SHFMT: true
56+
VALIDATE_TRIVY: true
57+
VALIDATE_YAML: true
58+
VALIDATE_YAML_PRETTIER: true

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ This repository also ships Codex plugin metadata in place:
9797
# Detects main/master, creates feature/X branch, implements, creates PR
9898
```
9999

100+
### PR Babysitting with /goal
101+
```bash
102+
# Set a persistent goal to babysit a PR — auto-fix CI, address reviews, wait for green
103+
/goal /github:babysit-pr https://github.com/duyet/clickhouse-monitoring/pull/1355
104+
105+
# With auto-merge and CI fixing
106+
/goal /github:babysit-pr --pr 1355 --auto-merge --fix-ci
107+
```
108+
100109
---
101110

102111
## Plugins at a Glance

github/commands/babysit-pr.md

Lines changed: 146 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,80 @@
11
---
2-
allowed-tools: Bash(git *), Bash(gh *), Read, Edit, Write, Glob, Grep, Agent
3-
description: Babysit a PR - monitor, fix review bot suggestions, resolve conflicts, and merge when ready
2+
allowed-tools: Bash(git *), Bash(gh *), Read, Edit, Write, Glob, Grep, Agent, Task(general-purpose,code-review)
3+
description: Babysit a PR - monitor, auto-fix review comments, ensure CI is green, handle auto-merge, and merge when ready
44
---
55

66
# Babysit PR
77

8-
Continuously monitor a pull request, read AI review bot comments (CodeRabbit, Sourcery, Gemini), fix suggested issues, resolve merge conflicts, and merge when ready. Reports total effort at completion.
8+
Continuously monitor a pull request with intelligent automation:
9+
- **Auto-address code review comments** from AI bots (CodeRabbit, Sourcery, Gemini) and human reviewers
10+
- **Auto-fix CI failures** by analyzing logs, fixing issues, and retrying
11+
- **Keep PR in green state** by monitoring CI checks and resolving blockers
12+
- **Smart merge handling** for repos with auto-merge enabled
13+
- **Effort tracking** — reports total fixes, conflicts, and duration at completion
14+
15+
This command **always** ensures the PR CI is green before considering the job done. It will auto-fix CI failures, auto-address all review comments (from bots and humans), and **wait** until everything is green — CI checks passing, no unresolved review comments, no merge conflicts. Do not stop the loop until all conditions are met or max iterations is reached.
916

1017
## Usage
1118

1219
```bash
1320
/github:babysit-pr
1421
/github:babysit-pr --pr 123
1522
/github:babysit-pr --auto-merge
23+
/github:babysit-pr --fix-ci # Auto-fix CI failures
24+
/github:babysit-pr --force-merge # Force merge even if auto-merge is stuck
1625
/github:babysit-pr --max-iterations 10
26+
/github:babysit-pr --ci-timeout 30 # CI wait timeout in minutes
1727
/github:babysit-pr --dry-run
1828
```
1929

2030
## Options
2131

2232
- `--pr <number>`: Specific PR number (default: current branch's PR)
2333
- `--auto-merge`: Merge PR when CI passes and all review comments are resolved
34+
- `--fix-ci`: Attempt to auto-fix CI failures by analyzing error logs
35+
- `--force-merge`: Force merge via API even if auto-merge is stuck (use with caution)
2436
- `--max-iterations <n>`: Maximum fix iterations (default: 10)
37+
- `--ci-timeout <n>`: Maximum minutes to wait for CI (default: 15)
2538
- `--dry-run`: Preview what would happen without making changes
2639

2740
## How It Works
2841

2942
### 1. Initial Setup
3043
- Verify we're on a feature branch (not main/master)
3144
- Find the PR for current branch (or use `--pr`)
45+
- Check if repo has auto-merge enabled (for later handling)
3246
- Record start time for effort tracking
47+
- Validate git state (no uncommitted changes)
3348

3449
### 2. Babysit Loop
3550

3651
For each iteration:
3752

3853
#### Step A: Wait for CI and Reviews
39-
- Poll CI status until all checks complete (or timeout after 15 min)
40-
- Wait for review bots to post their comments (30s grace period after CI)
54+
- Poll CI status until all checks complete (timeout per `--ci-timeout`, default 15 min)
55+
- Track which checks are failing vs passing
56+
- Wait for review bots to post their comments (30s grace period after CI completes)
57+
58+
**Auto-fix CI Failures (if `--fix-ci`):**
59+
```bash
60+
# Get CI workflow run details
61+
gh api repos/{owner}/{repo}/actions/runs/{run_id}
62+
63+
# Download and analyze CI logs
64+
gh run view $RUN_ID --log
65+
66+
# Parse error messages and attempt smart fixes:
67+
# - Linting errors → run linter auto-fix (eslint --fix, prettier, etc.)
68+
# - Type errors → analyze TS/flow errors and fix types
69+
# - Test failures → analyze stack trace and fix tests/code
70+
# - Build errors → fix build config or dependency issues
71+
```
72+
73+
If CI check fails after analysis:
74+
1. Attempt automatic fix using code understanding (not trial-and-error)
75+
2. Run specific failing check locally to verify fix
76+
3. Commit fix and push (this triggers new CI run)
77+
4. Re-poll CI status
4178

4279
#### Step B: Fetch ALL Review Comments
4380
Read all review comments — both from AI bots and human reviewers:
@@ -87,8 +124,15 @@ For each unresolved review comment (bot or human):
87124
2. Read the suggested change or instruction
88125
3. For bot comments: extract structured suggestions (code blocks, diffs)
89126
4. For human comments: read the instruction and apply using code understanding
90-
5. Apply the fix (not blind text replacement — understand intent)
91-
6. Track the fix in effort report
127+
5. Apply the fix intelligently (understand intent, don't blindly replace)
128+
6. Validate fix (run tests, lint checks if applicable)
129+
7. Track the fix in effort report
130+
131+
**Auto-integrate suggestions from other agents:**
132+
- Monitor for comments from other AI agents (autofix agents, ML agents)
133+
- Parse structured fix suggestions from agent comments
134+
- Apply verified, safe suggestions automatically
135+
- Flag suspicious or conflicting suggestions for manual review
92136

93137
#### Step E: Commit and Push
94138
```bash
@@ -105,10 +149,44 @@ git push
105149

106150
#### Step F: Check Completion
107151
Exit loop if:
108-
- CI passes AND no unresolved review comments → ready to merge
152+
- CI passes (all green) AND no unresolved review comments → ready to merge
109153
- Max iterations reached → report and stop
154+
- Critical error → report and stop
110155

111-
### 3. Merge (if `--auto-merge`)
156+
### 3. Smart Merge Logic
157+
158+
#### Detect Auto-Merge Status
159+
```bash
160+
# Check if auto-merge is enabled and what merge strategy
161+
gh api repos/{owner}/{repo}/pulls/{pr_number} --jq '.autoMerge'
162+
163+
# Possible states:
164+
# - enabled: auto-merge queued (will merge when ready)
165+
# - disabled: auto-merge off
166+
# - conflicted: enabled but blocked by conflicts or checks
167+
```
168+
169+
#### Merge Strategy (Priority Order)
170+
1. **Auto-merge enabled & CI green** → Wait for auto-merge to complete (poll every 30s)
171+
2. **Auto-merge enabled but stuck** → Use `--force-merge` to manually trigger API merge
172+
3. **Auto-merge disabled** → Use direct `gh pr merge` command
173+
4. **Merge conflicts** → Resolve conflicts, push, then retry merge
174+
175+
#### Force Merge (for stuck auto-merge)
176+
```bash
177+
# If auto-merge is enabled but not progressing, trigger via API
178+
gh api repos/{owner}/{repo}/pulls/{pr_number}/merge \
179+
--input - <<EOF
180+
{
181+
"commit_title": "Merge PR #{pr_number}",
182+
"commit_message": "Merged via babysit-pr auto-merge handler",
183+
"merge_method": "squash",
184+
"sha": "$(git rev-parse HEAD)"
185+
}
186+
EOF
187+
```
188+
189+
#### Fallback: Simple Direct Merge
112190
```bash
113191
gh pr merge $PR_NUMBER --squash --delete-branch
114192
```
@@ -122,25 +200,31 @@ Print summary at completion:
122200
PR #123: Feature title
123201
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
124202
125-
Effort Summary:
126-
Iterations: 3
127-
Fixes applied: 7
128-
CodeRabbit: 4
129-
Sourcery: 2
130-
Gemini: 1
131-
Conflicts resolved: 1
132-
Total duration: 12m 34s
203+
Automation Summary:
204+
Iterations: 3
205+
Review fixes applied: 7
206+
CodeRabbit: 4
207+
Sourcery: 2
208+
Gemini: 1
209+
Other agents: 0
210+
CI fixes applied: 2
211+
Linting fixes: 1
212+
Type fixes: 1
213+
Conflicts resolved: 1
214+
Total duration: 12m 34s
133215
134216
Result: ✅ Merged successfully
217+
Auto-merge status: Handled via API (auto-merge was stuck)
135218
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
136219
```
137220

138221
## Exit Conditions
139222

140223
The loop exits when:
141-
- ✅ CI passes AND all review suggestions (bot + human) addressed → merge (if `--auto-merge`)
224+
- ✅ CI passes (all green) AND all review suggestions (bot + human) addressed → merge (if `--auto-merge`)
225+
- ✅ Auto-merge successfully triggered or manually merged
142226
- ⚠️ Max iterations reached → report status and stop
143-
- ⚠️ Unresolvable conflict or error → report and stop
227+
- ⚠️ Unresolvable conflict or critical error → report and stop
144228
- ⚠️ Manual interrupt (Ctrl+C)
145229

146230
## Supported Review Bots
@@ -164,42 +248,75 @@ The loop exits when:
164248

165249
## Examples
166250

167-
### Basic babysit
251+
### Basic babysit (watch and address reviews)
168252
```bash
169253
# On a feature branch with an open PR
170254
git checkout feat/new-feature
171255
/github:babysit-pr
172256
```
173257

174-
### Babysit and auto-merge
258+
### Babysit with auto-fix CI and merge
175259
```bash
176-
/github:babysit-pr --auto-merge
260+
/github:babysit-pr --auto-merge --fix-ci
177261
```
178262

179-
### Babysit specific PR with limited iterations
263+
### Force merge stuck auto-merge
180264
```bash
181-
/github:babysit-pr --pr 456 --max-iterations 3
265+
# Repo has auto-merge enabled but it's stuck/not progressing
266+
/github:babysit-pr --auto-merge --force-merge
182267
```
183268

184-
### Preview mode
269+
### Babysit specific PR with aggressive CI fixing
270+
```bash
271+
/github:babysit-pr --pr 456 --max-iterations 5 --fix-ci --auto-merge
272+
```
273+
274+
### Preview mode (dry-run)
185275
```bash
186276
/github:babysit-pr --dry-run
187277
```
188278

279+
### Long CI timeout (for slow repos)
280+
```bash
281+
/github:babysit-pr --auto-merge --fix-ci --ci-timeout 45
282+
```
283+
189284
## Continuous Monitoring with /loop
190285

191286
For long-running PRs, combine with `/loop` for periodic checks:
192287

193288
```bash
194-
# Check every 10 minutes, auto-merge when ready
195-
/loop 10m /github:babysit-pr --auto-merge
289+
# Check every 10 minutes, auto-fix CI and auto-merge when ready
290+
/loop 10m /github:babysit-pr --auto-merge --fix-ci
196291

197-
# Check every 5 minutes for a specific PR
198-
/loop 5m /github:babysit-pr --pr 123 --auto-merge
292+
# Check every 5 minutes for a specific PR, with force-merge for stuck auto-merge
293+
/loop 5m /github:babysit-pr --pr 123 --auto-merge --force-merge
294+
295+
# Check every 3 minutes with aggressive CI fixing and extended timeout
296+
/loop 3m /github:babysit-pr --auto-merge --fix-ci --ci-timeout 30
199297
```
200298

299+
## Troubleshooting
300+
301+
### Auto-merge is enabled but PR won't merge
302+
- Use `--force-merge` flag to manually trigger merge via API
303+
- Check if all required status checks are passing
304+
- Verify branch protection rules aren't blocking merge
305+
- Check if there are dismissed reviews blocking merge
306+
307+
### CI keeps failing on same issue
308+
- Use `--fix-ci` to enable automatic CI failure analysis and fixing
309+
- Check CI logs: `gh run view {run_id} --log`
310+
- Some CI failures may require manual investigation
311+
312+
### Conflicts keep appearing
313+
- Ensure base branch is fully fetched: `git fetch origin main`
314+
- Rebase before pushing fixes: `git rebase origin/main`
315+
- Check for competing changes from other contributors
316+
201317
## Related Commands
202318

203319
- `/github:watch-and-fix` - Simpler CI-focused watch loop (no bot parsing)
204320
- `/fix:and-update-pr` - Single-iteration fix and push
205321
- `/github:bulk-merge-prs` - Merge multiple approved PRs
322+
- `/github:fix-workflow-failures` - Dedicated CI failure fixing tool

statusline/.claude-plugin/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "statusline",
3-
"version": "1.7.0",
4-
"description": "Multi-provider status bar with context health, API rate limits (Anthropic 5h/7d + z.ai GLM tokens/tools), git branch, and active tools. Auto-detects provider from model name. Supports 1/2/3 line layouts with smart hiding.",
3+
"version": "1.8.0",
4+
"description": "Configurable multi-line status bar with context health, cache hit rate, session duration, API rate limits (Anthropic 5h/7d + z.ai GLM), git branch, and active tools. Supports 1/2/3 line layouts, icon themes, and template presets.",
55
"author": {
66
"name": "duyet"
77
}

0 commit comments

Comments
 (0)