- pre-compact-backup.sh: derive transcript path from session_id+cwd (no longer relies on transcript_path field that Claude Code stopped providing); register each backup in tracking.json after saving - extract-transcripts.py: new script managing tracking.json — register, list, extract conversation text, mark-processed modes - list-transcripts-here.sh: thin wrapper for extract-transcripts --list using $(pwd); needed because SKILL.md bang commands reject $() substitution - install-hooks.sh: now also symlinks skill-helper scripts into ~/.claude/scripts/ via a curated SKILL_HELPERS list - Memory docs: new script-extract-transcripts.md, script-list-transcripts-here.md; updated skill-log.md, script-install-hooks.md, MEMORY.md index Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
79 lines
2.7 KiB
Bash
Executable File
79 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Symlink all hooks from claude-foundations/hooks/ into ~/.claude/hooks/,
|
|
# and symlink skill-helper scripts from claude-foundations/scripts/ into ~/.claude/scripts/.
|
|
# Prints the settings.json configuration to add for hooks.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
HOOKS_SRC="$(cd "$SCRIPT_DIR/../hooks" && pwd)"
|
|
HOOKS_DST="$HOME/.claude/hooks"
|
|
SCRIPTS_DST="$HOME/.claude/scripts"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Hooks
|
|
# ---------------------------------------------------------------------------
|
|
mkdir -p "$HOOKS_DST"
|
|
echo "Installing hooks: $HOOKS_SRC → $HOOKS_DST"
|
|
for HOOK in "$HOOKS_SRC"/*.sh; do
|
|
NAME="$(basename "$HOOK")"
|
|
ln -sf "$HOOK" "$HOOKS_DST/$NAME"
|
|
echo " ✓ $NAME"
|
|
done
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Skill-helper scripts (scripts that skills reference via ~/.claude/scripts/)
|
|
# Not all claude-foundations scripts go here — only the ones used by skills.
|
|
# ---------------------------------------------------------------------------
|
|
mkdir -p "$SCRIPTS_DST"
|
|
echo ""
|
|
echo "Installing skill-helper scripts: $SCRIPT_DIR → $SCRIPTS_DST"
|
|
SKILL_HELPERS=(
|
|
"extract-transcripts.py"
|
|
"list-transcripts-here.sh"
|
|
)
|
|
for SCRIPT in "${SKILL_HELPERS[@]}"; do
|
|
SRC="$SCRIPT_DIR/$SCRIPT"
|
|
if [ -f "$SRC" ]; then
|
|
ln -sf "$SRC" "$SCRIPTS_DST/$SCRIPT"
|
|
echo " ✓ $SCRIPT"
|
|
else
|
|
echo " ✗ $SCRIPT (not found at $SRC)"
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo "Done. Ensure your ~/.claude/settings.json (and profile settings.json files) include:"
|
|
echo ""
|
|
cat <<'EOF'
|
|
{
|
|
"hooks": {
|
|
"PreCompact": [
|
|
{
|
|
"matcher": "auto",
|
|
"hooks": [{ "type": "command", "command": "~/.claude/hooks/pre-compact-backup.sh", "timeout": 15, "statusMessage": "Backing up transcript before compaction..." }]
|
|
},
|
|
{
|
|
"matcher": "manual",
|
|
"hooks": [{ "type": "command", "command": "~/.claude/hooks/pre-compact-backup.sh", "timeout": 15, "statusMessage": "Backing up transcript before compaction..." }]
|
|
}
|
|
],
|
|
"PostToolUse": [
|
|
{
|
|
"matcher": "Edit|Write|MultiEdit",
|
|
"hooks": [{ "type": "command", "command": "~/.claude/hooks/post-edit-lint.sh", "timeout": 30, "statusMessage": "Formatting and linting..." }]
|
|
}
|
|
],
|
|
"PreToolUse": [
|
|
{
|
|
"matcher": "ExitPlanMode",
|
|
"hooks": [{ "type": "command", "command": "~/.claude/hooks/require-plan-file.sh" }]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
EOF
|
|
echo ""
|
|
echo "Note: hooks are referenced as ~/.claude/hooks/ (default profile path) in all profile settings.json files."
|
|
echo "Note: skill-helper scripts are installed to ~/.claude/scripts/ only — profiles reference this shared path."
|