71 lines
2.3 KiB
Bash
Executable File
71 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
echo "🤖 Installing Claude Code CLI..."
|
|
|
|
# Check if already installed
|
|
if command -v claude >/dev/null 2>&1; then
|
|
echo "✅ Claude Code already installed"
|
|
claude --version || echo "Claude Code version check failed"
|
|
exit 0
|
|
fi
|
|
|
|
# Ensure npm is available
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
|
|
if ! command -v npm >/dev/null 2>&1; then
|
|
echo "❌ npm not found - Node.js installation required"
|
|
exit 1
|
|
fi
|
|
|
|
echo "📥 Installing Claude Code CLI via npm..."
|
|
# Use correct Claude Code package name
|
|
npm install -g @anthropic-ai/claude-code@latest || {
|
|
echo "⚠️ Official Claude package not available, trying alternatives..."
|
|
npm install -g @anthropic-ai/claude-cli@latest || npm install -g claude-ai-cli || echo "❌ All Claude installations failed"
|
|
}
|
|
|
|
# Verify installation
|
|
if command -v claude >/dev/null 2>&1; then
|
|
echo "✅ Claude Code installed successfully!"
|
|
echo "🔧 Run 'claude auth login' to authenticate"
|
|
echo "💡 Use 'claude chat' for interactive assistance"
|
|
echo "💡 Use 'claude edit <file>' to edit files with AI"
|
|
|
|
# Create helper script
|
|
mkdir -p /home/coder/bin
|
|
cat > /home/coder/bin/claude-help << 'CLAUDE_HELP_END'
|
|
#!/bin/bash
|
|
echo "🤖 Claude Code AI Assistant"
|
|
echo "=========================="
|
|
echo ""
|
|
echo "Authentication:"
|
|
echo " claude auth login # Authenticate with Anthropic"
|
|
echo " claude auth logout # Sign out"
|
|
echo " claude auth whoami # Check current user"
|
|
echo ""
|
|
echo "Interactive Chat:"
|
|
echo " claude chat # Start interactive session"
|
|
echo " claude chat 'question' # Single question"
|
|
echo ""
|
|
echo "File Editing:"
|
|
echo " claude edit file.py # AI-powered file editing"
|
|
echo " claude edit --help # Edit command options"
|
|
echo ""
|
|
echo "Code Analysis:"
|
|
echo " claude analyze . # Analyze current directory"
|
|
echo " claude review file.py # Code review"
|
|
echo ""
|
|
echo "Project Operations:"
|
|
echo " claude init # Initialize Claude in project"
|
|
echo " claude status # Show project status"
|
|
echo ""
|
|
echo "💡 For full documentation: https://docs.anthropic.com/claude/docs"
|
|
CLAUDE_HELP_END
|
|
chmod +x /home/coder/bin/claude-help
|
|
|
|
echo "💡 Run 'claude-help' for quick reference"
|
|
else
|
|
echo "❌ Claude Code installation failed"
|
|
exit 1
|
|
fi |