1 unstable release
| 0.1.2 | Nov 22, 2025 |
|---|
#1814 in Web programming
Used in 6 crates
(4 directly)
735KB
16K
SLoC
miyabi-agent-review
Code review, quality scoring (100-point scale), and security scanning agent for the Miyabi framework.
π Overview
miyabi-agent-review (ιη§°: γγ γΎγ) is an automated code review agent that performs comprehensive quality analysis on Rust codebases. It integrates cargo clippy, cargo check, cargo-audit, and test coverage tools to generate detailed quality reports with actionable recommendations.
Key Capabilities:
- π Linting Analysis: Runs
cargo clippyand scores based on warnings - π οΈ Type Checking: Runs
cargo checkand detects compilation errors - π Security Scanning: Uses
cargo-auditto detect known vulnerabilities - π Coverage Analysis: Calculates test coverage (integrates with
cargo-tarpaulin) - π 100-Point Scoring: Generates overall quality score with detailed breakdown
- β οΈ Escalation: Automatically escalates to Tech Lead if score < 60
π Features
- Automated Quality Scoring: 100-point scale based on:
- Clippy warnings (100 - warnings Γ 5)
- Type errors (100 - errors Γ 10)
- Security vulnerabilities (dynamic scoring based on severity)
- Test coverage (target: 80%+)
- Detailed Issue Reporting: File, line, severity, and message for each issue
- Recommendations: Actionable suggestions to improve code quality
- Escalation Logic: Automatically escalates low-quality code (< 60 score) to human reviewers
- JSON Output: Structured quality reports for CI/CD integration
π¦ Installation
Add to your Cargo.toml:
[dependencies]
miyabi-agent-review = "0.1.0"
Or install the CLI:
cargo install miyabi-cli
π§ Usage
As a Library
use miyabi_agent_review::ReviewAgent;
use miyabi_agent_core::BaseAgent;
use miyabi_types::{AgentConfig, Task, TaskType};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure agent
let config = AgentConfig {
device_identifier: "macbook-pro".to_string(),
github_token: std::env::var("GITHUB_TOKEN")?,
repo_owner: Some("your-org".to_string()),
repo_name: Some("your-repo".to_string()),
..Default::default()
};
// Create agent
let reviewer = ReviewAgent::new(config);
// Create task
let task = Task {
id: "task-001".to_string(),
title: "Review PR #123".to_string(),
description: "Review code quality for feature implementation".to_string(),
task_type: TaskType::Feature,
..Default::default()
};
// Execute review
let result = reviewer.execute(&task).await?;
// Check quality score
if let Some(metrics) = result.metrics {
if let Some(score) = metrics.quality_score {
println!("Quality Score: {}/100", score);
if score >= 80 {
println!("β
Code approved for merge!");
} else {
println!("β Code needs improvement");
}
}
}
Ok(())
}
As a CLI Tool
# Review current directory
miyabi agent run review --task-id task-001
# Review specific path
cd /path/to/your/project
miyabi agent run review --task-id task-002
# With custom config
miyabi agent run review --task-id task-003 --config config.toml
π Quality Report Structure
{
"score": 87,
"passed": true,
"issues": [
{
"issue_type": "Eslint",
"severity": "Medium",
"message": "unused variable `foo`",
"file": "src/main.rs",
"line": 42,
"score_impact": 5
}
],
"recommendations": [
"Fix clippy warnings to improve code quality",
"Increase test coverage to at least 80%"
],
"breakdown": {
"clippy_score": 90,
"rustc_score": 100,
"security_score": 100,
"test_coverage_score": 75
}
}
π Security Scanning
The agent integrates cargo-audit to detect known security vulnerabilities:
# Install cargo-audit (required for security scanning)
cargo install cargo-audit
# Review will automatically run security checks
miyabi agent run review --task-id security-check
Security Scoring:
- 100: No vulnerabilities detected
- 80: Low severity vulnerabilities only
- 60: Medium severity vulnerabilities
- 40: High severity vulnerabilities
- 0: Critical vulnerabilities found
π§ͺ Testing
# Run all tests
cargo test --package miyabi-agent-review
# Run with output
cargo test --package miyabi-agent-review -- --nocapture
# Test specific functionality
cargo test --package miyabi-agent-review test_review_agent_creation
π Scoring Algorithm
Overall Score Calculation
Overall Score = Average(Clippy Score, Rustc Score, Security Score, Coverage Score)
Component Scores
- Clippy Score:
100 - (warnings Γ 5)(minimum: 0) - Rustc Score:
100 - (errors Γ 10)(minimum: 0) - Security Score: Dynamic based on vulnerability severity
- Coverage Score: Based on test coverage percentage (target: 80%+)
Approval Threshold
- β Approved: Score β₯ 80
- β οΈ Needs Work: Score 60-79
- β Escalated: Score < 60 (auto-escalates to Tech Lead)
ποΈ Architecture
ReviewAgent
βββ run_clippy() β ClippyResult
βββ run_rustc_check() β RustcResult
βββ run_security_audit() β SecurityResult
βββ calculate_coverage() β CoverageResult
βββ generate_quality_report() β QualityReport
π Dependencies
- Core:
miyabi-agent-core,miyabi-types,miyabi-core - Runtime:
tokio,async-trait - Serialization:
serde,serde_json - Utilities:
chrono,regex,thiserror,tracing
π Related Crates
miyabi-agent-coordinator- Task orchestration and DAG planningmiyabi-agent-codegen- AI-powered code generationmiyabi-agent-pr- Pull request creation and managementmiyabi-types- Shared type definitionsmiyabi-agent-core- Base agent traits and utilities
π€ Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
π License
Licensed under the MIT License. See LICENSE for details.
π Version History
- v0.1.0 (2025-10-25): Initial release
- Clippy integration
- Rustc type checking
- Security scanning (cargo-audit)
- 100-point quality scoring
- Escalation logic
Part of the Miyabi Framework - Autonomous AI Development Platform
Dependencies
~52β72MB
~1.5M SLoC