mirror of
https://github.com/anthropics/claude-code.git
synced 2026-01-30 04:02:03 +00:00
Change approach from separate PreTeleport/PostTeleport hook events to using SessionStart with a `teleport` matcher. This is cleaner since teleporting to CLI starts a new session anyway. SessionStart matchers: - `*` - All session starts - `teleport` - Only teleported sessions (web → CLI) - `fresh` - Only fresh sessions (not teleported) Removes pre-teleport.sh example since there's no pre-teleport hook.
53 lines
1.5 KiB
Bash
53 lines
1.5 KiB
Bash
#!/bin/bash
|
|
# Example SessionStart hook with "teleport" matcher for setting up environment
|
|
# after teleporting from web to CLI. This script pulls changes, installs
|
|
# dependencies, and starts the dev server.
|
|
|
|
set -euo pipefail
|
|
|
|
# Navigate to project directory
|
|
cd "$CLAUDE_PROJECT_DIR" || exit 0
|
|
|
|
echo "Setting up environment after teleport..."
|
|
|
|
# Pull latest changes if in a git repository
|
|
if [ -d ".git" ]; then
|
|
current_branch=$(git branch --show-current)
|
|
echo "🔄 Pulling latest changes for branch: $current_branch"
|
|
git pull origin "$current_branch" 2>/dev/null || echo "Could not pull (may be offline or no upstream)"
|
|
fi
|
|
|
|
# Install dependencies based on project type
|
|
if [ -f "package.json" ]; then
|
|
echo "📦 Installing Node.js dependencies..."
|
|
npm install --silent 2>/dev/null || npm install
|
|
fi
|
|
|
|
if [ -f "requirements.txt" ]; then
|
|
echo "🐍 Installing Python dependencies..."
|
|
pip install -r requirements.txt --quiet 2>/dev/null || pip install -r requirements.txt
|
|
fi
|
|
|
|
if [ -f "Cargo.toml" ]; then
|
|
echo "🦀 Building Rust project..."
|
|
cargo build 2>/dev/null || true
|
|
fi
|
|
|
|
# Start development server if available
|
|
if [ -f "package.json" ]; then
|
|
# Check for common dev server scripts
|
|
if grep -q '"dev:staging"' package.json; then
|
|
echo "🚀 Starting staging dev server..."
|
|
npm run dev:staging &
|
|
elif grep -q '"dev"' package.json; then
|
|
echo "🚀 Starting dev server..."
|
|
npm run dev &
|
|
elif grep -q '"start"' package.json; then
|
|
echo "🚀 Starting server..."
|
|
npm start &
|
|
fi
|
|
fi
|
|
|
|
echo "✅ Teleport complete! Environment ready."
|
|
exit 0
|