Files
roboco/docker/scripts/fable-prompt-nudge-hook.sh
Renn F 7716830322 feat(fleet): opus-fable adoption — doctrine + discipline hooks (v0.18.0 A)
Fleet behaves more like Fable 5 on existing model tiers, behind
ROBOCO_FABLE_MODE_ENABLED (config default off; armed :-true on the NAS compose,
absent from the registry compose).

- Doctrine: vendored agents/prompts/doctrine/fable.md composed into every
  agent's system prompt via fable_doctrine_layer() after base.md.
- Hooks (Claude Code): 4 non-overlapping hooks (stop-gate/bash-discipline/
  honesty-nudge/precompact) appended per-agent via _fable_hook_groups(). The
  make-quality + lint-suppression duplicates are deliberately NOT added (already
  gate-enforced); session-start skipped.
- Hooks (grok): conservative V1 — only the non-denying honesty-nudge, since a
  grok hook deny cancels the whole run.
- Flag on the feature-flags card; hook scripts shipped into the agent image.

Flag-off spawn path proven byte-identical (worktree diff, sha256 match); full
suite green (2074 unit + e2e-smoke + hook harness), mypy/xenon/ruff clean.
Fixed a real stdin bug in the vendored stop-gate hook (heredoc + pipe both
claimed stdin). Distilled from rennf93/opus-fable-playbook (MIT).
2026-07-04 06:44:40 +02:00

36 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Fable doctrine nudge on UserPromptSubmit: a question-shape heuristic picks
# an assess-only reminder vs generic Fable reminders. Ported from
# opus-fable-playbook hooks/prompt-nudge.sh (v0.1.3) — see
# docs/superpowers/plans/2026-07-04-v0.18.0-A-opus-fable-plan.md.
# Non-blocking: plain stdout is surfaced to the model as context.
# Fail-open: any internal error => exit 0 silent.
set -u
INPUT="$(cat)" || exit 0
PROMPT="$(printf '%s' "$INPUT" | python3 -c \
'import json,sys; print(json.load(sys.stdin).get("prompt",""))' 2>/dev/null || true)"
[ -z "$PROMPT" ] && exit 0
case "$PROMPT" in /*) exit 0 ;; esac
TRIMMED="$(printf '%s' "$PROMPT" | sed 's/[[:space:]]*$//')"
FIRST="$(printf '%s' "$PROMPT" | awk '{print tolower($1); exit}')"
LOWER="$(printf '%s' "$TRIMMED" | tr '[:upper:]' '[:lower:]')"
case "$TRIMMED" in *\?) Q=1 ;; *) Q=0 ;; esac
case "$FIRST" in
why|what|how|is|does|should|can|are|do|where|when|who|which) Q=1 ;;
esac
case "$LOWER" in
# imperative-investigate-then-report prompts ("run the tests and tell
# me where this project stands") are assess-only even though they
# don't start with a question word or end in "?".
*where*stand*) Q=1 ;;
esac
if [ "${Q:-0}" = "1" ]; then
printf 'This prompt is question-shaped: deliver your assessment; do not change code unless asked.'
else
printf 'Fable reminders: lead the final message with the outcome; finish work instead of narrating it; parallelize independent tool calls; delegate broad searches.'
fi
printf '\n'
exit 0