# miyabi-agent-workflow
**GitHub workflow automation agents: PR creation, Issue analysis, and Deployment for the Miyabi framework.**
[](https://crates.io/crates/miyabi-agent-workflow)
[](https://docs.rs/miyabi-agent-workflow)
[](../../LICENSE)
## π Overview
`miyabi-agent-workflow` provides three specialized agents for automating GitHub-based development workflows:
- **PRAgent** (γΎγ¨γγγ): Automatic Pull Request creation with Conventional Commits
- **IssueAgent** (γΏγ€γγγ): Issue analysis, classification, and label inference
- **DeploymentAgent** (γ―γγΆγ): CI/CD automation with build, test, deploy, and rollback
**Key Capabilities**:
- π **Conventional Commits**: Auto-generates PR titles following `feat(scope): description` format
- π·οΈ **Smart Labeling**: Infers appropriate labels from Miyabi's 57-label system
- π€ **Agent Assignment**: Automatically assigns tasks to the right agent (Coordinator, CodeGen, etc.)
- π **CI/CD Pipeline**: End-to-end deployment from build to health check
- π **Auto-Rollback**: Automatic rollback on deployment failure
- π **Impact Assessment**: Evaluates issue severity and business impact
## π Features
### PRAgent (γΎγ¨γγγ)
- **Conventional Commits Compliance**: Generates `feat`, `fix`, `refactor`, `docs`, `test`, `ci` prefixes
- **Scope Detection**: Extracts scope from title (e.g., "Auth: login bug" β `fix(auth): login bug`)
- **PR Body Generation**: Includes overview, changes, test results, checklist, and related issues
- **Label Assignment**: Automatically applies labels based on task type and priority
- **Reviewer Assignment**: Assigns appropriate reviewers based on code owners
### IssueAgent (γΏγ€γγγ)
- **Type Inference**: Detects Feature, Bug, Refactor, Docs, Test, or Deployment
- **Severity Assessment**: Evaluates Critical, High, Medium, or Low severity
- **Impact Evaluation**: Determines System, User, or Cosmetic impact level
- **Agent Routing**: Assigns to Coordinator, CodeGen, Review, PR, or Deployment agents
- **Duration Estimation**: Predicts task completion time (e.g., Feature: 60 min, Bug: 30 min)
- **Dependency Extraction**: Parses dependencies from issue body (e.g., `Depends on #123`)
- **Label Generation**: Selects from 57-label system across 11 categories
### DeploymentAgent (γ―γγΆγ)
- **Build Execution**: Runs `cargo build --release` with error handling
- **Test Execution**: Runs `cargo test --all` with pass/fail tracking
- **Environment Support**: Staging (auto-deploy) and Production (approval-required)
- **Health Checks**: Validates deployment success with HTTP health checks
- **Auto-Rollback**: Reverts to previous version on failure
- **Deployment Status**: Tracks Pending β Building β Testing β Deploying β HealthChecking β Success
## π¦ Installation
Add to your `Cargo.toml`:
```toml
[dependencies]
miyabi-agent-workflow = "0.1.0"
```
Or install the CLI:
```bash
cargo install miyabi-cli
```
## π§ Usage
### PRAgent Example
```rust
use miyabi_agent_workflow::PRAgent;
use miyabi_agent_core::BaseAgent;
use miyabi_types::{AgentConfig, Task, TaskType};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = AgentConfig {
github_token: std::env::var("GITHUB_TOKEN")?,
repo_owner: Some("your-org".to_string()),
repo_name: Some("your-repo".to_string()),
..Default::default()
};
let pr_agent = PRAgent::new(config);
let task = Task {
id: "task-001".to_string(),
title: "Auth: Add Google OAuth support".to_string(),
description: "Implement Google OAuth 2.0 authentication".to_string(),
task_type: TaskType::Feature,
..Default::default()
};
// Generates PR:
// Title: feat(auth): Add Google OAuth support
// Body: Overview, changes, checklist
// Labels: β¨ type:feature, ποΈ state:implementing
let result = pr_agent.execute(&task).await?;
println!("PR created: {:?}", result.data);
Ok(())
}
```
### IssueAgent Example
```rust
use miyabi_agent_workflow::IssueAgent;
use miyabi_types::{AgentConfig, Issue};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = AgentConfig::default();
let issue_agent = IssueAgent::new(config);
let issue = Issue {
number: 42,
title: "Critical: Database connection timeout".to_string(),
body: "Users cannot login. Database times out after 5s.".to_string(),
labels: vec!["bug".to_string()],
..Default::default()
};
let analysis = issue_agent.analyze_issue(&issue)?;
// Output:
// Type: Bug
// Severity: Critical
// Impact: System
// Agent: CodeGenAgent
// Duration: 30 minutes
// Labels: ["π type:bug", "π₯ priority:P0-Critical", "π€ agent:codegen"]
println!("Analysis: {:?}", analysis);
Ok(())
}
```
### DeploymentAgent Example
```rust
use miyabi_agent_workflow::{DeploymentAgent, Environment};
use miyabi_agent_core::BaseAgent;
use miyabi_types::{AgentConfig, Task, TaskType};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = AgentConfig {
firebase_staging_project: Some("miyabi-staging".to_string()),
staging_url: Some("https://staging.miyabi.dev".to_string()),
..Default::default()
};
let deploy_agent = DeploymentAgent::new(config);
let task = Task {
id: "deploy-001".to_string(),
title: "Deploy to staging".to_string(),
task_type: TaskType::Deployment,
..Default::default()
};
// Executes:
// 1. cargo build --release
// 2. cargo test --all
// 3. Deploy to staging
// 4. Health check (https://staging.miyabi.dev/health)
// 5. Rollback if health check fails
let result = deploy_agent.execute(&task).await?;
println!("Deployment: {:?}", result.status);
Ok(())
}
```
## π Label System Integration
IssueAgent integrates with Miyabi's **57-label system** across 11 categories:
| **Type** | 7 | `β¨ type:feature`, `π type:bug`, `β»οΈ type:refactor` |
| **Priority** | 5 | `π₯ priority:P0-Critical`, `β οΈ priority:P1-High` |
| **State** | 8 | `π₯ state:pending`, `ποΈ state:implementing`, `β
state:done` |
| **Agent** | 7 | `π€ agent:coordinator`, `π€ agent:codegen`, `π€ agent:review` |
| **Phase** | 6 | `π― phase:planning`, `ποΈ phase:implementation` |
| **Size** | 5 | `π size:XS`, `π size:S`, `π size:M`, `π size:L`, `π size:XL` |
| **Impact** | 3 | `π₯ impact:system`, `π€ impact:user`, `π¨ impact:cosmetic` |
| **Severity** | 4 | `π₯ severity:critical`, `β οΈ severity:high` |
| **Technical** | 7 | `π§ tech:api`, `ποΈ tech:db`, `π¨ tech:ui` |
| **Business** | 3 | `πΌ biz:marketing`, `π° biz:sales`, `π biz:analytics` |
| **Meta** | 2 | `π·οΈ good first issue`, `π help wanted` |
See [LABEL_SYSTEM_GUIDE.md](../../docs/LABEL_SYSTEM_GUIDE.md) for full documentation.
## π Deployment Workflow
```
βββββββββββββββββββββββ
β cargo build β β BuildResult
βββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β cargo test β β TestResult
βββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β Deploy (Staging) β β Automatic
βββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β Health Check β β GET /health
βββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β Success / Rollback β
βββββββββββββββββββββββ
```
## ποΈ Architecture
### PRAgent
```
PRAgent::execute(task)
βββ generate_pr_title() β feat(scope): description
βββ generate_pr_body() β Markdown body
βββ infer_labels() β [type:feature, state:implementing]
βββ create_pull_request() β GitHub PR
```
### IssueAgent
```
IssueAgent::analyze_issue(issue)
βββ infer_issue_type() β Feature/Bug/Refactor...
βββ assess_severity() β Critical/High/Medium/Low
βββ evaluate_impact() β System/User/Cosmetic
βββ determine_agent() β CodeGenAgent/ReviewAgent...
βββ estimate_duration() β 30-120 minutes
βββ extract_dependencies() β [#123, #456]
βββ generate_labels() β [57-label system]
```
### DeploymentAgent
```
DeploymentAgent::deploy(task)
βββ execute_build() β cargo build --release
βββ execute_tests() β cargo test --all
βββ deploy_to_environment() β Staging/Production
βββ run_health_check() β GET /health (3 retries)
βββ rollback_if_failed() β git revert + redeploy
```
## π Dependencies
- **Core**: `miyabi-agent-core`, `miyabi-types`, `miyabi-core`, `miyabi-github`
- **Runtime**: `tokio`, `async-trait`
- **GitHub**: `octocrab`, `reqwest`
- **Serialization**: `serde`, `serde_json`
- **Utilities**: `chrono`, `regex`, `thiserror`, `tracing`
## π§ͺ Testing
```bash
# Run all tests
cargo test --package miyabi-agent-workflow
# Test specific agent
cargo test --package miyabi-agent-workflow pr_agent
cargo test --package miyabi-agent-workflow issue_agent
cargo test --package miyabi-agent-workflow deployment_agent
# Integration tests (requires GitHub token)
GITHUB_TOKEN=ghp_xxx cargo test --package miyabi-agent-workflow --test integration
```
## π Related Crates
- [`miyabi-agent-coordinator`](../miyabi-agent-coordinator) - Task orchestration and DAG planning
- [`miyabi-agent-codegen`](../miyabi-agent-codegen) - AI-powered code generation
- [`miyabi-agent-review`](../miyabi-agent-review) - Code quality review and scoring
- [`miyabi-github`](../miyabi-github) - GitHub API client wrapper
- [`miyabi-types`](../miyabi-types) - Shared type definitions
## π€ Contributing
Contributions are welcome! Please see [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines.
## π License
Licensed under the MIT License. See [LICENSE](../../LICENSE) for details.
## π Version History
- **v0.1.0** (2025-10-25): Initial release
- PRAgent with Conventional Commits support
- IssueAgent with 57-label system integration
- DeploymentAgent with build/test/deploy/rollback workflow
- Automatic agent routing and label inference
---
**Part of the [Miyabi Framework](../../README.md)** - Autonomous AI Development Platform