Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "github",
"version": "1.3.1",
"description": "GitHub CI/CD automation plugin for auto-detecting, analyzing, and fixing CI/CD failures on any branch",
"version": "1.4.0",
"description": "GitHub CI/CD automation plugin with autonomous fix loops, PR workflows, and code review",
"author": {
"name": "Ladislav Martincik",
"url": "https://github.com/iamladi"
Expand All @@ -24,7 +24,9 @@
"review-comments",
"autonomous",
"ai-review",
"confidence-scoring"
"confidence-scoring",
"ci-loop",
"auto-fix"
],
"commands": {
"fix-ci": {
Expand All @@ -46,6 +48,10 @@
},
"agents": [
"./agents/ci-log-analyzer.md",
"./agents/ci-error-fixer.md"
"./agents/ci-error-fixer.md",
"./agents/ci-monitor.md"
],
"skills": [
"./skills/ci-fix-loop/SKILL.md"
]
}
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.4.0] - 2025-12-13

### Added

- **Autonomous CI Fix Loop** (`/fix-ci --loop` or `/fix-ci --auto`)
- Runs up to 10 fix-commit-push-wait cycles automatically
- Fully autonomous operation with no user prompts
- Background CI monitoring (polls every 60 seconds)
- Detailed history report on completion
- Early abort if same errors appear twice consecutively

- **New `ci-monitor` agent**
- Lightweight haiku-based CI status poller
- Token-efficient (~50 tokens per poll vs ~500 for sonnet)
- Runs in background to free terminal
- Returns: SUCCESS, FAILURE, CANCELLED, or TIMEOUT

- **New `ci-fix-loop` skill**
- Orchestrates the full autonomous loop
- State tracking: attempt count, error history, run IDs
- Smart progress detection to avoid infinite loops
- Comprehensive final reporting

### Safety Features

- Blocks on main/master branches (must use feature branch)
- Stashes uncommitted changes before starting
- Maximum 30 minute wait per CI run
- Maximum 10 retry attempts
- Detailed commit history for easy revert

### Token Efficiency

- ~6,000 tokens per iteration (vs ~15,000 without optimization)
- Haiku model for CI polling saves ~90% on wait cycles
- No context accumulation between iterations
- Background execution frees terminal for other work

## [1.3.1] - 2024-11-16

### Fixed
Expand Down
94 changes: 94 additions & 0 deletions agents/ci-monitor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
name: ci-monitor
description: Lightweight CI status poller for background monitoring. Uses haiku model for token efficiency.
tools: Bash
model: haiku
---

# CI Monitor Agent

Minimal CI status checker. Poll GitHub Actions and report status.

## Input

- `branch`: Branch name to monitor
- `run_id`: Optional specific run ID (if known)

## Behavior

1. Check status:
```bash
gh run list --branch "${BRANCH}" --limit 1 --json databaseId,status,conclusion,createdAt
```

2. Parse and return ONE of:
- `QUEUED` - Run queued, not started
- `IN_PROGRESS` - Run executing
- `SUCCESS` - Completed successfully
- `FAILURE` - Completed with failures
- `CANCELLED` - Run cancelled
- `TIMEOUT` - Exceeded max wait (30 min)

3. If `QUEUED` or `IN_PROGRESS`: wait 60 seconds, poll again
4. If terminal state: return immediately with result

## Polling Loop

```bash
MAX_WAIT=1800 # 30 minutes
START=$(date +%s)
POLL_INTERVAL=60

while true; do
RESULT=$(gh run list --branch "$BRANCH" --limit 1 --json databaseId,status,conclusion 2>/dev/null)

STATUS=$(echo "$RESULT" | jq -r '.[0].status // "unknown"')
CONCLUSION=$(echo "$RESULT" | jq -r '.[0].conclusion // "null"')
RUN_ID=$(echo "$RESULT" | jq -r '.[0].databaseId // "unknown"')

case "$STATUS" in
completed)
case "$CONCLUSION" in
success) echo "SUCCESS|$RUN_ID"; exit 0 ;;
failure) echo "FAILURE|$RUN_ID"; exit 1 ;;
cancelled) echo "CANCELLED|$RUN_ID"; exit 2 ;;
*) echo "FAILURE|$RUN_ID"; exit 1 ;;
esac
;;
queued|waiting|pending)
# Still waiting to start
;;
in_progress)
# Running
;;
*)
# Unknown status, keep polling
;;
esac

ELAPSED=$(($(date +%s) - START))
if [ $ELAPSED -gt $MAX_WAIT ]; then
echo "TIMEOUT|$RUN_ID"
exit 3
fi

sleep $POLL_INTERVAL
done
```

## Output Format

Single line: `STATUS|RUN_ID`

Examples:
- `SUCCESS|12345678`
- `FAILURE|12345678`
- `CANCELLED|12345678`
- `TIMEOUT|12345678`

## Important

- Be extremely concise
- No explanations - just return status
- Max poll time: 30 minutes
- Poll interval: 60 seconds
49 changes: 46 additions & 3 deletions commands/fix-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,56 @@ Auto-detect, analyze, and fix CI/CD failures on any branch using GitHub CLI and
## Usage

```bash
/fix-ci # Current branch
/fix-ci 123 # PR number
/fix-ci https://... # PR URL
/fix-ci # Current branch (single fix)
/fix-ci 123 # PR number (single fix)
/fix-ci https://... # PR URL (single fix)
/fix-ci --loop # Autonomous loop mode (up to 10 retries)
/fix-ci --auto # Alias for --loop
/fix-ci 123 --loop # Loop mode for specific PR
```

User provided: `$ARGUMENTS`

## Autonomous Loop Mode

When `--loop` or `--auto` flag is present, this command runs in autonomous mode using the `ci-fix-loop` skill.

**Detection:**
```bash
ARGS="$ARGUMENTS"
if [[ "$ARGS" == *"--loop"* ]] || [[ "$ARGS" == *"--auto"* ]]; then
# Extract PR number if provided (e.g., "123 --loop" → "123")
PR_NUM=$(echo "$ARGS" | grep -oE '^[0-9]+' || echo "")

# Invoke ci-fix-loop skill
# The skill will handle the full autonomous loop:
# 1. Analyze CI errors
# 2. Apply fixes
# 3. Commit and push
# 4. Monitor CI in background (polling every 60s)
# 5. If CI fails, repeat (up to 10 times)
# 6. Report final status

# IMPORTANT: Do not proceed with single-fix workflow below
fi
```

**Behavior:**
- Runs up to 10 fix-commit-push-wait cycles
- Fully autonomous (no user prompts)
- Background CI monitoring between iterations
- Reports detailed history when complete
- Aborts if same errors appear twice consecutively

**Safety:**
- Will not run on main/master branch
- Stashes uncommitted changes before starting
- Maximum 30 minute wait per CI run

---

When NOT in loop mode, proceed with single-fix workflow below.

## Workflow

### Step 1: Detect Context
Expand Down
Loading