Cloudflare Git

Repos/herdr-appPublic

main
33 lines · 1.2 KB · ExecutableRaw
#!/bin/bash
# Copies this repo's keys, layouts, mods and agent hook into place, then checks the mods.
# Run it after every change; the Herdr app reloads within a second.
set -euo pipefail
cd "$(dirname "$0")"
home=${HERDR_APP_HOME:-$HOME/.config/herdr-app}
claude=${CLAUDE_CONFIG_DIR:-$HOME/.claude}

cp keys/keys.json "$home/"
cp layouts/*.json "$home/layouts/"
mkdir -p "$home/themes"
cp themes/*.json "$home/themes/"
for m in mods/*/; do
    mkdir -p "$home/$m"
    cp -R "$m". "$home/$m"
    herdr-app check "$home/$m"
done

mkdir -p "$claude/hooks"
cp hooks/herdr-activity.sh "$claude/hooks/"

# Register the hook on UserPromptSubmit and Stop, once, for Claude Code and (if installed) Codex.
register() {
    [[ -f "$1" ]] || echo '{}' > "$1"
    jq '{"type": "command", "command": "bash ~/.claude/hooks/herdr-activity.sh", "timeout": 60, "async": true} as $h
        | reduce ("UserPromptSubmit", "Stop") as $e (.;
            if any(.hooks[$e][]?.hooks[]?; .command == $h.command) then . else .hooks[$e] += [{"hooks": [$h]}] end)' \
        "$1" > "$1.tmp" && mv "$1.tmp" "$1"
}
register "$claude/settings.json"
codex=${CODEX_HOME:-$HOME/.codex}
[[ -d "$codex" ]] && register "$codex/hooks.json"
echo "installed"