An AI-powered GitHub repository orchestrator that automatically manages issues and pull requests using GitHub Copilot.
- 🔄 Intelligent Orchestration: Continuously monitors and manages repository health with automated workflows
- 🤖 AI Issue Evaluation: Uses Azure AI Foundry models to analyze GitHub issues for Copilot suitability
- ✅ Automated Assignment: Assigns suitable issues to Copilot with labels and comments
- 📝 Smart PR Review: Reviews open pull requests using AI and automatically merges when appropriate
- 🔁 Continuous Loop Mode: Runs continuously, checking repositories at regular intervals
- 🎯 Capacity Management: Intelligently limits concurrent Copilot assignments to prevent overload
- 🏥 Repository Health Tracking: Monitors stuck PRs, escalates issues, and ensures forward progress
- 📊 Comprehensive Reporting: Provides detailed visibility into workflow operations
- 🛡️ Robust Error Handling: Handles API rate limits, network issues, and errors gracefully
-
Clone the repository:
git clone https://github.com/lucabol/JediMaster.git cd JediMaster -
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Required environment variables:
GITHUB_TOKEN: Your GitHub personal access token with repo permissionsAZURE_AI_FOUNDRY_PROJECT_ENDPOINT: Your Azure AI Foundry project endpoint for agents
Optional configuration:
MAX_COPILOT_SLOTS: Maximum concurrent Copilot assignments (default: 10)MAX_COMMENTS: Maximum PR comments before escalating to human (default: 35)CREATE_ISSUES: Enable AI-powered issue creation (0=disabled, 1=enabled, default: 0)CREATE_ISSUES_COUNT: Number of issues to create per repository (default: 3)SIMILARITY_THRESHOLD: Duplicate detection threshold when creating issues (0.0-1.0, default: 0.85)SKIP_PR_REVIEWS: Skip AI review and merge PRs directly (0=disabled, 1=enabled, default: 0)ISSUE_ACTION: How to handle suitable issues -assign(assign to Copilot) orlabel(only add labels)MERGE_MAX_RETRIES: Maximum merge retry attempts before giving up (default: 5)
Authentication: The application uses DefaultAzureCredential for Azure AI Foundry authentication, which supports:
- Azure CLI authentication (recommended for local development - run
az login) - Managed Identity (for Azure deployments)
- Environment variables (AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID)
- Visual Studio authentication
- And other Azure credential sources
Create a
.envfile in the project root (see.env.examplefor all options):# .env file (recommended) GITHUB_TOKEN=your_github_token AZURE_AI_FOUNDRY_PROJECT_ENDPOINT=https://your-project.services.ai.azure.com/api/projects/YourProject # Optional settings MAX_COMMENTS=35 CREATE_ISSUES=0 # Set to 1 to enable AI issue creation
-
Deploy the AI agents to Azure Foundry:
python deploy_agents.py
This deploys the three agents (
DeciderAgent,PRDeciderAgent,CreatorAgent) defined infoundry_agents/to your Azure AI Foundry project.
The best way to run JediMaster is in orchestrate mode with continuous loop, which intelligently manages your repositories:
python example.py --orchestrate --loop 20This will:
- ✅ Process all pull requests - review, merge, or escalate as needed
- ✅ Assign issues to Copilot - up to the configured capacity limit
- ✅ Track repository health - monitor stuck PRs and forward progress
- ✅ Run continuously - check every 20 minutes (configurable)
- ✅ Auto-stop when done - stops when all work is complete or needs human review
Command-line options for orchestrate mode:
# Run once and exit
python example.py --orchestrate
# Run continuously, checking every N minutes
python example.py --orchestrate --loop 20
# Enable AI-powered issue creation
python example.py --orchestrate --loop 20 --create-issues
# Process specific repositories
python example.py --orchestrate --loop 20 owner/repo1 owner/repo2
# Process all repos for a user (with topic "managed-by-coding-agent")
python example.py --orchestrate --loop 20 --user github-usernameThe orchestrator will:
-
Process PRs first (higher priority):
- Skip PRs already needing human review
- Skip PRs where Copilot is actively working
- Review PRs and either merge or request changes
- Track Copilot capacity to avoid overload
-
Assign issues to Copilot (with remaining capacity):
- Only assigns issues up to
MAX_COPILOT_SLOTSlimit - Prioritizes PRs over new issue assignments
- Only assigns issues up to
-
Monitor health and auto-stop:
- Stops when all PRs need human review and no issues to assign
- Provides detailed summary of each iteration
You can also run specific workflows manually:
python jedimaster.py owner/repo1 owner/repo2python jedimaster.py --user github-usernamepython jedimaster.py --manage-prs owner/repo1 owner/repo2Available command-line options:
--orchestrateRun intelligent orchestration workflow (recommended)--loop MINUTESRun continuously, checking every N minutes--create-issuesEnable AI-powered issue creation--create-issues-count NNumber of issues to create per repo (default: 3)--similarity-thresholdDuplicate detection threshold (0.0-1.0, enables OpenAI embeddings)--user, -u USERNAMEProcess repos for a GitHub user (with topic "managed-by-coding-agent")--verbose, -vEnable verbose logging--output, -o FILENAMEOutput filename for the report--save-reportSave detailed report to JSON file--use-file-filterUse .coding_agent file filtering instead of topic filtering
Legacy options (for manual workflows):
--manage-prsProcess open pull requests through state machine--just-labelOnly add labels to issues, do not assign them--assignAssign issues to Copilot (overrides --just-label)--populate-issuesSeed a demo repo with test issues--reset-repoReset a demo repo (closes all issues/PRs, deletes branches)
Start continuous orchestration:
# Check every 30 minutes
python example.py --orchestrate --loop 30
# With AI issue creation enabled
python example.py --orchestrate --loop 30 --create-issues
# For specific repos
python example.py --orchestrate --loop 30 owner/repo1 owner/repo2
# For all user repos with topic "managed-by-coding-agent"
python example.py --orchestrate --loop 30 --user myusernameOne-time operations:
# Single orchestration pass (run once)
python example.py --orchestrate owner/repo1
# Create AI-suggested issues
python example.py --create-issues owner/repo1
# Process only PRs (no issue assignment)
python example.py --manage-prs owner/repo1Demo/test operations:
# Populate demo repo with test issues
python example.py --populate-issues lucabol/Hello-World
# Reset demo repo to baseline
python example.py --reset-repo lucabol/Hello-WorldYou can also import and use JediMaster programmatically:
import asyncio
from jedimaster import JediMaster
async def main():
async with JediMaster(
github_token="<token>",
azure_foundry_project_endpoint="<project_endpoint>",
# Uses DefaultAzureCredential (no API key needed)
) as jm:
# Run orchestration workflow
report = await jm.run_simplified_workflow("owner/repo1")
print(f"Success: {report['success']}")
print(f"PRs processed: {report['prs_processed']}")
print(f"Issues assigned: {report['issues_assigned']}")
asyncio.run(main())JediMaster uses a sophisticated workflow to manage repositories:
-
PR Processing (Priority 1):
- Fetches all open PRs
- Skips PRs already escalated to humans (
copilot-human-reviewlabel) - Skips PRs where Copilot is actively working
- For remaining PRs:
- Reviews using PRDeciderAgent (AI-powered review)
- If approved and mergeable → merges automatically
- If approved but merge conflicts → asks Copilot to fix (with detailed diff)
- If changes needed → requests changes and reassigns to Copilot
- If too many comments (>MAX_COMMENTS) → escalates to human review
-
Issue Assignment (Priority 2):
- Evaluates unprocessed issues using IssueDeciderAgent
- Assigns suitable issues to Copilot
- Labels unsuitable issues
-
Capacity Management:
- Tracks active Copilot assignments across PRs and issues
- Limits concurrent work to prevent overload (hardcoded to 10 slots)
- Prioritizes PR review over new issue assignments
-
Auto-Stop Criteria:
- All PRs need human review AND
- No issues available to assign
- Prevents unnecessary API calls
- PRDeciderAgent: Reviews PRs and decides whether to approve or request changes
- IssueDeciderAgent: Evaluates issues for Copilot suitability
- CreatorAgent: Suggests new issues based on repository analysis (when enabled)
The three AI agents used by JediMaster are defined in the foundry_agents/ folder as YAML files:
| Agent | File | Purpose |
|---|---|---|
DeciderAgent |
decideragent.yaml |
Evaluates GitHub issues for Copilot suitability |
PRDeciderAgent |
prdecideragent.yaml |
Reviews PRs and decides to accept or request changes |
CreatorAgent |
creatoragent.yaml |
Suggests new issues based on repository analysis |
Extract agents from Azure Foundry:
python extract_agents.pyThis saves current agent definitions from your Azure AI Foundry project to foundry_agents/.
Deploy agents to Azure Foundry:
# Deploy all agents
python deploy_agents.py
# Deploy a specific agent
python deploy_agents.py --agent DeciderAgent
# Dry run (show what would be deployed)
python deploy_agents.py --dry-runYAML Definition Format:
name: DeciderAgent
model: claude-sonnet-4-5
instructions: |
Your system prompt instructions here...
⚠️ Experimental: Azure Functions deployment is currently experimental and may not work reliably. Use local execution (python example.py) for production workloads.
JediMaster can be deployed as an Azure Function for automated, scheduled repository management.
- Azure CLI (
az) installed and logged in - Azure Functions Core Tools (
func) installed - An existing Azure Function App (Python)
- Azure AI Foundry resource with managed identity access
-
Configure
.envwith deployment settings:# Azure deployment configuration (REQUIRED) RESOURCE_GROUP=your-resource-group FUNCTION_APP_NAME=your-function-app-name # AI resource for managed identity role assignment AI_RESOURCE_GROUP=your-ai-resource-group # Timer schedule (Azure Functions CRON format) SCHEDULE_CRON=0 */30 * * * * # Every 30 minutes # Repositories to process AUTOMATION_REPOS=owner/repo1,owner/repo2 # Processing flags PROCESS_PRS=1 AUTO_MERGE=1 JUST_LABEL=0 CREATE_ISSUES=0
-
Deploy using the script:
pwsh ./deploy_existing.ps1The script will:
- Enable system-assigned managed identity
- Configure Cognitive Services User role for AI access
- Apply all settings from
.env - Deploy the function code
Additional variables for Azure Functions (see .env.example for complete list):
| Variable | Description | Default |
|---|---|---|
SCHEDULE_CRON |
Timer trigger schedule (CRON format) | 0 */30 * * * * |
AUTOMATION_REPOS |
Comma-separated list of repos | - |
PROCESS_PRS |
Enable PR processing | 1 |
AUTO_MERGE |
Enable auto-merge of approved PRs | 1 |
JUST_LABEL |
Only label issues, don't assign | 0 |
USE_FILE_FILTER |
Use .coding_agent file filtering | 0 |
BATCH_SIZE |
Items to process per batch | 5 |
RATE_LIMIT_DELAY |
Delay between API calls (seconds) | 2.0 |
- Console: Real-time progress with summary statistics
- Continuous monitoring: Shows iteration number, timestamp, and next check time
- Detailed logging: Per-PR and per-issue status with reasons
- JSON Report: Available with
--save-reportflag
Example output:
================================================================================
[SimplifiedWorkflow] Iteration #5 at 2025-11-07 10:30:00 UTC
================================================================================
--- Processing: owner/repo1 ---
Step 1/2: Processing pull requests...
Found 15 open PRs (3 need human review, 12 processed):
PR #123: Fix authentication bug -> Merged
PR #124: Add new feature -> Changes requested
PR #125: Update documentation -> Copilot working
Copilot actively working on 3/10 PRs
Step 2/2: Processing issues (up to 7 assignments available)...
Processing 5 unprocessed issues:
Issue #45: Add error handling -> Assigned to Copilot
Issue #46: Fix typo -> Assigned to Copilot
Issue #47: Complex refactoring -> Not suitable for Copilot
================================================================================
Workflow complete:
- 15 PRs processed
- 2 issues assigned to Copilot
- Duration: 45.2s
================================================================================
[SimplifiedWorkflow] Next run at: 2025-11-07 10:50:00 UTC
- Handles API rate limits, network issues, authentication errors, and invalid data.
- Logs errors and provides clear messages for troubleshooting.
- Fork the repository
- Create a feature branch
- Make your changes and add tests
- Submit a pull request
This project is licensed under the MIT License.
- Check existing GitHub issues
- Create a new issue with details and logs (use
--verbosefor more info)