Move deprecated scripts to deprecated/ folder
Moved 3 scripts that are no longer recommended for installation: - install-claude-customizations.sh (replaced by interactive installer) - export-claude-customizations.sh (export utility, not needed for install) - sync-agents.sh (sync utility, not needed for install) Users should use interactive-install-claude.sh or MASTER-PROMPT.md instead. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
34
deprecated/README.md
Normal file
34
deprecated/README.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Deprecated Scripts
|
||||
|
||||
This folder contains scripts that are no longer maintained or recommended for use.
|
||||
|
||||
## Why These Scripts Are Deprecated
|
||||
|
||||
### 1. install-claude-customizations.sh
|
||||
- **Status**: Replaced by `interactive-install-claude.sh`
|
||||
- **Reason**: The interactive installer provides better user experience with more options
|
||||
- **Alternative**: Use `./interactive-install-claude.sh` instead
|
||||
|
||||
### 2. export-claude-customizations.sh
|
||||
- **Status**: Not needed for initial installation
|
||||
- **Reason**: This is an export utility for backing up customizations, not required for setup
|
||||
- **Alternative**: Manual backup or version control
|
||||
|
||||
### 3. sync-agents.sh
|
||||
- **Status**: Not needed for initial installation
|
||||
- **Reason**: This syncs agents with external repos, not required for initial setup
|
||||
- **Alternative**: Git-based management or manual updates
|
||||
|
||||
## Recommended Installation Method
|
||||
|
||||
Use the **Interactive Installer** for all new installations:
|
||||
|
||||
```bash
|
||||
./interactive-install-claude.sh
|
||||
```
|
||||
|
||||
Or follow **MASTER-PROMPT.md** for manual setup.
|
||||
|
||||
## Note
|
||||
|
||||
These scripts are kept for historical reference only. They may not work with current versions of Claude Code and are not supported.
|
||||
212
deprecated/export-claude-customizations.sh
Executable file
212
deprecated/export-claude-customizations.sh
Executable file
@@ -0,0 +1,212 @@
|
||||
#!/usr/bin/env bash
|
||||
################################################################################
|
||||
# Claude Code Customizations Exporter
|
||||
# This script packages all customizations for transfer to another machine
|
||||
################################################################################
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Configuration
|
||||
CLAUDE_DIR="$HOME/.claude"
|
||||
EXPORT_DIR="$HOME/claude-customizations-export"
|
||||
EXPORT_FILE="$HOME/claude-customizations-$(date +%Y%m%d_%H%M%S).tar.gz"
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
# Create export directory
|
||||
log_info "Creating export directory..."
|
||||
rm -rf "$EXPORT_DIR"
|
||||
mkdir -p "$EXPORT_DIR"
|
||||
|
||||
# Export agents
|
||||
log_info "Exporting custom agents..."
|
||||
mkdir -p "$EXPORT_DIR/agents"
|
||||
cp -r "$CLAUDE_DIR/agents/"* "$EXPORT_DIR/agents/" 2>/dev/null || true
|
||||
|
||||
# Export plugins configuration
|
||||
log_info "Exporting plugins configuration..."
|
||||
mkdir -p "$EXPORT_DIR/plugins"
|
||||
cp -r "$CLAUDE_DIR/plugins/cache/"* "$EXPORT_DIR/plugins/" 2>/dev/null || true
|
||||
cp "$CLAUDE_DIR/plugins/installed_plugins.json" "$EXPORT_DIR/plugins/" 2>/dev/null || true
|
||||
cp "$CLAUDE_DIR/plugins/known_marketplaces.json" "$EXPORT_DIR/plugins/" 2>/dev/null || true
|
||||
|
||||
# Export settings (without sensitive data)
|
||||
log_info "Exporting settings..."
|
||||
mkdir -p "$EXPORT_DIR/config"
|
||||
|
||||
# Export settings.local.json (permissions)
|
||||
cp "$CLAUDE_DIR/settings.local.json" "$EXPORT_DIR/config/" 2>/dev/null || true
|
||||
|
||||
# Create settings template (without actual API token)
|
||||
cat > "$EXPORT_DIR/config/settings-template.json" << EOF
|
||||
{
|
||||
"env": {
|
||||
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_TOKEN_HERE",
|
||||
"ANTHROPIC_BASE_URL": "https://api.anthropic.com",
|
||||
"API_TIMEOUT_MS": "3000000",
|
||||
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
|
||||
},
|
||||
"enabledPlugins": {
|
||||
"glm-plan-bug@zai-coding-plugins": true,
|
||||
"glm-plan-usage@zai-coding-plugins": true
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Export hooks if present
|
||||
log_info "Exporting hooks..."
|
||||
if [ -d "$CLAUDE_DIR/hooks" ] && [ "$(ls -A $CLAUDE_DIR/hooks)" ]; then
|
||||
mkdir -p "$EXPORT_DIR/hooks"
|
||||
cp -r "$CLAUDE_DIR/hooks/"* "$EXPORT_DIR/hooks/"
|
||||
fi
|
||||
|
||||
# Create README
|
||||
log_info "Creating documentation..."
|
||||
cat > "$EXPORT_DIR/README.md" << 'EOF'
|
||||
# Claude Code Customizations Package
|
||||
|
||||
This package contains all customizations for Claude Code including custom agents, MCP tools configuration, and plugins.
|
||||
|
||||
## Contents
|
||||
|
||||
- `agents/` - Custom agent definitions organized by category
|
||||
- `plugins/` - Plugin configurations
|
||||
- `config/` - Settings files
|
||||
- `hooks/` - Custom hooks (if any)
|
||||
|
||||
## Installation
|
||||
|
||||
### Quick Install
|
||||
|
||||
Run the automated installer:
|
||||
|
||||
```bash
|
||||
bash install-claude-customizations.sh
|
||||
```
|
||||
|
||||
### Manual Install
|
||||
|
||||
1. **Copy agents:**
|
||||
```bash
|
||||
cp -r agents/* ~/.claude/agents/
|
||||
```
|
||||
|
||||
2. **Copy plugins:**
|
||||
```bash
|
||||
cp -r plugins/* ~/.claude/plugins/
|
||||
```
|
||||
|
||||
3. **Configure settings:**
|
||||
```bash
|
||||
cp config/settings.local.json ~/.claude/
|
||||
# Edit ~/.claude/settings.json and add your API token
|
||||
```
|
||||
|
||||
4. **Install MCP tools:**
|
||||
```bash
|
||||
npm install -g @z_ai/mcp-server @z_ai/coding-helper
|
||||
```
|
||||
|
||||
5. **Restart Claude Code**
|
||||
|
||||
## Agent Categories
|
||||
|
||||
- **Engineering** - AI engineer, backend architect, frontend developer, DevOps, mobile app builder
|
||||
- **Marketing** - TikTok strategist, growth hacker, content creator
|
||||
- **Product** - Sprint prioritizer, feedback synthesizer, trend researcher
|
||||
- **Studio Operations** - Studio producer, project shipper, analytics, finance
|
||||
- **Project Management** - Experiment tracker, studio coach
|
||||
- **Testing** - Test writer/fixer, API tester, performance benchmarker
|
||||
- **Design** - UI designer, UX researcher, brand guardian, whimsy injector
|
||||
- **Bonus** - Joker, studio coach
|
||||
|
||||
## MCP Tools Included
|
||||
|
||||
- **zai-mcp-server** - Vision analysis (images, videos, UI screenshots, error diagnosis)
|
||||
- **web-search-prime** - Enhanced web search with domain filtering
|
||||
- **web-reader** - Fetch URLs and convert to markdown
|
||||
- **zread** - GitHub repository reader
|
||||
|
||||
## Skills
|
||||
|
||||
- `glm-plan-bug:case-feedback` - Submit bug/issue feedback
|
||||
- `glm-plan-usage:usage-query` - Query account usage statistics
|
||||
|
||||
## Customization
|
||||
|
||||
Edit agent `.md` files in `~/.claude/agents/` to customize agent behavior.
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions, refer to the original source machine or Claude Code documentation.
|
||||
EOF
|
||||
|
||||
# Create manifest
|
||||
log_info "Creating package manifest..."
|
||||
cat > "$EXPORT_DIR/MANIFEST.json" << EOF
|
||||
{
|
||||
"package": "claude-code-customizations",
|
||||
"version": "1.0.0",
|
||||
"exported_at": "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)",
|
||||
"contents": {
|
||||
"agents": "$(ls -1 "$EXPORT_DIR/agents" | wc -l) categories",
|
||||
"plugins": "$(ls -1 "$EXPORT_DIR/plugins" 2>/dev/null | wc -l) items",
|
||||
"config_files": "$(ls -1 "$EXPORT_DIR/config" | wc -l) files"
|
||||
},
|
||||
"mcp_tools": [
|
||||
"zai-mcp-server (vision)",
|
||||
"web-search-prime",
|
||||
"web-reader",
|
||||
"zread"
|
||||
],
|
||||
"skills": [
|
||||
"glm-plan-bug:case-feedback",
|
||||
"glm-plan-usage:usage-query"
|
||||
]
|
||||
}
|
||||
EOF
|
||||
|
||||
# Create tarball
|
||||
log_info "Creating compressed archive..."
|
||||
tar -czf "$EXPORT_FILE" -C "$HOME" "$(basename "$EXPORT_DIR")"
|
||||
|
||||
# Get file size
|
||||
FILE_SIZE=$(du -h "$EXPORT_FILE" | cut -f1)
|
||||
|
||||
log_success "═══════════════════════════════════════════════════════════"
|
||||
log_success "Export completed successfully!"
|
||||
log_success "═══════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
log_info "Export location: $EXPORT_FILE"
|
||||
log_info "Package size: $FILE_SIZE"
|
||||
log_info "Unpacked directory: $EXPORT_DIR"
|
||||
echo ""
|
||||
log_info "To transfer to another machine:"
|
||||
echo " 1. Copy the archive: scp $EXPORT_FILE user@target:~/"
|
||||
echo " 2. Extract: tar -xzf $(basename "$EXPORT_FILE")"
|
||||
echo " 3. Run: cd $(basename "$EXPORT_DIR") && bash install-claude-customizations.sh"
|
||||
echo ""
|
||||
|
||||
# Ask if user wants to keep unpacked directory
|
||||
read -p "Keep unpacked export directory? (y/N): " keep_unpacked
|
||||
if [[ ! "$keep_unpacked" =~ ^[Yy]$ ]]; then
|
||||
rm -rf "$EXPORT_DIR"
|
||||
log_info "Unpacked directory removed"
|
||||
fi
|
||||
396
deprecated/install-claude-customizations.sh
Executable file
396
deprecated/install-claude-customizations.sh
Executable file
@@ -0,0 +1,396 @@
|
||||
#!/usr/bin/env bash
|
||||
################################################################################
|
||||
# Claude Code Customizations Installer
|
||||
# This script automates the setup of custom agents, MCP tools, and plugins
|
||||
# for Claude Code on a new machine.
|
||||
################################################################################
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
CLAUDE_DIR="$HOME/.claude"
|
||||
AGENTS_DIR="$CLAUDE_DIR/agents"
|
||||
PLUGINS_DIR="$CLAUDE_DIR/plugins"
|
||||
BACKUP_DIR="$HOME/.claude-backup-$(date +%Y%m%d_%H%M%S)"
|
||||
|
||||
################################################################################
|
||||
# Helper Functions
|
||||
################################################################################
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
check_command() {
|
||||
if ! command -v $1 &> /dev/null; then
|
||||
log_error "$1 is not installed. Please install it first."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
backup_file() {
|
||||
local file="$1"
|
||||
if [ -f "$file" ]; then
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
cp "$file" "$BACKUP_DIR/"
|
||||
log_info "Backed up $file to $BACKUP_DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Prerequisites Check
|
||||
################################################################################
|
||||
|
||||
check_prerequisites() {
|
||||
log_info "Checking prerequisites..."
|
||||
|
||||
check_command "node"
|
||||
check_command "npm"
|
||||
check_command "python3"
|
||||
check_command "curl"
|
||||
|
||||
# Check Node.js version (need 14+)
|
||||
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
|
||||
if [ "$NODE_VERSION" -lt 14 ]; then
|
||||
log_error "Node.js version 14 or higher required. Current: $(node -v)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_success "Prerequisites check passed"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Directory Structure Setup
|
||||
################################################################################
|
||||
|
||||
setup_directories() {
|
||||
log_info "Setting up directory structure..."
|
||||
|
||||
mkdir -p "$AGENTS_DIR"/{engineering,marketing,product,studio-operations,project-management,testing,design,bonus}
|
||||
|
||||
mkdir -p "$PLUGINS_DIR"/{cache,marketplaces}
|
||||
mkdir -p "$CLAUDE_DIR"/{hooks,debug,file-history,paste-cache,projects,session-env,shell-snapshots,todos}
|
||||
|
||||
log_success "Directory structure created"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Settings Configuration
|
||||
################################################################################
|
||||
|
||||
setup_settings() {
|
||||
log_info "Configuring Claude Code settings..."
|
||||
|
||||
local settings_file="$CLAUDE_DIR/settings.json"
|
||||
|
||||
backup_file "$settings_file"
|
||||
|
||||
# Prompt for API credentials
|
||||
read -p "Enter your ANTHROPIC_AUTH_TOKEN (or press Enter to skip): " API_TOKEN
|
||||
read -p "Enter your ANTHROPIC_BASE_URL (default: https://api.anthropic.com): " API_BASE
|
||||
API_BASE=${API_BASE:-https://api.anthropic.com}
|
||||
|
||||
# Create settings.json
|
||||
cat > "$settings_file" << EOF
|
||||
{
|
||||
"env": {
|
||||
"ANTHROPIC_AUTH_TOKEN": "${API_TOKEN}",
|
||||
"ANTHROPIC_BASE_URL": "${API_BASE}",
|
||||
"API_TIMEOUT_MS": "3000000",
|
||||
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
|
||||
},
|
||||
"enabledPlugins": {
|
||||
"glm-plan-bug@zai-coding-plugins": true,
|
||||
"glm-plan-usage@zai-coding-plugins": true
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Create local settings for permissions
|
||||
local local_settings="$CLAUDE_DIR/settings.local.json"
|
||||
backup_file "$local_settings"
|
||||
|
||||
cat > "$local_settings" << EOF
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(npm install:*)",
|
||||
"Bash(npm run content:*)",
|
||||
"Bash(npm run build:*)",
|
||||
"Bash(grep:*)",
|
||||
"Bash(find:*)",
|
||||
"Bash(for:*)",
|
||||
"Bash(do sed:*)",
|
||||
"Bash(done)",
|
||||
"Bash(python3:*)",
|
||||
"Bash(while read f)",
|
||||
"Bash(do echo \\"\\$f%-* \\$f\\")",
|
||||
"Bash(ls:*)",
|
||||
"Bash(node:*)",
|
||||
"Bash(pm2 delete:*)",
|
||||
"Bash(pm2 start npm:*)",
|
||||
"Bash(pm2 save:*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
log_success "Settings configured"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# MCP Services Installation
|
||||
################################################################################
|
||||
|
||||
install_mcp_services() {
|
||||
log_info "Installing MCP services..."
|
||||
|
||||
# Install @z_ai/mcp-server globally for vision tools
|
||||
log_info "Installing @z_ai/mcp-server (vision analysis tools)..."
|
||||
npm install -g @z_ai/mcp-server 2>/dev/null || {
|
||||
log_warning "Global install failed, trying with npx..."
|
||||
# It's okay if this fails, the tools will use npx
|
||||
}
|
||||
|
||||
# Install @z_ai/coding-helper for MCP management
|
||||
log_info "Installing @z_ai/coding-helper..."
|
||||
npm install -g @z_ai/coding-helper 2>/dev/null || {
|
||||
log_warning "Global install failed, will use npx"
|
||||
}
|
||||
|
||||
log_success "MCP services installation completed"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Agent Definitions
|
||||
################################################################################
|
||||
|
||||
install_agents() {
|
||||
log_info "Installing custom agents..."
|
||||
|
||||
# Note: In a production setup, these would be downloaded from a repository
|
||||
# For now, we'll create placeholder agent definitions
|
||||
# The actual agent content should be copied from the source machine
|
||||
|
||||
log_info "Agent directory structure created at $AGENTS_DIR"
|
||||
log_warning "NOTE: You need to copy the actual agent .md files from the source machine"
|
||||
log_info "Run: scp -r user@source:~/.claude/agents/* $AGENTS_DIR/"
|
||||
|
||||
log_success "Agent structure ready"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Plugins Installation
|
||||
################################################################################
|
||||
|
||||
install_plugins() {
|
||||
log_info "Installing Claude Code plugins..."
|
||||
|
||||
# Initialize plugin registry
|
||||
local installed_plugins="$PLUGINS_DIR/installed_plugins.json"
|
||||
local known_marketplaces="$PLUGINS_DIR/known_marketplaces.json"
|
||||
|
||||
backup_file "$installed_plugins"
|
||||
backup_file "$known_marketplaces"
|
||||
|
||||
cat > "$known_marketplaces" << EOF
|
||||
{
|
||||
"marketplaces": {
|
||||
"https://github.com/anthropics/claude-plugins": {
|
||||
"displayName": "Official Claude Plugins",
|
||||
"contact": "support@anthropic.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Install GLM plugins via npx
|
||||
log_info "Installing GLM Coding Plan plugins..."
|
||||
|
||||
# Create plugin cache structure
|
||||
mkdir -p "$PLUGINS_DIR/cache/zai-coding-plugins"/{glm-plan-bug,glm-plan-usage}
|
||||
|
||||
# Note: Actual plugin installation happens via the @z_ai/coding-helper
|
||||
# which should already be installed
|
||||
|
||||
cat > "$installed_plugins" << EOF
|
||||
{
|
||||
"version": 2,
|
||||
"plugins": {
|
||||
"glm-plan-bug@zai-coding-plugins": [
|
||||
{
|
||||
"scope": "user",
|
||||
"installPath": "$PLUGINS_DIR/cache/zai-coding-plugins/glm-plan-bug/0.0.1",
|
||||
"version": "0.0.1",
|
||||
"installedAt": "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)",
|
||||
"lastUpdated": "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)"
|
||||
}
|
||||
],
|
||||
"glm-plan-usage@zai-coding-plugins": [
|
||||
{
|
||||
"scope": "user",
|
||||
"installPath": "$PLUGINS_DIR/cache/zai-coding-plugins/glm-plan-usage/0.0.1",
|
||||
"version": "0.0.1",
|
||||
"installedAt": "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)",
|
||||
"lastUpdated": "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
log_success "Plugins configured"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Download Agents from Repository
|
||||
################################################################################
|
||||
|
||||
download_agent_definitions() {
|
||||
log_info "Preparing to download agent definitions..."
|
||||
|
||||
# Create a temporary script to download agents
|
||||
# In production, this would download from a git repository or CDN
|
||||
|
||||
cat > /tmp/download_agents.sh << 'DOWNLOAD_SCRIPT'
|
||||
#!/bin/bash
|
||||
# This script would download agent definitions from a central repository
|
||||
# For now, it creates a template structure
|
||||
|
||||
AGENT_CATEGORIES=("engineering" "marketing" "product" "studio-operations" "project-management" "testing" "design" "bonus")
|
||||
|
||||
for category in "${AGENT_CATEGORIES[@]}"; do
|
||||
echo "Category: $category"
|
||||
# Agents would be downloaded here
|
||||
done
|
||||
DOWNLOAD_SCRIPT
|
||||
|
||||
chmod +x /tmp/download_agents.sh
|
||||
|
||||
log_info "Agent download script created at /tmp/download_agents.sh"
|
||||
log_warning "You need to provide the actual agent definitions"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Verification
|
||||
################################################################################
|
||||
|
||||
verify_installation() {
|
||||
log_info "Verifying installation..."
|
||||
|
||||
local errors=0
|
||||
|
||||
# Check directories
|
||||
[ -d "$CLAUDE_DIR" ] || { log_error "Claude directory missing"; errors=$((errors+1)); }
|
||||
[ -d "$AGENTS_DIR" ] || { log_error "Agents directory missing"; errors=$((errors+1)); }
|
||||
[ -d "$PLUGINS_DIR" ] || { log_error "Plugins directory missing"; errors=$((errors+1)); }
|
||||
|
||||
# Check files
|
||||
[ -f "$CLAUDE_DIR/settings.json" ] || { log_error "settings.json missing"; errors=$((errors+1)); }
|
||||
[ -f "$CLAUDE_DIR/settings.local.json" ] || { log_error "settings.local.json missing"; errors=$((errors+1)); }
|
||||
[ -f "$PLUGINS_DIR/installed_plugins.json" ] || { log_error "installed_plugins.json missing"; errors=$((errors+1)); }
|
||||
|
||||
# Check MCP availability
|
||||
if command -v npx &> /dev/null; then
|
||||
log_success "npx available for MCP tools"
|
||||
else
|
||||
log_error "npx not available"
|
||||
errors=$((errors+1))
|
||||
fi
|
||||
|
||||
if [ $errors -eq 0 ]; then
|
||||
log_success "Installation verification passed"
|
||||
return 0
|
||||
else
|
||||
log_error "Installation verification failed with $errors errors"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Main Installation Flow
|
||||
################################################################################
|
||||
|
||||
main() {
|
||||
echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${BLUE}║ Claude Code Customizations - Automated Installer ║${NC}"
|
||||
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
|
||||
# Parse command line arguments
|
||||
SKIP_AGENTS_COPY=false
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--skip-agents)
|
||||
SKIP_AGENTS_COPY=true
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --skip-agents Skip copying agent files (if already present)"
|
||||
echo " --help Show this help message"
|
||||
echo ""
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
log_error "Unknown option: $1"
|
||||
echo "Use --help for usage information"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Run installation steps
|
||||
check_prerequisites
|
||||
setup_directories
|
||||
setup_settings
|
||||
install_mcp_services
|
||||
install_agents
|
||||
install_plugins
|
||||
|
||||
# Verify installation
|
||||
if verify_installation; then
|
||||
echo ""
|
||||
log_success "═══════════════════════════════════════════════════════════"
|
||||
log_success "Installation completed successfully!"
|
||||
log_success "═══════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
log_info "Next steps:"
|
||||
echo " 1. Copy agent definitions from source machine:"
|
||||
echo " scp -r user@source:~/.claude/agents/* $AGENTS_DIR/"
|
||||
echo ""
|
||||
echo " 2. Restart Claude Code to load all customizations"
|
||||
echo ""
|
||||
echo " 3. Verify MCP tools are working by starting a new session"
|
||||
echo ""
|
||||
echo "Backup location: $BACKUP_DIR"
|
||||
echo ""
|
||||
else
|
||||
log_error "Installation failed. Please check the errors above."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
265
deprecated/sync-agents.sh
Executable file
265
deprecated/sync-agents.sh
Executable file
@@ -0,0 +1,265 @@
|
||||
#!/bin/bash
|
||||
# Claude Code Agents Sync Script
|
||||
# Syncs local agents with GitHub repository and backs up to Gitea
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Configuration
|
||||
AGENTS_DIR="${HOME}/.claude/agents"
|
||||
BACKUP_DIR="${AGENTS_DIR}.backup.$(date +%Y%m%d-%H%M%S)"
|
||||
GITHUB_REPO="https://github.com/contains-studio/agents"
|
||||
TEMP_DIR="/tmp/claude-agents-sync-$RANDOM"
|
||||
UPSTREAM_DIR="$TEMP_DIR/upstream"
|
||||
LOG_FILE="${AGENTS_DIR}/update.log"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
local level=$1
|
||||
shift
|
||||
local message="$@"
|
||||
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo "[$timestamp] [$level] $message" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Print colored message
|
||||
print_msg() {
|
||||
local color=$1
|
||||
shift
|
||||
echo -e "${color}$*${NC}"
|
||||
}
|
||||
|
||||
# Create backup
|
||||
create_backup() {
|
||||
print_msg "$BLUE" "📦 Creating backup..."
|
||||
if cp -r "$AGENTS_DIR" "$BACKUP_DIR"; then
|
||||
print_msg "$GREEN" "✓ Backup created: $BACKUP_DIR"
|
||||
log "INFO" "Backup created at $BACKUP_DIR"
|
||||
else
|
||||
print_msg "$RED" "✗ Failed to create backup"
|
||||
log "ERROR" "Backup creation failed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Download upstream agents
|
||||
download_upstream() {
|
||||
print_msg "$BLUE" "📥 Downloading agents from $GITHUB_REPO..."
|
||||
mkdir -p "$TEMP_DIR"
|
||||
|
||||
if command -v git &> /dev/null; then
|
||||
# Use git if available (faster)
|
||||
git clone --depth 1 "$GITHUB_REPO" "$UPSTREAM_DIR" 2>/dev/null || {
|
||||
print_msg "$RED" "✗ Failed to clone repository"
|
||||
log "ERROR" "Git clone failed"
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
# Fallback to wget/curl
|
||||
print_msg "$YELLOW" "⚠ Git not found, downloading archive..."
|
||||
local archive="$TEMP_DIR/agents.tar.gz"
|
||||
if command -v wget &> /dev/null; then
|
||||
wget -q "$GITHUB_REPO/archive/main.tar.gz" -O "$archive"
|
||||
elif command -v curl &> /dev/null; then
|
||||
curl -sL "$GITHUB_REPO/archive/main.tar.gz" -o "$archive"
|
||||
else
|
||||
print_msg "$RED" "✗ Need git, wget, or curl"
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$UPSTREAM_DIR"
|
||||
tar -xzf "$archive" -C "$UPSTREAM_DIR" --strip-components=1
|
||||
fi
|
||||
|
||||
print_msg "$GREEN" "✓ Downloaded upstream agents"
|
||||
log "INFO" "Downloaded agents from $GITHUB_REPO"
|
||||
}
|
||||
|
||||
# Compare and sync agents
|
||||
sync_agents() {
|
||||
print_msg "$BLUE" "🔄 Syncing agents..."
|
||||
|
||||
local new_agents=()
|
||||
local updated_agents=()
|
||||
local custom_agents=()
|
||||
|
||||
# Find all agent files in upstream
|
||||
while IFS= read -r upstream_file; do
|
||||
local rel_path="${upstream_file#$UPSTREAM_DIR/}"
|
||||
local local_file="$AGENTS_DIR/$rel_path"
|
||||
|
||||
if [[ ! -f "$local_file" ]]; then
|
||||
# New agent
|
||||
new_agents+=("$rel_path")
|
||||
mkdir -p "$(dirname "$local_file")"
|
||||
cp "$upstream_file" "$local_file"
|
||||
log "INFO" "Added new agent: $rel_path"
|
||||
elif ! diff -q "$upstream_file" "$local_file" &>/dev/null; then
|
||||
# Updated agent - check if customized
|
||||
if grep -q "CUSTOMIZED" "$local_file" 2>/dev/null || \
|
||||
[[ -f "${local_file}.local" ]]; then
|
||||
custom_agents+=("$rel_path")
|
||||
log "WARN" "Skipped customized agent: $rel_path"
|
||||
else
|
||||
updated_agents+=("$rel_path")
|
||||
cp "$upstream_file" "$local_file"
|
||||
log "INFO" "Updated agent: $rel_path"
|
||||
fi
|
||||
fi
|
||||
done < <(find "$UPSTREAM_DIR" -name "*.md" -type f)
|
||||
|
||||
# Report results
|
||||
echo ""
|
||||
print_msg "$GREEN" "✨ New agents (${#new_agents[@]}):"
|
||||
for agent in "${new_agents[@]}"; do
|
||||
echo " + $agent"
|
||||
done | head -20
|
||||
|
||||
echo ""
|
||||
print_msg "$YELLOW" "📝 Updated agents (${#updated_agents[@]}):"
|
||||
for agent in "${updated_agents[@]}"; do
|
||||
echo " ~ $agent"
|
||||
done | head -20
|
||||
|
||||
if [[ ${#custom_agents[@]} -gt 0 ]]; then
|
||||
echo ""
|
||||
print_msg "$YELLOW" "⚠️ Preserved custom agents (${#custom_agents[@]}):"
|
||||
for agent in "${custom_agents[@]}"; do
|
||||
echo " • $agent"
|
||||
done | head -20
|
||||
fi
|
||||
|
||||
# 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
|
||||
commit_to_git() {
|
||||
print_msg "$BLUE" "💾 Committing to git..."
|
||||
|
||||
cd "$AGENTS_DIR"
|
||||
|
||||
# Check if there are changes
|
||||
if git diff --quiet && git diff --cached --quiet; then
|
||||
print_msg "$YELLOW" "⚠️ No changes to commit"
|
||||
return
|
||||
fi
|
||||
|
||||
# Add all agents
|
||||
git add . -- '*.md'
|
||||
|
||||
# Commit with descriptive message
|
||||
local commit_msg="Update agents from upstream
|
||||
|
||||
$(date '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
Changes:
|
||||
- $(git diff --cached --name-only | wc -l) files updated
|
||||
- From: $GITHUB_REPO"
|
||||
|
||||
git commit -m "$commit_msg" 2>/dev/null || {
|
||||
print_msg "$YELLOW" "⚠️ Nothing to commit or git not configured"
|
||||
log "WARN" "Git commit skipped"
|
||||
return
|
||||
}
|
||||
|
||||
print_msg "$GREEN" "✓ Committed to local git"
|
||||
log "INFO" "Committed changes to git"
|
||||
}
|
||||
|
||||
# Push to Gitea
|
||||
push_to_gitea() {
|
||||
if [[ -z "${GITEA_REPO_URL:-}" ]]; then
|
||||
print_msg "$YELLOW" "⚠️ GITEA_REPO_URL not set, skipping push"
|
||||
print_msg "$YELLOW" " Set it with: export GITEA_REPO_URL='your-gitea-repo-url'"
|
||||
log "WARN" "GITEA_REPO_URL not set, push skipped"
|
||||
return
|
||||
fi
|
||||
|
||||
print_msg "$BLUE" "📤 Pushing to Gitea..."
|
||||
|
||||
cd "$AGENTS_DIR"
|
||||
|
||||
# Ensure remote exists
|
||||
if ! git remote get-url origin &>/dev/null; then
|
||||
git remote add origin "$GITEA_REPO_URL"
|
||||
fi
|
||||
|
||||
if git push -u origin main 2>/dev/null || git push -u origin master 2>/dev/null; then
|
||||
print_msg "$GREEN" "✓ Pushed to Gitea"
|
||||
log "INFO" "Pushed to Gitea: $GITEA_REPO_URL"
|
||||
else
|
||||
print_msg "$YELLOW" "⚠️ Push failed (check credentials/URL)"
|
||||
log "ERROR" "Push to Gitea failed"
|
||||
fi
|
||||
}
|
||||
|
||||
# Cleanup
|
||||
cleanup() {
|
||||
rm -rf "$TEMP_DIR"
|
||||
}
|
||||
|
||||
# Rollback function
|
||||
rollback() {
|
||||
print_msg "$RED" "🔄 Rolling back to backup..."
|
||||
if [[ -d "$BACKUP_DIR" ]]; then
|
||||
rm -rf "$AGENTS_DIR"
|
||||
mv "$BACKUP_DIR" "$AGENTS_DIR"
|
||||
print_msg "$GREEN" "✓ Rolled back successfully"
|
||||
log "INFO" "Rolled back to $BACKUP_DIR"
|
||||
else
|
||||
print_msg "$RED" "✗ No backup found!"
|
||||
log "ERROR" "Rollback failed - no backup"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
print_msg "$BLUE" "🚀 Claude Code Agents Sync"
|
||||
print_msg "$BLUE" "════════════════════════════"
|
||||
echo ""
|
||||
|
||||
trap cleanup EXIT
|
||||
trap rollback ERR
|
||||
|
||||
create_backup
|
||||
download_upstream
|
||||
sync_agents
|
||||
commit_to_git
|
||||
push_to_gitea
|
||||
|
||||
echo ""
|
||||
print_msg "$GREEN" "✅ Sync complete!"
|
||||
print_msg "$BLUE" "💾 Backup: $BACKUP_DIR"
|
||||
print_msg "$BLUE" "📋 Log: $LOG_FILE"
|
||||
echo ""
|
||||
print_msg "$YELLOW" "To rollback: rm -rf $AGENTS_DIR && mv $BACKUP_DIR $AGENTS_DIR"
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user