miyabi-github
Status: Stable | Category: Integration
GitHub API integration for Miyabi - High-level wrapper around Octocrab providing Issue, PR, Label, and Project management for autonomous development workflows.
๐ Overview
miyabi-github is the GitHub integration layer for the Miyabi autonomous development framework. It provides a unified, type-safe API for all GitHub operations required by Miyabi agents.
Key Capabilities:
- ๐ซ Issue Management: CRUD operations, state filtering, bulk operations
- ๐ท๏ธ Label Management: Full CRUD, bulk sync for 57-label system
- ๐ Pull Request Management: Create, merge, review, close PRs
- ๐ Project Management: GitHub Projects v2 integration, KPI tracking
- ๐ Authentication: Multi-source token discovery (env, gh CLI, config file)
- ๐ฏ State-Based Queries: Filter by Miyabi workflow states (pending, in_progress, review, blocked, completed)
This crate is built on top of Octocrab and extends it with Miyabi-specific functionality.
๐ Features
Issue Management
- CRUD Operations: Create, read, update, close issues
- State Filtering: Query issues by GitHub state (Open/Closed/All)
- Label Filtering: Query issues by single or multiple labels
- Miyabi State Queries: Built-in methods for workflow states
- Bulk Operations: Process multiple issues efficiently
- Comments: Add, update, delete issue comments
- Assignees: Manage issue assignees
Label Management
- Full CRUD: Create, read, update, delete labels
- Bulk Sync: Sync all 57 Miyabi labels from YAML definition
- Color Management: Hex color support (e.g., "ff0000")
- Description Support: Rich label descriptions
- Conflict Resolution: Smart update/create logic
Pull Request Operations
- Create PRs: With title, body, base/head branches, draft mode
- List PRs: Filter by state (Open/Closed/All)
- Merge PRs: Merge strategies (merge, squash, rebase)
- Close PRs: Close without merging
- Review Operations: Request reviews, approve, request changes
- PR Files: Get changed files in a PR
Project Management (GitHub Projects v2)
- Project Items: Add issues/PRs to projects
- Field Updates: Update custom fields (status, priority, etc.)
- KPI Tracking: Query project data for analytics
- Content Types: Support for Issue and PullRequest content types
Authentication
- Multi-Source Discovery: Automatic token discovery from 3 sources:
GITHUB_TOKENenvironment variablegh auth tokencommand (GitHub CLI)~/.config/gh/hosts.ymlfile
- Token Validation: Format validation (ghp_* pattern)
- CLI Status Check: Detect gh CLI installation and auth status
- Helpful Errors: Detailed setup instructions when auth fails
๐ฆ Installation
Add to your Cargo.toml:
[]
= "0.1.0"
= "0.1.0"
Or use cargo add:
๐ง Usage
Authentication Setup
Option 1: Environment Variable (Quick)
# Add to ~/.zshrc or ~/.bashrc for persistence
Option 2: GitHub CLI (Recommended)
# Install gh CLI
# or: https://cli.github.com/
# Authenticate
# Verify
Option 3: Token Discovery (Automatic)
use discover_token;
// Automatically tries all sources
let token = discover_token?;
Basic Usage
use GitHubClient;
use IssueState;
async
Issue Operations
use GitHubClient;
use State;
// Get a single issue
let issue = client.get_issue.await?;
println!;
// List open issues
let open_issues = client.list_issues.await?;
println!;
// List issues with labels
let bugs = client.list_issues.await?;
// Create an issue
let new_issue = client.create_issue.await?;
println!;
// Update an issue
client.update_issue.await?;
// Close an issue
client.close_issue.await?;
// Add labels to an issue
client.add_labels_to_issue.await?;
// Add a comment
client.create_issue_comment.await?;
Miyabi State Queries
use IssueState;
// Get issues by Miyabi workflow state
let pending = client.get_issues_by_state.await?;
let in_progress = client.get_issues_by_state.await?;
let review = client.get_issues_by_state.await?;
let blocked = client.get_issues_by_state.await?;
let completed = client.get_issues_by_state.await?;
println!;
println!;
println!;
println!;
println!;
println!;
Label Management
use Label;
// List all labels
let labels = client.list_labels.await?;
for label in labels
// Get a specific label
let label = client.get_label.await?;
// Create a label
client.create_label.await?;
// Update a label
client.update_label.await?;
// Delete a label
client.delete_label.await?;
// Bulk sync Miyabi's 57-label system
// (Loads from .github/labels.yml)
client.sync_labels.await?;
Pull Request Operations
// Get a PR
let pr = client.get_pull_request.await?;
println!;
// List open PRs
let open_prs = client.list_pull_requests.await?;
// Create a PR
let new_pr = client.create_pull_request.await?;
println!;
// Merge a PR (squash merge)
client.merge_pull_request.await?;
// Close a PR without merging
client.close_pull_request.await?;
Project Management (Projects v2)
use ;
// Add issue to project
let item = client.add_to_project.await?;
// Update project field
client.update_project_item_field.await?;
// Get KPI report
let report = client.get_project_kpi_report.await?;
println!;
println!;
println!;
Advanced: Direct Octocrab Access
For operations not yet wrapped, you can access the underlying Octocrab client:
let octocrab = client.octocrab;
// Use Octocrab directly
let repo = octocrab
.repos
.get
.await?;
๐๏ธ Architecture
miyabi-github
โโโ auth.rs # Multi-source token discovery & validation
โโโ client.rs # GitHubClient wrapper around Octocrab
โโโ issues.rs # Issue CRUD & state queries
โโโ labels.rs # Label management & bulk sync
โโโ projects.rs # GitHub Projects v2 integration
โโโ pull_requests.rs # PR operations & merge strategies
โโโ lib.rs # Public API & re-exports
Dependencies:
โโโ miyabi-types # Issue, Label, PR types
โโโ octocrab # GitHub API client (v0.41)
โโโ tokio # Async runtime
โโโ serde/serde_json # Serialization
โโโ dirs # Config directory discovery
๐งช Testing
Run Tests
# All tests (requires GITHUB_TOKEN)
# Unit tests only (no API calls)
# Integration tests (requires GitHub API access)
# With output
Environment Setup for Tests
# Required for integration tests
# Run tests
Example Test
async
๐ API Coverage
Implemented
- โ Issues (CRUD, comments, labels, assignees)
- โ Labels (CRUD, bulk sync)
- โ Pull Requests (CRUD, merge, close)
- โ Projects v2 (add items, update fields, KPI)
- โ Authentication (multi-source discovery)
- โ Repository info
Planned
- โณ Releases (create, update, publish)
- โณ Webhooks (create, list, delete)
- โณ Actions (trigger workflows, get run status)
- โณ Code Scanning (SARIF upload, alerts)
- โณ Dependabot (alerts, security updates)
๐ Dependencies
Core Dependencies
- miyabi-types - Shared type definitions (Issue, Label, PR)
- octocrab (v0.41) - GitHub REST API client
- tokio (v1.42) - Async runtime
- serde (v1.0) - Serialization framework
- serde_json (v1.0) - JSON support
- tracing (v0.1) - Structured logging
- dirs (v6.0) - Config directory discovery
๐ Related Crates
Agents (Consumers)
- miyabi-agent-coordinator - Orchestrates agents, uses GitHub for task management
- miyabi-agent-issue - Issue analysis, uses GitHub to fetch/update issues
- miyabi-agent-pr - PR creation, uses GitHub to create and manage PRs
- miyabi-agent-deployment - Deployment automation, uses GitHub releases
- miyabi-agent-refresher - Issue refresh, uses GitHub to update stale issues
Infrastructure
- miyabi-cli - CLI tool, uses GitHub client for all operations
- miyabi-core - Core utilities, shared with miyabi-github
- miyabi-types - Type definitions for GitHub entities
๐ Documentation
- GitHub API Reference: docs.github.com/rest
- Octocrab Docs: docs.rs/octocrab
- Miyabi Label System: LABEL_SYSTEM_GUIDE.md
- Entity-Relation Model: ENTITY_RELATION_MODEL.md
๐ Security Considerations
Token Security
- Never commit tokens: Add
.envto.gitignore - Use gh CLI: Most secure option, tokens stored in system keychain
- Rotate tokens regularly: GitHub Settings โ Developer settings โ Personal access tokens
- Scope tokens appropriately: Only grant necessary permissions (repo, issues, pull_requests)
Required GitHub Token Scopes
repo # Full control of private repositories
repo:status # Commit status
repo:deployment # Deployment status
public_repo # Public repository access
issues # Read/write access to issues
pull_requests # Read/write access to PRs
Rate Limiting
// Check rate limit status
let rate_limit = client.octocrab
.ratelimit
.get
.await?;
println!;
println!;
๐ค Contributing
See CONTRIBUTING.md for development guidelines.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Version History
- v0.1.0 (2025-11-06) - Initial release
- Issue CRUD operations
- Label management with bulk sync
- Pull request operations
- Projects v2 integration
- Multi-source authentication
- Miyabi state-based queries
Part of the Miyabi Framework - Autonomous AI Development Platform