-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
45 lines (39 loc) · 1.35 KB
/
Copy pathinstall.sh
File metadata and controls
45 lines (39 loc) · 1.35 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
#!/usr/bin/env bash
# Installs ai-codekeep into a project's .claude/ directory (or globally with --global).
# Usage: ./install.sh [--global] [--hook]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GLOBAL=false
HOOK=false
for arg in "$@"; do
case "$arg" in
--global) GLOBAL=true ;;
--hook) HOOK=true ;;
*) echo "unknown flag: $arg" >&2; exit 1 ;;
esac
done
if [ "$GLOBAL" = true ]; then
TARGET="$HOME/.claude"
else
TARGET="$(pwd)/.claude"
fi
mkdir -p "$TARGET/skills" "$TARGET/commands" "$TARGET/ai-codekeep/bin"
cp -r "$SCRIPT_DIR/skills/ai-codekeep" "$TARGET/skills/ai-codekeep"
cp "$SCRIPT_DIR/commands/"*.md "$TARGET/commands/"
cp "$SCRIPT_DIR/bin/ledger.mjs" "$TARGET/ai-codekeep/bin/ledger.mjs"
echo "ai-codekeep installed into $TARGET"
echo "run: node $TARGET/ai-codekeep/bin/ledger.mjs mode standard (from inside your project's git repo)"
if [ "$HOOK" = true ]; then
if [ ! -d .git ]; then
echo "no .git directory here — skipping hook install (run --hook from the repo you want tracked)" >&2
exit 0
fi
HOOK_PATH=".git/hooks/post-commit"
LEDGER_PATH="$TARGET/ai-codekeep/bin/ledger.mjs"
{
echo "#!/usr/bin/env bash"
echo "node \"$LEDGER_PATH\" update --commit HEAD >/dev/null 2>&1 || true"
} >> "$HOOK_PATH"
chmod +x "$HOOK_PATH"
echo "post-commit hook installed at $HOOK_PATH"
fi