- Created autonomous-planner.md agent file with context-aware workflow suggestions - Implemented safety-rules.json for safe/risky operation classification - Updated all installers (auto-installer.sh, interactive-install-claude.sh) to include autonomous planner - Updated agent counts: 40→41 total agents, 8→9 PROACTIVELY coordinators, 4→5 Bonus agents - Updated documentation (README.md, MASTER-PROMPT.md, extra-tools/README.md) - Added test-autonomous-planner.sh TDD test suite - Auto-triggers on: code changes, tests passing, deployments, safe task execution
412 lines
12 KiB
Bash
412 lines
12 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
CLAUDE_DIR="$HOME/.claude"
|
|
BACKUP_DIR="$HOME/.claude.backup.$(date +%Y%m%d_%H%M%S)"
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
CYAN='\033[0;36m'
|
|
BOLD='\033[1m'
|
|
NC='\033[0m'
|
|
|
|
################################################################################
|
|
# Helper Functions
|
|
################################################################################
|
|
|
|
print_header() {
|
|
clear
|
|
echo -e "${CYAN}═════════════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${BOLD}${CYAN} Claude Code GLM Suite - Auto Installer${NC}"
|
|
echo -e "${CYAN}═════════════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
}
|
|
|
|
print_step_header() {
|
|
local step="$1"
|
|
local title="$2"
|
|
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
echo -e "${BOLD} Step $step: $title${NC}"
|
|
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
echo ""
|
|
}
|
|
|
|
log_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_success() {
|
|
echo -e "${GREEN}[✓]${NC} $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[✗]${NC} $1"
|
|
}
|
|
|
|
log_warning() {
|
|
echo -e "${YELLOW}[!]${NC} $1"
|
|
}
|
|
|
|
confirm() {
|
|
local prompt="$1"
|
|
local default="$2"
|
|
local response
|
|
|
|
if [ "$default" = "Y" ]; then
|
|
read -p "$prompt [Y/n]: " response
|
|
response=${response:-Y}
|
|
else
|
|
read -p "$prompt [y/N]: " response
|
|
response=${response:-N}
|
|
fi
|
|
|
|
[[ "$response" =~ ^[Yy]$ ]]
|
|
}
|
|
|
|
################################################################################
|
|
# Step 1: Check Claude Code Installation Status
|
|
################################################################################
|
|
|
|
check_claude_installation() {
|
|
if command -v claude-code &> /dev/null; then
|
|
echo "INSTALLED"
|
|
return 0
|
|
else
|
|
echo "NOT_INSTALLED"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
step1_check_installation() {
|
|
print_step_header 1 "Check Claude Code Installation Status"
|
|
|
|
local status
|
|
status=$(check_claude_installation)
|
|
|
|
if [ "$status" = "INSTALLED" ]; then
|
|
log_success "Claude Code is installed"
|
|
echo ""
|
|
claude-code --version 2>/dev/null || log_info "Version: unknown"
|
|
echo ""
|
|
return 0
|
|
else
|
|
log_warning "Claude Code is not installed"
|
|
echo ""
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
################################################################################
|
|
# Step 2: Install or Configure with npx @z_ai/coding-helper
|
|
################################################################################
|
|
|
|
step2_install_or_configure() {
|
|
print_step_header 2 "Install or Configure Claude Code"
|
|
|
|
local claude_installed
|
|
claude_installed=$(check_claude_installation)
|
|
|
|
if [ "$claude_installed" = "INSTALLED" ]; then
|
|
log_info "Claude Code is already installed"
|
|
echo ""
|
|
log_info "You can configure it to use Z.AI GLM 4.7 Model for enhanced features:"
|
|
echo " • Usage tracking and analytics"
|
|
echo " • Feedback system"
|
|
echo " • Promotions and rewards"
|
|
echo ""
|
|
|
|
if confirm "Do you want to configure for Z.AI GLM 4.7 Model?" "Y"; then
|
|
log_info "Configuring Claude Code with Z.AI GLM 4.7..."
|
|
echo ""
|
|
|
|
if command -v npx &> /dev/null; then
|
|
log_info "Running: npx @z_ai/coding-helper init"
|
|
echo ""
|
|
|
|
if npx @z_ai/coding-helper init; then
|
|
log_success "Z.AI GLM 4.7 configuration completed"
|
|
echo ""
|
|
return 0
|
|
else
|
|
log_error "Z.AI configuration failed. You can configure manually later."
|
|
echo ""
|
|
return 1
|
|
fi
|
|
else
|
|
log_error "npx is not available. Please install Node.js first."
|
|
echo ""
|
|
log_info "Install Node.js: https://nodejs.org/"
|
|
echo ""
|
|
return 1
|
|
fi
|
|
else
|
|
log_info "Skipping Z.AI configuration"
|
|
echo ""
|
|
return 0
|
|
fi
|
|
else
|
|
log_info "Claude Code is not installed"
|
|
echo ""
|
|
log_info "Installing Claude Code using npx @z_ai/coding-helper..."
|
|
echo ""
|
|
|
|
if command -v npx &> /dev/null; then
|
|
log_info "Running: npx @z_ai/coding-helper init"
|
|
echo ""
|
|
|
|
if npx @z_ai/coding-helper init; then
|
|
log_success "Claude Code installation completed"
|
|
echo ""
|
|
|
|
if check_claude_installation &> /dev/null; then
|
|
claude-code --version 2>/dev/null || log_info "Version: unknown"
|
|
fi
|
|
echo ""
|
|
return 0
|
|
else
|
|
log_error "Claude Code installation failed"
|
|
echo ""
|
|
log_info "Please visit https://claude.ai/download to install manually"
|
|
echo ""
|
|
return 1
|
|
fi
|
|
else
|
|
log_error "npx is not available. Please install Node.js first."
|
|
echo ""
|
|
log_info "Install Node.js: https://nodejs.org/"
|
|
echo ""
|
|
return 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
################################################################################
|
|
# Step 3: Install All Modifications
|
|
################################################################################
|
|
|
|
backup_config() {
|
|
if [ -d "$CLAUDE_DIR" ]; then
|
|
log_info "Creating backup at: $BACKUP_DIR"
|
|
cp -r "$CLAUDE_DIR" "$BACKUP_DIR" 2>/dev/null || true
|
|
log_success "Backup created"
|
|
fi
|
|
}
|
|
|
|
create_directories() {
|
|
log_info "Creating directory structure..."
|
|
|
|
mkdir -p "$CLAUDE_DIR"/{skills,agents,plugins/cache,plugins/marketplaces,hooks,debug,file-history,paste-cache,projects,session-env,shell-snapshots,todos}
|
|
mkdir -p "$CLAUDE_DIR/agents"/{engineering,marketing,product,studio-operations,project-management,testing,design,bonus}
|
|
|
|
log_success "Directories created"
|
|
}
|
|
|
|
install_agents() {
|
|
log_info "Installing 41 specialized agents..."
|
|
|
|
local source_agents="$SCRIPT_DIR/agents"
|
|
|
|
if [ -d "$source_agents" ]; then
|
|
for category in engineering marketing product studio-operations project-management testing design bonus; do
|
|
if [ -d "$source_agents/$category" ]; then
|
|
cp -r "$source_agents/$category"/*.md "$CLAUDE_DIR/agents/$category/" 2>/dev/null || true
|
|
fi
|
|
done
|
|
log_success "Agents installed"
|
|
else
|
|
log_warning "Agent source directory not found at $source_agents"
|
|
fi
|
|
}
|
|
|
|
install_mcp_tools() {
|
|
log_info "Installing MCP tools..."
|
|
|
|
local source_mcp="$SCRIPT_DIR/mcp"
|
|
|
|
if [ -d "$source_mcp" ]; then
|
|
mkdir -p "$CLAUDE_DIR/skills"
|
|
cp -r "$source_mcp"/* "$CLAUDE_DIR/skills/" 2>/dev/null || true
|
|
log_success "MCP tools installed"
|
|
else
|
|
log_warning "MCP source directory not found at $source_mcp"
|
|
fi
|
|
}
|
|
|
|
install_skills() {
|
|
log_info "Installing skills..."
|
|
|
|
local source_skills="$SCRIPT_DIR/skills"
|
|
|
|
if [ -d "$source_skills" ]; then
|
|
cp -r "$source_skills"/* "$CLAUDE_DIR/skills/" 2>/dev/null || true
|
|
log_success "Skills installed"
|
|
else
|
|
log_warning "Skills source directory not found at $source_skills"
|
|
fi
|
|
}
|
|
|
|
install_plugins() {
|
|
log_info "Installing Z.AI plugins..."
|
|
|
|
local source_plugins="$SCRIPT_DIR/plugins"
|
|
|
|
if [ -d "$source_plugins" ]; then
|
|
mkdir -p "$CLAUDE_DIR/plugins"
|
|
cp -r "$source_plugins"/* "$CLAUDE_DIR/plugins/" 2>/dev/null || true
|
|
log_success "Plugins installed"
|
|
else
|
|
log_warning "Plugins source directory not found at $source_plugins"
|
|
fi
|
|
}
|
|
|
|
install_hooks() {
|
|
log_info "Installing hooks..."
|
|
|
|
local source_hooks="$SCRIPT_DIR/hooks"
|
|
|
|
if [ -d "$source_hooks" ]; then
|
|
cp -r "$source_hooks"/* "$CLAUDE_DIR/hooks/" 2>/dev/null || true
|
|
log_success "Hooks installed"
|
|
else
|
|
log_warning "Hooks source directory not found at $source_hooks"
|
|
fi
|
|
}
|
|
|
|
install_all_modifications() {
|
|
print_step_header 3 "Install All Modifications"
|
|
|
|
backup_config
|
|
create_directories
|
|
install_agents
|
|
install_mcp_tools
|
|
install_skills
|
|
install_plugins
|
|
install_hooks
|
|
|
|
echo ""
|
|
log_success "All modifications installed successfully"
|
|
echo ""
|
|
}
|
|
|
|
verify_installation() {
|
|
local errors=0
|
|
|
|
if [ ! -d "$CLAUDE_DIR/agents" ]; then
|
|
log_error "Agents directory not found"
|
|
errors=$((errors+1))
|
|
fi
|
|
|
|
if [ ! -d "$CLAUDE_DIR/skills" ]; then
|
|
log_error "Skills directory not found"
|
|
errors=$((errors+1))
|
|
fi
|
|
|
|
if [ ! -d "$CLAUDE_DIR/plugins" ]; then
|
|
log_error "Plugins directory not found"
|
|
errors=$((errors+1))
|
|
fi
|
|
|
|
if [ $errors -eq 0 ]; then
|
|
log_success "Installation verified"
|
|
return 0
|
|
else
|
|
log_error "Installation verification failed"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
################################################################################
|
|
# Step 4: Launch Claude Code
|
|
################################################################################
|
|
|
|
step4_launch_claude_code() {
|
|
print_step_header 4 "Launch Claude Code"
|
|
|
|
echo "Installation complete!"
|
|
echo ""
|
|
echo "Your Claude Code environment has been upgraded with:"
|
|
echo " • 41 specialized agents including Superpowers (TDD) and Autonomous Planner"
|
|
echo " • MCP tools for vision analysis, web search, and GitHub integration"
|
|
echo " • Custom skills and plugins"
|
|
echo " • Z.AI GLM 4.7 Model support"
|
|
echo ""
|
|
|
|
if confirm "Start Claude Code now?" "Y"; then
|
|
log_info "Launching Claude Code..."
|
|
echo ""
|
|
|
|
if command -v claude-code &> /dev/null; then
|
|
exec claude-code
|
|
else
|
|
log_error "Claude Code not found. Please install it first."
|
|
return 1
|
|
fi
|
|
else
|
|
log_info "You can start Claude Code later by running: claude-code"
|
|
echo ""
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
################################################################################
|
|
# Command Line Interface for Testing
|
|
################################################################################
|
|
|
|
if [ "$1" = "--check-install" ]; then
|
|
check_claude_installation | tr -d '[:space:]'
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$1" = "--install-modifications" ]; then
|
|
install_all_modifications
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$1" = "--verify" ]; then
|
|
verify_installation >/dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
echo "SUCCESS"
|
|
exit 0
|
|
else
|
|
echo "FAILED"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
################################################################################
|
|
# Main Installation Flow
|
|
################################################################################
|
|
|
|
main() {
|
|
print_header
|
|
|
|
echo -e "${BOLD}Welcome to Claude Code GLM Suite Auto Installer!${NC}"
|
|
echo ""
|
|
echo "This installer will guide you through a 4-step process:"
|
|
echo ""
|
|
echo -e " ${GREEN}1.${NC} Check Claude Code installation status"
|
|
echo -e " ${GREEN}2.${NC} Install or configure Claude Code with Z.AI GLM 4.7"
|
|
echo -e " ${GREEN}3.${NC} Install all modifications (agents, MCPs, skills)"
|
|
echo -e " ${GREEN}4.${NC} Start your upgraded Claude Code"
|
|
echo ""
|
|
|
|
if ! confirm "Continue with installation?" "Y"; then
|
|
echo "Installation cancelled."
|
|
exit 0
|
|
fi
|
|
|
|
echo ""
|
|
|
|
step1_check_installation
|
|
step2_install_or_configure
|
|
install_all_modifications
|
|
verify_installation
|
|
step4_launch_claude_code
|
|
}
|
|
|
|
main "$@"
|