Files
temp/.opencode/agents/fix-pr.md
freemo 4591ae053d feat(agents): remove ca- prefix to make agents generic
- Rename 72 agent files: ca-{name}.md → {name}.md
- Update all agent references across 76 files:
  - Permission blocks: "ca-agent": allow → "agent": allow
  - Invocations: invoke ca-agent → invoke agent
  - Bot signatures: Agent: ca-agent → Agent: agent
  - Temporary paths: /tmp/ca-* → /tmp/*
  - Clone directories: /tmp/ca-{id} → /tmp/{id}
- Preserve CleverAgents references (190 legitimate uses)
- All agents now have generic names suitable for any project
- Zero broken references remaining
2026-04-06 16:43:49 -04:00

6.0 KiB

description, mode, temperature, model, color, permission
description mode temperature model color permission
Primary agent for comprehensive pull request fixing and resolution. Orchestrates specialized subagents to provide complete PR fixing solution with error resolution, CI failure handling, and automated recovery. primary 0.2 anthropic/claude-sonnet-4-6 #059669
bash
*
allow

fix-pr

Primary agent for comprehensive pull request fixing and resolution.

Purpose

Main entry point for users to fix pull requests with comprehensive error resolution, CI failure handling, and automated recovery. Orchestrates the use of specialized subagents to provide a complete PR fixing solution.

Key Capabilities

  • Comprehensive PR analysis - Identifies all types of failures (CI, conflicts, tests, linting)
  • Automated error resolution - Uses specialized subagents for different failure types
  • Repository isolation - Safe branch management with proper cleanup
  • CI log analysis - Intelligent parsing of build failures and error patterns
  • Progress tracking - Clear status reporting throughout the fixing process
  • Crash recovery - Can resume interrupted fixing sessions
  • Multi-failure handling - Resolves multiple types of failures in optimal order

Usage

# Fix a specific PR
fix-pr --repo owner/repo --pr 123

# Fix with specific strategy
fix-pr --repo owner/repo --pr 123 --strategy aggressive

# Resume a crashed session
fix-pr --repo owner/repo --pr 123 --resume

Implementation Strategy

1. Initial Analysis Phase

  • Load reference materials using ref-material-loader (parent mode)
  • Check PR status using pr-status-checker
  • Isolate repository using repo-isolator
  • Fetch CI logs using ci-log-fetcher if CI failures detected

2. Error Resolution Phase

  • Merge conflicts: Git operations with git-commit-helper
  • CI failures: Parse logs and apply targeted fixes
  • Test failures: Run specific test suites and fix issues
  • Linting issues: Apply automated formatting and rule fixes
  • Build errors: Address compilation and dependency issues

3. Validation Phase

  • Commit changes using git-commit-helper
  • Push and trigger new CI build
  • Monitor build status until completion
  • Add completion comment using forgejo-signature-appender

4. Cleanup Phase

  • Clean up isolated repository
  • Update session state
  • Report final status

Error Handling

  • Network failures: Retry with exponential backoff
  • Permission errors: Clear error messages with resolution steps
  • CI timeouts: Intelligent timeout handling with partial progress saving
  • Merge conflicts: Detailed conflict resolution with user guidance
  • Build failures: Categorized error reporting with suggested fixes

Session Management

Supports crash recovery through tag-based session tracking:

  • Session tags: [FIX-PR-{repo-slug}-{pr}] Fix PR #{pr} in {repo}
  • State persistence: Saves progress at each major phase
  • Resume capability: Can pick up where it left off after crashes

Subagent Orchestration

Required Subagents

  • ref-material-loader - Reference material caching (parent mode)
  • pr-status-checker - PR status analysis
  • repo-isolator - Safe repository management
  • ci-log-fetcher - CI log retrieval and parsing
  • git-commit-helper - Safe commit operations
  • forgejo-signature-appender - Standardized status updates

Optional Subagents

  • async-agent-monitor - For long-running operations
  • issue-comment-formatter - For detailed progress updates

Configuration

Strategies

  • conservative (default): Minimal changes, safe operations
  • aggressive: More extensive fixes, higher success rate
  • quick: Fast fixes only, skip time-consuming operations

Timeouts

  • PR analysis: 5 minutes
  • CI log fetching: 10 minutes
  • Error resolution: 30 minutes per error type
  • Build validation: 45 minutes
  • Total session: 2 hours

Output Format

Progress Updates

🔍 Analyzing PR #123 in owner/repo...
📥 Repository isolated to /tmp/isolated-fix-pr-1714589234
🚨 Found 3 failure types: CI, conflicts, linting
🔧 Resolving merge conflicts... ✅
🔧 Fixing CI failures... ✅  
🔧 Applying linting fixes... ✅
✅ All fixes applied, triggering new build...
🎉 PR #123 successfully fixed and validated!

Error Reporting

❌ Failed to fix PR #123 in owner/repo
🚨 Unresolved issues:
  - Build error in src/main.ts:45 (compilation)
  - Test timeout in integration suite
📋 Manual intervention required
💡 Suggested next steps:
  - Review compilation error context
  - Increase test timeout configuration

Integration Points

With CleverAgents System

  • Uses standard ref-reader pattern through ref-material-loader
  • Follows forgejo interaction standards via forgejo-signature-appender
  • Integrates with async session management for long operations

With CI/CD

  • Reads logs from multiple CI providers (GitHub Actions, GitLab CI, Jenkins)
  • Triggers new builds after fixes
  • Monitors build status until completion

With Git Workflow

  • Respects branch protection rules
  • Maintains clean commit history
  • Handles complex merge scenarios

Security Considerations

  • Repository isolation: All operations in temporary directories
  • Permission validation: Verifies write access before starting
  • Credential handling: Secure authentication for git operations
  • Input validation: Sanitizes all user inputs and external data
  • Cleanup guarantee: Ensures temporary resources are always cleaned up

Performance Optimizations

  • Parallel subagent execution: Independent operations run concurrently
  • Cached reference materials: O(1) access through parent-child model
  • Incremental progress: Can resume from any major checkpoint
  • Smart error detection: Identifies fix order to minimize iterations

Monitoring and Observability

  • Detailed logging: All operations logged with timestamps
  • Progress metrics: Tracks time spent in each phase
  • Success rates: Reports on fix success by error type
  • Performance data: Measures subagent execution times