#!/usr/bin/env bash
# preference-consult-directive — UserPromptSubmit hook. Injects a standing line
# naming the two-layer preference architecture and two adherence directives:
# consult layer-2 preferences (profile-read) before any customer document, and
# promote finished deliverables out of output/. Prompt-independent; fail-open.
set -uo pipefail
HOOK_INPUT=$(cat 2>/dev/null || true)
command -v python3 >/dev/null 2>&1 || exit 0
python3 - <<'PY' 2>/dev/null || exit 0
import json
ctx = (
"<preference-adherence>\n"
"Your preferences live in two layers. Layer 1 is the fixed block already in front of you every turn. "
"Layer 2 is the account's own saved records, read with profile-read; it holds the signature policy, header, "
"naming conventions and styling that layer 1 does not, and it grows over time. Before any customer-facing "
"document deliverable (a PDF or file sent to the customer, or an email or Outlook message carrying an "
"attachment), read the relevant layer-2 preferences with profile-read and apply them. "
"Store finished deliverables under documents/ or the project folder. output/ is scratch of last resort, "
"rebuilt on the next tool write, and never the home a graph reference points at.\n"
"</preference-adherence>"
)
print(json.dumps({"hookSpecificOutput": {"hookEventName": "UserPromptSubmit", "additionalContext": ctx}}))
PY
echo "[pref-wrapper] op=inject" >&2
exit 0
