8000 GitHub - FrankFlitton/prfect: Prfect is a powerful tool that analyzes your git commits and generates professional pull request descriptions using local AI models via Ollama. No more struggling with blank PR templates or forgetting what you changed!
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Prfect is a powerful tool that analyzes your git commits and generates professional pull request descriptions using local AI models via Ollama. No more struggling with blank PR templates or forgetting what you changed!

License

Notifications You must be signed in to change notification settings

FrankFlitton/prfect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

50 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Prfect

Perfect PR descriptions, generated with AI

Prfect is a powerful tool that analyzes your git commits and generates professional pull request descriptions using local AI models via Ollama. No more struggling with blank PR templates or forgetting what you changed!

npm version License: MIT

✨ Features

  • 🧠 AI-Powered: Uses Ollama with DeepSeek or other local models
  • πŸ” Smart Git Analysis: Analyzes commits, file changes, and code diffs
  • 🌲 Branch Intelligence: Auto-detects main/master/develop branches
  • πŸ“ Professional Output: Generates structured, readable PR descriptions
  • πŸ“‹ Custom Templates: Supports GitHub PR templates and custom formats
  • 🎯 Context Support: Add custom context and background information to AI prompts
  • 🎨 Beautiful CLI: Colored output with progress indicators
  • πŸ’Ύ Export Options: Save to markdown files
  • 🌐 Flexible: Works 10000 with any git branching strategy

🎯 Quick Start

Prerequisites

  1. Install Ollama:
curl -fsSL https://ollama.ai/install.sh | sh
ollama serve
ollama pull qwen3:latest
  1. Ensure you're in a git repository

Installation & Usage

Choose your preferred version:

🟒 Node.js/TypeScript

# Install globally
npm install -g prfect

# Or run directly with npx
npx prfect

# Basic usage
prfect

# With options
prfect --source feature/auth --target main --save

🎯 Context Support

Enhance your PR descriptions by providing additional context that may not be visible in the code changes. Perfect for adding ticket numbers, business context, or background information.

Usage

# Basic context
prfect "This was a big refactor that addressed Linear ticket BE-123"

# Context with background info
prfect "Fixes critical bug from user reports. Addresses performance issues in checkout flow"

# Context with follow-up information
prfect "Implements OAuth integration per security requirements. Follow up for MFA coming in BE-124"

# Context in CI mode
prfect "Emergency hotfix for production issue" --ci --source hotfix/payment-bug --target main

What Context Helps With

  • πŸ“‹ Ticket References: Link to Linear, Jira, or other project management tools
  • πŸ’Ό Business Context: Explain the business reason or user impact
  • πŸ”— Dependencies: Note related work or follow-up tasks
  • ⚠️ Urgency: Indicate if this is a hotfix or time-sensitive change
  • πŸ“Š Performance: Provide benchmarks or performance context
  • πŸ”’ Security: Add security considerations or compliance notes

Context Integration

The context is automatically incorporated into:

  • Default prompts: Added as "ADDITIONAL CONTEXT" section
  • Custom templates: Seamlessly integrated into template-based generation
  • CI mode: Included in automated PR generation
  • All AI models: Works with any Ollama-compatible model

πŸ“ Custom PR Templates

Prfect supports custom PR templates to match your team's workflow and requirements. It automatically detects and uses GitHub standard templates or allows you to specify custom ones.

Template Detection Priority

  1. Explicit path: --template-path custom/template.md
  2. GitHub standard: .github/pull_request_template.md
  3. Alternative naming: .github/PULL_REQUEST_TEMPLATE.md
  4. Docs location: docs/pull_request_template.md
  5. Default built-in: Fallback template

Usage

# Use custom template
prfect --template-path .github/custom_template.md

# Auto-detect GitHub template (default behavior)
prfect

# Specify source and target with template
prfect --source feature/auth --target main --template-path team_template.md

# CI mode with custom template
prfect --ci --template-path templates/ci_template.md

Template Structure

Templates should include common sections that Prfect will intelligently fill:

## Summary
[Brief description of changes]

## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update

## Key Changes
- 
- 
- 

## How has this been tested?
- [ ] Unit tests pass
- [ ] Manual testing completed
- [ ] Edge cases considered

## Breaking Changes
[Only include if there are breaking changes]

## Additional Notes
[Any additional information for reviewers]

Template Features

  • 🏒 Mono-repo Support: Searches up directory tree for templates
  • βœ… Validation: Checks template structure and content quality
  • πŸ”— GitHub Integration: Works seamlessly with GitHub's PR template system
  • πŸ”„ Fallback Handling: Uses default template if custom one not found
  • 🎯 Smart Parsing: AI understands your template structure and fills it appropriately

Example: Team-Specific Template

Create .github/pull_request_template.md:

## Summary
[What does this PR accomplish?]

## Business Impact
[How does this benefit users/business?]

## Technical Details
[Implementation approach and key technical decisions]

## Security Considerations
- [ ] No sensitive data exposed
- [ ] Authentication/authorization reviewed
- [ ] Input validation implemented

## Performance Impact
- [ ] No performance degradation
- [ ] Load testing completed (if applicable)

## Testing Strategy
- [ ] Unit tests added/updated
- [ ] Integration tests pass
- [ ] Manual testing completed
- [ ] Accessibility tested (if UI changes)

## Deployment Notes
[Any special deployment considerations]

## Documentation
- [ ] README updated (if needed)
- [ ] API docs updated (if needed)
- [ ] Internal docs updated (if needed)

Prfect will automatically detect and use this template for all PRs in your repository!

πŸ“‹ Usage Examples

Command Line

# Generate PR for current branch β†’ auto-detected main
prfect

# Specify source branch
prfect --source feature/authentication

# Specify both branches
prfect --source feature/auth --target main

# Use different AI model
prfect --model llama2

# Save to file automatically
prfect --save

# Custom Ollama host
prfect --ollama-host http://192.168.1.100:11434

# Generate without emojis
prfect --no-emojis

# Show AI thinking process (useful for debugging)
prfect --show-thinking

# Use custom PR template
prfect --template-path .github/custom_template.md

# Add context information to the AI prompt
prfect "This was a big refactor that addressed Linear ticket BE-123. Follow up for BE-124 coming soon but non blocking"

# Context with other options
prfect "Fixes critical bug from user reports" --source feature/bugfix --target main --model qwen3:latest

Programmatic Usage (Node.js/TypeScript)

import { PRGenerator } from "prfect";

const generator = new PRGenerator();

const prMessage = await generator.run({
  source: "feature/new-feature",
  target: "main",
  model: "qwen3:latest",
  save: true,
  interactive: false,
  noEmojis: true,
  showThinking: false,
  templatePath: ".github/custom_template.md",
  context: "This addresses Linear ticket BE-123",
});

console.log(prMessage);

Integration with Package.json

{
  "scripts": {
    "pr": "prfect",
    "pr:save": "prfect --save --no-interactive",
    "pr:clean": "prfect --no-emojis --save",
    "pr:debug": "prfect --show-thinking",
    "pr:custom": "prfect --template-path .github/custom_template.md"
  }
}

πŸ“Š Sample Output

Prfect generates professional PR descriptions like this:

# Implement User Authentication System

## Summary

This PR adds a comprehensive user authentication system with JWT tokens,
password hashing, and role-based access control to improve application security.

## Key Changes

- Added JWT authentication middleware with token validation
- Implemented bcrypt password hashing for secure credential storage
- Created user registration and login API endpoints
- Added role-based permission system with admin/user roles
- Updated database schema with users and roles tables
- Added authentication guards for protected routes

## Breaking Changes

- All API endpoints now require authentication headers
- User session handling has changed from cookies to JWT tokens
- Database migration required for new user tables

## Testing Considerations

- Unit tests added for authentication functions
- Integration tests for login/register workflows
- Manual testing required for UI authentication flows
- Load testing recommended for JWT token validation

πŸ› οΈ Configuration

Environment Variables

export OLLAMA_HOST=http://localhost:11434
export PRFECT_MODEL=qwen3:latest
export PRFECT_DEFAULT_TARGET=main

Git Hooks Integration

Add to .git/hooks/pre-push:

#!/bin/sh
if [ "$2" = "origin" ]; then
    prfect --save --no-interactive
fi

πŸš€ Installation Options

Node.js/TypeScript (Full-Featured)

# Global installation
npm install -g prfect

# Local development
git clone <repository>
cd prfect
npm install
npm run build
npm start

Features:

  • βœ… TypeScript support with full type safety
  • βœ… Beautiful CLI with colors and progress
  • βœ… Programmatic API for integration
  • βœ… Professional error handling
  • βœ… Interactive and non-interactive modes
  • βœ… Comprehensive logging

πŸŽ›οΈ Available AI Models

Prfect works with any Ollama-compatible model:

  • qwen3:latest (Default)
  • qwen3:0.6b (Good for CI)
  • gemma3:latest
  • deepseek-coder:latest
  • llama3:latest
  • codellama:latest
  • mistral
  • mixtral

For a complete list visit Ollama's model hub and install them with the Ollama CLI.

Install models with:

ollama pull <model-name>

πŸ”§ Advanced Configuration

Custom Prompts

The Node.js package supports custom prompt templates:

const generator = new PRGenerator();
generator.setPromptTemplate(`
Custom prompt for ${sourceBranch} β†’ ${targetBranch}
Analysis: ${commitInfo}
Generate: [your requirements]
`);

CI/CD Integration

GitHub Actions

name: Generate PR Description
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  generate-description:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Ollama
        run: |
          curl -fsSL https://ollama.ai/install.sh | sh
          ollama serve &
          ollama pull qwen3:latest
      - name: Generate PR Description
        run: npx prfect --no-interactive --save

GitLab CI

generate-pr:
  stage: prepare
  script:
    - curl -fsSL https://ollama.ai/install.sh | sh
    - ollama serve &
    - ollama pull qwen3:latest
    - npx prfect --no-interactive

πŸ—οΈ Development Setup

Node.js/TypeScript Development

# Clone repository
git clone <repository>
cd prfect

# Install dependencies
npm install

# Development mode
npm run dev

# Build
npm run build

# Run tests
npm test

# Lint and format
npm run lint
npm run format

Project Structure

prfect/
β”œβ”€β”€ src/
β”‚   └── index.ts              # Main TypeScript application
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ prfect.sh            # Bash version
β”‚   └── prfect.py            # Python version
β”œβ”€β”€ dist/                     # Compiled JavaScript
β”œβ”€β”€ package.json             # Node.js configuration
β”œβ”€β”€ tsconfig.json            # TypeScript configuration
└── README.md               # This file

πŸ› Troubleshooting

Common Issues

"Not in a git repository"

# Ensure you're in a git repository
git status

"Ollama is not accessible"

# Check if Ollama is running
curl http://localhost:11434/api/tags

# Start Ollama if not running
ollama serve

"Model not found"

# List available models
ollama list

# Install default model
ollama pull qwen3:latest

"Could not detect default branch"

# Specify target branch explicitly
prfect --target main

"No commits found"

# Check if there are commits between branches
git log --oneline main..feature-branch

Debug Mode

For detailed logging:

# Node.js version
DEBUG=prfect* prfect

πŸ“ License

MIT License - see LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

For support, please open a new issue on the GitHub Issues page.

About

Prfect is a powerful tool that analyzes your git commits and generates professional pull request descriptions using local AI models via Ollama. No more struggling with blank PR templates or forgetting what you changed!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0