Status: ✅ PRODUCTION READY
Location: tools/github_agent_tool.py
Purpose: GitHub-focused agent for coordinating mindX branch backups, restores, milestone monitoring, and pre-upgrade backups
The GitHub Agent Tool is a specialized tool completely focused on GitHub as a version control and backup system. It ensures mindX always has a working fallback state in GitHub by:
The GitHub agent follows the principle: "Do one thing and do it well." It is completely focused on GitHub operations and does not perform strategic reasoning or decision-making beyond backup coordination.
create_backupParameters:
backup_type (optional): Type of backup (default: "manual")reason (required): Reason for the backupbranch_name (optional): Custom branch name (auto-generated if not provided)Example:
success, result = await github_agent.execute(
operation="create_backup",
backup_type="pre_architectural_upgrade",
reason="Major system refactoring"
)
restore_from_backupParameters:
branch_name (required): Name of the backup branch to restore fromtarget_branch (optional): Target branch to restore to (default: "main")Example:
success, result = await github_agent.execute(
operation="restore_from_backup",
branch_name="backup/pre-architectural-upgrade-20250108_143022",
target_branch="main"
)
check_milestonesExample:
success, result = await github_agent.execute(
operation="check_milestones"
)
detect_architectural_changesExample:
success, result = await github_agent.execute(
operation="detect_architectural_changes"
)
pre_upgrade_backupParameters:
upgrade_description (required): Description of the upgradeExample:
success, result = await github_agent.execute(
operation="pre_upgrade_backup",
upgrade_description="SEA Campaign: System architecture refactoring"
)
list_backupsExample:
success, result = await github_agent.execute(
operation="list_backups"
)
get_backup_statusExample:
success, result = await github_agent.execute(
operation="get_backup_status"
)
sync_with_githubExample:
success, result = await github_agent.execute(
operation="sync_with_github"
)
start_scheduled_backupsExample:
success, result = await github_agent.execute(
operation="start_scheduled_backups"
)
stop_scheduled_backupsExample:
success, result = await github_agent.execute(
operation="stop_scheduled_backups"
)
set_backup_scheduleParameters:
interval (required): "hourly", "daily", or "weekly"enabled (optional): Enable/disable this schedule (default: True)time (optional): Time for daily/weekly backups (format: "HH:MM")day (optional): Day of week for weekly backups (e.g., "sunday", "monday")Example:
# Enable daily backups at 2:00 AM
success, result = await github_agent.execute(
operation="set_backup_schedule",
interval="daily",
enabled=True,
time="02:00"
)
Enable weekly backups on Sunday at 3:00 AM
success, result = await github_agent.execute(
operation="set_backup_schedule",
interval="weekly",
enabled=True,
day="sunday",
time="03:00"
)
get_backup_scheduleExample:
success, result = await github_agent.execute(
operation="get_backup_schedule"
)
shutdown_backupExample:
success, result = await github_agent.execute(
operation="shutdown_backup"
)
The GitHub agent supports multiple backup types:
pre_architectural_upgrade: Created before major architectural changesmilestone_backup: Created when milestones are detectedscheduled_backup: Regular scheduled backupsmanual_backup: Manual backupsemergency_backup: Emergency backupsshutdown_backup: Created automatically before system shutdownhourly_backup: Created on hourly scheduledaily_backup: Created on daily scheduleweekly_backup: Created on weekly scheduleThe GitHub agent supports time-based backup scheduling:
Schedule configuration is stored in data/github_backup_schedule.json:
{
"enabled": true,
"schedules": {
"hourly": {
"enabled": false,
"interval_seconds": 3600
},
"daily": {
"enabled": true,
"interval_seconds": 86400,
"time": "02:00"
},
"weekly": {
"enabled": false,
"interval_seconds": 604800,
"day": "sunday",
"time": "03:00"
}
},
"shutdown_backup": {
"enabled": true
}
}
All backups are tracked in data/github_backups.json with the following structure:
{
"backups": [
{
"branch_name": "backup/pre-architectural-upgrade-20250108_143022",
"backup_type": "pre_architectural_upgrade",
"reason": "Major system refactoring",
"source_branch": "main",
"source_commit": "abc123...",
"created_at": "2025-01-08T14:30:22",
"status": "created"
}
],
"last_backup": {...},
"last_backup_at": "2025-01-08T14:30:22",
"restorations": [...]
}
The GitHub agent is automatically initialized in the Strategic Evolution Agent and creates backups before:
run_evolution_campaign)run_enhanced_blueprint_campaign)run_audit_driven_campaign)The Coordinator Agent:
The GitHub agent subscribes to the following events:
architectural.change.detected: Triggers backup creationcomponent.improvement.success: Checks for backup needsfrom tools.github_agent_tool import GitHubAgentTool
github_agent = GitHubAgentTool(memory_agent=memory_agent, config=config)
success, result = await github_agent.execute(
operation="pre_upgrade_backup",
upgrade_description="Manual system upgrade"
)
success, status = await github_agent.execute(
operation="get_backup_status"
)
print(f"Current branch: {status['current_branch']}")
print(f"Last backup: {status['last_backup']}")
success, backups = await github_agent.execute(
operation="list_backups"
)
for branch in backups['backup_branches']:
print(f"Backup branch: {branch}")
The GitHub agent uses the standard mindX configuration system. No special configuration is required, but you can customize:
The GitHub agent logs all operations to:
All backup operations are tracked and can be queried for system health monitoring.
Potential future enhancements: