mirror of
https://github.com/anthropics/claude-code.git
synced 2026-04-29 00:56:58 +00:00
refactor: Use SessionStart teleport matcher instead of separate hooks
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.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Example PostTeleport hook for setting up environment after teleporting
|
||||
# This script pulls changes, installs dependencies, and starts dev server
|
||||
# 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
|
||||
|
||||
@@ -14,12 +15,6 @@ 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)"
|
||||
|
||||
# Check for stashed changes from pre-teleport
|
||||
if git stash list | grep -q "pre-teleport-stash"; then
|
||||
echo "📦 Restoring stashed changes from pre-teleport..."
|
||||
git stash pop || echo "Could not restore stash (may have conflicts)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install dependencies based on project type
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Example PreTeleport hook for preparing environment before teleporting
|
||||
# This script stashes uncommitted changes and saves state for restoration
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Navigate to project directory
|
||||
cd "$CLAUDE_PROJECT_DIR" || exit 0
|
||||
|
||||
echo "Preparing for teleport..."
|
||||
|
||||
# Check if we're in a git repository
|
||||
if [ ! -d ".git" ]; then
|
||||
echo "Not a git repository, skipping pre-teleport preparation"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Stash uncommitted changes before teleporting
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "📦 Stashing uncommitted changes before teleport..."
|
||||
git stash push -m "pre-teleport-stash-$(date +%s)"
|
||||
echo "Changes stashed successfully"
|
||||
else
|
||||
echo "No uncommitted changes to stash"
|
||||
fi
|
||||
|
||||
# Save current branch state for post-teleport restoration
|
||||
mkdir -p .claude
|
||||
echo "$(git branch --show-current)" > .claude/.teleport-state
|
||||
echo "Current branch saved: $(cat .claude/.teleport-state)"
|
||||
|
||||
echo "Pre-teleport preparation complete"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user