-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclaude-code-wrapper.sh
More file actions
executable file
·66 lines (58 loc) · 1.74 KB
/
Copy pathclaude-code-wrapper.sh
File metadata and controls
executable file
·66 lines (58 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Claude Code wrapper with StackMemory integration
# Usage: Add alias to ~/.zshrc: alias claude='~/Dev/stackmemory/scripts/claude-code-wrapper.sh'
# Check for auto-sync flag
AUTO_SYNC=false
SYNC_INTERVAL=5
for arg in "$@"; do
case $arg in
--auto-sync)
AUTO_SYNC=true
shift
;;
--sync-interval=*)
SYNC_INTERVAL="${arg#*=}"
shift
;;
esac
done
# Start Linear auto-sync in background if requested
SYNC_PID=""
if [ "$AUTO_SYNC" = true ] && [ -n "$LINEAR_API_KEY" ]; then
echo "🔄 Starting Linear auto-sync (${SYNC_INTERVAL}min intervals)..."
(
while true; do
sleep $((SYNC_INTERVAL * 60))
if [ -d ".stackmemory" ]; then
stackmemory linear sync --quiet 2>/dev/null || true
fi
done
) &
SYNC_PID=$!
fi
cleanup() {
echo "📝 Saving StackMemory context..."
# Kill auto-sync if running
if [ -n "$SYNC_PID" ] && kill -0 $SYNC_PID 2>/dev/null; then
echo "🛑 Stopping auto-sync..."
kill $SYNC_PID 2>/dev/null || true
fi
# Check if in a git repo with stackmemory
if [ -d ".stackmemory" ] && [ -f "stackmemory.json" ]; then
# Save current context (without sync)
stackmemory status 2>/dev/null || true
echo "✅ StackMemory context saved"
fi
}
# Set trap for exit signals
trap cleanup EXIT INT TERM
# Run Claude Code (try multiple possible command names)
if command -v claude-code &> /dev/null; then
claude-code "$@"
elif command -v claude &> /dev/null; then
claude "$@"
else
echo "❌ Claude Code not found. Please install it first."
echo " Visit: https://github.com/anthropics/claude-code"
exit 1
fi