2026-04-27 13:20:51 -05:00
|
|
|
#!/bin/bash
|
2026-05-06 02:22:24 -05:00
|
|
|
# synthesis-gate.sh — optional UserPromptSubmit hook
|
2026-04-27 13:20:51 -05:00
|
|
|
#
|
2026-05-06 02:22:24 -05:00
|
|
|
# Injects a compact synthesis contract for decision-adjacent prompts. The hook
|
|
|
|
|
# is intentionally generic and public-safe: it does not depend on private local
|
|
|
|
|
# files, personal examples, or hidden project notes.
|
2026-04-27 13:20:51 -05:00
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
INPUT="$(cat)"
|
|
|
|
|
PROMPT="$(printf '%s' "$INPUT" | /usr/bin/python3 -c 'import sys,json;d=json.load(sys.stdin);print(d.get("prompt","") or d.get("user_prompt",""))' 2>/dev/null || printf '')"
|
|
|
|
|
|
2026-05-06 02:22:24 -05:00
|
|
|
DECISION_REGEX='(submit|submission|final|ship|launch|deploy|commit|decide|decision|recommend|should i|what should|purchase|buy|invest|architect|architecture|strategy|prep|prioriti|compose|tradeoff|trade-off|config|which (should|model|approach|one)|pick|choose|benchmark|competition|perform)'
|
2026-04-27 13:20:51 -05:00
|
|
|
|
|
|
|
|
if printf '%s' "$PROMPT" | /usr/bin/grep -qiE "$DECISION_REGEX"; then
|
|
|
|
|
/usr/bin/python3 <<'PYEOF'
|
|
|
|
|
import json
|
2026-05-06 02:22:24 -05:00
|
|
|
|
2026-04-27 13:20:51 -05:00
|
|
|
msg = (
|
2026-05-06 02:22:24 -05:00
|
|
|
"[VESTIGE SYNTHESIS GATE]\n\n"
|
|
|
|
|
"This prompt appears decision-adjacent. If Vestige is available and relevant, use the smallest retrieval plan that can change the answer.\n\n"
|
|
|
|
|
"Reasoning contract:\n"
|
|
|
|
|
"1. Retrieve evidence from adjacent topics, not only the exact topic.\n"
|
|
|
|
|
"2. Convert each useful memory into: fact -> implication -> action.\n"
|
|
|
|
|
"3. Surface contradictions or stale memories before recommending.\n"
|
|
|
|
|
"4. Do not list memory summaries as the final answer. Compose them into a concrete recommendation.\n"
|
|
|
|
|
"5. If no memory materially changes the answer, say so briefly and proceed from source evidence."
|
2026-04-27 13:20:51 -05:00
|
|
|
)
|
2026-05-06 02:22:24 -05:00
|
|
|
|
2026-04-27 13:20:51 -05:00
|
|
|
print(json.dumps({
|
|
|
|
|
"hookSpecificOutput": {
|
|
|
|
|
"hookEventName": "UserPromptSubmit",
|
|
|
|
|
"additionalContext": msg
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
PYEOF
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exit 0
|