Source index · Technical reference · Home

UNRELEASED DEVELOPMENT SNAPSHOT · READ-ONLY EXCERPT

hooks/shared/session-digest/run.sh

This is the cited technical source at local revision 275a354, inspected on 22 September 2026. It differs from the public release. This reference publishes only the cited sections, not an installable release or the development branch.

Line numbers refer to the complete recorded file. Uncited lines are omitted. Full-file SHA-256: 4cf8a65b86206a4c23da5c6072ae2a58cdcba39ddd6a2a7a1e1a2fc30452f22f.

1#!/usr/bin/env bash
2# session-digest — Lintel SessionStart hook (v4.8, ADR-0002)
3# Injects a compact memory digest into a fresh Claude Code session.
4# Fail-open: any error or empty digest → exit 0 with no output (never blocks a session).
6set -uo pipefail
8LINTEL_HOME="${LINTEL_HOME:-$HOME/.lintel}"
10# Operator override
11[ -f "$LINTEL_HOME/.digest-disabled" ] && exit 0
12[ -n "${NO_DIGEST:-}" ] && exit 0
14# Repo root (for tasks/, docs/). Outside a repo → still emit profile/jobs.
15REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
… omitted uncited lines …
21 [ -f "$1" ] || return 0
22 grep -E "^[[:space:]]*$2:" "$1" 2>/dev/null | head -1 \
23 | sed -E "s/^[[:space:]]*$2:[[:space:]]*//; s/[[:space:]]*#.*$//" | tr -d '"' | tr -d "'" \
24 | sed 's/[[:space:]]*$//'
27# ── gather (each section optional) ───────────────────────────────────────────
28lines=""
29add() { lines="${lines}$1"$'\n'; }
31# Identity from profile (+ optional compliance.mode via pack-resolver)
32pack="$(_yaml "$PROFILE" active_pack)"; pack="${pack:-_default}"
33mode="$(_yaml "$PROFILE" default_mode)"; mode="${mode:-internal-tool}"
34role="$(_yaml "$PROFILE" role_active)"; role="${role:-none}"
35compliance=""
36# Source order (ADR-0008 security): own tree (plugin cache / installed copy) FIRST —
37# auto-registration means this hook runs in EVERY repo, including untrusted ones;
38# never execute repo-supplied code from a SessionStart hook.
39_resolver="$(dirname "${BASH_SOURCE[0]}")/../../../lib/pack-resolver.sh"
40[ -f "$_resolver" ] || _resolver="$LINTEL_HOME/lib/pack-resolver.sh"
41if [ -f "$_resolver" ]; then
42 compliance="$( ( source "$_resolver" 2>/dev/null && resolve_pack_field compliance.mode 2>/dev/null ) | tr -d '[:space:]' )"
43fi
44[ -n "$compliance" ] && compliance=" · compliance: $compliance"
45add "Pack: ${pack} · mode: ${mode} · role: ${role}${compliance}"