npm package: @hempun10/prflow
Description: AI-powered CLI tool for creating beautiful, template-aware pull requests
Latest version: 1.0.0

# PRflow ✈️

> AI-powered CLI for creating beautiful, template-aware pull requests

[![npm version](https://img.shields.io/npm/v/prflow.svg)](https://www.npmjs.com/package/prflow)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

PRflow streamlines your pull request workflow by intelligently generating PR descriptions from your commits, filling in templates automatically, and remembering your team's preferences.

## ✨ Features

- 🤖 **AI-Powered Descriptions** - Generate PR descriptions from commits using OpenAI, Anthropic, or local Ollama
- 📝 **Template-Aware** - Automatically detects and fills your PR template
- 🧠 **Team Learning** - Remembers your frequently used reviewers and labels
- 📋 **Conventional Commits** - Understands and leverages conventional commit format
- 👀 **Preview Mode** - Review your PR before creating
- ✏️ **Editor Integration** - Edit descriptions in vim, nano, or VS Code
- 🔌 **Offline Mode** - Works without AI when needed

## 🚀 Quick Start

```bash
# Install globally
npm install -g prflow

# Or use npx
npx prflow

# Create a PR (from your feature branch)
prflow

# Or use the short alias
prf
```

## 📖 Usage

### Create a Pull Request

```bash
# Basic usage - creates PR from current branch to main
prflow

# Specify base branch
prflow develop

# Create as draft
prflow --draft

# Preview before creating
prflow --preview

# Skip AI generation
prflow --no-ai
```

### Configuration

```bash
# Interactive configuration wizard
prflow config

# Show current configuration
prflow config --show

# Configure globally
prflow config --global

# Configure for current project
prflow config --local

# Clear team learning data
prflow config --clear-learning
```

### Initialize in a Repository

```bash
# Create .prflowrc.json
prflow init

# Also create a PR template
prflow init --template
```

## ⚙️ Configuration

PRflow looks for configuration in the following order:
1. `.prflowrc.json` in current directory
2. `.prflowrc.yaml` in current directory
3. `prflow` key in `package.json`
4. Global `~/.prflowrc.json`
5. Environment variables

### Example Configuration

```json
{
  "ai": {
    "provider": "openai",
    "model": "gpt-4o"
  },
  "editor": "vim",
  "defaults": {
    "assignSelf": true,
    "draft": false,
    "labels": [],
    "reviewers": []
  }
}
```

### Environment Variables

| Variable | Description |
|----------|-------------|
| `GITHUB_TOKEN` | GitHub personal access token (required) |
| `OPENAI_API_KEY` | OpenAI API key |
| `ANTHROPIC_API_KEY` | Anthropic API key |
| `PR_PILOT_AI_PROVIDER` | Override AI provider |
| `PR_PILOT_AI_MODEL` | Override AI model |

## 🤖 AI Providers

### OpenAI (Default)
```json
{
  "ai": {
    "provider": "openai",
    "model": "gpt-4o"
  }
}
```

### Anthropic (Claude)
```json
{
  "ai": {
    "provider": "anthropic",
    "model": "claude-sonnet-4-20250514"
  }
}
```

### Ollama (Local)
```json
{
  "ai": {
    "provider": "ollama",
    "model": "llama3.2",
    "baseUrl": "http://localhost:11434"
  }
}
```

### Offline Mode
```json
{
  "ai": {
    "provider": "none"
  }
}
```

## 📝 PR Templates

PRflow automatically detects templates in these locations:
- `.github/PULL_REQUEST_TEMPLATE.md`
- `.github/pull_request_template.md`
- `PULL_REQUEST_TEMPLATE.md`
- `docs/PULL_REQUEST_TEMPLATE.md`

When a template is found, PRflow will:
1. Parse all sections (Description, Impact, etc.)
2. Detect checkboxes and type selections
3. Fill in content intelligently using AI
4. Preserve your template structure

## 🧠 Team Learning

PRflow remembers your preferences:
- **Reviewers** - Frequently selected reviewers appear first with ⭐
- **Labels** - Often-used labels are prioritized

Data is stored locally and persists across sessions.

## 🎯 Workflow Example

```bash
# 1. Create a feature branch
git checkout -b feature/user-authentication

# 2. Make commits (conventional commits work best)
git commit -m "feat(auth): add JWT token validation"
git commit -m "feat(auth): implement login endpoint"
git commit -m "test(auth): add authentication tests"

# 3. Create PR with PRflow
prflow

# PRflow will:
# ✅ Analyze your commits
# ✅ Detect conventional commit format
# ✅ Generate AI description
# ✅ Fill in your PR template
# ✅ Suggest relevant labels
# ✅ Show frequent reviewers first
# ✅ Preview before creating
# ✅ Create the PR with all metadata
```

## 🛠️ Development

```bash
# Clone the repository
git clone https://github.com/yourusername/prflow.git
cd prflow

# Install dependencies
npm install

# Build
npm run build

# Run in development
npm run dev

# Link for local testing
npm link
```

## 📄 License

MIT © Your Name

---

Built with ❤️ for the GitHub Copilot CLI Challenge