ifcurl/.claude/hooks/session-start.sh
Claude 8693bb5c90
.claude: add SessionStart hook to install bd and bootstrap beads
Installs bd (beads issue tracker) via go install and bootstraps the
embedded Dolt database from the git-tracked issues.jsonl on each fresh
web session, where the embeddeddolt/ directory is absent.

Bootstrap sequence:
  1. go install github.com/steveyegge/beads/cmd/bd@latest (if absent)
  2. Temporarily point sync.remote to the HTTP git origin so bootstrap
     can create the embedded Dolt schema (Dolt wire-protocol clone fails
     over HTTP/1.1 but that is expected and handled)
  3. Restore .beads/config.yaml and .beads/issues.jsonl from git before
     any bd auto-export can overwrite them
  4. bd config set issue_prefix ifcurl triggers auto-import of the full
     issues.jsonl into the initialised but empty database

Also adds bd to PATH via CLAUDE_ENV_FILE and sets beads.role=contributor
to suppress the role-not-configured warning.

https://claude.ai/code/session_01CKpkhWhzkzR5K5PDSR8N5F
2026-05-09 07:55:30 +00:00

43 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
if [ "${CLAUDE_CODE_REMOTE:-}" != "true" ]; then
exit 0
fi
# Install Python project and dev dependencies
pip install -e "." -q
pip install pytest ruff -q
# Install bd (beads issue tracker) if not present
GOPATH=$(go env GOPATH)
BD="$GOPATH/bin/bd"
if [ ! -x "$BD" ]; then
CGO_ENABLED=1 GOFLAGS=-tags=gms_pure_go \
go install github.com/steveyegge/beads/cmd/bd@latest
fi
# Make bd available as 'bd' in the session
if [ -n "${CLAUDE_ENV_FILE:-}" ]; then
echo "export PATH=\"\$PATH:$GOPATH/bin\"" >> "$CLAUDE_ENV_FILE"
fi
# Suppress beads.role warning for agent sessions
git config beads.role contributor 2>/dev/null || true
# Bootstrap beads database from git-tracked issues.jsonl if not already present.
# In fresh web sessions the embedded Dolt directory is absent (not tracked by git).
# The bootstrap sequence:
# 1. Point sync.remote to the HTTP git origin so bootstrap can create the db schema
# (the Dolt wire-protocol clone will fail over HTTP/1.1 but that is expected)
# 2. Run bootstrap — creates an initialised but empty embedded Dolt database
# 3. Restore git-tracked files before any bd auto-export can overwrite them
# 4. Trigger auto-import: bd detects missing issue_prefix and loads issues.jsonl
if ! "$BD" ready > /dev/null 2>&1; then
rm -rf .beads/embeddeddolt
ORIGIN_URL=$(git remote get-url origin)
"$BD" config set sync.remote "$ORIGIN_URL" 2>/dev/null || true
BD_NON_INTERACTIVE=1 "$BD" bootstrap 2>/dev/null || true
git checkout HEAD -- .beads/config.yaml .beads/issues.jsonl 2>/dev/null || true
"$BD" config set issue_prefix ifcurl 2>/dev/null || true
fi