style: format all files with prettier

This commit is contained in:
Seth Hobson
2026-01-19 17:07:03 -05:00
parent 8d37048deb
commit 56848874a2
355 changed files with 15215 additions and 10241 deletions

View File

@@ -15,13 +15,16 @@ Perform comprehensive analysis: security, performance, architecture, maintainabi
## Automated Code Review Workflow
### Initial Triage
1. Parse diff to determine modified files and affected components
2. Match file types to optimal static analysis tools
3. Scale analysis based on PR size (superficial >1000 lines, deep <200 lines)
4. Classify change type: feature, bug fix, refactoring, or breaking change
### Multi-Tool Static Analysis
Execute in parallel:
- **CodeQL**: Deep vulnerability analysis (SQL injection, XSS, auth bypasses)
- **SonarQube**: Code smells, complexity, duplication, maintainability
- **Semgrep**: Organization-specific rules and security policies
@@ -29,6 +32,7 @@ Execute in parallel:
- **GitGuardian/TruffleHog**: Secret detection
### AI-Assisted Review
```python
# Context-aware review prompt for Claude 4.5 Sonnet
review_prompt = f"""
@@ -59,12 +63,14 @@ Format as JSON array.
```
### Model Selection (2025)
- **Fast reviews (<200 lines)**: GPT-4o-mini or Claude 4.5 Haiku
- **Deep reasoning**: Claude 4.5 Sonnet or GPT-4.5 (200K+ tokens)
- **Code generation**: GitHub Copilot or Qodo
- **Multi-language**: Qodo or CodeAnt AI (30+ languages)
### Review Routing
```typescript
interface ReviewRoutingStrategy {
async routeReview(pr: PullRequest): Promise<ReviewEngine> {
@@ -94,6 +100,7 @@ interface ReviewRoutingStrategy {
## Architecture Analysis
### Architectural Coherence
1. **Dependency Direction**: Inner layers don't depend on outer layers
2. **SOLID Principles**:
- Single Responsibility, Open/Closed, Liskov Substitution
@@ -103,6 +110,7 @@ interface ReviewRoutingStrategy {
- Anemic models, Shotgun surgery
### Microservices Review
```go
type MicroserviceReviewChecklist struct {
CheckServiceCohesion bool // Single capability per service?
@@ -141,9 +149,11 @@ func (r *MicroserviceReviewer) AnalyzeServiceBoundaries(code string) []Issue {
## Security Vulnerability Detection
### Multi-Layered Security
**SAST Layer**: CodeQL, Semgrep, Bandit/Brakeman/Gosec
**AI-Enhanced Threat Modeling**:
```python
security_analysis_prompt = """
Analyze authentication code for vulnerabilities:
@@ -163,6 +173,7 @@ findings = claude.analyze(security_analysis_prompt, temperature=0.1)
```
**Secret Scanning**:
```bash
trufflehog git file://. --json | \
jq '.[] | select(.Verified == true) | {
@@ -173,6 +184,7 @@ trufflehog git file://. --json | \
```
### OWASP Top 10 (2025)
1. **A01 - Broken Access Control**: Missing authorization, IDOR
2. **A02 - Cryptographic Failures**: Weak hashing, insecure RNG
3. **A03 - Injection**: SQL, NoSQL, command injection via taint analysis
@@ -187,22 +199,25 @@ trufflehog git file://. --json | \
## Performance Review
### Performance Profiling
```javascript
class PerformanceReviewAgent {
async analyzePRPerformance(prNumber) {
const baseline = await this.loadBaselineMetrics('main');
const baseline = await this.loadBaselineMetrics("main");
const prBranch = await this.runBenchmarks(`pr-${prNumber}`);
const regressions = this.detectRegressions(baseline, prBranch, {
cpuThreshold: 10, memoryThreshold: 15, latencyThreshold: 20
cpuThreshold: 10,
memoryThreshold: 15,
latencyThreshold: 20,
});
if (regressions.length > 0) {
await this.postReviewComment(prNumber, {
severity: 'HIGH',
title: '⚠️ Performance Regression Detected',
severity: "HIGH",
title: "⚠️ Performance Regression Detected",
body: this.formatRegressionReport(regressions),
suggestions: await this.aiGenerateOptimizations(regressions)
suggestions: await this.aiGenerateOptimizations(regressions),
});
}
}
@@ -210,6 +225,7 @@ class PerformanceReviewAgent {
```
### Scalability Red Flags
- **N+1 Queries**, **Missing Indexes**, **Synchronous External Calls**
- **In-Memory State**, **Unbounded Collections**, **Missing Pagination**
- **No Connection Pooling**, **No Rate Limiting**
@@ -232,20 +248,28 @@ def detect_n_plus_1_queries(code_ast):
## Review Comment Generation
### Structured Format
```typescript
interface ReviewComment {
path: string; line: number;
severity: 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW' | 'INFO';
category: 'Security' | 'Performance' | 'Bug' | 'Maintainability';
title: string; description: string;
codeExample?: string; references?: string[];
autoFixable: boolean; cwe?: string; cvss?: number;
effort: 'trivial' | 'easy' | 'medium' | 'hard';
path: string;
line: number;
severity: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | "INFO";
category: "Security" | "Performance" | "Bug" | "Maintainability";
title: string;
description: string;
codeExample?: string;
references?: string[];
autoFixable: boolean;
cwe?: string;
cvss?: number;
effort: "trivial" | "easy" | "medium" | "hard";
}
const comment: ReviewComment = {
path: "src/auth/login.ts", line: 42,
severity: "CRITICAL", category: "Security",
path: "src/auth/login.ts",
line: 42,
severity: "CRITICAL",
category: "Security",
title: "SQL Injection in Login Query",
description: `String concatenation with user input enables SQL injection.
**Attack Vector:** Input 'admin' OR '1'='1' bypasses authentication.
@@ -259,13 +283,17 @@ const query = 'SELECT * FROM users WHERE username = ?';
const result = await db.execute(query, [username]);
`,
references: ["https://cwe.mitre.org/data/definitions/89.html"],
autoFixable: false, cwe: "CWE-89", cvss: 9.8, effort: "easy"
autoFixable: false,
cwe: "CWE-89",
cvss: 9.8,
effort: "easy",
};
```
## CI/CD Integration
### GitHub Actions
```yaml
name: AI Code Review
on:
@@ -318,7 +346,7 @@ jobs:
## Complete Example: AI Review Automation
```python
````python
#!/usr/bin/env python3
import os, json, subprocess
from dataclasses import dataclass
@@ -411,11 +439,12 @@ if __name__ == '__main__':
diff = reviewer.get_pr_diff()
ai_issues = reviewer.ai_review(diff, static_results)
reviewer.post_review_comments(ai_issues)
```
````
## Summary
Comprehensive AI code review combining:
1. Multi-tool static analysis (SonarQube, CodeQL, Semgrep)
2. State-of-the-art LLMs (GPT-5, Claude 4.5 Sonnet)
3. Seamless CI/CD integration (GitHub Actions, GitLab, Azure DevOps)

View File

@@ -16,12 +16,14 @@ The Multi-Agent Review Tool leverages a distributed, specialized agent network t
## Tool Arguments and Configuration
### Input Parameters
- `$ARGUMENTS`: Target code/project for review
- Supports: File paths, Git repositories, code snippets
- Handles multiple input formats
- Enables context extraction and agent routing
### Agent Types
1. Code Quality Reviewers
2. Security Auditors
3. Architecture Specialists
@@ -32,6 +34,7 @@ The Multi-Agent Review Tool leverages a distributed, specialized agent network t
## Multi-Agent Coordination Strategy
### 1. Agent Selection and Routing Logic
- **Dynamic Agent Matching**:
- Analyze input characteristics
- Select most appropriate agent types
@@ -51,11 +54,13 @@ The Multi-Agent Review Tool leverages a distributed, specialized agent network t
```
### 2. Context Management and State Passing
- **Contextual Intelligence**:
- Maintain shared context across agent interactions
- Pass refined insights between agents
- Support incremental review refinement
- **Context Propagation Model**:
```python
class ReviewContext:
def __init__(self, target, metadata):
@@ -68,11 +73,13 @@ The Multi-Agent Review Tool leverages a distributed, specialized agent network t
```
### 3. Parallel vs Sequential Execution
- **Hybrid Execution Strategy**:
- Parallel execution for independent reviews
- Sequential processing for dependent insights
- Intelligent timeout and fallback mechanisms
- **Execution Flow**:
```python
def execute_review(review_context):
# Parallel independent agents
@@ -89,6 +96,7 @@ The Multi-Agent Review Tool leverages a distributed, specialized agent network t
```
### 4. Result Aggregation and Synthesis
- **Intelligent Consolidation**:
- Merge insights from multiple agents
- Resolve conflicting recommendations
@@ -106,6 +114,7 @@ The Multi-Agent Review Tool leverages a distributed, specialized agent network t
```
### 5. Conflict Resolution Mechanism
- **Smart Conflict Handling**:
- Detect contradictory agent recommendations
- Apply weighted scoring
@@ -118,6 +127,7 @@ The Multi-Agent Review Tool leverages a distributed, specialized agent network t
```
### 6. Performance Optimization
- **Efficiency Techniques**:
- Minimal redundant processing
- Cached intermediate results
@@ -129,6 +139,7 @@ The Multi-Agent Review Tool leverages a distributed, specialized agent network t
```
### 7. Quality Validation Framework
- **Comprehensive Validation**:
- Cross-agent result verification
- Statistical confidence scoring
@@ -143,6 +154,7 @@ The Multi-Agent Review Tool leverages a distributed, specialized agent network t
## Example Implementations
### 1. Parallel Code Review Scenario
```python
multi_agent_review(
target="/path/to/project",
@@ -155,6 +167,7 @@ multi_agent_review(
```
### 2. Sequential Workflow
```python
sequential_review_workflow = [
{"phase": "design-review", "agent": "architect-reviewer"},
@@ -165,6 +178,7 @@ sequential_review_workflow = [
```
### 3. Hybrid Orchestration
```python
hybrid_review_strategy = {
"parallel_agents": ["security", "performance"],
@@ -191,4 +205,4 @@ The tool is designed with a plugin-based architecture, allowing easy addition of
## Invocation
Target for review: $ARGUMENTS
Target for review: $ARGUMENTS