Add optional Claude Code installation with Z.AI API support
Features: - New install-claude-code.sh script for automated Claude Code installation - Z.AI API integration (GLM models: glm-4.5-air, glm-4.7) - Automated and manual installation modes - Supercharge.sh now offers to install Claude Code if not present - Updated README with comprehensive Claude Code installation guide Z.AI Models: - glm-4.5-air: Fast, efficient model (Haiku class) - glm-4.7: Powerful model (Sonnet/Opus class) Documentation: https://docs.z.ai/devpack/tool/claude
This commit is contained in:
56
README.md
56
README.md
@@ -77,6 +77,62 @@ cd SuperCharged-Claude-Code-Upgrade
|
||||
./supercharge.sh --dev-mode
|
||||
```
|
||||
|
||||
## Claude Code Installation (Optional)
|
||||
|
||||
If you don't have Claude Code installed yet, the supercharge script will offer to install it for you with **Z.AI API support**.
|
||||
|
||||
### What is Z.AI API?
|
||||
|
||||
Z.AI provides GLM (General Language Model) models that can be used with Claude Code:
|
||||
|
||||
- **glm-4.5-air** - Fast, efficient model (Haiku class)
|
||||
- **glm-4.7** - Powerful model (Sonnet/Opus class)
|
||||
|
||||
### Automated Installation
|
||||
|
||||
```bash
|
||||
# Install Claude Code with Z.AI API
|
||||
./install-claude-code.sh --auto
|
||||
|
||||
# You'll be prompted for your Z.AI API key
|
||||
# Get your API key from: https://docs.z.ai/devpack/tool/claude
|
||||
```
|
||||
|
||||
### Manual Installation
|
||||
|
||||
```bash
|
||||
# 1. Install Claude Code via npm
|
||||
npm install -g @anthropic-ai/claude-code
|
||||
|
||||
# 2. Configure Z.AI API
|
||||
# Create or edit ~/.claude/settings.json:
|
||||
{
|
||||
"env": {
|
||||
"ANTHROPIC_API_KEY": "your-zai-api-key-here",
|
||||
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
|
||||
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
|
||||
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7"
|
||||
}
|
||||
}
|
||||
|
||||
# 3. Start Claude Code
|
||||
claude
|
||||
|
||||
# 4. Check model status
|
||||
/status
|
||||
```
|
||||
|
||||
### Show Manual Instructions Only
|
||||
|
||||
```bash
|
||||
./install-claude-code.sh --manual
|
||||
```
|
||||
|
||||
### Documentation
|
||||
|
||||
- **Z.AI Official Docs**: https://docs.z.ai/devpack/tool/claude
|
||||
- **Claude Code Docs**: https://docs.anthropic.com/en/docs/claude-code/overview
|
||||
|
||||
## What Gets Installed
|
||||
|
||||
### Directory Structure
|
||||
|
||||
374
install-claude-code.sh
Executable file
374
install-claude-code.sh
Executable file
@@ -0,0 +1,374 @@
|
||||
#!/bin/bash
|
||||
################################################################################
|
||||
# Claude Code Installation Script with Z.AI API Support
|
||||
################################################################################
|
||||
# This script optionally installs Claude Code and configures it with Z.AI API
|
||||
# from https://docs.z.ai/devpack/tool/claude
|
||||
#
|
||||
# Features:
|
||||
# - Automated Claude Code installation via npm
|
||||
# - Z.AI API configuration (GLM models)
|
||||
# - Manual configuration instructions
|
||||
# - Model configuration for glm-4.5-air, glm-4.7
|
||||
#
|
||||
# Usage: ./install-claude-code.sh [options]
|
||||
# --auto Automatic installation with API key prompt
|
||||
# --manual Show manual installation steps only
|
||||
# --skip-install Skip Claude Code installation, just configure API
|
||||
################################################################################
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
MAGENTA='\033[0;35m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Claude config directory
|
||||
CLAUDE_DIR="${HOME}/.claude"
|
||||
|
||||
# Flags
|
||||
AUTO_MODE=true
|
||||
SKIP_INSTALL=false
|
||||
|
||||
################################################################################
|
||||
# Helper Functions
|
||||
################################################################################
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_step() {
|
||||
echo -e "${CYAN}${BOLD}==>${NC} ${BOLD}$1${NC}"
|
||||
}
|
||||
|
||||
print_banner() {
|
||||
echo -e "${MAGENTA}${BOLD}"
|
||||
cat << "EOF"
|
||||
╔═══════════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ ███████╗██╗ █████╗ ██████╗ ║
|
||||
║ ██╔════╝██║ ██╔══██╗██╔════╝ ║
|
||||
║ ███████╗██║ ███████║██║ ███╗ ║
|
||||
║ ╚════██║██║ ██╔══██║██║ ██║ ║
|
||||
║ ███████║███████╗██║ ██║╚██████╔╝ ║
|
||||
║ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ║
|
||||
║ ║
|
||||
║ + Z.AI API Integration (GLM Models) ║
|
||||
║ ║
|
||||
║ Installation Script ║
|
||||
║ ║
|
||||
╚═══════════════════════════════════════════════════════════════╝
|
||||
EOF
|
||||
echo -e "${NC}"
|
||||
echo ""
|
||||
echo -e "${CYAN}Official Documentation:${NC} https://docs.z.ai/devpack/tool/claude"
|
||||
echo ""
|
||||
}
|
||||
|
||||
check_nodejs() {
|
||||
log_step "Checking for Node.js 18+..."
|
||||
|
||||
if ! command -v node &> /dev/null; then
|
||||
log_error "Node.js not found!"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Node.js 18 or newer is required to install Claude Code.${NC}"
|
||||
echo ""
|
||||
echo "Please install Node.js first:"
|
||||
echo " - Ubuntu/Debian: sudo apt install nodejs npm"
|
||||
echo " - Arch: sudo pacman -S nodejs npm"
|
||||
echo " - macOS: brew install node"
|
||||
echo " - Or visit: https://nodejs.org/"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local node_version=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
|
||||
if [ "$node_version" -lt 18 ]; then
|
||||
log_error "Node.js version $node_version is too old!"
|
||||
echo "Node.js 18 or newer is required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_success "Node.js $(node -v) found"
|
||||
}
|
||||
|
||||
install_claude_code() {
|
||||
if [ "$SKIP_INSTALL" = true ]; then
|
||||
log_info "Skipping Claude Code installation (--skip-install flag)"
|
||||
return
|
||||
fi
|
||||
|
||||
log_step "Installing Claude Code..."
|
||||
|
||||
if command -v claude &> /dev/null; then
|
||||
local current_version=$(claude --version 2>/dev/null | head -1 || echo "unknown")
|
||||
log_info "Claude Code already installed: $current_version"
|
||||
echo ""
|
||||
read -p "Update to latest version? [y/N] " -n 1 -r
|
||||
echo ""
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
log_info "Updating Claude Code..."
|
||||
npm update -g @anthropic-ai/claude-code
|
||||
log_success "Claude Code updated"
|
||||
fi
|
||||
else
|
||||
log_info "Installing Claude Code via npm..."
|
||||
npm install -g @anthropic-ai/claude-code
|
||||
log_success "Claude Code installed"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
claude --version
|
||||
}
|
||||
|
||||
get_zai_api_key() {
|
||||
log_step "Z.AI API Configuration"
|
||||
echo ""
|
||||
echo -e "${CYAN}To use Claude Code with Z.AI's GLM models, you need an API key.${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Get your API key from:${NC} https://docs.z.ai/devpack/tool/claude"
|
||||
echo ""
|
||||
echo -e "${MAGENTA}Your API key format is: ${BOLD}your-api-key-here${NC}"
|
||||
echo ""
|
||||
|
||||
read -p "Enter your Z.AI API key (or press Enter to skip): " -r API_KEY
|
||||
echo ""
|
||||
|
||||
if [ -z "$API_KEY" ]; then
|
||||
log_warn "No API key provided. You can configure it later manually."
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
configure_zai_api() {
|
||||
local api_key="$1"
|
||||
|
||||
log_step "Configuring Z.AI API..."
|
||||
|
||||
# Ensure .claude directory exists
|
||||
mkdir -p "$CLAUDE_DIR"
|
||||
|
||||
# Backup existing settings
|
||||
if [ -f "$CLAUDE_DIR/settings.json" ]; then
|
||||
cp "$CLAUDE_DIR/settings.json" "$CLAUDE_DIR/settings.json.backup-$(date +%Y%m%d_%H%M%S)"
|
||||
log_info "Backed up existing settings.json"
|
||||
fi
|
||||
|
||||
# Create or update settings.json with Z.AI configuration
|
||||
if [ -f "$CLAUDE_DIR/settings.json" ]; then
|
||||
# Merge with existing settings
|
||||
python3 -c "
|
||||
import json
|
||||
import sys
|
||||
|
||||
try:
|
||||
with open('$CLAUDE_DIR/settings.json', 'r') as f:
|
||||
settings = json.load(f)
|
||||
except:
|
||||
settings = {}
|
||||
|
||||
# Add or update env section
|
||||
if 'env' not in settings:
|
||||
settings['env'] = {}
|
||||
|
||||
# Configure Z.AI GLM models
|
||||
settings['env']['ANTHROPIC_API_KEY'] = '$api_key'
|
||||
settings['env']['ANTHROPIC_DEFAULT_HAIKU_MODEL'] = 'glm-4.5-air'
|
||||
settings['env']['ANTHROPIC_DEFAULT_SONNET_MODEL'] = 'glm-4.7'
|
||||
settings['env']['ANTHROPIC_DEFAULT_OPUS_MODEL'] = 'glm-4.7'
|
||||
|
||||
with open('$CLAUDE_DIR/settings.json', 'w') as f:
|
||||
json.dump(settings, f, indent=2)
|
||||
" 2>/dev/null || {
|
||||
# Fallback if python3 not available
|
||||
cat > "$CLAUDE_DIR/settings.json" << EOF
|
||||
{
|
||||
"env": {
|
||||
"ANTHROPIC_API_KEY": "$api_key",
|
||||
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
|
||||
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
|
||||
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
}
|
||||
else
|
||||
# Create new settings.json
|
||||
cat > "$CLAUDE_DIR/settings.json" << EOF
|
||||
{
|
||||
"env": {
|
||||
"ANTHROPIC_API_KEY": "$api_key",
|
||||
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
|
||||
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
|
||||
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
|
||||
log_success "Z.AI API configured"
|
||||
log_info "API key set to: ${api_key:0:10}...${api_key: -4}"
|
||||
}
|
||||
|
||||
show_manual_instructions() {
|
||||
echo ""
|
||||
echo -e "${CYAN}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${CYAN}${BOLD} Manual Installation Instructions${NC}"
|
||||
echo -e "${CYAN}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
echo -e "${GREEN}Step 1: Install Claude Code${NC}"
|
||||
echo "─────────────────────────────────────────────────────────────────"
|
||||
echo ""
|
||||
echo " # Prerequisites: Node.js 18 or newer"
|
||||
echo " npm install -g @anthropic-ai/claude-code"
|
||||
echo ""
|
||||
echo " # Verify installation"
|
||||
echo " claude --version"
|
||||
echo ""
|
||||
echo -e "${GREEN}Step 2: Get Z.AI API Key${NC}"
|
||||
echo "─────────────────────────────────────────────────────────────────"
|
||||
echo ""
|
||||
echo " Visit: https://docs.z.ai/devpack/tool/claude"
|
||||
echo " Sign up and get your API key"
|
||||
echo ""
|
||||
echo -e "${GREEN}Step 3: Configure Z.AI API${NC}"
|
||||
echo "─────────────────────────────────────────────────────────────────"
|
||||
echo ""
|
||||
echo " Create or edit ~/.claude/settings.json:"
|
||||
echo ""
|
||||
echo -e "${YELLOW} {${NC}"
|
||||
echo -e "${YELLOW} \"env\": {${NC}"
|
||||
echo -e "${YELLOW} \"ANTHROPIC_API_KEY\": \"your-zai-api-key-here\",${NC}"
|
||||
echo -e "${YELLOW} \"ANTHROPIC_DEFAULT_HAIKU_MODEL\": \"glm-4.5-air\",${NC}"
|
||||
echo -e "${YELLOW} \"ANTHROPIC_DEFAULT_SONNET_MODEL\": \"glm-4.7\",${NC}"
|
||||
echo -e "${YELLOW} \"ANTHROPIC_DEFAULT_OPUS_MODEL\": \"glm-4.7\"${NC}"
|
||||
echo -e "${YELLOW} }${NC}"
|
||||
echo -e "${YELLOW} }${NC}"
|
||||
echo ""
|
||||
echo -e "${GREEN}Step 4: Start Claude Code${NC}"
|
||||
echo "─────────────────────────────────────────────────────────────────"
|
||||
echo ""
|
||||
echo " cd your-project-directory"
|
||||
echo " claude"
|
||||
echo ""
|
||||
echo " # Check model status with: /status"
|
||||
echo ""
|
||||
echo -e "${GREEN}Available GLM Models${NC}"
|
||||
echo "─────────────────────────────────────────────────────────────────"
|
||||
echo ""
|
||||
echo " • glm-4.5-air - Fast, efficient model (Haiku class)"
|
||||
echo " • glm-4.7 - Powerful model (Sonnet/Opus class)"
|
||||
echo ""
|
||||
echo -e "${CYAN}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
print_success_summary() {
|
||||
echo ""
|
||||
echo -e "${GREEN}${BOLD}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${GREEN}${BOLD}║ Installation Complete! ║${NC}"
|
||||
echo -e "${GREEN}${BOLD}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
echo -e "${BOLD}Claude Code is ready with Z.AI GLM models!${NC}"
|
||||
echo ""
|
||||
echo -e "${CYAN}Quick Start:${NC}"
|
||||
echo -e " 1. ${YELLOW}cd your-project-directory${NC}"
|
||||
echo -e " 2. ${YELLOW}claude${NC}"
|
||||
echo -e " 3. ${YELLOW}/status${NC} - Check current model status"
|
||||
echo ""
|
||||
echo -e "${CYAN}Model Configuration:${NC}"
|
||||
echo -e " • ${GREEN}Haiku class${NC}: glm-4.5-air (fast, efficient)"
|
||||
echo -e " • ${GREEN}Sonnet class${NC}: glm-4.7 (powerful)"
|
||||
echo -e " • ${GREEN}Opus class${NC}: glm-4.7 (most powerful)"
|
||||
echo ""
|
||||
echo -e "${CYAN}Configuration File:${NC}"
|
||||
echo -e " ${YELLOW}~/.claude/settings.json${NC}"
|
||||
echo ""
|
||||
echo -e "${CYAN}Documentation:${NC}"
|
||||
echo -e " ${YELLOW}https://docs.z.ai/devpack/tool/claude${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Main Installation
|
||||
################################################################################
|
||||
|
||||
main() {
|
||||
print_banner
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--auto)
|
||||
AUTO_MODE=true
|
||||
shift
|
||||
;;
|
||||
--manual)
|
||||
AUTO_MODE=false
|
||||
shift
|
||||
;;
|
||||
--skip-install)
|
||||
SKIP_INSTALL=true
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [options]"
|
||||
echo " --auto Automatic installation with API key prompt (default)"
|
||||
echo " --manual Show manual installation steps only"
|
||||
echo " --skip-install Skip Claude Code installation, just configure API"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
log_error "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Manual mode - just show instructions
|
||||
if [ "$AUTO_MODE" = false ]; then
|
||||
show_manual_instructions
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Automatic mode
|
||||
check_nodejs
|
||||
install_claude_code
|
||||
|
||||
# Get and configure API key
|
||||
if get_zai_api_key; then
|
||||
configure_zai_api "$API_KEY"
|
||||
print_success_summary
|
||||
else
|
||||
echo ""
|
||||
log_info "You can configure the API key later by:"
|
||||
echo " 1. Editing ~/.claude/settings.json"
|
||||
echo " 2. Or running this script again"
|
||||
echo ""
|
||||
show_manual_instructions
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
@@ -13,10 +13,16 @@
|
||||
# - Custom hooks for session management
|
||||
# - MCP servers integration
|
||||
# - Plugin marketplace setup
|
||||
# - Optional Claude Code installation with Z.AI API support
|
||||
#
|
||||
# Usage: ./supercharge.sh [options]
|
||||
# --skip-deps Skip dependency installation
|
||||
# --dev-mode Development mode (verbose output)
|
||||
#
|
||||
# For Claude Code installation: ./install-claude-code.sh [options]
|
||||
# --auto Automatic installation with API key prompt (default)
|
||||
# --manual Show manual installation steps only
|
||||
# --skip-install Skip Claude Code installation, just configure API
|
||||
################################################################################
|
||||
|
||||
set -e
|
||||
@@ -97,12 +103,48 @@ check_claude_code() {
|
||||
log_step "Checking for Claude Code installation..."
|
||||
|
||||
if ! command -v claude &> /dev/null; then
|
||||
log_error "Claude Code CLI not found!"
|
||||
echo "Please install Claude Code first: https://claude.com/claude-code"
|
||||
exit 1
|
||||
log_warn "Claude Code CLI not found!"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Claude Code is required to use these customizations.${NC}"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " 1. Install Claude Code with Z.AI API support (recommended)"
|
||||
echo " 2. Install manually later"
|
||||
echo " 3. Exit to install first"
|
||||
echo ""
|
||||
read -p "Choose option [1/2/3]: " -n 1 -r choice
|
||||
echo ""
|
||||
|
||||
case $choice in
|
||||
1)
|
||||
log_info "Running Claude Code installer..."
|
||||
bash "$SCRIPT_DIR/install-claude-code.sh" --auto
|
||||
if ! command -v claude &> /dev/null; then
|
||||
log_error "Claude Code installation failed. Please install manually."
|
||||
exit 1
|
||||
fi
|
||||
log_success "Claude Code installed successfully"
|
||||
;;
|
||||
2)
|
||||
log_warn "Skipping Claude Code installation"
|
||||
log_info "You can install it later with: ./install-claude-code.sh"
|
||||
return 1
|
||||
;;
|
||||
3)
|
||||
log_info "Please install Claude Code first:"
|
||||
echo " npm install -g @anthropic-ai/claude-code"
|
||||
echo " Or run: ./install-claude-code.sh"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
log_error "Invalid choice"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
log_success "Claude Code found: $(claude --version 2>/dev/null || echo 'installed')"
|
||||
return 0
|
||||
}
|
||||
|
||||
backup_existing_config() {
|
||||
@@ -420,7 +462,15 @@ main() {
|
||||
done
|
||||
|
||||
# Run installation steps
|
||||
check_claude_code
|
||||
if ! check_claude_code; then
|
||||
log_info "Customizations installed. Install Claude Code to use them."
|
||||
echo ""
|
||||
echo -e "${CYAN}Install Claude Code:${NC}"
|
||||
echo " npm install -g @anthropic-ai/claude-code"
|
||||
echo " Or run: ./install-claude-code.sh"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
backup_existing_config
|
||||
install_dependencies
|
||||
install_skills
|
||||
|
||||
Reference in New Issue
Block a user