claude-meta/scripts/install.sh

87 lines
1.8 KiB
Bash

#!/bin/bash
# install.sh — Link claude-meta config into ~/.claude/
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
SOURCE_DIR="$REPO_ROOT/home-claude"
CLAUDE_DIR="$HOME/.claude"
# Verify source exists
if [ ! -d "$SOURCE_DIR" ]; then
echo "ERROR: home-claude/ not found at $SOURCE_DIR"
exit 1
fi
# Ensure ~/.claude/ is a real directory
if [ -L "$CLAUDE_DIR" ]; then
echo "ERROR: ~/.claude/ is a symlink. It must be a real directory."
echo "Claude Code Bug #764: symlinked ~/.claude/ breaks file detection."
exit 1
fi
mkdir -p "$CLAUDE_DIR"
echo "Installing claude-meta config..."
echo " Source: $SOURCE_DIR"
echo " Target: $CLAUDE_DIR"
echo ""
# File symlinks
for file in CLAUDE.md settings.json; do
src="$SOURCE_DIR/$file"
dst="$CLAUDE_DIR/$file"
[ ! -f "$src" ] && echo " SKIP: $file" && continue
# Remove existing
[ -e "$dst" ] || [ -L "$dst" ] && rm -f "$dst"
ln -s "$src" "$dst"
echo " SYMLINK: $file -> $src"
done
# Directory symlinks
for dir in skills rules; do
src="$SOURCE_DIR/$dir"
dst="$CLAUDE_DIR/$dir"
[ ! -d "$src" ] && echo " SKIP: $dir/" && continue
# Remove existing
if [ -L "$dst" ]; then
rm "$dst"
elif [ -d "$dst" ]; then
rm -rf "$dst"
fi
ln -s "$src" "$dst"
echo " SYMLINK: $dir/ -> $src"
done
# Validation
echo ""
echo "Validating..."
for file in CLAUDE.md settings.json; do
dst="$CLAUDE_DIR/$file"
if [ -f "$dst" ] && [ -s "$dst" ]; then
echo " OK: $file readable"
else
echo " FAIL: $file"
fi
done
for dir in skills rules; do
dst="$CLAUDE_DIR/$dir"
if [ -d "$dst" ]; then
count=$(find "$dst" -type f | wc -l)
echo " OK: $dir/ ($count files)"
else
echo " FAIL: $dir/"
fi
done
echo ""
echo "Installation complete!"