Skip to content
Merged
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
97 changes: 97 additions & 0 deletions .github/workflows/fix-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Fix CI Failures

on:
workflow_run:
workflows: [Run tests for the CLI]
types: [completed]

permissions:
contents: write
pull-requests: write
actions: read

jobs:
attempt-fix:
if: >-
${{ github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.name != 'Fix CI Failures' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checkout checks out wrong branch in workflow_run context

High Severity

The actions/checkout step is missing a ref parameter. In a workflow_run context, checkout defaults to the repository's default branch (e.g., main), not the PR branch that caused the CI failure. The cursor-agent will analyze and attempt to fix code on the wrong branch. To check out the PR branch, a ref like ${{ github.event.workflow_run.head_sha }} is needed.

Fix in Cursor Fix in Web


- name: Install Cursor CLI
run: |
curl https://cursor.com/install -fsS | bash
echo "$HOME/.cursor/bin" >> $GITHUB_PATH

- name: Configure git identity
run: |
git config user.name "Cursor Agent"
git config user.email "cursor-agent@onkernel.com"

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Fix CI failure
env:
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_PREFIX: ci-fix
run: |
cursor-agent -p "You are operating in a GitHub Actions runner for the Kernel CLI repository.

The GitHub CLI is available as \`gh\` and authenticated via GH_TOKEN. Git is available. You have write access to repository contents and can comment on pull requests, but you must not create or edit PRs directly.

# Context
- Repo: ${{ github.repository }}
- Workflow Run ID: ${{ github.event.workflow_run.id }}
- Workflow Run URL: ${{ github.event.workflow_run.html_url }}
- Fix Branch Prefix: ci-fix

# Codebase Structure
- cmd/ - CLI commands (main command implementations)
- cmd/proxies/ - Proxy-related commands
- cmd/mcp/ - MCP server commands
- pkg/ - Supporting packages and templates
- Makefile - Build and test targets (\`make test\` runs \`go vet\` and \`go test\`)

# Goal
Implement an end-to-end CI fix flow: identify the failing PR, analyze the failure, make minimal targeted fixes, and propose changes back.

# Requirements
1. Use \`gh run view ${{ github.event.workflow_run.id }} --log-failed\` to get failure logs
2. Identify the PR associated with the failed workflow run
3. Analyze the failure - common issues include:
- Go compilation errors
- Test failures (missing interface methods, type mismatches)
- Mock/fake implementations missing new interface methods
- Linting issues from \`go vet\`
4. Make minimal, targeted edits consistent with the repo style
5. Create/update a fix branch: ci-fix/<pr-head-branch>
6. Push changes and post a PR comment with ONLY a compare link for quick PR creation
- Format: Describe the fix, then provide ONLY a single PR creation link
- Example format:
\"🔧 CI Fix Available
I've pushed a fix for the CI failure.

👉 Click here to create a PR with the fix\"
- Do NOT include any git merge instructions or manual merge commands
- Only include the compare link (e.g., https://github.com/.../compare/...)

# Style Guidelines
- Go: Follow existing patterns, use testify for tests
- Comments: Keep simple, no extra formatting
- Interfaces: When adding methods to interfaces, update all implementations including test fakes

# Constraints
- Do NOT create PRs directly - only post comments with compare links
- Avoid duplicate comments - update existing bot comments
- If no actionable fix is possible, make no changes and post no comment
- PR comments must ONLY include the PR creation link, no manual merge instructions
" --model opus-4.5 --force --output-format=text