# https://github.com/The-PR-Agent/pr-agent 项目说明书

生成时间：2026-05-15 20:09:06 UTC

## 目录

- [Introduction to PR-Agent](#introduction)
- [Quick Start Guide](#quickstart)
- [System Architecture](#architecture)
- [Git Providers System](#git-providers)
- [Command-to-Tool Mapping](#command-handling)
- [Tools Overview](#tools-overview)
- [/describe Tool](#describe-tool)
- [/review Tool](#review-tool)
- [/improve Tool](#improve-tool)
- [Additional Tools](#additional-tools)

<a id='introduction'></a>

## Introduction to PR-Agent

### 相关页面

相关主题：[Quick Start Guide](#quickstart), [System Architecture](#architecture), [Tools Overview](#tools-overview)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [README.md](https://github.com/The-PR-Agent/pr-agent/blob/main/README.md)
- [pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)
- [pr_agent/servers/help.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/servers/help.py)
- [pr_agent/tools/pr_config.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_config.py)
- [pr_agent/tools/pr_code_suggestions.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_code_suggestions.py)
- [CONTRIBUTING.md](https://github.com/The-PR-Agent/pr-agent/blob/main/CONTRIBUTING.md)
</details>

# Introduction to PR-Agent

PR-Agent is an open-source, AI-powered code review agent that provides automated analysis and feedback on pull requests. Originally developed by Qodo, the project was donated to the open-source community, making it a community-maintained legacy project distinct from Qodo's primary AI code review offering.

## Overview

PR-Agent serves as an intelligent assistant that scans pull request code changes and generates automated feedback, suggestions, and descriptions. It integrates seamlessly with major version control platforms including GitHub, GitLab, Bitbucket, and Azure DevOps.

The project provides a comprehensive suite of tools that can be triggered automatically on PR events (such as when a PR is opened or synchronized) or invoked manually through comments on pull requests. Each tool focuses on a specific aspect of the PR review process.

## Architecture

PR-Agent follows a modular architecture where each tool operates as an independent component. The core system consists of:

1. **Agent Core** - The main orchestration layer that processes incoming requests and routes them to appropriate tools
2. **Git Provider Integration** - Abstraction layer for different VCS platforms
3. **Tool Suite** - Individual tools for description, review, improvement, and other operations
4. **Configuration System** - TOML-based configuration with environment variable support

### Component Flow

```mermaid
graph TD
    A[Pull Request Event] --> B[Git Provider]
    B --> C[Agent Core]
    C --> D[Tool Router]
    D --> E[/describe]
    D --> F[/review]
    D --> G[/improve]
    D --> H[/ask]
    E --> I[AI Model]
    F --> I
    G --> I
    H --> I
    I --> J[PR Comment/Update]
```

## Available Tools

PR-Agent provides multiple tools that can be invoked via slash commands in PR comments.

### Describe Tool

The `/describe` tool scans PR code changes and generates a comprehensive description including:

- **Title** - Auto-generated PR title in the format `<PR type>: <title>`
- **Type** - Classification such as Bug fix, Tests, Enhancement, Documentation, or Other
- **Summary** - Brief overview of changes
- **Walkthrough** - File-by-file breakdown of modifications
- **Labels** - Auto-assigned labels based on content

资料来源：[pr_agent/servers/help.py:1-50]()

### Review Tool

The `/review` tool performs detailed code analysis and provides:

- **Code quality assessment** - Evaluation of code structure and patterns
- **Security analysis** - Potential vulnerability detection
- **Performance considerations** - Optimization suggestions
- **Recommended focus areas** - Specific files or lines requiring attention

资料来源：[pr_agent/servers/help.py:1-100]()

### Improve Tool (Code Suggestions)

The `/improve` tool automatically generates code improvement suggestions:

- **Category classification** - Each suggestion is labeled and categorized
- **Impact scoring** - Suggestions are scored by potential improvement impact
- **Code examples** - Before/after code comparisons when relevant
- **Automatic sorting** - Suggestions ordered by score within categories

资料来源：[pr_agent/tools/pr_code_suggestions.py:1-80]()

### Ask Tool

The `/ask` tool answers natural language questions about the PR:

- Queries about the entire PR scope
- Specific questions about code lines or files
- Image-related questions when visual content is present

Note that the tool does not retain memory between questions—each query is answered independently.

资料来源：[pr_agent/servers/help.py:1-150]()

### Help Docs Tool

The `/help_docs` tool retrieves documentation based on relative file paths, supporting both repository-local documentation and external sources.

## Output Format

PR-Agent generates output using GitHub Flavored Markdown (GFM) with enhanced formatting:

```mermaid
graph LR
    A[Code Analysis] --> B[GFM Table Format]
    B --> C[Collapsible Sections]
    C --> D[Code Blocks]
    D --> E[Links & References]
```

### Markdown Table Structure

PR-Agent uses structured HTML tables within Markdown for organized output:

```html
<table>
  <thead>
    <tr>
      <td><strong>Category</strong></td>
      <td><strong>Suggestion</strong></td>
      <td><strong>Impact</strong></td>
    </tr>
  </thead>
  <tbody>
    <!-- Content rows -->
  </tbody>
</table>
```

资料来源：[pr_agent/algo/utils.py:1-100]()

## Configuration

PR-Agent uses a TOML-based configuration system with multiple configuration levels.

### Configuration Sections

| Section | Purpose | Key Settings |
|---------|---------|--------------|
| `pr_description` | Describe tool behavior | `enable_help_comment`, `use_description_markers`, `output_relevant_configurations` |
| `pr_reviewer` | Review tool behavior | Various review-specific options |
| `pr_code_suggestions` | Improve tool behavior | Suggestion filtering and scoring |
| `config` | Global settings | `output_relevant_configurations` |

资料来源：[pr_agent/tools/pr_config.py:1-50]()

### Configuration Methods

**Command-line invocation:**
```bash
/describe --pr_description.some_config1=... --pr_description.some_config2=...
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
```

**Configuration file (TOML):**
```toml
[pr_description]
some_config1=...
some_config2=...

[pr_code_suggestions]
some_config1=...
```

资料来源：[pr_agent/servers/help.py:1-200]()

### Custom Labels

The describe tool supports custom labels defined in the repository's labels page or via configuration file. Examples:

| Custom Label | Description |
|--------------|-------------|
| `Main topic:performance` | PR focuses on performance optimization |
| `New endpoint` | New API endpoint added |
| `SQL query` | Database query changes |
| `Dockerfile changes` | Container configuration updates |

## Installation and Deployment

### Docker Installation

Docker images are published to `pragent/pr-agent`. Recent releases (0.34.2+) are available at the new namespace. Legacy images up to v0.31 remain at `codiumai/pr-agent`.

资料来源：[README.md:1-100]()

### GitHub Action (Recommended)

```yaml
name: PR Agent
on:
  pull_request:
    types: [opened, synchronize]
jobs:
  pr_agent_job:
    runs-on: ubuntu-latest
    steps:
    - name: PR Agent action step
      uses: the-pr-agent/pr-agent@main
      env:
        OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

### CLI Usage

```bash
pip install pr-agent
export OPENAI_KEY=your_key_here
pr-agent --pr_url https://github.com/owner/repo/pull/123 review
```

## Automation Modes

PR-Agent supports multiple automation configurations:

1. **Automatic on PR events** - Tools run automatically when PR is opened or updated
2. **Manual invocation** - Users trigger tools via slash commands in comments
3. **Marker-based control** - Using `pr_agent:marker_name` markers for selective updates

The default automation mode for the describe tool uses:
```python
pr_commands = ["/describe", ...]
```

资料来源：[pr_agent/servers/help.py:1-250]()

## Development Guidelines

Contributors should follow these practices:

- Use conventional commit messages (e.g., `fix: handle missing repo settings gracefully`)
- Target branch names follow `feature/<name>` or `fix/<issue>` patterns
- Keep PRs focused on single features or fixes
- Include unit tests for new functionality using pytest
- Update prompts and configuration files together when behavior changes

资料来源：[CONTRIBUTING.md:1-80]()

## Security Considerations

- Secrets must be supplied through environment variables, not hardcoded
- API keys and credentials should never be committed to the repository
- Docker builds and e2e tests requiring external credentials need coordination before execution

---

<a id='quickstart'></a>

## Quick Start Guide

### 相关页面

相关主题：[Introduction to PR-Agent](#introduction)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [README.md](https://github.com/The-PR-Agent/pr-agent/blob/main/README.md)
- [pr_agent/cli.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/cli.py)
- [pr_agent/servers/help.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/servers/help.py)
- [pr_agent/tools/pr_description.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_description.py)
- [pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)
- [SECURITY.md](https://github.com/The-PR-Agent/pr-agent/blob/main/SECURITY.md)
- [AGENTS.md](https://github.com/The-PR-Agent/pr-agent/blob/main/AGENTS.md)
</details>

# Quick Start Guide

## Overview

The Quick Start Guide provides developers with immediate access to automated PR review capabilities through PR-Agent. This guide covers installation methods, configuration options, and basic usage patterns to get started with AI-powered code review in minutes.

PR-Agent is an open-source, AI-powered code review agent that integrates seamlessly with GitHub, GitLab, Bitbucket, and Azure DevOps. It offers automated reviews, descriptions, code suggestions, and more without requiring complex setup.

## Installation Methods

PR-Agent supports multiple installation methods to accommodate different development workflows and infrastructure requirements.

### GitHub Action (Recommended)

The GitHub Action method is the recommended approach for automated PR reviews. It runs as part of your CI/CD pipeline and automatically reviews pull requests when they are opened or updated.

```yaml
# .github/workflows/pr-agent.yml
name: PR Agent
on:
  pull_request:
    types: [opened, synchronize]
jobs:
  pr_agent_job:
    runs-on: ubuntu-latest
    steps:
    - name: PR Agent action step
      uses: the-pr-agent/pr-agent@main
      env:
        OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

资料来源：[README.md:1-25]()

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `OPENAI_KEY` | secret | Yes | OpenAI API key for AI capabilities |
| `GITHUB_TOKEN` | secret | Yes | GitHub token for API access |
| `GITLAB_TOKEN` | secret | No | Required for GitLab integration |
| `AZURE_DEVOPS_TOKEN` | secret | No | Required for Azure DevOps integration |

### CLI Usage (Local Development)

For local development and testing, use the Command Line Interface:

```bash
pip install pr-agent
export OPENAI_KEY=your_key_here
pr-agent --pr_url https://github.com/owner/repo/pull/123 review
```

资料来源：[README.md:31-37]()

| Command | Description |
|---------|-------------|
| `pr-agent --pr_url <URL> review` | Run a review on a PR |
| `pr-agent --pr_url <URL> describe` | Generate PR description |
| `pr-agent --pr_url <URL> improve` | Get code improvement suggestions |
| `pr-agent --pr_url <URL> ask "<question>"` | Ask questions about the PR |

### Docker Deployment

Docker images are available for containerized deployments:

| Image Tag | Description | Registry |
|-----------|-------------|----------|
| `pragent/pr-agent:0.34.2+` | Current releases | hub.docker.com |
| `pragent/pr-agent:latest` | Latest stable | hub.docker.com |
| `pragent/pr-agent:0.34.2-github_action` | GitHub Action variant | hub.docker.com |
| `codiumai/pr-agent:v0.31` | Legacy (frozen) | hub.docker.com |

版本 0.34.2 及之后发布在 `pragent/pr-agent` 命名空间，旧版本（直到 v0.31）仍可在 `codiumai/pr-agent` 获取但不会再更新。

资料来源：[README.md:1-8]()

For enhanced security, specify Docker images using their digest:

```yaml
steps:
  - name: PR Agent action step
    id: pragent
    uses: docker://pragent/pr-agent@sha256:a0b36966ca3a197ca739fa1e65c16703076fc1c744cd423ca203b8c21707d71c
```

资料来源：[SECURITY.md:1-12]()

## Architecture Overview

```mermaid
graph TD
    A[Pull Request Event] --> B[GitHub/GitLab/Bitbucket/Azure DevOps]
    B --> C[PR-Agent Trigger]
    C --> D{Installation Method}
    D -->|GitHub Action| E[GitHub Actions Runner]
    D -->|CLI| F[Local Environment]
    D -->|Docker| G[Container Runtime]
    E --> H[OpenAI API / LLM]
    F --> H
    G --> H
    H --> I[Review Output]
    I --> J[PR Comment]
```

## Configuration System

PR-Agent uses a flexible configuration system that supports multiple levels of customization.

### Configuration Hierarchy

| Level | Location | Scope | Priority |
|-------|----------|-------|----------|
| 1 | Environment Variables | Global | Highest |
| 2 | Configuration File | Project | Medium |
| 3 | Inline Command Flags | Per-invocation | Lowest |

### Configuration File Format

Create a `.pr_agent.toml` or use `pr_agent/settings/configuration.toml`:

```toml
[pr_description]
extra_instructions="""\
- The PR title should be in the format: '<PR type>: <title>'
- The title should be short and concise (up to 10 words)
"""
```

资料来源：[pr_agent/servers/help.py:1-15]()

### Inline Configuration via Comments

When commenting on a PR, use the following template to modify configurations:

```
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
```

资料来源：[pr_agent/servers/help.py:1-10]()

## Available Commands

PR-Agent provides several commands that can be invoked via PR comments:

### Command Reference Table

| Command | Purpose | Auto-trigger | Manual Trigger |
|---------|---------|--------------|----------------|
| `/describe` | Generate PR description | ✓ | ✓ |
| `/review` | Perform code review | ✓ | ✓ |
| `/improve` | Suggest code improvements | ✓ | ✓ |
| `/ask "..."` | Answer questions about PR | ✗ | ✓ |
| `/help_docs "..."` | Query documentation | ✗ | ✓ |
| `/config` | Show configuration | ✗ | ✓ |

### Command Usage Examples

资料来源：[pr_agent/servers/help.py:1-50]()

#### Describe Command

```
/describe --pr_description.some_config1=value
```

Generates a PR description including title, type, summary, walkthrough, and labels.

#### Review Command

```
/review --pr_reviewer.some_config1=value --pr_reviewer.some_config2=value
```

Performs an automated code review with configurable focus areas.

#### Improve Command

```
/improve --pr_code_suggestions.some_config1=value
```

Scans PR code changes and generates improvement suggestions.

#### Ask Command

```
/ask "What are the main changes in this PR?"
```

Answers questions about the PR without memory of previous interactions.

## Security Best Practices

### Environment Variables

Secrets should be supplied through environment variables exclusively:

```bash
export OPENAI_KEY=sk-...
export GITHUB_TOKEN=ghp_...
```

Do not persist credentials in code or configuration files that might be committed to version control.

资料来源：[AGENTS.md:1-10]()

### Docker Security

For production deployments, use pinned Docker image digests instead of floating tags:

```yaml
uses: docker://pragent/pr-agent@sha256:<digest>
```

资料来源：[SECURITY.md:1-12]()

## Output Format

PR-Agent generates formatted markdown output for PR comments with support for GitHub Flavored Markdown (GFM).

### Output Structure

```mermaid
graph LR
    A[Review Output] --> B{GFM Supported?}
    B -->|Yes| C[Rich Tables & Details]
    B -->|No| D[Plain Markdown]
    C --> E[Collapsible Sections]
    D --> F[Basic Formatting]
```

### Example Output Features

| Feature | GFM Support | Fallback |
|---------|-------------|----------|
| Code blocks | ✓ Syntax highlighting | ✓ Basic blocks |
| Tables | ✓ Rich formatting | ✗ Text list |
| Collapsible details | ✓ `<details>` tags | ✗ Flat text |
| Line links | ✓ Clickable references | ✗ Line numbers only |

资料来源：[pr_agent/algo/utils.py:1-30]()

## Troubleshooting

### Common Issues

| Issue | Cause | Solution |
|-------|-------|----------|
| Bot doesn't respond | App not installed | Install GitHub App |
| Empty review | No code changes | Ensure PR has diff |
| Rate limit errors | API quota exceeded | Check OpenAI billing |
| Authentication failed | Invalid token | Verify secret configuration |

### Help Command

Use the inline help feature for tool-specific guidance:

```
/help how to configure the review tool
```

资料来源：[pr_agent/tools/pr_description.py:1-15]()

## Next Steps

After setting up PR-Agent:

1. **Customize prompts** - Modify extra instructions in configuration files
2. **Enable auto-tools** - Configure automatic triggers for new PRs
3. **Set up custom labels** - Define project-specific PR categories
4. **Integrate with your workflow** - Add to existing CI/CD pipelines

## Additional Resources

| Resource | Link |
|----------|------|
| Documentation | https://qodo-merge-docs.qodo.ai/ |
| GitHub Action Guide | https://docs.pr-agent.ai/installation/github/ |
| CLI Setup Guide | https://docs.pr-agent.ai/usage-guide/automations_and_usage/#local-repo-cli |
| Discord Community | https://discord.com/channels/1057273017547378788/ |

---

<a id='architecture'></a>

## System Architecture

### 相关页面

相关主题：[Git Providers System](#git-providers), [Command-to-Tool Mapping](#command-handling)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [pr_agent/agent/pr_agent.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/agent/pr_agent.py)
- [pr_agent/git_providers/__init__.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/__init__.py)
- [pr_agent/tools/__init__.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/__init__.py)
- [pr_agent/algo/types.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/types.py)
- [pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)
- [pr_agent/tools/pr_description.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_description.py)
- [pr_agent/tools/pr_code_suggestions.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_code_suggestions.py)
- [pr_agent/git_providers/bitbucket_server_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/bitbucket_server_provider.py)
</details>

# System Architecture

## Overview

PR-Agent is an open-source AI-powered code review agent that provides automated PR analysis, review, and improvement suggestions. The system follows a modular architecture that separates concerns between agent orchestration, tool execution, git provider abstraction, and utility functions.

The primary goal of PR-Agent's architecture is to support multiple Git hosting platforms (GitHub, GitLab, Bitbucket, Azure DevOps) while providing consistent tooling for PR-related operations like description generation, code review, code suggestions, and documentation assistance.

资料来源：[README.md](https://github.com/The-PR-Agent/pr-agent/blob/main/README.md)

---

## High-Level Architecture

### System Components

The PR-Agent system consists of four main layers:

| Layer | Purpose | Key Modules |
|-------|---------|-------------|
| **Agent Layer** | Orchestrates tool invocation and command processing | `pr_agent/agent/pr_agent.py` |
| **Tool Layer** | Implements individual PR tools (describe, review, improve, etc.) | `pr_agent/tools/` |
| **Provider Layer** | Abstracts Git platform differences | `pr_agent/git_providers/` |
| **Utility Layer** | Shared algorithms, types, and formatting utilities | `pr_agent/algo/` |

资料来源：[pr_agent/agent/pr_agent.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/agent/pr_agent.py)

### Data Flow

```mermaid
graph TD
    A[Git Platform<br/>Webhook/CLI] --> B[Agent Entry Point<br/>pr_agent.py]
    B --> C{Command Router}
    C -->|/describe| D[PR Description Tool]
    C -->|/review| E[PR Review Tool]
    C -->|/improve| F[Code Suggestions Tool]
    C -->|/ask| G[Ask Tool]
    C -->|/help| H[Help Server]
    
    D --> I[Git Provider<br/>Abstraction]
    E --> I
    F --> I
    G --> I
    
    I --> J[GitHub Provider]
    I --> K[GitLab Provider]
    I --> L[Bitbucket Provider]
    I --> M[Azure DevOps Provider]
    
    J --> N[GitHub API]
    K --> O[GitLab API]
    L --> P[Bitbucket API]
    M --> Q[Azure DevOps API]
    
    I --> R[Utility Functions<br/>algo/utils.py]
    D --> R
    E --> R
    F --> R
```

---

## Agent Layer

### Core Agent Implementation

The agent layer is the central orchestrator that handles:

1. **Command parsing and routing** - Interprets user commands (`/describe`, `/review`, `/improve`, `/ask`, `/help`)
2. **Tool instantiation** - Creates appropriate tool instances based on commands
3. **Execution coordination** - Manages the flow between tools and git providers
4. **Response formatting** - Structures output for different platforms (GitHub vs GitLab vs Bitbucket)

资料来源：[pr_agent/agent/pr_agent.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/agent/pr_agent.py)

### Agent Initialization Flow

```mermaid
sequenceDiagram
    participant Main as Main Entry Point
    participant Agent as PRAgent Class
    participant Provider as GitProvider Factory
    participant Tool as Tool Instances
    
    Main->>Agent: Initialize PRAgent(pr_url, cli_mode)
    Agent->>Provider: create_git_provider(pr_url)
    Provider->>Provider: Detect platform type
    Provider-->>Agent: Return Provider Instance
    Agent->>Tool: Initialize Tools
    Agent-->>Main: Ready to process commands
```

---

## Git Provider Layer

### Provider Abstraction Architecture

The git provider layer provides a unified interface for interacting with different Git hosting platforms. This abstraction allows tools to operate identically regardless of the underlying platform.

```mermaid
graph LR
    A[Tools Layer] --> B[GitProvider Interface<br/>__init__.py]
    B --> C[GitHubProvider]
    B --> D[GitLabProvider]
    B --> D[BitbucketProvider]
    B --> E[AzureDevOpsProvider]
```

资料来源：[pr_agent/git_providers/__init__.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/__init__.py)

### Provider Interface Capabilities

The base `GitProvider` interface defines the following capabilities:

| Capability | Description |
|------------|-------------|
| `get_diff_files()` | Retrieves list of changed files in the PR |
| `get_comments()` | Fetches existing PR comments |
| `publish_comment()` | Posts a comment to the PR |
| `publish_code_suggestion()` | Publishes inline code suggestions |
| `get_languages()` | Returns programming languages used in PR |
| `get_repo_settings()` | Retrieves repository configuration |
| `is_supported(feature)` | Checks if a specific feature is supported |

资料来源：[pr_agent/git_providers/__init__.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/__init__.py)

### Platform-Specific Implementations

Each Git platform has a dedicated provider class that implements the interface:

| Platform | Provider Class | Special Considerations |
|----------|----------------|------------------------|
| GitHub | `GithubProvider` | Full GFM markdown support, fine-grained permissions |
| GitLab | `GitLabProvider` | Different markdown rendering, MR terminology |
| Bitbucket | `BitbucketProvider` | No multi-line suggestions (uses code blocks instead) |
| Azure DevOps | `AzureDevOpsProvider` | Work item integration |

资料来源：[pr_agent/git_providers/bitbucket_server_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/bitbucket_server_provider.py)

#### Bitbucket Multi-Line Suggestion Limitation

Bitbucket Server does not support multi-line code suggestions natively. The implementation falls back to code blocks when handling suggestions:

```python
# Bitbucket does not support multi-line suggestions so use a code block instead
# Reference: https://jira.atlassian.com/browse/BSERV-4553
body = body.replace("```suggestion", "```")
```

资料来源：[pr_agent/git_providers/bitbucket_server_provider.py:45](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/bitbucket_server_provider.py)

---

## Tool Layer

### Available Tools

The tool layer contains modular implementations for each PR-Agent capability:

| Tool | File | Primary Function |
|------|------|------------------|
| `describe` | `pr_description.py` | Generates PR title, type, summary, walkthrough |
| `review` | `pr_reviewer.py` | Analyzes PR code for issues and concerns |
| `improve` | `pr_code_suggestions.py` | Generates code improvement suggestions |
| `ask` | `ask.py` | Answers questions about PR changes |
| `help` | `help.py` | Provides usage guidance |
| `config` | `pr_config.py` | Displays relevant configurations |

资料来源：[pr_agent/tools/__init__.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/__init__.py)

### Tool Structure Pattern

Each tool follows a common structure pattern:

```mermaid
graph TD
    A[Tool Class] --> B[__init__<br/>Initialize git_provider]
    A --> C[run<br/>Main entry point]
    C --> D[get_deferred_reply]
    C --> E[work|
    D --> F[LLM Processing]
    E --> G[Markdown Generation]
    F --> G
    G --> H[publish_output]
```

### Code Suggestions Tool Architecture

The code suggestions tool (`improve`) demonstrates the typical tool structure:

```python
# Language extension mapping for syntax highlighting
language_extension_map_org = get_settings().language_extension_map_org
extension_to_language = {}
for language, extensions in language_extension_map_org.items():
    for ext in extensions:
        extension_to_language[ext] = language
```

资料来源：[pr_agent/tools/pr_code_suggestions.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_code_suggestions.py)

#### Suggestion Output Format

The code suggestions tool outputs structured markdown tables:

```
┌──────────┬─────────────────────┬────────┐
│ Category │ Suggestion          │ Impact │
├──────────┼─────────────────────┼────────┤
│ Security │ Input validation    │ High   │
└──────────┴─────────────────────┴────────┘
```

Suggestions are grouped by label and sorted by score:

```python
# Sort suggestions_labels by the suggestion with the highest score
suggestions_labels = dict(
    sorted(suggestions_labels.items(), key=lambda x: max([s['score'] for s in x[1]]), reverse=True))
```

资料来源：[pr_agent/tools/pr_code_suggestions.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_code_suggestions.py)

### PR Description Tool

The description tool generates comprehensive PR descriptions including:

| Component | Description |
|-----------|-------------|
| **Title** | Concise PR title (up to 10 words) |
| **Type** | PR classification (bug fix, feature, etc.) |
| **Summary** | Brief overview of changes |
| **Walkthrough** | Line-by-line change explanation |
| **Labels** | Auto-generated or custom labels |
| **Diagram** | Optional sequence diagram (Mermaid) |

资料来源：[pr_agent/tools/pr_description.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_description.py)

#### Description Output Structure

```mermaid
graph TD
    A[PR Description Request] --> B{Use Markers?}
    B -->|Yes| C[Replace marker placeholders]
    B -->|No| D[Generate full description]
    D --> E[Add help comment if enabled]
    E --> F[Output configurations if enabled]
    C --> F
    F --> G[Publish to PR]
```

---

## Utility Layer

### Types and Data Models

The `pr_agent/algo/types.py` module defines core data types used throughout the system:

| Type | Purpose |
|------|---------|
| `ActionResult` | Encapsulates tool action results |
| `ModelData` | LLM response container |
| `CodeSuggestion` | Code suggestion data model |

资料来源：[pr_agent/algo/types.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/types.py)

### Utility Functions

The `pr_agent/algo/utils.py` module provides shared utilities:

| Function | Purpose |
|----------|---------|
| `parse_code_suggestion()` | Converts suggestion dict to markdown |
| `extract_relevant_lines_str()` | Extracts code lines from diff |
| `convert_to_markdown()` | Generic dict-to-markdown converter |
| `show_relevant_configurations()` | Renders config as markdown |

资料来源：[pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)

### Markdown Generation Utilities

The system supports both GitHub Flavored Markdown (GFM) and standard markdown:

```python
def parse_code_suggestion(code_suggestion: dict, i: int = 0, gfm_supported: bool = True) -> str:
    """
    Convert a dictionary of data into markdown format.
    
    Args:
        code_suggestion (dict): A dictionary containing data to be converted to markdown format.
        gfm_supported (bool): Whether GFM features are available for this provider.
    """
```

GFM features enable collapsible file lists, detailed code references, and rich table formatting. Non-GFM providers receive simplified output:

| GFM Feature | GFM Output | Standard Output |
|-------------|------------|------------------|
| Code links | `<a href='...'>line</a>` | Plain text |
| Collapsible sections | `<details>` tags | Full text |
| Table formatting | `<table>` tags | Headers only |

资料来源：[pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)

---

## Deployment Architecture

### Supported Deployment Methods

PR-Agent supports multiple deployment models:

| Method | Use Case | Configuration |
|--------|----------|---------------|
| **GitHub App** | Automated reviews on PR open | GitHub App installation |
| **GitHub Action** | CI/CD integration | Workflow YAML |
| **CLI** | Local development | `pr-agent` command |
| **Docker** | Self-hosted deployment | Docker container |

资料来源：[README.md](https://github.com/The-PR-Agent/pr-agent/blob/main/README.md)

### GitHub Action Workflow

```yaml
name: PR Agent
on:
  pull_request:
    types: [opened, synchronize]
jobs:
  pr_agent_job:
    runs-on: ubuntu-latest
    steps:
    - name: PR Agent action step
      uses: the-pr-agent/pr-agent@main
      env:
        OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

资料来源：[README.md](https://github.com/The-PR-Agent/pr-agent/blob/main/README.md)

---

## Configuration Architecture

### Configuration Hierarchy

PR-Agent uses a layered configuration system:

1. **Default settings** - `pr_agent/settings/configuration.toml`
2. **Environment variables** - Override defaults
3. **Repository settings** - `.pr_agent.toml` or `pyproject.toml`
4. **Runtime parameters** - Command-line arguments

### Configuration Display

The `pr_config.py` tool can output relevant configurations as markdown:

```python
for key, value in settings_dict.items():
    if key in relevant_keys:
        markdown_text += f"\n{header.lower()}.{key.lower()} = {repr(value) if isinstance(value, str) else value}"
```

资料来源：[pr_agent/tools/pr_config.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_config.py)

---

## Key Architectural Patterns

### 1. Provider Pattern

All Git platform interactions go through a provider abstraction, enabling platform-agnostic tool implementations:

```python
class SomeTool:
    def __init__(self, git_provider: GitProvider):
        self.git_provider = git_provider
    
    def work(self):
        # Platform-agnostic code
        diff_files = self.git_provider.get_diff_files()
        # Same code works for GitHub, GitLab, Bitbucket
```

### 2. Factory Pattern

Git providers are instantiated via a factory function that detects the platform:

```python
def create_git_provider(pr_url: str, configuration: dict = None) -> GitProvider:
    # Detect platform from pr_url
    # Return appropriate provider instance
```

### 3. Deferred Execution Pattern

Tools support deferred execution for async operations:

```python
def get_deferred_reply(self) -> dict:
    """Returns deferred response for async processing."""
    return {"action": "defer", "tool": self.__class__.__name__}
```

资料来源：[pr_agent/tools/pr_description.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_description.py)

---

## Summary

The PR-Agent system architecture follows a clean, layered design:

| Layer | Responsibility | Extensibility |
|-------|----------------|---------------|
| **Agent** | Command routing, orchestration | Add new commands |
| **Tools** | PR operations (describe, review, improve) | Add new tools |
| **Providers** | Git platform abstraction | Add new platforms |
| **Algo** | Shared utilities, formatting | Reuse across tools |

This architecture enables:
- **Platform independence**: Same tools work across GitHub, GitLab, Bitbucket, Azure DevOps
- **Tool modularity**: Each tool can be independently developed and tested
- **Flexible deployment**: Supports GitHub Apps, Actions, CLI, and Docker
- **Consistent output**: Platform-appropriate markdown formatting

资料来源：[pr_agent/agent/pr_agent.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/agent/pr_agent.py), [pr_agent/git_providers/__init__.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/__init__.py)

---

<a id='git-providers'></a>

## Git Providers System

### 相关页面

相关主题：[System Architecture](#architecture)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [pr_agent/git_providers/__init__.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/__init__.py)
- [pr_agent/git_providers/github_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/github_provider.py)
- [pr_agent/git_providers/gitlab_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/gitlab_provider.py)
- [pr_agent/git_providers/bitbucket_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/bitbucket_provider.py)
- [pr_agent/git_providers/azuredevops_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/azuredevops_provider.py)
- [pr_agent/git_providers/gitea_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/gititea_provider.py)
- [pr_agent/git_providers/git_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/git_provider.py)
</details>

# Git Providers System

## Overview

The Git Providers System is a core abstraction layer in PR-Agent that provides a unified interface for interacting with different Git hosting platforms. It abstracts the differences between GitHub, GitLab, Bitbucket, Azure DevOps, and Gitea, allowing PR-Agent tools to operate uniformly regardless of the underlying platform.

## Architecture

The system follows a provider pattern with a base abstract class and platform-specific implementations. All providers inherit from a common `GitProvider` base class that defines the standard interface.

```mermaid
graph TB
    subgraph "Git Providers System"
        GP[GitProvider<br/>Base Class]
        GHP[GitHubProvider]
        GLP[GitLabProvider]
        BBP[BitbucketProvider]
        ADP[AzureDevOpsProvider]
        GTP[GiteaProvider]
    end
    
    GP <|-- GHP
    GP <|-- GLP
    GP <|-- BBP
    GP <|-- ADP
    GP <|-- GTP
    
    Tools[PR-Agent Tools] --> GP
```

## Supported Platforms

| Platform | Provider Class | Package Used |
|----------|---------------|--------------|
| GitHub | `GitHubProvider` | `PyGithub` |
| GitLab | `GitLabProvider` | `python-gitlab` |
| Bitbucket | `BitbucketProvider` | `atlassian-python-api` |
| Azure DevOps | `AzureDevOpsProvider` | `ado_wit_client` |
| Gitea | `GiteaProvider` | `giteapy` |

资料来源：[pr_agent/git_providers/__init__.py]()

## Base Class Interface

The `GitProvider` abstract base class defines the core interface that all platform-specific providers must implement:

### Core PR Operations

| Method | Purpose |
|--------|---------|
| `get_pr_description()` | Retrieve the PR/MR description text |
| `get_pr_title()` | Get the title of the pull request |
| `get_pr_branch()` | Get the source branch name |
| `get_target_branch()` | Get the target/destination branch |
| `get_user()` | Get the username of the PR author |
| `get_pr_id()` | Get the internal PR identifier |

### Diff and File Operations

| Method | Purpose |
|--------|---------|
| `get_diff_files()` | Retrieve list of changed files with diff information |
| `get_pr_file_content(filename)` | Get the content of a specific file in the PR |
| `get_diff()[source_file, target_file, new_content]` | Get the raw diff content |

资料来源：[pr_agent/git_providers/git_provider.py]()

### Publishing Operations

| Method | Purpose |
|--------|---------|
| `publish_comment(comment)` | Publish a general comment on the PR |
| `publish_code_suggestion(code_suggestion)` | Publish inline code suggestions |
| `create_inline_comment(file, line, body)` | Create an inline/review comment |
| `remove_initial_comment()` | Remove the bot's initial comment |
| `update_comment(comment_id, body)` | Update an existing comment |

### Review Operations

| Method | Purpose |
|--------|---------|
| `get_review_comments()` | Retrieve existing review comments |
| `get_comments()` | Get all comments on the PR |
| `get_issue_comments()` | Get issue-specific comments |

### Labels and Status

| Method | Purpose |
|--------|---------|
| `get_labels()` | Get current PR labels |
| `add_label(label)` | Add a label to the PR |
| `remove_label(label)` | Remove a label from the PR |
| `get_pr_status()` | Get the current PR status/state |

## Provider Implementation Details

### GitHub Provider

The `GitHubProvider` uses the `PyGithub` library to interact with GitHub's REST API. It supports GitHub-specific features like:

- Draft PR handling
- Review request management
- GitHub-specific markdown rendering (GFM)
- Code suggestions with inline comments

资料来源：[pr_agent/git_providers/github_provider.py]()

### GitLab Provider

The `GitLabProvider` leverages the `python-gitlab` library for GitLab API interactions. It handles:

- GitLab-flavored Markdown (GFM)
- Merge request workflows
- Different comment threading models

资料来源：[pr_agent/git_providers/gitlab_provider.py]()

### Bitbucket Provider

The `BitbucketProvider` utilizes the `atlassian-python-api` library to communicate with Bitbucket's APIs. It supports:

- Bitbucket-specific diff formats
- Pull request workflows

资料来源：[pr_agent/git_providers/bitbucket_provider.py]()

### Azure DevOps Provider

The `AzureDevOpsProvider` uses `ado_wit_client` for Azure DevOps integration. It handles:

- Azure-specific PR structures
- Work item linking
- Azure DevOps review workflows

资料来源：[pr_agent/git_providers/azuredevops_provider.py]()

### Gitea Provider

The `GiteaProvider` uses the `giteapy` library for self-hosted Gitea instances. It provides:

- Gitea API integration
- Support for self-hosted GitHub-like platforms

资料来源：[pr_agent/git_providers/gitea_provider.py]()

## Feature Support Detection

Each provider implements a capability detection system via the `is_supported(feature)` method. This allows tools to check whether a specific feature is available on the current platform:

```python
def is_supported(self, feature: str) -> bool:
    """Check if a specific feature is supported by the current provider."""
```

Common features checked include:

| Feature | Purpose |
|---------|---------|
| `gfm_markdown` | GitHub-flavored Markdown support |
| `code_suggestions` | Inline code suggestion capability |
| `review_comments` | Review comment functionality |
| `labels` | Label management support |

## Usage in PR-Agent Tools

### Tool Integration Pattern

PR-Agent tools interact with git providers through dependency injection:

```python
class SomeTool:
    def __init__(self, git_provider: GitProvider, ...):
        self.git_provider = git_provider
```

### Example: PR Description Tool

The `pr_description.py` tool demonstrates typical provider usage:

```python
# Get diff files for analysis
diff_files = self.git_provider.get_diff_files()

# Publish results
self.git_provider.publish_comment(pr_body)

# Check platform capabilities
if self.git_provider.is_supported("gfm_markdown"):
    # Use GFM formatting
```

资料来源：[pr_agent/tools/pr_description.py]()

### Example: Changelog Tool

The `pr_update_changelog.py` tool shows file operations:

```python
# Retrieve current changelog
changelog_content = self.git_provider.get_pr_file_content(
    "CHANGELOG.md", 
    self.git_provider.get_pr_branch()
)

# Update changelog file
self.git_provider.publish_comment(f"**Changelog updates: 🔄**\n\n{answer}")
```

资料来源：[pr_agent/tools/pr_update_changelog.py]()

## Configuration

### Environment Variables

| Variable | Description |
|----------|-------------|
| `GITHUB_TOKEN` | GitHub personal/access token |
| `GITLAB_TOKEN` | GitLab personal access token |
| `BITBUCKET_TOKEN` | Bitbucket app password |
| `AZURE_DEVOPS_TOKEN` | Azure DevOps personal access token |
| `GITEA_TOKEN` | Gitea API token |

### Provider Selection

The provider is selected automatically based on the PR URL format or explicitly configured:

```toml
[config]
git_provider = "github"  # or "gitlab", "bitbucket", "azure", "gitea"
```

## Data Models

### DiffFile Structure

Each provider returns diff information with a consistent structure:

```python
@dataclass
class DiffFile:
    filename: str
    patch: str
    num_plus_lines: int
    num_minus_lines: int
    status: str  # "added", "modified", "deleted", "renamed"
```

### CodeSuggestion Structure

```python
@dataclass
class CodeSuggestion:
    relevant_file: str
    relevant_lines: str
    code_suggestion: dict  # Contains 'before' and 'after' code
```

## Error Handling

Providers implement consistent error handling through:

- Exception wrapping for platform-specific errors
- Fallback mechanisms (e.g., extracting from patch when file content unavailable)
- Logging integration via `get_logger()`

Example fallback pattern from utils.py:

```python
if not file.head_file:
    # Fallback: extract relevant lines directly from patch
    patch = file.patch
    _, selected_lines = extract_hunk_lines_from_patch(patch, ...)
```

资料来源：[pr_agent/algo/utils.py]()

## Sequence Diagram: Comment Publishing

```mermaid
sequenceDiagram
    participant Tool as PR-Agent Tool
    participant Provider as GitProvider
    participant API as Platform API
    
    Tool->>Provider: publish_comment(comment)
    Provider->>API: POST comment request
    API-->>Provider: Comment created
    Provider-->>Tool: Success response
    
    Tool->>Provider: is_supported("gfm_markdown")
    Provider-->>Tool: Boolean support status
```

## Extending the Provider System

To add support for a new Git platform:

1. Create a new provider class inheriting from `GitProvider`
2. Implement all abstract methods from the base class
3. Register the provider in `git_providers/__init__.py`
4. Add provider selection logic based on PR URL patterns
5. Implement feature detection via `is_supported()`

### Required Abstract Methods

| Category | Methods |
|----------|---------|
| PR Info | `get_pr_title()`, `get_pr_description()`, `get_user()` |
| Diff | `get_diff_files()`, `get_diff()`, `get_pr_file_content()` |
| Comments | `publish_comment()`, `get_comments()`, `remove_initial_comment()` |
| Labels | `get_labels()`, `add_label()`, `remove_label()` |
| Utils | `is_supported()`, `get_line_link()` |

## Best Practices

1. **Always check feature support** before using platform-specific features
2. **Handle missing file content** by falling back to patch extraction
3. **Use consistent error handling** with proper logging
4. **Test across providers** when adding new provider-agnostic features

---

<a id='command-handling'></a>

## Command-to-Tool Mapping

### 相关页面

相关主题：[System Architecture](#architecture), [Tools Overview](#tools-overview)

<details>
<summary>Relevant Source Files</summary>

以下源码文件用于生成本页说明：

- [pr_agent/agent/pr_agent.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/agent/pr_agent.py)
- [pr_agent/cli.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/cli.py)
- [pr_agent/algo/cli_args.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/cli_args.py)
- [pr_agent/servers/help.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/servers/help.py)
- [pr_agent/tools/pr_description.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_description.py)
- [pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)
</details>

# Command-to-Tool Mapping

## Overview

The Command-to-Tool Mapping system in PR-Agent is the core routing mechanism that translates user-issued commands (such as `/review`, `/describe`, `/improve`) into corresponding tool invocations. This mapping enables the framework to dispatch requests to appropriate specialized tools while managing configuration, argument parsing, and execution flow.

The system serves as the entry point for all user interactions, whether they occur via GitHub/GitLab comments, CLI execution, or programmatic API calls.

## Architecture

```mermaid
graph TD
    A[User Command] --> B[CLI / Comment Handler]
    B --> C[Command Parser]
    C --> D[Argument Extraction]
    D --> E[Tool Router]
    E --> F{Command Type}
    F -->|/describe| G[pr_description.py]
    F -->|/review| H[pr_reviewer.py]
    F -->|/improve| I[pr_code_suggestions.py]
    F -->|/ask| J[pr_ask.py]
    F -->|/help| K[help.py]
    G --> L[Git Provider]
    H --> L
    I --> L
    J --> L
    K --> M[Documentation]
```

## Core Components

### Command Registry

The command registry maps slash commands to their corresponding tool implementations. Based on the help system and tool definitions, the following commands are registered:

| Command | Tool Module | Purpose |
|---------|-------------|---------|
| `/describe` | `pr_description.py` | Generate PR description, title, type, summary, walkthrough |
| `/review` | `pr_reviewer.py` | Perform automated code review |
| `/improve` | `pr_code_suggestions.py` | Generate code improvement suggestions |
| `/ask` | `pr_ask.py` | Answer questions about PR changes |
| `/help_docs` | `help_docs.py` | Query repository documentation |

资料来源：[pr_agent/servers/help.py:1-50]()

### Argument Parsing

The `cli_args.py` module handles command-line argument parsing and configuration overrides. Commands can accept configuration parameters in two formats:

**Inline Configuration (GitHub Comment):**
```
/describe --pr_description.some_config1=value1 --pr_description.some_config2=value2
```

**Configuration File Format:**
```toml
[pr_description]
some_config1=value1
some_config2=value2
```

资料来源：[pr_agent/servers/help.py:30-45]()

## Command Handlers

### Describe Command

The `/describe` command triggers automatic PR description generation.

```python
@staticmethod
def get_describe_usage_guide():
    output = "**Overview:**\n"
    output += "The `describe` tool scans the PR code changes, and generates a description for the PR"
```

**Configuration Section:** `pr_description`

**Key Parameters:**
- `enable_help_comment` - Show help links in PR body
- `use_description_markers` - Use markers in PR description for selective updates
- `output_relevant_configurations` - Display relevant config settings

资料来源：[pr_agent/tools/pr_description.py:1-30]()

### Review Command

The `/review` command initiates automated code review.

```python
# Configuration template from help message
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
```

**Configuration Section:** `pr_reviewer`

资料来源：[pr_agent/servers/help.py:50-70]()

### Improve Command

The `/improve` command generates code improvement suggestions.

```python
@staticmethod
def get_improve_usage_guide():
    output = "**Overview:**\n"
    output += "The code suggestions tool, named `improve`, scans the PR code changes..."
```

**Configuration Section:** `pr_code_suggestions`

**Key Features:**
- Automatic triggering on PR open
- Manual invocation via comment
- Configurable suggestion categories and scoring

资料来源：[pr_agent/servers/help.py:50-100]()

### Ask Command

The `/ask` command answers questions about the PR without maintaining conversation state.

```
/ask "What changes were made to the authentication module?"
```

```python
@staticmethod
def get_ask_usage_guide():
    output += """\
The `ask` tool answers questions about the PR, based on the PR code changes.
Note that the tool does not have "memory" of previous questions,
and answers each question independently.
You can ask questions about the entire PR, about specific code lines,
or about an image related to the PR code changes.
```

资料来源：[pr_agent/servers/help.py:80-95]()

### Help Docs Command

The `/help_docs` command queries repository documentation.

```python
@staticmethod
def get_help_docs_usage_guide():
    output = "**Overview:**\n"
    output += """\
The help docs tool, named `help_docs`, answers a question based on
a given relative path of documentation."""
```

资料来源：[pr_agent/servers/help.py:130-145]()

## Execution Flow

```mermaid
sequenceDiagram
    participant User
    participant CLI as Command Line
    participant Parser as Argument Parser
    participant Router as Tool Router
    participant Tool as Selected Tool
    participant Provider as Git Provider

    User->>CLI: /command --config=value
    CLI->>Parser: Parse arguments
    Parser->>Router: Route to tool
    Router->>Tool: Instantiate tool class
    Tool->>Provider: Fetch PR data
    Provider-->>Tool: Diff files, comments
    Tool->>Tool: Process and analyze
    Tool->>Provider: Post results
    Provider-->>User: PR comment/response
```

## Configuration Integration

### Configuration Precedence

The system follows a hierarchical configuration resolution:

1. **Default values** - Defined in tool settings
2. **Configuration file** - User-defined settings in `.pr_agent.toml` or `settings/configuration.toml`
3. **Command arguments** - Inline overrides from command invocation
4. **Environment variables** - System-level settings

### Relevant Configurations Output

When enabled, the system can output relevant configuration settings in the PR response:

```python
if get_settings().get('config', {}).get('output_relevant_configurations', False):
    pr_body += show_relevant_configurations(relevant_section='pr_description')
```

资料来源：[pr_agent/tools/pr_description.py:25-27]()

## CLI Integration

The CLI module (`cli.py`) provides command-line access to all tools:

```bash
# Local repository CLI usage
pr-agent --pr_url https://github.com/owner/repo/pull/123 review

# Help text
pr-agent --help
```

The CLI maps the `--pr_url` parameter and selected command to the appropriate tool implementation.

资料来源：[README.md:30-40]()

## Tool Output Formatting

The utility module (`algo/utils.py`) provides shared formatting functions used across all tools:

| Function | Purpose |
|----------|---------|
| `parse_code_suggestion()` | Convert code suggestions to markdown |
| `extract_relevant_lines_str()` | Extract relevant code lines from diff |
| `render_issue()` | Format review findings as markdown |

资料来源：[pr_agent/algo/utils.py:50-150]()

## Summary

The Command-to-Tool Mapping system provides:

- **Unified Interface**: Single entry point for all user interactions
- **Flexible Configuration**: Per-command and global configuration options
- **Extensible Architecture**: Easy addition of new commands and tools
- **Consistent Output**: Standardized markdown formatting across tools
- **Multi-Platform Support**: Works with GitHub, GitLab, Bitbucket, and Azure DevOps

This architecture enables PR-Agent to maintain a clean separation between command handling, tool implementation, and output rendering, facilitating maintainability and extensibility.

---

<a id='tools-overview'></a>

## Tools Overview

### 相关页面

相关主题：[/describe Tool](#describe-tool), [/review Tool](#review-tool), [/improve Tool](#improve-tool), [Additional Tools](#additional-tools)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [pr_agent/servers/help.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/servers/help.py)
- [pr_agent/tools/pr_description.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_description.py)
- [pr_agent/tools/pr_code_suggestions.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_code_suggestions.py)
- [pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)
- [pr_agent/tools/pr_config.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_config.py)
- [pr_agent/git_providers/bitbucket_server_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/bitbucket_server_provider.py)
</details>

# Tools Overview

PR-Agent provides a comprehensive suite of AI-powered tools for automated pull request analysis, review, and enhancement. These tools are designed to streamline the code review process by automating routine tasks and providing intelligent suggestions.

## Architecture Overview

The tools system in PR-Agent follows a modular architecture where each tool is responsible for a specific aspect of PR management. Tools can be invoked automatically (on PR events) or manually via slash commands in PR comments.

```mermaid
graph TD
    A[GitHub/GitLab/Bitbucket Event] --> B[PR Agent Core]
    B --> C[Tool Router]
    C --> D[/describe]
    C --> E[/review]
    C --> F[/improve]
    C --> G[/ask]
    C --> H[/help_docs]
    
    D --> I[pr_description.py]
    E --> J[pr_reviewer.py]
    F --> K[pr_code_suggestions.py]
    G --> L[pr_questions.py]
    H --> M[Help System]
    
    I --> N[Markdown Output]
    J --> N
    K --> N
    L --> N
    M --> N
```

## Available Tools

PR-Agent includes five core tools, each designed for specific PR workflow tasks:

| Tool | Purpose | Invocation |
|------|---------|------------|
| `/describe` | Generates PR description (title, type, summary, walkthrough, labels) | Automatic or manual |
| `/review` | Performs comprehensive code review with issue detection | Automatic or manual |
| `/improve` | Provides code improvement suggestions | Automatic or manual |
| `/ask` | Answers questions about the PR code changes | Manual only |
| `/help_docs` | Retrieves documentation based on repository files | Manual only |

资料来源：[pr_agent/servers/help.py:1-50]()

## Tool Invocation Patterns

### Slash Command Invocation

Tools can be triggered by commenting directly on a PR using slash commands:

```
/describe --pr_description.some_config1=... --pr_description.some_config2=...
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
/ask "Your question here"
/help_docs "path/to/documentation"
```

资料来源：[pr_agent/servers/help.py:8-25]()

### Configuration File Invocation

For persistent configuration, tools can be configured via a configuration file:

```toml
[pr_description]
some_config1=...
some_config2=...

[pr_reviewer]
some_config1=...
some_config2=...

[pr_code_suggestions]
some_config1=...
some_config2=...
```

## Describe Tool

The `describe` tool scans PR code changes and generates a comprehensive description including:

- **Title**: Short, concise PR title (up to 10 words)
- **Type**: PR classification (Bug fix, Enhancement, Documentation, etc.)
- **Summary**: Brief overview of changes
- **Walkthrough**: File-by-file change explanation
- **Labels**: Relevant labels for the PR

### Description Markers

When `use_description_markers` is enabled, the tool replaces markers in the PR description:

```markdown
pr_agent:type
pr_agent:summary
pr_agent:walkthrough
pr_agent:diagram
```

资料来源：[pr_agent/servers/help.py:85-105]()

### Custom Labels

The describe tool supports custom labels defined in the repository's labels page or configuration:

```toml
[pr_description]
extra_instructions="""\
- The PR title should be in the format: '<PR type>: <title>'
- The title should be short and concise (up to 10 words)
"""
```

Supported custom label formats:
- `Main topic:performance` - Marks performance-related PRs
- `New endpoint` - Indicates new API endpoints
- `SQL query` - Flags SQL changes
- `Dockerfile changes` - Identifies container changes

## Review Tool

The `/review` tool performs comprehensive code review by analyzing:

- Code quality issues
- Security vulnerabilities
- Performance concerns
- Test coverage gaps
- Documentation completeness

### Review Focus Areas

The review tool generates a table of recommended focus areas with links to relevant code sections:

```python
# From pr_description.py - Focus areas structure
if gfm_supported:
    issue_str = f"<details><summary><a href='{reference_link}'><strong>{issue_header}</strong></a>\n\n{issue_content}\n</summary>\n\n{relevant_lines_str}\n\n</details>"
```

## Improve Tool (Code Suggestions)

The `improve` tool generates actionable code improvement suggestions, organized by category and impact score.

### Suggestion Output Structure

```mermaid
graph TD
    A[Code Suggestions] --> B[Group by Label]
    B --> C[Sort by Score]
    C --> D[Category Column]
    C --> E[Suggestion Column]
    C --> F[Impact Column]
```

### Suggestion Table Format

The tool outputs suggestions in a structured table format:

```html
<table>
<thead>
<tr>
<td><strong>Category</strong></td>
<td align=left><strong>Suggestion</strong></td>
<td align=center><strong>Impact</strong></td>
</tr>
</thead>
<tbody>
```

资料来源：[pr_agent/tools/pr_code_suggestions.py:30-45]()

### Suggestion Processing

Suggestions are processed through the following pipeline:

1. **Label Grouping**: Suggestions are grouped by their category labels
2. **Score Sorting**: Groups and suggestions within are sorted by score (descending)
3. **Markdown Formatting**: Suggestions are formatted using GitHub Flavored Markdown

```python
# Group suggestions by label
suggestions_labels = dict()
for suggestion in data['code_suggestions']:
    label = suggestion['label'].strip().strip("'").strip('"')
    if label not in suggestions_labels:
        suggestions_labels[label] = []
    suggestions_labels[label].append(suggestion)

# Sort by highest score
suggestions_labels = dict(
    sorted(suggestions_labels.items(), 
           key=lambda x: max([s['score'] for s in x[1]]), 
           reverse=True))
```

资料来源：[pr_agent/tools/pr_code_suggestions.py:50-70]()

## Ask Tool

The `ask` tool provides conversational access to PR information:

- Answers questions about the entire PR
- Can reference specific code lines
- Processes images related to PR changes
- Independent question answering (no memory of previous questions)

```
/ask "What is the purpose of the new authentication module?"
/ask "Explain the changes in src/utils.py lines 50-100"
```

Note: Each question is answered independently without context from previous questions.

资料来源：[pr_agent/servers/help.py:115-130]()

## Help Docs Tool

The `help_docs` tool retrieves and explains documentation based on repository files:

```
/help_docs "How do I configure the CI pipeline?"
```

This tool searches documentation within the repository or a specified external repository.

## Output Formatting

### GitHub Flavored Markdown Support

PR-Agent detects GFM support and adjusts output accordingly:

```python
if gfm_supported:
    markdown_text += '<table>'
    # Table-based formatting with collapsible sections
else:
    # Standard markdown with headers
    markdown_text += f"### {emoji} {key_nice}: {value}\n\n"
```

### Collapsible File Lists

For PRs with many changed files, the tools use collapsible sections:

```html
<details><summary>{filename}</summary>
<hr>
{file_content}
</details>
```

资料来源：[pr_agent/tools/pr_description.py:100-130]()

### Diff Statistics

File changes are displayed with diff statistics:

```python
diff_plus_minus += f"+{num_plus_lines}/-{num_minus_lines}"
```

## Configuration System

### Per-Tool Configuration

Each tool has its own configuration section:

| Tool | Configuration Section | Location |
|------|----------------------|----------|
| Describe | `pr_description` | pr_agent/settings/configuration.toml |
| Review | `pr_reviewer` | pr_agent/settings/configuration.toml |
| Improve | `pr_code_suggestions` | pr_agent/settings/configuration.toml |

### Configuration Output

When `output_relevant_configurations` is enabled, tools output relevant settings:

```python
if get_settings().get('config', {}).get('output_relevant_configurations', False):
    pr_body += show_relevant_configurations(relevant_section='pr_description')
```

资料来源：[pr_agent/tools/pr_config.py:1-30]()

## Help Comments

Tools can optionally add help comments to PR descriptions:

```python
if get_settings().pr_description.enable_help_comment and self.git_provider.is_supported("gfm_markdown"):
    pr_body += ('\n\n___\n\n> <details> <summary>  Need help?</summary><li>Type <code>/help how to ...</code> '
                'in the comments thread for any questions about PR-Agent usage.</li><li>Check out the '
                '<a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> '
                'for more information.</li></details>')
```

资料来源：[pr_agent/tools/pr_description.py:45-60]()

## Multi-Platform Support

PR-Agent tools adapt their output based on the Git provider:

### GitHub

Uses full GFM support with table formatting and collapsible sections.

### GitLab

Adapted output for GitLab markdown compatibility:

```python
else:  # gitlab
    pr_body += ("\n\n___\n\n<details><summary>Need help?</summary>- Type <code>/help how to ...</code> in the comments "
                "thread for any questions about PR-Agent usage.<br>- Check out the "
                "<a href='https://qodo-merge-docs.qodo.ai/usage-guide/'>documentation</a> for more information.</details>")
```

### Bitbucket

Bitbucket Server has limited multi-line suggestion support, so code suggestions use code blocks instead:

```python
# Bitbucket does not support multi-line suggestions so use a code block instead
body = body.replace("```suggestion", "```")
```

资料来源：[pr_agent/git_providers/bitbucket_server_provider.py:150-160]()

## Workflow Integration

### Automatic Triggers

Tools can be configured to run automatically on PR events:

```yaml
pr_commands = ["/describe", "/review", "/improve"]
```

With markers enabled:

```yaml
pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
```

### Manual Invocation

For interactive use, tools are invoked via PR comments:

```bash
# Review a specific aspect
/review --pr_reviewer.extra_instructions="Focus on security issues only"
```

## Summary

The PR-Agent tools system provides comprehensive automation for pull request workflows:

- **Describe**: Automatic PR documentation
- **Review**: Intelligent code analysis
- **Improve**: Actionable suggestions
- **Ask**: Conversational PR queries
- **Help Docs**: Documentation retrieval

Each tool is independently configurable, supports multiple Git providers, and can be integrated into CI/CD pipelines or used interactively.

---

<a id='describe-tool'></a>

## /describe Tool

### 相关页面

相关主题：[Tools Overview](#tools-overview)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [pr_agent/tools/pr_description.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_description.py)
- [pr_agent/servers/help.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/servers/help.py)
- [pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)
- [pr_agent/tools/pr_config.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_config.py)
- [AGENTS.md](https://github.com/The-PR-Agent/pr-agent/blob/main/AGENTS.md)
</details>

# /describe Tool

The `/describe` tool is one of the core features of PR-Agent that automatically generates comprehensive descriptions for Pull Requests by analyzing code changes.

## Overview

The `describe` tool scans PR code changes and automatically generates a structured description including:

- **PR Title** - Concise summary of the changes
- **PR Type** - Classification (Bug fix, Enhancement, Documentation, Tests, Other)
- **Summary** - High-level overview of modifications
- **Walkthrough** - File-by-file breakdown of changes
- **Labels** - Automatically suggested labels based on content

资料来源：[pr_agent/servers/help.py:1-50]()

## Architecture

```mermaid
graph TD
    A[PR Opened/Updated] --> B{Automation Triggered?}
    B -->|Yes| C[Automatic Mode]
    B -->|No| D[Manual Comment: /describe]
    C --> E[PRDescriptionTool.run]
    D --> E
    E --> F[Analyze Diff Files]
    F --> G[Generate Title & Type]
    G --> H[Generate Summary]
    H --> I[Generate Walkthrough Table]
    I --> J[Apply Labels]
    J --> K[Update PR Description]
    K --> L[Optional: Add Help Comment]
```

## Usage Modes

### Automatic Mode

The tool can run automatically when a PR is opened or updated, configured via GitHub App settings.

```yaml
# Default automation configuration
pr_commands = ["/describe", ...]
```

资料来源：[pr_agent/servers/help.py:70-85]()

### Manual Mode

Invoke manually by commenting on a PR:

```
/describe
```

With custom configurations:

```
/describe --pr_description.some_config1=... --pr_description.some_config2=...
```

资料来源：[pr_agent/servers/help.py:45-60]()

### Marker Mode

An alternative approach using markers in the PR description:

```yaml
pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
```

Available markers:
- `pr_agent:type` - PR type
- `pr_agent:summary` - PR summary
- `pr_agent:walkthrough` - File walkthrough
- `pr_agent:diagram` - Sequence diagram (if enabled)

资料来源：[pr_agent/servers/help.py:80-100]()

## Output Structure

The generated PR description follows this structure:

| Section | Description |
|---------|-------------|
| Title | PR type prefix + concise title (max 10 words) |
| Type | Classification of the change |
| Summary | High-level description of modifications |
| Walkthrough | Table of changed files with descriptions |
| Labels | Suggested labels for categorization |

## Configuration Options

### Configuration File

```toml
[pr_description]
extra_instructions="""\
- The PR title should be in the format: '<PR type>: <title>'
- The title should be short and concise (up to 10 words)
- Use bullet points for clarity
"""
```

### Key Configuration Parameters

| Parameter | Description | Default |
|-----------|-------------|---------|
| `enable_help_comment` | Add help text to PR | `true` |
| `use_description_markers` | Use markers in PR body | `false` |
| `enable_generate_title` | Auto-generate title | `true` |
| `enable.type` | Include PR type | `true` |
| `enable.walkthrough` | Include file walkthrough | `true` |
| `enable.labels` | Include labels | `true` |
| `extra_instructions` | Custom instructions | `""` |

资料来源：[pr_agent/servers/help.py:46-55]()

## Walkthrough Table Format

The file walkthrough is rendered as a markdown table with collapsible sections:

```markdown
| Theme | Files Changed |
|-------|---------------|
| **Core Logic** | <details><summary>2 files</summary>... |
```

### Table Components

| Component | Description |
|-----------|-------------|
| `file_changes_title` | Category or component name |
| `diff_plus_minus` | Lines added/removed (`+X/-Y`) |
| `file_change_description` | Description of changes |
| `link` | URL to file diff |

资料来源：[pr_agent/tools/pr_description.py:100-150]()

## Custom Labels

The tool supports custom labels defined in the repository's labels page:

### Default Labels

- `Bug fix`
- `Tests`
- `Enhancement`
- `Documentation`
- `Other`

### Custom Label Format

```
Main topic:performance - pr_agent:The main topic of this PR is performance
New endpoint - pr_agent:A new endpoint was added in this PR
SQL query - pr_agent:A new SQL query was added in this PR
Dockerfile changes - pr_agent:The PR contains changes in the Dockerfile
```

资料来源：[pr_agent/servers/help.py:105-130]()

## Help Comment Integration

When enabled, a help comment is appended to the PR:

```html
> <details> <summary> Need help?</summary>
> <li>Type <code>/help how to ...</code> in the comments thread</li>
> <li>Check out the <a href="...">documentation</a></li>
> </details>
```

This is displayed conditionally based on:
- `enable_help_comment` setting
- Git provider support for GFM markdown
- Provider type (GitHub vs GitLab)

资料来源：[pr_agent/tools/pr_description.py:25-45]()

## Implementation Flow

```mermaid
sequenceDiagram
    participant User
    participant GitProvider
    participant PRDescriptionTool
    participant Model
    
    User->>GitProvider: Opens PR
    GitProvider->>PRDescriptionTool: Trigger /describe
    PRDescriptionTool->>GitProvider: Get diff files
    GitProvider-->>PRDescriptionTool: Return diff
    PRDescriptionTool->>Model: Request description
    Model-->>PRDescriptionTool: Generated content
    PRDescriptionTool->>PRDescriptionTool: Format markdown
    PRDescriptionTool->>GitProvider: Update PR description
    alt enable_help_comment
        PRDescriptionTool->>GitProvider: Add help comment
    end
```

## Code Suggestion Integration

The describe tool works alongside the `improve` tool for code suggestions:

```python
# From pr_description.py
if get_settings().get('config', {}).get('output_relevant_configurations', False):
    pr_body += show_relevant_configurations(relevant_section='pr_description')
```

资料来源：[pr_agent/tools/pr_description.py:50-52]()

## Relevant Configuration Display

When `output_relevant_configurations` is enabled, relevant settings are included in the output:

```toml
[pr_description]
some_config1=...
some_config2=...
```

资料来源：[pr_agent/tools/pr_config.py:1-20]()

## Related Commands

| Command | Purpose |
|---------|---------|
| `/review` | Analyze PR code and provide feedback |
| `/improve` | Generate code improvement suggestions |
| `/ask` | Answer questions about the PR |
| `/help_docs` | Answer questions from documentation |

## Best Practices

1. **Custom Labels**: Define labels relevant to your repository's domain
2. **Extra Instructions**: Use `extra_instructions` for project-specific formatting rules
3. **Markers**: Use markers for incremental updates to PR descriptions
4. **Automation**: Enable automatic triggering for consistent documentation

资料来源：[AGENTS.md:1-30]()

## Summary

The `/describe` tool is a powerful feature that transforms raw code changes into human-readable PR descriptions. It supports multiple invocation modes, customizable output formats, and integrates seamlessly with GitHub's workflow automation capabilities.

---

<a id='review-tool'></a>

## /review Tool

### 相关页面

相关主题：[Tools Overview](#tools-overview)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [pr_agent/servers/help.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/servers/help.py)
- [pr_agent/tools/pr_code_suggestions.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_code_suggestions.py)
- [pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)
- [pr_agent/tools/pr_config.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_config.py)
- [pr_agent/git_providers/bitbucket_server_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/bitbucket_server_provider.py)
</details>

# /review Tool

## Overview

The `/review` tool is a core component of PR-Agent that performs automated code review of pull requests. It scans PR code changes and provides a comprehensive analysis including code quality assessment, potential bugs, security issues, testing gaps, and improvement suggestions.

The tool can be triggered automatically when a new PR is opened, or invoked manually by commenting on a PR with the `/review` command.

## Architecture

```mermaid
graph TD
    A[User Trigger: /review] --> B[Git Provider Integration]
    B --> C[Diff Files Extraction]
    C --> D[PR Reviewer Engine]
    D --> E[LLM Analysis]
    E --> F[Review Output Generation]
    F --> G[Publish to PR Comments]
    
    H[Configuration] --> D
    I[Prompt Templates] --> E
```

## Invocation Methods

### Manual Invocation

To invoke the review tool manually, comment on a PR with:

```
/review
```

To customize behavior, pass configuration parameters:

```
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
```

### Configuration File

Alternatively, configure via a configuration file:

```toml
[pr_reviewer]
some_config1=...
some_config2=...
```

## Configuration Options

The `pr_reviewer` section in `configuration.toml` controls the review tool behavior:

| Parameter | Description | Default |
|-----------|-------------|---------|
| `enable_help_text` | Show help text in review output | `true` |
| `enable_load_files` | Load file contents for deeper analysis | `false` |
| `enable_intro` | Show introduction section | `true` |
| `enable_final_comment` | Add final summary comment | `true` |
| `enable_review_status` | Track review completion status | `false` |

资料来源：[pr_agent/servers/help.py:1-30]()

## Review Output Structure

The review output is generated in markdown format with collapsible sections. The output follows this structure:

```markdown
## PR Review Summary

[Overview of changes]

### Code Quality Assessment
[Analysis of code structure and patterns]

### Potential Issues
[List of identified problems]

### Suggestions
[Improvement recommendations]

### Security Considerations
[Security-relevant findings]
```

## Integration with Code Suggestions

The review tool leverages the code suggestions subsystem to provide actionable improvement recommendations:

```python
# From pr_code_suggestions.py
suggestions_labels = dict()
for suggestion in data['code_suggestions']:
    label = suggestion['label'].strip()
    if label not in suggestions_labels:
        suggestions_labels[label] = []
    suggestions_labels[label].append(suggestion)
```

资料来源：[pr_agent/tools/pr_code_suggestions.py:50-60]()

## Code Suggestion Display Format

When GFM (GitHub Flavored Markdown) is supported, suggestions are displayed in a structured table:

```html
<table>
  <thead>
    <tr>
      <td><strong>Category</strong></td>
      <td align=left><strong>Suggestion</strong></td>
      <td align=center><strong>Impact</strong></td>
    </tr>
  </thead>
  <tbody>
    <!-- Suggestions rendered here -->
  </tbody>
</table>
```

资料来源：[pr_agent/tools/pr_code_suggestions.py:40-50]()

## Markdown Rendering Utilities

The tool uses utility functions to convert suggestion dictionaries to markdown:

```python
def parse_code_suggestion(code_suggestion: dict, i: int = 0, gfm_supported: bool = True) -> str:
    """
    Convert a dictionary of data into markdown format.
    """
    markdown_text = ""
    if gfm_supported and 'relevant_line' in code_suggestion:
        markdown_text += '<table>'
        # ... table rendering logic
    markdown_text += "</table>\n"
    return markdown_text
```

资料来源：[pr_agent/algo/utils.py:100-120]()

## Git Provider Integration

The review output can be published to different Git platforms. The `publish_code_suggestions` method in `bitbucket_server_provider.py` demonstrates platform-specific handling:

```python
if relevant_lines_end > relevant_lines_start:
    # Bitbucket does not support multi-line suggestions
    body = body.replace("```suggestion", "```")
    post_parameters = {
        "body": body,
        "path": relevant_file,
        "line": relevant_lines_end,
        # ...
    }
```

资料来源：[pr_agent/git_providers/bitbucket_server_provider.py:1-30]()

## Configuration Output

The tool can output relevant configurations in the review comment when enabled:

```python
def show_relevant_configurations(relevant_section='pr_description') -> str:
    # Returns formatted markdown of configuration settings
```

资料来源：[pr_agent/tools/pr_config.py:1-20]()

## Workflow Diagram

```mermaid
sequenceDiagram
    participant User
    participant GitProvider
    participant ReviewTool
    participant LLM
    participant OutputFormatter
    
    User->>GitProvider: /review command
    GitProvider->>ReviewTool: Fetch PR diff
    ReviewTool->>LLM: Send for analysis
    LLM->>OutputFormatter: Return structured review
    OutputFormatter->>GitProvider: Format as markdown
    GitProvider->>User: Publish review comment
```

## File Walkthrough Parsing

The review tool parses file walkthroughs from PR descriptions using regex patterns:

```python
regex_pattern = r'<details.*?>\s*<summary>\s*<h3>\s*' + re.escape(PRDescriptionHeader.FILE_WALKTHROUGH.value) + r'\s*</h3>\s*</summary>'
description_split = re.split(regex_pattern, description_full, maxsplit=1, flags=re.DOTALL)
```

资料来源：[pr_agent/algo/utils.py:150-160]()

## Help Text Integration

The review tool includes contextual help text that can be displayed based on configuration:

```python
if get_settings().pr_reviewer.enable_help_text and self.git_provider.is_supported("gfm_markdown"):
    pr_body += HelpMessage.get_review_usage_guide()
```

资料来源：[pr_agent/servers/help.py:10-20]()

## Automated Triggers

The review tool can be configured to run automatically on PR events:

```yaml
pr_commands = ["/review", ...]  # Default mode
# Or with specific configurations:
pr_commands = ["/review --pr_reviewer.enable_intro=false", ...]
```

资料来源：[pr_agent/servers/help.py:15-25]()

## Best Practices

1. **Use specific configurations** to focus review on relevant aspects (security, code quality, etc.)
2. **Enable intro text** for new team members to understand review comments
3. **Disable help text** in short-lived branches to reduce noise
4. **Combine with `/improve`** for actionable code suggestions

## External Documentation

For comprehensive usage guides and examples, see the official documentation:
- [Review Tool Usage](https://pr-agent-docs.codium.ai/tools/review/)
- [Configuration Options](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/)
- [Automations](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened)

---

<a id='improve-tool'></a>

## /improve Tool

### 相关页面

相关主题：[Tools Overview](#tools-overview)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [pr_agent/tools/pr_code_suggestions.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_code_suggestions.py)
- [pr_agent/servers/help.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/servers/help.py)
- [pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)
- [pr_agent/git_providers/bitbucket_server_provider.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/git_providers/bitbucket_server_provider.py)
- [pr_agent/tools/pr_config.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_config.py)
</details>

# /improve Tool

## Overview

The `/improve` tool is a PR-Agent module that automatically scans pull request code changes and generates actionable code suggestions for improving the PR. It serves as the core component behind the `pr_code_suggestions` feature, providing developers with intelligent recommendations to enhance code quality, performance, and maintainability.

The tool can be triggered automatically when a PR is opened or invoked manually by commenting `/improve` on any pull request.

## Key Characteristics

| Attribute | Description |
|-----------|-------------|
| Tool Name | `improve` |
| Configuration Section | `pr_code_suggestions` |
| Invocation Command | `/improve` |
| Auto-trigger Support | Yes |
| Manual Trigger | Via PR comment |
| Output Format | Markdown table with collapsible code diffs |

## Architecture

```mermaid
graph TD
    A[PR Opened / /improve Command] --> B[pr_code_suggestions.py]
    B --> C[Get Diff Files from PR]
    C --> D[Analyze Code Changes]
    D --> E[Generate Suggestions via LLM]
    E --> F[Parse & Format Suggestions]
    F --> G[Render Markdown Output]
    G --> H[Post to PR as Comment]
    
    F --> I[parse_code_suggestion function]
    I --> J[Table Format with GFM]
    I --> K[Diff Code Generation]
    
    H --> L[GitHub Provider]
    H --> M[GitLab Provider]
    H --> N[Bitbucket Provider]
```

## Data Flow

```mermaid
sequenceDiagram
    participant User
    participant GitProvider
    participant ImproveTool
    participant LLM
    participant MarkdownRenderer
    
    User->>GitProvider: Trigger /improve command
    GitProvider->>ImproveTool: Pass PR diff files
    ImproveTool->>LLM: Request code suggestions
    LLM->>ImproveTool: Return structured suggestions
    ImproveTool->>MarkdownRenderer: Parse suggestion data
    MarkdownRenderer->>ImproveTool: Generate formatted markdown
    ImproveTool->>GitProvider: Post comment to PR
```

## Configuration Options

The `/improve` tool is configured via the `pr_code_suggestions` section in the configuration file or through command-line arguments.

### Configuration Parameters

| Parameter | Type | Description | Default |
|-----------|------|-------------|---------|
| `enable_help_comment` | bool | Show help instructions in PR comment | Varies |
| `num_code_suggestions` | int | Maximum number of suggestions to generate | Config dependent |

### Command-Line Override

When commenting on a PR, edit configurations using:

```bash
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
```

### Configuration File Format

```toml
[pr_code_suggestions]
some_config1=...
some_config2=...
```

资料来源：[pr_agent/servers/help.py:78-90]()

## Output Format

### Markdown Table Structure

The tool renders suggestions in a structured table format:

```
Category | Suggestion Content | Impact
---------|-------------------|--------
```

### Suggestion Component Model

Each code suggestion contains:

| Field | Description |
|-------|-------------|
| `label` | Category/label for the suggestion |
| `score` | Priority score (used for sorting) |
| `one_sentence_summary` | Brief description |
| `existing_code` | Original code block |
| `improved_code` | Suggested improved code |
| `relevant_file` | Target file path |
| `relevant_lines_start` | Start line number |
| `relevant_lines_end` | End line number |

资料来源：[pr_agent/tools/pr_code_suggestions.py:1-50]()

### Rendering Logic

The rendering engine sorts suggestions by:

1. **Primary sort**: Group by label, ordered by highest score within each group
2. **Secondary sort**: Within each label group, suggestions are sorted by score descending

```python
suggestions_labels = dict(
    sorted(suggestions_labels.items(), key=lambda x: max([s['score'] for s in x[1]]), reverse=True))
for label, suggestions in suggestions_labels.items():
    suggestions_labels[label] = sorted(suggestions, key=lambda x: x['score'], reverse=True)
```

资料来源：[pr_agent/tools/pr_code_suggestions.py:30-40]()

## Diff Generation

### Unified Diff Format

The tool generates `unified_diff` output for comparing existing and improved code:

```python
diff = difflib.unified_diff(
    existing_code.split('\n'),
    improved_code.split('\n'), 
    n=999
)
patch_orig = "\n".join(diff)
patch = "\n".join(patch_orig.splitlines()[5:]).strip('\n')
```

资料来源：[pr_agent/tools/pr_code_suggestions.py:80-90]()

### Output Wrapper

```markdown
```diff
--- original
+++ improved
@@ ... @@
...diff content...
```
```

## Multi-Provider Support

### GitHub Provider

Standard markdown rendering with collapsible details:

```html
<details><summary>Suggestion Summary</summary>

___

**Suggestion Content**

[file.py:10-25](link)

```diff
...code diff...
```
</details>
```

### GitLab Provider

Similar to GitHub with minor formatting adjustments.

### Bitbucket Server Provider

Special handling for multi-line suggestions:

> Bitbucket does not support multi-line suggestions so use a code block instead

资料来源：[pr_agent/git_providers/bitbucket_server_provider.py:200-210]()

## Usage Examples

### Manual Invocation

```
/improve
/improve --pr_code_suggestions.num_code_suggestions=5
/improve --pr_code_suggestions.some_config=value
```

### Automated Trigger

Configured via GitHub App automatic tools, the tool runs on PR open events when enabled in settings.

## Related Utility Functions

### parse_code_suggestion

Located in `pr_agent/algo/utils.py`, this function converts suggestion dictionaries to markdown:

```python
def parse_code_suggestion(code_suggestion: dict, i: int = 0, gfm_supported: bool = True) -> str:
    """
    Convert a dictionary of data into markdown format.
    """
    markdown_text = ""
    if gfm_supported and 'relevant_line' in code_suggestion:
        markdown_text += '<table>'
        # ... processing logic
    return markdown_text
```

资料来源：[pr_agent/algo/utils.py:100-120]()

### extract_relevant_lines_str

Extracts relevant code lines from PR diff for context:

```python
def extract_relevant_lines_str(end_line, files, relevant_file, start_line, dedent=False) -> str:
    """Finds 'relevant_file' in 'files', and extracts the lines from 'start_line' to 'end_line'"""
```

资料来源：[pr_agent/algo/utils.py:150-180]()

## Integration Points

```mermaid
graph LR
    A[pr_code_suggestions.py] --> B[HelpMessage]
    A --> C[get_settings]
    A --> D[GitProvider]
    A --> E[utils.py functions]
    
    B --> F[get_improve_usage_guide]
    C --> G[Configuration Loading]
    D --> H[Post Comments]
    E --> I[parse_code_suggestion]
    E --> J[render_*_markdown]
```

## See Also

- [Review Tool](/tools/review/) - Code review functionality
- [Describe Tool](/tools/describe/) - PR description generation
- [Ask Tool](/tools/ask/) - Interactive PR questions
- [Configuration Guide](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/)

---

<a id='additional-tools'></a>

## Additional Tools

### 相关页面

相关主题：[Tools Overview](#tools-overview), [/describe Tool](#describe-tool), [/review Tool](#review-tool)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [pr_agent/tools/pr_questions.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_questions.py)
- [pr_agent/tools/pr_help_docs.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_help_docs.py)
- [pr_agent/tools/pr_update_changelog.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_update_changelog.py)
- [pr_agent/tools/pr_generate_labels.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_generate_labels.py)
- [pr_agent/tools/pr_similar_issue.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_similar_issue.py)
- [pr_agent/servers/help.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/servers/help.py)
- [pr_agent/algo/utils.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/algo/utils.py)
</details>

# Additional Tools

PR-Agent provides several supplementary tools that extend beyond the core code review capabilities. These tools help developers with documentation lookup, changelog management, label generation, and finding related issues.

## Overview

The Additional Tools module encompasses standalone utilities that can be invoked manually on pull requests. Unlike the core automated tools (describe, review, improve) that run automatically, these tools are typically triggered through comments on specific PRs.

```mermaid
graph TD
    A[PR Agent Tools] --> B[Core Automated Tools]
    A --> C[Additional Tools]
    
    C --> D[ask]
    C --> E[help_docs]
    C --> F[update_changelog]
    C --> G[generate_labels]
    C --> H[similar_issue]
    
    style C fill:#f9f,stroke:#333,stroke-width:2px
    style D fill:#bbf,stroke:#333,stroke-width:1px
    style E fill:#bbf,stroke:#333,stroke-width:1px
    style F fill:#bbf,stroke:#333,stroke-width:1px
    style G fill:#bbf,stroke:#333,stroke-width:1px
    style H fill:#bbf,stroke:#333,stroke-width:1px
```

## Ask Tool

The `ask` tool answers questions about the PR code changes using natural language.

### Purpose

The ask tool provides a question-and-answer interface that allows developers to query information about a specific pull request. It analyzes the PR diff and code to provide contextual answers.

### Invocation

```bash
/ask "What changes were made to the authentication module?"
```

### Key Characteristics

| Characteristic | Description |
|----------------|-------------|
| **Memory** | No memory of previous questions |
| **Independence** | Each question answered independently |
| **Scope** | Entire PR, specific code lines, or images |
| **Invocation** | Manual only via PR comments |

资料来源：[pr_agent/servers/help.py:1-50]()

### Implementation

The ask functionality is implemented in `pr_agent/tools/pr_questions.py`. The tool:

1. Parses the question from the PR comment
2. Extracts relevant code changes from the PR diff
3. Generates a contextual response using the LLM

```mermaid
graph LR
    A[User Comment: /ask "..."] --> B[Parse Question]
    B --> C[Extract PR Diff]
    C --> D[Generate Context]
    D --> E[LLM Processing]
    E --> F[Response Output]
```

## Help Docs Tool

The `help_docs` tool answers questions based on documentation files within the repository.

### Purpose

This tool enables developers to ask questions about project documentation and receive accurate answers based on the actual documentation files.

### Invocation

```bash
/help_docs "How do I configure the webhook?"
```

### Configuration

The tool supports documentation from:
- The repository's own documentation files
- External documentation sources specified in configuration

### Key Features

- Answers questions based on relative documentation paths
- Supports both repository-local and external documentation sources
- Provides accurate answers using RAG (Retrieval-Augmented Generation) techniques

资料来源：[pr_agent/tools/pr_help_docs.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_help_docs.py)

## Update Changelog Tool

The `update_changelog` tool automatically updates changelog files based on PR changes.

### Purpose

This tool ensures that changelog entries are created or updated when new features, fixes, or changes are merged.

### Key Workflow

```mermaid
graph TD
    A[PR Merged] --> B[Trigger update_changelog]
    B --> C[Analyze PR Changes]
    C --> D[Determine Changelog Category]
    D --> E{Find Existing Changelog?}
    E -->|Yes| F[Update Existing Entry]
    E -->|No| G[Create New Entry]
    F --> H[Format According to Standards]
    G --> H
    H --> I[Commit Changes]
```

### Changelog Categories

| Category | Description |
|----------|-------------|
| Features | New functionality additions |
| Bug Fixes | Resolution of bugs |
| Breaking Changes | API or behavior changes |
| Documentation | Documentation updates |

资料来源：[pr_agent/tools/pr_update_changelog.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_update_changelog.py)

## Generate Labels Tool

The `generate_labels` tool automatically creates or suggests labels for pull requests.

### Purpose

This tool analyzes PR changes and generates appropriate labels based on the content, type, and impact of the changes.

### Label Generation Process

```mermaid
graph LR
    A[Analyze PR Diff] --> B[Determine PR Type]
    B --> C[Assess Impact Area]
    C --> D[Match Against Existing Labels]
    D --> E[Generate Label Suggestions]
    E --> F[Apply or Present to User]
```

### Supported Label Types

| Label Type | Example |
|------------|---------|
| **Type-based** | Bug fix, Enhancement, Documentation |
| **Area-based** | Frontend, Backend, API, Database |
| **Scope-based** | Performance, Security, Testing |
| **Custom** | Repository-specific labels |

资料来源：[pr_agent/tools/pr_generate_labels.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_generate_labels.py)

## Similar Issue Tool

The `similar_issue` tool finds related issues or pull requests that address similar problems.

### Purpose

This tool helps developers avoid duplicate work by identifying existing issues or PRs that may be related to the current issue being addressed.

### Search Strategy

The tool uses multiple approaches to find similar issues:

1. **Semantic Search**: Uses embeddings to find semantically similar text
2. **Keyword Matching**: Identifies shared terminology
3. **Historical Analysis**: Examines closed/resolved similar issues

### Output Format

| Field | Description |
|-------|-------------|
| Issue/PR Number | Reference identifier |
| Title | Issue/PR title |
| Similarity Score | Relevance indicator |
| Status | Open/Closed/Resolved |
| Resolution | How it was addressed (if closed) |

资料来源：[pr_agent/tools/pr_similar_issue.py](https://github.com/The-PR-Agent/pr-agent/blob/main/pr_agent/tools/pr_similar_issue.py)

## Common Configuration Options

Additional tools share several common configuration patterns.

### Configuration via Comments

```bash
/tool_name --section.option=value
```

### Configuration via File

```toml
[section_name]
option1 = value1
option2 = value2
```

### Shared Settings

| Setting | Description | Default |
|---------|-------------|---------|
| `enable_help_comment` | Show help links in output | Varies by tool |
| `output_relevant_configurations` | Include config details in output | false |

资料来源：[pr_agent/servers/help.py:1-100]()

## Usage Patterns

### Manual Invocation

All additional tools are invoked manually through PR comments:

```bash
/ask "What does this function do?"
/help_docs "How do I run tests?"
/generate_labels
/similar_issue "authentication bug"
```

### Tool Comparison

| Tool | Trigger Type | Automated | Primary Use Case |
|------|-------------|-----------|------------------|
| ask | Manual | No | Code understanding |
| help_docs | Manual | No | Documentation lookup |
| update_changelog | Manual/Auto | Optional | Release notes |
| generate_labels | Manual | Optional | Organization |
| similar_issue | Manual | No | Avoiding duplicates |

## Help System Integration

Each tool includes integrated help documentation accessible through the help system:

```mermaid
graph TD
    A[User] --> B[/help or /ask "help"]
    B --> C[HelpMessage Class]
    C --> D{Identify Tool}
    D --> E[get_{tool}_usage_guide]
    E --> F[Display Usage Info]
    F --> G[Link to Full Documentation]
```

The help system provides:
- Usage examples for each tool
- Configuration templates
- Links to detailed documentation pages
- GitHub App vs GitLab compatibility notes

资料来源：[pr_agent/servers/help.py:50-150]()

## Implementation Architecture

### Tool Base Structure

```mermaid
classDiagram
    class BaseTool {
        +run()
        +get_settings()
        +git_provider
    }
    class AskTool {
        +answer_question()
    }
    class HelpDocsTool {
        +find_documentation()
    }
    class UpdateChangelogTool {
        +update_changelog()
    }
    class GenerateLabelsTool {
        +generate_labels()
    }
    class SimilarIssueTool {
        +find_similar()
    }
    
    BaseTool <|-- AskTool
    BaseTool <|-- HelpDocsTool
    BaseTool <|-- UpdateChangelogTool
    BaseTool <|-- GenerateLabelsTool
    BaseTool <|-- SimilarIssueTool
```

### Utility Functions

Shared utilities in `pr_agent/algo/utils.py` provide common functionality:

- `parse_code_suggestion()`: Converts code suggestion dictionaries to markdown
- `extract_relevant_lines_str()`: Extracts specific code lines from diffs
- `show_relevant_configurations()`: Displays configuration details

资料来源：[pr_agent/algo/utils.py:1-100]()

## Best Practices

### When to Use Additional Tools

| Scenario | Recommended Tool |
|----------|-----------------|
| Understanding complex code changes | `ask` |
| Finding documentation information | `help_docs` |
| Preparing release notes | `update_changelog` |
| Organizing PRs with labels | `generate_labels` |
| Checking for duplicate work | `similar_issue` |

### Configuration Recommendations

1. **Enable help comments** to guide users unfamiliar with tools
2. **Set up custom label mappings** for the generate_labels tool
3. **Configure changelog format** to match project standards
4. **Use appropriate documentation paths** for help_docs tool

## Documentation References

For detailed information about specific tools, refer to:

- [Ask Tool Documentation](https://pr-agent-docs.codium.ai/tools/ask/)
- [Help Docs Tool Documentation](https://pr-agent-docs.codium.ai/tools/help_docs/)
- [Configuration Guide](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/)

资料来源：[pr_agent/servers/help.py:1-50](), [pr_agent/servers/help.py:50-100]()

---

---

## Doramagic Pitfall Log

Project: The-PR-Agent/pr-agent

Summary: Found 38 potential pitfall items; 5 are high/blocking. Highest priority: installation - 来源证据：Allow specifying a custom branch for locating `.pr_agent.toml`.

## 1. installation · 来源证据：Allow specifying a custom branch for locating `.pr_agent.toml`

- Severity: high
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Allow specifying a custom branch for locating `.pr_agent.toml`
- User impact: 可能增加新用户试用和生产接入成本。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_6aa2027573564d778bdccf1c0e603a0f | https://github.com/The-PR-Agent/pr-agent/issues/1977 | 来源类型 github_issue 暴露的待验证使用条件。

## 2. security_permissions · 失败模式：security_permissions: Add support for Databricks hosted models

- Severity: high
- Evidence strength: source_linked
- Finding: Developers should check this security_permissions risk before relying on the project: Add support for Databricks hosted models
- User impact: Developers may expose sensitive permissions or credentials: Add support for Databricks hosted models
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: Add support for Databricks hosted models. Context: Observed when using python, docker
- Guardrail action: Do not recommend enabling privileged or credential-bearing paths until the source-backed risk is reviewed: https://github.com/The-PR-Agent/pr-agent/issues/2246
- Evidence: failure_mode_cluster:github_issue | fmev_63e7f7511bd7314419df2ded4a1a20e9 | https://github.com/The-PR-Agent/pr-agent/issues/2246 | Add support for Databricks hosted models

## 3. security_permissions · 来源证据：Add support for Databricks hosted models

- Severity: high
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Add support for Databricks hosted models
- User impact: 可能影响授权、密钥配置或安全边界。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_6b5b4692165240e5a79137dc9335bd50 | https://github.com/The-PR-Agent/pr-agent/issues/2246 | 来源讨论提到 docker 相关条件，需在安装/试用前复核。

## 4. security_permissions · 来源证据：GITLAB 404 project not found

- Severity: high
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：GITLAB 404 project not found
- User impact: 可能影响授权、密钥配置或安全边界。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_04774e9f24034b56b080d2af0875b7fd | https://github.com/The-PR-Agent/pr-agent/issues/2282 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 5. security_permissions · 来源证据：Incorrect Inline Code Suggestion Formatting in Azure DevOps

- Severity: high
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Incorrect Inline Code Suggestion Formatting in Azure DevOps
- User impact: 可能影响升级、迁移或版本选择。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_d01349d41e8a48db89a80ebdb4ca9bde | https://github.com/The-PR-Agent/pr-agent/issues/2110 | 来源讨论提到 docker 相关条件，需在安装/试用前复核。

## 6. installation · 失败模式：installation: Bug + feature: `-i` (incremental review) crashes on Azure DevOps; needs full incremental supp...

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this installation risk before relying on the project: Bug + feature: `-i` (incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider
- User impact: Developers may fail before the first successful local run: Bug + feature: `-i` (incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: Bug + feature: `-i` (incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider. Context: Observed when using python
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_f812843570a304cde8d165f9bd42e8dc | https://github.com/The-PR-Agent/pr-agent/issues/2379 | Bug + feature: `-i` (incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider

## 7. installation · 失败模式：installation: feat: support agent skills for context-aware review guidance

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this installation risk before relying on the project: feat: support agent skills for context-aware review guidance
- User impact: Developers may fail before the first successful local run: feat: support agent skills for context-aware review guidance
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: feat: support agent skills for context-aware review guidance. Context: Observed when using python
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_6fae5a58920d170992e268f4837b86a9 | https://github.com/The-PR-Agent/pr-agent/issues/2384 | feat: support agent skills for context-aware review guidance

## 8. installation · 失败模式：installation: v0.35.0

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this installation risk before relying on the project: v0.35.0
- User impact: Upgrade or migration may change expected behavior: v0.35.0
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: v0.35.0. Context: Observed when using python, docker, windows
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_release | fmev_c8b7b30719c4160c5c0104029f83e764 | https://github.com/The-PR-Agent/pr-agent/releases/tag/v0.35.0 | v0.35.0

## 9. installation · 来源证据：CORS error on Azure DevOps when displaying "Work in progress" loading GIF

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：CORS error on Azure DevOps when displaying "Work in progress" loading GIF
- User impact: 可能增加新用户试用和生产接入成本。
- Suggested check: 来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_befb1a7b72d44beba27f8ffc0e2646ca | https://github.com/The-PR-Agent/pr-agent/issues/2223 | 来源讨论提到 docker 相关条件，需在安装/试用前复核。

## 10. installation · 来源证据：Publish linux/arm64 Docker image for github_app tag

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Publish linux/arm64 Docker image for github_app tag
- User impact: 可能增加新用户试用和生产接入成本。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_8cb9e552d2e2452cbe958628f6e800b6 | https://github.com/The-PR-Agent/pr-agent/issues/2386 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 11. installation · 来源证据：[Bug] UnicodeDecodeError in gitea_provider.py when parsing binary files before extension filtering

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：[Bug] UnicodeDecodeError in gitea_provider.py when parsing binary files before extension filtering
- User impact: 可能阻塞安装或首次运行。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_52bd470b7b5e4be6858b290e41c93036 | https://github.com/The-PR-Agent/pr-agent/issues/2380 | 来源讨论提到 docker 相关条件，需在安装/试用前复核。

## 12. installation · 来源证据：[Bug] `temperature` parameter sent to claude-opus-4-7 causes 400 from Anthropic

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：[Bug] `temperature` parameter sent to claude-opus-4-7 causes 400 from Anthropic
- User impact: 可能影响升级、迁移或版本选择。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_14856949ca534836a7f707e2c1333b17 | https://github.com/The-PR-Agent/pr-agent/issues/2400 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 13. installation · 来源证据：v0.34.2

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：v0.34.2
- User impact: 可能增加新用户试用和生产接入成本。
- Suggested check: 来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_4bc22335937e44c0b529ab84d1e69a60 | https://github.com/The-PR-Agent/pr-agent/releases/tag/v0.34.2 | 来源讨论提到 docker 相关条件，需在安装/试用前复核。

## 14. configuration · 失败模式：configuration: /improve on GitLab duplicates the persistent suggestions thread on every push once the previo...

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: /improve on GitLab duplicates the persistent suggestions thread on every push once the previous one has any reply
- User impact: Developers may misconfigure credentials, environment, or host setup: /improve on GitLab duplicates the persistent suggestions thread on every push once the previous one has any reply
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: /improve on GitLab duplicates the persistent suggestions thread on every push once the previous one has any reply. Context: Observed when using python
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_f4643954c8dbe2f730d31cefbeaa8c78 | https://github.com/The-PR-Agent/pr-agent/issues/2402 | /improve on GitLab duplicates the persistent suggestions thread on every push once the previous one has any reply

## 15. configuration · 失败模式：configuration: Allow specifying a custom branch for locating `.pr_agent.toml`

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: Allow specifying a custom branch for locating `.pr_agent.toml`
- User impact: Developers may misconfigure credentials, environment, or host setup: Allow specifying a custom branch for locating `.pr_agent.toml`
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: Allow specifying a custom branch for locating `.pr_agent.toml`. Context: Source discussion did not expose a precise runtime context.
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_339ee91f6568996765e72eae51a899dd | https://github.com/The-PR-Agent/pr-agent/issues/1977 | Allow specifying a custom branch for locating `.pr_agent.toml`

## 16. configuration · 失败模式：configuration: AzureDevopsProvider.get_repo_settings drops chunks after the first, silently truncating .pr_a...

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: AzureDevopsProvider.get_repo_settings drops chunks after the first, silently truncating .pr_agent.toml
- User impact: Developers may misconfigure credentials, environment, or host setup: AzureDevopsProvider.get_repo_settings drops chunks after the first, silently truncating .pr_agent.toml
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: AzureDevopsProvider.get_repo_settings drops chunks after the first, silently truncating .pr_agent.toml. Context: Observed when using python
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_08e02634b8266f9592093717f3fcb5ac | https://github.com/The-PR-Agent/pr-agent/issues/2376 | AzureDevopsProvider.get_repo_settings drops chunks after the first, silently truncating .pr_agent.toml

## 17. configuration · 失败模式：configuration: CORS error on Azure DevOps when displaying "Work in progress" loading GIF

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: CORS error on Azure DevOps when displaying "Work in progress" loading GIF
- User impact: Developers may misconfigure credentials, environment, or host setup: CORS error on Azure DevOps when displaying "Work in progress" loading GIF
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: CORS error on Azure DevOps when displaying "Work in progress" loading GIF. Context: Observed when using python, docker, linux
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_683820f79c6410463ae03829a7e5eb54 | https://github.com/The-PR-Agent/pr-agent/issues/2223 | CORS error on Azure DevOps when displaying "Work in progress" loading GIF

## 18. configuration · 失败模式：configuration: GITLAB 404 project not found

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: GITLAB 404 project not found
- User impact: Developers may misconfigure credentials, environment, or host setup: GITLAB 404 project not found
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: GITLAB 404 project not found. Context: Observed when using python
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_b2e82742d50cf2a8c0c2c182eb4f3928 | https://github.com/The-PR-Agent/pr-agent/issues/2282 | GITLAB 404 project not found

## 19. configuration · 失败模式：configuration: Incorrect Inline Code Suggestion Formatting in Azure DevOps

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: Incorrect Inline Code Suggestion Formatting in Azure DevOps
- User impact: Developers may misconfigure credentials, environment, or host setup: Incorrect Inline Code Suggestion Formatting in Azure DevOps
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: Incorrect Inline Code Suggestion Formatting in Azure DevOps. Context: Observed when using python, docker, linux
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_abf700a9dc4cdcc58a9bdae1a8ee37c0 | https://github.com/The-PR-Agent/pr-agent/issues/2110 | Incorrect Inline Code Suggestion Formatting in Azure DevOps

## 20. configuration · 失败模式：configuration: OSS build silently ignores best_practices.md (currently SaaS-only)

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: OSS build silently ignores best_practices.md (currently SaaS-only)
- User impact: Developers may misconfigure credentials, environment, or host setup: OSS build silently ignores best_practices.md (currently SaaS-only)
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: OSS build silently ignores best_practices.md (currently SaaS-only). Context: Observed when using python
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_6490ac18c4cc673d33dcc567f7b6f466 | https://github.com/The-PR-Agent/pr-agent/issues/2377 | OSS build silently ignores best_practices.md (currently SaaS-only)

## 21. configuration · 失败模式：configuration: [Bug] UnicodeDecodeError in gitea_provider.py when parsing binary files before extension filt...

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: [Bug] UnicodeDecodeError in gitea_provider.py when parsing binary files before extension filtering
- User impact: Developers may misconfigure credentials, environment, or host setup: [Bug] UnicodeDecodeError in gitea_provider.py when parsing binary files before extension filtering
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: [Bug] UnicodeDecodeError in gitea_provider.py when parsing binary files before extension filtering. Context: Observed when using docker
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_e66caf8bd4ddcbc747835f854317ef45 | https://github.com/The-PR-Agent/pr-agent/issues/2380 | [Bug] UnicodeDecodeError in gitea_provider.py when parsing binary files before extension filtering

## 22. configuration · 失败模式：configuration: [Bug] `temperature` parameter sent to claude-opus-4-7 causes 400 from Anthropic

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: [Bug] `temperature` parameter sent to claude-opus-4-7 causes 400 from Anthropic
- User impact: Developers may misconfigure credentials, environment, or host setup: [Bug] `temperature` parameter sent to claude-opus-4-7 causes 400 from Anthropic
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: [Bug] `temperature` parameter sent to claude-opus-4-7 causes 400 from Anthropic. Context: Observed when using python, docker
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_48f61c9074aaf84acadaada17c3514fa | https://github.com/The-PR-Agent/pr-agent/issues/2400 | [Bug] `temperature` parameter sent to claude-opus-4-7 causes 400 from Anthropic

## 23. configuration · 失败模式：configuration: v0.33

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: v0.33
- User impact: Upgrade or migration may change expected behavior: v0.33
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: v0.33. Context: Source discussion did not expose a precise runtime context.
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_release | fmev_3a2819a8993abeddf308dd2a4c20c5d1 | https://github.com/The-PR-Agent/pr-agent/releases/tag/v0.33 | v0.33

## 24. configuration · 失败模式：configuration: v0.34

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this configuration risk before relying on the project: v0.34
- User impact: Upgrade or migration may change expected behavior: v0.34
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: v0.34. Context: Source discussion did not expose a precise runtime context.
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_release | fmev_57bd9625e730f20342967abef2739c49 | https://github.com/The-PR-Agent/pr-agent/releases/tag/v0.34 | v0.34

## 25. configuration · 来源证据：AzureDevopsProvider.get_repo_settings drops chunks after the first, silently truncating .pr_agent.toml

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个配置相关的待验证问题：AzureDevopsProvider.get_repo_settings drops chunks after the first, silently truncating .pr_agent.toml
- User impact: 可能增加新用户试用和生产接入成本。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_4ee2a84ba307469b9b329a043a70a224 | https://github.com/The-PR-Agent/pr-agent/issues/2376 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 26. configuration · 来源证据：Ticket context not scoped per PR in long-lived deployments — stale tickets leak between unrelated PRs

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个配置相关的待验证问题：Ticket context not scoped per PR in long-lived deployments — stale tickets leak between unrelated PRs
- User impact: 可能增加新用户试用和生产接入成本。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_a9b90b0cfbbf4529b60d65f564f4592e | https://github.com/The-PR-Agent/pr-agent/issues/2383 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 27. capability · 能力判断依赖假设

- Severity: medium
- Evidence strength: source_linked
- Finding: README/documentation is current enough for a first validation pass.
- User impact: 假设不成立时，用户拿不到承诺的能力。
- Suggested check: 将假设转成下游验证清单。
- Guardrail action: 假设必须转成验证项；没有验证结果前不能写成事实。
- Evidence: capability.assumptions | github_repo:662766482 | https://github.com/The-PR-Agent/pr-agent | README/documentation is current enough for a first validation pass.

## 28. runtime · 失败模式：runtime: Publish linux/arm64 Docker image for github_app tag

- Severity: medium
- Evidence strength: source_linked
- Finding: Developers should check this runtime risk before relying on the project: Publish linux/arm64 Docker image for github_app tag
- User impact: Developers may hit a documented source-backed failure mode: Publish linux/arm64 Docker image for github_app tag
- Suggested check: Before packaging this project, run the relevant install/config/quickstart check for: Publish linux/arm64 Docker image for github_app tag. Context: Observed when using python, docker, linux
- Guardrail action: State this as source-backed community evidence, not as Doramagic reproduction.
- Evidence: failure_mode_cluster:github_issue | fmev_0fdc283afd24a3b8b85d15520113c789 | https://github.com/The-PR-Agent/pr-agent/issues/2386 | Publish linux/arm64 Docker image for github_app tag, failure_mode_cluster:github_issue | fmev_5d0d8e693d605019991cbe932edb560a | https://github.com/The-PR-Agent/pr-agent/issues/2386 | Publish linux/arm64 Docker image for github_app tag

## 29. maintenance · 维护活跃度未知

- Severity: medium
- Evidence strength: source_linked
- Finding: 未记录 last_activity_observed。
- User impact: 新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- Suggested check: 补 GitHub 最近 commit、release、issue/PR 响应信号。
- Guardrail action: 维护活跃度未知时，推荐强度不能标为高信任。
- Evidence: evidence.maintainer_signals | github_repo:662766482 | https://github.com/The-PR-Agent/pr-agent | last_activity_observed missing

## 30. security_permissions · 下游验证发现风险项

- Severity: medium
- Evidence strength: source_linked
- Finding: no_demo
- User impact: 下游已经要求复核，不能在页面中弱化。
- Suggested check: 进入安全/权限治理复核队列。
- Guardrail action: 下游风险存在时必须保持 review/recommendation 降级。
- Evidence: downstream_validation.risk_items | github_repo:662766482 | https://github.com/The-PR-Agent/pr-agent | no_demo; severity=medium

## 31. security_permissions · 存在评分风险

- Severity: medium
- Evidence strength: source_linked
- Finding: no_demo
- User impact: 风险会影响是否适合普通用户安装。
- Suggested check: 把风险写入边界卡，并确认是否需要人工复核。
- Guardrail action: 评分风险必须进入边界卡，不能只作为内部分数。
- Evidence: risks.scoring_risks | github_repo:662766482 | https://github.com/The-PR-Agent/pr-agent | no_demo; severity=medium

## 32. security_permissions · 来源证据：/improve on GitLab duplicates the persistent suggestions thread on every push once the previous one has any reply

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：/improve on GitLab duplicates the persistent suggestions thread on every push once the previous one has any reply
- User impact: 可能影响授权、密钥配置或安全边界。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_8bf58f5468884b5eab533349076803f3 | https://github.com/The-PR-Agent/pr-agent/issues/2402 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 33. security_permissions · 来源证据：Bug + feature: `-i` (incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Bug + feature: `-i` (incremental review) crashes on Azure DevOps; needs full incremental support in AzureDevopsProvider
- User impact: 可能阻塞安装或首次运行。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_e65762126ba84855a8440bd9e5a685bb | https://github.com/The-PR-Agent/pr-agent/issues/2379 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 34. security_permissions · 来源证据：OSS build silently ignores best_practices.md (currently SaaS-only)

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：OSS build silently ignores best_practices.md (currently SaaS-only)
- User impact: 可能影响授权、密钥配置或安全边界。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_f51f28cf40b14b7ca80598af4527661a | https://github.com/The-PR-Agent/pr-agent/issues/2377 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 35. security_permissions · 来源证据：feat: support agent skills for context-aware review guidance

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：feat: support agent skills for context-aware review guidance
- User impact: 可能影响授权、密钥配置或安全边界。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_59ad4ca55ca248f989c91ce40068cc6d | https://github.com/The-PR-Agent/pr-agent/issues/2384 | 来源类型 github_issue 暴露的待验证使用条件。

## 36. security_permissions · 来源证据：litellm success/cost callbacks never fire from pr-agent's async run loop

- Severity: medium
- Evidence strength: source_linked
- Finding: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：litellm success/cost callbacks never fire from pr-agent's async run loop
- User impact: 可能影响授权、密钥配置或安全边界。
- Suggested check: 来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- Guardrail action: 不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- Evidence: community_evidence:github | cevd_42f0b36e0c434c939c49c91fc7ccb82a | https://github.com/The-PR-Agent/pr-agent/issues/2378 | 来源讨论提到 python 相关条件，需在安装/试用前复核。

## 37. maintenance · issue/PR 响应质量未知

- Severity: low
- Evidence strength: source_linked
- Finding: issue_or_pr_quality=unknown。
- User impact: 用户无法判断遇到问题后是否有人维护。
- Suggested check: 抽样最近 issue/PR，判断是否长期无人处理。
- Guardrail action: issue/PR 响应未知时，必须提示维护风险。
- Evidence: evidence.maintainer_signals | github_repo:662766482 | https://github.com/The-PR-Agent/pr-agent | issue_or_pr_quality=unknown

## 38. maintenance · 发布节奏不明确

- Severity: low
- Evidence strength: source_linked
- Finding: release_recency=unknown。
- User impact: 安装命令和文档可能落后于代码，用户踩坑概率升高。
- Suggested check: 确认最近 release/tag 和 README 安装命令是否一致。
- Guardrail action: 发布节奏未知或过期时，安装说明必须标注可能漂移。
- Evidence: evidence.maintainer_signals | github_repo:662766482 | https://github.com/The-PR-Agent/pr-agent | release_recency=unknown

<!-- canonical_name: The-PR-Agent/pr-agent; human_manual_source: deepwiki_human_wiki -->
