Add real-time GitHub sync to installers and sync script

Interactive installer (interactive-install-claude.sh):
- Add fetch_latest_agents() function to check GitHub for updates
- Clone latest agents from contains-studio/agents before installing
- Update local agents directory with upstream changes
- Gracefully fallback to local agents if GitHub fetch fails
- Call fetch_latest_agents() before install_agents() in main flow

Sync script (sync-agents.sh):
- Add REPO_AGENTS_DIR environment variable support
- Automatically update repository agents directory when syncing
- Keep installer agents in sync with Claude Code agents

This ensures users always get the latest agents from upstream GitHub
while maintaining customizations in the local repository.
This commit is contained in:
uroma
2026-01-16 09:13:08 +00:00
Unverified
parent 8b8a474703
commit 641ca1588d
2 changed files with 63 additions and 0 deletions

View File

@@ -594,6 +594,49 @@ create_directories() {
log_success "Directories created"
}
fetch_latest_agents() {
log_info "Checking for agent updates from GitHub..."
local GITHUB_REPO="https://github.com/contains-studio/agents"
local TEMP_AGENT_DIR="/tmp/claude-agents-latest-$RANDOM"
local UPDATE_FOUND=false
# Create temp directory
mkdir -p "$TEMP_AGENT_DIR"
# Try to clone using git
if command -v git &> /dev/null; then
if git clone --depth 1 --quiet "$GITHUB_REPO" "$TEMP_AGENT_DIR" 2>/dev/null; then
UPDATE_FOUND=true
log_success "Fetched latest agents from GitHub"
# Copy updated agents to source directory
for category in engineering marketing product studio-operations project-management testing design bonus; do
if [ -d "$TEMP_AGENT_DIR/$category" ]; then
mkdir -p "$SCRIPT_DIR/agents/$category"
cp -f "$TEMP_AGENT_DIR/$category"/*.md "$SCRIPT_DIR/agents/$category/" 2>/dev/null || true
fi
done
# Update README if present
if [ -f "$TEMP_AGENT_DIR/README.md" ]; then
cp -f "$TEMP_AGENT_DIR/README.md" "$SCRIPT_DIR/agents/README.md" 2>/dev/null || true
fi
log_info "Local agents updated from GitHub"
else
log_warning "Failed to fetch from GitHub (using local agents)"
fi
else
log_warning "Git not found (using local agents)"
fi
# Cleanup
rm -rf "$TEMP_AGENT_DIR"
return 0
}
install_agents() {
if [ $SELECTED_AGENTS -eq 0 ]; then
return
@@ -1055,6 +1098,7 @@ perform_installation() {
echo ""
create_directories
fetch_latest_agents
install_agents
install_settings
install_local_settings

View File

@@ -137,6 +137,25 @@ sync_agents() {
# Summary
local total_changes=$((${#new_agents[@]} + ${#updated_agents[@]}))
log "INFO" "Sync complete: ${#new_agents[@]} new, ${#updated_agents[@]} updated, ${#custom_agents[@]} preserved"
# If REPO_AGENTS_DIR is set, also update repository agents
if [[ -n "${REPO_AGENTS_DIR:-}" && -d "$REPO_AGENTS_DIR" ]]; then
print_msg "$BLUE" "📦 Updating repository agents directory..."
for category in engineering marketing product studio-operations project-management testing design bonus; do
if [ -d "$AGENTS_DIR/$category" ]; then
mkdir -p "$REPO_AGENTS_DIR/$category"
cp -f "$AGENTS_DIR/$category"/*.md "$REPO_AGENTS_DIR/$category/" 2>/dev/null || true
fi
done
if [ -f "$AGENTS_DIR/README.md" ]; then
cp -f "$AGENTS_DIR/README.md" "$REPO_AGENTS_DIR/README.md" 2>/dev/null || true
fi
print_msg "$GREEN" "✓ Repository agents updated"
log "INFO" "Repository agents updated at $REPO_AGENTS_DIR"
fi
}
# Commit to git