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
9 changes: 9 additions & 0 deletions .github/workflows/pr-analyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run PR Analyzer
uses: ./
with:
Expand Down
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ build/Release
# Dependency directories
node_modules/
jspm_packages/
package-lock.json
# Note: package-lock.json should be committed for reproducible builds

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
Expand Down Expand Up @@ -154,5 +154,17 @@ dist/*
!dist/index.js
!dist/index.js.map

# Allow necessary directories for agent imports (needed when ncc doesn't fully bundle)
!dist/utils/
!dist/utils/**
!dist/agents/
!dist/agents/**
!dist/tools/
!dist/tools/**
!dist/providers/
!dist/providers/**
!dist/types/
!dist/types/**

# ArchDoc configuration (contains API keys)
.archdoc.config.json
63 changes: 50 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ PR Agent analyzes your code changes and provides:

```bash
# Install
npm install -g pr-agent
npm install -g @techdebtgpt/pr-agent

# Setup
pr-agent config --init
Expand Down Expand Up @@ -80,13 +80,13 @@ Before using PR Agent, you'll need:
Install PR Agent globally using npm:

```bash
npm install -g pr-agent
npm install -g @techdebtgpt/pr-agent
```

Or use it directly with npx:

```bash
npx pr-agent analyze
npx @techdebtgpt/pr-agent analyze
```

### Verify Installation
Expand Down Expand Up @@ -278,6 +278,35 @@ export GOOGLE_API_KEY="..."

Add to your `.bashrc`, `.zshrc`, or `.env` file for persistence.

#### Default Branch Configuration

PR Agent automatically detects the default branch for your repository using the following priority:

1. **Config file** (`git.defaultBranch`) - If set in `.pragent.config.json`, this takes highest priority
2. **GitHub API** - If `GITHUB_TOKEN` is available, fetches the default branch from GitHub
3. **Git commands** - Falls back to detecting from local git repository
4. **Fallback** - Defaults to `origin/main` if nothing else works

**Examples:**

```bash
# Set default branch in config
pr-agent config --set git.defaultBranch=origin/develop

# For repositories using 'master' as default
pr-agent config --set git.defaultBranch=origin/master

# Override for a single analysis
pr-agent analyze --branch origin/feature-branch
```

**Troubleshooting Branch Issues:**

- **Branch not found**: Run `git fetch origin` to update remote branch references
- **Wrong branch detected**: Set `git.defaultBranch` in config or use `--branch` flag
- **GitHub API errors**: Ensure `GITHUB_TOKEN` is valid, or rely on git fallback
- **Custom default branch**: Configure it explicitly: `pr-agent config --set git.defaultBranch=origin/your-branch`

## Architecture Documentation Integration

PR Agent can leverage your project's architecture documentation for context-aware analysis.
Expand Down Expand Up @@ -521,7 +550,8 @@ cd pr-agent
### 2. Install Dependencies

```bash
npm install
# Install dependencies (use --legacy-peer-deps to handle langchain peer dependency conflicts)
npm install --legacy-peer-deps
```

### 3. Build the Project
Expand All @@ -542,15 +572,21 @@ npm run build:action
#### Test CLI

```bash
# Run directly with tsx (development)
npm run dev
# Option 1: Link locally to use 'pr-agent' command
npm link
pr-agent config --init
pr-agent analyze --staged

# Build and test
npm run build
node dist/cli/index.js analyze --help
# Option 2: Use npm script
npm run cli config --init
npm run cli analyze --staged

# Test analyze command
# Option 3: Run directly with node
node dist/cli/index.js config --init
node dist/cli/index.js analyze --staged

# Option 4: Development mode (no build needed)
npm run dev
```

#### Test GitHub Action
Expand Down Expand Up @@ -651,10 +687,10 @@ For large or complex PRs, PR Agent uses an intelligent agent system that:

```bash
# If pr-agent command not found after npm install -g
npm install -g pr-agent
npm install -g @techdebtgpt/pr-agent

# Or use npx
npx pr-agent analyze
npx @techdebtgpt/pr-agent analyze
```

#### API Key Not Recognized
Expand Down Expand Up @@ -768,6 +804,7 @@ Best for: Overall quality, architecture understanding, and complex reasoning

### OpenAI GPT

- **gpt-5.1** - Latest GPT-5.1 model (newest)
- **gpt-4-turbo-preview** - Latest GPT-4 (recommended)
- **gpt-4** - Stable and reliable
- **gpt-3.5-turbo** - Fast and cost-effective
Expand Down Expand Up @@ -860,7 +897,7 @@ Add to your CI pipeline:
# .github/workflows/pr-check.yml
- name: PR Quality Check
run: |
npm install -g pr-agent
npm install -g @techdebtgpt/pr-agent
pr-agent analyze --full
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Expand Down
Loading