Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
286 changes: 286 additions & 0 deletions README_LLM_ENHANCEMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
# πŸ€– LLM-Enhanced PR Analysis

## 🎯 LLM-Enhanced Analysis Made Standard!

We've successfully implemented LLM-enhanced analysis as the standard approach for all PR evaluations, providing intelligent insights for every code change.

## πŸ“Š Intelligence Levels

### 🧠 Smart Mode (Default)
- **LLM-enhanced breaking change detection**
- **Intelligent coordination recommendations**
- **Seconds execution, minimal token usage**
- **Perfect for**: Complex PRs, coordination-sensitive changes

```python
git_analyzer(
base_branch="main",
feature_branch="feature/subfeatureB",
compare_branches=["feature/subfeatureA", "mobile/F1"],
intelligence_level="smart" # Default
)
```

### πŸ§ͺ Deep Mode
- **Comprehensive LLM analysis with business impact**
- **Coordination planning and stakeholder mapping**
- **Minutes execution, higher token usage**
- **Perfect for**: Critical releases, major architectural changes

```python
git_analyzer(
base_branch="main",
feature_branch="feature/subfeatureB",
compare_branches=["feature/subfeatureA", "mobile/F1"],
intelligence_level="deep"
)
```

## 🎣 What LLM Enhancement Adds

### πŸ“ˆ git_analyzer Enhancements:

#### Smart Mode:
- **πŸ” Breaking Change Detection**:
```json
{
"breaking_changes": [
{
"file": "src/api/auth.py",
"description": "Function signature changed from login(email, password) to login(credentials)",
"severity": "high"
}
]
}
```

- **🀝 Coordination Requirements**:
```json
{
"coordination_required": [
{
"team": "mobile",
"reason": "API endpoint changed, mobile app needs update",
"priority": "high"
}
]
}
```

#### Deep Mode adds:
- **🏒 Business Impact Assessment**:
```json
{
"business_risk": "medium",
"customer_impact": {
"areas": ["login flow", "authentication"],
"severity": "medium"
},
"compliance_risk": {
"level": "low",
"areas": []
}
}
```

- **πŸ“‹ Coordination Planning**:
```json
{
"coordination_required": [...],
"testing_strategy": {
"parallel_testing": ["mobile", "frontend"],
"integration_checkpoints": ["API contracts", "user flows"]
},
"communication_plan": {
"pre_merge": ["Notify teams of API changes"],
"post_merge": ["Update documentation"]
}
}
```

### πŸ›‘οΈ pr_manager Enhancements:

#### Smart Mode:
- **πŸ“ Commit Message Quality Analysis**:
```json
{
"overall_quality": "good",
"score": 7.5,
"issues": ["Some commits lack technical context"],
"recommendations": ["Add more specific technical details"]
}
```

#### Deep Mode adds:
- **🏒 Business Context Integration**
- **🀝 Stakeholder Impact Mapping**
- **πŸ“‹ Rollback Strategy Generation**

## πŸš€ Usage Examples

### Demo Script:
```bash
# LLM-enhanced analysis (default)
python examples/pr_analysis_demo.py

# Interactive mode (choose your level)
python examples/pr_analysis_demo.py interactive
```

### Interactive Mode Example:
```
Enter repository path (default: .): .
Enter source/feature branch: feature/subfeatureB
Enter target branch: main
Enter context branches: feature/subfeatureA,mobile/F1
Safety level (strict/moderate/permissive, default: moderate): moderate
Use LLM enhancement? (y/N, default: N): y

πŸ” Analyzing feature/subfeatureB β†’ main...
🧠 Intelligence level: smart
Context branches: feature/subfeatureA,mobile/F1
```

### CLI Usage:
```python
# Fast analysis
git_analyzer(
base_branch="main",
feature_branch="feature/subfeatureB",
compare_branches=["feature/subfeatureA", "mobile/F1"]
)

# Smart analysis with specific model
git_analyzer(
base_branch="main",
feature_branch="feature/subfeatureB",
compare_branches=["feature/subfeatureA", "mobile/F1"],
intelligence_level="smart",
llm_model="gpt-4"
)

# Deep PR validation
pr_manager(
action="analyze",
source_branch="feature/subfeatureB",
target_branch="main",
context_branches=["feature/subfeatureA", "mobile/F1"],
intelligence_level="deep",
safety_level="strict"
)
```

## πŸ“Š Enhanced Output Examples

### Smart Mode Output:
```
🎯 BRANCH IMPACTS:
main: 🟑 MEDIUM
Files affected: 8
Lines modified: 156
Areas impacted: Core code, API

πŸ€– LLM-ENHANCED ANALYSIS:
Intelligence level: smart
Model used: gpt-4

🚨 BREAKING CHANGES DETECTED:
πŸ”΄ src/api/auth.py: Function signature changed from login(email, password) to login(credentials)
🟑 src/utils/validation.py: Removed backward compatibility helper

πŸ’‘ RECOMMENDATIONS:
🚨 Breaking change detected in src/api/auth.py: Function signature changed from login(email, password) to login(credentials)
🀝 Coordinate with mobile: API endpoint changed, mobile app needs update
```

### Deep Mode Output:
```
πŸ€– LLM-ENHANCED PR ANALYSIS:
Intelligence level: deep
Model used: gpt-4

πŸ“ Commit quality: βœ… Good (Score: 7.5/10)

🏒 Business risk: 🟑 MEDIUM

🧠 Enhanced insights:
🚨 High business impact detected - ensure stakeholder approval before merge
πŸ“‹ Compliance considerations: authentication methods
🀝 Coordinate with mobile team before merge
🀝 Coordinate with frontend team before merge
```

## ⚑ Performance & Cost Trade-offs

| Feature | Smart (Default) | Deep |
|---------|-----------------|------|
| **Speed** | πŸ–₯️ 5-15 seconds | 🧠 1-3 minutes |
| **Cost** | πŸͺ™ Few cents | πŸ’΅ 10-50 cents |
| **Intelligence** | 🧠 Context-aware | 🏒 Deep understanding |
| **Best For** | Complex PRs | Major releases |

## πŸ”§ Configuration

### Using Different LLM Models:
```python
# Use specific model for analysis
git_analyzer(
base_branch="main",
feature_branch="feature/subfeatureB",
intelligence_level="smart",
llm_model="claude-3-opus" # Override default model
)
```

### Model Recommendation by Use Case:
- **Quick coordination**: `gpt-3.5-turbo` (fast, cheap)
- **Standard analysis**: `gpt-4` (balanced)
- **Deep business impact**: `claude-3-opus` (thorough)

## 🎯 Real-World Impact

### Before LLM Enhancement:
```
πŸ“Š Files changed: 12
⚠️ Potential collision: feature/subfeatureA
πŸ’‘ Consider coordinating with teams
```

### After LLM Enhancement (Smart Mode):
```
πŸ“Š Files changed: 12
πŸ€– LLM-ENHANCED ANALYSIS:
🚨 BREAKING CHANGES DETECTED:
πŸ”΄ src/api/auth.py: login() function signature API breaking
🟑 config/database.py: Connection pool configuration changed

🀝 COORDINATION REQUIRED:
🚨 Mobile team: API contract changed (URGENT)
⚑ DevOps team: Database configuration updated

πŸ’‘ RECOMMENDATIONS:
🚨 Breaking change detected in src/api/auth.py: login() function signature API breaking
🀝 Coordinate with mobile: API contract changed (URGENT)
🀝 Coordinate with devops: Database configuration updated
```

### Deep Mode adds business context:
```
🏒 Business risk: 🟑 MEDIUM - Authentication system changes
πŸ“‹ Compliance: Payment processing affected
🀝 Stakeholder notifications: Product team, Support team
πŸ“‹ Rollback plan: Database migration rollback procedure documented
```

## πŸŽ‰ Standard Intelligence Success!

βœ… **Built-in intelligence** - All PR evaluations include LLM analysis
βœ… **Configurable depth** - Choose between smart and deep analysis
βœ… **Real business value** - Understand impact beyond code changes
βœ… **Team coordination** - Automatic identification of affected teams

Your friend now has a comprehensive system:
- **All situations**: Intelligent LLM-enhanced insights
- **Critical changes**: Deep business impact understanding

**Powerful PR management with built-in intelligence!** πŸ€–πŸ“Žβœ¨
Loading
Loading