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
49 changes: 49 additions & 0 deletions .cursor/rules/python.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
description:
globs: *.py
alwaysApply: false
---
# Python Coding Rules for PR Agent

## Code Style
- Follow Python PEP 8 style guidelines
- Use 4 spaces for indentation (never tabs)
- Line length should not exceed 120 characters
- Use double quotes for strings unless single quotes avoid escaping
- Add trailing commas in multi-line data structures

## Naming Conventions
- Use snake_case for variables, functions, and module names
- Use PascalCase for class names
- Use UPPER_SNAKE_CASE for constants
- Prefix private methods and attributes with underscore

## Type Hints and Documentation
- Always use type hints for function parameters and return values
- Use docstrings for all public functions and classes
- Use Google-style docstrings format
- Include type information in docstrings when not obvious

## Python Best Practices
- Prefer f-strings over .format() or % formatting
- Use pathlib.Path instead of os.path for file operations
- Always handle exceptions explicitly, avoid bare except clauses
- Use specific exception types instead of generic Exception

## Patterns to Avoid
- Don't use global variables
- Avoid nested functions with more than 2 levels
- Don't leave print() statements in production code
- Never commit TODO comments without GitHub issues
- Avoid importing * (star imports)

## Error Handling
- Always log errors with appropriate context
- Use try/except blocks close to the failing operation
- Prefer early returns to reduce nesting

## Testing
- Write unit tests for all new functions
- Use descriptive test method names
- Follow AAA pattern: Arrange, Act, Assert
- Mock external dependencies in tests
46 changes: 46 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# PR Agent Cursor Rules

## Code Style
- Use Python PEP 8 style guidelines
- Use 4 spaces for indentation (never tabs)
- Line length should not exceed 120 characters
- Use double quotes for strings unless single quotes avoid escaping
- Add trailing commas in multi-line data structures

## Naming Conventions
- Use snake_case for variables, functions, and module names
- Use PascalCase for class names
- Use UPPER_SNAKE_CASE for constants
- Prefix private methods and attributes with underscore

## Best Practices
- Always use type hints for function parameters and return values
- Use docstrings for all public functions and classes
- Prefer f-strings over .format() or % formatting
- Use pathlib.Path instead of os.path for file operations
- Always handle exceptions explicitly, avoid bare except clauses

## Patterns to Avoid
- Don't use global variables
- Avoid nested functions with more than 2 levels
- Don't leave print() statements in production code
- Never commit TODO comments without GitHub issues
- Avoid importing * (star imports)

## Error Handling
- Use specific exception types instead of generic Exception
- Always log errors with appropriate context
- Use try/except blocks close to the failing operation
- Prefer early returns to reduce nesting

## Documentation
- All public functions must have docstrings
- Use Google-style docstrings format
- Include type information in docstrings when not obvious
- Document complex algorithms with inline comments

## Testing
- Write unit tests for all new functions
- Use descriptive test method names
- Follow AAA pattern: Arrange, Act, Assert
- Mock external dependencies in tests
42 changes: 0 additions & 42 deletions .github/workflows/test-action.yml

This file was deleted.

65 changes: 65 additions & 0 deletions .github/workflows/test-pr-bot-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Test PR Bot (Development)

on:
pull_request:
types: [opened, reopened, ready_for_review, synchronize]

concurrency:
group: test-pr-bot-dev-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
test-pr-bot-dev:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build local PR bot image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.github_action
tags: pr-bot-dev:latest
load: true
no-cache: true

- name: Test PR Bot with Development Code
run: |
docker run --rm \
-e ANTHROPIC__KEY="${{ secrets.ANTHROPIC_API_KEY }}" \
-e GITHUB_TOKEN="${{ github.token }}" \
-e GITHUB_ACTION_CONFIG__AUTO_REVIEW="true" \
-e CONFIG__ENABLE_AUTO_APPROVAL="true" \
-e PR_REVIEWER__ENABLE_REVIEW_LABELS_EFFORT="true" \
-e PR_REVIEWER__ENABLE_REVIEW_LABELS_SECURITY="true" \
-e CONFIG__USE_CURSOR_RULES="true" \
-e CONFIG__MODEL="anthropic/claude-sonnet-4-20250514" \
-e CONFIG__MAX_MODEL_TOKENS="100000" \
-e PR_REVIEWER__NUM_MAX_FINDINGS="5" \
-e GITHUB_ACTION_CONFIG__PRETTY_LOGS="true" \
-e CONFIG__FEEDBACK_ON_DRAFT_PR="false" \
-e GITHUB_ACTION_CONFIG__ENABLE_OUTPUT="false" \
-e GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" \
-e GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" \
-e GITHUB_EVENT_NAME="${GITHUB_EVENT_NAME}" \
-e GITHUB_HEAD_REF="${GITHUB_HEAD_REF}" \
-e GITHUB_BASE_REF="${GITHUB_BASE_REF}" \
-e GITHUB_SHA="${GITHUB_SHA}" \
-e GITHUB_ACTOR="${GITHUB_ACTOR}" \
-e GITHUB_WORKFLOW="${GITHUB_WORKFLOW}" \
-e GITHUB_RUN_ID="${GITHUB_RUN_ID}" \
-e GITHUB_RUN_NUMBER="${GITHUB_RUN_NUMBER}" \
-e GITHUB_API_URL="${GITHUB_API_URL}" \
-e GITHUB_SERVER_URL="${GITHUB_SERVER_URL}" \
-v "${GITHUB_EVENT_PATH}:${GITHUB_EVENT_PATH}" \
-v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \
-w "${GITHUB_WORKSPACE}" \
pr-bot-dev:latest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Byte-compiled / optimized / DLL files
-# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
Expand Down
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
| 💡 **Code Suggestions** | Specific improvements and best practices | Learn better coding patterns, optimize performance |
| ✅ **Auto Approval** | Safe approval of low-risk changes | Speed up workflow, focus reviews on complex changes |
| 🎯 **Smart Triggers** | Flexible activation via PR events or manual commands | Control when and how the bot runs |
| 📐 **Repository Rules** | Respects official Cursor rules files in your repository | Follows your project's coding standards automatically |

## 🚀 Quick Setup

Expand Down Expand Up @@ -121,6 +122,7 @@ Create `.pr_bot.toml`:
model = "anthropic/claude-sonnet-4-20250514"
enable_auto_approval = true
max_model_tokens = 100000
use_cursor_rules = true # Enable Cursor rules (default: true)

[github_action_config]
require_aidesc_trigger = true # Requires ##prbot in PR description
Expand All @@ -129,6 +131,56 @@ auto_review = true
auto_improve = true
```

## 📐 Cursor Rules Support

The bot automatically detects and respects official Cursor rules in your repository, ensuring AI reviews follow your project's specific coding standards.

### Supported Rules Files

The bot looks for these official Cursor rules files:

**Current Format (Recommended):**
- `.cursor/rules/*.mdc` - Modern Cursor project rules files

**Legacy Format (Deprecated but supported):**
- `.cursorrules` - Legacy Cursor rules file

### Example Rules File

Create `.cursor/rules/style.mdc` in your repository:

```markdown
---
description: Code style and formatting rules
alwaysApply: true
---

# Project Coding Rules

## Code Style
- Use 2 spaces for indentation
- Prefer const over let when possible
- Always use semicolons
- Use single quotes for strings

## Naming Conventions
- Use camelCase for variables and functions
- Use PascalCase for classes and components
- Use UPPER_SNAKE_CASE for constants

## Patterns to Avoid
- Don't use console.log in production code
- Avoid nested ternary operators
- Never commit commented-out code

## Preferred Patterns
- Use TypeScript strict mode
- Prefer async/await over promises.then()
- Use destructuring for object properties
```

The bot will automatically include these rules in its analysis, ensuring consistent code reviews that match your project's standards.

## Usage

### Automatic Mode
Expand Down
5 changes: 5 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ inputs:
description: 'Enable processing of draft PRs (default: false to skip draft PRs)'
required: false
default: 'false'
use_cursor_rules:
description: 'Enable reading Cursor rules from repository (.cursor/rules/*.mdc and .cursorrules)'
required: false
default: 'true'

outputs:
review_posted:
Expand Down Expand Up @@ -91,3 +95,4 @@ runs:
PR_REVIEWER__ENABLE_REVIEW_LABELS_EFFORT: ${{ inputs.enable_review_labels_effort }}
PR_REVIEWER__ENABLE_REVIEW_LABELS_SECURITY: ${{ inputs.enable_review_labels_security }}
CONFIG__FEEDBACK_ON_DRAFT_PR: ${{ inputs.feedback_on_draft_pr }}
CONFIG__USE_CURSOR_RULES: ${{ inputs.use_cursor_rules }}
Loading